00001
00002
00003
00004 #include "S60MemoryLabContainer.h"
00005 #include <eiklabel.h>
00006 #include <eikappui.h>
00007
00008
00009
00010
00011
00012
00013
00014
00015 _LIT(KTextExtremelyLongLabel, "Extremely Long Label");
00016 _LIT(KTextVeryLongLabel, "Very Long Label");
00017 _LIT(KTextLongLabel, "Long Label");
00018 _LIT(KTextLabel, "Label");
00019 _LIT(KTextCleanupStackTest, "Cleanup Stack Test");
00020
00021
00022 void CS60MemoryLabContainer::ConstructL(const TRect& aRect)
00023 {
00024 CreateWindowL();
00025
00026
00027
00028
00029 iTopLabel = new (ELeave) CEikLabel;
00030 iTopLabel->SetContainerWindowL(*this);
00031 iTopLabel->SetTextL(KTextLabel);
00032
00033 iBottomLabel = new (ELeave) CEikLabel;
00034 iBottomLabel->SetContainerWindowL( *this );
00035 iBottomLabel->SetTextL(KTextLongLabel);
00036
00037 SetRect(aRect);
00038 ActivateL();
00039 }
00040
00041
00042 CS60MemoryLabContainer::~CS60MemoryLabContainer()
00043 {
00044 delete iTopLabel;
00045 delete iBottomLabel;
00046 }
00047
00048 void CS60MemoryLabContainer::ToggleLabelsL()
00049 {
00050 if (iToggleFlag)
00051 {
00052 iTopLabel->SetTextL(KTextLabel);
00053 iBottomLabel->SetTextL(KTextLongLabel);
00054 }
00055 else
00056 {
00057
00058
00059
00060
00061
00062 iTopLabel->SetTextL(KTextVeryLongLabel);
00063
00064
00065 iBottomLabel->SetTextL(KTextExtremelyLongLabel);
00066 }
00067 iToggleFlag = !iToggleFlag;
00068 }
00069
00070 void CS60MemoryLabContainer::CleanupStackTestL()
00071 {
00072
00073 HBufC* labelText = HBufC::NewL(KTextCleanupStackTest().Length());
00074
00075
00076
00077
00078 *labelText = KTextCleanupStackTest;
00079
00080
00081 iBottomLabel->SetTextL(*labelText);
00082
00083 delete labelText;
00084 }
00085
00086
00087
00088
00089
00090
00091
00092 void CS60MemoryLabContainer::SizeChanged()
00093 {
00094
00095
00096 TRect rect = Rect();
00097
00098 iTopLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
00099 iBottomLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
00100 }
00101
00102
00103
00104
00105
00106 TInt CS60MemoryLabContainer::CountComponentControls() const
00107 {
00108 return 2;
00109 }
00110
00111
00112
00113
00114
00115 CCoeControl* CS60MemoryLabContainer::ComponentControl(TInt aIndex) const
00116 {
00117 switch ( aIndex )
00118 {
00119 case 0:
00120 return iTopLabel;
00121 case 1:
00122 return iBottomLabel;
00123 default:
00124 return NULL;
00125 }
00126 }
00127
00128
00129
00130
00131
00132 void CS60MemoryLabContainer::Draw(const TRect& aRect) const
00133 {
00134 CWindowGc& gc = SystemGc();
00135
00136 gc.SetPenStyle(CGraphicsContext::ENullPen);
00137 gc.SetBrushColor(KRgbGray);
00138 gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00139 gc.DrawRect(aRect);
00140 }
00141
00142
00143
00144
00145
00146
00147 void CS60MemoryLabContainer::HandleControlEventL(
00148 CCoeControl* ,TCoeEvent )
00149 {
00150
00151 }
00152
00153