|
1 /**************************************************************************** |
|
2 ** |
|
3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
4 ** All rights reserved. |
|
5 ** Contact: Nokia Corporation (qt-info@nokia.com) |
|
6 ** |
|
7 ** This file is part of the utility applications of the Qt Toolkit. |
|
8 ** |
|
9 ** $QT_BEGIN_LICENSE:LGPL$ |
|
10 ** No Commercial Usage |
|
11 ** This file contains pre-release code and may not be distributed. |
|
12 ** You may use this file in accordance with the terms and conditions |
|
13 ** contained in the Technology Preview License Agreement accompanying |
|
14 ** this package. |
|
15 ** |
|
16 ** GNU Lesser General Public License Usage |
|
17 ** Alternatively, this file may be used under the terms of the GNU Lesser |
|
18 ** General Public License version 2.1 as published by the Free Software |
|
19 ** Foundation and appearing in the file LICENSE.LGPL included in the |
|
20 ** packaging of this file. Please review the following information to |
|
21 ** ensure the GNU Lesser General Public License version 2.1 requirements |
|
22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
|
23 ** |
|
24 ** In addition, as a special exception, Nokia gives you certain additional |
|
25 ** rights. These rights are described in the Nokia Qt LGPL Exception |
|
26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. |
|
27 ** |
|
28 ** If you have questions regarding the use of this file, please contact |
|
29 ** Nokia at qt-info@nokia.com. |
|
30 ** |
|
31 ** |
|
32 ** |
|
33 ** |
|
34 ** |
|
35 ** |
|
36 ** |
|
37 ** |
|
38 ** $QT_END_LICENSE$ |
|
39 ** |
|
40 ****************************************************************************/ |
|
41 |
|
42 // INCLUDE FILES |
|
43 |
|
44 #include <eiklabel.h> |
|
45 #include <avkon.rsg> |
|
46 #include <aknviewappui.h> |
|
47 #include <aknconsts.h> |
|
48 |
|
49 #include "pm_mapper.hrh" |
|
50 #include <pm_mapper.rsg> |
|
51 #include "pm_mapperView.h" |
|
52 #include "pm_mapperApp.h" |
|
53 |
|
54 #include <aknlists.h> |
|
55 #include <avkon.hrh> |
|
56 #include <AknUtils.h> |
|
57 |
|
58 // ----------------------------------------------------------------------------- |
|
59 // C++ constructor can NOT contain any code, that |
|
60 // might leave. |
|
61 // ----------------------------------------------------------------------------- |
|
62 // |
|
63 CPixelMetricsMapperViewContainer::CPixelMetricsMapperViewContainer(): iCount( 1 ) |
|
64 { |
|
65 } |
|
66 |
|
67 |
|
68 // ----------------------------------------------------------------------------- |
|
69 // Symbian 2nd phase constructor can leave. |
|
70 // ----------------------------------------------------------------------------- |
|
71 // |
|
72 void CPixelMetricsMapperViewContainer::ConstructL( const TRect& aRect ) |
|
73 { |
|
74 CreateWindowL(); |
|
75 SetCanDrawOutsideRect(); |
|
76 |
|
77 iTexts = new( ELeave ) CDesCArrayFlat( 10 ); |
|
78 iTexts->AppendL( _L( "\tStarted." ) ); |
|
79 |
|
80 iListbox = new( ELeave ) CAknSingleStyleListBox; |
|
81 iListbox->SetContainerWindowL( *this ); |
|
82 iListbox->ConstructL( this, EAknListBoxViewerFlags ); |
|
83 |
|
84 iListbox->Model()->SetItemTextArray( iTexts ); |
|
85 iListbox->SetRect( TRect( aRect.Size() ) ); |
|
86 |
|
87 iListbox->CreateScrollBarFrameL( ETrue ); |
|
88 iListbox->ScrollBarFrame()->SetScrollBarVisibilityL( |
|
89 CEikScrollBarFrame::EOn, |
|
90 CEikScrollBarFrame::EOn ); |
|
91 |
|
92 SetRect( aRect ); |
|
93 iListbox->ActivateL(); |
|
94 ActivateL(); |
|
95 } |
|
96 |
|
97 |
|
98 // ----------------------------------------------------------------------------- |
|
99 // |
|
100 // ----------------------------------------------------------------------------- |
|
101 // |
|
102 void CPixelMetricsMapperViewContainer::ShowL( const TDesC& aString, TBool& aLast, const TBool& aFileOutput ) |
|
103 { |
|
104 MDesCArray* itemList = iListbox->Model()->ItemTextArray(); |
|
105 CDesCArray* itemArray = ( CDesCArray* ) itemList; |
|
106 |
|
107 itemArray->AppendL( aString ); |
|
108 |
|
109 iListbox->HandleItemAdditionL(); |
|
110 iListbox->SetCurrentItemIndex( iCount ); |
|
111 iCount++; |
|
112 if ( aLast ) |
|
113 { |
|
114 if (aFileOutput) |
|
115 { |
|
116 RFile file; |
|
117 RFs& fs = CEikonEnv::Static()->FsSession(); |
|
118 TFileName fileName =_L("Layout_"); |
|
119 |
|
120 TRect screenRect; |
|
121 AknLayoutUtils::LayoutMetricsRect( |
|
122 AknLayoutUtils::EApplicationWindow, |
|
123 screenRect ); |
|
124 |
|
125 // Add screen dimensions |
|
126 TInt height = screenRect.Height(); |
|
127 TInt width = screenRect.Width(); |
|
128 fileName.AppendNum(height); |
|
129 fileName.Append('_'); |
|
130 fileName.AppendNum(width); |
|
131 |
|
132 if (AknLayoutUtils::LayoutMirrored()) |
|
133 fileName.Append(_L("_mirrored")); |
|
134 fileName.Append(_L(".txt")); |
|
135 |
|
136 TInt err=file.Open(fs,fileName,EFileStreamText|EFileWrite|EFileShareAny); |
|
137 if (err==KErrNotFound) // file does not exist - create it |
|
138 err=file.Create(fs,fileName,EFileStreamText|EFileWrite|EFileShareAny); |
|
139 else |
|
140 file.SetSize(0); //sweep the file |
|
141 TFileText textFile; |
|
142 textFile.Set(file); |
|
143 err = textFile.Seek(ESeekStart); |
|
144 if (err) User::InfoPrint(_L("File corrupted")); |
|
145 |
|
146 // Finally loop through all the entries: |
|
147 TInt idx = 0; |
|
148 for(;idx!=itemList->MdcaCount();idx++) |
|
149 { |
|
150 err = textFile.Write(itemList->MdcaPoint(idx)); |
|
151 if (err) User::InfoPrint(_L("File corrupted")); |
|
152 } |
|
153 file.Close(); |
|
154 } |
|
155 DrawNow(); |
|
156 } |
|
157 } |
|
158 |
|
159 void CPixelMetricsMapperViewContainer::ClearL() |
|
160 { |
|
161 MDesCArray* itemList = iListbox->Model()->ItemTextArray(); |
|
162 CDesCArray* itemArray = ( CDesCArray* ) itemList; |
|
163 |
|
164 itemArray->Reset(); |
|
165 |
|
166 iListbox->HandleItemAdditionL(); |
|
167 iCount = 0; |
|
168 DrawNow(); |
|
169 } |
|
170 |
|
171 |
|
172 // ----------------------------------------------------------------------------- |
|
173 // Destructor. |
|
174 // ----------------------------------------------------------------------------- |
|
175 // |
|
176 CPixelMetricsMapperViewContainer::~CPixelMetricsMapperViewContainer() |
|
177 { |
|
178 delete iListbox; |
|
179 } |
|
180 |
|
181 |
|
182 // ----------------------------------------------------------------------------- |
|
183 // |
|
184 // ----------------------------------------------------------------------------- |
|
185 // |
|
186 void CPixelMetricsMapperViewContainer::SizeChanged() |
|
187 { |
|
188 CCoeControl::SizeChanged(); |
|
189 if ( iListbox ) |
|
190 { |
|
191 iListbox->SetRect( Rect() ); |
|
192 } |
|
193 } |
|
194 |
|
195 |
|
196 // ----------------------------------------------------------------------------- |
|
197 // |
|
198 // ----------------------------------------------------------------------------- |
|
199 // |
|
200 TInt CPixelMetricsMapperViewContainer::CountComponentControls() const |
|
201 { |
|
202 return 1; |
|
203 } |
|
204 |
|
205 |
|
206 // ----------------------------------------------------------------------------- |
|
207 // CTestAppViewContainer::ComponentControl |
|
208 // |
|
209 // |
|
210 // ----------------------------------------------------------------------------- |
|
211 // |
|
212 CCoeControl* CPixelMetricsMapperViewContainer::ComponentControl( |
|
213 TInt /*aIndex*/ ) const |
|
214 { |
|
215 return iListbox; |
|
216 } |
|
217 |
|
218 |
|
219 // ----------------------------------------------------------------------------- |
|
220 // |
|
221 // ----------------------------------------------------------------------------- |
|
222 // |
|
223 void CPixelMetricsMapperViewContainer::Draw( const TRect& /*aRect*/ ) const |
|
224 { |
|
225 } |
|
226 |
|
227 |
|
228 // ----------------------------------------------------------------------------- |
|
229 // |
|
230 // ----------------------------------------------------------------------------- |
|
231 // |
|
232 void CPixelMetricsMapperViewContainer::HandleControlEventL( |
|
233 CCoeControl* /*aControl*/, |
|
234 TCoeEvent /*aEventType*/ ) |
|
235 { |
|
236 } |
|
237 |
|
238 |
|
239 // ----------------------------------------------------------------------------- |
|
240 // |
|
241 // ----------------------------------------------------------------------------- |
|
242 // |
|
243 TKeyResponse CPixelMetricsMapperViewContainer::OfferKeyEventL( |
|
244 const TKeyEvent& aKeyEvent, |
|
245 TEventCode aType ) |
|
246 { |
|
247 if (aKeyEvent.iCode == EKeyUpArrow || |
|
248 aKeyEvent.iCode == EKeyDownArrow ) |
|
249 { |
|
250 return iListbox->OfferKeyEventL( aKeyEvent, aType ); |
|
251 } |
|
252 return EKeyWasNotConsumed; |
|
253 } |
|
254 |
|
255 void CPixelMetricsMapperViewContainer::HandleResourceChange(TInt aType) |
|
256 { |
|
257 CCoeControl::HandleResourceChange( aType ); |
|
258 if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
259 { |
|
260 TRect mainPaneRect; |
|
261 AknLayoutUtils::LayoutMetricsRect( |
|
262 AknLayoutUtils::EMainPane, |
|
263 mainPaneRect ); |
|
264 SetRect( mainPaneRect ); |
|
265 |
|
266 CPixelMetricsMapperAppUi* myApp = static_cast<CPixelMetricsMapperAppUi*> (ControlEnv()->AppUi()); |
|
267 if (myApp->ReadyForAutoOp()) |
|
268 myApp->DoAutoOperationL(); |
|
269 } |
|
270 if (iListbox) iListbox->HandleResourceChange(aType); |
|
271 } |
|
272 |
|
273 |
|
274 // ----------------------------------------------------------------------------- |
|
275 // |
|
276 // ----------------------------------------------------------------------------- |
|
277 // |
|
278 void CPixelMetricsMapperView::ShowL( const TDesC& aString, TBool& aLast, const TBool& aFileOutput ) |
|
279 { |
|
280 iView->ShowL( aString, aLast, aFileOutput ); |
|
281 } |
|
282 |
|
283 void CPixelMetricsMapperView::ClearL() |
|
284 { |
|
285 iView->ClearL(); |
|
286 } |
|
287 |
|
288 |
|
289 // ----------------------------------------------------------------------------- |
|
290 // Symbian 2nd phase constructor can leave. |
|
291 // ----------------------------------------------------------------------------- |
|
292 // |
|
293 void CPixelMetricsMapperView::ConstructL() |
|
294 { |
|
295 BaseConstructL( R_PMMAPPER_VIEW ); |
|
296 } |
|
297 |
|
298 |
|
299 // ----------------------------------------------------------------------------- |
|
300 // Destructor. |
|
301 // ----------------------------------------------------------------------------- |
|
302 // |
|
303 CPixelMetricsMapperView::~CPixelMetricsMapperView() |
|
304 { |
|
305 if ( iView ) |
|
306 { |
|
307 AppUi()->RemoveFromViewStack( *this, iView ); |
|
308 } |
|
309 delete iView; |
|
310 } |
|
311 |
|
312 |
|
313 // ----------------------------------------------------------------------------- |
|
314 // |
|
315 // ----------------------------------------------------------------------------- |
|
316 // |
|
317 TUid CPixelMetricsMapperView::Id() const |
|
318 { |
|
319 return TUid::Uid( EPMMapperViewId ); |
|
320 } |
|
321 |
|
322 |
|
323 // ----------------------------------------------------------------------------- |
|
324 // |
|
325 // ----------------------------------------------------------------------------- |
|
326 // |
|
327 void CPixelMetricsMapperView::HandleCommandL( TInt aCommand ) |
|
328 { |
|
329 AppUi()->HandleCommandL( aCommand ); |
|
330 } |
|
331 |
|
332 // ----------------------------------------------------------------------------- |
|
333 // |
|
334 // ----------------------------------------------------------------------------- |
|
335 // |
|
336 void CPixelMetricsMapperView::HandleStatusPaneSizeChange() |
|
337 { |
|
338 if ( iView ) |
|
339 { |
|
340 TRect cr = ClientRect(); |
|
341 iView->SetRect( cr ); |
|
342 } |
|
343 } |
|
344 |
|
345 // ----------------------------------------------------------------------------- |
|
346 // |
|
347 // ----------------------------------------------------------------------------- |
|
348 // |
|
349 void CPixelMetricsMapperView::DoActivateL( |
|
350 const TVwsViewId& /*aPrevViewId*/, |
|
351 TUid /*aCustomMessageId*/, |
|
352 const TDesC8& /*aCustomMessage*/ ) |
|
353 { |
|
354 iView = new( ELeave ) CPixelMetricsMapperViewContainer; |
|
355 |
|
356 TRect cr = ClientRect(); |
|
357 iView->ConstructL( cr ); |
|
358 AppUi()->AddToViewStackL( *this, iView ); |
|
359 } |
|
360 |
|
361 // ----------------------------------------------------------------------------- |
|
362 // |
|
363 // ----------------------------------------------------------------------------- |
|
364 // |
|
365 void CPixelMetricsMapperView::DoDeactivate() |
|
366 { |
|
367 if (iView) |
|
368 { |
|
369 AppUi()->RemoveFromViewStack( *this, iView ); |
|
370 } |
|
371 delete iView; |
|
372 iView = NULL; |
|
373 } |
|
374 |
|
375 // End of File |