epoc32/include/mw/akntoolbar.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:27:01 +0100
branchSymbian2
changeset 3 e1b950c65cb4
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Attempt to represent the S^2->S^3 header reorganisation as a series of "hg rename" operations
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2005-2007 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     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
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description:  Popup toolbar component
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
#ifndef __AKNTOOLBAR_H__
williamr@2
    21
#define __AKNTOOLBAR_H__
williamr@2
    22
williamr@2
    23
//  INCLUDES
williamr@2
    24
#include <avkon.hrh> // TAknOrientation
williamr@2
    25
#include <akncontrol.h> // CCoeControl
williamr@2
    26
#include <coecobs.h>    // MCoeControlObserver
williamr@2
    27
#include <eikcmobs.h>   // MEikCommandObserver
williamr@2
    28
#include <aknpopupfader.h>
williamr@2
    29
#include <babitflags.h>
williamr@2
    30
williamr@2
    31
// FORWARD DECLARATIONS
williamr@2
    32
class CAknButton;
williamr@2
    33
class CAknToolbarItem;
williamr@2
    34
class CAknToolbarExtension;
williamr@2
    35
class MAknToolbarObserver;
williamr@2
    36
class CEikButtonGroupContainer;
williamr@2
    37
class TAknWindowComponentLayout;
williamr@2
    38
class CAknsFrameBackgroundControlContext;
williamr@2
    39
class CAknsBasicBackgroundControlContext;
williamr@2
    40
williamr@2
    41
williamr@2
    42
// DisableToolbarL leaves with this value if toolbar is shown, since toolbar
williamr@2
    43
// should not be shown when disabling/enabling toolbar. 
williamr@2
    44
const TInt KErrToolbarShown = -101;   
williamr@2
    45
williamr@2
    46
// CLASS DECLARATION
williamr@2
    47
williamr@2
    48
/**
williamr@2
    49
*  The class to provide toolbar for the application
williamr@2
    50
*
williamr@2
    51
*  @lib eikcoctl.lib
williamr@2
    52
*  @since Series 60 3.1
williamr@2
    53
*/
williamr@2
    54
class CAknToolbar : public CAknControl, public MCoeControlObserver, 
williamr@2
    55
    public MCoeControlBackground, public MEikCommandObserver, 
williamr@2
    56
    public MAknFadedComponent
williamr@2
    57
    {
williamr@2
    58
    public: //Enumerations: 
williamr@2
    59
williamr@2
    60
    enum TEventModifiers {
williamr@2
    61
        ELongPress = 1,
williamr@2
    62
        ELongPressEnded = 2,
williamr@2
    63
    };
williamr@2
    64
williamr@2
    65
    public: // Constructors and destructor
williamr@2
    66
williamr@2
    67
        /**
williamr@2
    68
         * Two-phased constructor.
williamr@2
    69
         *
williamr@2
    70
         * @param aResourceId The ID for this component's resource
williamr@2
    71
         * @return Pointer to the created toolbar object
williamr@2
    72
         */
williamr@2
    73
        IMPORT_C static CAknToolbar* NewL( const TInt aResourceId );
williamr@2
    74
williamr@2
    75
        /**
williamr@2
    76
         * Two-phased constructor.
williamr@2
    77
         *
williamr@2
    78
         * @param aResourceId The ID for this component's resource
williamr@2
    79
         * @return Pointer to the created toolbar object
williamr@2
    80
         */
williamr@2
    81
        IMPORT_C static CAknToolbar* NewLC( const TInt aResourceId );
williamr@2
    82
williamr@2
    83
        /**
williamr@2
    84
         * Destructor
williamr@2
    85
         */
williamr@2
    86
        ~CAknToolbar();
williamr@2
    87
williamr@2
    88
    public: // From base class
williamr@2
    89
williamr@2
    90
        /**
williamr@2
    91
         * From CCoeControl.
williamr@2
    92
         * Gets the number of controls contained in a compound control.
williamr@2
    93
         *
williamr@2
    94
         * @return The number of component controls contained by this control.
williamr@2
    95
         */
williamr@2
    96
         IMPORT_C TInt CountComponentControls() const;
williamr@2
    97
williamr@2
    98
         /**
williamr@2
    99
         * From CCoeControl.
williamr@2
   100
         * Gets the specified component of a compound control.
williamr@2
   101
         *
williamr@2
   102
         * @param aIndex The index of the control to get
williamr@2
   103
         * @return The component control with an index of aIndex.
williamr@2
   104
         */
williamr@2
   105
        IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const ;
williamr@2
   106
williamr@2
   107
        /**
williamr@2
   108
         * From CCoeControl.
williamr@2
   109
         * Handles pointer events.
williamr@2
   110
         *
williamr@2
   111
         * @param aPointerEvent The pointer event. 
williamr@2
   112
         */
williamr@2
   113
        IMPORT_C void HandlePointerEventL( const TPointerEvent& aPointerEvent );
williamr@2
   114
williamr@2
   115
        /**
williamr@2
   116
         * From CCoeControl.
williamr@2
   117
         * Handles a change to the control's resources.
williamr@2
   118
         *
williamr@2
   119
         * @param aType A message UID value.
williamr@2
   120
         */
williamr@2
   121
        IMPORT_C void HandleResourceChange( TInt aType );
williamr@2
   122
williamr@2
   123
        /**
williamr@2
   124
         * From MCoeControlObserver.
williamr@2
   125
         * Handles an event from an observed toolbar item.
williamr@2
   126
         *
williamr@2
   127
         * @param aControl The control which sent the event
williamr@2
   128
         * @param aEventType The event type
williamr@2
   129
         */
williamr@2
   130
        IMPORT_C void HandleControlEventL( CCoeControl* aControl, 
williamr@2
   131
                                           TCoeEvent aEventType );
williamr@2
   132
williamr@2
   133
        /**
williamr@2
   134
         * From CCoeControl.
williamr@2
   135
         * Responds to changes in the position of a toolbar.
williamr@2
   136
         */
williamr@2
   137
        IMPORT_C void PositionChanged();
williamr@2
   138
williamr@2
   139
        /**
williamr@2
   140
         * From MEikCommandObserver.
williamr@2
   141
         * Processes user commands.
williamr@2
   142
         *
williamr@2
   143
         * @param TInt aCommandId  ID of the command to respond to.
williamr@2
   144
         */
williamr@2
   145
        IMPORT_C void ProcessCommandL( TInt aCommandId );
williamr@2
   146
williamr@2
   147
        /**
williamr@2
   148
         * From CCoeControl.
williamr@2
   149
         * Sets toolbar dimmed. Doesn't redraw.
williamr@2
   150
         *
williamr@2
   151
         * @param aDimmed is ETrue to dim the toolbar, 
williamr@2
   152
         *      EFalse to set the toolbar as not dimmed
williamr@2
   153
         */
williamr@2
   154
        IMPORT_C void SetDimmed( TBool aDimmed );
williamr@2
   155
williamr@2
   156
        /**
williamr@2
   157
         * From CCoeControl.
williamr@2
   158
         * Handles key events.
williamr@2
   159
         *
williamr@2
   160
         * @param aKeyEvent The key event
williamr@2
   161
         * @param aType The type of key event: EEventKey, EEventKeyUp
williamr@2
   162
         *      or EEventKeyDown.
williamr@2
   163
         * @return TKeyResponse Indicates whether or not the key event was used
williamr@2
   164
         *      by this control.
williamr@2
   165
         */
williamr@2
   166
        IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,
williamr@2
   167
                                              TEventCode aType );
williamr@2
   168
williamr@2
   169
        /**
williamr@2
   170
         * From CCoeControl.
williamr@2
   171
         * Gets the control's input capabilities.
williamr@2
   172
         *
williamr@2
   173
         * @return The control's input capabilities.
williamr@2
   174
         */
williamr@2
   175
        IMPORT_C TCoeInputCapabilities InputCapabilities() const;
williamr@2
   176
williamr@2
   177
        /**
williamr@2
   178
         * From MCoeControlBackground.
williamr@2
   179
         * Draw the background for a given control.
williamr@2
   180
         * The text drawer that shall be used to draw text on the specific
williamr@2
   181
         * background can be fetched through the GetTextDrawer() method.
williamr@2
   182
         *
williamr@2
   183
         * @param aGc Graphics context used for drawing.
williamr@2
   184
         * @param aControl The control being drawn (may be a child of the drawer).
williamr@2
   185
         * @param aRect The area to be redrawn.
williamr@2
   186
         */
williamr@2
   187
        IMPORT_C void Draw( CWindowGc& aGc,
williamr@2
   188
                            const CCoeControl& aControl,
williamr@2
   189
                            const TRect& aRect ) const;
williamr@2
   190
williamr@2
   191
    public: // New functions
williamr@2
   192
williamr@2
   193
        /**
williamr@2
   194
         * Gets a pointer to the specified control.
williamr@2
   195
         *
williamr@2
   196
         * @param aControlId The ID of the control for which a pointer is
williamr@2
   197
         *      required.
williamr@2
   198
         * @return Pointer to the control with the specified ID.
williamr@2
   199
         */
williamr@2
   200
        IMPORT_C CCoeControl* ControlOrNull( const TInt aControlId ) const;
williamr@2
   201
williamr@2
   202
        /**
williamr@2
   203
         * Shows or hides toolbar. Position of the top left corner should be set
williamr@2
   204
         * in advance. Toolbar set visible with this method is by default focusing.
williamr@2
   205
         * Does nothing if toolbar is disabled.
williamr@2
   206
         * @param aVisible ETrue to show it, EFalse to hide it.
williamr@2
   207
         */
williamr@2
   208
        IMPORT_C void SetToolbarVisibility( const TBool aVisible );
williamr@2
   209
williamr@2
   210
        /**
williamr@2
   211
        * Shows or hides toolbar. Position of the top left corner should be set
williamr@2
   212
        * in advance. This overload of the method allows toolbar to be set
williamr@2
   213
        * non-focusing. Does nothing if toolbar is disabled. 
williamr@2
   214
        * @param aVisible ETrue to show it, EFalse to hide it.
williamr@2
   215
        * @param aFocusing ETrue to set toolbar focusing, otherwise EFalse.
williamr@2
   216
        */
williamr@2
   217
        IMPORT_C void SetToolbarVisibility( const TBool aVisible, 
williamr@2
   218
                                            const TBool aFocusing );
williamr@2
   219
williamr@2
   220
        /**
williamr@2
   221
         * Dims (greys out) or undims a toolbar item.
williamr@2
   222
         *
williamr@2
   223
         * @param aCommandId The command (as defined in an .hrh file)
williamr@2
   224
         *      associated with this toolbar item. This identifies the toolbar
williamr@2
   225
         *      item, whose text is to be dimmed or un-dimmed.
williamr@2
   226
         * @param aDimmed Use ETrue to dim this toolbar item or EFalse to
williamr@2
   227
         *      un-dim this toolbar item.
williamr@2
   228
         * @param aDrawNow Should be ETrue for the item to be redrawn.
williamr@2
   229
         */
williamr@2
   230
        IMPORT_C void SetItemDimmed( const TInt aCommandId,
williamr@2
   231
                                     const TBool aDimmed,
williamr@2
   232
                                     const TBool aDrawNow );
williamr@2
   233
williamr@2
   234
        /**
williamr@2
   235
         * Hides or unhides a toolbar item.
williamr@2
   236
         *
williamr@2
   237
         * @param aCommandId The command (as defined in an .hrh file)
williamr@2
   238
         *      associated with this toolbar item. This identifies the toolbar
williamr@2
   239
         *      item, which will be set to hidden or unhidden.
williamr@2
   240
         * @param aHide Use ETrue to hide this toolbar item or EFalse to
williamr@2
   241
         *      unhide this toolbar item.
williamr@2
   242
         * @param aDrawNow Should be ETrue for the toolbar to be redrawn.
williamr@2
   243
         */
williamr@2
   244
        IMPORT_C void HideItem( const TInt aCommandId,
williamr@2
   245
                                const TBool aHide,
williamr@2
   246
                                const TBool aDrawNow );
williamr@2
   247
williamr@2
   248
        /**
williamr@2
   249
         * Sets the observer for the toolbar.
williamr@2
   250
         *
williamr@2
   251
         * @param aObserver A pointer to the observer. Ownership is not changed.
williamr@2
   252
         */
williamr@2
   253
        IMPORT_C void SetToolbarObserver( MAknToolbarObserver* aObserver );
williamr@2
   254
williamr@2
   255
        /**
williamr@2
   256
         * Returns a pointer to the toolbar observer.
williamr@2
   257
         *
williamr@2
   258
         * @return Pointer to the toolbar observer.
williamr@2
   259
         */
williamr@2
   260
        IMPORT_C MAknToolbarObserver* ToolbarObserver();
williamr@2
   261
williamr@2
   262
        /**
williamr@2
   263
         * Adds one item to the end of the toolbar. Takes ownership.
williamr@2
   264
         * Leaves with value KErrNotSupported, if the control type is not
williamr@2
   265
         * supported by toolbar (see CAknToolbar::IsSupportedItemType()).
williamr@2
   266
         *
williamr@2
   267
         * @param aItem The control.
williamr@2
   268
         * @param aType The type of the new toolbar item.
williamr@2
   269
         * @param aCommandId The command ID for this item.
williamr@2
   270
         * @param aFlags The flags.
williamr@2
   271
         */
williamr@2
   272
        IMPORT_C void AddItemL( CCoeControl* aItem, 
williamr@2
   273
                                const TInt aType, 
williamr@2
   274
                                const TInt aCommandId, 
williamr@2
   275
                                const TInt aFlags );
williamr@2
   276
williamr@2
   277
        /**
williamr@2
   278
         * Adds one item to the specified place. Takes ownership.
williamr@2
   279
         * Leaves with value KErrNotSupported, if the control type is not
williamr@2
   280
         * supported by toolbar (see CAknToolbar::IsSupportedItemType()).
williamr@2
   281
         *
williamr@2
   282
         * @param aItem The control.
williamr@2
   283
         * @param aType The type of the new toolbar item.
williamr@2
   284
         * @param aCommandId The command ID for this item.
williamr@2
   285
         * @param aFlags The flags.
williamr@2
   286
         * @param aIndex The index in array at which item should be added.
williamr@2
   287
         */
williamr@2
   288
        IMPORT_C void AddItemL( CCoeControl* aItem,
williamr@2
   289
                                const TInt aType,
williamr@2
   290
                                const TInt aCommandId,
williamr@2
   291
                                const TInt aFlags,
williamr@2
   292
                                const TInt aIndex );
williamr@2
   293
williamr@2
   294
        /**
williamr@2
   295
         * Removes one item from the toolbar.
williamr@2
   296
         *
williamr@2
   297
         * @param aCommandId The ID of the item which should be removed.
williamr@2
   298
         */
williamr@2
   299
        IMPORT_C void RemoveItem( const TInt aCommandId );
williamr@2
   300
williamr@2
   301
        /**
williamr@2
   302
         * Returns ETrue if the type of the item can be included in the
williamr@2
   303
         * toolbar.
williamr@2
   304
         *
williamr@2
   305
         * @return ETrue for the supported type, otherwise EFalse.
williamr@2
   306
         */
williamr@2
   307
        IMPORT_C TBool IsSupportedItemType( const TInt aType ) const;
williamr@2
   308
williamr@2
   309
        /**
williamr@2
   310
         * Changes the command ID for the initially focused item when toolbar is
williamr@2
   311
         * shown or gain focus. Notice that, if this item is not visible, then
williamr@2
   312
         * focus will be according default behaviour. Normally, focus will be on
williamr@2
   313
         * the first item, if KAknToolbarMiddleItemFocused flag was not used.
williamr@2
   314
         *
williamr@2
   315
         * @param aCommandId The command ID for the item to get focus.
williamr@2
   316
         */
williamr@2
   317
        IMPORT_C void SetInitialFocusedItem( const TInt aCommandId );
williamr@2
   318
williamr@2
   319
        /**
williamr@2
   320
         * Called by the framework to handle the emphasising or
williamr@2
   321
         * de-emphasising of a toolbar window when it is needed. 
williamr@2
   322
         * 
williamr@2
   323
         * @param aEmphasis ETrue to emphasize the menu, EFalse otherwise.
williamr@2
   324
         */
williamr@2
   325
        IMPORT_C void SetEmphasis( const TBool aEmphasis );
williamr@2
   326
williamr@2
   327
        /**
williamr@2
   328
         * Returns toolbar visibility at this moment
williamr@2
   329
         *
williamr@2
   330
         * @return ETrue, if toolbar is shown.
williamr@2
   331
         */
williamr@2
   332
        IMPORT_C TBool IsShown() const;
williamr@2
   333
williamr@2
   334
        /**
williamr@2
   335
         * Specifies whether toolbar should be shown with sliding effect or not.
williamr@2
   336
         * By default toolbar is shown with sliding.
williamr@2
   337
         *
williamr@2
   338
         * @param aSlide ETrue for sliding effect, EFalse without sliding.
williamr@2
   339
         */
williamr@2
   340
        IMPORT_C void SetWithSliding( const TBool aSlide );
williamr@2
   341
williamr@2
   342
        /**
williamr@2
   343
         * Sets whether the toolbar should be closed or remain open after the
williamr@2
   344
         * specified command is issued from the toolbar.
williamr@2
   345
         *
williamr@2
   346
         * @param aCommandId The command.
williamr@2
   347
         * @param aClose ETrue, if toolbar should be close.
williamr@2
   348
         */
williamr@2
   349
        IMPORT_C void SetCloseOnCommand( const TInt aCommandId,
williamr@2
   350
                                         const TBool aClose );
williamr@2
   351
williamr@2
   352
        /**
williamr@2
   353
         * Sets whether the toolbar should be closed after a command is issued
williamr@2
   354
         * from the toolbar. This method affects every command on the toolbar.
williamr@2
   355
         *
williamr@2
   356
         * @param aClose ETrue, if toolbar should be closed.
williamr@2
   357
         */
williamr@2
   358
        IMPORT_C void SetCloseOnAllCommands( const TBool aClose );
williamr@2
   359
        
williamr@2
   360
        /**
williamr@2
   361
         * Sets toolbar orientation.
williamr@2
   362
         * 
williamr@2
   363
         * @param aOrientation Orientation that should be used for toolbar.
williamr@2
   364
         * @since 3.2
williamr@2
   365
         */
williamr@2
   366
        IMPORT_C void SetOrientation( const TAknOrientation aOrientation );
williamr@2
   367
        
williamr@2
   368
        /**
williamr@2
   369
         * Updates transparent toolbar's background. 
williamr@2
   370
         * @since 3.2
williamr@2
   371
         */
williamr@2
   372
        IMPORT_C void UpdateBackground();
williamr@2
   373
         
williamr@2
   374
        /**
williamr@2
   375
         * Shows toolbar again after it has been hidden for background changing 
williamr@2
   376
         * purposes
williamr@2
   377
         * 
williamr@2
   378
         * @since 3.2
williamr@2
   379
         */
williamr@2
   380
        void ShowToolbarForBackgroundUpdate(); 
williamr@2
   381
        
williamr@2
   382
        /**
williamr@2
   383
         * Disables/Enables toolbar so that it cannot/can be activated from e.g. 
williamr@2
   384
         * touch pane. Needed especially if a dialog is on the screen and 
williamr@2
   385
         * toolbar is not wished to be shown. Leaves with value KErrToolbarShown
williamr@2
   386
         * if called when toolbar is shown. 
williamr@2
   387
         * 
williamr@2
   388
         * @param aDisable ETrue if toolbar should be disabled 
williamr@2
   389
         * 
williamr@2
   390
         * @since S60 3.2
williamr@2
   391
         */
williamr@2
   392
        IMPORT_C void DisableToolbarL( TBool aDisable ); 
williamr@2
   393
williamr@2
   394
        /**
williamr@2
   395
         * Checks if toolbar is disabled. 
williamr@2
   396
         * 
williamr@2
   397
         * @return ETrue if toolbar is disabled, EFalse if not 
williamr@2
   398
         * 
williamr@2
   399
         * @since S60 3.2
williamr@2
   400
         */
williamr@2
   401
        IMPORT_C TBool IsToolbarDisabled() const; 
williamr@2
   402
        
williamr@2
   403
        /**
williamr@2
   404
         * Moves highlight from one item to another. Leaves with 
williamr@2
   405
         * value KErrNotFound if item not found. 
williamr@2
   406
         * 
williamr@2
   407
         * @param aCommandId command id of the item to be focused.           
williamr@2
   408
         * 
williamr@2
   409
         * @since S60 3.2
williamr@2
   410
         */
williamr@2
   411
        IMPORT_C void SetFocusedItemL( const TInt aCommandId ); 
williamr@2
   412
williamr@2
   413
        /**
williamr@2
   414
         * Returns command id of focused item. 
williamr@2
   415
         * 
williamr@2
   416
         * @return command id of focused item. Returns KErrNotFound if 
williamr@2
   417
         * no item is focused. 
williamr@2
   418
         * 
williamr@2
   419
         * @since S60 3.2
williamr@2
   420
         */
williamr@2
   421
        IMPORT_C TInt FocusedItem() const; 
williamr@2
   422
williamr@2
   423
        /**
williamr@2
   424
         * Takes focus away from edwin or other controls if needed. Called by 
williamr@2
   425
         * AknAppUi from HandleWsEventL when a pointer event is targeted to 
williamr@2
   426
         * other control than toolbar. 
williamr@2
   427
         * 
williamr@2
   428
         * @since S60 3.2
williamr@2
   429
         */
williamr@2
   430
        void PrepareForFocusLossL(); 
williamr@2
   431
williamr@2
   432
        /**
williamr@2
   433
         * Returns event modifiers defined in TEventModifiers in this header. 
williamr@2
   434
         * This can be used by applications in OfferToolbarEventL to know if 
williamr@2
   435
         * the event sent was for example a long press event. Information is
williamr@2
   436
         * valid only during OfferToolbarEventL. 
williamr@2
   437
         * 
williamr@2
   438
         * @return event modifiers
williamr@2
   439
         * @since S60 3.2
williamr@2
   440
         */
williamr@2
   441
        IMPORT_C TInt EventModifiers() const; 
williamr@2
   442
williamr@2
   443
        /**
williamr@2
   444
         * Returns the flags of toolbar. Flags are defined in eikon.hrh.  
williamr@2
   445
         * @return toolbar flags
williamr@2
   446
         * @since S60 3.2
williamr@2
   447
         */
williamr@2
   448
        IMPORT_C TInt ToolbarFlags() const; 
williamr@2
   449
williamr@2
   450
        /*
williamr@2
   451
         * Count faded components
williamr@2
   452
         * @return then number of faded components
williamr@2
   453
         */
williamr@2
   454
        TInt CountFadedComponents(); 
williamr@2
   455
williamr@2
   456
        /*
williamr@2
   457
         * Returns faded components by index
williamr@2
   458
         * @return faded component
williamr@2
   459
         */
williamr@2
   460
        CCoeControl* FadedComponent( TInt aIndex ); 
williamr@2
   461
williamr@2
   462
        /*
williamr@2
   463
         * Reduces main pane rect if it intersects with toolbar's rect
williamr@2
   464
         * @param aBoundingRect the rect to reduce
williamr@2
   465
         */
williamr@2
   466
        void ReduceRect( TRect& aBoundingRect ) const; 
williamr@2
   467
williamr@2
   468
        /**
williamr@2
   469
         * Sets the resource id for toolbar softkeys. If cba allready exists 
williamr@2
   470
         * then changes the existing softkeys and redraws toolbar cba.  
williamr@2
   471
         * @param aSoftkeyResourceId ID of the resource structure specifying 
williamr@2
   472
         * the command buttons.
williamr@2
   473
         * @since S60 3.2
williamr@2
   474
         */
williamr@2
   475
        IMPORT_C void SetSoftkeyResourceIdL( TInt aSoftkeyResourceId ); 
williamr@2
   476
williamr@2
   477
        /**
williamr@2
   478
         * Extension notifies of its events using this method
williamr@2
   479
         * aCommandId command id of the button
williamr@2
   480
         */
williamr@2
   481
        void ExtensionEventL( TInt aCommandId ); 
williamr@2
   482
williamr@2
   483
        /**
williamr@2
   484
         * Returns the index of the toolbar item inside of the iVisibleItems
williamr@2
   485
         * array.
williamr@2
   486
         *
williamr@2
   487
         * @param aControl The control which index is needed.
williamr@2
   488
         * @return Index of the toolbar item.
williamr@2
   489
         */
williamr@2
   490
        TInt ToolbarVisibleIndexByControl( const CCoeControl* aControl ) const;
williamr@2
   491
williamr@2
   492
        /**
williamr@2
   493
         * Returns pointer to toolbar extension if available
williamr@2
   494
         * @return toolbar extension or NULL
williamr@2
   495
         */
williamr@2
   496
        IMPORT_C CAknToolbarExtension* ToolbarExtension() const;  		
williamr@2
   497
williamr@2
   498
        /**
williamr@2
   499
         * Calls DynInitToolbar with extensions commmand id
williamr@2
   500
         * 
williamr@2
   501
         */
williamr@2
   502
        void DynInitExtensionL( CCoeControl* aControl ); 
williamr@2
   503
williamr@2
   504
        /**
williamr@2
   505
         * Callback for sliding toolbar.
williamr@2
   506
         */
williamr@2
   507
        static TInt ReadyToSlide( TAny* aThis ); 
williamr@2
   508
williamr@2
   509
        /**
williamr@2
   510
         * Slide toolbar
williamr@2
   511
         */
williamr@2
   512
        void SlideWithIdle(); 
williamr@2
   513
williamr@2
   514
        /**
williamr@2
   515
         * Hides/Unhides toolbar items temporarily. When called with ETrue 
williamr@2
   516
         * toolbar draws just background in landscape and is hidden in portrait. 
williamr@2
   517
         * Calling with EFalse returns the situation to normal, so drawing the 
williamr@2
   518
         * items normally in portrait and landscape. Use this method only with
williamr@2
   519
         * fixed toolbar! 
williamr@2
   520
         *  
williamr@2
   521
         * @param aHide ETrue if hiding items, EFalse if unhiding.  
williamr@2
   522
         */
williamr@2
   523
        IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide ); 
williamr@2
   524
williamr@2
   525
        /**
williamr@2
   526
         * Hides/Unhides toolbar items temporarily. When called with ETrue
williamr@2
   527
         * toolbar draws just background in landscape and is hidden in portrait. 
williamr@2
   528
         * Toolbar window priority is changed to priority passed in parameter.
williamr@2
   529
         * Priority should be one of the window priority values defined in 
williamr@2
   530
         * TCoeWinPriority. Default priority is ECoeWinPriorityLow.
williamr@2
   531
         * Note that if toolbar is already hidden, the toolbar window priority
williamr@2
   532
         * is still changed to priority passed in parameter.
williamr@2
   533
         * Calling the function HideItemsAndDrawOnlyBackground with EFalse returns
williamr@2
   534
         * the situation to normal, so drawing the items normally in portrait 
williamr@2
   535
         * and landscape. Use this method only with fixed toolbar! 
williamr@2
   536
         *  
williamr@2
   537
         * @param aHide ETrue if hiding items, EFalse if unhiding.
williamr@2
   538
         * @param aPriority Ordinal priority of toolbar window.  
williamr@2
   539
         */
williamr@2
   540
        IMPORT_C void HideItemsAndDrawOnlyBackground( TBool aHide, TInt aPriority ); 
williamr@2
   541
williamr@2
   542
williamr@2
   543
    protected: // From base class
williamr@2
   544
williamr@2
   545
        /**
williamr@2
   546
         * From CCoeControl.
williamr@2
   547
         * Responds to size changes to sets the size and position of 
williamr@2
   548
         * the contents of this control.
williamr@2
   549
         */
williamr@2
   550
        IMPORT_C void SizeChanged();
williamr@2
   551
williamr@2
   552
        /**
williamr@2
   553
         * From CCoeControl.
williamr@2
   554
         * This function is called whenever a control gains or loses focus.
williamr@2
   555
         *
williamr@2
   556
         * @param aDrawNow Contains the value that was passed to it by SetFocus().
williamr@2
   557
         */
williamr@2
   558
        IMPORT_C void FocusChanged( TDrawNow aDrawNow );
williamr@2
   559
williamr@2
   560
        /**
williamr@2
   561
         * From CAknControl.
williamr@2
   562
         * For future extensions.
williamr@2
   563
         *
williamr@2
   564
         * @param aInterface The ID for the extension interface.
williamr@2
   565
         */
williamr@2
   566
        IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2
   567
williamr@2
   568
        /**
williamr@2
   569
         * From CCoeControl.
williamr@2
   570
         * Retrieves an object of the same type as that encapsulated in aId.
williamr@2
   571
         *
williamr@2
   572
         * @param aId An encapsulated object type ID.
williamr@2
   573
         * @return Encapsulated pointer to the object provided. 
williamr@2
   574
         *      Note that the encapsulated pointer may be NULL.
williamr@2
   575
         */
williamr@2
   576
        IMPORT_C TTypeUid::Ptr MopSupplyObject( TTypeUid aId );
williamr@2
   577
williamr@2
   578
    private: // Constructors
williamr@2
   579
williamr@2
   580
        /**
williamr@2
   581
         * C++ default constructor.
williamr@2
   582
         */
williamr@2
   583
        CAknToolbar();
williamr@2
   584
williamr@2
   585
        /**
williamr@2
   586
         * Symbian 2nd phase constructor.
williamr@2
   587
         */
williamr@2
   588
        void ConstructL();
williamr@2
   589
williamr@2
   590
    private: // From base class
williamr@2
   591
williamr@2
   592
        /**
williamr@2
   593
         * From CCoeControl.
williamr@2
   594
         * Constructs controls from a resource file.
williamr@2
   595
         * Hides the one defined in base class.
williamr@2
   596
         *
williamr@2
   597
         * @param aReader The resource reader with which to access
williamr@2
   598
         *      the control's resource values.
williamr@2
   599
         */
williamr@2
   600
        IMPORT_C void ConstructFromResourceL( TResourceReader& aReader );
williamr@2
   601
williamr@2
   602
        /**
williamr@2
   603
         * From CCoeControl.
williamr@2
   604
         * Draw a control called by window server.
williamr@2
   605
         *
williamr@2
   606
         * @param aRect The region of the control to be redrawn. 
williamr@2
   607
         *      Co-ordinates are relative to the control's origin (top left corner).
williamr@2
   608
         */
williamr@2
   609
        IMPORT_C void Draw( const TRect& aRect ) const;
williamr@2
   610
williamr@2
   611
    private: // New functions
williamr@2
   612
williamr@2
   613
        /**
williamr@2
   614
         * Constructs controls from a resource file.
williamr@2
   615
         *
williamr@2
   616
         * @param aResourceId The ID for this component's resource.
williamr@2
   617
         */
williamr@2
   618
        void ConstructFromResourceL( const TInt aResourceId );
williamr@2
   619
williamr@2
   620
        /**
williamr@2
   621
         * Constructs one of the toolbar items.
williamr@2
   622
         *
williamr@2
   623
         * @param aReader The resource reader with which to access the control's
williamr@2
   624
         *      resource values.
williamr@2
   625
         * @return Constructed toolbar item.
williamr@2
   626
         */
williamr@2
   627
        CAknToolbarItem* ConstructControlLC( TResourceReader& aReader );
williamr@2
   628
williamr@2
   629
        /**
williamr@2
   630
         * Calculates size and position of the toolbar depending on the
williamr@2
   631
         * number and size of the toolbar items.
williamr@2
   632
         *
williamr@2
   633
         * @return Toolbar rectangular.
williamr@2
   634
         */
williamr@2
   635
        TRect CalculateSizeAndPosition();
williamr@2
   636
williamr@2
   637
        /**
williamr@2
   638
         * Calculates rects that are used in calculating the size
williamr@2
   639
         * and position of the toolbar items
williamr@2
   640
         *
williamr@2
   641
         * @param aMainPaneRect main pane rect
williamr@2
   642
         * @param aToolbarRect rect for toolbar
williamr@2
   643
         * @param aGridPaneRect rect for grid pane
williamr@2
   644
         * @param aCellPaneRect rect for cell pane
williamr@2
   645
         */
williamr@2
   646
        void CalculateRects( TRect& aMainPaneRect, TRect& aToolbarRect,
williamr@2
   647
            TRect& aGridPaneRect, TRect& aCellPaneRect );
williamr@2
   648
williamr@2
   649
        /**
williamr@2
   650
         * Calculates the position and size of the control rect
williamr@2
   651
         * 
williamr@2
   652
         * @param aCurrentCellPaneRect current cell pane rect is needed to 
williamr@2
   653
         * get correct control rect from layout data. 
williamr@2
   654
         * @return control rect for the toolbar item
williamr@2
   655
         */
williamr@2
   656
        TRect CalculateControlRect( TRect& aCurrentCellPaneRect ); 
williamr@2
   657
williamr@2
   658
        /**
williamr@2
   659
         * Checks the number of visible items, and if too few the toolbar CBA is
williamr@2
   660
         * deleted. If last time there were too few items then toolbar CBA is 
williamr@2
   661
         * created again. Also the ordinal position of the toolbar is set if 
williamr@2
   662
         * there are changes to previous situation. 
williamr@2
   663
         * 
williamr@2
   664
         * @return ETrue if too few items are visible, EFalse if not 
williamr@2
   665
         */
williamr@2
   666
        TBool TooFewItemsVisible(); 
williamr@2
   667
williamr@2
   668
        /**
williamr@2
   669
         * Returns toolbar item object for the specified control.
williamr@2
   670
         *
williamr@2
   671
         * @param aControl Pointer to the control.
williamr@2
   672
         * @return Pointer to the toolbar item.
williamr@2
   673
         */
williamr@2
   674
        CAknToolbarItem* ToolbarItemByControl( const CCoeControl* aControl ) const;
williamr@2
   675
williamr@2
   676
        /**
williamr@2
   677
         * Returns toolbar item object for the specified command ID.
williamr@2
   678
         *
williamr@2
   679
         * @param aId The command ID of the item.
williamr@2
   680
         * @return Pointer to the toolbar item.
williamr@2
   681
         */
williamr@2
   682
        CAknToolbarItem* ToolbarItemById( const TInt aId ) const;
williamr@2
   683
williamr@2
   684
        /**
williamr@2
   685
         * Returns the index of the toolbar item inside of the iItems array.
williamr@2
   686
         *
williamr@2
   687
         * @param aId The command ID of the item
williamr@2
   688
         * @return Index of the toolbar item.
williamr@2
   689
         */
williamr@2
   690
        TInt ToolbarItemIndexById( const TInt aId ) const;
williamr@2
   691
williamr@2
   692
        /**
williamr@2
   693
         * Returns the index of the toolbar item inside of the iItems array.
williamr@2
   694
         *
williamr@2
   695
         * @param aControl The control which index is needed.
williamr@2
   696
         * @return Index of the toolbar item.
williamr@2
   697
         */
williamr@2
   698
        TInt ToolbarItemIndexByControl( const CCoeControl* aControl ) const;
williamr@2
   699
williamr@2
   700
        /**
williamr@2
   701
         * Returns the index of the toolbar item inside of the iVisibleItems
williamr@2
   702
         * array.
williamr@2
   703
         *
williamr@2
   704
         * @param aId The command ID of the item.
williamr@2
   705
         * @return Index of the toolbar item.
williamr@2
   706
         */
williamr@2
   707
        TInt ToolbarVisibleIndexById( const TInt aId ) const;  
williamr@2
   708
williamr@2
   709
        /**
williamr@2
   710
         * Draws toolbar with sliding effect.
williamr@2
   711
         *
williamr@2
   712
         * @param aEndPos The position of the top left corner of toolbar at 
williamr@2
   713
         * the end of animation.
williamr@2
   714
         */
williamr@2
   715
        void SlideToolbar( const TPoint& aEndPos );
williamr@2
   716
williamr@2
   717
        /**
williamr@2
   718
         * Changes CBA text if all items are dimmed.
williamr@2
   719
         */
williamr@2
   720
        void SetRightCbaTextL();
williamr@2
   721
williamr@2
   722
        /**
williamr@2
   723
         * Returns next non-dimmed and non-hidden control index.
williamr@2
   724
         *
williamr@2
   725
         * @param aStartIndex The index of the item from which the search
williamr@2
   726
         *      should be started.
williamr@2
   727
         * @param aMoveForward ETrue if search is done from lower index to
williamr@2
   728
         *      the higher one.
williamr@2
   729
         * @return The index of next non-dimmed and non-hidden item.
williamr@2
   730
         */
williamr@2
   731
        TInt GetNextSelectableItemIndex( TInt aStartIndex,
williamr@2
   732
                                        TBool aMoveForward );
williamr@2
   733
williamr@2
   734
        /**
williamr@2
   735
         * Moves highlight from one item to another. It also will change 
williamr@2
   736
         * softkey text for the focused toolbar.
williamr@2
   737
         *
williamr@2
   738
         * @param aItemIndex The index for the newly focused item.
williamr@2
   739
         * @param aDrawNow Specifies whether the item should be redrawn.
williamr@2
   740
         * @param aMoveForward Specifies whether the next item in the array
williamr@2
   741
         *      should be selected when the item with aItemIndex is dimmed.
williamr@2
   742
         * @param aPrepareControl Specifies whether PrepareForFocusLossL() or
williamr@2
   743
         *      PrepareForFocusGainL() functions should be called.
williamr@2
   744
         */
williamr@2
   745
        void MoveHighlightL( TInt aItemIndex,
williamr@2
   746
                              const TBool aDrawNow,
williamr@2
   747
                              const TBool aMoveForward = ETrue,
williamr@2
   748
                              const TBool aPrepareControl = ETrue );
williamr@2
   749
williamr@2
   750
        /**
williamr@2
   751
         * Makes toolbar visible and activates it. Position of the top left 
williamr@2
   752
         * corner should be set in advance. Also use SetFocus() to specify
williamr@2
   753
         * whether toolbar gets key events or not.
williamr@2
   754
         */
williamr@2
   755
        void ShowToolbarL();
williamr@2
   756
williamr@2
   757
        /**
williamr@2
   758
         * Hides toolbar.
williamr@2
   759
         */
williamr@2
   760
        void HideToolbarL();
williamr@2
   761
williamr@2
   762
        /**
williamr@2
   763
         * Sets the focus to the middle or the first item, depending on the
williamr@2
   764
         * toolbar flags.
williamr@2
   765
         *
williamr@2
   766
         * @param aDrawNow if the newly focused item should be redrawn.
williamr@2
   767
         */
williamr@2
   768
        void InitFocusedItemL( const TBool aDrawNow );
williamr@2
   769
williamr@2
   770
        /**
williamr@2
   771
         * Sets the flag to be on or off and also calls
williamr@2
   772
         * CCoeControl::MakeVisible().
williamr@2
   773
         */
williamr@2
   774
        void SetShown( const TBool aShown );
williamr@2
   775
williamr@2
   776
        /**
williamr@2
   777
         * Selects/deselects the toolbar item at given index.
williamr@2
   778
         */
williamr@2
   779
        void SelectItemL( const TInt aIndex, const TBool aSelect );
williamr@2
   780
williamr@2
   781
        /**
williamr@2
   782
         * Gets rect from layout data.
williamr@2
   783
         */
williamr@2
   784
        TRect RectFromLayout( const TRect& aParent,
williamr@2
   785
            const TAknWindowComponentLayout& aComponentLayout ) const;
williamr@2
   786
        
williamr@2
   787
        /**
williamr@2
   788
         * Callback to get notified when ready to show toolbar again
williamr@2
   789
         */
williamr@2
   790
        static TInt WaitForScreenSwitch(TAny* aThis); 
williamr@2
   791
williamr@2
   792
        /**
williamr@2
   793
         * Hides toolbar so that screen capture can be taken from the 
williamr@2
   794
         * background in order to update it. 
williamr@2
   795
         */
williamr@2
   796
        void HideToolbarForBackgroundUpdate(); 
williamr@2
   797
        
williamr@2
   798
        /**
williamr@2
   799
         * Updates control positions so that tooltips are positioned correctly
williamr@2
   800
         */
williamr@2
   801
        void UpdateControlPositions();
williamr@2
   802
williamr@2
   803
        /**
williamr@2
   804
        * Shows toolbar via CIdle. As a result, toolbar's window priority is 
williamr@2
   805
        * setted after the application's container window. This places toolbar
williamr@2
   806
        * to the right place in the window tree.
williamr@2
   807
        */
williamr@2
   808
        void ShowViaIdle();
williamr@2
   809
        
williamr@2
   810
        /**
williamr@2
   811
        * Callback for delayed toolbar showing.
williamr@2
   812
        */
williamr@2
   813
        static TInt ShowDelayedToolbar( TAny* aThis );
williamr@2
   814
williamr@2
   815
        /**
williamr@2
   816
         * Modifies highlight bitmap that is 50% transparent to use when drawing 
williamr@2
   817
         * highlight for small transparent toolbar. 
williamr@2
   818
         */
williamr@2
   819
        void ModifyHighlightMaskL( TBool aCreateBitmaps );
williamr@2
   820
williamr@2
   821
        /**
williamr@2
   822
         * Fades behind toolbar
williamr@2
   823
         * @param aFade if ETrue then fade
williamr@2
   824
         */
williamr@2
   825
        void FadeBehindPopup( TBool aFade ); 
williamr@2
   826
williamr@2
   827
        /**
williamr@2
   828
         * Sets buttons to check their touchable areas when tapped 
williamr@2
   829
         */
williamr@2
   830
        void CheckHitAreas( ); 
williamr@2
   831
williamr@2
   832
        /**
williamr@2
   833
         * Counts buttons of fixed tool bar and adds button(s) if needed
williamr@2
   834
         * There has to bee at leas three buttons in fixed toolbar.
williamr@2
   835
         */
williamr@2
   836
        void CheckFixedToolbarButtonsL();
williamr@2
   837
williamr@2
   838
        /**
williamr@2
   839
         * Draws backgrounds of fixed toolbar
williamr@2
   840
         * @param aGc Graphics context used for drawing.
williamr@2
   841
         * @param aControl The control being drawn (may be a child of the drawer).
williamr@2
   842
         * @param aRect The area to be drawn.
williamr@2
   843
         */
williamr@2
   844
        void DrawFixedBackgroundL( CWindowGc& aGc, 
williamr@2
   845
                                   const CCoeControl& aControl, 
williamr@2
   846
                                   const TRect& aRect ) const;
williamr@2
   847
                                   
williamr@2
   848
        /**
williamr@2
   849
        * Adjusts button's properties depending on the toolbar's features.
williamr@2
   850
        */                                   
williamr@2
   851
        void AdjustButton( CAknButton& aButton );
williamr@2
   852
        
williamr@2
   853
        /**
williamr@2
   854
        * Adjusts all buttons' properties depending on the toolbar's features.
williamr@2
   855
        */
williamr@2
   856
        void AdjustAllButtons();
williamr@2
   857
        
williamr@2
   858
        /**
williamr@2
   859
        * Adjusts toolbar's and overlying dialog's window positions so that
williamr@2
   860
        * dialog is displayed on top of the toolbar.
williamr@2
   861
        */
williamr@2
   862
        void SetOrdinalPositions() const;
williamr@2
   863
williamr@2
   864
        /**
williamr@2
   865
        * Updates control visibility based on toolbar visibility and 
williamr@2
   866
        * buttons visibility inside toolbar.
williamr@2
   867
        */
williamr@2
   868
        void UpdateControlVisibility();
williamr@2
   869
	
williamr@2
   870
    private: // Member variables
williamr@2
   871
williamr@2
   872
        // Array for toolbar items
williamr@2
   873
        RPointerArray<CAknToolbarItem> iItems;
williamr@2
   874
williamr@2
   875
        // Array for visible toolbar items
williamr@2
   876
        RPointerArray<CAknToolbarItem> iVisibleItems;
williamr@2
   877
williamr@2
   878
        // Toolbar flags
williamr@2
   879
        TInt iFlags;
williamr@2
   880
williamr@2
   881
        // Observer to report toolbar item events, not owned
williamr@2
   882
        MAknToolbarObserver* iToolbarObserver;
williamr@2
   883
williamr@2
   884
        // Index of focused item, used with focusable toolbar
williamr@2
   885
        TInt iFocusedItem;
williamr@2
   886
williamr@2
   887
        // Index of selected item, used with focusable and non-focusable toolbar
williamr@2
   888
        TInt iSelectedItem;
williamr@2
   889
williamr@2
   890
        // Toolbar cba, used with focusable toolbar
williamr@2
   891
        // own
williamr@2
   892
        CEikButtonGroupContainer* iToolbarCba;
williamr@2
   893
williamr@2
   894
        // Resource id for toolbar
williamr@2
   895
        TInt iToolbarResourceId;
williamr@2
   896
williamr@2
   897
        // The default focused item
williamr@2
   898
        TInt iInitialFocusedItem;
williamr@2
   899
williamr@2
   900
        // Last focused item before focus was lost
williamr@2
   901
        TInt iLastFocusedItem;
williamr@2
   902
williamr@2
   903
        // Toolbar frame context
williamr@2
   904
        // own
williamr@2
   905
        CAknsFrameBackgroundControlContext* iFrameContext;
williamr@2
   906
williamr@2
   907
        // Toolbar background context
williamr@2
   908
        // own
williamr@2
   909
        CAknsBasicBackgroundControlContext* iBgContext;
williamr@2
   910
        
williamr@2
   911
        // Toolbar orientation
williamr@2
   912
        TAknOrientation iOrientation;
williamr@2
   913
        
williamr@2
   914
        // Transparency bitmap
williamr@2
   915
        // own
williamr@2
   916
        CFbsBitmap* iBgBitmap;
williamr@2
   917
williamr@2
   918
        // This is used to call ShowToolbarForBackgroundChange after toolbar has
williamr@2
   919
        // been hidden 
williamr@2
   920
        // own
williamr@2
   921
        CIdle* iIdle;
williamr@2
   922
        
williamr@2
   923
        // Highlight bitmap
williamr@2
   924
        CFbsBitmap* iHighlightBitmap; 
williamr@2
   925
williamr@2
   926
        // Highlight mask 
williamr@2
   927
        CFbsBitmap* iHighlightMask; 
williamr@2
   928
        
williamr@2
   929
        // event modifiers
williamr@2
   930
        TInt iEventModifiers; 
williamr@2
   931
	
williamr@2
   932
	    // Background fader
williamr@2
   933
        TAknPopupFader iFader;
williamr@2
   934
	    
williamr@2
   935
	    // Softkey resource
williamr@2
   936
        TInt iSoftkeyResource; 
williamr@2
   937
	    
williamr@2
   938
        // Used to store previous item that had pointerevents
williamr@2
   939
        TInt iPreviousItem;
williamr@2
   940
williamr@2
   941
	    // Step for toolbar sliding
williamr@2
   942
	    TInt iStep; 
williamr@2
   943
williamr@2
   944
	    // End position for toolbar sliding 
williamr@2
   945
	    TInt iEndPos;
williamr@2
   946
	    
williamr@2
   947
	    // Internal flags used to store toolbar's properties
williamr@2
   948
	    TBitFlags iInternalFlags;
williamr@2
   949
	    
williamr@2
   950
	    // Background area to be drawn when not enough visible items
williamr@2
   951
	    // to cover the toolbar area
williamr@2
   952
	    TRect iBgRect;
williamr@2
   953
williamr@2
   954
        // Toolbar window priority if set in HideItemsAndDrawOnlyBackground
williamr@2
   955
	    TInt iDrawingPriority;
williamr@2
   956
williamr@2
   957
    };
williamr@2
   958
williamr@2
   959
#endif // __AKNTOOLBAR_H__
williamr@2
   960
williamr@2
   961
// End of File