emailuis/uicomponents/inc/fscontrolbarvisualiser.h
branchRCL_3
changeset 64 3533d4323edc
equal deleted inserted replaced
63:d189ee25cf9d 64:3533d4323edc
       
     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:  Visualiser class for control bar.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_FSCONTROLBARVISUALISER_H
       
    20 #define C_FSCONTROLBARVISUALISER_H
       
    21 
       
    22 #include <gdi.h>
       
    23 
       
    24 class CAlfDeckLayout;
       
    25 class CAlfVisual;
       
    26 class CAlfLayout;
       
    27 class CAlfTexture;
       
    28 class CAlfFrameBrush;
       
    29 class CAlfImageBrush;
       
    30 class CAlfGradientBrush;
       
    31 class CAlfTexture;
       
    32 class CFsControlBar;
       
    33 class CFsControlBarModel;
       
    34 
       
    35 
       
    36 /**
       
    37  *  Visualiser class of ControlBar component
       
    38  *
       
    39  *  @code
       
    40  *
       
    41  *  @endcode
       
    42  *
       
    43  *  @lib fs_generic.lib
       
    44  */
       
    45 NONSHARABLE_CLASS( CFsControlBarVisualiser ) : public CBase
       
    46     {
       
    47 
       
    48 public:
       
    49 
       
    50     /**
       
    51      * Two-phased constructor.
       
    52      *
       
    53      * @param aParentControl Parent control.
       
    54      * @param aModel Model of control bar.
       
    55      */
       
    56     static CFsControlBarVisualiser* NewL(
       
    57         CFsControlBar& aParentControl, CFsControlBarModel& aModel );
       
    58 
       
    59     /**
       
    60      * Destructor
       
    61      */
       
    62     virtual ~CFsControlBarVisualiser();
       
    63 
       
    64     /**
       
    65      * Starts redrawing of the control bar.
       
    66      *
       
    67      * @param aScreenSizeChanged Screen size changed -> bar's width
       
    68      * has to be recalculated.
       
    69      */
       
    70     void RefreshL( TBool aScreenSizeChanged = EFalse );
       
    71 
       
    72     /**
       
    73      * Sets bar's background color.
       
    74      *
       
    75      * @param aColor Background color to be set.
       
    76      */
       
    77     void SetBackgroundColor( const TRgb& aColor );
       
    78 
       
    79     /**
       
    80      * Clears bar's background color. Bar is transparent.
       
    81      */
       
    82     IMPORT_C virtual void ClearBackgroundColor();
       
    83 
       
    84     /**
       
    85      * Sets bar's image.
       
    86      *
       
    87      * @param aImage Background image to be set.
       
    88      */
       
    89     void SetBackgroundImageL( CAlfTexture& aImage );
       
    90 
       
    91     /**
       
    92      * Clears bar's background image.
       
    93      */
       
    94     void ClearBackgroundImage();
       
    95 
       
    96     /**
       
    97      * Update the size of the controlbar layout.
       
    98      */
       
    99     void UpdateSizeL();
       
   100 
       
   101     /**
       
   102      * Retrieves layouter of the control bar.
       
   103      *
       
   104      * @return Control bar's layouter.
       
   105      */
       
   106     CAlfDeckLayout* Layout();
       
   107 
       
   108     /**
       
   109      * Sets transition time for selector.
       
   110      *
       
   111      * @param aTransitionTime Transition time in miliseconds.
       
   112      */
       
   113     void SetSelectorTransitionTimeL( TInt aTransitionTime );
       
   114 
       
   115     /**
       
   116      * Set selector image.
       
   117      * Gaines the ownership of the brush.
       
   118      *
       
   119      * @param aSelectorBrush New selector brush.
       
   120      * @param aOpacity Opacity of the selector.
       
   121      */
       
   122     void SetSelectorImageL( CAlfBrush* aSelectorBrush, TReal32 aOpacity );
       
   123 
       
   124     /**
       
   125      * Hides selector. Invoked when bar is focused no more.
       
   126      */
       
   127     void HideSelector();
       
   128 
       
   129     /**
       
   130      * Reorder the visuals. Button visual are build from two separate visual,
       
   131      * background and content. Those are arranged so that the background
       
   132      * visual are set at back and contents are to front. Selector visual is
       
   133      * placed between them.
       
   134      */
       
   135     void ReorderVisuals();
       
   136 
       
   137     /**
       
   138      * Enables selector drawing.
       
   139      * NOTE: Do not change focus state. Item might be focused altough
       
   140      *       selector is not visible.
       
   141      *  @param aShow if ETrue selector can be drawn.
       
   142      *  @param aFromTouch tells that was method called after touch event.
       
   143      */
       
   144     void MakeSelectorVisible( TBool aShow, TBool aFromTouch = EFalse );
       
   145 
       
   146 private:
       
   147 
       
   148     /**
       
   149      * Constructor.
       
   150      *
       
   151      * @param aParentControl Parent control.
       
   152      * @param aModel Model of control bar.
       
   153      */
       
   154     CFsControlBarVisualiser( CFsControlBar& aParentControl,
       
   155         CFsControlBarModel& aModel );
       
   156 
       
   157     /**
       
   158      * Second phase constructor.
       
   159      */
       
   160     void ConstructL();
       
   161 
       
   162     /**
       
   163      * Draws selector over selected (focused) button.
       
   164      *
       
   165      * @param aSelectedButtonIndex Index of the button.
       
   166      * @param aFastDraw Updates selector's position without any transition
       
   167      * delay.
       
   168      */
       
   169     void DrawSelectorL( const TInt aSelectedButtonIndex, TBool aFastDraw );
       
   170 
       
   171 private: // data
       
   172 
       
   173     /**
       
   174      * Model of control bar.
       
   175      * Not own.
       
   176      */
       
   177     CFsControlBarModel& iModel;
       
   178 
       
   179     /**
       
   180      * Parent control.
       
   181      * Not own.
       
   182      */
       
   183     CFsControlBar& iParent;
       
   184 
       
   185     /**
       
   186      * Layout for control bar.
       
   187      * Not own.
       
   188      */
       
   189     CAlfDeckLayout* iBarLayout;
       
   190 
       
   191     /**
       
   192      * Background layout for control bar.
       
   193      * Not own.
       
   194      */
       
   195     CAlfLayout* iBgLayout;
       
   196 
       
   197     /**
       
   198      * Background color.
       
   199      */
       
   200     CAlfGradientBrush* iBgColor;
       
   201 
       
   202     /**
       
   203      * Brush with the default background image.
       
   204      * Owned.
       
   205      */
       
   206     CAlfFrameBrush* iDefaultBgBrush;
       
   207 
       
   208     /**
       
   209      * Brush with the background image.
       
   210      * Owned.
       
   211      */
       
   212     CAlfImageBrush* iBgImage;
       
   213 
       
   214     /**
       
   215      * Visual for image of selector.
       
   216      * Not own.
       
   217      */
       
   218     CAlfVisual* iSelector;
       
   219 
       
   220     /**
       
   221      * Brush for selector.
       
   222      * Owned.
       
   223      */
       
   224     CAlfBrush* iSelectorBrush;
       
   225 
       
   226     /**
       
   227      * Selector's opacity.
       
   228      */
       
   229     TReal32 iSelectorOpacity;
       
   230 
       
   231     /**
       
   232      * Index of last selected button.
       
   233      */
       
   234     TInt iLastSelectedButton;
       
   235 
       
   236     /**
       
   237      * Flag that states if event was received after touch event.
       
   238      */
       
   239     TBool iTouchPressed;
       
   240     };
       
   241 
       
   242 
       
   243 #endif // C_FSCONTROLBARVISUALISER_H