|
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 <swtlaffacade.h> |
|
20 #include "s60commonutils.h" |
|
21 #include "swtfactory.h" |
|
22 #include "swtdisplaybase.h" |
|
23 #include "eswtwidgetsexpanded.h" |
|
24 #include "eswtmobileextensions.h" |
|
25 #include "swtevents.h" |
|
26 #include "swtkeymapper.h" |
|
27 #include "swttimer.h" |
|
28 #include "swtimage.h" |
|
29 #include "swtmidremconobserver.h" |
|
30 #include "swtjavabufferdrawer.h" |
|
31 #include "swtfont.h" |
|
32 #include "swtuiutils.h" |
|
33 |
|
34 |
|
35 #define ASSERT_JAVAUITHREAD() ASSERT(IsCurrentThreadJavaUi()) |
|
36 #define ASSERT_NATIVEUITHREAD() ASSERT(IsCurrentThreadNativeUi()) |
|
37 |
|
38 |
|
39 // Assuming ResourceLanguageFileNameL inserts DRIVE:/KDC_RESOURCE_FILES_DIR/java/ |
|
40 // Assuming KDC_RESOURCE_FILES_DIR = /resource/java/ |
|
41 _LIT(KSwtResFile, "eswtcore.rsc"); |
|
42 |
|
43 |
|
44 // ======== MEMBER FUNCTIONS ======== |
|
45 |
|
46 |
|
47 /** |
|
48 * 2nd phase constructor |
|
49 */ |
|
50 void ASwtDisplayBase::ConstructInJavaUiThreadL() |
|
51 { |
|
52 iEventQueue = CSwtEventQueue::NewL(*this); |
|
53 } |
|
54 |
|
55 /** |
|
56 * UI thread's side constructor |
|
57 */ |
|
58 void ASwtDisplayBase::ConstructInNativeUiThreadL() |
|
59 { |
|
60 ASSERT_NATIVEUITHREAD(); |
|
61 |
|
62 iCoeEnv = CEikonEnv::Static(); // codescanner::eikonenvstatic |
|
63 ASSERT(iCoeEnv); |
|
64 iFactory = CSwtFactory::NewL(); |
|
65 iResId = LoadResourceFileL(); |
|
66 iUiUtils = iFactory->NewUiUtilsL(*this); |
|
67 iMenuArranger = iFactory->NewMenuArrangerL(*this); |
|
68 iCommandArranger = iFactory->NewCommandArrangerL(*this); |
|
69 iKeyMapper = CSwtKeyMapper::NewL(); |
|
70 iRemConObserver = CSwtMIDRemConObserver::NewL(); |
|
71 if (iRemConObserver) |
|
72 { |
|
73 iRemConObserver->AddMediaKeysListenerL(this); |
|
74 } |
|
75 iJavaBufferDrawer = new(ELeave) CSwtJavaBufferDrawer(*this); |
|
76 #ifdef RD_SCALABLE_UI_V2 |
|
77 iLongTapDetector = CAknLongTapDetector::NewL(this); |
|
78 #endif |
|
79 } |
|
80 |
|
81 |
|
82 /** |
|
83 * Destructor |
|
84 */ |
|
85 ASwtDisplayBase::~ASwtDisplayBase() |
|
86 { |
|
87 } |
|
88 |
|
89 |
|
90 /** |
|
91 * Destroys the Display part that runs in the UI thread |
|
92 */ |
|
93 void ASwtDisplayBase::DestroyInNativeUiThread() |
|
94 { |
|
95 ASSERT_NATIVEUITHREAD(); |
|
96 |
|
97 if (iRemConObserver) |
|
98 { |
|
99 iRemConObserver->RemoveMediaKeysListener(this); |
|
100 } |
|
101 delete iRemConObserver; |
|
102 iRemConObserver = NULL; |
|
103 |
|
104 if (iSystemFont) |
|
105 { |
|
106 iSystemFont->RemoveRef(); |
|
107 iSystemFont = NULL; |
|
108 } |
|
109 |
|
110 delete iKeyMapper; |
|
111 iKeyMapper = NULL; |
|
112 |
|
113 delete iCommandArranger; // Mobile Extensions |
|
114 iCommandArranger = NULL; |
|
115 |
|
116 delete iMenuArranger; |
|
117 iMenuArranger = NULL; |
|
118 |
|
119 delete iUiUtils; // Core |
|
120 iUiUtils = NULL; |
|
121 |
|
122 delete iFactory; |
|
123 iFactory = NULL; |
|
124 |
|
125 iTimers.ResetAndDestroy(); |
|
126 |
|
127 if (iEventQueue) |
|
128 iEventQueue->Flush(); |
|
129 |
|
130 iResourceChangeObservers.Close(); |
|
131 iAppFocusObservers.Close(); |
|
132 |
|
133 delete iJavaBufferDrawer; |
|
134 iJavaBufferDrawer = NULL; |
|
135 |
|
136 #ifdef RD_SCALABLE_UI_V2 |
|
137 delete iLongTapDetector; |
|
138 iLongTapDetector = NULL; |
|
139 #endif //RD_SCALABLE_UI_V2 |
|
140 |
|
141 if (iResId != KErrNotFound) |
|
142 { |
|
143 iCoeEnv->DeleteResourceFile(iResId); |
|
144 iResId = KErrNotFound; |
|
145 } |
|
146 |
|
147 iCoeEnv = NULL; |
|
148 } |
|
149 |
|
150 |
|
151 /** |
|
152 * Sleeps until an event is received |
|
153 * |
|
154 * Must be executed in the main thread. |
|
155 * |
|
156 * @return <code>ETrue</code> if the reason for awakening is reception of an |
|
157 * event; <code>EFalse</code> otherwise. |
|
158 */ |
|
159 TBool ASwtDisplayBase::Sleep() |
|
160 { |
|
161 ASSERT_JAVAUITHREAD(); |
|
162 |
|
163 // Must be set before checking if the queue is empty so that if an event |
|
164 // arrives between the moment we checked the queue and when we call |
|
165 // WaitForRequest(), we won't go to sleep. |
|
166 iRequestStatus = KRequestPending; |
|
167 |
|
168 if (!iEventQueue->IsEmpty()) //lint !e613 |
|
169 return ETrue; |
|
170 |
|
171 User::WaitForRequest(iRequestStatus); |
|
172 return ETrue; |
|
173 } |
|
174 |
|
175 /** |
|
176 * Creates a new timer that will auto-destruct. It will also register with |
|
177 * <code>RegisterTimerL()</code>, in case we need to exit and the timer is |
|
178 * still running. |
|
179 */ |
|
180 void ASwtDisplayBase::AddTimerL(TInt aDelayInMilliSeconds, TInt aTimerHandle) |
|
181 { |
|
182 CSwtTimer* timer = CSwtTimer::NewL(*this); |
|
183 timer->ExecuteAfterLD(aDelayInMilliSeconds, aTimerHandle); |
|
184 } |
|
185 |
|
186 |
|
187 /** |
|
188 * Adds a new timer to the java side timer list |
|
189 */ |
|
190 void ASwtDisplayBase::RegisterTimerL(const CSwtTimer* aTimer) |
|
191 { |
|
192 UnRegisterTimer(aTimer); //prevents duplicating timers |
|
193 User::LeaveIfError(iTimers.Append(aTimer)); |
|
194 } |
|
195 |
|
196 |
|
197 /** |
|
198 * Removes the timer from the java side timer list |
|
199 */ |
|
200 void ASwtDisplayBase::UnRegisterTimer(const CSwtTimer* aTimer) |
|
201 { |
|
202 TInt pos = iTimers.Find(aTimer); |
|
203 if (pos >= 0) |
|
204 { |
|
205 iTimers.Remove(pos); |
|
206 } |
|
207 } |
|
208 |
|
209 |
|
210 /** |
|
211 * Awakens the display because of reception of a new event. |
|
212 * |
|
213 * Must be executed from within the App UI's thread. |
|
214 */ |
|
215 void ASwtDisplayBase::HandleNewEvent() |
|
216 { |
|
217 ASSERT_NATIVEUITHREAD(); |
|
218 DoWake(ETrue); |
|
219 } |
|
220 |
|
221 |
|
222 /** |
|
223 * Awakens the display (i.e. the main thread) |
|
224 */ |
|
225 void ASwtDisplayBase::DoWake(TBool aBecauseOfEvent) |
|
226 { |
|
227 if (iRequestStatus == KRequestPending) |
|
228 { |
|
229 TRequestStatus* statusPtr = &iRequestStatus; |
|
230 iJavaUiThread.RequestComplete(statusPtr, aBecauseOfEvent); |
|
231 } |
|
232 } |
|
233 |
|
234 |
|
235 /** |
|
236 * Returns the maximum allowed depth of icons |
|
237 * |
|
238 * Must be executed from within the App UI's thread. |
|
239 */ |
|
240 TInt ASwtDisplayBase::GetIconDepth() const |
|
241 { |
|
242 ASSERT_NATIVEUITHREAD(); |
|
243 return TDisplayModeUtils::NumDisplayModeBitsPerPixel(iCoeEnv->ScreenDevice()->DisplayMode()); |
|
244 } |
|
245 |
|
246 |
|
247 /** |
|
248 * Returns the double click time |
|
249 * |
|
250 * Must be executed from within the App UI's thread. |
|
251 */ |
|
252 TInt ASwtDisplayBase::GetDoubleClickTime() const |
|
253 { |
|
254 ASSERT_NATIVEUITHREAD(); |
|
255 TTimeIntervalMicroSeconds32 interval(0); |
|
256 TInt distance(0); |
|
257 iCoeEnv->WsSession().GetDoubleClickSettings(interval, distance); |
|
258 return interval.Int(); |
|
259 } |
|
260 |
|
261 |
|
262 /** |
|
263 * Emits a beep |
|
264 * |
|
265 * Must be executed from within the App UI's thread. |
|
266 */ |
|
267 void ASwtDisplayBase::Beep() const |
|
268 { |
|
269 ASSERT_NATIVEUITHREAD(); |
|
270 iCoeEnv->Beep(); |
|
271 } |
|
272 |
|
273 |
|
274 /** |
|
275 * Posts an asynchronous event. |
|
276 * |
|
277 * @param aData SWT data of the key event. |
|
278 * |
|
279 * This method should be able to post events of type KeyDown or KeyUp. |
|
280 */ |
|
281 void ASwtDisplayBase::PostL(const TSwtKeyEventData& aData) |
|
282 { |
|
283 ASSERT_NATIVEUITHREAD(); |
|
284 |
|
285 if ((aData.iType == ESwtEventKeyDown) || (aData.iType == ESwtEventKeyUp)) |
|
286 { |
|
287 MSwtShell* shell = iUiUtils->GetActiveShell(); |
|
288 if (shell == NULL) |
|
289 { |
|
290 return; |
|
291 } |
|
292 MSwtControl* control = shell->FocusControl(); |
|
293 if (control == NULL) |
|
294 { |
|
295 return; |
|
296 } |
|
297 |
|
298 TKeyEvent keyEvent; |
|
299 keyEvent.iCode = 0; |
|
300 keyEvent.iRepeats = 0; |
|
301 keyEvent.iModifiers = iKeyMapper->GetSymbianModifier(aData); |
|
302 |
|
303 if (aData.iType == ESwtEventKeyUp) |
|
304 { |
|
305 // Key up event: keyEvent.iCode is set to 0 |
|
306 keyEvent.iScanCode = iKeyMapper->GetSymbianScanCode(aData.iKeyCode); |
|
307 control->CoeControl().OfferKeyEventL(keyEvent, EEventKeyUp); |
|
308 } |
|
309 else |
|
310 { |
|
311 // Key down event in SWT = key down event follows with key event in Symbian |
|
312 // If several SWT ESwtEventKeyDown are following, |
|
313 // we should post first one Symbian EEventKeyDown |
|
314 // and then as many Symbian EEventKey as SWT ESwtEventKeyDown. |
|
315 // But posting EEventKeyDown and EEventKey at each time should not cause any problem. |
|
316 |
|
317 // Key down event: keyEvent.iCode is set to 0 |
|
318 TUint code = aData.iCharacter; |
|
319 iKeyMapper->GetSymbianCodes(aData.iKeyCode, keyEvent.iScanCode, &code); |
|
320 control->CoeControl().OfferKeyEventL(keyEvent, EEventKeyDown); |
|
321 |
|
322 // Key event: keyEvent.iCode is not 0. |
|
323 keyEvent.iCode = code; |
|
324 control->CoeControl().OfferKeyEventL(keyEvent, EEventKey); |
|
325 } |
|
326 } |
|
327 } |
|
328 |
|
329 /** |
|
330 * Posts an asynchronous event. |
|
331 * @param aData SWT data of the mouse event. |
|
332 * This method should be able to post events of type MouseDown, MouseUp, MouseMove. |
|
333 */ |
|
334 TBool ASwtDisplayBase::MousePostL(const TSwtKeyEventData& aData, TPoint point) |
|
335 { |
|
336 ASSERT_NATIVEUITHREAD(); |
|
337 |
|
338 if (AknLayoutUtils::PenEnabled()) |
|
339 { |
|
340 TRawEvent event; |
|
341 if (aData.iType == ESwtEventMouseDown) |
|
342 { |
|
343 event.Set(TRawEvent::EButton1Down, point.iX, point.iY); |
|
344 iCoeEnv->WsSession().SimulateRawEvent(event); |
|
345 } |
|
346 else if (aData.iType == ESwtEventMouseUp) |
|
347 { |
|
348 event.Set(TRawEvent::EButton1Up, point.iX, point.iY); |
|
349 iCoeEnv->WsSession().SimulateRawEvent(event); |
|
350 } |
|
351 else if (aData.iType == ESwtEventMouseMove) |
|
352 { |
|
353 event.Set(TRawEvent::EPointerMove, point.iX, point.iY); |
|
354 iCoeEnv->WsSession().SimulateRawEvent(event); |
|
355 } |
|
356 return ETrue; |
|
357 } |
|
358 else |
|
359 { |
|
360 return EFalse; |
|
361 } |
|
362 } |
|
363 |
|
364 /** |
|
365 * Constructs an uninitialised Image |
|
366 * |
|
367 * @param aSize The new image's size |
|
368 */ |
|
369 MSwtImage* ASwtDisplayBase::NewImageL(const TSize& aSize) |
|
370 { |
|
371 return CSwtImage::NewL(*this, aSize, *this); |
|
372 } |
|
373 |
|
374 |
|
375 /** |
|
376 * Constructs an Image with initial data |
|
377 * |
|
378 * @param aData The data to construct the image from |
|
379 */ |
|
380 MSwtImage* ASwtDisplayBase::NewImageFromDataL(const MSwtImageData& aData) |
|
381 { |
|
382 return CSwtImage::NewL(this, aData, this); |
|
383 } |
|
384 |
|
385 |
|
386 // |
|
387 // Own internal event methods |
|
388 // |
|
389 |
|
390 void ASwtDisplayBase::PostForegroundEventL(TSwtPeer aPeer, const TBool& aForeground) |
|
391 { |
|
392 ASSERT_NATIVEUITHREAD(); |
|
393 iEventQueue->PushL(new(ELeave) CSwtForegroundEvent(aPeer, aForeground)); //lint !e613 |
|
394 } |
|
395 |
|
396 |
|
397 // |
|
398 // Virtual methods from MSwtDisplay |
|
399 // |
|
400 |
|
401 MSwtDevice& ASwtDisplayBase::Device() |
|
402 { |
|
403 return *this; |
|
404 } |
|
405 |
|
406 const MSwtFactory& ASwtDisplayBase::Factory() const |
|
407 { |
|
408 ASSERT(iFactory); |
|
409 return *iFactory; |
|
410 } |
|
411 |
|
412 MSwtUiUtils& ASwtDisplayBase::UiUtils() |
|
413 { |
|
414 ASSERT(iUiUtils!=NULL); |
|
415 return *iUiUtils; //lint !e613 |
|
416 } |
|
417 |
|
418 MSwtMenuArranger& ASwtDisplayBase::MenuArranger() |
|
419 { |
|
420 ASSERT(iMenuArranger!=NULL); |
|
421 return *iMenuArranger; |
|
422 } |
|
423 |
|
424 MSwtCommandArranger* ASwtDisplayBase::CommandArranger() |
|
425 { |
|
426 return iCommandArranger; |
|
427 } |
|
428 |
|
429 void ASwtDisplayBase::AddResourceChangeObserverL(MSwtResourceChangeObserver* aObserver) |
|
430 { |
|
431 User::LeaveIfError(iResourceChangeObservers.Append(aObserver)); |
|
432 } |
|
433 |
|
434 void ASwtDisplayBase::RemoveResourceChangeObserver(MSwtResourceChangeObserver* aObserver) |
|
435 { |
|
436 TInt pos = iResourceChangeObservers.Find(aObserver); |
|
437 if (pos != KErrNotFound) |
|
438 { |
|
439 iResourceChangeObservers.Remove(pos); |
|
440 } |
|
441 } |
|
442 |
|
443 void ASwtDisplayBase::AddAppFocusObserverL(MSwtAppFocusObserver* aObserver) |
|
444 { |
|
445 User::LeaveIfError(iAppFocusObservers.Append(aObserver)); |
|
446 } |
|
447 |
|
448 void ASwtDisplayBase::RemoveAppFocusObserver(MSwtAppFocusObserver* aObserver) |
|
449 { |
|
450 TInt pos = iAppFocusObservers.Find(aObserver); |
|
451 if (pos != KErrNotFound) |
|
452 { |
|
453 iAppFocusObservers.Remove(pos); |
|
454 } |
|
455 } |
|
456 |
|
457 TInt ASwtDisplayBase::GetSymbianScanCode(const TInt aSwtKeyCode) const |
|
458 { |
|
459 return CSwtKeyMapper::GetSymbianScanCode(aSwtKeyCode); |
|
460 } |
|
461 |
|
462 TUint ASwtDisplayBase::GetSymbianKeyCode(const TInt aSwtKeyCode) const |
|
463 { |
|
464 TUint keyCode = aSwtKeyCode; |
|
465 TInt scanCodeNotNeeded; |
|
466 CSwtKeyMapper::GetSymbianCodes(aSwtKeyCode, scanCodeNotNeeded, &keyCode); |
|
467 return keyCode; |
|
468 } |
|
469 |
|
470 void ASwtDisplayBase::ForceTraverseEventL(MSwtControl& aControl, TSwtTraversal aDetail, TBool aDoIt) |
|
471 { |
|
472 ASSERT_NATIVEUITHREAD(); |
|
473 |
|
474 TSwtKeyEventData data; |
|
475 data.iType = ESwtEventTraverse; |
|
476 data.iCharacter = 0; |
|
477 data.iKeyCode = 0; |
|
478 data.iStateMask = 0; |
|
479 |
|
480 TKeyEvent keyEvent; |
|
481 keyEvent.iCode = 0; |
|
482 keyEvent.iModifiers = 0; |
|
483 keyEvent.iRepeats = 0; |
|
484 keyEvent.iScanCode = 0; |
|
485 |
|
486 iEventQueue->PushL(new(ELeave) CSwtTraverseEvent(aControl, aDetail, aDoIt, data, keyEvent, EEventKey)); //lint !e613 |
|
487 } |
|
488 |
|
489 |
|
490 void ASwtDisplayBase::PostTraverseEventL(MSwtControl& aControl, TSwtTraversal aDetail, const TKeyEvent& aKeyEvent, |
|
491 TEventCode aType, TBool aDoIt) |
|
492 { |
|
493 ASSERT_NATIVEUITHREAD(); |
|
494 ASSERT(iKeyMapper!=NULL); |
|
495 |
|
496 TSwtKeyEventData data(iKeyMapper->MapKeyEventL(aKeyEvent, aType)); //lint !e613 |
|
497 if (data.iType != ESwtEventNone) |
|
498 iEventQueue->PushL(new(ELeave) CSwtTraverseEvent(aControl, aDetail, aDoIt, data, aKeyEvent, aType)); //lint !e613 |
|
499 } |
|
500 |
|
501 |
|
502 void ASwtDisplayBase::PostKeyEventL(MSwtControl& aControl, const TKeyEvent& aKeyEvent, TEventCode aType) |
|
503 { |
|
504 ASSERT_NATIVEUITHREAD(); |
|
505 ASSERT(iKeyMapper!=NULL); |
|
506 ASSERT(aType!=EEventNull); |
|
507 |
|
508 // EEventKeyDown can be posted only if the key does not generate EEventKey! |
|
509 TSwtKeyEventData data(iKeyMapper->MapKeyEventL(aKeyEvent, aType)); //lint !e613 |
|
510 if (data.iType != ESwtEventNone) |
|
511 iEventQueue->PushL(new(ELeave) CSwtKeyEvent(aControl, data, aKeyEvent, aType)); //lint !e613 |
|
512 } |
|
513 |
|
514 |
|
515 void ASwtDisplayBase::PostPaintEventL(TSwtPeer aSenderPeer, TSwtPeer aShellPeer, const TRect& aRect, TBool aMergeable) |
|
516 { |
|
517 ASSERT_NATIVEUITHREAD(); |
|
518 iEventQueue->PushL(new(ELeave) CSwtPaintEvent(aSenderPeer, aShellPeer, aRect, aMergeable)); //lint !e613 |
|
519 } |
|
520 |
|
521 |
|
522 void ASwtDisplayBase::PostMouseEventL(TSwtPeer aPeer, TSwtEventType aType, TInt aButton, const TPoint& aPos, TInt aStateMask) |
|
523 { |
|
524 ASSERT_NATIVEUITHREAD(); |
|
525 ASSERT(aType>=ESwtEventMouseDown && aType<=ESwtEventMouseDoubleClick); |
|
526 ASSERT(aButton==0 || (aType==ESwtEventMouseDown || aType==ESwtEventMouseUp)); |
|
527 |
|
528 #ifdef RD_SCALABLE_UI_V2 |
|
529 // After the long tap we send mouse up event for button2, see also HandleLongTapEventL(). |
|
530 if (iLongTapDetected && aType == ESwtEventMouseUp && aButton == KSwtMouseButton1) |
|
531 { |
|
532 aButton = KSwtMouseButton2; |
|
533 } |
|
534 #endif //RD_SCALABLE_UI_V2 |
|
535 |
|
536 iEventQueue->PushL(new(ELeave) CSwtMouseEvent(aPeer, aType, aButton, aPos, aStateMask)); //lint !e613 |
|
537 } |
|
538 |
|
539 void ASwtDisplayBase::PostMoveEventL(TSwtPeer aPeer) |
|
540 { |
|
541 ASSERT_NATIVEUITHREAD(); |
|
542 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventMove)); //lint !e613 |
|
543 } |
|
544 |
|
545 void ASwtDisplayBase::PostResizeEventL(TSwtPeer aPeer) |
|
546 { |
|
547 ASSERT_NATIVEUITHREAD(); |
|
548 iEventQueue->PushL(new(ELeave) CSwtResizeEvent(aPeer)); //lint !e613 |
|
549 } |
|
550 |
|
551 void ASwtDisplayBase::PostScrollEventL(TSwtPeer aPeer, TInt aDetail) |
|
552 { |
|
553 ASSERT_NATIVEUITHREAD(); |
|
554 iEventQueue->PushL(new(ELeave) CSwtScrollEvent(aPeer, aDetail)); //lint !e613 |
|
555 } |
|
556 |
|
557 void ASwtDisplayBase::PostSelectionEventL(TSwtPeer aPeer) |
|
558 { |
|
559 ASSERT_NATIVEUITHREAD(); |
|
560 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventSelection)); //lint !e613 |
|
561 } |
|
562 |
|
563 void ASwtDisplayBase::PostSelectionEventL(TSwtPeer aPeer, const TDesC& aText) |
|
564 { |
|
565 ASSERT_NATIVEUITHREAD(); |
|
566 iEventQueue->PushL(CSwtTextSelectionEvent::NewL(aPeer, aText)); //lint !e613 |
|
567 } |
|
568 |
|
569 void ASwtDisplayBase::PostSelectionEventL(TSwtPeer aPeer, TInt aDetail, TSwtPeer aItemPeer) |
|
570 { |
|
571 ASSERT_NATIVEUITHREAD(); |
|
572 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventSelection, aDetail, aItemPeer)); //lint !e613 |
|
573 } |
|
574 |
|
575 void ASwtDisplayBase::PostDefaultSelectionEventL(TSwtPeer aPeer) |
|
576 { |
|
577 ASSERT_NATIVEUITHREAD(); |
|
578 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventDefaultSelection,KSwtNone,NULL)); //lint !e613 |
|
579 } |
|
580 |
|
581 void ASwtDisplayBase::PostDefaultSelectionEventL(TSwtPeer aPeer, TInt aDetail, TSwtPeer aItemPeer) |
|
582 { |
|
583 ASSERT_NATIVEUITHREAD(); |
|
584 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventDefaultSelection, aDetail, aItemPeer)); //lint !e613 |
|
585 } |
|
586 |
|
587 void ASwtDisplayBase::PostFocusEventL(TSwtPeer aPeer, TSwtEventType aType) |
|
588 { |
|
589 ASSERT_NATIVEUITHREAD(); |
|
590 ASSERT(aType==ESwtEventFocusIn || aType==ESwtEventFocusOut); |
|
591 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, aType)); //lint !e613 |
|
592 } |
|
593 |
|
594 void ASwtDisplayBase::PostShellEventL(TSwtPeer aPeer, TSwtEventType aType) |
|
595 { |
|
596 ASSERT_NATIVEUITHREAD(); |
|
597 ASSERT(aType==ESwtEventActivate || aType==ESwtEventDeactivate); |
|
598 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, aType)); //lint !e613 |
|
599 } |
|
600 |
|
601 void ASwtDisplayBase::PostModifyEventL(TSwtPeer aPeer) |
|
602 { |
|
603 ASSERT_NATIVEUITHREAD(); |
|
604 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventModify, KSwtNone, NULL)); //lint !e613 |
|
605 } |
|
606 |
|
607 void ASwtDisplayBase::PostVerifyEventL(MSwtVerifyEventObserver& aWidget, TSwtPeer aPeer, TInt aStart, TInt aEnd, const TDesC& aText) |
|
608 { |
|
609 ASSERT_NATIVEUITHREAD(); |
|
610 ASSERT(aStart>=0 && aStart<=aEnd); |
|
611 iEventQueue->PushL(CSwtVerifyEvent::NewL(aWidget, aPeer, aStart, aEnd, aText)); //lint !e613 |
|
612 } |
|
613 |
|
614 void ASwtDisplayBase::PostShowEventL(TSwtPeer aPeer) |
|
615 { |
|
616 ASSERT_NATIVEUITHREAD(); |
|
617 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventShow)); //lint !e613 |
|
618 } |
|
619 |
|
620 void ASwtDisplayBase::PostHideEventL(TSwtPeer aPeer) |
|
621 { |
|
622 ASSERT_NATIVEUITHREAD(); |
|
623 iEventQueue->PushL(new(ELeave) CSwtPlainEvent(aPeer, ESwtEventHide)); //lint !e613 |
|
624 } |
|
625 |
|
626 void ASwtDisplayBase::PostScreenEventL(TSwtPeer aPeer, TInt aType) |
|
627 { |
|
628 ASSERT_NATIVEUITHREAD(); |
|
629 iEventQueue->PushL(new(ELeave) CSwtScreenEvent(aPeer, aType)); //lint !e613 |
|
630 } |
|
631 |
|
632 void ASwtDisplayBase::PostMobileDeviceEventL(TSwtPeer aPeer, TInt aEventType) |
|
633 { |
|
634 ASSERT_NATIVEUITHREAD(); |
|
635 iEventQueue->PushL(new(ELeave) CSwtMobileDeviceEvent(aPeer, aEventType)); //lint !e613 |
|
636 } |
|
637 |
|
638 void ASwtDisplayBase::PostTreeEventL(TSwtPeer aPeer, TSwtEventType aType, TInt aItemHandle) |
|
639 { |
|
640 ASSERT_NATIVEUITHREAD(); |
|
641 iEventQueue->PushL(new(ELeave) CSwtTreeEvent(aPeer, aType, aItemHandle)); //lint !e613 |
|
642 } |
|
643 |
|
644 void ASwtDisplayBase::PostLocationChangingEventL(TSwtPeer aPeer |
|
645 , MSwtBrowser& aBrowser, TBool aDoIt, TBool aTop |
|
646 , const TDesC& aLocation, TSwtBrCallBackOperationType aCallBackOperationType) |
|
647 { |
|
648 ASSERT_NATIVEUITHREAD(); |
|
649 iEventQueue->PushL(CSwtLocationChangingEvent::NewL(aPeer, aBrowser, aDoIt, aTop |
|
650 , aLocation, aCallBackOperationType)); |
|
651 } |
|
652 |
|
653 void ASwtDisplayBase::PostLocationChangedEventL(TSwtPeer aPeer, |
|
654 TBool aDoIt, TBool aTop, const TDesC& aLocation) |
|
655 { |
|
656 ASSERT_NATIVEUITHREAD(); |
|
657 iEventQueue->PushL(CSwtLocationChangedEvent::NewL(aPeer, aDoIt, aTop, aLocation)); |
|
658 } |
|
659 |
|
660 void ASwtDisplayBase::PostProgressEventL(TSwtPeer aPeer, TInt aCurrent, TInt aTotal) |
|
661 { |
|
662 ASSERT_NATIVEUITHREAD(); |
|
663 iEventQueue->PushL(new(ELeave) CSwtProgressEvent(aPeer, aCurrent, aTotal)); |
|
664 } |
|
665 |
|
666 void ASwtDisplayBase::PostProgressCompletedEventL(TSwtPeer aPeer, TInt aCurrent, TInt aTotal) |
|
667 { |
|
668 ASSERT_NATIVEUITHREAD(); |
|
669 iEventQueue->PushL(new(ELeave) CSwtProgressCompletedEvent(aPeer, aCurrent, aTotal)); |
|
670 } |
|
671 |
|
672 void ASwtDisplayBase::PostStatusTextEventL(TSwtPeer aPeer, const TDesC& aStatusText) |
|
673 { |
|
674 ASSERT_NATIVEUITHREAD(); |
|
675 iEventQueue->PushL(CSwtStatusTextEvent::NewL(aPeer, aStatusText)); |
|
676 } |
|
677 |
|
678 void ASwtDisplayBase::PostTitleEventL(TSwtPeer aPeer, const TDesC& aTitle) |
|
679 { |
|
680 ASSERT_NATIVEUITHREAD(); |
|
681 iEventQueue->PushL(CSwtTitleEvent::NewL(aPeer, aTitle)); |
|
682 } |
|
683 |
|
684 void ASwtDisplayBase::PostDialogResultEventL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, const TDesC& aDialogResult) |
|
685 { |
|
686 ASSERT_NATIVEUITHREAD(); |
|
687 iEventQueue->PushL(CSwtDialogStringResultEvent::NewL(aBroker, aPeer, aDialogResult)); |
|
688 } |
|
689 |
|
690 void ASwtDisplayBase::PostDialogResultEventL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, TInt aDialogResult) |
|
691 { |
|
692 ASSERT_NATIVEUITHREAD(); |
|
693 iEventQueue->PushL(new(ELeave) CSwtDialogIntegerResultEvent(aBroker, aPeer, aDialogResult)); |
|
694 } |
|
695 |
|
696 void ASwtDisplayBase::PostDialogResultEventL(CSwtDialogBroker* aBroker, TSwtPeer aPeer, TInt aDialogResult1, TInt aDialogResult2, TInt aDialogResult3) |
|
697 { |
|
698 ASSERT_NATIVEUITHREAD(); |
|
699 iEventQueue->PushL(new(ELeave) CSwtDialogRgbResultEvent(aBroker, aPeer, aDialogResult1, aDialogResult2, aDialogResult3)); |
|
700 } |
|
701 |
|
702 void ASwtDisplayBase::PostCloseEventL(TSwtPeer aPeer, TBool& aDispatched) |
|
703 { |
|
704 ASSERT_NATIVEUITHREAD(); |
|
705 iEventQueue->PushL(new(ELeave) CSwtCloseEvent(aPeer, aDispatched)); |
|
706 } |
|
707 |
|
708 TInt ASwtDisplayBase::ApplicationUid() |
|
709 { |
|
710 return iApplicationUid; |
|
711 } |
|
712 |
|
713 CEikonEnv* ASwtDisplayBase::CoeEnv() const |
|
714 { |
|
715 ASSERT(iCoeEnv); |
|
716 return iCoeEnv; |
|
717 } |
|
718 |
|
719 CDesC16ArrayFlat* ASwtDisplayBase::GetFontNamesL(TBool aScalable) const |
|
720 { |
|
721 ASSERT_NATIVEUITHREAD(); |
|
722 |
|
723 CEikonEnv* eikEnv = iCoeEnv; |
|
724 CWsScreenDevice* screenDevice = NULL; |
|
725 if (eikEnv) |
|
726 { |
|
727 screenDevice = eikEnv->ScreenDevice(); |
|
728 } |
|
729 if (!eikEnv || !screenDevice) |
|
730 { |
|
731 return NULL; |
|
732 } |
|
733 |
|
734 // Look for available fonts |
|
735 const TInt KArrayGranularity = 4; |
|
736 //Caller method is responsible for deleting the fontNameList |
|
737 CDesC16ArrayFlat* fontNameList = new(ELeave) CDesC16ArrayFlat(KArrayGranularity); |
|
738 CleanupStack::PushL(fontNameList); |
|
739 FontUtils::GetAvailableFontsL(*screenDevice, *fontNameList, EGulAllFonts); |
|
740 |
|
741 TFontSpec fontSpec; |
|
742 CFont* font = NULL; |
|
743 TInt fontNameListCount = fontNameList->Count(); |
|
744 for (TInt nameIndex=0; nameIndex<fontNameListCount; ++nameIndex) |
|
745 { |
|
746 // Look for the nearest font from the current typeface name. |
|
747 // This is needed only to check if the font correspond to the |
|
748 // aScalable parameter |
|
749 fontSpec.iTypeface.iName = (*fontNameList)[nameIndex]; |
|
750 fontSpec.iHeight = 0; |
|
751 fontSpec.iFontStyle = TFontStyle(EPostureUpright, EStrokeWeightNormal, EPrintPosNormal); |
|
752 User::LeaveIfError(screenDevice->GetNearestFontInTwips(font, fontSpec) == KErrNone); |
|
753 |
|
754 // Manage scalable attribute |
|
755 // CFont::TypeUid() returns the UId of the type of the font: |
|
756 // - KCFbsFontUid for a CFbsFont |
|
757 // - KCBitmapFontUid or KCBitmapFontUidVal for a CBitmapFont |
|
758 // On Series60 SDK, no Uid is available for CBitmapFont. |
|
759 // So scalable management is processed only for CFbsFont. |
|
760 // For the other font types, the font is always added to the list. |
|
761 if (font->TypeUid() == KCFbsFontUid) |
|
762 { |
|
763 if (aScalable !=(static_cast<CFbsFont*>(font))->IsOpenFont()) |
|
764 { |
|
765 // Delete the font because its scalable attribute |
|
766 // doesn't correspond to aScalable parameter. |
|
767 fontNameList->Delete(nameIndex); |
|
768 fontNameList->Compress(); |
|
769 fontNameListCount--; |
|
770 nameIndex--; |
|
771 } |
|
772 } |
|
773 #ifdef _DEBUG |
|
774 else |
|
775 { |
|
776 // Non-recognized font type Uid. |
|
777 __DEBUGGER(); |
|
778 } |
|
779 #endif |
|
780 screenDevice->ReleaseFont(font); |
|
781 font = NULL; |
|
782 } |
|
783 |
|
784 CleanupStack::Pop(fontNameList); |
|
785 return fontNameList; |
|
786 } |
|
787 |
|
788 TBool ASwtDisplayBase::RevertPointerEvent() const |
|
789 { |
|
790 return iRevertPointerEvent || iLongTapDetected; |
|
791 } |
|
792 |
|
793 void ASwtDisplayBase::SetRevertPointerEvent(TBool aStatus) |
|
794 { |
|
795 iRevertPointerEvent = aStatus; |
|
796 } |
|
797 |
|
798 // |
|
799 // Virtual methods from MSwtDevice |
|
800 // |
|
801 |
|
802 MSwtColor* ASwtDisplayBase::CreateColorL(const TRgb& aRgbValue) const |
|
803 { |
|
804 return iFactory->NewColorL(*this, aRgbValue); //lint !e613 |
|
805 } |
|
806 |
|
807 TRect ASwtDisplayBase::Bounds() const |
|
808 { |
|
809 ASSERT_NATIVEUITHREAD(); |
|
810 return TRect(iCoeEnv->EikAppUi()->ApplicationRect()); |
|
811 } |
|
812 |
|
813 TRect ASwtDisplayBase::ClientArea() const |
|
814 { |
|
815 ASSERT_NATIVEUITHREAD(); |
|
816 TRect appUiCltRect(iCoeEnv->EikAppUi()->ApplicationRect()); |
|
817 iUiUtils->Cba().ReduceRect(appUiCltRect); |
|
818 return appUiCltRect; |
|
819 } |
|
820 |
|
821 TInt ASwtDisplayBase::Depth() const |
|
822 { |
|
823 ASSERT_NATIVEUITHREAD(); |
|
824 switch (iCoeEnv->ScreenDevice()->DisplayMode()) |
|
825 { |
|
826 case EGray2: |
|
827 return 1; |
|
828 case EGray4: |
|
829 return 2; |
|
830 case EGray16: |
|
831 return 4; |
|
832 case EGray256: |
|
833 return 8; |
|
834 case EColor16: |
|
835 return 4; |
|
836 case EColor256: |
|
837 return 8; |
|
838 case EColor64K: |
|
839 return 16; |
|
840 case EColor16M: |
|
841 return 24; |
|
842 case EColor16MU: |
|
843 return 32; |
|
844 case EColor16MA: |
|
845 return 32; |
|
846 case EColor16MAP: |
|
847 return 32; |
|
848 case EColor4K: |
|
849 return 12; |
|
850 default: |
|
851 ASSERT(EFalse); |
|
852 return 0; |
|
853 } |
|
854 } |
|
855 |
|
856 TSize ASwtDisplayBase::Dpi() const |
|
857 { |
|
858 ASSERT_NATIVEUITHREAD(); |
|
859 |
|
860 // Convert a 1440x1440 twips (i.e. 1x1 inch) square to pixels, this yelds the |
|
861 // DPI resolution. |
|
862 return iCoeEnv->ScreenDevice()->TwipsToPixels(TPoint(KTwipsPerInch,KTwipsPerInch)).AsSize(); |
|
863 } |
|
864 |
|
865 static TInt getTheHeightInTWipsL(CEikonEnv* aEnv, const MSwtDevice& aDevice, |
|
866 const TFontSpec& aFontSpec, TInt aIndexInArray, CArrayFixFlat<TInt>* aArrayHeight) |
|
867 { |
|
868 TFontSpec fontSpec(aFontSpec); |
|
869 CFont* iFont = NULL; |
|
870 TInt heightInTWips = aArrayHeight->At(aIndexInArray); |
|
871 TInt heightOfObtainFontPt = 0; |
|
872 TInt heightOfAskedFontPt = FontUtils::PointsFromTwips(heightInTWips); |
|
873 TInt maxHeightPt = FontUtils::PointsFromTwips(aArrayHeight->At(aArrayHeight->Count()-1)); |
|
874 |
|
875 CBitmapDevice& bmpDevice = *(aEnv->ScreenDevice()); |
|
876 |
|
877 // Look for available heights for the current font. |
|
878 fontSpec.iHeight = FontUtils::TwipsFromPoints(heightOfAskedFontPt); |
|
879 User::LeaveIfError(bmpDevice.GetNearestFontInTwips(iFont, fontSpec)); |
|
880 heightOfObtainFontPt = FontUtils::PointsFromTwips(iFont->FontSpecInTwips().iHeight); |
|
881 |
|
882 while (((heightInTWips != iFont->FontSpecInTwips().iHeight) |
|
883 && (heightOfAskedFontPt < maxHeightPt)) |
|
884 && (heightOfAskedFontPt > heightOfObtainFontPt)) |
|
885 { |
|
886 heightOfAskedFontPt++; |
|
887 fontSpec.iHeight = FontUtils::TwipsFromPoints(heightOfAskedFontPt); |
|
888 |
|
889 const_cast<MSwtDevice&>(aDevice).GraphicsDevice().ReleaseFont(iFont); |
|
890 heightOfObtainFontPt = FontUtils::PointsFromTwips(iFont->FontSpecInTwips().iHeight); |
|
891 User::LeaveIfError(bmpDevice.GetNearestFontInTwips(iFont, fontSpec)); |
|
892 } |
|
893 |
|
894 const_cast<MSwtDevice&>(aDevice).GraphicsDevice().ReleaseFont(iFont); |
|
895 return fontSpec.iHeight; |
|
896 } |
|
897 |
|
898 CArrayFixFlat<TSwtFontData>* ASwtDisplayBase::GetFontListL(const TDesC& aFaceName, TBool aScalable) const |
|
899 { |
|
900 ASSERT_NATIVEUITHREAD(); |
|
901 |
|
902 CEikonEnv& eikEnv = *iCoeEnv; |
|
903 |
|
904 // Look for available fonts |
|
905 const TInt KArrayGranularity = 4; |
|
906 CDesC16ArrayFlat* fontNameList = new(ELeave) CDesC16ArrayFlat(KArrayGranularity); |
|
907 CleanupStack::PushL(fontNameList); |
|
908 if (aFaceName.Length() == 0) |
|
909 { |
|
910 FontUtils::GetAvailableFontsL(*(eikEnv.ScreenDevice()), *fontNameList, EGulAllFonts); |
|
911 } |
|
912 else |
|
913 { |
|
914 fontNameList->AppendL(aFaceName); |
|
915 } |
|
916 |
|
917 CArrayFixFlat<TSwtFontData>* arrayFontData = new(ELeave) CArrayFixFlat<TSwtFontData>(KArrayGranularity); |
|
918 CleanupStack::PushL(arrayFontData); |
|
919 |
|
920 CArrayFixFlat<TInt>* heightList = new(ELeave)CArrayFixFlat<TInt>(KArrayGranularity); |
|
921 CleanupStack::PushL(heightList); |
|
922 |
|
923 TFontSpec fontSpec; |
|
924 TSwtFontData fontData; |
|
925 CFont* font = NULL; |
|
926 TInt heightIndex; |
|
927 TInt fontNameListCount = fontNameList->Count(); |
|
928 TInt heightListCount; |
|
929 for (TInt nameIndex=0; nameIndex<fontNameListCount; ++nameIndex) |
|
930 { |
|
931 // Look for the nearest font from the current typeface name. |
|
932 fontSpec.iTypeface.iName = (*fontNameList)[nameIndex]; |
|
933 fontSpec.iHeight = 0; |
|
934 fontSpec.iFontStyle = TFontStyle(EPostureUpright, EStrokeWeightNormal, EPrintPosNormal); |
|
935 User::LeaveIfError(eikEnv.ScreenDevice()->GetNearestFontInTwips(font, fontSpec) == KErrNone); |
|
936 |
|
937 // Manage scalable attribute |
|
938 // CFont::TypeUid() returns the UId of the type of the font: |
|
939 // - KCFbsFontUid for a CFbsFont |
|
940 // - KCBitmapFontUid or KCBitmapFontUidVal for a CBitmapFont |
|
941 // On Series60 SDK, no Uid is available for CBitmapFont. |
|
942 // So scalable management is processed only for CFbsFont. |
|
943 // For the other font types, the font is always added to the list. |
|
944 if (font->TypeUid() == KCFbsFontUid) |
|
945 { |
|
946 if (aScalable != (static_cast<CFbsFont*>(font))->IsOpenFont()) |
|
947 { |
|
948 // Ignore the font because its scalable attribute |
|
949 // doesn't correspond to aScalable parameter. |
|
950 continue; |
|
951 } |
|
952 } |
|
953 #ifdef _DEBUG |
|
954 else |
|
955 { |
|
956 // Non-recognized font type Uid. |
|
957 __DEBUGGER(); |
|
958 } |
|
959 #endif |
|
960 |
|
961 |
|
962 fontSpec = font->FontSpecInTwips(); |
|
963 |
|
964 // Look for available heights for the current font |
|
965 if (FontUtils::GetAvailableHeightsInTwipsL(*(eikEnv.ScreenDevice()), |
|
966 fontSpec.iTypeface.iName, *heightList) == KErrNone) |
|
967 { |
|
968 fontData.iFontSpec = font->FontSpecInTwips(); |
|
969 heightListCount = heightList->Count(); |
|
970 for (heightIndex = 0; heightIndex<heightListCount; heightIndex++) |
|
971 { |
|
972 fontData.iFontSpec.iHeight = getTheHeightInTWipsL(iCoeEnv, *this, |
|
973 fontData.iFontSpec, heightIndex, heightList); |
|
974 arrayFontData->AppendL(fontData); |
|
975 } |
|
976 } |
|
977 heightList->Reset(); |
|
978 eikEnv.ScreenDevice()->ReleaseFont(font); |
|
979 font = NULL; |
|
980 } |
|
981 |
|
982 CleanupStack::PopAndDestroy(heightList); |
|
983 CleanupStack::Pop(arrayFontData); |
|
984 CleanupStack::PopAndDestroy(fontNameList); |
|
985 return arrayFontData; |
|
986 } |
|
987 |
|
988 TRgb ASwtDisplayBase::GetSystemColor(TSwtColorId aId) const |
|
989 { |
|
990 ASSERT_NATIVEUITHREAD(); |
|
991 return iUiUtils->GetSystemColor(aId); //lint !e613 |
|
992 } |
|
993 |
|
994 const MSwtFont* ASwtDisplayBase::GetSystemFont() const |
|
995 { |
|
996 ASSERT_NATIVEUITHREAD(); |
|
997 if (!iSystemFont) |
|
998 { |
|
999 ASwtDisplayBase* self = const_cast<ASwtDisplayBase*>(this); |
|
1000 TRAP_IGNORE(self->iSystemFont = CSwtFont::NewL(*self, *AknLayoutUtils::FontFromId( |
|
1001 CSwtLafFacade::GetFontId(CSwtLafFacade::EForm2MidpLabelPaneT1Font, 0)))); |
|
1002 } |
|
1003 return iSystemFont; |
|
1004 } |
|
1005 |
|
1006 TInt ASwtDisplayBase::GetDefaultFontHeightL() |
|
1007 { |
|
1008 TFontSpec fontSpec(KNullDesC, 0); |
|
1009 CFont* font = NULL; |
|
1010 CBitmapDevice& device = GraphicsDevice(); |
|
1011 User::LeaveIfError(device.GetNearestFontInTwips(font, fontSpec)); |
|
1012 |
|
1013 TInt result = 0; |
|
1014 if (font!=NULL) |
|
1015 { |
|
1016 fontSpec = font->FontSpecInTwips(); |
|
1017 result = FontUtils::PointsFromTwips(fontSpec.iHeight); |
|
1018 device.ReleaseFont(font); |
|
1019 font = NULL; |
|
1020 } |
|
1021 |
|
1022 return result; |
|
1023 } |
|
1024 |
|
1025 |
|
1026 // |
|
1027 // Virtual methods from MSwtDrawable |
|
1028 // |
|
1029 |
|
1030 MSwtGc* ASwtDisplayBase::NewGcL() |
|
1031 { |
|
1032 _LIT(KLibName, "scdv"); |
|
1033 |
|
1034 ASSERT_NATIVEUITHREAD(); |
|
1035 |
|
1036 CFbsScreenDevice* device = CFbsScreenDevice::NewL(KLibName, iCoeEnv->ScreenDevice()->DisplayMode()); |
|
1037 device->SetAutoUpdate(ETrue); |
|
1038 CleanupStack::PushL(device); |
|
1039 CFbsBitGc* nativeGc; |
|
1040 User::LeaveIfError(device->CreateContext(nativeGc)); |
|
1041 CleanupStack::Pop(device); |
|
1042 |
|
1043 return iFactory->NewBitmapGcL(*this, nativeGc, DestroyNativeGc, KRgbBlack, KRgbWhite, *iSystemFont); //lint !e613 |
|
1044 } |
|
1045 |
|
1046 void ASwtDisplayBase::DestroyNativeGc(CBitmapContext* aGc) |
|
1047 { |
|
1048 delete aGc->Device(); |
|
1049 delete aGc; |
|
1050 } |
|
1051 |
|
1052 CBitmapDevice& ASwtDisplayBase::GraphicsDevice() |
|
1053 { |
|
1054 ASSERT_NATIVEUITHREAD(); |
|
1055 return *(iCoeEnv->ScreenDevice()); |
|
1056 } |
|
1057 |
|
1058 void ASwtDisplayBase::HandleUpdate() |
|
1059 { |
|
1060 // Nothing to do |
|
1061 } |
|
1062 |
|
1063 void ASwtDisplayBase::SetMobileDevice(MSwtMobileDevice* aMobileDevice) |
|
1064 { |
|
1065 // Not to be called by anyone except CSwtMobileDevice and only once |
|
1066 ASSERT(!iMobileDevice); |
|
1067 iMobileDevice = aMobileDevice; |
|
1068 } |
|
1069 |
|
1070 MSwtMobileDevice* ASwtDisplayBase::MobileDevice() |
|
1071 { |
|
1072 return iMobileDevice; |
|
1073 } |
|
1074 |
|
1075 #ifdef RD_SCALABLE_UI_V2 |
|
1076 void ASwtDisplayBase::TryDetectLongTapL(const TPointerEvent& aPointerEvent) |
|
1077 { |
|
1078 ASSERT_NATIVEUITHREAD(); |
|
1079 ASSERT(iCommandArranger); |
|
1080 |
|
1081 if (aPointerEvent.iType == TPointerEvent::EButton1Down) |
|
1082 { |
|
1083 iLongTapControl = NULL; |
|
1084 iLongTapDetected = EFalse; |
|
1085 MSwtControl* ctrl = iUiUtils->GetPointerGrabbingControl(); |
|
1086 |
|
1087 // No long tap animation on scrollbars or trimings. |
|
1088 // Long tap animation only if there is a popup menu. |
|
1089 if (ctrl && ctrl->IsLongTapAnimationCandidate(aPointerEvent)) |
|
1090 { |
|
1091 iLongTapControl = ctrl; |
|
1092 } |
|
1093 } |
|
1094 |
|
1095 iLongTapPointerEvent = aPointerEvent; |
|
1096 |
|
1097 if (iLongTapControl) |
|
1098 { |
|
1099 iLongTapDetector->PointerEventL(aPointerEvent); |
|
1100 } |
|
1101 } |
|
1102 |
|
1103 MSwtControl* ASwtDisplayBase::LongTapAnimationControl() const |
|
1104 { |
|
1105 ASSERT_NATIVEUITHREAD(); |
|
1106 return iLongTapControl; |
|
1107 } |
|
1108 |
|
1109 void ASwtDisplayBase::CancelLongTapAnimation() |
|
1110 { |
|
1111 ASSERT_NATIVEUITHREAD(); |
|
1112 // IAD WARNING: Do not call CAknLongTapDetector::CancelAnimationL() |
|
1113 iLongTapControl = NULL; |
|
1114 iLongTapDetected = EFalse; |
|
1115 } |
|
1116 |
|
1117 void ASwtDisplayBase::HandleLongTapEventL(const TPoint& /*aPenEventLocation*/, |
|
1118 const TPoint& aPenEventScreenLocation) |
|
1119 { |
|
1120 ASSERT_NATIVEUITHREAD(); |
|
1121 ASSERT(iMenuArranger); |
|
1122 |
|
1123 MSwtControl* ctrl = iLongTapControl; |
|
1124 if (!ctrl) |
|
1125 { |
|
1126 // Control disposed or pen lifted just before menu was about to open. |
|
1127 iLongTapDetected = EFalse; |
|
1128 return; |
|
1129 } |
|
1130 |
|
1131 // Will be switched back after the popup menu closes |
|
1132 // and the late pointer up event was delivered. |
|
1133 iLongTapDetected = ETrue; |
|
1134 |
|
1135 // Open menu on the longTap cursor position |
|
1136 iMenuArranger->OpenStylusPopupMenuL(*ctrl, aPenEventScreenLocation, this); |
|
1137 } |
|
1138 #endif //RD_SCALABLE_UI_V2 |
|
1139 |
|
1140 // From MSwtPopupMenuCallBack |
|
1141 // Native Ui Thread |
|
1142 void ASwtDisplayBase::HandlePopupMenuClosedL() |
|
1143 { |
|
1144 if (iLongTapControl) |
|
1145 { |
|
1146 // Forward delayed pointer event |
|
1147 TPointerEvent event(iLongTapPointerEvent); |
|
1148 event.iType = TPointerEvent::EButton1Up; |
|
1149 iLongTapControl->HandlePointerEventL(event); // revert |
|
1150 } |
|
1151 |
|
1152 // Just to clear the flags. |
|
1153 CancelLongTapAnimation(); |
|
1154 } |
|
1155 |
|
1156 // From MSwtMediaKeysListener |
|
1157 // Native Ui Thread |
|
1158 void ASwtDisplayBase::HandleMediaKeyEvent(TKeyEvent& aKeyEvent, TInt aEventType) |
|
1159 { |
|
1160 ASSERT(iUiUtils); |
|
1161 |
|
1162 MSwtControl* focusControl = 0; |
|
1163 MSwtShell* activeShell = NULL; |
|
1164 |
|
1165 if (iUiUtils->IsAppFocused()) |
|
1166 { |
|
1167 activeShell = iUiUtils->GetActiveShell(); |
|
1168 |
|
1169 if (activeShell) |
|
1170 { |
|
1171 focusControl = activeShell->FocusControl(); |
|
1172 } |
|
1173 } |
|
1174 else |
|
1175 { |
|
1176 CSwtUiUtils* uiUtils = static_cast<CSwtUiUtils*>(iUiUtils); |
|
1177 focusControl = uiUtils->NextFocusedControl(); |
|
1178 } |
|
1179 |
|
1180 if (focusControl) |
|
1181 { |
|
1182 TRAP_IGNORE(focusControl->CoeControl().OfferKeyEventL(aKeyEvent, (TEventCode)aEventType)); |
|
1183 } |
|
1184 else |
|
1185 { |
|
1186 if (activeShell) |
|
1187 { |
|
1188 TRAP_IGNORE(activeShell->Control()->CoeControl().OfferKeyEventL(aKeyEvent, (TEventCode)aEventType)); |
|
1189 } |
|
1190 } |
|
1191 } |
|
1192 |
|
1193 // --------------------------------------------------------------------------- |
|
1194 // CSwtUiUtils::LoadResourceFileL |
|
1195 // --------------------------------------------------------------------------- |
|
1196 // |
|
1197 TInt ASwtDisplayBase::LoadResourceFileL() |
|
1198 { |
|
1199 TFileName langFile = java::util::S60CommonUtils::ResourceLanguageFileNameL(KSwtResFile); |
|
1200 return iCoeEnv->AddResourceFileL(langFile); |
|
1201 } |