vtuis/videotelui/inc/features/toolbar/cvtuitoolbarbase.h
changeset 0 ed9695c8bcbe
equal deleted inserted replaced
-1:000000000000 0:ed9695c8bcbe
       
     1 /*
       
     2 * Copyright (c) 2006 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:  Base class for toolbar.
       
    15 *
       
    16 */
       
    17 
       
    18 
       
    19 #ifndef C_VTUITOOLBAR_H
       
    20 #define C_VTUITOOLBAR_H
       
    21 
       
    22 #include <e32base.h>
       
    23 #include <aknappui.h>
       
    24 #include <akntoolbarobserver.h>
       
    25 
       
    26 #include "mvtuifeature.h"
       
    27 #include "CVtUiAppUi.h"
       
    28 #include "cvtuifeaturebase.h"
       
    29 #include "mvtuicommandui.h"
       
    30 #include "mvtuicomponent.h"
       
    31 #include "mvtuiresourcechangeobserver.h"
       
    32 #include "tvtuicomponentstate.h"
       
    33 #include  "mvtuilayoutchangeobserver.h"
       
    34 #include <aknlayoutscalable_avkon.cdl.h>
       
    35 
       
    36 class MVtuiFeature;
       
    37 class CAknToolbar;
       
    38 class CVtUiToolbarItem;
       
    39 class TVtUiFeatureState;
       
    40 class TVtUiStates;
       
    41 class CVtUiToolbarContext;
       
    42 class CVtUiToolbarCmdPolicy;
       
    43 class CVtUiHideToolbarItemAction;
       
    44 class CVtUiFeatureManager;
       
    45 class CVtUiToolbarSKModifier;
       
    46 class CVtUiToolbarButton;
       
    47 
       
    48 /**
       
    49 *  TVtUiToolbarComponentState
       
    50 *
       
    51 * Toolbar componentstate definition.
       
    52 *
       
    53 *  @since S60 v3.2
       
    54 */
       
    55 class TVtUiToolbarComponentState : public TVtUiComponentState
       
    56     {
       
    57 
       
    58 public:
       
    59 
       
    60     /**
       
    61     * Constructor
       
    62     * @param aComponent Reference to component.
       
    63     */
       
    64     TVtUiToolbarComponentState( MVtUiComponent& aComponent );
       
    65     
       
    66     };
       
    67 
       
    68 /**
       
    69 * CVtUiToolbar  
       
    70 * 
       
    71 * Toolbar UI feature definition.
       
    72 *
       
    73 * @since S60 3.2
       
    74 */
       
    75 class CVtUiToolbarBase : public CVtUiFeatureBase, public MAknToolbarObserver,
       
    76     public MVtUiCommandUi, public MVtUiComponent,
       
    77     public MVtUiLayoutChangeObserver
       
    78     {
       
    79     public: // public methods
       
    80 
       
    81         /**
       
    82         * C++ destructor.
       
    83         */
       
    84         ~CVtUiToolbarBase();
       
    85     
       
    86     public: // from MAknToolbarObserver 
       
    87     
       
    88         /**
       
    89         * @see MAknToolbarObserver::DynInitToolbarL
       
    90         */
       
    91         void DynInitToolbarL( 
       
    92             TInt aResourceId,
       
    93             CAknToolbar* aToolbar );
       
    94         
       
    95         /**
       
    96         * @see MAknToolbarObserver::DynInitToolbarL
       
    97         */
       
    98         void OfferToolbarEventL( TInt aCommand );
       
    99     
       
   100     public: // from MVtUiFeature
       
   101         /**
       
   102         * @see MVtUiFeature::StartL
       
   103         */
       
   104         void StartL();
       
   105 
       
   106         /**
       
   107         * @see MVtUiFeature::Stop
       
   108         */
       
   109         void Stop();
       
   110         
       
   111         /*
       
   112         * @see MVtUiFeature::InitFeatureL
       
   113         */
       
   114         void InitFeatureL();
       
   115         
       
   116     public: // from MVtUiCommandUi
       
   117     
       
   118         /**
       
   119         * @see MVtUiCommandUi::RefreshL
       
   120         */
       
   121         void RefreshL();
       
   122 
       
   123         /**
       
   124         *  @see MVtUiCommandUi::AddCommandModifier
       
   125         */
       
   126          TInt AddCommandModifier( CVtUiCommandModifyBase& aModifier );
       
   127 
       
   128         /**
       
   129         * @see MVtUiCommandUi::RemoveCommandModifier
       
   130         */
       
   131          void RemoveCommandModifier( CVtUiCommandModifyBase& aModifier );
       
   132         
       
   133     public: // from MVtUiComponent
       
   134 
       
   135         /**
       
   136         * @see MVtUiComponent::ComponentId
       
   137         */
       
   138         TComponentId ComponentId() const;
       
   139 
       
   140         /**
       
   141         * @see MVtUiComponent::ComponentAsControl
       
   142         */
       
   143         CCoeControl* ComponentAsControl();
       
   144 
       
   145         /**
       
   146         * @see MVtUiComponent::DoActivateL
       
   147         */
       
   148         virtual void DoActivateL();
       
   149 
       
   150         /**
       
   151         * @see MVtUiComponent::DoDeactivateL
       
   152         */
       
   153         virtual void DoDeactivateL();
       
   154     
       
   155     public: // from MVtUiComponentManager
       
   156 
       
   157         /**
       
   158         * @see MVtUiComponentManager::HandleLayoutChangeL
       
   159         */
       
   160         void HandleLayoutChangeL();
       
   161 
       
   162     public:
       
   163 
       
   164         /**
       
   165         * Return number of commands in toolbar.
       
   166         * @return Number of commands.
       
   167         */
       
   168         TInt NumberOfToolbarControls() const;
       
   169         
       
   170         /**
       
   171         * Maps command id array index to command id.
       
   172         * @param aIndex Command id array index.
       
   173         * @return Command id associated with index.
       
   174         */
       
   175         TInt CommandIdByCmdIdsArrayIndex( TInt aIndex ) const;
       
   176    
       
   177         /**
       
   178         * Updates toolbar's buttons states and
       
   179         * redraws the toolbar.
       
   180         */
       
   181         void UpdateToolbarL();
       
   182      
       
   183         /**
       
   184         * EHidden
       
   185         *  command is hidden
       
   186         * EDimmed
       
   187         *  command is dimmed
       
   188         * EShown
       
   189         * command is visible
       
   190         */
       
   191         enum TCmdStateFlags
       
   192             {
       
   193             ENotInitialized = -1,
       
   194             EHidden,
       
   195             EDimmed,
       
   196             EShown
       
   197             }; 
       
   198 
       
   199          /**
       
   200         * Sets visibility of toolbar commands.
       
   201         * @param aCmdId command id.
       
   202         * @param aNewState command's new state.
       
   203         * @return ETrue if command is available, otherwise EFalse.
       
   204         */
       
   205         void SetCmdIdVisibilityStateL( TInt aCmdId, TCmdStateFlags aNewState);
       
   206         
       
   207         /**
       
   208         * Cheks if command is available in toolbar.
       
   209         * @param aCmdId command id.
       
   210         * @return ETrue if command is available, otherwise EFalse.
       
   211         */
       
   212         TBool IsCommandInToolbar( TInt aCmdId ) const;
       
   213          
       
   214     protected:
       
   215 
       
   216         /**
       
   217         * C++ constructor
       
   218         */
       
   219         CVtUiToolbarBase( CVtUiFeatureManager& aFeatureManager );
       
   220 
       
   221         /**
       
   222         * 2nd phase constructor
       
   223         */
       
   224         void BaseConstructL();
       
   225 
       
   226     protected:    
       
   227   
       
   228         /**
       
   229         * Creates toolbar buttons
       
   230         */
       
   231         virtual void CreateToolbarButtonsL();
       
   232 
       
   233         /*
       
   234         * Appends all the commnands used by toolbar to an array.
       
   235         */
       
   236         virtual void PopulateCmdsIdsL();    
       
   237             
       
   238         /*
       
   239         * Sets toolbar visibility after layoutchange
       
   240         */    
       
   241         virtual void SetToolbarVisibilityAfterLayoutChangeL( TBool aVisible );
       
   242     
       
   243         /**
       
   244         * Creates all toolbar items()
       
   245         */
       
   246         void CreateToolbarItemL( TInt aResourceId,
       
   247             TInt aCommandId, CVtUiAppUi& appUi );
       
   248    
       
   249         /**
       
   250         * Finds command from array by command id.
       
   251         */
       
   252         CVtUiToolbarButton* FindToolbarItemByCommandId( const TInt aCommandId );
       
   253          
       
   254         /*
       
   255         * Starts or stops to block pointer events
       
   256         * @param aIsBlocking ETrue if events are blocked
       
   257         * otherwise EFalse
       
   258         */
       
   259         void BlockPointerEvents( TBool aIsBlocking );
       
   260            
       
   261         /*
       
   262         * Starts or stops to block key events
       
   263         * @param aIsBlocking ETrue if events are blocked
       
   264         * otherwise EFalse
       
   265         */
       
   266         void BlockKeyEvents( TBool aIsBlocking );
       
   267          
       
   268         /*
       
   269         * Cheks if dialer component is active
       
   270         * @return ETrue if dialer is aactive, otherwise EFalse. 
       
   271         */
       
   272         TBool IsDialerActive() const;
       
   273         
       
   274         /**
       
   275         * Dims toolbar.
       
   276         * @param aDimmed ETrue ETrue to dim the toolbar, 
       
   277         *      EFalse to set the toolbar as not dimmed
       
   278         */
       
   279         void DimToolbar( const TBool aDimmed, const TBool aDrawNow );
       
   280     private:
       
   281     
       
   282         /**
       
   283         * Hides command from toolbar.
       
   284         */
       
   285         void HideToolbarButton( const TInt aCommandId, const TBool aHide,
       
   286             const TBool aDrawNow );
       
   287         
       
   288         /**
       
   289         * Dims command from toolbar.
       
   290         */
       
   291         void DimToolbarButton( const TInt aCommandId, const TBool aDimmed,
       
   292             const TBool aDrawNow ); 
       
   293        
       
   294         /**
       
   295         * Maps toggle button id to single command id.
       
   296         */
       
   297         TInt MapCmdIdToChilId( TInt aCmdId );
       
   298         
       
   299         /**
       
   300         * Maps single command id to toggle button id.
       
   301         */
       
   302         TInt MapCmdIdToParentId( TInt aCmdId );
       
   303         
       
   304         /*
       
   305         * Checks if command id associated with toggle button is visible.
       
   306         * Togglle button has two states and two command ids which has their
       
   307         * own state values. See from .rss file.
       
   308         */
       
   309         TBool IsCmdIdVisibleInToggleButton( TInt aCmdId );
       
   310         
       
   311         /*
       
   312         * Checks if both command ids in togglebutton are dimmed.
       
   313         */
       
   314         TBool IsToggleButtonHidden( TInt aFirstCmdId, TInt aSecondCmdId );
       
   315         
       
   316         /*
       
   317         * Removes registrations.
       
   318         */
       
   319         void Clean();
       
   320         
       
   321     protected: // data
       
   322         
       
   323         // array of supported commmand ids
       
   324         RArray<TInt> iCmdIds;    
       
   325         
       
   326         // current focus id
       
   327         TInt iCmdFocus;
       
   328         
       
   329          // owned toolbar control
       
   330         CAknToolbar* iToolbar;
       
   331         
       
   332         // Number of supported toolbar buttons
       
   333         TInt iNumberOfToolbarButtons;
       
   334      
       
   335     private: // data
       
   336          
       
   337         // struct used by iCmdStates array
       
   338         class TCommandState 
       
   339             {
       
   340             public:
       
   341                 TInt iCmdId;
       
   342                 TCmdStateFlags iOldState;
       
   343                 TCmdStateFlags iNewState;
       
   344             };     
       
   345         
       
   346          // owned toolbar item array
       
   347         RPointerArray<CVtUiToolbarButton> iToolBarControls;
       
   348 
       
   349         // toolbar context instance
       
   350         CVtUiToolbarContext* iToolbarCtx; 
       
   351        
       
   352         // owned hide toolbar item action
       
   353         CVtUiHideToolbarItemAction* iHideToolbarItemAction;
       
   354         
       
   355         // Toolbar command policy instance
       
   356         CVtUiToolbarCmdPolicy* iToolbarCmdPolicy;
       
   357         
       
   358         // owned softkey modifier
       
   359         CVtUiToolbarSKModifier* iToolbarSKModifier;
       
   360         
       
   361         // array which hold state information of the commands
       
   362         RArray<TCommandState> iCmdStates;
       
   363         
       
   364         // Component state
       
   365         TVtUiToolbarComponentState iComponentState;
       
   366         
       
   367         // ETrue if capture mode was on in previous update
       
   368         TBool iWasCaptureModePreviousState;
       
   369     
       
   370     };
       
   371 
       
   372 #endif // C_VTUITOOLBAR_H