|
1 /* |
|
2 * Copyright (c) 2007 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: The implementation for presentation elements. |
|
15 * |
|
16 */ |
|
17 |
|
18 |
|
19 |
|
20 #include "alfviewwidget.h" |
|
21 #include "alfviewcontrol.h" |
|
22 #include <e32std.h> |
|
23 #include <assert.h> |
|
24 #include <memory> |
|
25 #include <alf/alfcontrolgroup.h> |
|
26 #include <alf/alfenv.h> |
|
27 #include <alf/alfdisplay.h> |
|
28 #include <alf/alfroster.h> |
|
29 #include <alf/alfmetric.h> |
|
30 #include "alf/alfwidget.h" |
|
31 #include <alf/alfwidgetcontrol.h> |
|
32 #include <alf/alfanchorlayoutmanager.h> |
|
33 #include <alf/alfgridlayout.h> |
|
34 #include <alf/ialfgridlayoutpolicy.h> |
|
35 #include <alf/alfwidgetenvextension.h> |
|
36 #include <alf/ialfwidgetfactory.h> |
|
37 |
|
38 #include <alf/alfutil.h> |
|
39 |
|
40 #include "alfviewwidgetexception.h" |
|
41 |
|
42 #include <eikbtgpc.h> |
|
43 #include <eikspane.h> |
|
44 #include <eikmenub.h> |
|
45 |
|
46 namespace Alf |
|
47 { |
|
48 |
|
49 /** |
|
50 * Observer class to observe changes in the relative order of control groups in associated |
|
51 * roster object and to notify view object about possible view activation (view coming |
|
52 * top-most) and deactivation. |
|
53 * |
|
54 * This class is a Symbian - specific implementation class. |
|
55 */ |
|
56 class AlfViewWidgetZOrderChangedObserver : public MAlfControlGroupOrderChangedObserver |
|
57 { |
|
58 public: |
|
59 |
|
60 /** |
|
61 * Default constructor |
|
62 */ |
|
63 AlfViewWidgetZOrderChangedObserver(CAlfDisplay& aDisplay, AlfViewWidget& aView) |
|
64 : iDisplay(aDisplay), iView(aView) |
|
65 { |
|
66 aDisplay.Roster().AddControlGroupOrderChangedObserverL(*this); |
|
67 } |
|
68 |
|
69 /** |
|
70 * Default destructor |
|
71 */ |
|
72 ~AlfViewWidgetZOrderChangedObserver() |
|
73 { |
|
74 int index = CAlfEnv::Static()->FindDisplayIndex(iDisplay); |
|
75 if(index != -1) |
|
76 { |
|
77 iDisplay.Roster().RemoveControlGroupOrderChangedObserver(*this); |
|
78 } |
|
79 } |
|
80 |
|
81 /** |
|
82 * Callback method called by roster when control group order changes. |
|
83 */ |
|
84 void NotifyControlGroupOrderChanged() |
|
85 { |
|
86 // If the associated view is on top, notify it about view activation |
|
87 // and the view below it about view deactivation. |
|
88 if(iView.getViewStackPosition() == 0) |
|
89 { |
|
90 AlfViewWidget* viewBelow = getViewFromStack(1); |
|
91 if(viewBelow) |
|
92 { |
|
93 viewBelow->notifyViewActivated(false); |
|
94 } |
|
95 |
|
96 iView.notifyViewActivated(true); |
|
97 } |
|
98 } |
|
99 |
|
100 private: |
|
101 |
|
102 /** |
|
103 * Utility method to return view from specified z-position on the view stack. |
|
104 * Returns 0 if the index is out of bounds. |
|
105 */ |
|
106 AlfViewWidget* getViewFromStack(int index) |
|
107 { |
|
108 int zPos = 0; |
|
109 |
|
110 // Iterate through the control groups in the roster |
|
111 for(int i = (iDisplay.Roster().Count() - 1); i >= 0; --i) |
|
112 { |
|
113 CAlfControlGroup& group = iDisplay.Roster().ControlGroup(i); |
|
114 |
|
115 // Investigate whether this is a control group of a view widget |
|
116 if(group.Count() > 0) |
|
117 { |
|
118 CAlfControl& control = group.Control(0); |
|
119 CAlfViewControl* viewControl = dynamic_cast<CAlfViewControl*>(&control); |
|
120 if(viewControl != 0) |
|
121 { |
|
122 // View widget found from the roster |
|
123 if(zPos == index) |
|
124 { |
|
125 return &viewControl->viewWidget(); |
|
126 } |
|
127 zPos++; |
|
128 } |
|
129 } |
|
130 } |
|
131 |
|
132 return 0; |
|
133 } |
|
134 |
|
135 /** Roster to which this callback object is added to. */ |
|
136 CAlfDisplay& iDisplay; |
|
137 |
|
138 /** View widget that this observer notifies. */ |
|
139 AlfViewWidget& iView; |
|
140 |
|
141 }; |
|
142 |
|
143 |
|
144 AlfViewWidget::AlfViewWidget(const char* aWidgetName, int aControlGroupId, CAlfEnv& aEnv, |
|
145 CAlfDisplay& aDisplay, DuiNode* aNode, const char *aFilePath) : |
|
146 mEnv(&aEnv), mDisplay(&aDisplay), mControlGroup(0), |
|
147 mZOrderChangedObserver(0), |
|
148 mControlGroupResourceId(aControlGroupId), |
|
149 mShown(false), mControlPaneEnabled(true), mStatusPaneEnabled(true), |
|
150 mSkinEnabled(false), mSkinId(KAknsIIDQsnBgScreen), mHasFocus(false) |
|
151 { |
|
152 mChildWidgetName.setAutoDelete(true); |
|
153 mWidget.reset(new (EMM) AlfWidget(aWidgetName)); |
|
154 |
|
155 TRAPD(err,aEnv.AddActionObserverL(this)); |
|
156 if(err!=KErrNone) |
|
157 { |
|
158 ALF_THROW(AlfViewWidgetException, err, |
|
159 "CAlfEnv::AddActionObserverL() - failed."); |
|
160 } |
|
161 |
|
162 // By default, we use ClientRect() as the area of the view widget |
|
163 TRect rect = ((CAknAppUi*)CEikonEnv::Static()->AppUi())->ClientRect(); |
|
164 mDisplayRect = TRect(rect); |
|
165 |
|
166 mZOrderChangedObserver.reset(new (EMM) AlfViewWidgetZOrderChangedObserver(aDisplay, *this)); |
|
167 |
|
168 constructDefault(aEnv); |
|
169 |
|
170 } |
|
171 |
|
172 AlfViewWidget::~AlfViewWidget() |
|
173 { |
|
174 //If the view widget is deleted before the AlfEnv is deleted, |
|
175 //the control group needs to be destroyed. |
|
176 if(mEnv->FindControlGroup(mControlGroupResourceId)) |
|
177 { |
|
178 mEnv->DeleteControlGroup(mControlGroup->ResourceId()); |
|
179 } |
|
180 |
|
181 mEnv->RemoveActionObserver(this); |
|
182 |
|
183 IAlfWidget* childWidget = NULL; |
|
184 |
|
185 IAlfWidgetFactory& factory = AlfWidgetEnvExtension::widgetFactory(*(CAlfEnv::Static())); |
|
186 for(int i =0 ;i < mChildWidgetName.count();i++) |
|
187 { |
|
188 childWidget = factory.findWidget(mChildWidgetName.at(i)->getUtf8()); |
|
189 if(childWidget) |
|
190 { |
|
191 factory.destroyWidget(childWidget); |
|
192 childWidget = NULL; |
|
193 } |
|
194 } |
|
195 mChildWidgetName.clear(); |
|
196 } |
|
197 |
|
198 CAlfWidgetControl* AlfViewWidget::control() const |
|
199 { |
|
200 return mWidget->control(); |
|
201 } |
|
202 |
|
203 IAlfContainerWidget* AlfViewWidget::parent() const |
|
204 { |
|
205 return mWidget->parent(); |
|
206 } |
|
207 |
|
208 void AlfViewWidget::setControl(CAlfWidgetControl* aControl, bool aDeletePreviousControl) |
|
209 { |
|
210 CAlfWidgetControl* prevControl = mWidget->control(); |
|
211 |
|
212 // Set new control to the widget implementation. |
|
213 // Never delete the previous control in this phase, so that we can |
|
214 // still remove it from the control group if this call is succesfull. |
|
215 mWidget->setControl(aControl, false); |
|
216 |
|
217 // Remove the previous control from control group. |
|
218 if(prevControl != 0) |
|
219 { |
|
220 assert(prevControl->ControlGroup() == mControlGroup); |
|
221 if(aDeletePreviousControl) |
|
222 { |
|
223 mControlGroup->Remove(prevControl); |
|
224 delete prevControl; |
|
225 } |
|
226 } |
|
227 |
|
228 // Append the new control into the control group. |
|
229 if(aControl) |
|
230 { |
|
231 TRAPD(err, mControlGroup->AppendL(aControl)); |
|
232 if(err != KErrNone) |
|
233 { |
|
234 mWidget->setControl(0, false); |
|
235 ALF_THROW(AlfViewWidgetException, err, "CAlfControlGroup::AppendL() - failed."); |
|
236 } |
|
237 } |
|
238 } |
|
239 |
|
240 void AlfViewWidget::setChildNameToDelete( UString aChildName ) |
|
241 { |
|
242 UString* childName = new(EMM)UString(aChildName.getUtf8()); |
|
243 mChildWidgetName.resize(mChildWidgetName.count()+1); |
|
244 mChildWidgetName.insert(mChildWidgetName.count(),childName); |
|
245 } |
|
246 |
|
247 IAlfModel* AlfViewWidget::model() |
|
248 { |
|
249 return 0; |
|
250 } |
|
251 |
|
252 void AlfViewWidget::setModel(IAlfModel* /*aModel*/, bool /*aTakeOwnership*/) |
|
253 { |
|
254 //Do nothing. |
|
255 } |
|
256 |
|
257 const char* AlfViewWidget::widgetName() const |
|
258 { |
|
259 return mWidget->widgetName(); |
|
260 } |
|
261 |
|
262 void AlfViewWidget::setChildFocus(bool /*aFocus*/) |
|
263 { |
|
264 |
|
265 } |
|
266 |
|
267 //--------------------------------------------------------------------------- |
|
268 // Creates the presentation for the widget from XML. Destroys any existing |
|
269 // presentation. |
|
270 //--------------------------------------------------------------------------- |
|
271 // |
|
272 void AlfViewWidget::setPresentation (const char* aFilePath) |
|
273 { |
|
274 if(mWidget.get()) |
|
275 { |
|
276 mWidget->setPresentation(aFilePath); |
|
277 } |
|
278 } |
|
279 |
|
280 int AlfViewWidget::widgetCount() const |
|
281 { |
|
282 return mWidget->widgetCount(); |
|
283 } |
|
284 |
|
285 void AlfViewWidget::addWidget(IAlfWidget& aWidget) |
|
286 { |
|
287 mWidget->addWidget(aWidget); |
|
288 } |
|
289 |
|
290 IAlfWidget* AlfViewWidget::getWidget(int aIndex) const |
|
291 { |
|
292 return mWidget->getWidget(aIndex); |
|
293 } |
|
294 |
|
295 int AlfViewWidget::getWidgetIndex(IAlfWidget& aWidget) const |
|
296 { |
|
297 return mWidget->getWidgetIndex(aWidget); |
|
298 } |
|
299 |
|
300 void AlfViewWidget::removeWidget(int aIndex) |
|
301 { |
|
302 mWidget->removeWidget(aIndex); |
|
303 } |
|
304 |
|
305 void AlfViewWidget::applyLayout(IAlfLayoutManager& aLayout) |
|
306 { |
|
307 mWidget->applyLayout(aLayout); |
|
308 } |
|
309 |
|
310 IAlfInterfaceBase* AlfViewWidget::makeInterface(const IfId& aType) |
|
311 { |
|
312 // Type cast to IAlfWidget |
|
313 if(!strcmp(aType.mImplementationId, IAlfWidget::type().mImplementationId)) |
|
314 { |
|
315 return static_cast<IAlfWidget*>(this); |
|
316 } |
|
317 |
|
318 // Type cast to IAlfContainerWidget |
|
319 if (!strcmp(aType.mImplementationId, IAlfContainerWidget::type().mImplementationId)) |
|
320 { |
|
321 return static_cast<IAlfContainerWidget*>(this); |
|
322 } |
|
323 |
|
324 // Type cast to IAlfViewWidget |
|
325 if(!strcmp(aType.mImplementationId, IAlfViewWidget::type().mImplementationId)) |
|
326 { |
|
327 return static_cast<IAlfViewWidget*>(this); |
|
328 } |
|
329 |
|
330 return mWidget->makeInterface(aType); |
|
331 } |
|
332 |
|
333 void AlfViewWidget::notifyViewActivated(bool aIsActivated) |
|
334 { |
|
335 if(aIsActivated) |
|
336 { |
|
337 // Update control pane, status pane and background according to state of the view. |
|
338 updateStatusPane(); |
|
339 updateControlPane(); |
|
340 updateBackGroundImage(); |
|
341 // When a view is activated, it sets the size of the display to full screen |
|
342 // This is done so that the view widget gets pointer events in the entire screen |
|
343 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
344 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
345 setRect(mDisplayRect); |
|
346 |
|
347 // Restore the focus here |
|
348 IAlfWidget* focusedWidget = 0; |
|
349 focusedWidget = AlfWidgetEnvExtension::widgetFactory(*mEnv).findWidget(mFocusedChildWidgetID.c_str()); |
|
350 if(focusedWidget == 0 && widgetCount() > 0) |
|
351 { |
|
352 focusedWidget = getWidget(0); |
|
353 } |
|
354 if(!mHasFocus) |
|
355 { |
|
356 mHasFocus = true; |
|
357 if(focusedWidget != 0) |
|
358 { |
|
359 focusedWidget->control()->AcquireFocus(); |
|
360 } |
|
361 else |
|
362 { |
|
363 control()->AcquireFocus(); |
|
364 } |
|
365 } |
|
366 } |
|
367 else |
|
368 { |
|
369 // Cache and release the focus here |
|
370 // FocusedControl function is not exported from the toolkit |
|
371 CAlfControl* focusedCtrl = focusedControl(); |
|
372 if(focusedCtrl) |
|
373 { |
|
374 CAlfWidgetControl* focusedWidgetControl = dynamic_cast<CAlfWidgetControl*>(focusedCtrl); |
|
375 if(focusedWidgetControl != 0) |
|
376 { |
|
377 mFocusedChildWidgetID = focusedWidgetControl->widget()->widgetName(); |
|
378 } |
|
379 focusedCtrl->RelinquishFocus(); |
|
380 } |
|
381 mHasFocus = false; |
|
382 } |
|
383 } |
|
384 |
|
385 CAlfControl* AlfViewWidget::focusedControl() |
|
386 { |
|
387 CAlfControl* focusedconnection = control(); |
|
388 |
|
389 // Iterate through the focused connections and return the control |
|
390 // that has the focus. |
|
391 while(focusedconnection != 0) |
|
392 { |
|
393 if(focusedconnection->Focus()) |
|
394 { |
|
395 // There should be no connections leading outside from the control |
|
396 // group of the view. |
|
397 assert(focusedconnection->ControlGroup() == mControlGroup); |
|
398 return focusedconnection; |
|
399 } |
|
400 focusedconnection = focusedconnection->FocusedConnection(); |
|
401 } |
|
402 |
|
403 return 0; |
|
404 } |
|
405 |
|
406 void AlfViewWidget::show(bool aShow) |
|
407 { |
|
408 mShown = aShow; |
|
409 if (aShow) |
|
410 { |
|
411 TRAPD(err, mDisplay->Roster().ShowL(*mControlGroup)); |
|
412 if (err != KErrNone) |
|
413 { |
|
414 ALF_THROW(AlfViewWidgetException, err, "AlfViewWidget::show(): View Widget Show failed"); |
|
415 } |
|
416 } |
|
417 else |
|
418 { |
|
419 // Notify this view that it is being deactivated. |
|
420 notifyViewActivated(false); |
|
421 |
|
422 // Hide the control group |
|
423 mDisplay->Roster().Hide(*mControlGroup); |
|
424 } |
|
425 } |
|
426 |
|
427 void AlfViewWidget::acceptEvents(bool aAccept) |
|
428 { |
|
429 assert(mControlGroup); |
|
430 mControlGroup->SetAcceptInput(aAccept); |
|
431 } |
|
432 |
|
433 void AlfViewWidget::enableStatusPane(bool aEnable) |
|
434 { |
|
435 if(aEnable != mStatusPaneEnabled) |
|
436 { |
|
437 mStatusPaneEnabled = aEnable; |
|
438 |
|
439 // Update status pane and background image state if this view is active. |
|
440 if(getViewStackPosition() == 0) |
|
441 { |
|
442 updateStatusPane(); |
|
443 updateBackGroundImage(); |
|
444 } |
|
445 } |
|
446 } |
|
447 |
|
448 void AlfViewWidget::enableControlPane(bool aEnable) |
|
449 { |
|
450 if (aEnable != mControlPaneEnabled) |
|
451 { |
|
452 mControlPaneEnabled=aEnable; |
|
453 |
|
454 // Update control pane and background image state if this view is active. |
|
455 if(getViewStackPosition() == 0) |
|
456 { |
|
457 updateControlPane(); |
|
458 updateBackGroundImage(); |
|
459 } |
|
460 } |
|
461 } |
|
462 |
|
463 void AlfViewWidget::useSkinBackground(bool aSkinBackground) |
|
464 { |
|
465 if(mSkinEnabled != aSkinBackground) |
|
466 { |
|
467 mSkinEnabled = aSkinBackground; |
|
468 updateBackGroundImage(); |
|
469 } |
|
470 |
|
471 } |
|
472 |
|
473 void AlfViewWidget::setSkinBackground(TAknsItemID aSkinID) |
|
474 { |
|
475 mSkinEnabled = true; |
|
476 mSkinId = aSkinID; |
|
477 updateBackGroundImage(); |
|
478 } |
|
479 |
|
480 bool AlfViewWidget::shown() |
|
481 { |
|
482 return mShown; |
|
483 } |
|
484 |
|
485 int AlfViewWidget::getViewStackPosition() const |
|
486 { |
|
487 int ret = 0; |
|
488 const CAlfRoster& roster = mDisplay->Roster(); |
|
489 |
|
490 // Iterate through the control groups in the roster |
|
491 for(int i = (roster.Count() - 1); i >= 0; --i) |
|
492 { |
|
493 CAlfControlGroup& group = roster.ControlGroup(i); |
|
494 |
|
495 // Compare the control group with this view's control group |
|
496 if(mControlGroup == &group) |
|
497 { |
|
498 return ret; |
|
499 } |
|
500 |
|
501 // Investigate whether this is a control group of a view widget |
|
502 if(group.Count() > 0) |
|
503 { |
|
504 CAlfControl& control = group.Control(0); |
|
505 if(dynamic_cast<CAlfViewControl*>(&control) != 0) |
|
506 { |
|
507 ret++; |
|
508 } |
|
509 } |
|
510 } |
|
511 |
|
512 return -1; |
|
513 } |
|
514 |
|
515 bool AlfViewWidget::eventsAccepted() |
|
516 { |
|
517 assert(mControlGroup); |
|
518 return mControlGroup->AcceptInput(); |
|
519 } |
|
520 |
|
521 bool AlfViewWidget::statusPaneEnabled() |
|
522 { |
|
523 return mStatusPaneEnabled; |
|
524 } |
|
525 |
|
526 bool AlfViewWidget::controlPaneEnabled() |
|
527 { |
|
528 return mControlPaneEnabled; |
|
529 } |
|
530 |
|
531 bool AlfViewWidget::usingSkinBackground() |
|
532 { |
|
533 return mSkinEnabled; |
|
534 } |
|
535 |
|
536 TAknsItemID AlfViewWidget::skinBackground() |
|
537 { |
|
538 return mSkinId; |
|
539 } |
|
540 |
|
541 // --------------------------------------------------------------------------- |
|
542 // Constructs components from node |
|
543 // --------------------------------------------------------------------------- |
|
544 // |
|
545 void AlfViewWidget::constructComponentsFromNode(CAlfEnv& aEnv) |
|
546 { |
|
547 constructDefault(aEnv, false); |
|
548 |
|
549 //check, if the layoutmanager is already set. |
|
550 IAlfLayoutManager* layoutManager = |
|
551 IAlfInterfaceBase::makeInterface<IAlfLayoutManager>(control()); |
|
552 if (!layoutManager) |
|
553 { |
|
554 setDefaultLayoutManager(); |
|
555 } |
|
556 } |
|
557 |
|
558 //--------------------------------------------------------------------------- |
|
559 // Constructs widget using the presentation XML. Other widget parts |
|
560 // are default. |
|
561 //--------------------------------------------------------------------------- |
|
562 // |
|
563 void AlfViewWidget::constructFromPresentationXML(CAlfEnv& aEnv, const char* /**aFilePath*/) |
|
564 { |
|
565 constructDefault(aEnv, true); |
|
566 } |
|
567 |
|
568 // --------------------------------------------------------------------------- |
|
569 // Imperative construction |
|
570 // --------------------------------------------------------------------------- |
|
571 // |
|
572 void AlfViewWidget::constructDefault(CAlfEnv& aEnv, bool aCreateLM) |
|
573 { |
|
574 TRAPD( err, |
|
575 mControlGroup = &aEnv.NewControlGroupL(mControlGroupResourceId); |
|
576 ); |
|
577 |
|
578 if(err != KErrNone) |
|
579 { |
|
580 if (err == KErrAlreadyExists) |
|
581 { |
|
582 ALF_THROW(AlfViewWidgetException, |
|
583 EControlGroupAlreadyExists, "AlfViewWidget::AlfViewWidget() - Tried to create a control group with already existing ID."); |
|
584 } |
|
585 else |
|
586 { |
|
587 ALF_THROW(AlfViewWidgetException, |
|
588 err, "AlfViewWidget::AlfViewWidget() - Control group creation failed."); |
|
589 } |
|
590 } |
|
591 |
|
592 // Create control for the view widget |
|
593 auto_ptr<CAlfViewControl> control( new (EMM) CAlfViewControl(aEnv, *this) ); |
|
594 setControl(control.get()); |
|
595 control.release(); |
|
596 |
|
597 if (aCreateLM) |
|
598 { |
|
599 setDefaultLayoutManager(); |
|
600 } |
|
601 } |
|
602 |
|
603 // --------------------------------------------------------------------------- |
|
604 // Imperative createDefaultLayoutManager |
|
605 // --------------------------------------------------------------------------- |
|
606 // |
|
607 void AlfViewWidget::setDefaultLayoutManager() |
|
608 { |
|
609 // A root layout covering the entire display is created to grab all pointer events in the screen |
|
610 // Note that this layout is just dummy and does not do any actual layouting |
|
611 CAlfControl* ctrl = (CAlfControl*)control(); |
|
612 CAlfLayout* fullDisplayLayout = CAlfLayout::AddNewL(*ctrl); |
|
613 |
|
614 // Default layout manager provided by the view widget |
|
615 auto_ptr<AlfAnchorLayoutManager> layoutManager(new (EMM) AlfAnchorLayoutManager()); |
|
616 this->applyLayout(*layoutManager.get()); |
|
617 |
|
618 layoutManager.release(); |
|
619 } |
|
620 |
|
621 void AlfViewWidget::updateStatusPane() |
|
622 { |
|
623 /*CEikStatusPane *sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
624 if(sp) |
|
625 { |
|
626 sp->MakeVisible(mStatusPaneEnabled); |
|
627 // mDisplay->SetVisibleArea(CEikonEnv::Static()->AppUiFactory()->ClientRect()); |
|
628 }*/ |
|
629 } |
|
630 |
|
631 void AlfViewWidget::updateControlPane() |
|
632 { |
|
633 /*CEikButtonGroupContainer* cba= CEikonEnv::Static()->AppUiFactory()->Cba(); |
|
634 if(cba) |
|
635 { |
|
636 cba->MakeVisible(mControlPaneEnabled); |
|
637 // mDisplay->SetVisibleArea(CEikonEnv::Static()->AppUiFactory()->ClientRect()); |
|
638 }*/ |
|
639 |
|
640 } |
|
641 |
|
642 void AlfViewWidget::updateBackGroundImage() |
|
643 { |
|
644 TAknsItemID skinId=KAknsIIDQsnBgScreen; |
|
645 // Do background related stuff only if the view is showing |
|
646 if(mSkinEnabled ) |
|
647 { |
|
648 skinId=mSkinId; |
|
649 } |
|
650 if(mShown) |
|
651 { |
|
652 TAlfDisplayBackgroundItem bgItem(mDisplay->VisibleArea(),skinId); |
|
653 RArray<TAlfDisplayBackgroundItem> bgItemArray; |
|
654 bgItemArray.Append(bgItem); |
|
655 TRAPD(err,mDisplay->SetBackgroundItemsL(bgItemArray)); |
|
656 if(err!=KErrNone) |
|
657 { |
|
658 ALF_THROW(AlfViewWidgetException, err,"Skin Background could not be set"); |
|
659 } |
|
660 bgItemArray.Reset(); |
|
661 } |
|
662 |
|
663 } |
|
664 |
|
665 |
|
666 void AlfViewWidget::HandleActionL(const TAlfActionCommand& aActionCommand) |
|
667 { |
|
668 if(KAlfActionIdDeviceLayoutChanged == aActionCommand.Id()) |
|
669 { |
|
670 TAlfCustomEventCommand command(KAlfActionIdDeviceLayoutChanged); |
|
671 control()->Env().Send(command,0); |
|
672 if(mShown && getViewStackPosition() == 0) |
|
673 { |
|
674 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
675 |
|
676 // SetVisibleArea() only have an effect if the application is on foreground! |
|
677 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
678 updateBackGroundImage(); |
|
679 } |
|
680 |
|
681 } |
|
682 |
|
683 else if(KAlfActionIdForegroundGained == aActionCommand.Id()) |
|
684 { |
|
685 |
|
686 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
687 |
|
688 // SetVisibleArea() only have an effect if the application is on foreground! |
|
689 |
|
690 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
691 |
|
692 updateBackGroundImage(); |
|
693 |
|
694 } |
|
695 |
|
696 } |
|
697 |
|
698 TBool AlfViewWidget::OfferEventL(const TAlfEvent& /*aEvent*/) |
|
699 { |
|
700 /* if(aEvent.IsCustomEvent() && aEvent.CustomParameter() == KAlfActionIdDeviceLayoutChanged) |
|
701 { |
|
702 if(mShown && getViewStackPosition() == 0) |
|
703 { |
|
704 //need to do this to overwrite the displayrect done by menuApp |
|
705 // TRect rect= control()->Env().PrimaryDisplay().VisibleArea(); |
|
706 // control()->Env().PrimaryDisplay().SetVisibleArea(mDisplayRect); |
|
707 updateBackGroundImage(); |
|
708 } |
|
709 return ETrue; |
|
710 } |
|
711 */ return EFalse; |
|
712 } |
|
713 |
|
714 void AlfViewWidget::setRect(const TRect& aRect) |
|
715 { |
|
716 mDisplayRect = aRect; |
|
717 |
|
718 IAlfLayoutManager* layoutManager = IAlfInterfaceBase::makeInterface<IAlfLayoutManager>(control()); |
|
719 if (layoutManager) |
|
720 { |
|
721 // Set the area of the root layout of the view widget to the one specified |
|
722 CAlfLayout& layout = layoutManager->getLayout(); |
|
723 layout.SetFlag(EAlfVisualFlagManualLayout); |
|
724 TAlfRealRect rect(mDisplayRect); |
|
725 layout.SetRect(rect); |
|
726 } |
|
727 |
|
728 TRect visibleRect = control()->Env().PrimaryDisplay().VisibleArea(); |
|
729 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
730 |
|
731 if(visibleRect != screenRect && getViewStackPosition() == 0) |
|
732 { |
|
733 // the display area is required to be full screen, for the pointer grab to work |
|
734 // check here whether the display area is full screen. If not, set it to full screen |
|
735 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
736 updateBackGroundImage(); |
|
737 } |
|
738 } |
|
739 |
|
740 } //Alf |
|
741 |
|
742 |
|
743 //End of file |
|
744 |