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 // When a view is activated, it sets the size of the display to full screen |
|
341 // This is done so that the view widget gets pointer events in the entire screen |
|
342 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
343 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
344 setRect(mDisplayRect); |
|
345 |
|
346 // Restore the focus here |
|
347 IAlfWidget* focusedWidget = 0; |
|
348 focusedWidget = AlfWidgetEnvExtension::widgetFactory(*mEnv).findWidget(mFocusedChildWidgetID.c_str()); |
|
349 if(focusedWidget == 0 && widgetCount() > 0) |
|
350 { |
|
351 focusedWidget = getWidget(0); |
|
352 } |
|
353 if(!mHasFocus) |
|
354 { |
|
355 mHasFocus = true; |
|
356 if(focusedWidget != 0) |
|
357 { |
|
358 focusedWidget->control()->AcquireFocus(); |
|
359 } |
|
360 else |
|
361 { |
|
362 control()->AcquireFocus(); |
|
363 } |
|
364 } |
|
365 } |
|
366 else |
|
367 { |
|
368 // Cache and release the focus here |
|
369 // FocusedControl function is not exported from the toolkit |
|
370 CAlfControl* focusedCtrl = focusedControl(); |
|
371 if(focusedCtrl) |
|
372 { |
|
373 CAlfWidgetControl* focusedWidgetControl = dynamic_cast<CAlfWidgetControl*>(focusedCtrl); |
|
374 if(focusedWidgetControl != 0) |
|
375 { |
|
376 mFocusedChildWidgetID = focusedWidgetControl->widget()->widgetName(); |
|
377 } |
|
378 focusedCtrl->RelinquishFocus(); |
|
379 } |
|
380 mHasFocus = false; |
|
381 } |
|
382 } |
|
383 |
|
384 CAlfControl* AlfViewWidget::focusedControl() |
|
385 { |
|
386 CAlfControl* focusedconnection = control(); |
|
387 |
|
388 // Iterate through the focused connections and return the control |
|
389 // that has the focus. |
|
390 while(focusedconnection != 0) |
|
391 { |
|
392 if(focusedconnection->Focus()) |
|
393 { |
|
394 // There should be no connections leading outside from the control |
|
395 // group of the view. |
|
396 assert(focusedconnection->ControlGroup() == mControlGroup); |
|
397 return focusedconnection; |
|
398 } |
|
399 focusedconnection = focusedconnection->FocusedConnection(); |
|
400 } |
|
401 |
|
402 return 0; |
|
403 } |
|
404 |
|
405 void AlfViewWidget::show(bool aShow) |
|
406 { |
|
407 mShown = aShow; |
|
408 if (aShow) |
|
409 { |
|
410 TRAPD(err, mDisplay->Roster().ShowL(*mControlGroup)); |
|
411 if (err != KErrNone) |
|
412 { |
|
413 ALF_THROW(AlfViewWidgetException, err, "AlfViewWidget::show(): View Widget Show failed"); |
|
414 } |
|
415 } |
|
416 else |
|
417 { |
|
418 // Notify this view that it is being deactivated. |
|
419 notifyViewActivated(false); |
|
420 |
|
421 // Hide the control group |
|
422 mDisplay->Roster().Hide(*mControlGroup); |
|
423 } |
|
424 } |
|
425 |
|
426 void AlfViewWidget::acceptEvents(bool aAccept) |
|
427 { |
|
428 assert(mControlGroup); |
|
429 mControlGroup->SetAcceptInput(aAccept); |
|
430 } |
|
431 |
|
432 void AlfViewWidget::enableStatusPane(bool aEnable) |
|
433 { |
|
434 if(aEnable != mStatusPaneEnabled) |
|
435 { |
|
436 mStatusPaneEnabled = aEnable; |
|
437 |
|
438 // Update status pane and background image state if this view is active. |
|
439 if(getViewStackPosition() == 0) |
|
440 { |
|
441 updateStatusPane(); |
|
442 } |
|
443 } |
|
444 } |
|
445 |
|
446 void AlfViewWidget::enableControlPane(bool aEnable) |
|
447 { |
|
448 if (aEnable != mControlPaneEnabled) |
|
449 { |
|
450 mControlPaneEnabled=aEnable; |
|
451 |
|
452 // Update control pane and background image state if this view is active. |
|
453 if(getViewStackPosition() == 0) |
|
454 { |
|
455 updateControlPane(); |
|
456 } |
|
457 } |
|
458 } |
|
459 |
|
460 void AlfViewWidget::useSkinBackground(bool aSkinBackground) |
|
461 { |
|
462 if(mSkinEnabled != aSkinBackground) |
|
463 { |
|
464 mSkinEnabled = aSkinBackground; |
|
465 updateBackGroundImage(); |
|
466 } |
|
467 |
|
468 } |
|
469 |
|
470 void AlfViewWidget::setSkinBackground(TAknsItemID aSkinID) |
|
471 { |
|
472 mSkinEnabled = true; |
|
473 mSkinId = aSkinID; |
|
474 updateBackGroundImage(); |
|
475 } |
|
476 |
|
477 bool AlfViewWidget::shown() |
|
478 { |
|
479 return mShown; |
|
480 } |
|
481 |
|
482 int AlfViewWidget::getViewStackPosition() const |
|
483 { |
|
484 int ret = 0; |
|
485 const CAlfRoster& roster = mDisplay->Roster(); |
|
486 |
|
487 // Iterate through the control groups in the roster |
|
488 for(int i = (roster.Count() - 1); i >= 0; --i) |
|
489 { |
|
490 CAlfControlGroup& group = roster.ControlGroup(i); |
|
491 |
|
492 // Compare the control group with this view's control group |
|
493 if(mControlGroup == &group) |
|
494 { |
|
495 return ret; |
|
496 } |
|
497 |
|
498 // Investigate whether this is a control group of a view widget |
|
499 if(group.Count() > 0) |
|
500 { |
|
501 CAlfControl& control = group.Control(0); |
|
502 if(dynamic_cast<CAlfViewControl*>(&control) != 0) |
|
503 { |
|
504 ret++; |
|
505 } |
|
506 } |
|
507 } |
|
508 |
|
509 return -1; |
|
510 } |
|
511 |
|
512 bool AlfViewWidget::eventsAccepted() |
|
513 { |
|
514 assert(mControlGroup); |
|
515 return mControlGroup->AcceptInput(); |
|
516 } |
|
517 |
|
518 bool AlfViewWidget::statusPaneEnabled() |
|
519 { |
|
520 return mStatusPaneEnabled; |
|
521 } |
|
522 |
|
523 bool AlfViewWidget::controlPaneEnabled() |
|
524 { |
|
525 return mControlPaneEnabled; |
|
526 } |
|
527 |
|
528 bool AlfViewWidget::usingSkinBackground() |
|
529 { |
|
530 return mSkinEnabled; |
|
531 } |
|
532 |
|
533 TAknsItemID AlfViewWidget::skinBackground() |
|
534 { |
|
535 return mSkinId; |
|
536 } |
|
537 |
|
538 // --------------------------------------------------------------------------- |
|
539 // Constructs components from node |
|
540 // --------------------------------------------------------------------------- |
|
541 // |
|
542 void AlfViewWidget::constructComponentsFromNode(CAlfEnv& aEnv) |
|
543 { |
|
544 constructDefault(aEnv, false); |
|
545 |
|
546 //check, if the layoutmanager is already set. |
|
547 IAlfLayoutManager* layoutManager = |
|
548 IAlfInterfaceBase::makeInterface<IAlfLayoutManager>(control()); |
|
549 if (!layoutManager) |
|
550 { |
|
551 setDefaultLayoutManager(); |
|
552 } |
|
553 } |
|
554 |
|
555 //--------------------------------------------------------------------------- |
|
556 // Constructs widget using the presentation XML. Other widget parts |
|
557 // are default. |
|
558 //--------------------------------------------------------------------------- |
|
559 // |
|
560 void AlfViewWidget::constructFromPresentationXML(CAlfEnv& aEnv, const char* /**aFilePath*/) |
|
561 { |
|
562 constructDefault(aEnv, true); |
|
563 } |
|
564 |
|
565 // --------------------------------------------------------------------------- |
|
566 // Imperative construction |
|
567 // --------------------------------------------------------------------------- |
|
568 // |
|
569 void AlfViewWidget::constructDefault(CAlfEnv& aEnv, bool aCreateLM) |
|
570 { |
|
571 TRAPD( err, |
|
572 mControlGroup = &aEnv.NewControlGroupL(mControlGroupResourceId); |
|
573 ); |
|
574 |
|
575 if(err != KErrNone) |
|
576 { |
|
577 if (err == KErrAlreadyExists) |
|
578 { |
|
579 ALF_THROW(AlfViewWidgetException, |
|
580 EControlGroupAlreadyExists, "AlfViewWidget::AlfViewWidget() - Tried to create a control group with already existing ID."); |
|
581 } |
|
582 else |
|
583 { |
|
584 ALF_THROW(AlfViewWidgetException, |
|
585 err, "AlfViewWidget::AlfViewWidget() - Control group creation failed."); |
|
586 } |
|
587 } |
|
588 |
|
589 // Create control for the view widget |
|
590 auto_ptr<CAlfViewControl> control( new (EMM) CAlfViewControl(aEnv, *this) ); |
|
591 setControl(control.get()); |
|
592 control.release(); |
|
593 |
|
594 if (aCreateLM) |
|
595 { |
|
596 setDefaultLayoutManager(); |
|
597 } |
|
598 } |
|
599 |
|
600 // --------------------------------------------------------------------------- |
|
601 // Imperative createDefaultLayoutManager |
|
602 // --------------------------------------------------------------------------- |
|
603 // |
|
604 void AlfViewWidget::setDefaultLayoutManager() |
|
605 { |
|
606 // A root layout covering the entire display is created to grab all pointer events in the screen |
|
607 // Note that this layout is just dummy and does not do any actual layouting |
|
608 CAlfControl* ctrl = (CAlfControl*)control(); |
|
609 CAlfLayout* fullDisplayLayout = CAlfLayout::AddNewL(*ctrl); |
|
610 |
|
611 // Default layout manager provided by the view widget |
|
612 auto_ptr<AlfAnchorLayoutManager> layoutManager(new (EMM) AlfAnchorLayoutManager()); |
|
613 this->applyLayout(*layoutManager.get()); |
|
614 |
|
615 layoutManager.release(); |
|
616 } |
|
617 |
|
618 void AlfViewWidget::updateStatusPane() |
|
619 { |
|
620 /*CEikStatusPane *sp = CEikonEnv::Static()->AppUiFactory()->StatusPane(); |
|
621 if(sp) |
|
622 { |
|
623 sp->MakeVisible(mStatusPaneEnabled); |
|
624 // mDisplay->SetVisibleArea(CEikonEnv::Static()->AppUiFactory()->ClientRect()); |
|
625 }*/ |
|
626 } |
|
627 |
|
628 void AlfViewWidget::updateControlPane() |
|
629 { |
|
630 /*CEikButtonGroupContainer* cba= CEikonEnv::Static()->AppUiFactory()->Cba(); |
|
631 if(cba) |
|
632 { |
|
633 cba->MakeVisible(mControlPaneEnabled); |
|
634 // mDisplay->SetVisibleArea(CEikonEnv::Static()->AppUiFactory()->ClientRect()); |
|
635 }*/ |
|
636 |
|
637 } |
|
638 |
|
639 void AlfViewWidget::updateBackGroundImage() |
|
640 { |
|
641 TAknsItemID skinId=KAknsIIDQsnBgScreen; |
|
642 // Do background related stuff only if the view is showing |
|
643 if(mSkinEnabled ) |
|
644 { |
|
645 skinId=mSkinId; |
|
646 } |
|
647 if(mShown) |
|
648 { |
|
649 TAlfDisplayBackgroundItem bgItem(mDisplay->VisibleArea(),skinId); |
|
650 RArray<TAlfDisplayBackgroundItem> bgItemArray; |
|
651 bgItemArray.Append(bgItem); |
|
652 TRAPD(err,mDisplay->SetBackgroundItemsL(bgItemArray)); |
|
653 if(err!=KErrNone) |
|
654 { |
|
655 ALF_THROW(AlfViewWidgetException, err,"Skin Background could not be set"); |
|
656 } |
|
657 bgItemArray.Reset(); |
|
658 } |
|
659 |
|
660 } |
|
661 |
|
662 |
|
663 void AlfViewWidget::HandleActionL(const TAlfActionCommand& aActionCommand) |
|
664 { |
|
665 if(KAlfActionIdDeviceLayoutChanged == aActionCommand.Id()) |
|
666 { |
|
667 TAlfCustomEventCommand command(KAlfActionIdDeviceLayoutChanged); |
|
668 control()->Env().Send(command,0); |
|
669 if(mShown && getViewStackPosition() == 0) |
|
670 { |
|
671 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
672 |
|
673 // SetVisibleArea() only have an effect if the application is on foreground! |
|
674 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
675 } |
|
676 |
|
677 } |
|
678 |
|
679 else if(KAlfActionIdForegroundGained == aActionCommand.Id()) |
|
680 { |
|
681 |
|
682 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
683 |
|
684 // SetVisibleArea() only have an effect if the application is on foreground! |
|
685 |
|
686 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
687 |
|
688 |
|
689 } |
|
690 |
|
691 } |
|
692 |
|
693 TBool AlfViewWidget::OfferEventL(const TAlfEvent& /*aEvent*/) |
|
694 { |
|
695 /* if(aEvent.IsCustomEvent() && aEvent.CustomParameter() == KAlfActionIdDeviceLayoutChanged) |
|
696 { |
|
697 if(mShown && getViewStackPosition() == 0) |
|
698 { |
|
699 //need to do this to overwrite the displayrect done by menuApp |
|
700 // TRect rect= control()->Env().PrimaryDisplay().VisibleArea(); |
|
701 // control()->Env().PrimaryDisplay().SetVisibleArea(mDisplayRect); |
|
702 updateBackGroundImage(); |
|
703 } |
|
704 return ETrue; |
|
705 } |
|
706 */ return EFalse; |
|
707 } |
|
708 |
|
709 void AlfViewWidget::setRect(const TRect& aRect) |
|
710 { |
|
711 mDisplayRect = aRect; |
|
712 |
|
713 IAlfLayoutManager* layoutManager = IAlfInterfaceBase::makeInterface<IAlfLayoutManager>(control()); |
|
714 if (layoutManager) |
|
715 { |
|
716 // Set the area of the root layout of the view widget to the one specified |
|
717 CAlfLayout& layout = layoutManager->getLayout(); |
|
718 layout.SetFlag(EAlfVisualFlagManualLayout); |
|
719 TAlfRealRect rect(mDisplayRect); |
|
720 layout.SetRect(rect); |
|
721 } |
|
722 |
|
723 TRect visibleRect = control()->Env().PrimaryDisplay().VisibleArea(); |
|
724 TRect screenRect(TPoint(0,0), TSize(AlfUtil::ScreenSize())); |
|
725 |
|
726 if(visibleRect != screenRect && getViewStackPosition() == 0) |
|
727 { |
|
728 // the display area is required to be full screen, for the pointer grab to work |
|
729 // check here whether the display area is full screen. If not, set it to full screen |
|
730 control()->Env().PrimaryDisplay().SetVisibleArea(screenRect); |
|
731 } |
|
732 } |
|
733 |
|
734 } //Alf |
|
735 |
|
736 |
|
737 //End of file |
|
738 |
|