author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Fri, 19 Feb 2010 23:40:16 +0200 | |
branch | RCL_3 |
changeset 4 | 3b1da2848fc7 |
parent 3 | 41300fa6a67c |
permissions | -rw-r--r-- |
0 | 1 |
/**************************************************************************** |
2 |
** |
|
4
3b1da2848fc7
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
3
diff
changeset
|
3 |
** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). |
0 | 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 |
fileName.Append(_L(".txt")); |
|
133 |
||
134 |
TInt err=file.Open(fs,fileName,EFileStreamText|EFileWrite|EFileShareAny); |
|
135 |
if (err==KErrNotFound) // file does not exist - create it |
|
136 |
err=file.Create(fs,fileName,EFileStreamText|EFileWrite|EFileShareAny); |
|
137 |
else |
|
138 |
file.SetSize(0); //sweep the file |
|
139 |
TFileText textFile; |
|
140 |
textFile.Set(file); |
|
141 |
err = textFile.Seek(ESeekStart); |
|
142 |
if (err) User::InfoPrint(_L("File corrupted")); |
|
143 |
||
144 |
// Finally loop through all the entries: |
|
145 |
TInt idx = 0; |
|
146 |
for(;idx!=itemList->MdcaCount();idx++) |
|
147 |
{ |
|
148 |
err = textFile.Write(itemList->MdcaPoint(idx)); |
|
149 |
if (err) User::InfoPrint(_L("File corrupted")); |
|
150 |
} |
|
151 |
file.Close(); |
|
152 |
} |
|
153 |
DrawNow(); |
|
154 |
} |
|
155 |
} |
|
156 |
||
157 |
void CPixelMetricsMapperViewContainer::ClearL() |
|
158 |
{ |
|
159 |
MDesCArray* itemList = iListbox->Model()->ItemTextArray(); |
|
160 |
CDesCArray* itemArray = ( CDesCArray* ) itemList; |
|
161 |
||
162 |
itemArray->Reset(); |
|
163 |
||
164 |
iListbox->HandleItemAdditionL(); |
|
165 |
iCount = 0; |
|
166 |
DrawNow(); |
|
167 |
} |
|
168 |
||
169 |
||
170 |
// ----------------------------------------------------------------------------- |
|
171 |
// Destructor. |
|
172 |
// ----------------------------------------------------------------------------- |
|
173 |
// |
|
174 |
CPixelMetricsMapperViewContainer::~CPixelMetricsMapperViewContainer() |
|
175 |
{ |
|
176 |
delete iListbox; |
|
177 |
} |
|
178 |
||
179 |
||
180 |
// ----------------------------------------------------------------------------- |
|
181 |
// |
|
182 |
// ----------------------------------------------------------------------------- |
|
183 |
// |
|
184 |
void CPixelMetricsMapperViewContainer::SizeChanged() |
|
185 |
{ |
|
186 |
CCoeControl::SizeChanged(); |
|
187 |
if ( iListbox ) |
|
188 |
{ |
|
189 |
iListbox->SetRect( Rect() ); |
|
190 |
} |
|
191 |
} |
|
192 |
||
193 |
||
194 |
// ----------------------------------------------------------------------------- |
|
195 |
// |
|
196 |
// ----------------------------------------------------------------------------- |
|
197 |
// |
|
198 |
TInt CPixelMetricsMapperViewContainer::CountComponentControls() const |
|
199 |
{ |
|
200 |
return 1; |
|
201 |
} |
|
202 |
||
203 |
||
204 |
// ----------------------------------------------------------------------------- |
|
205 |
// CTestAppViewContainer::ComponentControl |
|
206 |
// |
|
207 |
// |
|
208 |
// ----------------------------------------------------------------------------- |
|
209 |
// |
|
210 |
CCoeControl* CPixelMetricsMapperViewContainer::ComponentControl( |
|
211 |
TInt /*aIndex*/ ) const |
|
212 |
{ |
|
213 |
return iListbox; |
|
214 |
} |
|
215 |
||
216 |
||
217 |
// ----------------------------------------------------------------------------- |
|
218 |
// |
|
219 |
// ----------------------------------------------------------------------------- |
|
220 |
// |
|
221 |
void CPixelMetricsMapperViewContainer::Draw( const TRect& /*aRect*/ ) const |
|
222 |
{ |
|
223 |
} |
|
224 |
||
225 |
||
226 |
// ----------------------------------------------------------------------------- |
|
227 |
// |
|
228 |
// ----------------------------------------------------------------------------- |
|
229 |
// |
|
230 |
void CPixelMetricsMapperViewContainer::HandleControlEventL( |
|
231 |
CCoeControl* /*aControl*/, |
|
232 |
TCoeEvent /*aEventType*/ ) |
|
233 |
{ |
|
234 |
} |
|
235 |
||
236 |
||
237 |
// ----------------------------------------------------------------------------- |
|
238 |
// |
|
239 |
// ----------------------------------------------------------------------------- |
|
240 |
// |
|
241 |
TKeyResponse CPixelMetricsMapperViewContainer::OfferKeyEventL( |
|
242 |
const TKeyEvent& aKeyEvent, |
|
243 |
TEventCode aType ) |
|
244 |
{ |
|
245 |
if (aKeyEvent.iCode == EKeyUpArrow || |
|
246 |
aKeyEvent.iCode == EKeyDownArrow ) |
|
247 |
{ |
|
248 |
return iListbox->OfferKeyEventL( aKeyEvent, aType ); |
|
249 |
} |
|
250 |
return EKeyWasNotConsumed; |
|
251 |
} |
|
252 |
||
253 |
void CPixelMetricsMapperViewContainer::HandleResourceChange(TInt aType) |
|
254 |
{ |
|
255 |
CCoeControl::HandleResourceChange( aType ); |
|
256 |
if ( aType == KEikDynamicLayoutVariantSwitch ) |
|
257 |
{ |
|
258 |
TRect mainPaneRect; |
|
259 |
AknLayoutUtils::LayoutMetricsRect( |
|
260 |
AknLayoutUtils::EMainPane, |
|
261 |
mainPaneRect ); |
|
262 |
SetRect( mainPaneRect ); |
|
263 |
||
264 |
} |
|
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
265 |
if (iListbox) |
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
266 |
iListbox->HandleResourceChange(aType); |
0 | 267 |
} |
268 |
||
269 |
||
270 |
// ----------------------------------------------------------------------------- |
|
271 |
// |
|
272 |
// ----------------------------------------------------------------------------- |
|
273 |
// |
|
274 |
void CPixelMetricsMapperView::ShowL( const TDesC& aString, TBool& aLast, const TBool& aFileOutput ) |
|
275 |
{ |
|
276 |
iView->ShowL( aString, aLast, aFileOutput ); |
|
277 |
} |
|
278 |
||
279 |
void CPixelMetricsMapperView::ClearL() |
|
280 |
{ |
|
281 |
iView->ClearL(); |
|
282 |
} |
|
283 |
||
284 |
||
285 |
// ----------------------------------------------------------------------------- |
|
286 |
// Symbian 2nd phase constructor can leave. |
|
287 |
// ----------------------------------------------------------------------------- |
|
288 |
// |
|
289 |
void CPixelMetricsMapperView::ConstructL() |
|
290 |
{ |
|
291 |
BaseConstructL( R_PMMAPPER_VIEW ); |
|
292 |
} |
|
293 |
||
294 |
||
295 |
// ----------------------------------------------------------------------------- |
|
296 |
// Destructor. |
|
297 |
// ----------------------------------------------------------------------------- |
|
298 |
// |
|
299 |
CPixelMetricsMapperView::~CPixelMetricsMapperView() |
|
300 |
{ |
|
301 |
if ( iView ) |
|
302 |
{ |
|
303 |
AppUi()->RemoveFromViewStack( *this, iView ); |
|
304 |
} |
|
305 |
delete iView; |
|
306 |
} |
|
307 |
||
308 |
||
309 |
// ----------------------------------------------------------------------------- |
|
310 |
// |
|
311 |
// ----------------------------------------------------------------------------- |
|
312 |
// |
|
313 |
TUid CPixelMetricsMapperView::Id() const |
|
314 |
{ |
|
315 |
return TUid::Uid( EPMMapperViewId ); |
|
316 |
} |
|
317 |
||
318 |
||
319 |
// ----------------------------------------------------------------------------- |
|
320 |
// |
|
321 |
// ----------------------------------------------------------------------------- |
|
322 |
// |
|
323 |
void CPixelMetricsMapperView::HandleCommandL( TInt aCommand ) |
|
324 |
{ |
|
325 |
AppUi()->HandleCommandL( aCommand ); |
|
326 |
} |
|
327 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
328 |
|
0 | 329 |
// ----------------------------------------------------------------------------- |
330 |
// |
|
331 |
// ----------------------------------------------------------------------------- |
|
332 |
// |
|
333 |
void CPixelMetricsMapperView::HandleStatusPaneSizeChange() |
|
334 |
{ |
|
335 |
if ( iView ) |
|
336 |
{ |
|
337 |
TRect cr = ClientRect(); |
|
338 |
iView->SetRect( cr ); |
|
339 |
} |
|
340 |
} |
|
341 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
342 |
|
0 | 343 |
// ----------------------------------------------------------------------------- |
344 |
// |
|
345 |
// ----------------------------------------------------------------------------- |
|
346 |
// |
|
347 |
void CPixelMetricsMapperView::DoActivateL( |
|
348 |
const TVwsViewId& /*aPrevViewId*/, |
|
349 |
TUid /*aCustomMessageId*/, |
|
350 |
const TDesC8& /*aCustomMessage*/ ) |
|
351 |
{ |
|
352 |
iView = new( ELeave ) CPixelMetricsMapperViewContainer; |
|
353 |
||
354 |
TRect cr = ClientRect(); |
|
355 |
iView->ConstructL( cr ); |
|
356 |
AppUi()->AddToViewStackL( *this, iView ); |
|
357 |
} |
|
358 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
359 |
|
0 | 360 |
// ----------------------------------------------------------------------------- |
361 |
// |
|
362 |
// ----------------------------------------------------------------------------- |
|
363 |
// |
|
364 |
void CPixelMetricsMapperView::DoDeactivate() |
|
365 |
{ |
|
366 |
if (iView) |
|
367 |
{ |
|
368 |
AppUi()->RemoveFromViewStack( *this, iView ); |
|
369 |
} |
|
370 |
delete iView; |
|
371 |
iView = NULL; |
|
372 |
} |
|
373 |
||
3
41300fa6a67c
Revision: 201003
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
0
diff
changeset
|
374 |
|
0 | 375 |
// End of File |