emailuis/uicomponents/inc/fscontrolbarmodel.h
branchRCL_3
changeset 25 3533d4323edc
equal deleted inserted replaced
24:d189ee25cf9d 25: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:  Model class for control bar.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_FSCONTROLBARMODEL_H
       
    20 #define C_FSCONTROLBARMODEL_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <e32cmn.h>
       
    24 #include <gdi.h>
       
    25 
       
    26 class CFsControlButton;
       
    27 class CHuiTexture;
       
    28 
       
    29 /**
       
    30  *  Model class of ControlBar component
       
    31  *
       
    32  *  @code
       
    33  *  @endcode
       
    34  *
       
    35  *  @lib fs_generic.lib
       
    36  */
       
    37 NONSHARABLE_CLASS( CFsControlBarModel ) : public CBase
       
    38     {
       
    39 
       
    40 public:
       
    41 
       
    42     /**
       
    43      * Two-phased constructor.
       
    44      */
       
    45     static CFsControlBarModel* NewL();
       
    46 
       
    47     /**
       
    48      * Two-phased constructor.
       
    49      */
       
    50     static CFsControlBarModel* NewLC();
       
    51 
       
    52     /**
       
    53      * Destructor
       
    54      */
       
    55     virtual ~CFsControlBarModel();
       
    56 
       
    57     /**
       
    58      * Adds button to model.
       
    59      *
       
    60      * @param aButton Button to be added.
       
    61      */
       
    62     void AddButtonL( CFsControlButton& aButton );
       
    63 
       
    64     /**
       
    65      * Retrieves button with specified index from model.
       
    66      *
       
    67      * @param aIndex Index of the button to be retrieved.
       
    68      * @return retrieved button
       
    69      */
       
    70     CFsControlButton* ButtonByIndex( TInt aIndex );
       
    71 
       
    72     /**
       
    73      * Retrieves button with specified id from model.
       
    74      *
       
    75      * @param aId Id of button to be retrieved.
       
    76      * @return retrieved button
       
    77      */
       
    78     CFsControlButton* ButtonById( TInt aId );
       
    79 
       
    80     /**
       
    81      * Gets actual number of buttons in model.
       
    82      *
       
    83      * @return number of buttons.
       
    84      */
       
    85     TInt Count() const;
       
    86 
       
    87     /**
       
    88      * Removes button with specified index from model.
       
    89      *
       
    90      * @param aIndex Index of button to be deleted
       
    91      */
       
    92     void RemoveButtonByIndex( TInt aIndex );
       
    93 
       
    94     /**
       
    95      * Removes button with specified id from model.
       
    96      *
       
    97      * @param aId Id of button to be deleted.
       
    98      * @return KErrNotFound If button's id doesn't exist, otherwise KErrNone.
       
    99      */
       
   100     TInt RemoveButtonById( TInt aId );
       
   101 
       
   102     /**
       
   103      * Checks if button with specified id is in the model.
       
   104      *
       
   105      * @param aId Id to be checked.
       
   106      * @return ETrue if yes, EFalse otherwise.
       
   107      */
       
   108     TBool ExistsButtonWithId( TInt aId );
       
   109 
       
   110     /**
       
   111      * Return index of the button with specified id.
       
   112      *
       
   113      * @param aButtonId Button's id.
       
   114      * @return Button's index in collection.
       
   115      */
       
   116     TInt IndexById( TInt aButtonId );
       
   117 
       
   118     /**
       
   119      * Retrieves button next to the button with specified id.
       
   120      *
       
   121      * @param aButtonId Current button's id.
       
   122      * @return Next button after current.
       
   123      */
       
   124     CFsControlButton* NextButton( TInt aButtonId, TBool aLandscape = EFalse );
       
   125 
       
   126     /**
       
   127      * Retrieves button previous to the button with specified id.
       
   128      *
       
   129      * @param aButtonId Current button's id.
       
   130      * @return Previous button after current.
       
   131      */
       
   132     CFsControlButton* PrevButton( TInt aButtonId, TBool aLandscape = EFalse );
       
   133 
       
   134     /**
       
   135      * Sets focus state for control bar.
       
   136      *
       
   137      * @param aState State to be set.
       
   138      */
       
   139     void SetFocus( TBool aState = ETrue );
       
   140 
       
   141     /**
       
   142      * Checks if focus.
       
   143      *
       
   144      * @return Current focus state.
       
   145      */
       
   146     TBool IsFocused() const;
       
   147 
       
   148     /**
       
   149      * Generates id for new button.
       
   150      *
       
   151      * @return Unique id for new button.
       
   152      */
       
   153     TInt GenerateButtonId();
       
   154 
       
   155     /**
       
   156      * Gets background color for control bar.
       
   157      *
       
   158      * @return Controlbar background color.
       
   159      */
       
   160     const TRgb& BarBgColor() const;
       
   161 
       
   162     /**
       
   163      * Gets transition time for moving selector.
       
   164      *
       
   165      * @return Transition time in miliseconds.
       
   166      */
       
   167     TInt SelectorTransitionTime() const;
       
   168 
       
   169     /**
       
   170      * Sets transition time for moving selector.
       
   171      *
       
   172      * @param aTransitionTime Transition time in miliseconds.
       
   173      */
       
   174     void SetSelectorTransitionTime( TInt aTransitionTime );
       
   175 
       
   176     /**
       
   177      * Refresh the buttons' positions.
       
   178      */
       
   179     void UpdateButtonsPositions();
       
   180 
       
   181     /**
       
   182      * Sets bar's width.
       
   183      *
       
   184      * @param aWidth New bar's width.
       
   185      */
       
   186     void SetWidth( TInt aWidth );
       
   187 
       
   188     /**
       
   189      * Sets bar's height.
       
   190      *
       
   191      * @param aHeight New bar's height.
       
   192      */
       
   193     void SetHeight( TInt aHeight );
       
   194 
       
   195     /**
       
   196      * Set bar's rect
       
   197      */
       
   198     void SetRect( const TRect& aRect );
       
   199 
       
   200     /**
       
   201      * Get size of the controlbar.
       
   202      *
       
   203      * @return Size of the controlbar.
       
   204      */
       
   205     TSize Size() const;
       
   206 
       
   207     /**
       
   208      * Get top-left position
       
   209      */
       
   210     TPoint Pos() const;
       
   211 
       
   212 private:
       
   213 
       
   214     /**
       
   215      * Default constructor.
       
   216      */
       
   217     CFsControlBarModel();
       
   218 
       
   219     /**
       
   220      * Constructs and initializes bar model.
       
   221      */
       
   222     void ConstructL();
       
   223 
       
   224 private: // data
       
   225 
       
   226     /**
       
   227      * Collection of button's objects.
       
   228      * Own all button objects.
       
   229      */
       
   230     RPointerArray<CFsControlButton> iButtons;
       
   231 
       
   232     /**
       
   233      * Focus state.
       
   234      */
       
   235     TBool iFocused;
       
   236 
       
   237     /**
       
   238      * Controlbar's background color.
       
   239      */
       
   240     TRgb iBgColor;
       
   241 
       
   242     /**
       
   243      * Delay for selector moves.
       
   244      */
       
   245     TInt iSelectorTransitionTime;
       
   246 
       
   247     /**
       
   248      * Size of the bar.
       
   249      */
       
   250     TSize iSize;
       
   251 
       
   252     /**
       
   253      * Width default flag.
       
   254      */
       
   255     TBool iWidthUseDefault;
       
   256 
       
   257     /**
       
   258      * Height default flag.
       
   259      */
       
   260     TBool iHeightUseDefault;
       
   261 
       
   262     /**
       
   263      * Top-left position
       
   264      */
       
   265     TPoint iTl;
       
   266     };
       
   267 
       
   268 
       
   269 #endif // C_FSCONTROLBARMODEL_H