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.     
  22.     
  23.     iToDoLabel = new (ELeave) CEikLabel;
  24.     iToDoLabel->SetContainerWindowL( *this );
  25.     iToDoLabel->SetTextL(KTextWorld);
  26.    
  27.     
  28.     SetRect(aRect);
  29.     ActivateL();
  30.     }
  31. // Destructor
  32. CS60ResourceLabContainer::~CS60ResourceLabContainer()
  33.     {
  34.     delete iLabel;
  35.     delete iToDoLabel;
  36.     }
  37. void CS60ResourceLabContainer::GoodbyeL()
  38.     {
  39.     HBufC* goodbye = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_GOODBYE);
  40.     iLabel->SetTextL(*goodbye);
  41.     HBufC* everyone = iCoeEnv->AllocReadResourceLC(R_S60RESOURCELAB_TEXT_EVERYONE);
  42.     iToDoLabel->SetTextL(*everyone);
  43.     CleanupStack::PopAndDestroy(2);
  44.     }
  45. // ---------------------------------------------------------
  46. // CS60ResourceLabContainer::SizeChanged()
  47. // Called by framework when the view size is changed
  48. // ---------------------------------------------------------
  49. //
  50. void CS60ResourceLabContainer::SizeChanged()
  51.     {
  52.     // Set the postion of the labels and reserve 
  53.     // a minimum size for expansion
  54.     //iLabel->SetExtent(TPoint(60, 50), TSize(100, 15));
  55.     //iToDoLabel->SetExtent(TPoint(60, 80), TSize(100, 15));
  56.     iLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
  57.     iToDoLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
  58.     }
  59. // ---------------------------------------------------------
  60. // CS60ResourceLabContainer::CountComponentControls() const
  61. // ---------------------------------------------------------
  62. //
  63. TInt CS60ResourceLabContainer::CountComponentControls() const
  64.     {
  65.     return 2; // return nbr of controls inside this container
  66.     }
  67. // ---------------------------------------------------------
  68. // CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
  69. // ---------------------------------------------------------
  70. //
  71. CCoeControl* CS60ResourceLabContainer::ComponentControl(TInt aIndex) const
  72.     {
  73.     switch ( aIndex )
  74.         {
  75.         case 0:
  76.             return iLabel;
  77.         case 1:
  78.             return iToDoLabel;
  79.         default:
  80.             return NULL;
  81.         }
  82.     }
  83. // ---------------------------------------------------------
  84. // CS60ResourceLabContainer::Draw(const TRect& aRect) const
  85. // ---------------------------------------------------------
  86. //
  87. void CS60ResourceLabContainer::Draw(const TRect& aRect) const
  88.     {
  89.     CWindowGc& gc = SystemGc();
  90.     
  91.     gc.SetPenStyle(CGraphicsContext::ENullPen);
  92.     gc.SetBrushColor(KRgbGray);
  93.     gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
  94.     gc.DrawRect(aRect);
  95.     }
  96. // ---------------------------------------------------------
  97. // CS60ResourceLabContainer::HandleControlEventL(
  98. //     CCoeControl* aControl,TCoeEvent aEventType)
  99. // ---------------------------------------------------------
  100. //
  101. void CS60ResourceLabContainer::HandleControlEventL(
  102.     CCoeControl* /*aControl*/,TCoeEvent /*aEventType*/)
  103.     {
  104.     }
  105. // End of File