S60UIExampleInitialContainer.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:5k
源码类别:
Symbian
开发平台:
C/C++
- // Copyright (c) 2006 Nokia Corporation.
- #include "S60UIExampleInitialContainer.h"
- #include "S60UIExampleModel.h"
- #include <aknViewAppUi.h>
- #include <aknutils.h>
- #include <akniconutils.h>
- #include <S60UIExample.mbg>
- #include <S60UIExample.rsg>
- #include <stringloader.h>
- #include <akntitle.h>
- #include <eikspane.h>
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::NewL()
- // Two-phased constructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialContainer* CS60UIExampleInitialContainer::NewL(
- const TRect& aRect,
- CS60UIExampleModel& aModel)
- {
- CS60UIExampleInitialContainer* self =
- CS60UIExampleInitialContainer::NewLC(aRect, aModel);
- CleanupStack::Pop(self);
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::NewLC()
- // Two-phased constructor.
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialContainer* CS60UIExampleInitialContainer::NewLC(
- const TRect& aRect,
- CS60UIExampleModel& aModel)
- {
- CS60UIExampleInitialContainer* self =
- new (ELeave) CS60UIExampleInitialContainer(aModel);
- CleanupStack::PushL(self);
- self->ConstructL(aRect);
- return self;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::CS60UIExampleInitialContainer()
- // First stage constructor
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialContainer::CS60UIExampleInitialContainer(
- CS60UIExampleModel& aModel)
- :iModel(aModel)
- {
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::ConstructL()
- // Symbian 2nd phase constructor can leave.
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialContainer::ConstructL(const TRect& aRect)
- {
- CreateWindowL();
- // Set the text string.
- iTitle = StringLoader::LoadL(R_S60UIEXAMPLE_TITLE_TEXT, iCoeEnv);
- // Draw on Title Pane
- CEikStatusPane* statusPane = iAvkonViewAppUi->StatusPane();
- CAknTitlePane* titlePane = (CAknTitlePane*)statusPane->ControlL(TUid::Uid(EEikStatusPaneUidTitle));
- titlePane ->SetTextL(*iTitle);
- // Get background graphic
- _LIT(KSvgFile,"z:\resource\apps\S60UIExample.mif");
- iBkgBitmap = AknIconUtils::CreateIconL(KSvgFile,
- EMbmS60uiexampleStart_bkg);
- SetRect(aRect);
- ActivateL();
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::~CS60UIExampleInitialContainer()
- // Destructor
- // -----------------------------------------------------------------------------
- //
- CS60UIExampleInitialContainer::~CS60UIExampleInitialContainer()
- {
- delete iBkgBitmap;
- delete iTitle;
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::SizeChanged()
- // Handles necessary size changes, in this case resizing the bitmap.
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialContainer::SizeChanged()
- {
- TRect rect = Rect();
- TInt error = AknIconUtils::SetSize(iBkgBitmap,
- rect.Size(),
- EAspectRatioNotPreserved);
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::HandleResourceChange()
- // Called by framework when screen size changes. Use to cause necessary
- // resizing to be performed.
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialContainer::HandleResourceChange(TInt aType)
- {
- CCoeControl::HandleResourceChange(aType);
- if (aType == KEikDynamicLayoutVariantSwitch)
- {
- // Screen size has changed. Get the new Main Pane size
- TRect rect;
- AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
- // Pass it on. Eventually SizeChanged() performs the necessary
- // resizing
- SetRect(rect);
- }
- }
- // -----------------------------------------------------------------------------
- // CS60UIExampleInitialContainer::Draw() const
- // Draws the display
- // -----------------------------------------------------------------------------
- //
- void CS60UIExampleInitialContainer::Draw(const TRect& aRect) const
- {
- CWindowGc& gc = SystemGc();
- // draw the background
- gc.BitBlt(TPoint(0,0), iBkgBitmap);
- // Overlay the title
- gc.SetPenStyle(CGraphicsContext::ESolidPen);
- gc.SetPenColor(KRgbBlack);
- gc.UseFont(AknLayoutUtils::FontFromId(EAknLogicalFontTitleFont));
- TPoint textPos(aRect.iBr.iX/3, aRect.iBr.iY/3);
- gc.DrawText(*iTitle, textPos);
- gc.DiscardFont();
- }
- // End of File