S60ResourceLabContainer.cpp
上传用户:laixiong
上传日期:2007-03-11
资源大小:2994k
文件大小:4k
源码类别:

Symbian

开发平台:

C/C++

  1. // Copyright (c) 2006 Nokia Corporation.
  2. // INCLUDE FILES
  3. #include "S60ResourceLabContainer.h"
  4. #include <S60ResourceLab.rsg>
  5. #include <eiklabel.h>  // for example label control
  6. #include <coemain.h>   // for CCoeEnv
  7. // ================= MEMBER FUNCTIONS =======================
  8. _LIT(KTextHello, "Hello");
  9. _LIT(KTextWorld, "World!");
  10. // ---------------------------------------------------------
  11. // CS60ResourceLabContainer::ConstructL(const TRect& aRect)
  12. // EPOC two phased constructor
  13. // ---------------------------------------------------------
  14. //
  15. void CS60ResourceLabContainer::ConstructL(const TRect& aRect)
  16.     {
  17.     CreateWindowL();
  18.     iLabel = new (ELeave) CEikLabel;
  19.     iLabel->SetContainerWindowL( *this );
  20.     iLabel->SetTextL(KTextHello);
  21.     iToDoLabel = new (ELeave) CEikLabel;
  22.     iToDoLabel->SetContainerWindowL( *this );
  23.     iToDoLabel->SetTextL(KTextWorld);
  24.     SetRect(aRect);
  25.     ActivateL();
  26.     }
  27. // Destructor
  28. CS60ResourceLabContainer::~CS60ResourceLabContainer()
  29.     {
  30.     delete iLabel;
  31.     delete iToDoLabel;
  32.     }
  33. void CS60ResourceLabContainer::GoodbyeL()
  34.     {
  35.     HBufC* goodbye = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_GOODBYE);
  36.     iLabel->SetTextL(*goodbye);
  37.     HBufC* everyone = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_EVERYONE);
  38.     iToDoLabel->SetTextL(*everyone);
  39.     CleanupStack::PopAndDestroy(2);
  40.     }
  41. // ---------------------------------------------------------
  42. // CS60ResourceLabContainer::SizeChanged()
  43. // Called by framework when the view size is changed
  44. // ---------------------------------------------------------
  45. //
  46. void CS60ResourceLabContainer::SizeChanged()
  47.     {
  48.     // Set the postion of the labels and reserve 
  49.     // a minimum size for expansion
  50.     //iLabel->SetExtent(TPoint(60, 50), TSize(100, 15));
  51.     //iToDoLabel->SetExtent(TPoint(60, 80), TSize(100, 15));
  52.     iLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
  53.     iToDoLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
  54.     }
  55. // ---------------------------------------------------------
  56. // CS60ResourceLabContainer::CountComponentControls() const
  57. // ---------------------------------------------------------
  58. //
  59. TInt CS60ResourceLabContainer::CountComponentControls() const
  60.     {
  61.     return 2; // return nbr of controls inside this container
  62.     }
  63. // ---------------------------------------------------------
  64. // CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
  65. // ---------------------------------------------------------
  66. //
  67. CCoeControl* CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
  68.     {
  69.     switch ( aIndex )
  70.         {
  71.         case 0:
  72.             return iLabel;
  73.         case 1:
  74.             return iToDoLabel;
  75.         default:
  76.             return NULL;
  77.         }
  78.     }
  79. // ---------------------------------------------------------
  80. // CS60ResourceLabContainer::Draw(const TRect& aRect) const
  81. // ---------------------------------------------------------
  82. //
  83. void CS60ResourceLabContainer::Draw(const TRect& aRect) const
  84.     {
  85.     CWindowGc& gc = SystemGc();
  86.     
  87.     gc.SetPenStyle(CGraphicsContext::ENullPen);
  88.     gc.SetBrushColor(KRgbGray);
  89.     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  90.     gc.DrawRect(aRect);
  91.     }
  92. // ---------------------------------------------------------
  93. // CS60ResourceLabContainer::HandleControlEventL(
  94. //     CCoeControl* aControl,TCoeEvent aEventType)
  95. // ---------------------------------------------------------
  96. //
  97. void CS60ResourceLabContainer::HandleControlEventL(
  98.     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
  99.     {
  100.     }
  101. // End of File