|
1 /* |
|
2 * Copyright (c) 2006 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: Display |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #ifdef SYMBIAN_ENABLE_SPLIT_HEADERS |
|
21 #include <uikon/eikdefmacros.h> |
|
22 #endif |
|
23 #include <aknappui.h> |
|
24 #include <coecntrl.h> |
|
25 #include <coecobs.h> |
|
26 #include <gdi.h> |
|
27 #include <AknUtils.h> |
|
28 #include <babitflags.h> |
|
29 |
|
30 #include "alf/alfdisplay.h" |
|
31 #include "alfdisplaysubsession.h" |
|
32 #include "alf/alfroster.h" |
|
33 #include "alf/alfenv.h" |
|
34 #include "alfclient.h" |
|
35 #include "alf/alfevent.h" |
|
36 #include "alf/alfinputcapabilitiessupplier.h" |
|
37 #include "alflogger.h" |
|
38 #include "alf/alfevent.h" |
|
39 #include <alf/alfscreenbuffer.h> |
|
40 #include <alf/alfsymbiansbdrawer.h> |
|
41 |
|
42 #include "uiacceltk/HuiUtil.h" |
|
43 |
|
44 // Flags |
|
45 enum TAlfDisplayFlags |
|
46 { |
|
47 EAlfDisplayActive = 0x01, |
|
48 EAlfDisplayUpdateRenderState = 0x02, |
|
49 EAlfDisplayOwnRoster = 0x04 |
|
50 }; |
|
51 |
|
52 // Default flags. |
|
53 const TUint KAlfDisplayDefaultFlags = 0x00; |
|
54 |
|
55 enum |
|
56 { |
|
57 EAlfDisplayRectCustom, |
|
58 EAlfDisplayRectMainPane, |
|
59 EAlfDisplayRectWholeSceen |
|
60 }; |
|
61 |
|
62 |
|
63 // Private data. |
|
64 struct CAlfDisplay::TPrivateData |
|
65 { |
|
66 TPrivateData():iEnv(0),iNativeControl(0),iRoster(0){} |
|
67 RAlfDisplaySubSession iDisplaySubSession; // Owned |
|
68 TUint iFlags; // Owned. |
|
69 CAlfEnv* iEnv; // Not owned. |
|
70 CAlfDisplayCoeControl* iNativeControl; // Owned. |
|
71 CAlfRoster* iRoster; // Owned/not owned - see EAlfDisplayOwnRoster |
|
72 TInt iDisplayRectType; // To allow automatic screensize change in layout switch |
|
73 }; |
|
74 |
|
75 // ======== LOCAL FUNCTIONS ======== |
|
76 |
|
77 NONSHARABLE_CLASS( CAlfDisplayCoeControl ): |
|
78 public CCoeControl |
|
79 { |
|
80 public: // Enumerations |
|
81 enum |
|
82 { |
|
83 EManipulatingInputFocusIndex, |
|
84 EIsActiveIndex |
|
85 }; |
|
86 |
|
87 public: |
|
88 |
|
89 CAlfDisplayCoeControl(){} |
|
90 CAlfDisplayCoeControl( CAlfDisplay& aDisplay ) : iDisplay(&aDisplay){} |
|
91 void SetFocusedEditor( MAlfInputCapabilitiesSupplier* aFocusedEditor ); |
|
92 |
|
93 /** |
|
94 * This returns whether the CCoeControl is focused in general. However, during an operation where |
|
95 * focus is temporarily withdrawn from the CCoeControl, this state will continue to return ETrue. |
|
96 * This method cannot be called IsFocused since that would access the instantaneous |
|
97 * CONE focus, which is not what is required here. |
|
98 */ |
|
99 TBool IsActive() const; |
|
100 |
|
101 /** |
|
102 * Sets the active state according to the current focus state from CONE |
|
103 */ |
|
104 void SetActiveState(); |
|
105 |
|
106 virtual void InitL(); |
|
107 |
|
108 virtual TBool DrawsIntoLocalWindow() const; |
|
109 |
|
110 protected: |
|
111 TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType); |
|
112 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
113 void HandleResourceChange(TInt aType); |
|
114 /** |
|
115 * From CCoeControl |
|
116 */ |
|
117 protected: |
|
118 virtual TCoeInputCapabilities InputCapabilities() const; |
|
119 virtual void FocusChanged(TDrawNow aDrawNow); |
|
120 |
|
121 protected: |
|
122 CAlfDisplay* iDisplay; |
|
123 MAlfInputCapabilitiesSupplier* iFocusedEditor; |
|
124 TBitFlags iFlags; // Cleared at construction |
|
125 }; |
|
126 |
|
127 void CAlfDisplayCoeControl::InitL() |
|
128 { |
|
129 // Window is needed for HandleResourceChange to get events |
|
130 CreateWindowL(); |
|
131 Window().EnableOSB(EFalse); |
|
132 } |
|
133 |
|
134 |
|
135 TKeyResponse CAlfDisplayCoeControl::OfferKeyEventL( |
|
136 const TKeyEvent& aKeyEvent, |
|
137 TEventCode aType) |
|
138 { |
|
139 TAlfEvent event(*iDisplay, aKeyEvent, aType); |
|
140 if(iDisplay->Roster().HandleEventL(event)) |
|
141 { |
|
142 return EKeyWasConsumed; |
|
143 } |
|
144 return EKeyWasNotConsumed; |
|
145 } |
|
146 |
|
147 |
|
148 void CAlfDisplayCoeControl::HandlePointerEventL( |
|
149 const TPointerEvent& aPointerEvent) |
|
150 { |
|
151 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
152 } |
|
153 |
|
154 void CAlfDisplayCoeControl::HandleResourceChange(TInt aType) |
|
155 { |
|
156 CCoeControl::HandleResourceChange( aType ); |
|
157 if (aType == KEikDynamicLayoutVariantSwitch) |
|
158 { |
|
159 iDisplay->Env().ReportWsEventAsActionCommand(KAlfActionIdDeviceLayoutChanged); |
|
160 } |
|
161 } |
|
162 |
|
163 TCoeInputCapabilities CAlfDisplayCoeControl::InputCapabilities() const |
|
164 { |
|
165 if ( iFocusedEditor ) |
|
166 { |
|
167 return iFocusedEditor->InputCapabilities(); |
|
168 } |
|
169 else |
|
170 { |
|
171 TCoeInputCapabilities nullCapabilities(TCoeInputCapabilities::ENavigation); |
|
172 return nullCapabilities; |
|
173 } |
|
174 } |
|
175 |
|
176 // --------------------------------------------------------------------------- |
|
177 // Sets the pointer to the object supplying input capabilities. |
|
178 // This method needs to ensure that the FEP registers the change in focus of the AlfControl |
|
179 // - some sort of editor in this case. |
|
180 // --------------------------------------------------------------------------- |
|
181 // |
|
182 void CAlfDisplayCoeControl::SetFocusedEditor( MAlfInputCapabilitiesSupplier* aFocusedEditor ) |
|
183 { |
|
184 // A flag is set to register the fact that we are currently manipulating focus of the CCoeControl, albeit temporarily. |
|
185 // The flag is used by call-backs to suppress Alf reacting too deeply to the focus changes. |
|
186 iFlags.Set( EManipulatingInputFocusIndex ); |
|
187 if ( !aFocusedEditor ) |
|
188 { |
|
189 // The focus state of this CCoeControl must be preserved through this "kicking" of the FEP |
|
190 // Use a local variable to highlight that the "IsActive" flag may change temporarily during this sequence |
|
191 // (depending on implementation) |
|
192 TBool focusStateToKeep = iFlags.IsSet( EIsActiveIndex ); |
|
193 if ( focusStateToKeep ) // No need to even remove focus if off already |
|
194 { |
|
195 SetFocus(EFalse, ENoDrawNow); // Forces focus off this |
|
196 // Force removal of focus to be synchronous |
|
197 ControlEnv()->SyncNotifyFocusObserversOfChangeInFocus(); |
|
198 } |
|
199 iFocusedEditor = aFocusedEditor; // Removed only after FEP has taken focus off |
|
200 |
|
201 if ( !IsFocused() && focusStateToKeep ) // Ensure focus gets put back on |
|
202 { |
|
203 SetFocus(ETrue, ENoDrawNow); // Forces focus on again but now there is no AlfControl |
|
204 } |
|
205 } |
|
206 else |
|
207 { |
|
208 iFocusedEditor = aFocusedEditor; // Put in place before focus is forced on |
|
209 SetFocus(ETrue, ENoDrawNow); // Forces focus onto this control |
|
210 } |
|
211 iFlags.Clear( EManipulatingInputFocusIndex ); |
|
212 } |
|
213 |
|
214 // --------------------------------------------------------------------------- |
|
215 // This is a call-back from CONE when the focus is changed on a this CCoeControl. |
|
216 // The roster must be kept "in step" with the focus change, and is called strictly |
|
217 // only when the focus state changes. |
|
218 // However Alf should not track focus changes when SetFocusedEditor is being processed |
|
219 // This interlock is effected by the ManipulatingInputFocus flag |
|
220 // --------------------------------------------------------------------------- |
|
221 void CAlfDisplayCoeControl::FocusChanged( TDrawNow aDrawNow ) |
|
222 { |
|
223 if ( iFlags.IsClear( EManipulatingInputFocusIndex ) ) |
|
224 { |
|
225 TBool coneFocus = IsFocused(); |
|
226 if ( !COMPARE_BOOLS(iFlags.IsSet( EIsActiveIndex ), coneFocus ) ) |
|
227 { |
|
228 iFlags.Assign( EIsActiveIndex, coneFocus ); |
|
229 iDisplay->Roster().DisplayFocusChanged( *iDisplay, coneFocus ); |
|
230 } |
|
231 } |
|
232 CCoeControl::FocusChanged( aDrawNow ); |
|
233 } |
|
234 |
|
235 |
|
236 // --------------------------------------------------------------------------- |
|
237 // Implemenation of CCoeControl virtual. |
|
238 // Used here to set up the focus state at the construction point of the control. |
|
239 // --------------------------------------------------------------------------- |
|
240 void CAlfDisplayCoeControl::SetActiveState() |
|
241 { |
|
242 iFlags.Assign( EIsActiveIndex, IsFocused() ); |
|
243 iDisplay->Roster().DisplayFocusChanged( *iDisplay, iFlags.IsSet( EIsActiveIndex ) ); |
|
244 } |
|
245 |
|
246 TBool CAlfDisplayCoeControl::IsActive() const |
|
247 { |
|
248 return iFlags.IsSet( EIsActiveIndex ); |
|
249 } |
|
250 |
|
251 TBool CAlfDisplayCoeControl::DrawsIntoLocalWindow() const |
|
252 { |
|
253 return EFalse; |
|
254 } |
|
255 |
|
256 // |
|
257 // |
|
258 // |
|
259 // |
|
260 NONSHARABLE_CLASS( CAlfDisplayOffScreenBufferCoeControl ): |
|
261 public CAlfDisplayCoeControl, public MAlfScreenBufferObserver |
|
262 { |
|
263 public: |
|
264 CAlfDisplayOffScreenBufferCoeControl( CAlfDisplay& aDisplay ); |
|
265 |
|
266 ~CAlfDisplayOffScreenBufferCoeControl(); |
|
267 |
|
268 void InitL(TUid aBufferUid); |
|
269 |
|
270 void Draw( const TRect& aRect ) const; |
|
271 |
|
272 void SizeChanged(); |
|
273 |
|
274 TBool DrawsIntoLocalWindow() const; |
|
275 |
|
276 protected: |
|
277 void HandlePointerEventL(const TPointerEvent& aPointerEvent); |
|
278 |
|
279 private: // From MAlfScreenBufferObserver |
|
280 |
|
281 TBool BufferComplete(TUid aId, TRect& aDisplayRect, TRect& aDirtyRect); |
|
282 void HandleScreenBufferEvent(TUid aId, TInt aEvent); |
|
283 |
|
284 private: |
|
285 CAlfScreenBuffer* iAlfScreenBuffer; |
|
286 TRect iDisplayRect; |
|
287 CAlfSymbianBufferDrawer* iBufferDrawer; |
|
288 TUid iBufferUid; |
|
289 }; |
|
290 |
|
291 CAlfDisplayOffScreenBufferCoeControl::CAlfDisplayOffScreenBufferCoeControl(CAlfDisplay& aDisplay) |
|
292 { |
|
293 iDisplay = &aDisplay; |
|
294 } |
|
295 |
|
296 CAlfDisplayOffScreenBufferCoeControl::~CAlfDisplayOffScreenBufferCoeControl() |
|
297 { |
|
298 if(iBufferDrawer) |
|
299 iBufferDrawer->ReleaseDrawer(); |
|
300 delete iAlfScreenBuffer; |
|
301 } |
|
302 |
|
303 void CAlfDisplayOffScreenBufferCoeControl::InitL(TUid aBufferUid) |
|
304 { |
|
305 CAlfDisplayCoeControl::InitL(); |
|
306 |
|
307 // Set the windows size |
|
308 SetRect( iDisplay->VisibleArea() ); |
|
309 |
|
310 // Activate the window, which makes it ready to be drawn |
|
311 ActivateL(); |
|
312 |
|
313 iAlfScreenBuffer = CAlfScreenBuffer::NewL(iDisplay->Env()); |
|
314 iAlfScreenBuffer->AddObserverL(aBufferUid, this); |
|
315 iBufferUid = aBufferUid; |
|
316 |
|
317 EnableDragEvents(); |
|
318 } |
|
319 |
|
320 |
|
321 void CAlfDisplayOffScreenBufferCoeControl::Draw( const TRect& /*aRect*/ ) const |
|
322 { |
|
323 // Get the standard graphics context |
|
324 CWindowGc& gc = SystemGc(); |
|
325 |
|
326 if (iBufferDrawer) |
|
327 { |
|
328 iBufferDrawer->DrawBuffer(gc, TPoint(), iDisplayRect); |
|
329 } |
|
330 |
|
331 } |
|
332 |
|
333 void CAlfDisplayOffScreenBufferCoeControl::SizeChanged() |
|
334 { |
|
335 DrawDeferred(); |
|
336 } |
|
337 |
|
338 TBool CAlfDisplayOffScreenBufferCoeControl::BufferComplete(TUid aId, TRect& aDisplayRect, TRect& /*aDirtyRect*/) |
|
339 { |
|
340 if (aId == iBufferUid) |
|
341 { |
|
342 if (!iBufferDrawer) |
|
343 { |
|
344 iBufferDrawer = (CAlfSymbianBufferDrawer*)iAlfScreenBuffer->GetDrawingInterface(KAlfSymbianBufferDrawerUid, iBufferUid); |
|
345 } |
|
346 iDisplayRect = aDisplayRect; |
|
347 DrawNow(); |
|
348 } |
|
349 |
|
350 return ETrue; |
|
351 } |
|
352 |
|
353 |
|
354 void CAlfDisplayOffScreenBufferCoeControl::HandleScreenBufferEvent(TUid aId, TInt aEvent) |
|
355 { |
|
356 if (aId == iBufferUid) |
|
357 { |
|
358 if (aEvent == MAlfScreenBufferObserver::ECreated) |
|
359 { |
|
360 } |
|
361 else if (aEvent == MAlfScreenBufferObserver::EDeleted) |
|
362 { |
|
363 // delete bitmap drawer etc. |
|
364 if(iBufferDrawer) |
|
365 iBufferDrawer->ReleaseDrawer(); |
|
366 iBufferDrawer = NULL; |
|
367 // Draw |
|
368 DrawNow(); |
|
369 } |
|
370 } |
|
371 } |
|
372 |
|
373 void CAlfDisplayOffScreenBufferCoeControl::HandlePointerEventL( |
|
374 const TPointerEvent& aPointerEvent) |
|
375 { |
|
376 CCoeControl::HandlePointerEventL( aPointerEvent ); |
|
377 iDisplay->HandlePointerEventL( aPointerEvent ); |
|
378 } |
|
379 |
|
380 TBool CAlfDisplayOffScreenBufferCoeControl::DrawsIntoLocalWindow() const |
|
381 { |
|
382 return ETrue; |
|
383 } |
|
384 |
|
385 |
|
386 // ======== MEMBER FUNCTIONS ======== |
|
387 |
|
388 // --------------------------------------------------------------------------- |
|
389 // Constructor |
|
390 // --------------------------------------------------------------------------- |
|
391 // |
|
392 CAlfDisplay::CAlfDisplay() |
|
393 { |
|
394 } |
|
395 |
|
396 |
|
397 // --------------------------------------------------------------------------- |
|
398 // ConstructL |
|
399 // --------------------------------------------------------------------------- |
|
400 // |
|
401 void CAlfDisplay::ConstructL( |
|
402 CAlfEnv& aEnv, |
|
403 TBool aAsCoeControl, |
|
404 const TRect& aRect, |
|
405 CAlfRoster* aSharedRoster, |
|
406 TInt aDisplayType, |
|
407 TUid aBufferUid) |
|
408 { |
|
409 iData = new (ELeave) TPrivateData; |
|
410 |
|
411 User::LeaveIfError( iData->iDisplaySubSession.Open(aEnv.Client(), aRect, aDisplayType, aBufferUid) ); |
|
412 |
|
413 |
|
414 iData->iFlags = KAlfDisplayDefaultFlags; |
|
415 |
|
416 iData->iEnv = &aEnv; |
|
417 iData->iNativeControl = NULL; |
|
418 iData->iFlags |= EAlfDisplayActive; |
|
419 iData->iFlags |= EAlfDisplayUpdateRenderState; |
|
420 |
|
421 |
|
422 // Create a control roster. |
|
423 if(aSharedRoster) |
|
424 { |
|
425 iData->iRoster = aSharedRoster; |
|
426 iData->iFlags &= ~EAlfDisplayOwnRoster; |
|
427 } |
|
428 else |
|
429 { |
|
430 // Construct a private roster. |
|
431 CAlfRoster* roster = new (ELeave) CAlfRoster; |
|
432 CleanupStack::PushL(roster); |
|
433 roster->ConstructL(this); |
|
434 CleanupStack::Pop(roster); |
|
435 iData->iRoster= roster; |
|
436 iData->iFlags |= EAlfDisplayOwnRoster; |
|
437 } |
|
438 |
|
439 if ( aAsCoeControl ) |
|
440 { |
|
441 if (aDisplayType == EDisplayOffScreenBuffer && aBufferUid.iUid != 0) |
|
442 { |
|
443 CAlfDisplayOffScreenBufferCoeControl* osbf = new (ELeave) CAlfDisplayOffScreenBufferCoeControl(*this); |
|
444 iData->iNativeControl = osbf; |
|
445 iData->iNativeControl->SetMopParent( iAvkonAppUi ); |
|
446 CCoeEnv::Static()->AppUi()->AddToStackL(iData->iNativeControl); |
|
447 iData->iNativeControl->SetActiveState(); |
|
448 osbf->InitL(aBufferUid); |
|
449 } |
|
450 else |
|
451 { |
|
452 iData->iNativeControl = new (ELeave) CAlfDisplayCoeControl(*this); |
|
453 iData->iNativeControl->SetMopParent( iAvkonAppUi ); |
|
454 CCoeEnv::Static()->AppUi()->AddToStackL(iData->iNativeControl); |
|
455 iData->iNativeControl->SetActiveState(); |
|
456 iData->iNativeControl->InitL(); |
|
457 } |
|
458 } |
|
459 |
|
460 iData->iDisplayRectType = EAlfDisplayRectCustom; |
|
461 if ( CCoeEnv::Static() ) // check that we are running this from Symbian application |
|
462 { |
|
463 CheckScreenRect(aRect); |
|
464 |
|
465 // In case of display is created after application has already received foregound |
|
466 // we notify just to make sure we really have foreground |
|
467 aEnv.Client().ApplicationIsForeground(iAvkonAppUi->IsForeground() || |
|
468 iAvkonAppUi->IsPartialForeground()); |
|
469 } |
|
470 } |
|
471 |
|
472 |
|
473 // --------------------------------------------------------------------------- |
|
474 // Destructor |
|
475 // --------------------------------------------------------------------------- |
|
476 // |
|
477 CAlfDisplay::~CAlfDisplay() |
|
478 { |
|
479 if ( iData ) |
|
480 { |
|
481 if ( (iData->iFlags&EAlfDisplayOwnRoster) && iData->iRoster ) |
|
482 { |
|
483 delete iData->iRoster; |
|
484 } |
|
485 iData->iFlags &= ~EAlfDisplayOwnRoster; |
|
486 iData->iRoster = NULL; |
|
487 |
|
488 if ( iData->iNativeControl ) |
|
489 { |
|
490 CCoeEnv::Static()->AppUi()->RemoveFromStack(iData->iNativeControl); |
|
491 delete iData->iNativeControl; |
|
492 iData->iNativeControl = NULL; |
|
493 } |
|
494 |
|
495 if ( iData->iEnv ) |
|
496 { |
|
497 iData->iEnv->RemoveDisplay(*this); |
|
498 } |
|
499 |
|
500 iData->iDisplaySubSession.Close(); |
|
501 } |
|
502 |
|
503 delete iData; |
|
504 iData = NULL; |
|
505 } |
|
506 |
|
507 // --------------------------------------------------------------------------- |
|
508 // Sets clear background method |
|
509 // --------------------------------------------------------------------------- |
|
510 // |
|
511 EXPORT_C void CAlfDisplay::SetClearBackgroundL(TInt aClearBackground) |
|
512 { |
|
513 TInt err = |
|
514 iData->iDisplaySubSession.SetClearBackground( |
|
515 aClearBackground ); |
|
516 |
|
517 if ( err != KErrNone ) |
|
518 { |
|
519 __ALFLOGSTRING1( "CAlfDisplay::SetClearBackgroundL leave error %d", err ) |
|
520 User::Leave( err ); |
|
521 } |
|
522 } |
|
523 |
|
524 // --------------------------------------------------------------------------- |
|
525 // Returns roster |
|
526 // --------------------------------------------------------------------------- |
|
527 // |
|
528 EXPORT_C CAlfRoster& CAlfDisplay::Roster() |
|
529 { |
|
530 __ASSERT_ALWAYS( iData, USER_INVARIANT() ); |
|
531 __ASSERT_ALWAYS( iData->iRoster, USER_INVARIANT() ); |
|
532 return *iData->iRoster; |
|
533 } |
|
534 |
|
535 // --------------------------------------------------------------------------- |
|
536 // Returns roster |
|
537 // --------------------------------------------------------------------------- |
|
538 // |
|
539 EXPORT_C const CAlfRoster& CAlfDisplay::Roster() const |
|
540 { |
|
541 __ASSERT_ALWAYS( iData, USER_INVARIANT() ); |
|
542 __ASSERT_ALWAYS( iData->iRoster, USER_INVARIANT() ); |
|
543 return *iData->iRoster; |
|
544 } |
|
545 |
|
546 // --------------------------------------------------------------------------- |
|
547 // Sets visible area. |
|
548 // --------------------------------------------------------------------------- |
|
549 // |
|
550 EXPORT_C void CAlfDisplay::SetVisibleArea(const TRect& aArea) |
|
551 { |
|
552 TInt err = iData->iDisplaySubSession.SetVisibleArea( aArea ); |
|
553 |
|
554 if ( err != KErrNone ) |
|
555 { |
|
556 // panic? |
|
557 __ALFLOGSTRING1( "CAlfDisplay::SetVisibleArea ignore error %d", err ) |
|
558 } |
|
559 |
|
560 if ( CCoeEnv::Static() ) // check that we are running this from Symbian application |
|
561 { |
|
562 CheckScreenRect(aArea); |
|
563 |
|
564 // If offscreenbuffer is drawn, then set its rect too. |
|
565 if (iData->iNativeControl && iData->iNativeControl->DrawsIntoLocalWindow()) |
|
566 { |
|
567 iData->iNativeControl->SetRect(aArea); |
|
568 } |
|
569 } |
|
570 } |
|
571 |
|
572 // --------------------------------------------------------------------------- |
|
573 // Sets visible area. |
|
574 // --------------------------------------------------------------------------- |
|
575 // |
|
576 EXPORT_C void CAlfDisplay::ForceSetVisibleArea(const TRect& aArea) |
|
577 { |
|
578 // forces to set visible area |
|
579 TInt err = iData->iDisplaySubSession.SetVisibleArea( aArea, ETrue ); |
|
580 |
|
581 if ( err != KErrNone ) |
|
582 { |
|
583 // panic? |
|
584 __ALFLOGSTRING1( "CAlfDisplay::ForceSetVisibleArea ignore error %d", err ) |
|
585 } |
|
586 |
|
587 if ( CCoeEnv::Static() ) // check that we are running this from Symbian application |
|
588 { |
|
589 CheckScreenRect(aArea); |
|
590 |
|
591 // If offscreenbuffer is drawn, then set its rect too. |
|
592 if (iData->iNativeControl && iData->iNativeControl->DrawsIntoLocalWindow()) |
|
593 { |
|
594 iData->iNativeControl->SetRect(aArea); |
|
595 } |
|
596 } |
|
597 } |
|
598 |
|
599 // --------------------------------------------------------------------------- |
|
600 // Returns visible area |
|
601 // --------------------------------------------------------------------------- |
|
602 // |
|
603 EXPORT_C TRect CAlfDisplay::VisibleArea() const |
|
604 { |
|
605 TRect area(0,0,0,0); |
|
606 |
|
607 TInt err = iData->iDisplaySubSession.VisibleArea( area ); |
|
608 |
|
609 if ( err != KErrNone ) |
|
610 { |
|
611 // panic? |
|
612 __ALFLOGSTRING1( "CAlfDisplay::VisibleArea ignore error %d", err ) |
|
613 } |
|
614 |
|
615 return area; |
|
616 } |
|
617 |
|
618 // --------------------------------------------------------------------------- |
|
619 // Returns env. |
|
620 // --------------------------------------------------------------------------- |
|
621 // |
|
622 EXPORT_C CAlfEnv& CAlfDisplay::Env() |
|
623 { |
|
624 return *iData->iEnv; |
|
625 } |
|
626 |
|
627 |
|
628 // --------------------------------------------------------------------------- |
|
629 // Returns server handle |
|
630 // --------------------------------------------------------------------------- |
|
631 // |
|
632 TInt CAlfDisplay::ServerHandle() const |
|
633 { |
|
634 return iData->iDisplaySubSession.SubSessionHandle(); |
|
635 } |
|
636 // --------------------------------------------------------------------------- |
|
637 // Set the current focused editor. |
|
638 // --------------------------------------------------------------------------- |
|
639 // |
|
640 EXPORT_C void CAlfDisplay::SetFocusedEditor( MAlfInputCapabilitiesSupplier* aCurrentEditor ) |
|
641 { |
|
642 __ASSERT_ALWAYS(iData->iNativeControl, USER_INVARIANT() ); |
|
643 iData->iNativeControl->SetFocusedEditor(aCurrentEditor); |
|
644 } |
|
645 |
|
646 // --------------------------------------------------------------------------- |
|
647 // Set display dirty. |
|
648 // --------------------------------------------------------------------------- |
|
649 // |
|
650 EXPORT_C void CAlfDisplay::SetDirty() |
|
651 { |
|
652 iData->iDisplaySubSession.SetDirty(); |
|
653 } |
|
654 |
|
655 // --------------------------------------------------------------------------- |
|
656 // Set display rendering quality. |
|
657 // --------------------------------------------------------------------------- |
|
658 // |
|
659 EXPORT_C void CAlfDisplay::SetQuality(TAlfQuality aRenderingQuality) |
|
660 { |
|
661 TInt err = iData->iDisplaySubSession.SetQuality(aRenderingQuality); |
|
662 if ( err != KErrNone ) |
|
663 { |
|
664 // panic? |
|
665 __ALFLOGSTRING1( "CAlfDisplay::SetQuality ignore error %d", err ) |
|
666 } |
|
667 } |
|
668 |
|
669 // --------------------------------------------------------------------------- |
|
670 // Get display rendering quality. |
|
671 // --------------------------------------------------------------------------- |
|
672 // |
|
673 EXPORT_C TAlfQuality CAlfDisplay::Quality() const |
|
674 { |
|
675 TAlfQuality renderingQuality; |
|
676 TInt err = iData->iDisplaySubSession.Quality(renderingQuality); |
|
677 if ( err != KErrNone ) |
|
678 { |
|
679 // panic? |
|
680 __ALFLOGSTRING1( "CAlfDisplay::Quality ignore error %d", err ) |
|
681 } |
|
682 return renderingQuality; |
|
683 } |
|
684 |
|
685 // --------------------------------------------------------------------------- |
|
686 // Set display depth test use |
|
687 // --------------------------------------------------------------------------- |
|
688 // |
|
689 EXPORT_C void CAlfDisplay::SetUseDepth(TBool aUseDepth) |
|
690 { |
|
691 TInt err = iData->iDisplaySubSession.SetUseDepth(aUseDepth); |
|
692 if ( err != KErrNone ) |
|
693 { |
|
694 // panic? |
|
695 __ALFLOGSTRING1( "CAlfDisplay::SetUseDepth ignore error %d", err ) |
|
696 } |
|
697 } |
|
698 |
|
699 // --------------------------------------------------------------------------- |
|
700 // Handles layout switch |
|
701 // --------------------------------------------------------------------------- |
|
702 // |
|
703 void CAlfDisplay::NotifyLayoutChangedL() |
|
704 { |
|
705 // If screen size had been set to main pane or whole screen, |
|
706 // set it automatically here to new value. |
|
707 // Otherwise let application handle it. |
|
708 if (iData->iDisplayRectType == EAlfDisplayRectMainPane) |
|
709 { |
|
710 TRect metricsRect = TRect(0,0,0,0); |
|
711 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, metricsRect); |
|
712 ForceSetVisibleArea(metricsRect); |
|
713 } |
|
714 else if (iData->iDisplayRectType == EAlfDisplayRectWholeSceen) |
|
715 { |
|
716 TRect metricsRect = TRect(0,0,0,0); |
|
717 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, metricsRect); |
|
718 ForceSetVisibleArea(metricsRect); |
|
719 } |
|
720 else |
|
721 { |
|
722 // for PC lint |
|
723 } |
|
724 } |
|
725 |
|
726 |
|
727 // --------------------------------------------------------------------------- |
|
728 // |
|
729 // --------------------------------------------------------------------------- |
|
730 // |
|
731 void CAlfDisplay::CheckScreenRect(TRect aRect) |
|
732 { |
|
733 TRect mainpaneRect = TRect(0,0,0,0); |
|
734 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EMainPane, mainpaneRect); |
|
735 |
|
736 TRect screenRect = TRect(0,0,0,0); |
|
737 AknLayoutUtils::LayoutMetricsRect(AknLayoutUtils::EScreen, screenRect); |
|
738 |
|
739 if (aRect == mainpaneRect) |
|
740 { |
|
741 iData->iDisplayRectType = EAlfDisplayRectMainPane; |
|
742 } |
|
743 else if (aRect == screenRect) |
|
744 { |
|
745 iData->iDisplayRectType = EAlfDisplayRectWholeSceen; |
|
746 } |
|
747 else |
|
748 { |
|
749 iData->iDisplayRectType = EAlfDisplayRectCustom; |
|
750 } |
|
751 } |
|
752 |
|
753 // --------------------------------------------------------------------------- |
|
754 // Access the object provider for the display. |
|
755 // --------------------------------------------------------------------------- |
|
756 // |
|
757 EXPORT_C MObjectProvider* CAlfDisplay::ObjectProvider() const |
|
758 { |
|
759 return iData->iNativeControl; |
|
760 } |
|
761 |
|
762 TBool CAlfDisplay::IsFocused() const |
|
763 { |
|
764 return iData->iNativeControl ? iData->iNativeControl->IsActive() : ETrue; |
|
765 } |
|
766 |
|
767 |
|
768 // --------------------------------------------------------------------------- |
|
769 // Sets usage hint |
|
770 // --------------------------------------------------------------------------- |
|
771 // |
|
772 EXPORT_C void CAlfDisplay::SetUsageL(TUint aUsageHint) |
|
773 { |
|
774 TInt err = iData->iDisplaySubSession.SetUsage(aUsageHint); |
|
775 if ( err != KErrNone ) |
|
776 { |
|
777 __ALFLOGSTRING1( "CAlfDisplay::SetUsageL leave error %d", err ) |
|
778 User::Leave( err ); |
|
779 } |
|
780 } |
|
781 |
|
782 // --------------------------------------------------------------------------- |
|
783 // Suppresses automatic fading |
|
784 // --------------------------------------------------------------------------- |
|
785 // |
|
786 EXPORT_C TInt CAlfDisplay::SuppressAutomaticFading( TBool aSuppress ) |
|
787 { |
|
788 TInt err = iData->iDisplaySubSession.SuppressAutomaticFading( aSuppress ); |
|
789 if ( err != KErrNone ) |
|
790 { |
|
791 __ALFLOGSTRING1( "CAlfDisplay::SuppressAutomaticFading return error %d", err ) |
|
792 } |
|
793 return err; |
|
794 } |
|
795 |
|
796 // --------------------------------------------------------------------------- |
|
797 // |
|
798 // --------------------------------------------------------------------------- |
|
799 // |
|
800 EXPORT_C void CAlfDisplay::SetBackgroundItemsL(const RArray<TAlfDisplayBackgroundItem>& aItems) |
|
801 { |
|
802 TInt err = iData->iDisplaySubSession.SetBackgroundItemsL(aItems); |
|
803 if ( err != KErrNone ) |
|
804 { |
|
805 __ALFLOGSTRING1( "CAlfDisplay::SetBackgroundItemsL ignore error %d", err ) |
|
806 } |
|
807 } |
|
808 |
|
809 // --------------------------------------------------------------------------- |
|
810 // |
|
811 // --------------------------------------------------------------------------- |
|
812 // |
|
813 EXPORT_C void CAlfDisplay::HandlePointerEventL(const TPointerEvent& aPointerEvent) |
|
814 { |
|
815 TInt err = iData->iDisplaySubSession.HandlePointerEventL(aPointerEvent); |
|
816 if ( err != KErrNone ) |
|
817 { |
|
818 __ALFLOGSTRING1( "CAlfDisplay::HandlePointerEventL ignore error %d", err ) |
|
819 } |
|
820 } |
|
821 |
|
822 |
|
823 // --------------------------------------------------------------------------- |
|
824 // |
|
825 // --------------------------------------------------------------------------- |
|
826 // |
|
827 |
|
828 EXPORT_C void CAlfDisplay::SetClientWindowForDrawingL(RWindow* aWindow, CAlfVisual* aVisual) |
|
829 { |
|
830 TInt windowGroupId = 0; |
|
831 TInt clientWindowHandle = 0; |
|
832 TInt visualHandle = NULL; |
|
833 windowGroupId = aWindow->WindowGroupId(); |
|
834 clientWindowHandle = aWindow->ClientHandle(); |
|
835 if (aVisual) |
|
836 { |
|
837 visualHandle = aVisual->Identifier(); |
|
838 } |
|
839 iData->iDisplaySubSession.SetClientWindowForDrawingL(windowGroupId, clientWindowHandle, visualHandle); |
|
840 } |