|
1 /* |
|
2 * Copyright (c) 2007-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 * Description: Widget Implementation |
|
15 * |
|
16 */ |
|
17 |
|
18 // Include Files |
|
19 #include <alf/alfenv.h> |
|
20 #include <alf/alfwidgetenvextension.h> |
|
21 |
|
22 // Class headers |
|
23 #include "mulcoverflowwidget.h" |
|
24 |
|
25 // Mul Headers |
|
26 #include "imulmodelaccessor.h" |
|
27 #include "mulassert.h" |
|
28 #include "mullog.h" //for logs |
|
29 #include <mul/imulsliderwidget.h> |
|
30 |
|
31 // Local Headers |
|
32 #include "mulbaseelement.h" |
|
33 #include "mulcoverflowcontrol.h" |
|
34 |
|
35 namespace Alf |
|
36 { |
|
37 |
|
38 // --------------------------------------------------------------------------- |
|
39 // MulCoverFlowWidget |
|
40 // --------------------------------------------------------------------------- |
|
41 // |
|
42 MulCoverFlowWidget::MulCoverFlowWidget( CAlfEnv& aEnv, |
|
43 const char* aWidgetId, IAlfContainerWidget& aContainerWidget):AlfWidget(aWidgetId,aContainerWidget,aEnv) |
|
44 { |
|
45 mMulModelAccessor = NULL; |
|
46 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::MulCoverFlowWidget"); |
|
47 mWidgetPropertyFlag = 0; //Initialization |
|
48 |
|
49 //Create default control |
|
50 mCoverflowControl = new (EMM) MulCoverFlowControl( aEnv ); |
|
51 setControl( mCoverflowControl,true ); |
|
52 |
|
53 // create Base element |
|
54 mBaseElement = new (EMM) MulBaseElement( *mCoverflowControl, KBase ); |
|
55 mTakesModelOwnership = false; |
|
56 |
|
57 } |
|
58 |
|
59 // --------------------------------------------------------------------------- |
|
60 // ~MulCoverFlowWidget |
|
61 // --------------------------------------------------------------------------- |
|
62 // |
|
63 MulCoverFlowWidget::~MulCoverFlowWidget() |
|
64 { |
|
65 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::~MulCoverFlowWidget"); |
|
66 // Control will be destroyed in the Widget deletion sequence. In that sequence |
|
67 // Control's owner widget will be set to NULL. So,We cannot access the widget in |
|
68 // the Coverflow control's destructor. So,This will be the right place to remove the |
|
69 // model Observer. |
|
70 |
|
71 if( control() && model()) |
|
72 { |
|
73 ((IMulModelAccessor*)model())->RemoveModelObserver(static_cast<MulCoverFlowControl*>( control())); |
|
74 } |
|
75 if (mMulModelAccessor && mTakesModelOwnership) |
|
76 { |
|
77 delete mMulModelAccessor; |
|
78 } |
|
79 |
|
80 IAlfWidgetFactory& widgetFactory = AlfWidgetEnvExtension::widgetFactory(*(CAlfEnv::Static())); |
|
81 IAlfWidget* sliderWidget = widgetFactory.findWidget( KNameSliderWidget ); |
|
82 |
|
83 if(control()) |
|
84 { |
|
85 (static_cast<MulCoverFlowControl*>(control()))->DestroySlider(); |
|
86 } |
|
87 |
|
88 if(sliderWidget) |
|
89 { |
|
90 widgetFactory.destroyWidget(sliderWidget); |
|
91 } |
|
92 } |
|
93 |
|
94 // --------------------------------------------------------------------------- |
|
95 // parent |
|
96 // --------------------------------------------------------------------------- |
|
97 // |
|
98 IAlfContainerWidget* MulCoverFlowWidget::parent() const |
|
99 { |
|
100 return AlfWidget::parent (); //return container widget |
|
101 } |
|
102 |
|
103 // --------------------------------------------------------------------------- |
|
104 // control |
|
105 // --------------------------------------------------------------------------- |
|
106 // |
|
107 CAlfWidgetControl* MulCoverFlowWidget::control() const |
|
108 { |
|
109 //Call the base class method |
|
110 return AlfWidget::control(); |
|
111 } |
|
112 |
|
113 // --------------------------------------------------------------------------- |
|
114 // setControl |
|
115 // --------------------------------------------------------------------------- |
|
116 // |
|
117 void MulCoverFlowWidget::setControl( CAlfWidgetControl* aControl,bool aDeletePreviousControl ) |
|
118 { |
|
119 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::setControl"); |
|
120 AlfWidget::setControl( aControl,aDeletePreviousControl ); |
|
121 } |
|
122 |
|
123 // --------------------------------------------------------------------------- |
|
124 // model |
|
125 // --------------------------------------------------------------------------- |
|
126 // |
|
127 IAlfModel* MulCoverFlowWidget::model() |
|
128 { |
|
129 return mMulModelAccessor; |
|
130 } |
|
131 |
|
132 // --------------------------------------------------------------------------- |
|
133 // setModel |
|
134 // --------------------------------------------------------------------------- |
|
135 // |
|
136 void MulCoverFlowWidget::setModel( IAlfModel* /*aModel*/ , bool /*aTakeOwnership*/ ) |
|
137 { |
|
138 } |
|
139 |
|
140 // --------------------------------------------------------------------------- |
|
141 // widgetName |
|
142 // --------------------------------------------------------------------------- |
|
143 // |
|
144 const char* MulCoverFlowWidget::widgetName() const |
|
145 { |
|
146 return AlfWidget::widgetName(); |
|
147 } |
|
148 |
|
149 |
|
150 // --------------------------------------------------------------------------- |
|
151 // SetBackground |
|
152 // --------------------------------------------------------------------------- |
|
153 // |
|
154 void MulCoverFlowWidget::SetBackground(const TRgb& aColor) |
|
155 { |
|
156 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetBackground"); |
|
157 |
|
158 mBaseElement->SetBackground( aColor ); |
|
159 } |
|
160 |
|
161 // --------------------------------------------------------------------------- |
|
162 // SetBackground |
|
163 // --------------------------------------------------------------------------- |
|
164 // |
|
165 void MulCoverFlowWidget::SetBackground(const TAknsItemID& aItemID) |
|
166 { |
|
167 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetBackground"); |
|
168 |
|
169 mBaseElement->SetBackground( aItemID ); |
|
170 } |
|
171 // --------------------------------------------------------------------------- |
|
172 // SetFlags |
|
173 // --------------------------------------------------------------------------- |
|
174 // |
|
175 void MulCoverFlowWidget::SetFlags( unsigned int aAnyFlag ) |
|
176 { |
|
177 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetFlags"); |
|
178 mWidgetPropertyFlag |= aAnyFlag; |
|
179 |
|
180 // When the IMulMultiItemWidget::EMulWidgetFlagFastScroll flag is modified we should |
|
181 // set the enable holding flag to gesture helper to recieve the hold events. |
|
182 if(aAnyFlag == IMulMultiItemWidget::EMulWidgetFlagFastScroll) |
|
183 { |
|
184 mCoverflowControl->SetHoldingEnabled(); |
|
185 } |
|
186 else if(aAnyFlag == IMulMultiItemWidget::EMulWidgetDoubleTap) |
|
187 { |
|
188 mCoverflowControl->SetDoubleTapEnabled(true); |
|
189 } |
|
190 } |
|
191 |
|
192 // --------------------------------------------------------------------------- |
|
193 // ClearFlags |
|
194 // --------------------------------------------------------------------------- |
|
195 // |
|
196 void MulCoverFlowWidget::ClearFlags( unsigned int aAnyFlag ) |
|
197 { |
|
198 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::ClearFlags"); |
|
199 mWidgetPropertyFlag &= ~aAnyFlag; |
|
200 if(aAnyFlag == IMulMultiItemWidget::EMulWidgetDoubleTap) |
|
201 { |
|
202 mCoverflowControl->SetDoubleTapEnabled(false); |
|
203 } |
|
204 else if(aAnyFlag == IMulMultiItemWidget::EMulWidgetFlagFastScroll) |
|
205 { |
|
206 mCoverflowControl->SetHoldingEnabled(); |
|
207 } |
|
208 } |
|
209 |
|
210 // --------------------------------------------------------------------------- |
|
211 // IsFlagSet |
|
212 // --------------------------------------------------------------------------- |
|
213 // |
|
214 bool MulCoverFlowWidget::IsFlagSet( TMulWidgetPropertiesFlag aAnyFlag ) const |
|
215 { |
|
216 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::IsFlagSet"); |
|
217 |
|
218 return (mWidgetPropertyFlag & aAnyFlag); |
|
219 |
|
220 } |
|
221 |
|
222 // --------------------------------------------------------------------------- |
|
223 // GetFlags |
|
224 // --------------------------------------------------------------------------- |
|
225 // |
|
226 unsigned int MulCoverFlowWidget::GetFlags() const |
|
227 { |
|
228 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::GetFlags"); |
|
229 return mWidgetPropertyFlag; |
|
230 } |
|
231 |
|
232 // --------------------------------------------------------------------------- |
|
233 // SetRect |
|
234 // --------------------------------------------------------------------------- |
|
235 // |
|
236 void MulCoverFlowWidget::SetRect( int /*aLeftMargin*/, int /*aTopmargin*/, int /*aHeight*/, |
|
237 int /*aWidth*/, int /*aTransitionTime*/ ) |
|
238 { |
|
239 //@todo need to be removed once its removed from imulwidget. |
|
240 } |
|
241 // --------------------------------------------------------------------------- |
|
242 // ShowWidget |
|
243 // --------------------------------------------------------------------------- |
|
244 // |
|
245 void MulCoverFlowWidget::ShowWidget( bool aShow, int aTransitionTime ) |
|
246 { |
|
247 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::ShowWidget"); |
|
248 mBaseElement->ShowWidget( aShow,aTransitionTime ); |
|
249 |
|
250 // Reset the flag . Event handling gets disabled once the flag is reset to false. |
|
251 mCoverflowControl->ResetShowWidgetFlag( aShow ); |
|
252 } |
|
253 |
|
254 // --------------------------------------------------------------------------- |
|
255 // SetModel |
|
256 // --------------------------------------------------------------------------- |
|
257 // |
|
258 void MulCoverFlowWidget::SetModel( IMulModelAccessor* aAccessor, bool aFlag ) |
|
259 { |
|
260 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetModel"); |
|
261 |
|
262 //remove from observing change from old model |
|
263 if ( mMulModelAccessor != aAccessor ) |
|
264 { |
|
265 if (mMulModelAccessor && control()) |
|
266 { |
|
267 ((IMulModelAccessor*)model())->RemoveModelObserver(static_cast<MulCoverFlowControl*>( control())); |
|
268 } |
|
269 // Release the old model. |
|
270 if (mTakesModelOwnership) |
|
271 { |
|
272 delete mMulModelAccessor; |
|
273 } |
|
274 // Set the new model. |
|
275 mMulModelAccessor = aAccessor; |
|
276 mTakesModelOwnership=aFlag; |
|
277 } |
|
278 else // just copy the ownership flag |
|
279 { |
|
280 if (mMulModelAccessor != NULL) |
|
281 { |
|
282 mTakesModelOwnership=aFlag; |
|
283 } |
|
284 } |
|
285 |
|
286 IMulSliderWidget* sliderWidget = static_cast<IMulSliderWidget*>(mCoverflowControl->GetSliderWidget()); |
|
287 // cancel all previous commands (like marquee and bounce) |
|
288 mCoverflowControl->Env().CancelCustomCommands(mCoverflowControl); |
|
289 |
|
290 if( aAccessor ) |
|
291 { |
|
292 mMulModelAccessor = aAccessor; |
|
293 MUL_LOG_INFO("MUL::MulCoverFlowWidget::SetModel()::SetVisibleWindow "); |
|
294 aAccessor->AddModelObserver(mCoverflowControl); |
|
295 // Notify the control regarding model change. |
|
296 mCoverflowControl->ModelChanged(aAccessor); |
|
297 |
|
298 if( aAccessor->CurrentItemCount() <= 0 ) |
|
299 { |
|
300 if(sliderWidget) |
|
301 { |
|
302 mBaseElement->ShowSlider(false); |
|
303 } |
|
304 } |
|
305 } |
|
306 else // For Null Model case |
|
307 { |
|
308 mCoverflowControl->RecycleVisuals(); |
|
309 mBaseElement->ShowEmptyText( true ); |
|
310 |
|
311 if( sliderWidget ) |
|
312 { |
|
313 mBaseElement->ShowSlider(false); |
|
314 } |
|
315 } |
|
316 } |
|
317 |
|
318 // --------------------------------------------------------------------------- |
|
319 // GetIconSize |
|
320 // --------------------------------------------------------------------------- |
|
321 // |
|
322 void MulCoverFlowWidget::GetIconSize( mulwidget::TLogicalTemplate aTemplateId, |
|
323 mulvisualitem::TVisualAttribute aAttribute, int& aHeight, int& aWidth) |
|
324 { |
|
325 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::GetIconSize"); |
|
326 if((aAttribute == mulvisualitem::KMulIcon1) || |
|
327 (aAttribute == mulvisualitem::KMulIndicator2)) |
|
328 { |
|
329 mBaseElement->GetIconSize(aTemplateId,aAttribute,aHeight,aWidth); |
|
330 } |
|
331 else |
|
332 { |
|
333 __MUL_ASSERT( false,KInvalidArgument); |
|
334 } |
|
335 } |
|
336 |
|
337 // --------------------------------------------------------------------------- |
|
338 // GetIconSize |
|
339 // --------------------------------------------------------------------------- |
|
340 // |
|
341 void MulCoverFlowWidget::GetIconSize(mulvisualitem::TVisualAttribute aAttribute, |
|
342 int& aHeight, int& aWidth) |
|
343 { |
|
344 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::GetIconSize"); |
|
345 __MUL_ASSERT( mMulModelAccessor != 0,KTemplateNotFound); |
|
346 if((aAttribute == mulvisualitem::KMulIcon1) || |
|
347 (aAttribute == mulvisualitem::KMulIndicator2)) |
|
348 { |
|
349 mBaseElement->GetIconSize(mMulModelAccessor->Template(),aAttribute, |
|
350 aHeight,aWidth); |
|
351 } |
|
352 else |
|
353 { |
|
354 __MUL_ASSERT( false,KInvalidArgument); |
|
355 } |
|
356 } |
|
357 |
|
358 // --------------------------------------------------------------------------- |
|
359 // makeInterface |
|
360 // --------------------------------------------------------------------------- |
|
361 // |
|
362 IAlfInterfaceBase* MulCoverFlowWidget::makeInterface( const IfId& /*aType*/ ) |
|
363 { |
|
364 return static_cast<IMulCoverFlowWidget*>( this ); |
|
365 } |
|
366 |
|
367 // --------------------------------------------------------------------------- |
|
368 // setChildFocus |
|
369 // --------------------------------------------------------------------------- |
|
370 // |
|
371 void MulCoverFlowWidget::setChildFocus( bool /*aFocus*/ ) |
|
372 { |
|
373 // pure virtual function of base Class. |
|
374 // not usefull for this widget |
|
375 } |
|
376 |
|
377 void MulCoverFlowWidget::setPresentation(const char* /*aFilePath*/) |
|
378 { |
|
379 // pure virtual function of base Class. |
|
380 // not usefull for this widget |
|
381 } |
|
382 |
|
383 // --------------------------------------------------------------------------- |
|
384 // AddEventHandler |
|
385 // --------------------------------------------------------------------------- |
|
386 // |
|
387 void MulCoverFlowWidget::AddEventHandler( IAlfWidgetEventHandler& aObserver ) |
|
388 { |
|
389 control()->addEventHandler( &aObserver ); |
|
390 } |
|
391 |
|
392 // --------------------------------------------------------------------------- |
|
393 // RemoveEventHandler |
|
394 // --------------------------------------------------------------------------- |
|
395 // |
|
396 void MulCoverFlowWidget::RemoveEventHandler( IAlfWidgetEventHandler& aObserver ) |
|
397 { |
|
398 control()->removeEventHandler( aObserver ); |
|
399 } |
|
400 // --------------------------------------------------------------------------- |
|
401 // ContainerLayout |
|
402 // --------------------------------------------------------------------------- |
|
403 // |
|
404 const CAlfLayout& MulCoverFlowWidget::ContainerLayout() |
|
405 { |
|
406 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::ContainerLayout"); |
|
407 CAlfLayout* layout=(CAlfLayout*)mBaseElement->findVisual(0); |
|
408 return *layout; |
|
409 } |
|
410 // --------------------------------------------------------------------------- |
|
411 // SetEmptyText |
|
412 // --------------------------------------------------------------------------- |
|
413 // |
|
414 void MulCoverFlowWidget::SetEmptyText( const UString& aDefaultText) |
|
415 { |
|
416 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetEmptyText"); |
|
417 mBaseElement->SetEmptyText(aDefaultText); |
|
418 } |
|
419 |
|
420 // --------------------------------------------------------------------------- |
|
421 // SetMarkMode |
|
422 // --------------------------------------------------------------------------- |
|
423 // |
|
424 void MulCoverFlowWidget::SetMarkMode(bool /*aFlag*/) |
|
425 { |
|
426 // Marking mode is not supported by coverflow widget. |
|
427 } |
|
428 |
|
429 // --------------------------------------------------------------------------- |
|
430 // IsMarkMode |
|
431 // --------------------------------------------------------------------------- |
|
432 // |
|
433 bool MulCoverFlowWidget::IsMarkMode()const |
|
434 { |
|
435 // Marking mode is not supported by coverflow widget. |
|
436 return false; |
|
437 } |
|
438 |
|
439 // --------------------------------------------------------------------------- |
|
440 // SetReorderMode |
|
441 // --------------------------------------------------------------------------- |
|
442 // |
|
443 void MulCoverFlowWidget::SetReorderMode(TMulReOrderMode /*aReorderMode*/) |
|
444 { |
|
445 // reorder mode is not supported by coverflow widget. |
|
446 } |
|
447 |
|
448 // --------------------------------------------------------------------------- |
|
449 // IsReorderMode |
|
450 // --------------------------------------------------------------------------- |
|
451 // |
|
452 bool MulCoverFlowWidget::IsReorderModeOn() const |
|
453 { |
|
454 // reorder mode is not supported by coverflow widget. |
|
455 return false; |
|
456 } |
|
457 |
|
458 // --------------------------------------------------------------------------- |
|
459 // SetOverlay |
|
460 // --------------------------------------------------------------------------- |
|
461 // |
|
462 void MulCoverFlowWidget::SetOverlay(TMulAttributeDataType /*aType*/, const UString& /*aAttribute*/, |
|
463 const UString& /*aFormat*/) |
|
464 { |
|
465 // No implementation . |
|
466 } |
|
467 |
|
468 // --------------------------------------------------------------------------- |
|
469 // SetAnimationTime |
|
470 // --------------------------------------------------------------------------- |
|
471 // |
|
472 void MulCoverFlowWidget::SetAnimationTime( TMulVisualEffect aVisualEffect, int aTransitionTime ) |
|
473 { |
|
474 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetAnimationTime"); |
|
475 // EHighlightTransition is used to set coverflow step scroll animation time. |
|
476 if( aVisualEffect == EHighlightTransition ) |
|
477 { |
|
478 mBaseElement->SetScrollAnimationTime(aTransitionTime); |
|
479 } |
|
480 } |
|
481 // --------------------------------------------------------------------------- |
|
482 // SetUIOnOFF |
|
483 // --------------------------------------------------------------------------- |
|
484 // |
|
485 void MulCoverFlowWidget::SetUIMode(bool UIOn, int aTransition ) |
|
486 { |
|
487 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetUIMode"); |
|
488 mBaseElement->UIOnOffMode( UIOn,aTransition ); |
|
489 } |
|
490 |
|
491 // --------------------------------------------------------------------------- |
|
492 // SetVisualColor |
|
493 // --------------------------------------------------------------------------- |
|
494 // |
|
495 void MulCoverFlowWidget::SetVisualColor( TMulVisualType aVisualType , const TRgb& aColor ) |
|
496 { |
|
497 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetVisualColor"); |
|
498 switch(aVisualType) |
|
499 { |
|
500 case EItemBackgroundBrush: |
|
501 { |
|
502 mBaseElement->SetItemBrush(aColor); |
|
503 } |
|
504 break; |
|
505 case ECoverflowCounterVisual: |
|
506 { |
|
507 mBaseElement->SetTextColor(ECounterVisual,aColor); |
|
508 } |
|
509 break; |
|
510 case ETextVisual: |
|
511 { |
|
512 mBaseElement->SetTextColor(ETilteDetailTextVisual,aColor); |
|
513 } |
|
514 break; |
|
515 default: |
|
516 break; |
|
517 |
|
518 } |
|
519 } |
|
520 |
|
521 // --------------------------------------------------------------------------- |
|
522 // SetDefaultImage |
|
523 // --------------------------------------------------------------------------- |
|
524 // |
|
525 void MulCoverFlowWidget::SetDefaultImage(int aTextureId) |
|
526 { |
|
527 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::SetDefaultImage"); |
|
528 mCoverflowControl->SetDefaultImage(aTextureId); |
|
529 } |
|
530 |
|
531 // --------------------------------------------------------------------------- |
|
532 // RotateImage |
|
533 // --------------------------------------------------------------------------- |
|
534 // |
|
535 void MulCoverFlowWidget::RotateImage(TMulRotation aDirection,TSize aImageSize,int aAnimationTime) |
|
536 { |
|
537 MUL_LOG_ENTRY_EXIT("aakash::MulCoverFlowWidget::RotateImage"); |
|
538 mBaseElement->RotateImage(aDirection,aImageSize,aAnimationTime); |
|
539 } |
|
540 |
|
541 // --------------------------------------------------------------------------- |
|
542 // Gesturehelper |
|
543 // --------------------------------------------------------------------------- |
|
544 // |
|
545 GestureHelper::CGestureHelper* MulCoverFlowWidget::Gesturehelper() |
|
546 { |
|
547 return mCoverflowControl->Gesturehelper(); |
|
548 } |
|
549 |
|
550 } //namespace alf |
|
551 |
|
552 //End of File |