epoc32/include/mw/eiktbar.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
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@4
     1
/*
williamr@4
     2
* Copyright (c) 2002-2006 Nokia Corporation and/or its subsidiary(-ies).
williamr@4
     3
* All rights reserved.
williamr@4
     4
* This component and the accompanying materials are made available
williamr@4
     5
* under the terms of "Eclipse Public License v1.0"
williamr@4
     6
* which accompanies this distribution, and is available
williamr@4
     7
* at the URL "http://www.eclipse.org/legal/epl-v10.html".
williamr@4
     8
*
williamr@4
     9
* Initial Contributors:
williamr@4
    10
* Nokia Corporation - initial contribution.
williamr@4
    11
*
williamr@4
    12
* Contributors:
williamr@4
    13
*
williamr@4
    14
* Description:  Class declaration for EIKON toolbar control.
williamr@4
    15
*
williamr@4
    16
*/
williamr@4
    17
williamr@4
    18
williamr@4
    19
#ifndef __EIKTBAR_H__
williamr@4
    20
#define __EIKTBAR_H__
williamr@4
    21
williamr@4
    22
#include <eikctgrp.h>
williamr@4
    23
#include <coecobs.h>
williamr@4
    24
#include <eikbtgrp.h>
williamr@4
    25
#include <eikbtgpc.h>
williamr@4
    26
williamr@4
    27
// Forward declarations
williamr@4
    28
williamr@4
    29
class MEikCommandObserver;
williamr@4
    30
class TEikButtonCoordinator;
williamr@4
    31
class CEikCommandButton;
williamr@4
    32
class CCoeBrushAndPenContext;
williamr@4
    33
williamr@4
    34
/**
williamr@4
    35
 * A vertical group of controls displayed down the right-hand side of the
williamr@4
    36
 * screen in an application.
williamr@4
    37
 *
williamr@4
    38
 * It contains buttons which are used to issue application commands,
williamr@4
    39
 * and other controls. A toolband may also be created using this class,
williamr@4
    40
 * by setting the @c EEikToolBarHorizontal flag and initialising from a
williamr@4
    41
 * @c TOOLBAND resource.
williamr@4
    42
 *
williamr@4
    43
 * @lib eikcoctl.lib
williamr@4
    44
 * @since S60 0.9
williamr@4
    45
 */
williamr@4
    46
class CEikToolBar : public CEikControlGroup,
williamr@4
    47
                    public MCoeControlObserver,
williamr@4
    48
                    public MEikButtonGroup
williamr@4
    49
	{
williamr@4
    50
public:
williamr@4
    51
williamr@4
    52
    /**
williamr@4
    53
     * Destructor.
williamr@4
    54
     * Deletes the toolbar's brush and pen context and control types.
williamr@4
    55
     */
williamr@4
    56
	IMPORT_C ~CEikToolBar();
williamr@4
    57
	
williamr@4
    58
	/**
williamr@4
    59
     * Default C++ constructor.
williamr@4
    60
     * Creates a new toolbar object, but does not initialise any of
williamr@4
    61
     * its heap-stored members.
williamr@4
    62
     */
williamr@4
    63
	IMPORT_C CEikToolBar();
williamr@4
    64
	
williamr@4
    65
	/**
williamr@4
    66
	 * Completes construction of a default-constructed toolbar.
williamr@4
    67
	 *
williamr@4
    68
     * The command observer interface defines a method for creating custom
williamr@4
    69
     * controls on the toolbar from user-defined IDs specified in the
williamr@4
    70
     * resource @c aResourceId.
williamr@4
    71
     *
williamr@4
    72
     * IDs for controls which cannot be constructed using
williamr@4
    73
     * @c EikControlFactory::CreateByTypeL() are passed to this object's
williamr@4
    74
     * command observer for construction.
williamr@4
    75
     *
williamr@4
    76
     * Applications requiring custom controls in their toolbars should
williamr@4
    77
     * override their AppUI's @c CreateCustomCommandControlL() method,
williamr@4
    78
     * inherited from @c MEikCommandObserver.
williamr@4
    79
     *
williamr@4
    80
     * @param aCommandObserver Sets the command observer for this toolbar.
williamr@4
    81
     *                         The observer's @c ProcessCommandL()
williamr@4
    82
     *                         function is invoked when a toolbar command
williamr@4
    83
     *                         is invoked by the user.
williamr@4
    84
     *                         @see MEikCommandObserver::ProcessCommandL().
williamr@4
    85
     *                         Typically the observer is the
williamr@4
    86
     *                         application's AppUI.
williamr@4
    87
     *
williamr@4
    88
     * @param aResourceId      The ID of a @c TOOLBAR or @c TOOLBAND
williamr@4
    89
     *                         resource structure.
williamr@4
    90
     *
williamr@4
    91
     * @param aBoundingRect    Defines the rectangle to which the toolbar's
williamr@4
    92
     *                         extent must be limited. This is typically given
williamr@4
    93
     *                         by @c CEikAppUi::ClientRect(), which returns
williamr@4
    94
     *                         the extent of the whole application window,
williamr@4
    95
     *                         less the extent of any toolbars that already
williamr@4
    96
     *                         exist and are owned by the AppUI.
williamr@4
    97
     *
williamr@4
    98
     * @panic EIKCOCTL-36      If the control on the toolbar cannot be
williamr@4
    99
     *                         constructed.
williamr@4
   100
     */
williamr@4
   101
	IMPORT_C void ConstructL( MEikCommandObserver* aCommandObserver,
williamr@4
   102
	                          TInt aResourceId,
williamr@4
   103
	                          const TRect& aBoundingRect );
williamr@4
   104
	
williamr@4
   105
	/**
williamr@4
   106
	 * Creates a toolbar from a resource definition,
williamr@4
   107
	 * but does not set its extent or activate it.
williamr@4
   108
	 *
williamr@4
   109
	 * This function is used by @c ConstructL(), applications will
williamr@4
   110
	 * not typically need to use it.
williamr@4
   111
	 *
williamr@4
   112
	 * @param aCommandObserver Specifies the object in which
williamr@4
   113
	 *                         @c HandleCommandL() is called when a toolbar
williamr@4
   114
	 *                         command is invoked, typically the application's
williamr@4
   115
	 *                         AppUI.
williamr@4
   116
	 *
williamr@4
   117
	 * @param aResourceId      The resource that defines the toolbar.
williamr@4
   118
	 *
williamr@4
   119
	 * @panic EIKCOCTL-36      If the control on the toolbar cannot be
williamr@4
   120
	 *                         constructed.
williamr@4
   121
	 */
williamr@4
   122
	IMPORT_C void StaticConstructL( MEikCommandObserver* aCommandObserver,
williamr@4
   123
	                                TInt aResourceId );
williamr@4
   124
	
williamr@4
   125
	/**
williamr@4
   126
	 * Sets the toolbar's command observer.
williamr@4
   127
	 * Applications will not typically need to use this function.
williamr@4
   128
	 *
williamr@4
   129
	 * @param aCommandObserver The command observer for this toolbar.
williamr@4
   130
	 *                         When a command is invoked in the toolbar,
williamr@4
   131
	 *                         @c HandleCommandL() is called in the observer.
williamr@4
   132
	 */
williamr@4
   133
	IMPORT_C void SetCommandObserver(MEikCommandObserver* aCommandObserver);
williamr@4
   134
	
williamr@4
   135
	/**
williamr@4
   136
	 * Sets the button co-ordinator for a group of buttons in a toolbar.
williamr@4
   137
	 *
williamr@4
   138
	 * @param aId           Command identifying a toolbar button. 
williamr@4
   139
	 * @param aCount        The number of buttons in the group. 
williamr@4
   140
	 * @param aCoordinator  The button coordinator. 
williamr@4
   141
	 */
williamr@4
   142
	IMPORT_C void CoordinateButtons( TInt aId,
williamr@4
   143
	                                 TInt aCount,
williamr@4
   144
	                                 TEikButtonCoordinator* aCoordinator );
williamr@4
   145
	
williamr@4
   146
	/**
williamr@4
   147
	 * Sets the state of the specified button and draws the button
williamr@4
   148
	 * to show the new state.
williamr@4
   149
	 *
williamr@4
   150
	 * @param aId    The command that identifies the button.
williamr@4
   151
	 * @param aState @c ETrue to set the button, @c EFalse to clear the button.
williamr@4
   152
	 */
williamr@4
   153
	IMPORT_C void SetButtonStateOn(TInt aId,TBool aState);
williamr@4
   154
	
williamr@4
   155
	/**
williamr@4
   156
	 * Delays activation of the toolbar when constructed.
williamr@4
   157
	 *
williamr@4
   158
	 * This function sets the toolbar flag @c EEikToolBarDelayActivation.
williamr@4
   159
	 * If this flag is set when @c ConstructL() is called on the toolbar,
williamr@4
   160
	 * the toolbar will be constructed but not activated.
williamr@4
   161
	 *
williamr@4
   162
	 * The application can subsequently activate the toolbar by calling
williamr@4
   163
	 * @c CCoeControl::ActivateL().
williamr@4
   164
	 *
williamr@4
   165
	 * @return @c ETrue to delay activation of the toolbar.
williamr@4
   166
	 */
williamr@4
   167
	IMPORT_C TBool DelayActivation() const;
williamr@4
   168
	
williamr@4
   169
public: /** From @c CCoeControl. */
williamr@4
   170
williamr@4
   171
    /**
williamr@4
   172
	 * Second-phase construction from a resource.
williamr@4
   173
	 * This is called by @c StaticConstructL() with an appropriate reader.
williamr@4
   174
	 *
williamr@4
   175
	 * From @c CCoeControl
williamr@4
   176
	 *
williamr@4
   177
	 * @param aReader     A resource reader pointing at a @c TOOLBAR or
williamr@4
   178
	 *                    @c TOOLBAND resource defining the toolbar.
williamr@4
   179
	 * @panic EIKCOCTL-36 If the control on the toolbar cannot be constructed.
williamr@4
   180
	 */
williamr@4
   181
	IMPORT_C void ConstructFromResourceL(TResourceReader& aReader);
williamr@4
   182
	
williamr@4
   183
	/**
williamr@4
   184
	 * Sets the toolbar dimmed or not dimmed.
williamr@4
   185
	 * Dimming usually indicates that user input is not accepted.
williamr@4
   186
	 *
williamr@4
   187
	 * From @c CCoeControl
williamr@4
   188
	 *
williamr@4
   189
	 * @param aDimmed @c ETrue to set as dimmed ,
williamr@4
   190
	 *                @c EFalse to set as not dimmed.
williamr@4
   191
	 */
williamr@4
   192
	IMPORT_C void SetDimmed(TBool aDimmed);
williamr@4
   193
	
williamr@4
   194
	/**
williamr@4
   195
	 * Gets the list of logical colours used to draw the control.
williamr@4
   196
	 * Appends the list to @c aColorUseList paired with an explanation
williamr@4
   197
	 * of how the colours are used.
williamr@4
   198
     *
williamr@4
   199
	 * From @c CCoeControl
williamr@4
   200
	 *
williamr@4
   201
	 * @param[in,out] aColorUseList The list of logical colours. 
williamr@4
   202
	 */
williamr@4
   203
	IMPORT_C void GetColorUseListL(CArrayFix<TCoeColorUse>& aColorUseList) const;
williamr@4
   204
	
williamr@4
   205
	/**
williamr@4
   206
     * Handles a change to the control's resources.
williamr@4
   207
     *
williamr@4
   208
     * The types of resources handled are those which are shared across
williamr@4
   209
     * the environment, e.g. colours or fonts. For colour scheme changes,
williamr@4
   210
     * @c DrawDeferred() is called in order to redraw the control.
williamr@4
   211
     *
williamr@4
   212
     * If overriding this method, the implementation must
williamr@4
   213
     * include a base call to this method.
williamr@4
   214
     *
williamr@4
   215
     * From @c CCoeControl.
williamr@4
   216
	 *
williamr@4
   217
     * @param aType The type of resource that has changed.
williamr@4
   218
     */
williamr@4
   219
	IMPORT_C void HandleResourceChange(TInt aType);
williamr@4
   220
	
williamr@4
   221
	/**
williamr@4
   222
     * Handles pointer events.
williamr@4
   223
     *
williamr@4
   224
     * This function gets called whenever a pointer event occurs in the 
williamr@4
   225
     * control, i.e. when the pointer is within the control's extent, or when 
williamr@4
   226
     * the control has grabbed the pointer.
williamr@4
   227
     * 
williamr@4
   228
     * If overriding this method, the implementation must 
williamr@4
   229
     * include a base call to this method.
williamr@4
   230
     *
williamr@4
   231
     * From @c CCoeControl.
williamr@4
   232
     *
williamr@4
   233
     * @param aPointerEvent The pointer event.
williamr@4
   234
     */
williamr@4
   235
	IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@4
   236
	
williamr@4
   237
public: /** From @c CEikControlGroup. */
williamr@4
   238
williamr@4
   239
    /**
williamr@4
   240
     * Adds a control to the control group.
williamr@4
   241
     *
williamr@4
   242
	 * From @c CEikControlGroup
williamr@4
   243
	 *
williamr@4
   244
	 * @param aControl    The control to add to the control group
williamr@4
   245
	 * @param aId         The control's ID.
williamr@4
   246
	 * @panic EIKCOCTL-26 If the control does not exist.
williamr@4
   247
	 */
williamr@4
   248
	IMPORT_C void AddControlL(CCoeControl* aControl,TInt aId);
williamr@4
   249
	
williamr@4
   250
	/**
williamr@4
   251
	 * Adds a control wrapped with its ID and length to the control group.
williamr@4
   252
	 *
williamr@4
   253
	 * From @c CEikControlGroup
williamr@4
   254
	 *
williamr@4
   255
	 * @param aGroupControl The wrapped control to add.
williamr@4
   256
	 * @panic EIKCOCTL-26   If the control does not exist.
williamr@4
   257
	 */
williamr@4
   258
	IMPORT_C void AddControlL(TEikGroupControl& aGroupControl);
williamr@4
   259
	
williamr@4
   260
public: // but not exported
williamr@4
   261
williamr@4
   262
    /**
williamr@4
   263
	 * Adds a control type to the control type array.
williamr@4
   264
	 *
williamr@4
   265
	 * @internal
williamr@4
   266
	 *
williamr@4
   267
	 * @param aType The control type to be added.
williamr@4
   268
	 */
williamr@4
   269
	void AddControlTypeL(TInt aType);
williamr@4
   270
	
williamr@4
   271
	/**
williamr@4
   272
	 * Removes a control type from the control type array.
williamr@4
   273
	 *
williamr@4
   274
	 * @internal
williamr@4
   275
	 *
williamr@4
   276
	 * @param aIndex Index of the control type to be removed
williamr@4
   277
	 *               in the control type array.
williamr@4
   278
	 */
williamr@4
   279
	void RemoveControlType(TInt aIndex);
williamr@4
   280
	
williamr@4
   281
	/**
williamr@4
   282
	 * Used to check if a control is a button type control or not.
williamr@4
   283
	 *
williamr@4
   284
	 * @internal
williamr@4
   285
	 *
williamr@4
   286
	 * @param  aIndex Index of the control.
williamr@4
   287
	 * @return @c ETrue, if the control is a button type control.
williamr@4
   288
	 */
williamr@4
   289
	TBool ControlIsButton(TInt aIndex) const;
williamr@4
   290
	
williamr@4
   291
public: /** From @c MEikButtonGroup. */
williamr@4
   292
williamr@4
   293
    /**
williamr@4
   294
     * Sets the toolbar's bounding rectangle.
williamr@4
   295
     * This function has a different effect on the toolbar's extent,
williamr@4
   296
     * depending on whether the toolbar is vertical or horizontal.
williamr@4
   297
     *
williamr@4
   298
     * For a vertical toolbar, sets the toolbar height to equal the
williamr@4
   299
     * height of the bounding rectangle.
williamr@4
   300
     *
williamr@4
   301
     * For a horizontal toolbar (toolband), sets the toolband width
williamr@4
   302
     * to equal the width of the bounding rectangle.
williamr@4
   303
     *
williamr@4
   304
	 * From @c MEikButtonGroup
williamr@4
   305
	 *
williamr@4
   306
	 * @param aBoundingRect The toolbar's bounding rectangle.
williamr@4
   307
	 */
williamr@4
   308
	IMPORT_C void SetBoundingRect(const TRect& aBoundingRect);
williamr@4
   309
	
williamr@4
   310
	/**
williamr@4
   311
	 * Shrinks a rectangle to exclude the toolbar area.
williamr@4
   312
     * This function reduces the size of the rectangle passed into the
williamr@4
   313
     * function so that on return, the area occupied by the toolbar or toolband
williamr@4
   314
     * is removed from the rectangle. It is provided to prevent drawing
williamr@4
   315
     * over an existing toolbar or toolband.
williamr@4
   316
     *
williamr@4
   317
	 * From @c MEikButtonGroup
williamr@4
   318
	 *
williamr@4
   319
	 * @param[in,out] aBoundingRect Specifies a rectangle which, on return,
williamr@4
   320
	 *                              is shrunk to exclude the toolbar’s extent.
williamr@4
   321
	 */
williamr@4
   322
	IMPORT_C void ReduceRect(TRect& aBoundingRect) const;
williamr@4
   323
	
williamr@4
   324
protected:
williamr@4
   325
williamr@4
   326
    /**
williamr@4
   327
     * Writes the internal state of the control and its
williamr@4
   328
     * components to @c aWriteStream.
williamr@4
   329
     * Does nothing in release mode.
williamr@4
   330
     *
williamr@4
   331
     * Designed to be overridden and base called from subclasses.
williamr@4
   332
     *
williamr@4
   333
     * From @c CCoeControl
williamr@4
   334
     *
williamr@4
   335
     * @param[in,out] aWriteStream A connected write stream.
williamr@4
   336
     */
williamr@4
   337
	IMPORT_C void WriteInternalStateL(RWriteStream& aWriteStream) const;
williamr@4
   338
	
williamr@4
   339
private:
williamr@4
   340
williamr@4
   341
	CEikCommandButton* ButtonByIndex(TInt aIndex) const;	
williamr@4
   342
	void SetCurrentId(TInt aPosition,TInt aId);	
williamr@4
   343
	TInt CurrentId(TInt aPosition) const;	
williamr@4
   344
	TEikGroupControl& GroupControlByIndex(TInt aIndex) const;	
williamr@4
   345
	TInt IndexFromPosition(TInt aPos) const;
williamr@4
   346
	
williamr@4
   347
private: /** From @c MEikButtonGroup */
williamr@4
   348
williamr@4
   349
	void SetCommandL( TInt aPosition,
williamr@4
   350
	                  TInt aCommandId,
williamr@4
   351
	                  const TDesC* aText,
williamr@4
   352
	                  const CFbsBitmap* aBitmap,
williamr@4
   353
	                  const CFbsBitmap* aMask );
williamr@4
   354
	                  
williamr@4
   355
	void SetCommandL(TInt aPosition,TInt aResourceId);
williamr@4
   356
	void SetCommandSetL(TInt aResourceId);
williamr@4
   357
	void AddCommandL( TInt aPosition,
williamr@4
   358
	                  TInt aCommandId,
williamr@4
   359
	                  const TDesC* aText,
williamr@4
   360
	                  const CFbsBitmap* aBitmap,
williamr@4
   361
	                  const CFbsBitmap* aMask );
williamr@4
   362
	void AddCommandToStackL( TInt aPosition,
williamr@4
   363
	                         TInt aCommandId,
williamr@4
   364
	                         const TDesC* aText,
williamr@4
   365
	                         const CFbsBitmap* aBitmap,
williamr@4
   366
	                         const CFbsBitmap* aMask );
williamr@4
   367
	void AddCommandToStackL(TInt aPosition,TInt aResourceId);
williamr@4
   368
	void AddCommandSetToStackL(TInt aResourceId);
williamr@4
   369
	void SetDefaultCommand(TInt aCommandId);
williamr@4
   370
	TSize CalcMinimumSizeL(TInt aResourceId);
williamr@4
   371
	void RemoveCommandFromStack(TInt aPosition,TInt aCommandId);
williamr@4
   372
	TInt CommandPos(TInt aCommandId) const;
williamr@4
   373
	void DimCommand(TInt aCommandId,TBool aDimmed);
williamr@4
   374
	TBool IsCommandDimmed(TInt aCommandId) const;
williamr@4
   375
	void MakeCommandVisible(TInt aCommandId,TBool aVisible);
williamr@4
   376
	TBool IsCommandVisible(TInt aCommandId) const;
williamr@4
   377
	CCoeControl* AsControl();
williamr@4
   378
	const CCoeControl* AsControl() const;
williamr@4
   379
	CCoeControl* GroupControlById(TInt aCommandId) const;
williamr@4
   380
	CEikCommandButton* GroupControlAsButton(TInt aCommandId) const;
williamr@4
   381
	TInt CommandId(TInt aCommandPos) const;
williamr@4
   382
	TInt ButtonCount() const;
williamr@4
   383
	TUint ButtonGroupFlags() const;
williamr@4
   384
williamr@4
   385
    void SetMSKCommandObserver(MEikCommandObserver* aCommandObserver);
williamr@4
   386
    void DimCommandByPosition(TInt aPosition,TBool aDimmed);
williamr@4
   387
    TBool IsCommandDimmedByPosition(TInt aPosition) const;
williamr@4
   388
    void MakeCommandVisibleByPosition(TInt aPosition,TBool aVisible);
williamr@4
   389
    TBool IsCommandVisibleByPosition(TInt aPosition) const;
williamr@4
   390
    void AnimateCommandByPosition(TInt aPosition);
williamr@4
   391
williamr@4
   392
private: /** From @c MCoeControlObserver */
williamr@4
   393
	IMPORT_C void HandleControlEventL(CCoeControl* aControl,TCoeEvent aEvent);
williamr@4
   394
	
williamr@4
   395
private:
williamr@4
   396
	IMPORT_C void Reserved_2();
williamr@4
   397
	
williamr@4
   398
private: /** From @c CAknControl */
williamr@4
   399
williamr@4
   400
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@4
   401
private:
williamr@4
   402
	void BaseConstructL();
williamr@4
   403
	TInt ControlCount() const;
williamr@4
   404
private:
williamr@4
   405
	TInt                    iToolBarFlags;
williamr@4
   406
	MEikCommandObserver*    iCommandObserver;
williamr@4
   407
	CCoeBrushAndPenContext* iBrushAndPenContext;
williamr@4
   408
	CArrayFix<TInt>*        iControlTypes; 
williamr@4
   409
	};
williamr@4
   410
williamr@4
   411
#endif // __EIKTBAR_H__