📄 filefetcherappview.cpp
字号:
/*
* ============================================================================
* Name : FileFetcherAppView.cpp
* Part of : File fetching Example
* Created : 12/9/2003 by Forum Nokia
* Implementation notes:
*
*
* Version : 1.0
* Copyright: Nokia Corporation
* ============================================================================
*/
#include <coemain.h>
#include <eikenv.h>
#include <gdi.h>
#include <eiklabel.h>
#include "FileFetcher.pan"
#include "FileFetcherAppView.h"
// Control enumerations
enum TControls
{
ELabel
};
#define KBackgroundColor TRgb(160,160,160)
#define LABEL_POS TPoint(10, 5)
static const TInt KNumberOfControls = 1;
// ----------------------------------------------------------------------------
// CFileFetcherAppView::NewL()
//
// Creates instance of CFileFetcherAppView.
// ----------------------------------------------------------------------------
CFileFetcherAppView* CFileFetcherAppView::NewL(const TRect& aRect)
{
CFileFetcherAppView* self = CFileFetcherAppView::NewLC(aRect);
CleanupStack::Pop(self);
return self;
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::NewLC()
//
// Creates instance of CFileFetcherAppView.
// ----------------------------------------------------------------------------
CFileFetcherAppView* CFileFetcherAppView::NewLC(const TRect& aRect)
{
CFileFetcherAppView* self = new (ELeave) CFileFetcherAppView;
CleanupStack::PushL(self);
self->ConstructL(aRect);
return self;
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::CFileFetcherAppView()
//
// First phase construction.
// ----------------------------------------------------------------------------
CFileFetcherAppView::CFileFetcherAppView()
{
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::~CFileFetcherAppView()
//
// Destructor.
// ----------------------------------------------------------------------------
CFileFetcherAppView::~CFileFetcherAppView()
{
delete iLabel;
iLabel = NULL;
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::ConstructL()
//
// Second phase construction.
// ----------------------------------------------------------------------------
void CFileFetcherAppView::ConstructL(const TRect& aRect)
{
// Create a window for this application view
CreateWindowL();
// Create a single label on view
iLabel = new (ELeave) CEikLabel;
iLabel->SetContainerWindowL(*this);
iLabel->SetFont(iEikonEnv->AnnotationFont());
_LIT(KLabelText,
"Use menu to browse files\nby using MGFetch or\nCAknFileSelectionDialog");
iLabel->SetTextL(KLabelText);
// Set the windows size
SetRect(aRect);
// Activate the window, which makes it ready to be drawn
ActivateL();
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::Draw()
//
// Draw this application's view to the screen
// ----------------------------------------------------------------------------
void CFileFetcherAppView::Draw(const TRect& aRect) const
{
CWindowGc& gc = SystemGc();
gc.SetPenStyle( CGraphicsContext::ENullPen );
gc.SetBrushColor( KBackgroundColor );
gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
gc.DrawRect( aRect );
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::CountComponentControls()
//
// Returns number of controls in this compound control.
// ----------------------------------------------------------------------------
TInt CFileFetcherAppView::CountComponentControls() const
{
return KNumberOfControls;
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::ComponentControl()
//
// Returns pointer to control with index aIndex.
// ----------------------------------------------------------------------------
CCoeControl* CFileFetcherAppView::ComponentControl(TInt aIndex) const
{
switch(aIndex)
{
case ELabel:
return iLabel;
default:
Panic(EFileFetcherView);
return 0;
}
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::HandleControlEventL()
//
// Handles control events.
// ----------------------------------------------------------------------------
void CFileFetcherAppView::HandleControlEventL(CCoeControl* /* aControl */,
TCoeEvent /* aEventType */ )
{
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::OfferKeyEventL()
//
// Handles key events.
// ----------------------------------------------------------------------------
TKeyResponse CFileFetcherAppView::OfferKeyEventL(const TKeyEvent& /*aKeyEvent*/,
TEventCode /*aType*/)
{
return EKeyWasNotConsumed;
}
// ----------------------------------------------------------------------------
// CFileFetcherAppView::SizeChanged()
//
// Called when size of this control has changed
// ----------------------------------------------------------------------------
void CFileFetcherAppView::SizeChanged()
{
iLabel->SetExtent(LABEL_POS, iLabel->MinimumSize());
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -