uifw/EikStd/coctlinc/akntoolbarextensionview.h
changeset 0 2f259fa3e83a
equal deleted inserted replaced
-1:000000000000 0:2f259fa3e83a
       
     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:  Toolbar extension view, which shows a set of buttons or other
       
    15 *                components. 
       
    16 *
       
    17 */
       
    18 
       
    19 
       
    20 #ifndef CAKNTOOLBAREXTENSIONVIEW_H
       
    21 #define CAKNTOOLBAREXTENSIONVIEW_H
       
    22 
       
    23 #include <AknControl.h>
       
    24 
       
    25 
       
    26 class CAknToolbarExtension; 
       
    27 class CAknToolbarItem; 
       
    28 class CAknsFrameBackgroundControlContext;
       
    29 class TAknWindowComponentLayout;
       
    30 class CAknResourceProvider;
       
    31 
       
    32 
       
    33 /**
       
    34  *  Toolbar extension view
       
    35  *
       
    36  *  Toolbar extension view shows the extension view window. Extension view
       
    37  *  can consist of buttons, editor and other controls. Extension view is 
       
    38  *  either focused or non-focusing, depending on toolbar. 
       
    39  *
       
    40  *  @lib eikcoctl.lib
       
    41  *  @since S60 v5.0
       
    42  */
       
    43 NONSHARABLE_CLASS( CAknToolbarExtensionView ) : public CAknControl
       
    44     {
       
    45 public:
       
    46 
       
    47     /**
       
    48      * Creates toolbar extension
       
    49      *
       
    50      * @return extension
       
    51      */
       
    52     static CAknToolbarExtensionView* NewL( TResourceReader& aReader,
       
    53         CAknToolbarExtension* aExtension );
       
    54 
       
    55     /**
       
    56      * Destructor
       
    57      */
       
    58     ~CAknToolbarExtensionView();
       
    59 
       
    60 
       
    61 // from base class CCoeControl
       
    62 
       
    63     /**
       
    64      * From CCoeControl.
       
    65      * Constructs extension view from resource
       
    66      *
       
    67      * @param aReader resource reader
       
    68      */
       
    69     void ConstructFromResourceL( TResourceReader& aReader );
       
    70 
       
    71     /**
       
    72      * From CCoeControl
       
    73      * Makes extension visible or hides it
       
    74      *
       
    75      * @param aVisible indicates if to show or to hide
       
    76      */
       
    77     void MakeVisible( TBool aVisible );
       
    78 
       
    79     /**
       
    80      * From CCoeControl.
       
    81      * Handles key events. 
       
    82      *
       
    83      * @param aKeyEvent information about the key event
       
    84      * @param aType type of the key event. 
       
    85      * @return consumed or did not consume the key event. 
       
    86      */
       
    87     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
       
    88 
       
    89     /**
       
    90      * From CCoeControl.
       
    91      * Gets the number of controls contained in a compound control.
       
    92      *
       
    93      * @return The number of component controls contained by this control.
       
    94      */
       
    95     TInt CountComponentControls() const;
       
    96 
       
    97     /**
       
    98      * From CCoeControl.
       
    99      * Gets the specified component of a compound control.
       
   100      *
       
   101      * @param aIndex The index of the control to get
       
   102      * @return The component control with an index of aIndex.
       
   103      */
       
   104     CCoeControl* ComponentControl( TInt aIndex ) const;
       
   105 
       
   106     /**
       
   107      * From CCoeControl.
       
   108      * Handles resource changes, for example layout and skin changes 
       
   109      *
       
   110      * @param aType the type of resource change
       
   111      */
       
   112     void HandleResourceChange( TInt aType );
       
   113 
       
   114     /**
       
   115      * Handles pointer events
       
   116      * @param aPointerEvent information about the pointer event
       
   117      */
       
   118     void HandlePointerEventL( const TPointerEvent& aPointerEvent ); 
       
   119 
       
   120 // new functions
       
   121 
       
   122     /**
       
   123      * Gets a pointer to the specified control.
       
   124      *
       
   125      * @param aControlId The ID of the control for which a pointer is
       
   126      *      required.
       
   127      * @return Pointer to the control with the specified ID.
       
   128      */
       
   129     CCoeControl* ControlOrNull( TInt aCommandId ) const; 
       
   130 
       
   131     /**
       
   132      * Returns command id of the control given
       
   133      * @param aControl the control which command id is needed 
       
   134      * @return command id of the control
       
   135      */
       
   136     TInt CommandIdByControl( CCoeControl* aControl ) const; 
       
   137 
       
   138     /**
       
   139      * Checks where controltype is an editor
       
   140      * @param aType controltype of the control
       
   141      * @return ETrue if control is editor. 
       
   142      */
       
   143     TBool Editor( TInt aType );
       
   144 
       
   145     /**
       
   146      * Adds one item to the specified place. Takes ownership.
       
   147      * Leaves with value KErrArgument if aItem does not exist or 
       
   148      * aIndex is out of bound. 
       
   149      *
       
   150      * @param aItem The control.
       
   151      * @param aType The type of the new toolbar item.
       
   152      * @param aCommandId The command ID for this item.
       
   153      * @param aFlags The flags.
       
   154      * @param aIndex The index in array at which item should be added.
       
   155      */
       
   156     void AddItemL( CCoeControl* aItem,
       
   157                    TInt aType,
       
   158                    TInt aCommandId,
       
   159                    TInt aFlags,
       
   160                    TInt aIndex );
       
   161 
       
   162     /**
       
   163      * Removes an item
       
   164      * @param aCommandId the command id of the item to be removed
       
   165      */
       
   166     void RemoveItemL( TInt aCommandId ); 
       
   167 
       
   168     /**
       
   169      * Sets an item dimmed or undimmed
       
   170      * @param aCommandId the command id of the item to be dimmed
       
   171      * @param aDimmed to dim or undim
       
   172      */
       
   173     void SetItemDimmed( TInt aCommandId, TBool aDimmed ); 
       
   174 
       
   175     /**
       
   176      * Hides an item or unhides it
       
   177      * @param aCommandId command id of the item to be hidden/unhidden
       
   178      * @param aHidden to hide or unhide
       
   179      */
       
   180     void HideItemL( TInt aCommandId, TBool aHide ); 
       
   181 
       
   182 private: // Functions from base class
       
   183 
       
   184     /**
       
   185      * From CCoeControl. Draws the control. Called by window server.
       
   186      */
       
   187     void Draw( const TRect& aRect ) const;  
       
   188 
       
   189 
       
   190 private: // New functions
       
   191 
       
   192     /**
       
   193      * Default constructor
       
   194      *
       
   195      * @param aExtension pointer to extension
       
   196      */
       
   197     CAknToolbarExtensionView( CAknToolbarExtension* aExtension );
       
   198 
       
   199     /**
       
   200      * 2nd phase constructor
       
   201      */
       
   202     void ConstructL(); 
       
   203 
       
   204     /**
       
   205      * Constructs an control from resources 
       
   206      *
       
   207      * @param aReader resource reader
       
   208      * @return a toolbar item
       
   209      */
       
   210     CAknToolbarItem* ConstructControlLC( TResourceReader& aReader ); 
       
   211 
       
   212     /**
       
   213      * Calculates size and position for the extension
       
   214      *
       
   215      * @return the extension rect
       
   216      */
       
   217     TRect CalculateSizeL(); 
       
   218 
       
   219     /**
       
   220      * Selects or unselects an item
       
   221      *
       
   222      * @param aIndex the item to select/unselect
       
   223      * @param aSelect if to select an item or unselect it
       
   224      */
       
   225     void SelectItemL( TInt aIndex, TBool aSelect ); 
       
   226 
       
   227     /**
       
   228      * Gets rect from layout data.
       
   229      */
       
   230     TRect RectFromLayout( const TRect& aParent,
       
   231         const TAknWindowComponentLayout& aComponentLayout) const; 
       
   232 
       
   233     /**
       
   234      * Resizing editor and button after it
       
   235      */
       
   236     void ResizeFindPaneL( TRect& aWindowRect, TBool aLandscape, TInt aPosition, 
       
   237         TInt& aIndex ); 
       
   238 
       
   239     /**
       
   240      * Getting the correct y-coordinate for extension
       
   241      */
       
   242     TInt GetVariety( TInt aRow, TBool aLandscape ); 
       
   243 
       
   244     /**
       
   245      * Checking button frames when an item was added, removed, hidden or unhidden
       
   246      * after an editor. 
       
   247      */
       
   248     void CheckButtonFrames( TInt aAdd, TInt aIndex ); 
       
   249 
       
   250     /**
       
   251      * Returns index of the item which commandid is given as parameter. 
       
   252      */
       
   253     TInt ToolbarItemIndexById( TBool aVisibleItems, const TInt aId ) const;  
       
   254 
       
   255     /**
       
   256      * Moves highlight to another item
       
   257      * @param aDirection to which direction to move, enum defined in 
       
   258      *        akntoolbarextenion.view.cpp
       
   259      * @param aIndex if aDirection is  ENoDirection, this index informs to which item 
       
   260      *        to move the highlight
       
   261      */
       
   262     void MoveHighlightL( TInt aDirection, TInt aIndex );
       
   263 
       
   264     /**
       
   265      * Calculates next focusable item. Used with floating toolbar extension. 
       
   266      * @param aStep how many steps to move. 
       
   267      * @return index of the next focusable item
       
   268      */
       
   269     TInt NextFocusable( TInt aStep ); 
       
   270 
       
   271     /**
       
   272      * Adjusts button's properties depending on the toolbar extension's features.
       
   273      */                                   
       
   274     void AdjustButtonL( CAknButton& aButton );
       
   275     
       
   276     /**
       
   277      * Calculates and sets the control positions according to layout rects
       
   278      * @param aWindowRect Window rect
       
   279      * @param aGridRect Grid rect
       
   280      * @param aCellRect Cell rect
       
   281      * @return Extension width
       
   282      */                                   
       
   283     TInt CalculateControlPositions( 
       
   284         TRect& aWindowRect, TRect& aGridRect, TRect& aCellRect );
       
   285 
       
   286     /**
       
   287      * Returns hidden items count
       
   288      * Needed when iVisibleItems is not up-to-date.
       
   289      * @return Count of hidden items
       
   290      */                                   
       
   291     TInt CountHiddenItems();
       
   292 
       
   293 private: // data
       
   294 
       
   295     /** Toolbar extension frame context
       
   296      * Own
       
   297      */ 
       
   298     CAknsFrameBackgroundControlContext* iFrameContext;
       
   299 
       
   300     /**
       
   301      * Pointer to extension
       
   302      * Not own. 
       
   303      */
       
   304     CAknToolbarExtension* iExtension; 
       
   305 
       
   306     /**
       
   307      * Pointer array of extension items
       
   308      * Own. 
       
   309      */
       
   310     RPointerArray<CAknToolbarItem> iItems; 
       
   311 
       
   312     /**
       
   313      * Pointer array of extension items
       
   314      * Own. 
       
   315      */
       
   316     RPointerArray<CAknToolbarItem> iVisibleItems; 
       
   317 
       
   318     /**
       
   319      * Extension position
       
   320      */
       
   321     TPoint iExtensionPosition; 
       
   322 
       
   323     /**
       
   324      * Currently selected item
       
   325      */
       
   326     TInt iSelectedItem; 
       
   327 
       
   328     /**
       
   329      * Previously selected item, used in handlepointerevent to control
       
   330      * the pointer events
       
   331      */
       
   332     TInt iPreviousItem; 
       
   333 
       
   334     /**
       
   335      * Item that catches point down event
       
   336      */
       
   337     TInt iDownItem;
       
   338 
       
   339     /**
       
   340      * Number of colums in extension. Used when moving the focus down or up. 
       
   341      */
       
   342     TInt iNumberOfColumns; 
       
   343 
       
   344     /**
       
   345      * Number of rows in extension. 
       
   346      */
       
   347     TInt iNumberOfRows; 
       
   348 
       
   349     /**
       
   350      * Resource provider.
       
   351      * Own.
       
   352      */
       
   353     CAknResourceProvider* iResourceProvider;
       
   354 
       
   355     /*
       
   356      * record whether the touch down operation takes place outside the view area
       
   357      */
       
   358     TBool    iIsDownOutside;
       
   359     };
       
   360 
       
   361 #endif // CAKNTOOLBAREXTENSIONVIEW_H