|
1 /* |
|
2 * Copyright (c) 2008 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 */ |
|
15 |
|
16 // System includes |
|
17 #include <e32base.h> |
|
18 #include <e32const.h> |
|
19 #include <coecntrl.h> |
|
20 #include <coemain.h> |
|
21 #include <AknUtils.h> |
|
22 #include <gfxtranseffect/gfxtranseffect.h> |
|
23 #include <akntransitionutils.h> |
|
24 #include <AknPriv.hrh> |
|
25 #ifdef RD_TACTILE_FEEDBACK |
|
26 #include <touchfeedback.h> |
|
27 #endif // RD_TACTILE_FEEDBACK |
|
28 |
|
29 // User includes |
|
30 #include "xnwidgetextensionadapter.h" |
|
31 #include "xncontroladapter.h" |
|
32 #include "xncomponentnodeimpl.h" |
|
33 #include "xncomponent.h" |
|
34 #include "xnuiengine.h" |
|
35 |
|
36 #include "xnnode.h" |
|
37 #include "xnnodepluginif.h" |
|
38 #include "xnviewnodeimpl.h" |
|
39 #include "xnnodepluginif.h" |
|
40 #include "xndomdocument.h" |
|
41 #include "xnproperty.h" |
|
42 #include "xnodt.h" |
|
43 #include "xntype.h" |
|
44 #include "xndomnode.h" |
|
45 #include "xndomstringpool.h" |
|
46 |
|
47 #include "xnappuiadapter.h" |
|
48 #include "xnviewmanager.h" |
|
49 #include "xnviewdata.h" |
|
50 #include "xnplugindata.h" |
|
51 |
|
52 // Constants |
|
53 _LIT8( KPopup, "popup" ); |
|
54 _LIT8( KPositionHint, "_s60-position-hint" ); |
|
55 _LIT8( KWidgetNodeName, "widget" ); |
|
56 _LIT8( KParentIdName, "parentid" ); |
|
57 _LIT8( KDisplay, "display" ); |
|
58 _LIT8( KNone, "none" ); |
|
59 |
|
60 // ============================ MEMBER FUNCTIONS =============================== |
|
61 |
|
62 // ----------------------------------------------------------------------------- |
|
63 // CXnWidgetExtensionAdapter::NewL |
|
64 // Two-phased constructor. Can leave. |
|
65 // ----------------------------------------------------------------------------- |
|
66 // |
|
67 CXnWidgetExtensionAdapter* CXnWidgetExtensionAdapter::NewL( |
|
68 CXnNodePluginIf& aNode ) |
|
69 { |
|
70 CXnWidgetExtensionAdapter* self = |
|
71 new ( ELeave ) CXnWidgetExtensionAdapter( aNode ); |
|
72 CleanupStack::PushL( self ); |
|
73 self->ConstructL(); |
|
74 CleanupStack::Pop( self ); |
|
75 return self; |
|
76 } |
|
77 |
|
78 // ----------------------------------------------------------------------------- |
|
79 // CXnWidgetExtensionAdapter::~CXnWidgetExtensionAdapter |
|
80 // Destructor. |
|
81 // ----------------------------------------------------------------------------- |
|
82 // |
|
83 CXnWidgetExtensionAdapter::~CXnWidgetExtensionAdapter() |
|
84 { |
|
85 if ( iAppUiAdapter ) |
|
86 { |
|
87 iAppUiAdapter->UiStateListener().RemoveObserver( |
|
88 *( static_cast< MXnUiStateObserver* >( this ) ) ); |
|
89 iAppUiAdapter->UiStateListener().RemoveObserver( |
|
90 *( static_cast< MXnUiResourceChangeObserver* >( this ) ) ); |
|
91 } |
|
92 GfxTransEffect::Deregister( this ); |
|
93 } |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CXnWidgetExtensionAdapter::HandleScreenDeviceChangedL |
|
96 // |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CXnWidgetExtensionAdapter::HandleScreenDeviceChangedL() |
|
100 { |
|
101 if( IsVisible() ) |
|
102 { |
|
103 CCoeControl::MakeVisible( EFalse ); |
|
104 } |
|
105 CXnControlAdapter::HandleScreenDeviceChangedL(); |
|
106 |
|
107 } |
|
108 |
|
109 // ----------------------------------------------------------------------------- |
|
110 // CXnWidgetExtensionAdapter::CXnWidgetExtensionAdapter |
|
111 // C++ default constructor. Must not leave. |
|
112 // ----------------------------------------------------------------------------- |
|
113 // |
|
114 CXnWidgetExtensionAdapter::CXnWidgetExtensionAdapter( CXnNodePluginIf& aNode ) |
|
115 : iPositionHint( AknLayoutUtils::LayoutMirrored() ? EAboveRight : EAboveLeft ), |
|
116 iNode( aNode ) |
|
117 { |
|
118 } |
|
119 |
|
120 // ----------------------------------------------------------------------------- |
|
121 // CXnWidgetExtensionAdapter::ConstructL |
|
122 // 2nd phase constructor. Can leave. |
|
123 // ----------------------------------------------------------------------------- |
|
124 // |
|
125 void CXnWidgetExtensionAdapter::ConstructL() |
|
126 { |
|
127 iAppUiAdapter = static_cast< CXnAppUiAdapter* >( iAvkonAppUi ); |
|
128 |
|
129 CreateWindowL(); |
|
130 |
|
131 Window().SetRequiredDisplayMode( EColor16MA ); |
|
132 |
|
133 // this adapter handles both widgetextension and popup nodes |
|
134 // we have to decide which one of them is the recent one |
|
135 |
|
136 CXnType* typeInfo = iNode.Node().Type(); |
|
137 User::LeaveIfNull( typeInfo ); |
|
138 const TDesC8& type = typeInfo->Type(); |
|
139 |
|
140 iPermanent = EFalse; |
|
141 |
|
142 if ( type == KPopup ) |
|
143 { |
|
144 iPopup = ETrue; |
|
145 CXnProperty* prop( iNode.Node().GetPropertyL( |
|
146 XnPropertyNames::popup::KPopupType ) ); |
|
147 |
|
148 if ( prop && prop->StringValue() == |
|
149 XnPropertyNames::popup::popuptype::KPermanent ) |
|
150 { |
|
151 iPermanent = ETrue; |
|
152 } |
|
153 } |
|
154 |
|
155 if ( Window().SetTransparencyAlphaChannel() == KErrNone ) |
|
156 { |
|
157 Window().SetBackgroundColor( ~0 ); |
|
158 } |
|
159 |
|
160 iUiEngine = iNode.Node().UiEngine(); |
|
161 CXnControlAdapter::ConstructL( iNode ); |
|
162 |
|
163 EnableDragEvents(); |
|
164 |
|
165 GfxTransEffect::Register( this, KGfxPreviewPopupControlUid ); |
|
166 } |
|
167 |
|
168 // ----------------------------------------------------------------------------- |
|
169 // CXnWidgetExtensionAdapter::MakeVisible |
|
170 // |
|
171 // ----------------------------------------------------------------------------- |
|
172 // |
|
173 void CXnWidgetExtensionAdapter::MakeVisible( TBool aVisible ) |
|
174 { |
|
175 if ( IsVisible() == aVisible ) |
|
176 { |
|
177 return; |
|
178 } |
|
179 |
|
180 CXnPluginData* plugin( |
|
181 iAppUiAdapter->ViewManager().ActiveViewData().Plugin( &iNode.Node() ) ); |
|
182 |
|
183 if ( !plugin ) |
|
184 { |
|
185 return; |
|
186 } |
|
187 |
|
188 SetPointerCapture( aVisible ); |
|
189 |
|
190 plugin->SetIsDisplayingPopup( aVisible, &iNode.Node() ); |
|
191 |
|
192 if ( !iPopup ) |
|
193 { |
|
194 DrawableWindow()->FadeBehind( aVisible ); |
|
195 } |
|
196 |
|
197 if ( !iPermanent ) |
|
198 { |
|
199 if ( aVisible ) |
|
200 { |
|
201 iAppUiAdapter->UiStateListener().AddObserver( |
|
202 *( static_cast< MXnUiStateObserver* >( this ) ) ); |
|
203 iAppUiAdapter->UiStateListener().AddObserver( |
|
204 *( static_cast< MXnUiResourceChangeObserver* >( this ) ) ); |
|
205 } |
|
206 else |
|
207 { |
|
208 iAppUiAdapter->UiStateListener().RemoveObserver( |
|
209 *( static_cast< MXnUiStateObserver* >( this ) ) ); |
|
210 iAppUiAdapter->UiStateListener().RemoveObserver( |
|
211 *( static_cast< MXnUiResourceChangeObserver* >( this ) ) ); |
|
212 } |
|
213 } |
|
214 |
|
215 if ( aVisible && iPopup ) |
|
216 { |
|
217 ChangePopupPosition(); |
|
218 } |
|
219 |
|
220 TBool effectStarted = EFalse; |
|
221 if ( iAppUiAdapter->IsForeground() ) |
|
222 { |
|
223 if ( aVisible ) |
|
224 { |
|
225 GfxTransEffect::Begin( this, KGfxControlAppearAction ); |
|
226 } |
|
227 else |
|
228 { |
|
229 GfxTransEffect::Begin( this, KGfxControlDisappearAction ); |
|
230 } |
|
231 effectStarted = ETrue; |
|
232 } |
|
233 |
|
234 CCoeControl::MakeVisible( aVisible ); |
|
235 |
|
236 if ( effectStarted ) |
|
237 { |
|
238 GfxTransEffect::SetDemarcation( this, iPosition ); |
|
239 GfxTransEffect::End( this ); |
|
240 } |
|
241 } |
|
242 |
|
243 // ----------------------------------------------------------------------------- |
|
244 // CXnWidgetExtensionAdapter::HandlePointerEventL |
|
245 // |
|
246 // ----------------------------------------------------------------------------- |
|
247 // |
|
248 void CXnWidgetExtensionAdapter::HandlePointerEventL( |
|
249 const TPointerEvent& aPointerEvent ) |
|
250 { |
|
251 |
|
252 // in case of popup, we have to make sure that |
|
253 // it will be closed after tapping outside of the |
|
254 // area of itself and its parent |
|
255 if ( iPopup ) |
|
256 { |
|
257 // check if the tap was inside of popup |
|
258 TRect popupRect( Rect() ); |
|
259 popupRect.Move( Position() ); |
|
260 |
|
261 TBool isInPopupWindow( popupRect.Contains( |
|
262 aPointerEvent.iParentPosition ) ); |
|
263 |
|
264 if ( !isInPopupWindow ) |
|
265 { |
|
266 // if tap was outside of window, check if tap was |
|
267 // inside of the parrent |
|
268 CXnProperty* parentIdProp( iNode.Node().GetPropertyL( |
|
269 KParentIdName ) ); |
|
270 |
|
271 if ( parentIdProp ) |
|
272 { |
|
273 const TDesC8& id( parentIdProp->StringValue() ); |
|
274 |
|
275 CXnNode* parent( |
|
276 iUiEngine->FindNodeByIdL( id, iNode.Node().Namespace() ) ); |
|
277 |
|
278 |
|
279 if ( parent ) |
|
280 { |
|
281 TRect clientRect( iAppUiAdapter->ClientRect() ); |
|
282 |
|
283 TRect parentRect( parent->Rect() ); |
|
284 parentRect.Move( clientRect.iTl ); |
|
285 |
|
286 if ( !parentRect.Contains( aPointerEvent.iParentPosition ) ) |
|
287 { |
|
288 // tap was neither in popup nor in its parent - |
|
289 // we can close it |
|
290 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
291 { |
|
292 #ifdef RD_TACTILE_FEEDBACK |
|
293 MTouchFeedback* fb( MTouchFeedback::Instance() ); |
|
294 |
|
295 if ( fb ) |
|
296 { |
|
297 fb->InstantFeedback( ETouchFeedbackBasic ); |
|
298 } |
|
299 #endif |
|
300 HidePopupL(); |
|
301 return; |
|
302 } |
|
303 } |
|
304 else |
|
305 { |
|
306 // tap was made inside of popup parent |
|
307 // we pass the event to it after |
|
308 // recalculating the taping point |
|
309 TPointerEvent newPointerEvent; |
|
310 |
|
311 newPointerEvent.Copy( aPointerEvent ); |
|
312 |
|
313 newPointerEvent.iPosition = TPoint( |
|
314 aPointerEvent.iParentPosition - clientRect.iTl ); |
|
315 |
|
316 parent->Control()->HandlePointerEventL( newPointerEvent ); |
|
317 } |
|
318 } |
|
319 } |
|
320 else |
|
321 { |
|
322 #ifdef RD_TACTILE_FEEDBACK |
|
323 if ( aPointerEvent.iType == TPointerEvent::EButton1Down ) |
|
324 { |
|
325 MTouchFeedback* fb( MTouchFeedback::Instance() ); |
|
326 |
|
327 if ( fb ) |
|
328 { |
|
329 fb->InstantFeedback( ETouchFeedbackBasic ); |
|
330 } |
|
331 #endif |
|
332 HidePopupL(); |
|
333 } |
|
334 } |
|
335 } |
|
336 } |
|
337 |
|
338 CXnControlAdapter::HandlePointerEventL( aPointerEvent ); |
|
339 } |
|
340 |
|
341 // ----------------------------------------------------------------------------- |
|
342 // CXnWidgetExtensionAdapter::Draw |
|
343 // |
|
344 // ----------------------------------------------------------------------------- |
|
345 // |
|
346 void CXnWidgetExtensionAdapter::Draw( const TRect& aRect ) const |
|
347 { |
|
348 SystemGc().Clear( aRect ); |
|
349 CXnControlAdapter::Draw( aRect ); |
|
350 } |
|
351 |
|
352 // ----------------------------------------------------------------------------- |
|
353 // CXnWidgetExtensionAdapter::SizeChanged |
|
354 // |
|
355 // ----------------------------------------------------------------------------- |
|
356 // |
|
357 void CXnWidgetExtensionAdapter::SizeChanged() |
|
358 { |
|
359 ChangePopupPosition(); |
|
360 CXnControlAdapter::SizeChanged(); |
|
361 } |
|
362 |
|
363 // ----------------------------------------------------------------------------- |
|
364 // CXnWidgetExtensionAdapter::ChangePopupPosition |
|
365 // |
|
366 // ----------------------------------------------------------------------------- |
|
367 // |
|
368 void CXnWidgetExtensionAdapter::ChangePopupPosition() |
|
369 { |
|
370 if ( iPopup ) |
|
371 { |
|
372 // read position-hint property and set-up its variable |
|
373 CXnProperty* positionHintProp = NULL; |
|
374 TRAP_IGNORE( positionHintProp = iNode.Node().GetPropertyL( KPositionHint ) ); |
|
375 |
|
376 if ( positionHintProp ) |
|
377 { |
|
378 const TDesC8& displayHintVal = positionHintProp->StringValue(); |
|
379 |
|
380 if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveLeft ) |
|
381 { |
|
382 iPositionHint = EAboveLeft; |
|
383 } |
|
384 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KAboveRight ) |
|
385 { |
|
386 iPositionHint = EAboveRight; |
|
387 } |
|
388 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowLeft ) |
|
389 { |
|
390 iPositionHint = EBelowLeft; |
|
391 } |
|
392 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KBelowRight ) |
|
393 { |
|
394 iPositionHint = EBelowRight; |
|
395 } |
|
396 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KRight ) |
|
397 { |
|
398 iPositionHint = ERight; |
|
399 } |
|
400 else if ( displayHintVal == XnPropertyNames::tooltip::positionhint::KLeft ) |
|
401 { |
|
402 iPositionHint = ELeft; |
|
403 } |
|
404 else |
|
405 { |
|
406 // if the value if of unknown type, use default one |
|
407 if ( AknLayoutUtils::LayoutMirrored() ) |
|
408 { |
|
409 iPositionHint = EAboveRight; |
|
410 } |
|
411 else |
|
412 { |
|
413 iPositionHint = EAboveLeft; |
|
414 } |
|
415 } |
|
416 } |
|
417 if ( iPositionHint != ENone ) |
|
418 { |
|
419 // the popup is going visible and position-hind is available |
|
420 // calculate its position |
|
421 CalculatePosition(); |
|
422 } |
|
423 } |
|
424 } |
|
425 |
|
426 // ----------------------------------------------------------------------------- |
|
427 // CalculatePosition |
|
428 // This is used only for popup element with position hint |
|
429 // ----------------------------------------------------------------------------- |
|
430 void CXnWidgetExtensionAdapter::CalculatePosition() |
|
431 { |
|
432 // widget's rectangle |
|
433 TRect controlRect; |
|
434 |
|
435 // get popup's size. |
|
436 TSize popupSize = iNode.BorderRect().Size(); |
|
437 |
|
438 TRect clientRect = static_cast<CEikAppUi&>( *iAppUiAdapter ).ClientRect(); |
|
439 |
|
440 // get entire screen except control pane |
|
441 TRect contentRect( 0, 0, clientRect.iBr.iX, clientRect.iBr.iY ); |
|
442 |
|
443 // resulting rectangle |
|
444 TRect rect; |
|
445 |
|
446 TPoint offset( clientRect.iTl ); |
|
447 |
|
448 // parent widget's rectangle ( first predecesscor which is "widget" ) |
|
449 CXnNode* parent = iNode.Node().Parent(); |
|
450 |
|
451 while ( parent ) |
|
452 { |
|
453 const TDesC8& type( parent->DomNode()->Name() ); |
|
454 if ( type == KWidgetNodeName ) |
|
455 { |
|
456 break; |
|
457 } |
|
458 parent = parent->Parent(); |
|
459 } |
|
460 |
|
461 // if predecesscor widget was not found, use parent's rectangle |
|
462 if ( parent == NULL ) |
|
463 { |
|
464 controlRect = iNode.Node().Parent()->Rect(); |
|
465 } |
|
466 else |
|
467 { |
|
468 controlRect = parent->BorderRect(); |
|
469 } |
|
470 |
|
471 // calculate available space for placing the popup |
|
472 TInt spaceAbove = controlRect.iTl.iY + offset.iY; |
|
473 TInt spaceBelow = contentRect.iBr.iY - controlRect.iBr.iY - offset.iY; |
|
474 TInt spaceLeft = controlRect.iTl.iX + offset.iX; |
|
475 TInt spaceRight = contentRect.iBr.iX - controlRect.iBr.iX - offset.iX; |
|
476 |
|
477 switch ( iPositionHint ) |
|
478 { |
|
479 |
|
480 case EAboveLeft: |
|
481 |
|
482 // if this position does not fit the screen, |
|
483 // and if below left is more suitable, use it |
|
484 if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove ) |
|
485 { |
|
486 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
|
487 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) ); |
|
488 } |
|
489 else |
|
490 { |
|
491 // use the above-left position |
|
492 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), |
|
493 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) ); |
|
494 |
|
495 } |
|
496 break; |
|
497 |
|
498 case EAboveRight: |
|
499 |
|
500 // if this position does not fit the screen, |
|
501 // and if below right is more suitable, use it |
|
502 if ( spaceAbove < popupSize.iHeight && spaceBelow > spaceAbove ) |
|
503 { |
|
504 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), |
|
505 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) ); |
|
506 } |
|
507 else |
|
508 { |
|
509 // use the above-right position |
|
510 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), |
|
511 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
|
512 } |
|
513 break; |
|
514 |
|
515 case EBelowLeft: |
|
516 |
|
517 // if this position does not fit the screen, |
|
518 // and if above left is more suitable, use it |
|
519 if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove ) |
|
520 { |
|
521 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), |
|
522 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) ); |
|
523 } |
|
524 else |
|
525 { |
|
526 // use the below-left position |
|
527 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
|
528 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) ); |
|
529 } |
|
530 break; |
|
531 |
|
532 case EBelowRight: |
|
533 |
|
534 // if this position does not fit the screen, |
|
535 // and if above right is more suitable, use it |
|
536 if ( spaceBelow < popupSize.iHeight && spaceBelow < spaceAbove ) |
|
537 { |
|
538 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), |
|
539 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
|
540 } |
|
541 else |
|
542 { |
|
543 // use the below-right position |
|
544 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), |
|
545 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) ); |
|
546 } |
|
547 break; |
|
548 |
|
549 case ERight: |
|
550 |
|
551 // if this position does not fit the screen, |
|
552 // and if left or above-left is more suitable, use it |
|
553 if ( spaceRight < popupSize.iWidth ) |
|
554 { |
|
555 // use the left position if the space is big enough |
|
556 if ( spaceLeft >= popupSize.iWidth ) |
|
557 { |
|
558 // use left position |
|
559 rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ), |
|
560 TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) ); |
|
561 } |
|
562 else if ( spaceAbove >= popupSize.iHeight ) |
|
563 { |
|
564 // use the above-right position |
|
565 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iTl.iY - popupSize.iHeight ), |
|
566 TPoint( controlRect.iBr.iX, controlRect.iTl.iY ) ); |
|
567 } |
|
568 else |
|
569 { |
|
570 // use the below-right position |
|
571 rect = TRect( TPoint( controlRect.iBr.iX - popupSize.iWidth, controlRect.iBr.iY ), |
|
572 TPoint( controlRect.iBr.iX, controlRect.iBr.iY + popupSize.iHeight ) ); |
|
573 } |
|
574 } |
|
575 else |
|
576 { |
|
577 // use the right position |
|
578 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), |
|
579 TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) ); |
|
580 } |
|
581 |
|
582 break; |
|
583 |
|
584 case ELeft: |
|
585 |
|
586 // if this position does not fit the screen, |
|
587 // and if right is more suitable, use it |
|
588 if ( spaceLeft < popupSize.iWidth ) |
|
589 { |
|
590 // use the right position, if it the space is big enough |
|
591 if ( spaceRight >= popupSize.iWidth ) |
|
592 { |
|
593 rect = TRect( TPoint( controlRect.iBr.iX, controlRect.iTl.iY ), |
|
594 TPoint( controlRect.iBr.iX + popupSize.iWidth, controlRect.iTl.iY + popupSize.iHeight ) ); |
|
595 } |
|
596 else if ( spaceAbove >= popupSize.iHeight ) |
|
597 { |
|
598 // use the above-left position |
|
599 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iTl.iY - popupSize.iHeight ), |
|
600 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iTl.iY ) ); |
|
601 } |
|
602 else |
|
603 { |
|
604 // use the below-left position |
|
605 rect = TRect( TPoint( controlRect.iTl.iX, controlRect.iBr.iY ), |
|
606 TPoint( controlRect.iTl.iX + popupSize.iWidth, controlRect.iBr.iY + popupSize.iHeight ) ); |
|
607 } |
|
608 } |
|
609 else |
|
610 { |
|
611 // use the left position |
|
612 rect = TRect( TPoint( controlRect.iTl.iX - popupSize.iWidth, controlRect.iTl.iY ), |
|
613 TPoint( controlRect.iTl.iX, controlRect.iTl.iY + popupSize.iHeight ) ); |
|
614 } |
|
615 break; |
|
616 default: |
|
617 break; |
|
618 } |
|
619 |
|
620 rect.Move( offset ); |
|
621 |
|
622 // if the popup rectangle exceeds the borders of content rectangle, move it. |
|
623 if ( rect.iTl.iY < contentRect.iTl.iY ) |
|
624 { |
|
625 rect.Move( 0, contentRect.iTl.iY - rect.iTl.iY ); |
|
626 } |
|
627 if ( rect.iTl.iX < contentRect.iTl.iX ) |
|
628 { |
|
629 rect.Move( contentRect.iTl.iX - rect.iTl.iX, 0 ); |
|
630 } |
|
631 if ( rect.iBr.iY > contentRect.iBr.iY ) |
|
632 { |
|
633 rect.Move( 0, contentRect.iBr.iY - rect.iBr.iY ); |
|
634 } |
|
635 if ( rect.iBr.iX > contentRect.iBr.iX ) |
|
636 { |
|
637 rect.Move( contentRect.iBr.iX - rect.iBr.iX, 0 ); |
|
638 } |
|
639 |
|
640 SetPosition( rect.iTl ); |
|
641 SetSizeWithoutNotification( rect.Size() ); |
|
642 } |
|
643 |
|
644 |
|
645 // ----------------------------------------------------------------------------- |
|
646 // CXnWidgetExtensionAdapter::NotifyForegroundChanged |
|
647 // |
|
648 // ----------------------------------------------------------------------------- |
|
649 // |
|
650 void CXnWidgetExtensionAdapter::NotifyForegroundChanged( |
|
651 TForegroundStatus aStatus ) |
|
652 { |
|
653 if ( iPopup && aStatus != EForeground ) |
|
654 { |
|
655 TRAP_IGNORE( HidePopupL() ); |
|
656 } |
|
657 else if ( !iPopup && aStatus == EForeground ) |
|
658 { |
|
659 if ( !DrawableWindow()->IsFaded() ) |
|
660 { |
|
661 DrawableWindow()->FadeBehind( ETrue ); |
|
662 } |
|
663 } |
|
664 } |
|
665 |
|
666 // ----------------------------------------------------------------------------- |
|
667 // CXnWidgetExtensionAdapter::NotifyLightStatusChanged |
|
668 // |
|
669 // ----------------------------------------------------------------------------- |
|
670 // |
|
671 void CXnWidgetExtensionAdapter::NotifyLightStatusChanged( TBool aLightsOn ) |
|
672 { |
|
673 if ( !aLightsOn ) |
|
674 { |
|
675 TRAP_IGNORE( HidePopupL() ); |
|
676 } |
|
677 } |
|
678 |
|
679 // ----------------------------------------------------------------------------- |
|
680 // CXnWidgetExtensionAdapter::NotifyInCallStateChaged |
|
681 // |
|
682 // ----------------------------------------------------------------------------- |
|
683 // |
|
684 void CXnWidgetExtensionAdapter::NotifyInCallStateChaged( TBool /*aInCall*/ ) |
|
685 { |
|
686 } |
|
687 |
|
688 // ----------------------------------------------------------------------------- |
|
689 // CXnWidgetExtensionAdapter::HidePopupL |
|
690 // |
|
691 // ----------------------------------------------------------------------------- |
|
692 // |
|
693 void CXnWidgetExtensionAdapter::HidePopupL() |
|
694 { |
|
695 if ( IsVisible() ) |
|
696 { |
|
697 CXnDomStringPool* sp( iNode.Node().DomNode()->StringPool() ); |
|
698 |
|
699 CXnProperty* prop = CXnProperty::NewL( |
|
700 KDisplay, KNone, CXnDomPropertyValue::EString, *sp ); |
|
701 |
|
702 CleanupStack::PushL( prop ); |
|
703 |
|
704 iNode.Node().SetPropertyL( prop ); |
|
705 |
|
706 CleanupStack::Pop( prop ); |
|
707 } |
|
708 } |
|
709 |
|
710 // ----------------------------------------------------------------------------- |
|
711 // CXnWidgetExtensionAdapter::NotifyStatusPaneSizeChanged |
|
712 // |
|
713 // ----------------------------------------------------------------------------- |
|
714 // |
|
715 void CXnWidgetExtensionAdapter::NotifyStatusPaneSizeChanged() |
|
716 { |
|
717 } |
|
718 |
|
719 // ----------------------------------------------------------------------------- |
|
720 // CXnWidgetExtensionAdapter::NotifyResourceChanged |
|
721 // |
|
722 // ----------------------------------------------------------------------------- |
|
723 // |
|
724 void CXnWidgetExtensionAdapter::NotifyResourceChanged( TInt aType ) |
|
725 { |
|
726 |
|
727 // if type is widget extension and fade has changed |
|
728 // we have to always fade main window |
|
729 if ( !iPopup && aType == KEikMessageWindowsFadeChange ) |
|
730 { |
|
731 if ( !DrawableWindow()->IsFaded() ) |
|
732 { |
|
733 DrawableWindow()->FadeBehind( ETrue ); |
|
734 } |
|
735 } |
|
736 } |
|
737 |
|
738 // End of File |