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 TRAPD(
00063 error,
00064 iTopLabel->SetTextL(KTextVeryLongLabel);
00065
00066 User::Leave(KErrNoMemory);
00067 iBottomLabel->SetTextL(KTextExtremelyLongLabel);
00068 );
00069
00070 if (error != KErrNone)
00071 {
00072
00073
00074
00075 iTopLabel->SetTextL(KTextLabel);
00076
00077 User::Leave(error);
00078 }
00079 }
00080 iToggleFlag = !iToggleFlag;
00081 }
00082
00083 void CS60MemoryLabContainer::CleanupStackTestL()
00084 {
00085
00086 HBufC* labelText = HBufC::NewL(KTextCleanupStackTest().Length());
00087
00088
00089
00090
00091 CleanupStack::PushL(labelText);
00092 *labelText = KTextCleanupStackTest;
00093
00094 User::Leave(KErrNoMemory);
00095 iBottomLabel->SetTextL(*labelText);
00096
00097 CleanupStack::PopAndDestroy();
00098 }
00099
00100
00101
00102
00103
00104
00105
00106 void CS60MemoryLabContainer::SizeChanged()
00107 {
00108
00109
00110 TRect rect = Rect();
00111
00112 iTopLabel->SetExtent( TPoint(0,0), TSize(Rect().Width(), Rect().Height()/2));
00113 iBottomLabel->SetExtent( TPoint(0,Rect().Height()/2), TSize(Rect().Width(),Rect().Height()/2));
00114 }
00115
00116
00117
00118
00119
00120 TInt CS60MemoryLabContainer::CountComponentControls() const
00121 {
00122 return 2;
00123 }
00124
00125
00126
00127
00128
00129 CCoeControl* CS60MemoryLabContainer::ComponentControl(TInt aIndex) const
00130 {
00131 switch ( aIndex )
00132 {
00133 case 0:
00134 return iTopLabel;
00135 case 1:
00136 return iBottomLabel;
00137 default:
00138 return NULL;
00139 }
00140 }
00141
00142
00143
00144
00145
00146 void CS60MemoryLabContainer::Draw(const TRect& aRect) const
00147 {
00148 CWindowGc& gc = SystemGc();
00149
00150 gc.SetPenStyle(CGraphicsContext::ENullPen);
00151 gc.SetBrushColor(KRgbGray);
00152 gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00153 gc.DrawRect(aRect);
00154 }
00155
00156
00157
00158
00159
00160
00161 void CS60MemoryLabContainer::HandleControlEventL(
00162 CCoeControl* ,TCoeEvent )
00163 {
00164
00165 }
00166
00167