author | Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com> |
Wed, 13 Oct 2010 14:23:59 +0300 | |
branch | RCL_3 |
changeset 83 | 26b2b12093af |
parent 66 | 2455ef1f5bbc |
permissions | -rw-r--r-- |
66 | 1 |
/******************************************************************************* |
2 |
* Copyright (c) 2005, 2010 Nokia Corporation and/or its subsidiary(-ies). |
|
3 |
* All rights reserved. This program and the accompanying materials |
|
4 |
* are made available under the terms of the Eclipse Public License v1.0 |
|
5 |
* which accompanies this distribution, and is available at |
|
6 |
* http://www.eclipse.org/legal/epl-v10.html |
|
7 |
* |
|
8 |
* Contributors: |
|
9 |
* Nokia Corporation - S60 implementation |
|
10 |
*******************************************************************************/ |
|
11 |
||
12 |
||
13 |
#include <eikbtgpc.h> |
|
14 |
#include <fbs.h> |
|
15 |
#include <gulutil.h> |
|
16 |
#include <eikon.hrh> |
|
17 |
#include <AknUtils.h> |
|
18 |
#include <bautils.h> |
|
19 |
#include <avkon.mbg> |
|
20 |
#include <AknsUtils.h> |
|
21 |
#include <AknsConstants.h> |
|
22 |
#include <aknconsts.h> |
|
23 |
#include <AknIconUtils.h> |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
24 |
#include <e32math.h> |
66 | 25 |
#include <swtlaffacade.h> |
26 |
#include "s60commonutils.h" |
|
27 |
#include "swtfactory.h" |
|
28 |
#include "swtdisplaybase.h" |
|
29 |
#include "eswtwidgetsexpanded.h" |
|
30 |
#include "eswtmobileextensions.h" |
|
31 |
#include "swtevents.h" |
|
32 |
#include "swtkeymapper.h" |
|
33 |
#include "swttimer.h" |
|
34 |
#include "swtimage.h" |
|
35 |
#include "swtmidremconobserver.h" |
|
36 |
#include "swtjavabufferdrawer.h" |
|
37 |
#include "swtfont.h" |
|
38 |
#include "swtuiutils.h" |
|
39 |
#include "imagescaler.h" |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
40 |
#include "mifconverter.h" |
66 | 41 |
|
42 |
#define ASSERT_JAVAUITHREAD() ASSERT(IsCurrentThreadJavaUi()) |
|
43 |
#define ASSERT_NATIVEUITHREAD() ASSERT(IsCurrentThreadNativeUi()) |
|
44 |
||
45 |
||
46 |
// Assuming ResourceLanguageFileNameL inserts DRIVE:/KDC_RESOURCE_FILES_DIR/java/ |
|
47 |
// Assuming KDC_RESOURCE_FILES_DIR = /resource/java/ |
|
48 |
_LIT(KSwtResFile, "eswtcore.rsc"); |
|
49 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
50 |
const TInt KMifFileHeaderUid = 0x34232342; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
51 |
const TInt KMifFileHeaderVersion = 2; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
52 |
const TInt KMifFileHeaderLength = 2; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
53 |
const TInt KMifIconHeaderUid = 0x34232343; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
54 |
const TInt KMifIconHeaderVersion = 1; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
55 |
const TInt KMifIconHeaderType = 1; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
56 |
const TInt KMifIconHeaderAnimated = 0; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
57 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
58 |
_LIT(KTempMifFileDrive, "D:\\"); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
59 |
_LIT(KTempMifFileExt, ".mif"); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
60 |
|
66 | 61 |
|
62 |
// ======== MEMBER FUNCTIONS ======== |
|
63 |
||
64 |
||
65 |
/** |
|
66 |
* 2nd phase constructor |
|
67 |
*/ |
|
68 |
void ASwtDisplayBase::ConstructInJavaUiThreadL() |
|
69 |
{ |
|
70 |
iEventQueue = CSwtEventQueue::NewL(*this); |
|
71 |
} |
|
72 |
||
73 |
/** |
|
74 |
* UI thread's side constructor |
|
75 |
*/ |
|
76 |
void ASwtDisplayBase::ConstructInNativeUiThreadL() |
|
77 |
{ |
|
78 |
ASSERT_NATIVEUITHREAD(); |
|
79 |
||
80 |
iCoeEnv = CEikonEnv::Static(); // codescanner::eikonenvstatic |
|
81 |
ASSERT(iCoeEnv); |
|
82 |
iFactory = CSwtFactory::NewL(); |
|
83 |
iResId = LoadResourceFileL(); |
|
84 |
iUiUtils = iFactory->NewUiUtilsL(*this); |
|
85 |
iMenuArranger = iFactory->NewMenuArrangerL(*this); |
|
86 |
iCommandArranger = iFactory->NewCommandArrangerL(*this); |
|
87 |
iKeyMapper = CSwtKeyMapper::NewL(); |
|
88 |
iRemConObserver = CSwtMIDRemConObserver::NewL(); |
|
89 |
if (iRemConObserver) |
|
90 |
{ |
|
91 |
iRemConObserver->AddMediaKeysListenerL(this); |
|
92 |
} |
|
93 |
iJavaBufferDrawer = new(ELeave) CSwtJavaBufferDrawer(*this); |
|
94 |
#ifdef RD_SCALABLE_UI_V2 |
|
95 |
iLongTapDetector = CAknLongTapDetector::NewL(this); |
|
96 |
#endif |
|
97 |
} |
|
98 |
||
99 |
||
100 |
/** |
|
101 |
* Destructor |
|
102 |
*/ |
|
103 |
ASwtDisplayBase::~ASwtDisplayBase() |
|
104 |
{ |
|
105 |
} |
|
106 |
||
107 |
||
108 |
/** |
|
109 |
* Destroys the Display part that runs in the UI thread |
|
110 |
*/ |
|
111 |
void ASwtDisplayBase::DestroyInNativeUiThread() |
|
112 |
{ |
|
113 |
ASSERT_NATIVEUITHREAD(); |
|
114 |
||
115 |
if (iRemConObserver) |
|
116 |
{ |
|
117 |
iRemConObserver->RemoveMediaKeysListener(this); |
|
118 |
} |
|
119 |
delete iRemConObserver; |
|
120 |
iRemConObserver = NULL; |
|
121 |
||
122 |
if (iSystemFont) |
|
123 |
{ |
|
124 |
iSystemFont->RemoveRef(); |
|
125 |
iSystemFont = NULL; |
|
126 |
} |
|
127 |
||
128 |
delete iKeyMapper; |
|
129 |
iKeyMapper = NULL; |
|
130 |
||
131 |
delete iCommandArranger; // Mobile Extensions |
|
132 |
iCommandArranger = NULL; |
|
133 |
||
134 |
delete iMenuArranger; |
|
135 |
iMenuArranger = NULL; |
|
136 |
||
137 |
delete iUiUtils; // Core |
|
138 |
iUiUtils = NULL; |
|
139 |
||
140 |
delete iFactory; |
|
141 |
iFactory = NULL; |
|
142 |
||
143 |
iTimers.ResetAndDestroy(); |
|
144 |
||
145 |
if (iEventQueue) |
|
146 |
iEventQueue->Flush(); |
|
147 |
||
148 |
iResourceChangeObservers.Close(); |
|
149 |
iAppFocusObservers.Close(); |
|
150 |
||
151 |
delete iJavaBufferDrawer; |
|
152 |
iJavaBufferDrawer = NULL; |
|
153 |
||
154 |
#ifdef RD_SCALABLE_UI_V2 |
|
155 |
delete iLongTapDetector; |
|
156 |
iLongTapDetector = NULL; |
|
157 |
#endif //RD_SCALABLE_UI_V2 |
|
158 |
||
159 |
if (iResId != KErrNotFound) |
|
160 |
{ |
|
161 |
iCoeEnv->DeleteResourceFile(iResId); |
|
162 |
iResId = KErrNotFound; |
|
163 |
} |
|
164 |
||
165 |
iCoeEnv = NULL; |
|
166 |
} |
|
167 |
||
168 |
||
169 |
/** |
|
170 |
* Sleeps until an event is received |
|
171 |
* |
|
172 |
* Must be executed in the main thread. |
|
173 |
* |
|
174 |
* @return <code>ETrue</code> if the reason for awakening is reception of an |
|
175 |
* event; <code>EFalse</code> otherwise. |
|
176 |
*/ |
|
177 |
TBool ASwtDisplayBase::Sleep() |
|
178 |
{ |
|
179 |
ASSERT_JAVAUITHREAD(); |
|
180 |
||
181 |
// Must be set before checking if the queue is empty so that if an event |
|
182 |
// arrives between the moment we checked the queue and when we call |
|
183 |
// WaitForRequest(), we won't go to sleep. |
|
184 |
iRequestStatus = KRequestPending; |
|
185 |
||
186 |
if (!iEventQueue->IsEmpty()) //lint !e613 |
|
187 |
return ETrue; |
|
188 |
||
189 |
User::WaitForRequest(iRequestStatus); |
|
190 |
return ETrue; |
|
191 |
} |
|
192 |
||
193 |
/** |
|
194 |
* Creates a new timer that will auto-destruct. It will also register with |
|
195 |
* <code>RegisterTimerL()</code>, in case we need to exit and the timer is |
|
196 |
* still running. |
|
197 |
*/ |
|
198 |
void ASwtDisplayBase::AddTimerL(TInt aDelayInMilliSeconds, TInt aTimerHandle) |
|
199 |
{ |
|
200 |
CSwtTimer* timer = CSwtTimer::NewL(*this); |
|
201 |
timer->ExecuteAfterLD(aDelayInMilliSeconds, aTimerHandle); |
|
202 |
} |
|
203 |
||
204 |
||
205 |
/** |
|
206 |
* Adds a new timer to the java side timer list |
|
207 |
*/ |
|
208 |
void ASwtDisplayBase::RegisterTimerL(const CSwtTimer* aTimer) |
|
209 |
{ |
|
210 |
UnRegisterTimer(aTimer); //prevents duplicating timers |
|
211 |
User::LeaveIfError(iTimers.Append(aTimer)); |
|
212 |
} |
|
213 |
||
214 |
||
215 |
/** |
|
216 |
* Removes the timer from the java side timer list |
|
217 |
*/ |
|
218 |
void ASwtDisplayBase::UnRegisterTimer(const CSwtTimer* aTimer) |
|
219 |
{ |
|
220 |
TInt pos = iTimers.Find(aTimer); |
|
221 |
if (pos >= 0) |
|
222 |
{ |
|
223 |
iTimers.Remove(pos); |
|
224 |
} |
|
225 |
} |
|
226 |
||
227 |
||
228 |
/** |
|
229 |
* Awakens the display because of reception of a new event. |
|
230 |
* |
|
231 |
* Must be executed from within the App UI's thread. |
|
232 |
*/ |
|
233 |
void ASwtDisplayBase::HandleNewEvent() |
|
234 |
{ |
|
235 |
ASSERT_NATIVEUITHREAD(); |
|
236 |
DoWake(ETrue); |
|
237 |
} |
|
238 |
||
239 |
||
240 |
/** |
|
241 |
* Awakens the display (i.e. the main thread) |
|
242 |
*/ |
|
243 |
void ASwtDisplayBase::DoWake(TBool aBecauseOfEvent) |
|
244 |
{ |
|
245 |
if (iRequestStatus == KRequestPending) |
|
246 |
{ |
|
247 |
TRequestStatus* statusPtr = &iRequestStatus; |
|
248 |
iJavaUiThread.RequestComplete(statusPtr, aBecauseOfEvent); |
|
249 |
} |
|
250 |
} |
|
251 |
||
252 |
||
253 |
/** |
|
254 |
* Returns the maximum allowed depth of icons |
|
255 |
* |
|
256 |
* Must be executed from within the App UI's thread. |
|
257 |
*/ |
|
258 |
TInt ASwtDisplayBase::GetIconDepth() const |
|
259 |
{ |
|
260 |
ASSERT_NATIVEUITHREAD(); |
|
261 |
return TDisplayModeUtils::NumDisplayModeBitsPerPixel(iCoeEnv->ScreenDevice()->DisplayMode()); |
|
262 |
} |
|
263 |
||
264 |
||
265 |
/** |
|
266 |
* Returns the double click time |
|
267 |
* |
|
268 |
* Must be executed from within the App UI's thread. |
|
269 |
*/ |
|
270 |
TInt ASwtDisplayBase::GetDoubleClickTime() const |
|
271 |
{ |
|
272 |
ASSERT_NATIVEUITHREAD(); |
|
273 |
TTimeIntervalMicroSeconds32 interval(0); |
|
274 |
TInt distance(0); |
|
275 |
iCoeEnv->WsSession().GetDoubleClickSettings(interval, distance); |
|
276 |
return interval.Int(); |
|
277 |
} |
|
278 |
||
279 |
||
280 |
/** |
|
281 |
* Emits a beep |
|
282 |
* |
|
283 |
* Must be executed from within the App UI's thread. |
|
284 |
*/ |
|
285 |
void ASwtDisplayBase::Beep() const |
|
286 |
{ |
|
287 |
ASSERT_NATIVEUITHREAD(); |
|
288 |
iCoeEnv->Beep(); |
|
289 |
} |
|
290 |
||
291 |
||
292 |
/** |
|
293 |
* Posts an asynchronous event. |
|
294 |
* |
|
295 |
* @param aData SWT data of the key event. |
|
296 |
* |
|
297 |
* This method should be able to post events of type KeyDown or KeyUp. |
|
298 |
*/ |
|
299 |
void ASwtDisplayBase::PostL(const TSwtKeyEventData& aData) |
|
300 |
{ |
|
301 |
ASSERT_NATIVEUITHREAD(); |
|
302 |
||
303 |
if ((aData.iType == ESwtEventKeyDown) || (aData.iType == ESwtEventKeyUp)) |
|
304 |
{ |
|
305 |
MSwtShell* shell = iUiUtils->GetActiveShell(); |
|
306 |
if (shell == NULL) |
|
307 |
{ |
|
308 |
return; |
|
309 |
} |
|
310 |
MSwtControl* control = shell->FocusControl(); |
|
311 |
if (control == NULL) |
|
312 |
{ |
|
313 |
return; |
|
314 |
} |
|
315 |
||
316 |
TKeyEvent keyEvent; |
|
317 |
keyEvent.iCode = 0; |
|
318 |
keyEvent.iRepeats = 0; |
|
319 |
keyEvent.iModifiers = iKeyMapper->GetSymbianModifier(aData); |
|
320 |
||
321 |
if (aData.iType == ESwtEventKeyUp) |
|
322 |
{ |
|
323 |
// Key up event: keyEvent.iCode is set to 0 |
|
324 |
keyEvent.iScanCode = iKeyMapper->GetSymbianScanCode(aData.iKeyCode); |
|
325 |
control->CoeControl().OfferKeyEventL(keyEvent, EEventKeyUp); |
|
326 |
} |
|
327 |
else |
|
328 |
{ |
|
329 |
// Key down event in SWT = key down event follows with key event in Symbian |
|
330 |
// If several SWT ESwtEventKeyDown are following, |
|
331 |
// we should post first one Symbian EEventKeyDown |
|
332 |
// and then as many Symbian EEventKey as SWT ESwtEventKeyDown. |
|
333 |
// But posting EEventKeyDown and EEventKey at each time should not cause any problem. |
|
334 |
||
335 |
// Key down event: keyEvent.iCode is set to 0 |
|
336 |
TUint code = aData.iCharacter; |
|
337 |
iKeyMapper->GetSymbianCodes(aData.iKeyCode, keyEvent.iScanCode, &code); |
|
338 |
control->CoeControl().OfferKeyEventL(keyEvent, EEventKeyDown); |
|
339 |
||
340 |
// Key event: keyEvent.iCode is not 0. |
|
341 |
keyEvent.iCode = code; |
|
342 |
control->CoeControl().OfferKeyEventL(keyEvent, EEventKey); |
|
343 |
} |
|
344 |
} |
|
345 |
} |
|
346 |
||
347 |
/** |
|
348 |
* Posts an asynchronous event. |
|
349 |
* @param aData SWT data of the mouse event. |
|
350 |
* This method should be able to post events of type MouseDown, MouseUp, MouseMove. |
|
351 |
*/ |
|
352 |
TBool ASwtDisplayBase::MousePostL(const TSwtKeyEventData& aData, TPoint point) |
|
353 |
{ |
|
354 |
ASSERT_NATIVEUITHREAD(); |
|
355 |
||
356 |
if (AknLayoutUtils::PenEnabled()) |
|
357 |
{ |
|
358 |
TRawEvent event; |
|
359 |
if (aData.iType == ESwtEventMouseDown) |
|
360 |
{ |
|
361 |
event.Set(TRawEvent::EButton1Down, point.iX, point.iY); |
|
362 |
iCoeEnv->WsSession().SimulateRawEvent(event); |
|
363 |
} |
|
364 |
else if (aData.iType == ESwtEventMouseUp) |
|
365 |
{ |
|
366 |
event.Set(TRawEvent::EButton1Up, point.iX, point.iY); |
|
367 |
iCoeEnv->WsSession().SimulateRawEvent(event); |
|
368 |
} |
|
369 |
else if (aData.iType == ESwtEventMouseMove) |
|
370 |
{ |
|
371 |
event.Set(TRawEvent::EPointerMove, point.iX, point.iY); |
|
372 |
iCoeEnv->WsSession().SimulateRawEvent(event); |
|
373 |
} |
|
374 |
return ETrue; |
|
375 |
} |
|
376 |
else |
|
377 |
{ |
|
378 |
return EFalse; |
|
379 |
} |
|
380 |
} |
|
381 |
||
382 |
/** |
|
383 |
* Constructs an uninitialised Image |
|
384 |
* @param aSize The new image's size |
|
385 |
*/ |
|
386 |
MSwtImage* ASwtDisplayBase::NewImageL(const TSize& aSize) |
|
387 |
{ |
|
388 |
return CSwtImage::NewL(*this, aSize, *this); |
|
389 |
} |
|
390 |
||
391 |
/** |
|
392 |
* Constructs an Image with initial data |
|
393 |
* @param aData The data to construct the image from |
|
394 |
*/ |
|
395 |
MSwtImage* ASwtDisplayBase::NewImageFromDataL(const MSwtImageData& aData) |
|
396 |
{ |
|
397 |
return CSwtImage::NewL(this, aData, this); |
|
398 |
} |
|
399 |
||
400 |
/** |
|
401 |
* Constructs an image from native theme. |
|
402 |
* @param aId See TSwtThemeImageId |
|
403 |
*/ |
|
404 |
MSwtImage* ASwtDisplayBase::NewImageFromThemeL(const TInt aId) |
|
405 |
{ |
|
406 |
CFbsBitmap* bmp = NULL; |
|
407 |
CFbsBitmap* mask = NULL; |
|
408 |
TSize size(0, 0); |
|
409 |
switch (aId) |
|
410 |
{ |
|
411 |
case ESwtThemeImageSecurityTrusted: |
|
412 |
AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
413 |
KAknsIIDQgnIndiMidpTrusted, bmp, mask, |
|
414 |
AknIconUtils::AvkonIconFileName(), |
|
415 |
EMbmAvkonQgn_indi_midp_trusted, |
|
416 |
EMbmAvkonQgn_indi_midp_trusted_mask); |
|
417 |
size = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EListSingleGraphicPaneG1, |
|
418 |
TRect(),0).Rect().Size(); |
|
419 |
break; |
|
420 |
case ESwtThemeImageSecurityUntrusted: |
|
421 |
AknsUtils::CreateIconL(AknsUtils::SkinInstance(), |
|
422 |
KAknsIIDQgnIndiMidpUntrusted, bmp, mask, |
|
423 |
AknIconUtils::AvkonIconFileName(), |
|
424 |
EMbmAvkonQgn_indi_midp_untrusted, |
|
425 |
EMbmAvkonQgn_indi_midp_untrusted_mask); |
|
426 |
size = CSwtLafFacade::GetLayoutRect(CSwtLafFacade::EListSingleGraphicPaneG1, |
|
427 |
TRect(),0).Rect().Size(); |
|
428 |
break; |
|
429 |
default: |
|
430 |
return NULL; |
|
431 |
} |
|
432 |
||
433 |
if (!bmp) |
|
434 |
{ |
|
435 |
return NULL; |
|
436 |
} |
|
437 |
else |
|
438 |
{ |
|
439 |
if (size.iWidth > 0) |
|
440 |
{ |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
441 |
AknIconUtils::SetSize(bmp, size); // will resize the mask as well |
66 | 442 |
} |
443 |
// bmp & mask ownership transferred to returned object |
|
444 |
return CSwtImage::NewL(*bmp, mask); |
|
445 |
} |
|
446 |
} |
|
447 |
||
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
448 |
MSwtImage* ASwtDisplayBase::NewImageFromSvgBufL(const TDesC8& aBuf, const TSize& aSize) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
449 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
450 |
CFbsBitmap* mifBmp = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
451 |
CFbsBitmap* mifMask = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
452 |
CFbsBitmap* bmp = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
453 |
CFbsBitmap* mask = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
454 |
TInt bmpId(0); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
455 |
TInt maskId(1); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
456 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
457 |
TFileName tmpFile; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
458 |
StoreSvgAsMifL(aBuf, tmpFile); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
459 |
AknIconUtils::ValidateLogicalAppIconId(tmpFile, bmpId, maskId); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
460 |
AknIconUtils::CreateIconL(mifBmp, mifMask, tmpFile, bmpId, maskId); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
461 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
462 |
if (!mifBmp) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
463 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
464 |
return NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
465 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
466 |
else |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
467 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
468 |
AknIconUtils::ExcludeFromCache(mifBmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
469 |
if (mifMask) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
470 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
471 |
AknIconUtils::ExcludeFromCache(mifMask); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
472 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
473 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
474 |
// Will resize the mask as well |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
475 |
AknIconUtils::SetSize(mifBmp, aSize, EAspectRatioPreservedAndUnusedSpaceRemoved); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
476 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
477 |
// Rasterize |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
478 |
CleanupStack::PushL(mifBmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
479 |
if (mifMask) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
480 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
481 |
CleanupStack::PushL(mifMask); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
482 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
483 |
bmp = RasterizeL(*mifBmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
484 |
CleanupStack::PushL(bmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
485 |
if (mifMask) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
486 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
487 |
mask = RasterizeL(*mifMask); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
488 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
489 |
CleanupStack::Pop(bmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
490 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
491 |
// Delete the mif bitmaps |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
492 |
if (mifMask) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
493 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
494 |
AknIconUtils::DestroyIconData(mifMask); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
495 |
CleanupStack::PopAndDestroy(mifMask); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
496 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
497 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
498 |
AknIconUtils::DestroyIconData(mifBmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
499 |
CleanupStack::PopAndDestroy(mifBmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
500 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
501 |
// Delete the temp file |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
502 |
iCoeEnv->FsSession().Delete(tmpFile); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
503 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
504 |
// bmp & mask ownership transferred to returned object |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
505 |
return CSwtImage::NewL(*bmp, mask); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
506 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
507 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
508 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
509 |
MSwtImage* ASwtDisplayBase::NewImageFromSvgFileL(const TDesC& aFile, const TSize& aSize) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
510 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
511 |
HBufC8* buf = LoadFileL(aFile); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
512 |
CleanupStack::PushL(buf); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
513 |
MSwtImage* res = NewImageFromSvgBufL(*buf, aSize); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
514 |
CleanupStack::PopAndDestroy(buf); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
515 |
return res; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
516 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
517 |
|
66 | 518 |
/** |
519 |
* Constructs an Image from another Image. |
|
520 |
* @param aData The data to construct the image from |
|
521 |
*/ |
|
522 |
MSwtImage* ASwtDisplayBase::ScaleImageL(const MSwtImage& aSrcImage, |
|
523 |
const TSize& aDestSize, TBool aKeepAspectRatio) |
|
524 |
{ |
|
525 |
CFbsBitmap& srcBmp = const_cast<CFbsBitmap&>(aSrcImage.Bitmap()); |
|
526 |
CFbsBitmap* srcMask = const_cast<CFbsBitmap*>(aSrcImage.MaskBitmap()); |
|
527 |
||
528 |
CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
|
529 |
CleanupStack::PushL(bmp); |
|
530 |
User::LeaveIfError(bmp->Create(aDestSize, srcBmp.DisplayMode())); |
|
531 |
||
532 |
CFbsBitmap* mask = 0; |
|
533 |
if (srcMask) |
|
534 |
{ |
|
535 |
mask = new(ELeave) CFbsBitmap; |
|
536 |
CleanupStack::PushL(mask); |
|
537 |
User::LeaveIfError(mask->Create(aDestSize, EGray256)); |
|
538 |
} |
|
539 |
||
540 |
CImageScaler* scaler = CImageScaler::NewL(); |
|
541 |
CleanupStack::PushL(scaler); |
|
542 |
scaler->Scale(srcBmp, *bmp, aKeepAspectRatio); |
|
543 |
if (srcMask) |
|
544 |
{ |
|
545 |
scaler->Scale(*srcMask, *mask, aKeepAspectRatio); |
|
546 |
} |
|
547 |
CleanupStack::PopAndDestroy(scaler); |
|
548 |
if (mask) |
|
549 |
{ |
|
550 |
CleanupStack::Pop(mask); |
|
551 |
} |
|
552 |
CleanupStack::Pop(bmp); |
|
553 |
||
554 |
// bmp & mask ownership transferred to returned object |
|
555 |
return CSwtImage::NewL(*bmp, mask); |
|
556 |
} |
|
557 |
||
558 |
// |
|
559 |
// Own internal event methods |
|
560 |
// |
|
561 |
||
562 |
void ASwtDisplayBase::PostForegroundEventL(TSwtPeer aPeer, const TBool& aForeground) |
|
563 |
{ |
|
564 |
ASSERT_NATIVEUITHREAD(); |
|
565 |
iEventQueue->PushL(new(ELeave) CSwtForegroundEvent(aPeer, aForeground)); //lint !e613 |
|
566 |
} |
|
567 |
||
568 |
||
569 |
// |
|
570 |
// Virtual methods from MSwtDisplay |
|
571 |
// |
|
572 |
||
573 |
MSwtDevice& ASwtDisplayBase::Device() |
|
574 |
{ |
|
575 |
return *this; |
|
576 |
} |
|
577 |
||
578 |
const MSwtFactory& ASwtDisplayBase::Factory() const |
|
579 |
{ |
|
580 |
ASSERT(iFactory); |
|
581 |
return *iFactory; |
|
582 |
} |
|
583 |
||
584 |
MSwtUiUtils& ASwtDisplayBase::UiUtils() |
|
585 |
{ |
|
586 |
ASSERT(iUiUtils!=NULL); |
|
587 |
return *iUiUtils; //lint !e613 |
|
588 |
} |
|
589 |
||
590 |
MSwtMenuArranger& ASwtDisplayBase::MenuArranger() |
|
591 |
{ |
|
592 |
ASSERT(iMenuArranger!=NULL); |
|
593 |
return *iMenuArranger; |
|
594 |
} |
|
595 |
||
596 |
MSwtCommandArranger* ASwtDisplayBase::CommandArranger() |
|
597 |
{ |
|
598 |
return iCommandArranger; |
|
599 |
} |
|
600 |
||
601 |
void ASwtDisplayBase::AddResourceChangeObserverL(MSwtResourceChangeObserver* aObserver) |
|
602 |
{ |
|
603 |
User::LeaveIfError(iResourceChangeObservers.Append(aObserver)); |
|
604 |
} |
|
605 |
||
606 |
void ASwtDisplayBase::RemoveResourceChangeObserver(MSwtResourceChangeObserver* aObserver) |
|
607 |
{ |
|
608 |
TInt pos = iResourceChangeObservers.Find(aObserver); |
|
609 |
if (pos != KErrNotFound) |
|
610 |
{ |
|
611 |
iResourceChangeObservers.Remove(pos); |
|
612 |
} |
|
613 |
} |
|
614 |
||
615 |
void ASwtDisplayBase::AddAppFocusObserverL(MSwtAppFocusObserver* aObserver) |
|
616 |
{ |
|
617 |
User::LeaveIfError(iAppFocusObservers.Append(aObserver)); |
|
618 |
} |
|
619 |
||
620 |
void ASwtDisplayBase::RemoveAppFocusObserver(MSwtAppFocusObserver* aObserver) |
|
621 |
{ |
|
622 |
TInt pos = iAppFocusObservers.Find(aObserver); |
|
623 |
if (pos != KErrNotFound) |
|
624 |
{ |
|
625 |
iAppFocusObservers.Remove(pos); |
|
626 |
} |
|
627 |
} |
|
628 |
||
629 |
TInt ASwtDisplayBase::GetSymbianScanCode(const TInt aSwtKeyCode) const |
|
630 |
{ |
|
631 |
return CSwtKeyMapper::GetSymbianScanCode(aSwtKeyCode); |
|
632 |
} |
|
633 |
||
634 |
TUint ASwtDisplayBase::GetSymbianKeyCode(const TInt aSwtKeyCode) const |
|
635 |
{ |
|
636 |
TUint keyCode = aSwtKeyCode; |
|
637 |
TInt scanCodeNotNeeded; |
|
638 |
CSwtKeyMapper::GetSymbianCodes(aSwtKeyCode, scanCodeNotNeeded, &keyCode); |
|
639 |
return keyCode; |
|
640 |
} |
|
641 |
||
642 |
void ASwtDisplayBase::ForceTraverseEventL(MSwtControl& aControl, TSwtTraversal aDetail, TBool aDoIt) |
|
643 |
{ |
|
644 |
ASSERT_NATIVEUITHREAD(); |
|
645 |
||
646 |
TSwtKeyEventData data; |
|
647 |
data.iType = ESwtEventTraverse; |
|
648 |
data.iCharacter = 0; |
|
649 |
data.iKeyCode = 0; |
|
650 |
data.iStateMask = 0; |
|
651 |
||
652 |
TKeyEvent keyEvent; |
|
653 |
keyEvent.iCode = 0; |
|
654 |
keyEvent.iModifiers = 0; |
|
655 |
keyEvent.iRepeats = 0; |
|
656 |
keyEvent.iScanCode = 0; |
|
657 |
||
658 |
iEventQueue->PushL(new(ELeave) CSwtTraverseEvent(aControl, aDetail, aDoIt, data, keyEvent, EEventKey)); //lint !e613 |
|
659 |
} |
|
660 |
||
661 |
||
662 |
void ASwtDisplayBase::PostTraverseEventL(MSwtControl& aControl, TSwtTraversal aDetail, const TKeyEvent& aKeyEvent, |
|
663 |
TEventCode aType, TBool aDoIt) |
|
664 |
{ |
|
665 |
ASSERT_NATIVEUITHREAD(); |
|
666 |
ASSERT(iKeyMapper!=NULL); |
|
667 |
||
668 |
TSwtKeyEventData data(iKeyMapper->MapKeyEventL(aKeyEvent, aType)); //lint !e613 |
|
669 |
if (data.iType != ESwtEventNone) |
|
670 |
iEventQueue->PushL(new(ELeave) CSwtTraverseEvent(aControl, aDetail, aDoIt, data, aKeyEvent, aType)); //lint !e613 |
|
671 |
} |
|
672 |
||
673 |
||
674 |
void ASwtDisplayBase::PostKeyEventL(MSwtControl& aControl, const TKeyEvent& aKeyEvent, TEventCode aType) |
|
675 |
{ |
|
676 |
ASSERT_NATIVEUITHREAD(); |
|
677 |
ASSERT(iKeyMapper!=NULL); |
|
678 |
ASSERT(aType!=EEventNull); |
|
679 |
||
680 |
// EEventKeyDown can be posted only if the key does not generate EEventKey! |
|
681 |
TSwtKeyEventData data(iKeyMapper->MapKeyEventL(aKeyEvent, aType)); //lint !e613 |
|
682 |
if (data.iType != ESwtEventNone) |
|
683 |
iEventQueue->PushL(new(ELeave) CSwtKeyEvent(aControl, data, aKeyEvent, aType)); //lint !e613 |
|
684 |
} |
|
685 |
||
686 |
||
687 |
void ASwtDisplayBase::PostPaintEventL(TSwtPeer aSenderPeer, TSwtPeer aShellPeer, const TRect& aRect, TBool aMergeable) |
|
688 |
{ |
|
689 |
ASSERT_NATIVEUITHREAD(); |
|
690 |
iEventQueue->PushL(new(ELeave) CSwtPaintEvent(aSenderPeer, aShellPeer, aRect, aMergeable)); //lint !e613 |
|
691 |
} |
|
692 |
||
693 |
||
694 |
void ASwtDisplayBase::PostMouseEventL(TSwtPeer aPeer, TSwtEventType aType, TInt aButton, const TPoint& aPos, TInt aStateMask) |
|
695 |
{ |
|
696 |
ASSERT_NATIVEUITHREAD(); |
|
697 |
ASSERT(aType>=ESwtEventMouseDown && aType<=ESwtEventMouseDoubleClick); |
|
698 |
ASSERT(aButton==0 || (aType==ESwtEventMouseDown || aType==ESwtEventMouseUp)); |
|
699 |
||
700 |
#ifdef RD_SCALABLE_UI_V2 |
|
701 |
// After the long tap we send mouse up event for button2, see also HandleLongTapEventL(). |
|
702 |
if (iLongTapDetected && aType == ESwtEventMouseUp && aButton == KSwtMouseButton1) |
|
703 |
{ |
|
704 |
aButton = KSwtMouseButton2; |
|
705 |
} |
|
706 |
#endif //RD_SCALABLE_UI_V2 |
|
707 |
||
708 |
iEventQueue->PushL(new(ELeave) CSwtMouseEvent(aPeer, aType, aButton, aPos, aStateMask)); //lint !e613 |
|
709 |
} |
|
710 |
||
711 |
void ASwtDisplayBase::PostMoveEventL(TSwtPeer aPeer) |
|
712 |
{ |
|
713 |
ASSERT_NATIVEUITHREAD(); |
|
714 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventMove)); //lint !e613 |
|
715 |
} |
|
716 |
||
717 |
void ASwtDisplayBase::PostResizeEventL(TSwtPeer aPeer) |
|
718 |
{ |
|
719 |
ASSERT_NATIVEUITHREAD(); |
|
720 |
iEventQueue->PushL(new(ELeave) CSwtResizeEvent(aPeer)); //lint !e613 |
|
721 |
} |
|
722 |
||
723 |
void ASwtDisplayBase::PostScrollEventL(TSwtPeer aPeer, TInt aDetail) |
|
724 |
{ |
|
725 |
ASSERT_NATIVEUITHREAD(); |
|
726 |
iEventQueue->PushL(new(ELeave) CSwtScrollEvent(aPeer, aDetail)); //lint !e613 |
|
727 |
} |
|
728 |
||
729 |
void ASwtDisplayBase::PostSelectionEventL(TSwtPeer aPeer) |
|
730 |
{ |
|
731 |
ASSERT_NATIVEUITHREAD(); |
|
732 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventSelection)); //lint !e613 |
|
733 |
} |
|
734 |
||
735 |
void ASwtDisplayBase::PostSelectionEventL(TSwtPeer aPeer, const TDesC& aText) |
|
736 |
{ |
|
737 |
ASSERT_NATIVEUITHREAD(); |
|
738 |
iEventQueue->PushL(CSwtTextSelectionEvent::NewL(aPeer, aText)); //lint !e613 |
|
739 |
} |
|
740 |
||
741 |
void ASwtDisplayBase::PostSelectionEventL(TSwtPeer aPeer, TInt aDetail, TSwtPeer aItemPeer) |
|
742 |
{ |
|
743 |
ASSERT_NATIVEUITHREAD(); |
|
744 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventSelection, aDetail, aItemPeer)); //lint !e613 |
|
745 |
} |
|
746 |
||
747 |
void ASwtDisplayBase::PostDefaultSelectionEventL(TSwtPeer aPeer) |
|
748 |
{ |
|
749 |
ASSERT_NATIVEUITHREAD(); |
|
750 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventDefaultSelection,KSwtNone,NULL)); //lint !e613 |
|
751 |
} |
|
752 |
||
753 |
void ASwtDisplayBase::PostDefaultSelectionEventL(TSwtPeer aPeer, TInt aDetail, TSwtPeer aItemPeer) |
|
754 |
{ |
|
755 |
ASSERT_NATIVEUITHREAD(); |
|
756 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventDefaultSelection, aDetail, aItemPeer)); //lint !e613 |
|
757 |
} |
|
758 |
||
759 |
void ASwtDisplayBase::PostFocusEventL(TSwtPeer aPeer, TSwtEventType aType) |
|
760 |
{ |
|
761 |
ASSERT_NATIVEUITHREAD(); |
|
762 |
ASSERT(aType==ESwtEventFocusIn || aType==ESwtEventFocusOut); |
|
763 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, aType)); //lint !e613 |
|
764 |
} |
|
765 |
||
766 |
void ASwtDisplayBase::PostShellEventL(TSwtPeer aPeer, TSwtEventType aType) |
|
767 |
{ |
|
768 |
ASSERT_NATIVEUITHREAD(); |
|
769 |
ASSERT(aType==ESwtEventActivate || aType==ESwtEventDeactivate); |
|
770 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, aType)); //lint !e613 |
|
771 |
} |
|
772 |
||
773 |
void ASwtDisplayBase::PostModifyEventL(TSwtPeer aPeer) |
|
774 |
{ |
|
775 |
ASSERT_NATIVEUITHREAD(); |
|
776 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventModify, KSwtNone, NULL)); //lint !e613 |
|
777 |
} |
|
778 |
||
779 |
void ASwtDisplayBase::PostVerifyEventL(MSwtVerifyEventObserver& aWidget, TSwtPeer aPeer, TInt aStart, TInt aEnd, const TDesC& aText) |
|
780 |
{ |
|
781 |
ASSERT_NATIVEUITHREAD(); |
|
782 |
ASSERT(aStart>=0 && aStart<=aEnd); |
|
783 |
iEventQueue->PushL(CSwtVerifyEvent::NewL(aWidget, aPeer, aStart, aEnd, aText)); //lint !e613 |
|
784 |
} |
|
785 |
||
786 |
void ASwtDisplayBase::PostShowEventL(TSwtPeer aPeer) |
|
787 |
{ |
|
788 |
ASSERT_NATIVEUITHREAD(); |
|
789 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventShow)); //lint !e613 |
|
790 |
} |
|
791 |
||
792 |
void ASwtDisplayBase::PostHideEventL(TSwtPeer aPeer) |
|
793 |
{ |
|
794 |
ASSERT_NATIVEUITHREAD(); |
|
795 |
iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventHide)); //lint !e613 |
|
796 |
} |
|
797 |
||
798 |
void ASwtDisplayBase::PostScreenEventL(TSwtPeer aPeer, TInt aType) |
|
799 |
{ |
|
800 |
ASSERT_NATIVEUITHREAD(); |
|
801 |
iEventQueue->PushL(new(ELeave) CSwtScreenEvent(aPeer, aType)); //lint !e613 |
|
802 |
} |
|
803 |
||
804 |
void ASwtDisplayBase::PostMobileDeviceEventL(TSwtPeer aPeer, TInt aEventType) |
|
805 |
{ |
|
806 |
ASSERT_NATIVEUITHREAD(); |
|
807 |
iEventQueue->PushL(new(ELeave) CSwtMobileDeviceEvent(aPeer, aEventType)); //lint !e613 |
|
808 |
} |
|
809 |
||
810 |
void ASwtDisplayBase::PostTreeEventL(TSwtPeer aPeer, TSwtEventType aType, TInt aItemHandle) |
|
811 |
{ |
|
812 |
ASSERT_NATIVEUITHREAD(); |
|
813 |
iEventQueue->PushL(new(ELeave) CSwtTreeEvent(aPeer, aType, aItemHandle)); //lint !e613 |
|
814 |
} |
|
815 |
||
816 |
void ASwtDisplayBase::PostLocationChangingEventL(TSwtPeer aPeer |
|
817 |
, MSwtBrowser& aBrowser, TBool aDoIt, TBool aTop |
|
818 |
, const TDesC& aLocation, TSwtBrCallBackOperationType aCallBackOperationType) |
|
819 |
{ |
|
820 |
ASSERT_NATIVEUITHREAD(); |
|
821 |
iEventQueue->PushL(CSwtLocationChangingEvent::NewL(aPeer, aBrowser, aDoIt, aTop |
|
822 |
, aLocation, aCallBackOperationType)); |
|
823 |
} |
|
824 |
||
825 |
void ASwtDisplayBase::PostLocationChangedEventL(TSwtPeer aPeer, |
|
826 |
TBool aDoIt, TBool aTop, const TDesC& aLocation) |
|
827 |
{ |
|
828 |
ASSERT_NATIVEUITHREAD(); |
|
829 |
iEventQueue->PushL(CSwtLocationChangedEvent::NewL(aPeer, aDoIt, aTop, aLocation)); |
|
830 |
} |
|
831 |
||
832 |
void ASwtDisplayBase::PostProgressEventL(TSwtPeer aPeer, TInt aCurrent, TInt aTotal) |
|
833 |
{ |
|
834 |
ASSERT_NATIVEUITHREAD(); |
|
835 |
iEventQueue->PushL(new(ELeave) CSwtProgressEvent(aPeer, aCurrent, aTotal)); |
|
836 |
} |
|
837 |
||
838 |
void ASwtDisplayBase::PostProgressCompletedEventL(TSwtPeer aPeer, TInt aCurrent, TInt aTotal) |
|
839 |
{ |
|
840 |
ASSERT_NATIVEUITHREAD(); |
|
841 |
iEventQueue->PushL(new(ELeave) CSwtProgressCompletedEvent(aPeer, aCurrent, aTotal)); |
|
842 |
} |
|
843 |
||
844 |
void ASwtDisplayBase::PostStatusTextEventL(TSwtPeer aPeer, const TDesC& aStatusText) |
|
845 |
{ |
|
846 |
ASSERT_NATIVEUITHREAD(); |
|
847 |
iEventQueue->PushL(CSwtStatusTextEvent::NewL(aPeer, aStatusText)); |
|
848 |
} |
|
849 |
||
850 |
void ASwtDisplayBase::PostTitleEventL(TSwtPeer aPeer, const TDesC& aTitle) |
|
851 |
{ |
|
852 |
ASSERT_NATIVEUITHREAD(); |
|
853 |
iEventQueue->PushL(CSwtTitleEvent::NewL(aPeer, aTitle)); |
|
854 |
} |
|
855 |
||
856 |
void ASwtDisplayBase::PostDialogResultEventL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, const TDesC& aDialogResult) |
|
857 |
{ |
|
858 |
ASSERT_NATIVEUITHREAD(); |
|
859 |
iEventQueue->PushL(CSwtDialogStringResultEvent::NewL(aBroker, aPeer, aDialogResult)); |
|
860 |
} |
|
861 |
||
862 |
void ASwtDisplayBase::PostDialogResultEventL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, TInt aDialogResult) |
|
863 |
{ |
|
864 |
ASSERT_NATIVEUITHREAD(); |
|
865 |
iEventQueue->PushL(new(ELeave) CSwtDialogIntegerResultEvent(aBroker, aPeer, aDialogResult)); |
|
866 |
} |
|
867 |
||
868 |
void ASwtDisplayBase::PostDialogResultEventL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, TInt aDialogResult1, TInt aDialogResult2, TInt aDialogResult3) |
|
869 |
{ |
|
870 |
ASSERT_NATIVEUITHREAD(); |
|
871 |
iEventQueue->PushL(new(ELeave) CSwtDialogRgbResultEvent(aBroker, aPeer, aDialogResult1, aDialogResult2, aDialogResult3)); |
|
872 |
} |
|
873 |
||
874 |
void ASwtDisplayBase::PostCloseEventL(TSwtPeer aPeer, TBool& aDispatched) |
|
875 |
{ |
|
876 |
ASSERT_NATIVEUITHREAD(); |
|
877 |
iEventQueue->PushL(new(ELeave) CSwtCloseEvent(aPeer, aDispatched)); |
|
878 |
} |
|
879 |
||
880 |
void ASwtDisplayBase::PostShowFocusedControlEventL(TSwtPeer aPeer) |
|
881 |
{ |
|
882 |
ASSERT_NATIVEUITHREAD(); |
|
883 |
iEventQueue->PushL(new(ELeave) CSwtShowFocusedControlEvent(aPeer)); |
|
884 |
} |
|
885 |
||
886 |
TInt ASwtDisplayBase::ApplicationUid() |
|
887 |
{ |
|
888 |
return iApplicationUid; |
|
889 |
} |
|
890 |
||
891 |
CEikonEnv* ASwtDisplayBase::CoeEnv() const |
|
892 |
{ |
|
893 |
ASSERT(iCoeEnv); |
|
894 |
return iCoeEnv; |
|
895 |
} |
|
896 |
||
897 |
CDesC16ArrayFlat* ASwtDisplayBase::GetFontNamesL(TBool aScalable) const |
|
898 |
{ |
|
899 |
ASSERT_NATIVEUITHREAD(); |
|
900 |
||
901 |
CEikonEnv* eikEnv = iCoeEnv; |
|
902 |
CWsScreenDevice* screenDevice = NULL; |
|
903 |
if (eikEnv) |
|
904 |
{ |
|
905 |
screenDevice = eikEnv->ScreenDevice(); |
|
906 |
} |
|
907 |
if (!eikEnv || !screenDevice) |
|
908 |
{ |
|
909 |
return NULL; |
|
910 |
} |
|
911 |
||
912 |
// Look for available fonts |
|
913 |
const TInt KArrayGranularity = 4; |
|
914 |
//Caller method is responsible for deleting the fontNameList |
|
915 |
CDesC16ArrayFlat* fontNameList = new(ELeave) CDesC16ArrayFlat(KArrayGranularity); |
|
916 |
CleanupStack::PushL(fontNameList); |
|
917 |
FontUtils::GetAvailableFontsL(*screenDevice, *fontNameList, EGulAllFonts); |
|
918 |
||
919 |
TFontSpec fontSpec; |
|
920 |
CFont* font = NULL; |
|
921 |
TInt fontNameListCount = fontNameList->Count(); |
|
922 |
for (TInt nameIndex=0; nameIndex<fontNameListCount; ++nameIndex) |
|
923 |
{ |
|
924 |
// Look for the nearest font from the current typeface name. |
|
925 |
// This is needed only to check if the font correspond to the |
|
926 |
// aScalable parameter |
|
927 |
fontSpec.iTypeface.iName = (*fontNameList)[nameIndex]; |
|
928 |
fontSpec.iHeight = 0; |
|
929 |
fontSpec.iFontStyle = TFontStyle(EPostureUpright, EStrokeWeightNormal, EPrintPosNormal); |
|
930 |
User::LeaveIfError(screenDevice->GetNearestFontInTwips(font, fontSpec) == KErrNone); |
|
931 |
||
932 |
// Manage scalable attribute |
|
933 |
// CFont::TypeUid() returns the UId of the type of the font: |
|
934 |
// - KCFbsFontUid for a CFbsFont |
|
935 |
// - KCBitmapFontUid or KCBitmapFontUidVal for a CBitmapFont |
|
936 |
// On Series60 SDK, no Uid is available for CBitmapFont. |
|
937 |
// So scalable management is processed only for CFbsFont. |
|
938 |
// For the other font types, the font is always added to the list. |
|
939 |
if (font->TypeUid() == KCFbsFontUid) |
|
940 |
{ |
|
941 |
if (aScalable !=(static_cast<CFbsFont*>(font))->IsOpenFont()) |
|
942 |
{ |
|
943 |
// Delete the font because its scalable attribute |
|
944 |
// doesn't correspond to aScalable parameter. |
|
945 |
fontNameList->Delete(nameIndex); |
|
946 |
fontNameList->Compress(); |
|
947 |
fontNameListCount--; |
|
948 |
nameIndex--; |
|
949 |
} |
|
950 |
} |
|
951 |
#ifdef _DEBUG |
|
952 |
else |
|
953 |
{ |
|
954 |
// Non-recognized font type Uid. |
|
955 |
__DEBUGGER(); |
|
956 |
} |
|
957 |
#endif |
|
958 |
screenDevice->ReleaseFont(font); |
|
959 |
font = NULL; |
|
960 |
} |
|
961 |
||
962 |
CleanupStack::Pop(fontNameList); |
|
963 |
return fontNameList; |
|
964 |
} |
|
965 |
||
966 |
TBool ASwtDisplayBase::RevertPointerEvent() const |
|
967 |
{ |
|
968 |
return iRevertPointerEvent || iLongTapDetected; |
|
969 |
} |
|
970 |
||
971 |
void ASwtDisplayBase::SetRevertPointerEvent(TBool aStatus) |
|
972 |
{ |
|
973 |
iRevertPointerEvent = aStatus; |
|
974 |
} |
|
975 |
||
976 |
// |
|
977 |
// Virtual methods from MSwtDevice |
|
978 |
// |
|
979 |
||
980 |
MSwtColor* ASwtDisplayBase::CreateColorL(const TRgb& aRgbValue) const |
|
981 |
{ |
|
982 |
return iFactory->NewColorL(*this, aRgbValue); //lint !e613 |
|
983 |
} |
|
984 |
||
985 |
TRect ASwtDisplayBase::Bounds() const |
|
986 |
{ |
|
987 |
ASSERT_NATIVEUITHREAD(); |
|
988 |
return TRect(iCoeEnv->EikAppUi()->ApplicationRect()); |
|
989 |
} |
|
990 |
||
991 |
TRect ASwtDisplayBase::ClientArea() const |
|
992 |
{ |
|
993 |
ASSERT_NATIVEUITHREAD(); |
|
994 |
TRect appUiCltRect(iCoeEnv->EikAppUi()->ApplicationRect()); |
|
995 |
iUiUtils->Cba().ReduceRect(appUiCltRect); |
|
996 |
return appUiCltRect; |
|
997 |
} |
|
998 |
||
999 |
TInt ASwtDisplayBase::Depth() const |
|
1000 |
{ |
|
1001 |
ASSERT_NATIVEUITHREAD(); |
|
1002 |
switch (iCoeEnv->ScreenDevice()->DisplayMode()) |
|
1003 |
{ |
|
1004 |
case EGray2: |
|
1005 |
return 1; |
|
1006 |
case EGray4: |
|
1007 |
return 2; |
|
1008 |
case EGray16: |
|
1009 |
return 4; |
|
1010 |
case EGray256: |
|
1011 |
return 8; |
|
1012 |
case EColor16: |
|
1013 |
return 4; |
|
1014 |
case EColor256: |
|
1015 |
return 8; |
|
1016 |
case EColor64K: |
|
1017 |
return 16; |
|
1018 |
case EColor16M: |
|
1019 |
return 24; |
|
1020 |
case EColor16MU: |
|
1021 |
return 32; |
|
1022 |
case EColor16MA: |
|
1023 |
return 32; |
|
1024 |
case EColor16MAP: |
|
1025 |
return 32; |
|
1026 |
case EColor4K: |
|
1027 |
return 12; |
|
1028 |
default: |
|
1029 |
ASSERT(EFalse); |
|
1030 |
return 0; |
|
1031 |
} |
|
1032 |
} |
|
1033 |
||
1034 |
TSize ASwtDisplayBase::Dpi() const |
|
1035 |
{ |
|
1036 |
ASSERT_NATIVEUITHREAD(); |
|
1037 |
||
1038 |
// Convert a 1440x1440 twips (i.e. 1x1 inch) square to pixels, this yelds the |
|
1039 |
// DPI resolution. |
|
1040 |
return iCoeEnv->ScreenDevice()->TwipsToPixels(TPoint(KTwipsPerInch,KTwipsPerInch)).AsSize(); |
|
1041 |
} |
|
1042 |
||
1043 |
static TInt getTheHeightInTWipsL(CEikonEnv* aEnv, const MSwtDevice& aDevice, |
|
1044 |
const TFontSpec& aFontSpec, TInt aIndexInArray, CArrayFixFlat<TInt>* aArrayHeight) |
|
1045 |
{ |
|
1046 |
TFontSpec fontSpec(aFontSpec); |
|
1047 |
CFont* iFont = NULL; |
|
1048 |
TInt heightInTWips = aArrayHeight->At(aIndexInArray); |
|
1049 |
TInt heightOfObtainFontPt = 0; |
|
1050 |
TInt heightOfAskedFontPt = FontUtils::PointsFromTwips(heightInTWips); |
|
1051 |
TInt maxHeightPt = FontUtils::PointsFromTwips(aArrayHeight->At(aArrayHeight->Count()-1)); |
|
1052 |
||
1053 |
CBitmapDevice& bmpDevice = *(aEnv->ScreenDevice()); |
|
1054 |
||
1055 |
// Look for available heights for the current font. |
|
1056 |
fontSpec.iHeight = FontUtils::TwipsFromPoints(heightOfAskedFontPt); |
|
1057 |
User::LeaveIfError(bmpDevice.GetNearestFontInTwips(iFont, fontSpec)); |
|
1058 |
heightOfObtainFontPt = FontUtils::PointsFromTwips(iFont->FontSpecInTwips().iHeight); |
|
1059 |
||
1060 |
while (((heightInTWips != iFont->FontSpecInTwips().iHeight) |
|
1061 |
&& (heightOfAskedFontPt < maxHeightPt)) |
|
1062 |
&& (heightOfAskedFontPt > heightOfObtainFontPt)) |
|
1063 |
{ |
|
1064 |
heightOfAskedFontPt++; |
|
1065 |
fontSpec.iHeight = FontUtils::TwipsFromPoints(heightOfAskedFontPt); |
|
1066 |
||
1067 |
const_cast<MSwtDevice&>(aDevice).GraphicsDevice().ReleaseFont(iFont); |
|
1068 |
heightOfObtainFontPt = FontUtils::PointsFromTwips(iFont->FontSpecInTwips().iHeight); |
|
1069 |
User::LeaveIfError(bmpDevice.GetNearestFontInTwips(iFont, fontSpec)); |
|
1070 |
} |
|
1071 |
||
1072 |
const_cast<MSwtDevice&>(aDevice).GraphicsDevice().ReleaseFont(iFont); |
|
1073 |
return fontSpec.iHeight; |
|
1074 |
} |
|
1075 |
||
1076 |
CArrayFixFlat<TSwtFontData>* ASwtDisplayBase::GetFontListL(const TDesC& aFaceName, TBool aScalable) const |
|
1077 |
{ |
|
1078 |
ASSERT_NATIVEUITHREAD(); |
|
1079 |
||
1080 |
CEikonEnv& eikEnv = *iCoeEnv; |
|
1081 |
||
1082 |
// Look for available fonts |
|
1083 |
const TInt KArrayGranularity = 4; |
|
1084 |
CDesC16ArrayFlat* fontNameList = new(ELeave) CDesC16ArrayFlat(KArrayGranularity); |
|
1085 |
CleanupStack::PushL(fontNameList); |
|
1086 |
if (aFaceName.Length() == 0) |
|
1087 |
{ |
|
1088 |
FontUtils::GetAvailableFontsL(*(eikEnv.ScreenDevice()), *fontNameList, EGulAllFonts); |
|
1089 |
} |
|
1090 |
else |
|
1091 |
{ |
|
1092 |
fontNameList->AppendL(aFaceName); |
|
1093 |
} |
|
1094 |
||
1095 |
CArrayFixFlat<TSwtFontData>* arrayFontData = new(ELeave) CArrayFixFlat<TSwtFontData>(KArrayGranularity); |
|
1096 |
CleanupStack::PushL(arrayFontData); |
|
1097 |
||
1098 |
CArrayFixFlat<TInt>* heightList = new(ELeave)CArrayFixFlat<TInt>(KArrayGranularity); |
|
1099 |
CleanupStack::PushL(heightList); |
|
1100 |
||
1101 |
TFontSpec fontSpec; |
|
1102 |
TSwtFontData fontData; |
|
1103 |
CFont* font = NULL; |
|
1104 |
TInt heightIndex; |
|
1105 |
TInt fontNameListCount = fontNameList->Count(); |
|
1106 |
TInt heightListCount; |
|
1107 |
for (TInt nameIndex=0; nameIndex<fontNameListCount; ++nameIndex) |
|
1108 |
{ |
|
1109 |
// Look for the nearest font from the current typeface name. |
|
1110 |
fontSpec.iTypeface.iName = (*fontNameList)[nameIndex]; |
|
1111 |
fontSpec.iHeight = 0; |
|
1112 |
fontSpec.iFontStyle = TFontStyle(EPostureUpright, EStrokeWeightNormal, EPrintPosNormal); |
|
1113 |
User::LeaveIfError(eikEnv.ScreenDevice()->GetNearestFontInTwips(font, fontSpec) == KErrNone); |
|
1114 |
||
1115 |
// Manage scalable attribute |
|
1116 |
// CFont::TypeUid() returns the UId of the type of the font: |
|
1117 |
// - KCFbsFontUid for a CFbsFont |
|
1118 |
// - KCBitmapFontUid or KCBitmapFontUidVal for a CBitmapFont |
|
1119 |
// On Series60 SDK, no Uid is available for CBitmapFont. |
|
1120 |
// So scalable management is processed only for CFbsFont. |
|
1121 |
// For the other font types, the font is always added to the list. |
|
1122 |
if (font->TypeUid() == KCFbsFontUid) |
|
1123 |
{ |
|
1124 |
if (aScalable != (static_cast<CFbsFont*>(font))->IsOpenFont()) |
|
1125 |
{ |
|
1126 |
// Ignore the font because its scalable attribute |
|
1127 |
// doesn't correspond to aScalable parameter. |
|
1128 |
continue; |
|
1129 |
} |
|
1130 |
} |
|
1131 |
#ifdef _DEBUG |
|
1132 |
else |
|
1133 |
{ |
|
1134 |
// Non-recognized font type Uid. |
|
1135 |
__DEBUGGER(); |
|
1136 |
} |
|
1137 |
#endif |
|
1138 |
||
1139 |
||
1140 |
fontSpec = font->FontSpecInTwips(); |
|
1141 |
||
1142 |
// Look for available heights for the current font |
|
1143 |
if (FontUtils::GetAvailableHeightsInTwipsL(*(eikEnv.ScreenDevice()), |
|
1144 |
fontSpec.iTypeface.iName, *heightList) == KErrNone) |
|
1145 |
{ |
|
1146 |
fontData.iFontSpec = font->FontSpecInTwips(); |
|
1147 |
heightListCount = heightList->Count(); |
|
1148 |
for (heightIndex = 0; heightIndex<heightListCount; heightIndex++) |
|
1149 |
{ |
|
1150 |
fontData.iFontSpec.iHeight = getTheHeightInTWipsL(iCoeEnv, *this, |
|
1151 |
fontData.iFontSpec, heightIndex, heightList); |
|
1152 |
arrayFontData->AppendL(fontData); |
|
1153 |
} |
|
1154 |
} |
|
1155 |
heightList->Reset(); |
|
1156 |
eikEnv.ScreenDevice()->ReleaseFont(font); |
|
1157 |
font = NULL; |
|
1158 |
} |
|
1159 |
||
1160 |
CleanupStack::PopAndDestroy(heightList); |
|
1161 |
CleanupStack::Pop(arrayFontData); |
|
1162 |
CleanupStack::PopAndDestroy(fontNameList); |
|
1163 |
return arrayFontData; |
|
1164 |
} |
|
1165 |
||
1166 |
TRgb ASwtDisplayBase::GetSystemColor(TSwtColorId aId) const |
|
1167 |
{ |
|
1168 |
ASSERT_NATIVEUITHREAD(); |
|
1169 |
return iUiUtils->GetSystemColor(aId); //lint !e613 |
|
1170 |
} |
|
1171 |
||
1172 |
const MSwtFont* ASwtDisplayBase::GetSystemFont() const |
|
1173 |
{ |
|
1174 |
ASSERT_NATIVEUITHREAD(); |
|
1175 |
if (!iSystemFont) |
|
1176 |
{ |
|
1177 |
ASwtDisplayBase* self = const_cast<ASwtDisplayBase*>(this); |
|
1178 |
TRAP_IGNORE(self->iSystemFont = CSwtFont::NewL(*self, *AknLayoutUtils::FontFromId( |
|
1179 |
CSwtLafFacade::GetFontId(CSwtLafFacade::EForm2MidpLabelPaneT1Font, 0)))); |
|
1180 |
} |
|
1181 |
return iSystemFont; |
|
1182 |
} |
|
1183 |
||
1184 |
TInt ASwtDisplayBase::GetDefaultFontHeightL() |
|
1185 |
{ |
|
1186 |
TFontSpec fontSpec(KNullDesC, 0); |
|
1187 |
CFont* font = NULL; |
|
1188 |
CBitmapDevice& device = GraphicsDevice(); |
|
1189 |
User::LeaveIfError(device.GetNearestFontInTwips(font, fontSpec)); |
|
1190 |
||
1191 |
TInt result = 0; |
|
1192 |
if (font!=NULL) |
|
1193 |
{ |
|
1194 |
fontSpec = font->FontSpecInTwips(); |
|
1195 |
result = FontUtils::PointsFromTwips(fontSpec.iHeight); |
|
1196 |
device.ReleaseFont(font); |
|
1197 |
font = NULL; |
|
1198 |
} |
|
1199 |
||
1200 |
return result; |
|
1201 |
} |
|
1202 |
||
1203 |
||
1204 |
// |
|
1205 |
// Virtual methods from MSwtDrawable |
|
1206 |
// |
|
1207 |
||
1208 |
MSwtGc* ASwtDisplayBase::NewGcL() |
|
1209 |
{ |
|
1210 |
_LIT(KLibName, "scdv"); |
|
1211 |
||
1212 |
ASSERT_NATIVEUITHREAD(); |
|
1213 |
||
1214 |
CFbsScreenDevice* device = CFbsScreenDevice::NewL(KLibName, iCoeEnv->ScreenDevice()->DisplayMode()); |
|
1215 |
device->SetAutoUpdate(ETrue); |
|
1216 |
CleanupStack::PushL(device); |
|
1217 |
CFbsBitGc* nativeGc; |
|
1218 |
User::LeaveIfError(device->CreateContext(nativeGc)); |
|
1219 |
CleanupStack::Pop(device); |
|
1220 |
||
1221 |
return iFactory->NewBitmapGcL(*this, nativeGc, DestroyNativeGc, KRgbBlack, KRgbWhite, *iSystemFont); //lint !e613 |
|
1222 |
} |
|
1223 |
||
1224 |
void ASwtDisplayBase::DestroyNativeGc(CBitmapContext* aGc) |
|
1225 |
{ |
|
1226 |
delete aGc->Device(); |
|
1227 |
delete aGc; |
|
1228 |
} |
|
1229 |
||
1230 |
CBitmapDevice& ASwtDisplayBase::GraphicsDevice() |
|
1231 |
{ |
|
1232 |
ASSERT_NATIVEUITHREAD(); |
|
1233 |
return *(iCoeEnv->ScreenDevice()); |
|
1234 |
} |
|
1235 |
||
1236 |
void ASwtDisplayBase::HandleUpdate() |
|
1237 |
{ |
|
1238 |
// Nothing to do |
|
1239 |
} |
|
1240 |
||
1241 |
void ASwtDisplayBase::SetMobileDevice(MSwtMobileDevice* aMobileDevice) |
|
1242 |
{ |
|
1243 |
// Not to be called by anyone except CSwtMobileDevice and only once |
|
1244 |
ASSERT(!iMobileDevice); |
|
1245 |
iMobileDevice = aMobileDevice; |
|
1246 |
} |
|
1247 |
||
1248 |
MSwtMobileDevice* ASwtDisplayBase::MobileDevice() |
|
1249 |
{ |
|
1250 |
return iMobileDevice; |
|
1251 |
} |
|
1252 |
||
1253 |
#ifdef RD_SCALABLE_UI_V2 |
|
1254 |
void ASwtDisplayBase::TryDetectLongTapL(const TPointerEvent& aPointerEvent) |
|
1255 |
{ |
|
1256 |
ASSERT_NATIVEUITHREAD(); |
|
1257 |
ASSERT(iCommandArranger); |
|
1258 |
||
1259 |
if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
1260 |
{ |
|
1261 |
iLongTapControl = NULL; |
|
1262 |
iLongTapDetected = EFalse; |
|
1263 |
||
1264 |
// The Shell is required to already have handled the pointer down. |
|
1265 |
MSwtControl* ctrl = iUiUtils->GetPointerGrabbingControl(); |
|
1266 |
||
1267 |
// No long tap animation on scrollbars or trimings. |
|
1268 |
// Long tap animation only if there is a popup menu. |
|
1269 |
if (ctrl && ctrl->IsLongTapAnimationCandidate(aPointerEvent)) |
|
1270 |
{ |
|
1271 |
iLongTapControl = ctrl; |
|
1272 |
} |
|
1273 |
} |
|
1274 |
||
1275 |
iLongTapPointerEvent = aPointerEvent; |
|
1276 |
||
1277 |
if (iLongTapControl) |
|
1278 |
{ |
|
1279 |
iLongTapDetector->PointerEventL(aPointerEvent); |
|
1280 |
} |
|
1281 |
} |
|
1282 |
||
1283 |
MSwtControl* ASwtDisplayBase::LongTapAnimationControl() const |
|
1284 |
{ |
|
1285 |
ASSERT_NATIVEUITHREAD(); |
|
1286 |
return iLongTapControl; |
|
1287 |
} |
|
1288 |
||
1289 |
void ASwtDisplayBase::CancelLongTapAnimation() |
|
1290 |
{ |
|
1291 |
ASSERT_NATIVEUITHREAD(); |
|
1292 |
// IAD WARNING: Do not call CAknLongTapDetector::CancelAnimationL() |
|
1293 |
iLongTapControl = NULL; |
|
1294 |
iLongTapDetected = EFalse; |
|
1295 |
} |
|
1296 |
||
1297 |
void ASwtDisplayBase::HandleLongTapEventL(const TPoint& /*aPenEventLocation*/, |
|
1298 |
const TPoint& aPenEventScreenLocation) |
|
1299 |
{ |
|
1300 |
ASSERT_NATIVEUITHREAD(); |
|
1301 |
ASSERT(iMenuArranger); |
|
1302 |
||
1303 |
MSwtControl* ctrl = iLongTapControl; |
|
1304 |
if (!ctrl) |
|
1305 |
{ |
|
1306 |
// Control disposed or pen lifted just before menu was about to open. |
|
1307 |
iLongTapDetected = EFalse; |
|
1308 |
return; |
|
1309 |
} |
|
1310 |
||
1311 |
// Will be switched back after the popup menu closes |
|
1312 |
// and the late pointer up event was delivered. |
|
1313 |
iLongTapDetected = ETrue; |
|
1314 |
||
1315 |
// Open menu on the longTap cursor position |
|
1316 |
iMenuArranger->OpenStylusPopupMenuL(*ctrl, aPenEventScreenLocation, this); |
|
1317 |
} |
|
1318 |
#endif //RD_SCALABLE_UI_V2 |
|
1319 |
||
1320 |
// From MSwtPopupMenuCallBack |
|
1321 |
// Native Ui Thread |
|
1322 |
void ASwtDisplayBase::HandlePopupMenuClosedL() |
|
1323 |
{ |
|
1324 |
if (iLongTapControl) |
|
1325 |
{ |
|
1326 |
// Forward delayed pointer event |
|
1327 |
TPointerEvent event(iLongTapPointerEvent); |
|
1328 |
event.iType = TPointerEvent::EButton1Up; |
|
1329 |
||
1330 |
MSwtShell* shell = iLongTapControl->ShellInterface(); |
|
1331 |
if (shell) |
|
1332 |
{ |
|
1333 |
// The Shells do not process (forward event to children |
|
1334 |
// or send mouse event to Java) the pointer if revert is on. |
|
1335 |
// Therefore reset early to let Shell send the mouse event. |
|
1336 |
CancelLongTapAnimation(); |
|
1337 |
shell->Control()->HandlePointerEventL(event); // revert |
|
1338 |
} |
|
1339 |
else |
|
1340 |
{ |
|
1341 |
iLongTapControl->HandlePointerEventL(event); // revert |
|
1342 |
} |
|
1343 |
} |
|
1344 |
||
1345 |
// Just to clear the flags. |
|
1346 |
CancelLongTapAnimation(); |
|
1347 |
} |
|
1348 |
||
1349 |
// From MSwtMediaKeysListener |
|
1350 |
// Native Ui Thread |
|
1351 |
void ASwtDisplayBase::HandleMediaKeyEvent(TKeyEvent& aKeyEvent, TInt aEventType) |
|
1352 |
{ |
|
1353 |
ASSERT(iUiUtils); |
|
1354 |
||
1355 |
MSwtControl* focusControl = 0; |
|
1356 |
MSwtShell* activeShell = NULL; |
|
1357 |
||
1358 |
if (iUiUtils->IsAppFocused()) |
|
1359 |
{ |
|
1360 |
activeShell = iUiUtils->GetActiveShell(); |
|
1361 |
||
1362 |
if (activeShell) |
|
1363 |
{ |
|
1364 |
focusControl = activeShell->FocusControl(); |
|
1365 |
} |
|
1366 |
} |
|
1367 |
else |
|
1368 |
{ |
|
1369 |
CSwtUiUtils* uiUtils = static_cast<CSwtUiUtils*>(iUiUtils); |
|
1370 |
focusControl = uiUtils->NextFocusedControl(); |
|
1371 |
} |
|
1372 |
||
1373 |
if (focusControl) |
|
1374 |
{ |
|
1375 |
TRAP_IGNORE(focusControl->CoeControl().OfferKeyEventL(aKeyEvent, (TEventCode)aEventType)); |
|
1376 |
} |
|
1377 |
else |
|
1378 |
{ |
|
1379 |
if (activeShell) |
|
1380 |
{ |
|
1381 |
TRAP_IGNORE(activeShell->Control()->CoeControl().OfferKeyEventL(aKeyEvent, (TEventCode)aEventType)); |
|
1382 |
} |
|
1383 |
} |
|
1384 |
} |
|
1385 |
||
1386 |
TInt ASwtDisplayBase::LoadResourceFileL() |
|
1387 |
{ |
|
1388 |
TFileName langFile = java::util::S60CommonUtils::ResourceLanguageFileNameL(KSwtResFile); |
|
1389 |
return iCoeEnv->AddResourceFileL(langFile); |
|
1390 |
} |
|
83
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1391 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1392 |
void ASwtDisplayBase::StoreSvgAsMifL(const TDesC8& aSvgBuf, TFileName& aGeneratedFile) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1393 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1394 |
TInt iconDataSize = aSvgBuf.Length(); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1395 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1396 |
// File header |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1397 |
TMifFileHeader fileHeader; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1398 |
fileHeader.iUid = KMifFileHeaderUid; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1399 |
fileHeader.iVersion = KMifFileHeaderVersion; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1400 |
fileHeader.iOffset = sizeof(fileHeader); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1401 |
fileHeader.iLength = KMifFileHeaderLength; // number of indexes |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1402 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1403 |
// Icon offset element |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1404 |
TMifIconOffset iconOffset; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1405 |
iconOffset.iIconOffset = sizeof(fileHeader) + sizeof(iconOffset) * KMifFileHeaderLength; // mif header + icon offset |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1406 |
iconOffset.iIconLength = sizeof(TMifIconHeader) + iconDataSize; // icon header + icon data |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1407 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1408 |
// Icon header |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1409 |
TMifIconHeader iconHeader; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1410 |
iconHeader.iUid = KMifIconHeaderUid; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1411 |
iconHeader.iVersion = KMifIconHeaderVersion; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1412 |
iconHeader.iOffset = sizeof(iconHeader); // dataOffset |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1413 |
iconHeader.iLength = iconDataSize; // dataLength |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1414 |
iconHeader.iType = KMifIconHeaderType; // svg |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1415 |
iconHeader.iDepth = EColor16M; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1416 |
iconHeader.iAnimated = KMifIconHeaderAnimated; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1417 |
iconHeader.iMaskDepth = EColor16M; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1418 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1419 |
// Generate a unique filename for the temporary mif file. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1420 |
// During the execution of the app, there cannot be 2 svg |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1421 |
// images loaded from the same mif file due to caching. |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1422 |
aGeneratedFile.Append(KTempMifFileDrive); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1423 |
TTime now; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1424 |
if (now.UniversalTimeSecure() != KErrNone) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1425 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1426 |
now.UniversalTime(); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1427 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1428 |
TInt64 seed = now.Int64(); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1429 |
aGeneratedFile.AppendNum(iApplicationUid, EHex); // the app uid |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1430 |
aGeneratedFile.AppendNum(seed, EHex); // universal time |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1431 |
aGeneratedFile.AppendNum(Math::Rand(seed), EHex);// random number |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1432 |
aGeneratedFile.Append(KTempMifFileExt); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1433 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1434 |
// Create MIFConverter class |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1435 |
CMifConverter* mifConverter = CMifConverter::NewL(iCoeEnv->FsSession(), aGeneratedFile); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1436 |
CleanupStack::PushL(mifConverter); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1437 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1438 |
// Write mif file header |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1439 |
mifConverter->WriteMifFileHeaderL(fileHeader); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1440 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1441 |
// Insert 2 iconOffset elements: first for the image, the other for the mask |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1442 |
mifConverter->WriteMifIconOffsetL(iconOffset); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1443 |
mifConverter->WriteMifIconOffsetL(iconOffset); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1444 |
mifConverter->WriteMifIconHeaderL(iconHeader); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1445 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1446 |
// Write mif file body |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1447 |
mifConverter->WriteMifBodyL(aSvgBuf); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1448 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1449 |
// Cleanup |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1450 |
CleanupStack::PopAndDestroy(mifConverter); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1451 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1452 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1453 |
HBufC8* ASwtDisplayBase::LoadFileL(const TDesC& aFileName) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1454 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1455 |
RFile file; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1456 |
User::LeaveIfError(file.Open(iCoeEnv->FsSession(), aFileName, EFileRead)); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1457 |
TInt size; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1458 |
User::LeaveIfError(file.Size(size)); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1459 |
HBufC8* buf = HBufC8::NewLC(size); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1460 |
TPtr8 ptr(buf->Des()); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1461 |
User::LeaveIfError(file.Read(ptr, size)); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1462 |
CleanupStack::Pop(buf); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1463 |
file.Close(); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1464 |
return buf; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1465 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1466 |
|
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1467 |
CFbsBitmap* ASwtDisplayBase::RasterizeL(const CFbsBitmap& aMifBmp) |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1468 |
{ |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1469 |
CFbsBitmap* bmp = new(ELeave) CFbsBitmap; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1470 |
CleanupStack::PushL(bmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1471 |
User::LeaveIfError(bmp->Create(aMifBmp.SizeInPixels(), aMifBmp.DisplayMode())); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1472 |
CFbsBitmapDevice* dev = CFbsBitmapDevice::NewL(bmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1473 |
CleanupStack::PushL(dev); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1474 |
CFbsBitGc* gc = NULL; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1475 |
User::LeaveIfError(dev->CreateContext(gc)); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1476 |
gc->BitBlt(TPoint(), &aMifBmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1477 |
delete gc; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1478 |
CleanupStack::PopAndDestroy(dev); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1479 |
CleanupStack::Pop(bmp); |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1480 |
return bmp; |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1481 |
} |
26b2b12093af
Revision: v2.2.17
Dremov Kirill (Nokia-D-MSW/Tampere) <kirill.dremov@nokia.com>
parents:
66
diff
changeset
|
1482 |