examples/ForumNokia/Symbian_OS_Basics_Lab_Exercises_v3_1/Lab_04307.cb1/solution/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     
00026     HBufC* hello = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_HELLO);
00027     iLabel->SetTextL(*hello);
00028 
00029     iToDoLabel = new (ELeave) CEikLabel;
00030     iToDoLabel->SetContainerWindowL( *this );
00031    
00032     HBufC* world = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_WORLD);
00033     iToDoLabel->SetTextL(*world);
00034 
00035     CleanupStack::PopAndDestroy(2);
00036 
00037     SetRect(aRect);
00038     ActivateL();
00039     }
00040 
00041 // Destructor
00042 CS60ResourceLabContainer::~CS60ResourceLabContainer()
00043     {
00044     delete iLabel;
00045     delete iToDoLabel;
00046     }
00047 
00048 void CS60ResourceLabContainer::GoodbyeL()
00049     {
00050     HBufC* goodbye = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_GOODBYE);
00051     iLabel->SetTextL(*goodbye);
00052     HBufC* everyone = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_EVERYONE);
00053     iToDoLabel->SetTextL(*everyone);
00054     CleanupStack::PopAndDestroy(2);
00055     }
00056 
00057 // ---------------------------------------------------------
00058 // CS60ResourceLabContainer::SizeChanged()
00059 // Called by framework when the view size is changed
00060 // ---------------------------------------------------------
00061 //
00062 void CS60ResourceLabContainer::SizeChanged()
00063     {
00064     // Set the postion of the labels and reserve 
00065     // a minimum size for expansion
00066     //iLabel->SetExtent(TPoint(60, 50), TSize(100, 15));
00067     //iToDoLabel->SetExtent(TPoint(60, 80), TSize(100, 15));
00068     iLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
00069     iToDoLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
00070     }
00071 
00072 // ---------------------------------------------------------
00073 // CS60ResourceLabContainer::CountComponentControls() const
00074 // ---------------------------------------------------------
00075 //
00076 TInt CS60ResourceLabContainer::CountComponentControls() const
00077     {
00078     return 2; // return nbr of controls inside this container
00079     }
00080 
00081 // ---------------------------------------------------------
00082 // CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
00083 // ---------------------------------------------------------
00084 //
00085 CCoeControl* CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
00086     {
00087     switch ( aIndex )
00088         {
00089         case 0:
00090             return iLabel;
00091         case 1:
00092             return iToDoLabel;
00093         default:
00094             return NULL;
00095         }
00096     }
00097 
00098 // ---------------------------------------------------------
00099 // CS60ResourceLabContainer::Draw(const TRect& aRect) const
00100 // ---------------------------------------------------------
00101 //
00102 void CS60ResourceLabContainer::Draw(const TRect& aRect) const
00103     {
00104     CWindowGc& gc = SystemGc();
00105     
00106     gc.SetPenStyle(CGraphicsContext::ENullPen);
00107     gc.SetBrushColor(KRgbGray);
00108     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00109     gc.DrawRect(aRect);
00110     }
00111 
00112 // ---------------------------------------------------------
00113 // CS60ResourceLabContainer::HandleControlEventL(
00114 //     CCoeControl* aControl,TCoeEvent aEventType)
00115 // ---------------------------------------------------------
00116 //
00117 void CS60ResourceLabContainer::HandleControlEventL(
00118     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
00119     {
00120     }
00121 
00122 // End of File  

Generated by  doxygen 1.6.2