|
1 /* |
|
2 * Copyright (c) 2008 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 #include <coemain.h> |
|
20 #include <aknnotewrappers.h> |
|
21 #include <creator.rsg> |
|
22 #include <AknDef.h> |
|
23 #include "creator_container.h" |
|
24 |
|
25 |
|
26 |
|
27 // Standard construction sequence |
|
28 CCreatorAppView* CCreatorAppView::NewL(const TRect& aRect) |
|
29 { |
|
30 CCreatorAppView* self = CCreatorAppView::NewLC(aRect); |
|
31 CleanupStack::Pop(self); |
|
32 return self; |
|
33 } |
|
34 |
|
35 CCreatorAppView* CCreatorAppView::NewLC(const TRect& aRect) |
|
36 { |
|
37 CCreatorAppView* self = new (ELeave) CCreatorAppView; |
|
38 CleanupStack::PushL(self); |
|
39 self->ConstructL(aRect); |
|
40 return self; |
|
41 } |
|
42 |
|
43 void CCreatorAppView::ConstructL(const TRect& aRect) |
|
44 { |
|
45 // Create a window for this application view |
|
46 CreateWindowL(); |
|
47 |
|
48 // Set the windows size |
|
49 SetRect(aRect); |
|
50 |
|
51 // Activate the window, which makes it ready to be drawn |
|
52 ActivateL(); |
|
53 |
|
54 } |
|
55 |
|
56 CCreatorAppView::CCreatorAppView() |
|
57 { |
|
58 // Add any construction code that can not leave here |
|
59 } |
|
60 |
|
61 |
|
62 CCreatorAppView::~CCreatorAppView() |
|
63 { |
|
64 // Add any destruction code here |
|
65 } |
|
66 |
|
67 |
|
68 // Draw this application's view to the screen |
|
69 void CCreatorAppView::Draw(const TRect& /*aRect*/) const |
|
70 { |
|
71 |
|
72 // Get the standard graphics context |
|
73 CWindowGc& gc = SystemGc(); |
|
74 |
|
75 // Gets the control's extent |
|
76 TRect rect = Rect(); |
|
77 |
|
78 // Clears the screen |
|
79 gc.Clear(rect); |
|
80 |
|
81 // variables for memory and disk handling |
|
82 TDriveNumber cDrive=EDriveC; |
|
83 TDriveNumber dDrive=EDriveD; |
|
84 TDriveNumber eDrive=EDriveE; |
|
85 TVolumeInfo vinfo; |
|
86 TBuf<16> cFree; |
|
87 TBuf<16> dFree; |
|
88 TBuf<16> eFree; |
|
89 TBuf<16> cSize; |
|
90 TBuf<16> dSize; |
|
91 TBuf<16> eSize; |
|
92 TBuf<64> cText; |
|
93 TBuf<64> dText; |
|
94 TBuf<64> eText; |
|
95 TBuf<64> hText; |
|
96 |
|
97 // get an access to file server |
|
98 RFs& fsSession = ControlEnv()->FsSession(); |
|
99 |
|
100 // check the C-drive |
|
101 fsSession.Volume(vinfo, cDrive); |
|
102 cFree.Num(TInt64(vinfo.iFree/1024)); |
|
103 cSize.Num(TInt64(vinfo.iSize/1024)); |
|
104 |
|
105 // format the information about the C-drive |
|
106 cText.Copy(_L("C: ")); |
|
107 cText.Append(cFree); |
|
108 cText.Append(_L("kB of ")); |
|
109 cText.Append(cSize); |
|
110 cText.Append(_L("kB")); |
|
111 |
|
112 |
|
113 // the same thing for D-drive |
|
114 fsSession.Volume(vinfo, dDrive); |
|
115 dFree.Num(TInt64(vinfo.iFree/1024)); |
|
116 dSize.Num(TInt64(vinfo.iSize/1024)); |
|
117 |
|
118 dText.Copy(_L("D: ")); |
|
119 dText.Append(dFree); |
|
120 dText.Append(_L("kB of ")); |
|
121 dText.Append(dSize); |
|
122 dText.Append(_L("kB")); |
|
123 |
|
124 |
|
125 // the same thing for E-drive (MMC), if it exists |
|
126 if (MMC_OK()) |
|
127 { |
|
128 fsSession.Volume(vinfo, eDrive); |
|
129 eFree.Num(TInt64(vinfo.iFree/1024)); |
|
130 eSize.Num(TInt64(vinfo.iSize/1024)); |
|
131 |
|
132 eText.Copy(_L("E: ")); |
|
133 eText.Append(eFree); |
|
134 eText.Append(_L("kB of ")); |
|
135 eText.Append(eSize); |
|
136 eText.Append(_L("kB")); |
|
137 } |
|
138 |
|
139 |
|
140 // available work memory |
|
141 TMemoryInfoV1Buf memory; |
|
142 UserHal::MemoryInfo(memory); |
|
143 TInt64 freeMemBytes=(TInt64)(memory().iFreeRamInBytes); |
|
144 TInt64 sizeMemBytes=(TInt64)(memory().iTotalRamInBytes); |
|
145 |
|
146 /// ... |
|
147 TInt64 sizeWorkMemBytes = sizeMemBytes; |
|
148 |
|
149 |
|
150 TBuf<16> freeMem; |
|
151 TBuf<16> sizeWorkMem; |
|
152 |
|
153 freeMem.Num(TInt64(freeMemBytes/1024)); |
|
154 sizeWorkMem.Num(TInt64(sizeWorkMemBytes/1024)); |
|
155 |
|
156 hText.Copy(freeMem); |
|
157 hText.Append(_L("kB of ")); |
|
158 hText.Append(sizeWorkMem); |
|
159 hText.Append(_L("kB")); |
|
160 |
|
161 |
|
162 // draw all the texts to the screen |
|
163 gc.UseFont(AknLayoutUtils::FontFromId(EAknLogicalFontSecondaryFont)); |
|
164 |
|
165 TSize mainPaneSize; |
|
166 AknLayoutUtils::LayoutMetricsSize(AknLayoutUtils::EMainPane, mainPaneSize); |
|
167 |
|
168 TReal X_factor = TReal(mainPaneSize.iWidth) / 176; |
|
169 TReal Y_factor = TReal(mainPaneSize.iHeight) / 144; |
|
170 |
|
171 gc.SetPenColor(KRgbDarkBlue); |
|
172 gc.DrawText(_L("Free RAM memory:"), TPoint(TInt(4*X_factor), TInt(15*Y_factor))); |
|
173 gc.SetPenColor(KRgbBlack); |
|
174 gc.DrawText(hText, TPoint(TInt(4*X_factor), TInt(30*Y_factor))); |
|
175 |
|
176 gc.SetPenColor(KRgbDarkBlue); |
|
177 gc.DrawText(_L("Free disk memory:"), TPoint(TInt(4*X_factor), TInt(55*Y_factor))); |
|
178 gc.SetPenColor(KRgbBlack); |
|
179 gc.DrawText(cText, TPoint(TInt(4*X_factor), TInt(70*Y_factor))); |
|
180 gc.DrawText(dText, TPoint(TInt(4*X_factor), TInt(85*Y_factor))); |
|
181 |
|
182 if (MMC_OK()) |
|
183 { |
|
184 gc.DrawText(eText, TPoint(TInt(4*X_factor), TInt(100*Y_factor))); |
|
185 } |
|
186 |
|
187 } |
|
188 |
|
189 TKeyResponse CCreatorAppView::OfferKeyEventL( |
|
190 const TKeyEvent& aKeyEvent,TEventCode aType) |
|
191 { |
|
192 // return the default functionality |
|
193 return CCoeControl::OfferKeyEventL(aKeyEvent, aType); |
|
194 } |
|
195 |
|
196 |
|
197 TCoeInputCapabilities CCreatorAppView::InputCapabilities() const |
|
198 { |
|
199 // this class does not implement any 'unusual' input capabilities |
|
200 return TCoeInputCapabilities::ENone; |
|
201 } |
|
202 |
|
203 |
|
204 void CCreatorAppView::UserDraw() const |
|
205 { |
|
206 ActivateGc(); |
|
207 Draw(Rect()); |
|
208 DeactivateGc(); |
|
209 } |
|
210 |
|
211 |
|
212 |
|
213 TBool CCreatorAppView::MMC_OK() const |
|
214 { |
|
215 TBool MMCstatus = EFalse; |
|
216 |
|
217 TDriveNumber eDrive=EDriveE; |
|
218 TVolumeInfo vinfo; |
|
219 |
|
220 // check if we can access the E-drive: |
|
221 if ( iEikonEnv->FsSession().Volume(vinfo, eDrive) == KErrNone) |
|
222 { |
|
223 MMCstatus = ETrue; |
|
224 } |
|
225 else |
|
226 { |
|
227 MMCstatus = EFalse; |
|
228 } |
|
229 |
|
230 // returns ETrue if MMC working properly |
|
231 return MMCstatus; |
|
232 } |
|
233 |
|
234 |
|
235 void CCreatorAppView::HandleResourceChange(TInt aType) |
|
236 { |
|
237 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
238 { |
|
239 TRect mainPaneRect; |
|
240 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainPaneRect); |
|
241 SetRect(mainPaneRect); |
|
242 } |
|
243 } |
|
244 |