epoc32/include/mw/akntoolbarextension.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 2 2fe1408b6811
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 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@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@2
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.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:  Toolbar extension component
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
#ifndef CAKNTOOLBAREXTENSION_H
williamr@2
    20
#define CAKNTOOLBAREXTENSION_H
williamr@2
    21
williamr@2
    22
#include <aknbutton.h>
williamr@2
    23
williamr@2
    24
class CAknToolbarItem;
williamr@2
    25
class CAknToolbarExtensionView;
williamr@2
    26
class CAknToolbar; 
williamr@2
    27
williamr@2
    28
williamr@2
    29
/**
williamr@2
    30
 *  Toolbar extension. 
williamr@2
    31
 *
williamr@2
    32
 *  Toolbar extension component. Opens an extension view when this extension
williamr@2
    33
 *  is pressed.   
williamr@2
    34
 *
williamr@2
    35
 *  @lib eikcoctl
williamr@2
    36
 *  @since S60 v5.0
williamr@2
    37
 */
williamr@2
    38
NONSHARABLE_CLASS( CAknToolbarExtension ) : public CAknButton, 
williamr@2
    39
    public MCoeControlObserver
williamr@2
    40
    {
williamr@2
    41
williamr@2
    42
public:
williamr@2
    43
williamr@2
    44
    /**
williamr@2
    45
     * Creates toolbar extension
williamr@2
    46
     *
williamr@2
    47
     * @return extension
williamr@2
    48
     */
williamr@2
    49
    static CAknToolbarExtension* NewL( );
williamr@2
    50
williamr@2
    51
williamr@2
    52
    /**
williamr@2
    53
     * Creates toolbar extension
williamr@2
    54
     *
williamr@2
    55
     * @param aResourceid The ID for this component's resource
williamr@2
    56
     * @return extension
williamr@2
    57
     */
williamr@2
    58
    IMPORT_C static CAknToolbarExtension* NewL( TInt aResourceId );
williamr@2
    59
williamr@2
    60
williamr@2
    61
    /**
williamr@2
    62
     * Creates toolbar extension
williamr@2
    63
     *
williamr@2
    64
     * @param aResourceid The ID for this component's resource
williamr@2
    65
     * @return extension
williamr@2
    66
     */
williamr@2
    67
    IMPORT_C static CAknToolbarExtension* NewLC( TInt aResourceId );
williamr@2
    68
williamr@2
    69
    /**
williamr@2
    70
     * Destructor
williamr@2
    71
     */
williamr@2
    72
    ~CAknToolbarExtension();
williamr@2
    73
williamr@2
    74
// from base class CCoeControl
williamr@2
    75
williamr@2
    76
    /**
williamr@2
    77
     * From CAknButton
williamr@2
    78
     * constructs the extension from resource
williamr@2
    79
     *
williamr@2
    80
     * @param aReader resource reader
williamr@2
    81
     */
williamr@2
    82
    void ConstructFromResourceL( TResourceReader& aReader );
williamr@2
    83
williamr@2
    84
    /**
williamr@2
    85
     * From CCoeControl
williamr@2
    86
     * 
williamr@2
    87
     * @param aKeyEvent information about the key event
williamr@2
    88
     * @param aType type of the key event
williamr@2
    89
     * @return boolean indicating if key event was consumed or not
williamr@2
    90
     */
williamr@2
    91
    TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );
williamr@2
    92
williamr@2
    93
    /**
williamr@2
    94
     * From CCoeControl
williamr@2
    95
     * Handles resource changes
williamr@2
    96
     *
williamr@2
    97
     * @param aType the type of the resource change
williamr@2
    98
     */
williamr@2
    99
    void HandleResourceChange( TInt aType ); 
williamr@2
   100
williamr@2
   101
    /**
williamr@2
   102
     * From CCoeControl.
williamr@2
   103
     * Makes extension and extension view visible or hides them
williamr@2
   104
     *
williamr@2
   105
     * @param aVisible boolean to tell if showing or hiding
williamr@2
   106
     */
williamr@2
   107
    void MakeVisible( TBool aVisible ); 
williamr@2
   108
williamr@2
   109
williamr@2
   110
// from base class MCoeControlObserver
williamr@2
   111
williamr@2
   112
    /**
williamr@2
   113
     * From MCoeControlObserver.
williamr@2
   114
     * Here the events from the extension itself and extension view components
williamr@2
   115
     * are handled
williamr@2
   116
     *
williamr@2
   117
     * @param aControl control that sent this event
williamr@2
   118
     * @param aEventType type of the event
williamr@2
   119
     */
williamr@2
   120
    void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
williamr@2
   121
williamr@2
   122
williamr@2
   123
// new functions
williamr@2
   124
    
williamr@2
   125
    /**
williamr@2
   126
     * Using this the extension view can get extension position in fixed toolbar
williamr@2
   127
     *
williamr@2
   128
     * @return index of the position
williamr@2
   129
     */
williamr@2
   130
    TInt ExtensionPosition(); 
williamr@2
   131
williamr@2
   132
    /**
williamr@2
   133
     * Creates idle if it does not exist yet and calls it by giving 
williamr@2
   134
     * a callback for notifying when ready to draw extension view. 
williamr@2
   135
     */
williamr@2
   136
    void ShowViewViaIdle(); 
williamr@2
   137
williamr@2
   138
    /**
williamr@2
   139
     * Callback to get notified when ready to show extension view again
williamr@2
   140
     * @param aThis pointer to this object
williamr@2
   141
     * @return error code
williamr@2
   142
     */
williamr@2
   143
    static TInt ShowView( TAny* aThis ); 
williamr@2
   144
williamr@2
   145
    /**
williamr@2
   146
     * Extension view tells extension to change state using this method. This is 
williamr@2
   147
     * used when tapping outside extension view. 
williamr@2
   148
     */
williamr@2
   149
    void ViewClosed(); 
williamr@2
   150
williamr@2
   151
    /**
williamr@2
   152
     * Gets a pointer to the specified control.
williamr@2
   153
     *
williamr@2
   154
     * @param aControlId The ID of the control for which a pointer is required.
williamr@2
   155
     * @return Pointer to the control with the specified ID.
williamr@2
   156
     */
williamr@2
   157
    IMPORT_C CCoeControl* ControlOrNull( TInt aCommandId ) const; 
williamr@2
   158
williamr@2
   159
    /**
williamr@2
   160
     * Adds one item to the specified place. Takes ownership. Leaves with 
williamr@2
   161
     * value KErrNotSupported, if called when extension view is shown and 
williamr@2
   162
     * with KErrArgument if aItem does not exist or aIndex is out of bound. 
williamr@2
   163
     *
williamr@2
   164
     * @param aItem The control.
williamr@2
   165
     * @param aType The type of the new toolbar item.
williamr@2
   166
     * @param aCommandId The command ID for this item.
williamr@2
   167
     * @param aFlags The flags.
williamr@2
   168
     * @param aIndex The index in array at which item should be added.
williamr@2
   169
     */
williamr@2
   170
    IMPORT_C void AddItemL( CCoeControl* aItem,
williamr@2
   171
                            TInt aType,
williamr@2
   172
                            TInt aCommandId,
williamr@2
   173
                            TInt aFlags,
williamr@2
   174
                            TInt aIndex );
williamr@2
   175
williamr@2
   176
williamr@2
   177
    /**
williamr@2
   178
     * Removes one item from the extension view. Leaves with value 
williamr@2
   179
     * KErrNotSupported if called when extension view is shown. 
williamr@2
   180
     *
williamr@2
   181
     * @param aCommandId The ID of the item which should be removed.
williamr@2
   182
     */
williamr@2
   183
    IMPORT_C void RemoveItemL( TInt aCommandId );
williamr@2
   184
williamr@2
   185
    /**
williamr@2
   186
     * Gets extension flags
williamr@2
   187
     * 
williamr@2
   188
     * @return extension flags
williamr@2
   189
     */
williamr@2
   190
    TInt ExtensionFlags(); 
williamr@2
   191
williamr@2
   192
    /**
williamr@2
   193
     * Returns boolean indicating if extension view is shown. 
williamr@2
   194
     * 
williamr@2
   195
     * @return ETrue if shown, EFalse if not
williamr@2
   196
     */
williamr@2
   197
    IMPORT_C TBool IsShown() const; 
williamr@2
   198
williamr@2
   199
    /**
williamr@2
   200
     * Shows or hides extension view. 
williamr@2
   201
     * 
williamr@2
   202
     * @param aShown to show or to hide 
williamr@2
   203
     */
williamr@2
   204
    IMPORT_C void SetShown( TBool aShown ); 
williamr@2
   205
williamr@2
   206
    /**
williamr@2
   207
     * Returns pointer to extension view
williamr@2
   208
     * 
williamr@2
   209
     * @return pointer to extension view
williamr@2
   210
     */
williamr@2
   211
    CCoeControl* ExtensionView(); 
williamr@2
   212
williamr@2
   213
    /**
williamr@2
   214
     * Sets item dimmed or undimmed
williamr@2
   215
     * 
williamr@2
   216
     * @param aCommandId command id of the item to be dimmed/undimmed 
williamr@2
   217
     * @param aDimmed to dim or undim
williamr@2
   218
     */
williamr@2
   219
    IMPORT_C void SetItemDimmed( TInt aCommandId, TBool aDimmed ); 
williamr@2
   220
williamr@2
   221
    /**
williamr@2
   222
     * Hides or unhides item. Leaves with value KErrNotSupported if called
williamr@2
   223
     * when extension view is shown. 
williamr@2
   224
     * 
williamr@2
   225
     * @param aCommandId command id of the item to be hidden/unhidden 
williamr@2
   226
     * @param aHide to hide or unhide
williamr@2
   227
     */
williamr@2
   228
    IMPORT_C void HideItemL( TInt aCommandId, TBool aHide ); 
williamr@2
   229
williamr@2
   230
private:
williamr@2
   231
williamr@2
   232
    /**
williamr@2
   233
     * Constructor
williamr@2
   234
     */
williamr@2
   235
    CAknToolbarExtension();
williamr@2
   236
williamr@2
   237
    /**
williamr@2
   238
     * Constructs the extension button by adding button states with icons
williamr@2
   239
     */
williamr@2
   240
    void BaseConstructL();
williamr@2
   241
williamr@2
   242
    /**
williamr@2
   243
     * Constructs a control from resource
williamr@2
   244
     *
williamr@2
   245
     * @param aResourceId The id for this component's resource.
williamr@2
   246
     */
williamr@2
   247
    void ConstructFromResourceL( const TInt aResourceId );  
williamr@2
   248
williamr@2
   249
private: // data
williamr@2
   250
williamr@2
   251
    /**
williamr@2
   252
     * Pointer to extension view. 
williamr@2
   253
     * Own.  
williamr@2
   254
     */
williamr@2
   255
    CAknToolbarExtensionView* iView;
williamr@2
   256
williamr@2
   257
    /**
williamr@2
   258
     * Pointer to toolbar, so that extension can notify toolbar about 
williamr@2
   259
     * extension events   
williamr@2
   260
     * Not own. 
williamr@2
   261
     */
williamr@2
   262
    CAknToolbar* iToolbar; 
williamr@2
   263
williamr@2
   264
    /**
williamr@2
   265
     * idle to show extension again on top of other components when 
williamr@2
   266
     * extension is shown when coming back to view. 
williamr@2
   267
     * Own. 
williamr@2
   268
     */
williamr@2
   269
    CIdle* iIdle; 
williamr@2
   270
williamr@2
   271
    /**
williamr@2
   272
     * Extension flags 
williamr@2
   273
     */
williamr@2
   274
    TInt iFlags; 
williamr@2
   275
    };
williamr@2
   276
williamr@2
   277
#endif // CAKNTOOLBAREXTENSION_H