2 * Copyright (c) 2002-2008 Nokia Corporation and/or its subsidiary(-ies).
4 * This component and the accompanying materials are made available
5 * under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
6 * which accompanies this distribution, and is available
7 * at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
9 * Initial Contributors:
10 * Nokia Corporation - initial contribution.
14 * Description: Decorator class for navigation pane controls.
15 * The class, for example, decorates navigation pane controls
24 #include <akncontrol.h>
28 #include <aknnaviobserver.h>
31 class CEikScrollButton;
33 class MAknNaviDecoratorObserver;
34 class CAknNavigationDecoratorExtension;
37 * Decorator class for navigation pane controls.
38 * The class, for example, decorates navigation pane controls with navi arrows.
40 class CAknNavigationDecorator : public CAknControl,
41 public MCoeControlObserver,
42 public MAknNavigationDecoratorInterface
45 friend class CAknNavigationControlContainer;
50 * Defines scroll buttons.
62 * Defines type of the decorated control.
66 /** Type not specified. */
91 * Creates a new navigation decorator. The object takes ownership of the
92 * decorated object at the beginning of the method before any leaving
95 * @param aNavigationControlContainer Container control.
96 * @param aDecoratedControl Control to be decorated.
97 * @param aType = @c ENotSpecified Control type.
98 * @return Navigation Decorator object that
99 * contains decorated object.
101 IMPORT_C static CAknNavigationDecorator* NewL(
102 CAknNavigationControlContainer* aNavigationControlContainer,
103 CCoeControl* aDecoratedControl,
104 TControlType aType = ENotSpecified);
109 IMPORT_C ~CAknNavigationDecorator();
112 * Returns the control inside a navigation decorator object. Ownership of
113 * the control is not changed.
115 * @return Control that is decorated with the decorator.
117 IMPORT_C CCoeControl* DecoratedControl();
120 * Shows or hides the navigation arrows at the both ends of the navigation
121 * pane when current object is shown.
123 * @param aVisible Boolean value if navigation arrows are shown with the
124 * decorated control. Visible if @c ETrue.
126 IMPORT_C void MakeScrollButtonVisible(TBool aVisible);
129 * Gets the State of the visibility of navigation arrows.
131 * @return @c ETrue if visible.
133 IMPORT_C TBool ScrollButtonVisible() const;
136 * Sets the navigation arrow dimmed (and highlighted). Arrows have to be
137 * visible so that the dimmed arrow is shown on the screen.
139 * @param aButton Navigation arrow to be set (@c ELeftButton or
141 * @param aDimmed @c ETrue is the button is dimmed, @c EFalse if the button
142 * is set highlighted.
144 IMPORT_C void SetScrollButtonDimmed(TScrollButton aButton, TBool aDimmed);
147 * Is button dimmed or highlighted.
149 * @param aButton Navigation arrow.
150 * @return @c ETrue If the navigation arrow is dimmed, @c EFalse if
153 IMPORT_C TBool IsScrollButtonDimmed(TScrollButton aButton) const;
156 * Sets the type of the decorated control.
158 * @param aType Type of the control.
160 IMPORT_C void SetControlType(TControlType aType);
163 * Returns the type of the decorated control.
165 * @return Control type.
167 IMPORT_C TControlType ControlType() const;
170 * Sets observer for navigation decorator events in the decorated control.
172 * @param aObserver Pointer to observer.
174 IMPORT_C virtual void SetNaviDecoratorObserver(
175 MAknNaviDecoratorObserver* aObserver);
178 * Sets the pointer to the default navigation pane control.
180 * @param aContainer Pointer to default control in navigation pane.
182 void SetNaviStack(CAknNavigationControlContainer* aContainer);
185 * From @c CCoeControl.
187 * Handle pointer events.
189 * @param aPointerEvent Pointer event to be handled.
191 IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
194 * Defines the navigation control layout style.
196 enum TAknNaviControlLayoutStyle
198 /** Normal layout style. */
199 ENaviControlLayoutNormal = 0x1,
201 /** Narrow layout style. */
202 ENaviControlLayoutNarrow = 0x2,
205 * Wide layout style, can be used only in portrait mode, in
206 * usual status pane layout (@c R_AVKON_STATUS_PANE_LAYOUT_USUAL_EXT).
208 * Tabs are not currently supported in wide layout style.
210 ENaviControlLayoutWide = 0x4
214 * Defines the navigation control layout mode.
216 enum TAknNaviControlLayoutMode
219 * This is the default layout mode. It lets UI framework to decide the
220 * proper layout style which is applied to decorated controls in all
223 ENaviControlLayoutModeAutomatic = 0x400,
226 * @c ENaviControlLayoutModeForced layout mode can be used to lock
227 * the layout style to the current style.
229 ENaviControlLayoutModeForced = 0x800
234 * Sets the layout style for this objects decorated control. The layout
235 * style can be normal or narrow style.
237 * The style is really applied if the decorated control supports it or if
238 * the layout mode has been set to forced mode
239 * (@c ENaviControlLayoutModeForced). Additionally narrow mode may not be
240 * supported at all in some statuspane configurations (even if forced).
242 * Whether decorated control supports or does not support given style at the
243 * currently active statuspane layout can be queried using
244 * @c NaviControlLayoutStyleSupported() method.
247 * @param aStyle Can be normal (@c ENaviControlLayoutNormal),
248 * narrow (@c ENaviControlLayoutNarrow) or
249 * wide (@c ENaviControlLayoutWide).
252 IMPORT_C void SetNaviControlLayoutStyle(TAknNaviControlLayoutStyle aStyle);
255 * Gets the current layout style of this objects decorated control
256 * (@c ENaviControlLayoutNormalm @c ENaviControlLayoutNarrow or
257 * @c ENaviControlLayoutWide).
260 * @return Current layout style of the navicontrol
262 IMPORT_C TAknNaviControlLayoutStyle NaviControlLayoutStyle();
265 * Tells if decorated control supports given layout style at the current
266 * statuspane layout. For @c ENotSpecified type of controls this always
267 * returns @c EFalse (just for safety) because their implementation is
271 * @param aStyle The layout style.
272 * @return @c ETrue if the control supports given layout style
273 * otherwise returns @c EFalse.
275 IMPORT_C TBool NaviControlLayoutStyleSupported(TAknNaviControlLayoutStyle
279 * Sets the layout mode @c ENaviControlLayoutModeAutomatic or
280 * @c ENaviControlLayoutModeForced. See @c TAknNaviControlLayoutMode
281 * for more information.
284 * @param aMode New layout mode.
287 IMPORT_C void SetNaviControlLayoutMode(TAknNaviControlLayoutMode aMode);
290 * Gets the current layout mode of decorated control. Can be
291 * @c ENaviControlLayoutModeAutomatic (default) or
292 * @c ENaviControlLayoutModeForced (usually set by the application).
295 * @return Decorated control's current layout
299 IMPORT_C TAknNaviControlLayoutMode NaviControlLayoutMode();
302 protected: // from CCoeControl
305 * From @c CCoeControl.
307 * Handles the size change events.
309 IMPORT_C virtual void SizeChanged();
312 * From @c CCoeControl.
314 * Returns the number of controls inside the context pane control.
316 * @return Number of controls.
318 IMPORT_C virtual TInt CountComponentControls() const;
321 * From @c CCoeControl.
323 * Returns a control determined by control id.
325 * @param aIndex Index of a control to be returned.
326 * @return Pointer to the control.
328 IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
330 public: // from CCoeControl
332 * Handles a change to the control's resources of type aType
333 * which are shared across the environment, e.g. color scheme change.
334 * @param aType Event type.
336 IMPORT_C virtual void HandleResourceChange(TInt aType);
338 protected: // from MCoeControlObserver
341 * From @c MCoeControlObserver.
343 * Handles an event from an observed control.
345 * @param aControl Control that caused the event.
346 * @param aEventType Type of the event.
348 IMPORT_C void HandleControlEventL(CCoeControl* aControl,
349 TCoeEvent aEventType);
356 IMPORT_C void* ExtensionInterface( TUid aInterface );
361 * Private constructor.
363 IMPORT_C void ConstructL();
370 IMPORT_C virtual void Draw(const TRect& aRect) const;
373 * Gets parent rect of this control. Used for layout calculation purposes.
380 * Gets the default rectangle of the given control type.
382 * @param aControlType The control type from which default rectangle is
384 * @param aArrowsUsed Whether or not the navigation arrows are used
385 * for the control. This is only used for the
386 * tab group control. If arrows are not used with
387 * tab group, then the whole navi pane area
388 * is provided to the tab group control.
390 * @return Rectangle which tells the default area for given
391 * controltype. Coordinates are relative to navi pane.
393 static TRect DecoratedControlRect( TInt aControlType,
394 TBool aArrowsUsed = ETrue );
397 * Gets the default rectangle of the navigation pane's default control.
399 * @param aControlType Not used.
400 * @return Rectangle of the navigation pane's default control.
402 static TRect DecoratedControlNarrowRect( TInt aControlType );
407 * Gets the default rect of default controltype relative to navipane in
408 * normal layoutstyle (@c ENaviControlLayoutNormal)
410 * @return Rectangle which is tells the default area for a navi control.
411 * Coordinates are relative to navipane.
414 static TRect DecoratedDefaultControlRect();
419 * Gets the default rect of tab group control type relative to navipane in
420 * normal (@c ENaviControlLayoutNormal) or wide (@c ENaviControlLayoutWide)
423 * @param aTopAdjacent @c ETrue to return a rectangle adjacent to the
424 * top of navi pane, @c EFalse for a rectangle
425 * adjacent to the bottom of navi pane.
426 * @param aArrowsUsed Whether or not the navigation arrows are used
427 * for the tab group. If arrows are not used, then
428 * the whole navi pane area is provided to the tab
431 * @return Rectangle which tells the default area for a tab group.
433 static TRect DecoratedTabControlRect( TBool aTopAdjacent,
439 * Gets the default rect of volume controltype relative to navipane in
440 * normal layoutstyle (@c ENaviControlLayoutNormal)
442 * @return Rectangle which is tells the default area for a volume control.
443 * Coordinates are relative to navipane.
446 static TRect DecoratedVolumeControlRect();
449 * This method handles sizechanges in normal layout style.
451 void SizeChangedInNormalLayout();
454 * This method handles sizechanges in narrow layout style.
456 void SizeChangedInNarrowLayout();
459 * This method handles sizechanges in wide layout style.
461 void SizeChangedInWideLayout();
464 * This method initializes timer that is used for times layout style
467 void InitLayoutStyleTimer();
470 * This method cancels timer that is used for times layout style changes.
472 void CancelLayoutStyleTimer();
475 * This method is executed when timer that is used for times layout style
478 static TInt LayoutStyleEvent(TAny * aPtr);
481 * This method is executed when timer that is used for times layout style
484 void DoLayoutStyleEvent();
488 void SmallDirectionIndicationL();
490 static TInt IndicationDrawCallbackL( TAny* aThis );
493 * This method cancels the timer that is used in the small direction
494 * indication animation.
499 * Gets the rectangle for a navigation arrow.
501 * @param aScrollButton @c ELeftButton to return the rectangle
502 * of the left navi arrow,
503 * @c ERightButton for right navi arrow.
505 * @param aNarrowLayout @c ETrue to get a navi arrow rectangle
506 * for a narrow decorator layout,
507 * @c EFalse otherwise.
509 * @param aNaviRect Navi pane rectangle to be used as parent,
510 * the returned rectangle is relative to this.
511 * If not defined, then relative to the
512 * default navi pane area.
514 * @return Navigation arrow rectangle.
515 * Coordinates are relative to navipane.
518 static TRect NaviArrowRect( TScrollButton aScrollButton,
519 TBool aNarrowLayout = EFalse,
520 TRect aNaviRect = TRect( 0,0,0,0 ) );
528 CCoeControl* iDecoratedControl;
531 * Navigation pane default control.
533 CAknNavigationControlContainer* iContainer;
536 * Observer for handling decorator events.
538 MAknNaviDecoratorObserver* iNaviDecoratorObserver;
541 TBool iNaviArrowsVisible;
542 TBool iNaviArrowLeftDimmed;
543 TBool iNaviArrowRightDimmed;
544 TControlType iControlType;
545 TPoint iArrowLeftPos;
546 TSize iArrowLeftSize;
547 TPoint iArrowRightPos;
548 TSize iArrowRightSize;
551 CPeriodic* iLayoutStyleTimer;
553 CAknNavigationDecoratorExtension* iExtension;
558 #endif // C_AKNNAVIDE_H