examples/SFExamples/RecipeEx/src/MainViewContainer.cpp

00001 // Symbian Foundation Example Code
00002 // 
00003 // This software is in the public domain. No copyright is claimed, and you 
00004 // may use it for any purpose without license from the Symbian Foundation.
00005 // No warranty for any purpose is expressed or implied by the authors or
00006 // the Symbian Foundation. 
00007 
00008 
00009 // Include Files
00010 #include <aknutils.h> 
00011 
00012 #include "MainViewContainer.h"
00013 
00014 // Constants
00015 _LIT(KExampleText, "RecipeEx");
00016 
00017 #include <eiklabel.h>  // for example description
00018 
00019 // ================= MEMBER FUNCTIONS =======================
00020 
00022 CMainViewContainer* CMainViewContainer::NewL(const TRect& aRect)
00023         {
00024         CMainViewContainer* self = CMainViewContainer::NewLC(aRect);
00025         CleanupStack::Pop( self );
00026         return self;    
00027         }
00028 
00030 CMainViewContainer* CMainViewContainer::NewLC(const TRect& aRect)
00031         {
00032         CMainViewContainer* self = new ( ELeave ) CMainViewContainer;
00033         CleanupStack::PushL( self );
00034         self->ConstructL(aRect);
00035         return self;    
00036         }
00037 
00039 void CMainViewContainer::ConstructL(const TRect& aRect)
00040     {
00041     CreateWindowL();
00042 
00043     iLabel = new (ELeave) CEikLabel;
00044     iLabel->SetContainerWindowL( *this );
00045     iLabel->SetTextL(KExampleText);
00046 
00047     SetRect(aRect);
00048     ActivateL();
00049     }
00050 
00052 CMainViewContainer::~CMainViewContainer()
00053     {
00054     delete iLabel;
00055     }
00056 
00061 void CMainViewContainer::SizeChanged()
00062     {
00063     // Control resize code
00064     iLabel->SetExtent( TPoint(10,10), iLabel->MinimumSize() );
00065     }
00066 
00070 TInt CMainViewContainer::CountComponentControls() const
00071     {
00072     return 1; // return nbr of controls inside this container
00073     }
00074 
00076 CCoeControl* CMainViewContainer::ComponentControl(TInt aIndex) const
00077     {
00078     switch ( aIndex )
00079         {
00080         case 0:
00081             return iLabel;
00082         default:
00083             return NULL;
00084         }
00085     }
00086 
00090 void CMainViewContainer::Draw(const TRect& aRect) const
00091     {
00092     CWindowGc& gc = SystemGc();
00093     gc.SetPenStyle(CGraphicsContext::ENullPen);
00094     gc.SetBrushColor(KRgbBlue);
00095     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00096     gc.DrawRect(aRect);
00097     }
00098 
00104 void CMainViewContainer::HandleResourceChange(TInt aType)
00105         {
00106     CCoeControl::HandleResourceChange(aType);
00107 
00108     // ADDED FOR SCALABLE UI SUPPORT
00109         TRect rect;
00110 
00111     if ( aType==KEikDynamicLayoutVariantSwitch )// layout change event
00112         {    
00113         // get new main panel rect and set it
00114         AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, rect);
00115         SetRect(rect);
00116         }
00117         }
00118 
00119 // End of File  

Generated by  doxygen 1.6.2