examples/ForumNokia/Symbian_OS_Basics_Lab_Exercises_v3_1/Lab_04307.cb1/starter/src/S60ResourceLabContainer.cpp

00001 // Copyright (c) 2006 Nokia Corporation.
00002 
00003 // INCLUDE FILES
00004 #include "S60ResourceLabContainer.h"
00005 #include <S60ResourceLab.rsg>
00006 
00007 #include <eiklabel.h>  // for example label control
00008 #include <coemain.h>   // for CCoeEnv
00009 
00010 // ================= MEMBER FUNCTIONS =======================
00011 
00012 _LIT(KTextHello, "Hello");
00013 _LIT(KTextWorld, "World!");
00014 // ---------------------------------------------------------
00015 // CS60ResourceLabContainer::ConstructL(const TRect& aRect)
00016 // EPOC two phased constructor
00017 // ---------------------------------------------------------
00018 //
00019 void CS60ResourceLabContainer::ConstructL(const TRect& aRect)
00020     {
00021     CreateWindowL();
00022 
00023     iLabel = new (ELeave) CEikLabel;
00024     iLabel->SetContainerWindowL( *this );
00025     iLabel->SetTextL(KTextHello);
00026 
00027     iToDoLabel = new (ELeave) CEikLabel;
00028     iToDoLabel->SetContainerWindowL( *this );
00029     iToDoLabel->SetTextL(KTextWorld);
00030 
00031     SetRect(aRect);
00032     ActivateL();
00033     }
00034 
00035 // Destructor
00036 CS60ResourceLabContainer::~CS60ResourceLabContainer()
00037     {
00038     delete iLabel;
00039     delete iToDoLabel;
00040     }
00041 
00042 void CS60ResourceLabContainer::GoodbyeL()
00043     {
00044     HBufC* goodbye = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_GOODBYE);
00045     iLabel->SetTextL(*goodbye);
00046     HBufC* everyone = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_EVERYONE);
00047     iToDoLabel->SetTextL(*everyone);
00048     CleanupStack::PopAndDestroy(2);
00049     }
00050 
00051 // ---------------------------------------------------------
00052 // CS60ResourceLabContainer::SizeChanged()
00053 // Called by framework when the view size is changed
00054 // ---------------------------------------------------------
00055 //
00056 void CS60ResourceLabContainer::SizeChanged()
00057     {
00058     // Set the postion of the labels and reserve 
00059     // a minimum size for expansion
00060     //iLabel->SetExtent(TPoint(60, 50), TSize(100, 15));
00061     //iToDoLabel->SetExtent(TPoint(60, 80), TSize(100, 15));
00062     iLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
00063     iToDoLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
00064     }
00065 
00066 // ---------------------------------------------------------
00067 // CS60ResourceLabContainer::CountComponentControls() const
00068 // ---------------------------------------------------------
00069 //
00070 TInt CS60ResourceLabContainer::CountComponentControls() const
00071     {
00072     return 2; // return nbr of controls inside this container
00073     }
00074 
00075 // ---------------------------------------------------------
00076 // CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
00077 // ---------------------------------------------------------
00078 //
00079 CCoeControl* CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
00080     {
00081     switch ( aIndex )
00082         {
00083         case 0:
00084             return iLabel;
00085         case 1:
00086             return iToDoLabel;
00087         default:
00088             return NULL;
00089         }
00090     }
00091 
00092 // ---------------------------------------------------------
00093 // CS60ResourceLabContainer::Draw(const TRect& aRect) const
00094 // ---------------------------------------------------------
00095 //
00096 void CS60ResourceLabContainer::Draw(const TRect& aRect) const
00097     {
00098     CWindowGc& gc = SystemGc();
00099     
00100     gc.SetPenStyle(CGraphicsContext::ENullPen);
00101     gc.SetBrushColor(KRgbGray);
00102     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00103     gc.DrawRect(aRect);
00104     }
00105 
00106 // ---------------------------------------------------------
00107 // CS60ResourceLabContainer::HandleControlEventL(
00108 //     CCoeControl* aControl,TCoeEvent aEventType)
00109 // ---------------------------------------------------------
00110 //
00111 void CS60ResourceLabContainer::HandleControlEventL(
00112     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
00113     {
00114     }
00115 
00116 // End of File  

Generated by  doxygen 1.6.2