epoc32/include/mw/aknchoicelist.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) 2005 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:  CAknChoiceList - Choice list for S60 
williamr@2
    15
*
williamr@2
    16
*/
williamr@2
    17
williamr@2
    18
williamr@2
    19
williamr@2
    20
#ifndef AKNCHOICELIST_H
williamr@2
    21
#define AKNCHOICELIST_H
williamr@2
    22
williamr@2
    23
// includes 
williamr@4
    24
#include <AknControl.h>
williamr@2
    25
#include <coecobs.h>
williamr@2
    26
williamr@2
    27
// forward declarations  
williamr@2
    28
class CAknButton;
williamr@2
    29
class CEikLabel;
williamr@2
    30
class CAknChoiceListPopup;
williamr@2
    31
class CAknChoiceListPopupList;
williamr@2
    32
class CAknsFrameBackgroundControlContext;
williamr@2
    33
class CAknInfoPopupNoteController;
williamr@2
    34
williamr@2
    35
// Class declaration
williamr@2
    36
williamr@2
    37
/**
williamr@2
    38
 *  CAknChoiceList
williamr@2
    39
 *  Choice list is new component, which allows selection from vertical list of choices.
williamr@2
    40
 *  By default choice list shows currently selected item and a arrow for opening the 
williamr@2
    41
 *  the choice list. Choice list can be used also without showing current selection. 
williamr@2
    42
 *  @lib avkon.lib
williamr@2
    43
 *  @since S60 5.0
williamr@2
    44
 */ 
williamr@2
    45
class CAknChoiceList : public CAknControl, public MCoeControlObserver
williamr@2
    46
    {   
williamr@2
    47
public:
williamr@2
    48
williamr@2
    49
    /* Flags for choice list types and positioning */   
williamr@2
    50
    enum TAknChoiceListFlags
williamr@2
    51
        {
williamr@2
    52
        /* Using default choice list with popup list */
williamr@2
    53
        EAknChoiceListWithCurrentSelection = 0x01,
williamr@2
    54
        /* Using user defined button to open choice list */
williamr@2
    55
        EAknChoiceListWithoutCurrentSelection = 0x02,
williamr@2
    56
        /* Popup positioning flags */
williamr@2
    57
        EAknChoiceListPositionLeft = 0x04,   
williamr@2
    58
        EAknChoiceListPositionRight = 0x08,   
williamr@2
    59
        EAknChoiceListPositionBottom = 0x10  
williamr@2
    60
        };    
williamr@2
    61
     
williamr@2
    62
     /* Tooltip positioning */
williamr@2
    63
     enum TTooltipPosition
williamr@2
    64
        {
williamr@2
    65
        EPositionTop = 1, /* Tooltip alignment vertically to top */
williamr@2
    66
        EPositionBottom, /* Tooltip alignment vertically to bottom */
williamr@2
    67
        EPositionLeft, /* Tooltip alignment horizontally to left */
williamr@2
    68
        EPositionRight /* Tooltip alignment horizontally to right */
williamr@2
    69
        };
williamr@2
    70
public: 
williamr@2
    71
williamr@2
    72
    /**
williamr@2
    73
     * Two-phased constructor.
williamr@2
    74
     * If the default flag is used then choice list shows an opening arrow and selected item on its 
williamr@2
    75
     * left side. If flag EAknChoiceListUsesButton is and user has defined own button then choice list
williamr@2
    76
     * open with items in the given array. Selected item is not show when choice list is closed. 
williamr@2
    77
     * @param aParent the parent control for choice list
williamr@2
    78
     * @param aItemArray Array of items to be shown in the choicelist. Transfers ownership.
williamr@2
    79
     * @param aFlags Flags for choice list type and positioning
williamr@2
    80
     * @param aButton user defined button for choicelist. Button replaces the typical choice list. 
williamr@2
    81
     * Transfers ownership.
williamr@2
    82
     */
williamr@2
    83
    IMPORT_C static CAknChoiceList* NewL( CCoeControl* aParent, CDesCArray* aItemArray, TInt aFlags = EAknChoiceListWithCurrentSelection, CAknButton* aButton = NULL );
williamr@2
    84
williamr@2
    85
    /**
williamr@2
    86
     * Two-phased constructor.
williamr@2
    87
     * If the default flag is used then choice list shows an opening arrow and selected item on its 
williamr@2
    88
     * left side. If flag EAknChoiceListUsesButton is and user has defined own button then choice list
williamr@2
    89
     * open with items in the given array. Selected item is not show when choice list is closed. 
williamr@2
    90
     * @param aParent the parent control for choice list
williamr@2
    91
     * @param aItemArray Array of items to be shown in the choicelist. Transfers ownership.
williamr@2
    92
     * @param aFlags Flags for choice list type and positioning
williamr@2
    93
     * @param aButton user defined button for choicelist. Button replaces the typical choice list. 
williamr@2
    94
     * Transfers ownership.
williamr@2
    95
     */
williamr@2
    96
    IMPORT_C static CAknChoiceList* NewLC( CCoeControl* aParent, CDesCArray* aItemArray, TInt aFlags = EAknChoiceListWithCurrentSelection, CAknButton* aButton = NULL );
williamr@2
    97
    
williamr@2
    98
    /**
williamr@2
    99
     * Destructor
williamr@2
   100
     */
williamr@2
   101
    ~CAknChoiceList();
williamr@2
   102
    
williamr@2
   103
    /**
williamr@2
   104
     * Open choice list.
williamr@2
   105
     * Choicelist can be opened with this function. If the choicelist is already
williamr@2
   106
     * open nothing will happen.
williamr@2
   107
     * @return KErrNone if succeeded
williamr@2
   108
     */
williamr@2
   109
    IMPORT_C TInt ShowChoiceListL();
williamr@2
   110
    
williamr@2
   111
    /**
williamr@2
   112
     * Set certain index of the choice list array to selected
williamr@2
   113
     * @param aIndex Index of the array to be selected as default
williamr@2
   114
     */
williamr@2
   115
    IMPORT_C void SetSelectedIndex( const TInt aIndex );
williamr@2
   116
    
williamr@2
   117
    /**
williamr@2
   118
     * Returns selected index from the choice list array
williamr@2
   119
     * @return TInt selected index
williamr@2
   120
     */
williamr@2
   121
    IMPORT_C TInt SelectedIndex() const;
williamr@2
   122
    
williamr@2
   123
    /**
williamr@2
   124
     * Set certain array as the contents of the choice list. 
williamr@2
   125
     * It's recommended to use CDesCArrayFlat. The ownership of the array is transferred
williamr@2
   126
     * to choice list.
williamr@2
   127
     * @param aArray Array of text items to be inserted as the content for choice list
williamr@2
   128
     */
williamr@2
   129
    IMPORT_C void SetItems( CDesCArray* aArray );
williamr@2
   130
    
williamr@2
   131
    /**
williamr@2
   132
     * Set certain array as the contents of the choice list. 
williamr@2
   133
     * It's recommended to use CDesCArrayFlat. 
williamr@2
   134
     * @param aResourceId Resource id for an array. 
williamr@2
   135
     */
williamr@2
   136
    IMPORT_C void SetItemsL( TInt aResourceId );
williamr@2
   137
    
williamr@2
   138
    /**
williamr@2
   139
     * Add a text as a new item in the end of the choice list array. 
williamr@2
   140
     * @param aDesC Pointer to a descriptor item that should be appended to the array. 
williamr@2
   141
     * Transfers ownership.
williamr@2
   142
     * @return index in the choicelist array for newly added item. 
williamr@2
   143
     */
williamr@2
   144
    IMPORT_C TInt AddItemL( const TDesC* aDesC );
williamr@2
   145
    
williamr@2
   146
    /**
williamr@2
   147
     * Removes an item from the choice list array with the given index. 
williamr@2
   148
     * @param aIndex index for the item that should be removed from the choice list array
williamr@2
   149
     */
williamr@2
   150
    IMPORT_C void RemoveItem( const TInt aIndex );    
williamr@2
   151
    
williamr@2
   152
    /**
williamr@2
   153
     * Sets flags for choice list.
williamr@2
   154
     * Choice lists position can be changed in runtime with right flags. 
williamr@2
   155
     * @param aFlags The flags to be set for choice list
williamr@2
   156
     */        
williamr@2
   157
    IMPORT_C void SetFlags( const TInt aFlags );
williamr@2
   158
    
williamr@2
   159
    /**
williamr@2
   160
     * Return choice list specific flags.
williamr@2
   161
     * @return choice list flags
williamr@2
   162
     */
williamr@2
   163
    IMPORT_C TInt Flags() const;
williamr@2
   164
    
williamr@2
   165
    /**
williamr@2
   166
     * Set the button that launches choice list opening.
williamr@2
   167
     * @param aButton The Button for opening choice list control 
williamr@2
   168
     */
williamr@2
   169
    IMPORT_C void SetButtonL( CAknButton* aButton );
williamr@2
   170
    
williamr@2
   171
    /**
williamr@2
   172
     * Hide choice list popup. Current selection is not selected.
williamr@2
   173
     */
williamr@2
   174
    IMPORT_C void HideChoiceList();
williamr@2
   175
williamr@2
   176
    /**
williamr@2
   177
     * Set text for tooltip
williamr@2
   178
     * @param aText The text shown as tooltip
williamr@2
   179
     */
williamr@2
   180
    IMPORT_C void SetTooltipTextL( const TDesC& aText );
williamr@2
   181
williamr@2
   182
    /**
williamr@2
   183
     * Set the delays for tooltip
williamr@2
   184
     * @param aBeforeTimeout The delay in milliseconds before tooltip
williamr@2
   185
     *        is shown. The default is 150 milliseconds
williamr@2
   186
     * @param aInViewTiemout The interval in milliseconds how long the
williamr@2
   187
     *        tooltip is displayed. The default is 3000 milliseconds.
williamr@2
   188
     */
williamr@2
   189
    IMPORT_C void SetTooltipTimeouts( const TInt aBeforeTimeout,
williamr@2
   190
                                      const TInt aInViewTimeout );
williamr@2
   191
    /**
williamr@2
   192
     * Set the postion of tooltip
williamr@2
   193
     * @param aPosition The position expressed with TTooltipPosition
williamr@2
   194
     *        The default is EPositionTop
williamr@2
   195
     */                                      
williamr@2
   196
    IMPORT_C void SetTooltipPosition( const TTooltipPosition aPosition );
williamr@2
   197
    
williamr@2
   198
// From CCoeControl
williamr@2
   199
    
williamr@2
   200
    /**
williamr@2
   201
     * From CCoeControl. Returns the control inside control with given index.
williamr@2
   202
     * @param aIndex Index of a control be returned
williamr@2
   203
     * @return A Pointer to control.
williamr@2
   204
     */
williamr@2
   205
    IMPORT_C CCoeControl* ComponentControl( TInt aIndex ) const;
williamr@2
   206
williamr@2
   207
    /**
williamr@2
   208
     * From CCoeControl. Returns number of controls inside the control.
williamr@2
   209
     * @return Number of component controls.
williamr@2
   210
     */
williamr@2
   211
    IMPORT_C TInt CountComponentControls() const;
williamr@2
   212
williamr@2
   213
    /**
williamr@2
   214
     * From CCoeControl. Returns the Minimum size needed by the control. 
williamr@2
   215
     * @return TSize minimum size. 
williamr@2
   216
     */
williamr@2
   217
    IMPORT_C TSize MinimumSize();    
williamr@2
   218
    
williamr@2
   219
    /**
williamr@2
   220
     * From CCoeControl. Handles a change to the control's resources.
williamr@2
   221
     * @param aType A message UID value.   
williamr@2
   222
     */
williamr@2
   223
    IMPORT_C void HandleResourceChange( TInt aType );    
williamr@2
   224
    
williamr@2
   225
    /**
williamr@2
   226
     * From CCoeControl. Handles key events.
williamr@2
   227
     * @param aKeyEvent the key event    
williamr@2
   228
     * @param aType The type of key event
williamr@2
   229
     * @return Indicates whether or not the keyevent was used by this control   
williamr@2
   230
     */
williamr@2
   231
    IMPORT_C TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent, TEventCode aType );    
williamr@2
   232
    
williamr@2
   233
    /**
williamr@2
   234
     * From CCoeControl. Draws control to given area
williamr@2
   235
     * @param aRect The rectangle that should be drawn by the control. 
williamr@2
   236
     */
williamr@2
   237
    IMPORT_C void Draw( const TRect& aRect ) const;
williamr@2
   238
    
williamr@2
   239
williamr@2
   240
    /**
williamr@2
   241
    * from CCoeControl 
williamr@2
   242
    *
williamr@2
   243
    * Responds to changes in the position of a control.
williamr@2
   244
    *
williamr@2
   245
    */
williamr@2
   246
    IMPORT_C virtual void PositionChanged();
williamr@2
   247
williamr@2
   248
williamr@2
   249
// From MCoeControlObserver
williamr@2
   250
    
williamr@2
   251
    /**
williamr@2
   252
     * From MCoeControlObserver. Handles an event from an observed control.
williamr@2
   253
     * If this component has observer, then a EEventStateChanged is sent to it
williamr@2
   254
     * when a item is selected from choice list
williamr@2
   255
     * @param aControl The control that sent the event.
williamr@2
   256
     * @param aEventType The event type. 
williamr@2
   257
     */
williamr@2
   258
    IMPORT_C void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
williamr@2
   259
williamr@2
   260
public: 
williamr@2
   261
    // new functions
williamr@2
   262
    /**
williamr@2
   263
    * Insert new item to a certain index. The rest of the array will be reindexed. 
williamr@2
   264
    * If given index is beyond current array then it's just appended to the end of the array.
williamr@2
   265
    * @param aIndex The array index where new item is going to be inserted.
williamr@2
   266
    * @param aText Items text
williamr@2
   267
    * @return The index of newly inserted item. Index can be other than passed if given index 
williamr@2
   268
    * is out of array bounds
williamr@2
   269
    */
williamr@2
   270
    IMPORT_C TInt InsertItemL( const TInt aIndex, const TDesC& aText );
williamr@2
   271
    
williamr@2
   272
protected: 
williamr@2
   273
williamr@2
   274
// from CCoeControl         
williamr@2
   275
    
williamr@2
   276
    /**
williamr@2
   277
     * From CCoeControl. Sets the size and position of the component. 
williamr@2
   278
     */
williamr@2
   279
    void SizeChanged();
williamr@2
   280
    
williamr@2
   281
    /**
williamr@2
   282
     * From CCoeControl. Handles pointer events
williamr@2
   283
     * @param aPointerEvent the pointer event be be handled.
williamr@2
   284
     */
williamr@2
   285
    void HandlePointerEventL( const TPointerEvent& aPointerEvent );    
williamr@2
   286
williamr@2
   287
private:
williamr@2
   288
williamr@2
   289
    /**
williamr@2
   290
     * C++ Default Constructor 
williamr@2
   291
     */
williamr@2
   292
    CAknChoiceList(); 
williamr@2
   293
williamr@2
   294
    /**
williamr@2
   295
     * 2nd phase constructor
williamr@2
   296
     * @param aParent the parent control for choice list
williamr@2
   297
     * @param aItemArray Array of items to be shown in the choicelist
williamr@2
   298
     * @param aFlags Flags for choice list type and positioning
williamr@2
   299
     * @param aButton user defined button for choicelist. Button replaces the typical choice list
williamr@2
   300
     */
williamr@2
   301
    void ConstructL( CCoeControl* aParent, CDesCArray* aItemArray, TInt aFlags, CAknButton* aButton );    
williamr@2
   302
    
williamr@2
   303
    /**
williamr@2
   304
     * Construct the typical choice list that open with arrow and show current selection 
williamr@2
   305
     * even in the closed state.
williamr@2
   306
     */
williamr@2
   307
    void ConstructTypicalChoiceListL();
williamr@2
   308
    
williamr@2
   309
    /**
williamr@2
   310
     * Calculate positioning for the opened choice list popup by the given position flag.
williamr@2
   311
     */
williamr@2
   312
    void SetPopupRect();
williamr@2
   313
    
williamr@2
   314
    /**
williamr@2
   315
     * Update labels text 
williamr@2
   316
     */
williamr@2
   317
    void UpdateLabelL();
williamr@2
   318
williamr@2
   319
    /**
williamr@2
   320
     * Show tooltip text
williamr@2
   321
     */
williamr@2
   322
    void ShowTooltipL();
williamr@2
   323
williamr@2
   324
    
williamr@2
   325
private: // data
williamr@2
   326
williamr@2
   327
    /**
williamr@2
   328
     * Flags for choice list
williamr@2
   329
     */
williamr@2
   330
    TInt iFlags;
williamr@2
   331
    
williamr@2
   332
    /** 
williamr@2
   333
     * Currently selected index of an item that is stored in choice list array.
williamr@2
   334
     */
williamr@2
   335
    TInt iSelectedIndex;
williamr@2
   336
    
williamr@2
   337
    /** 
williamr@2
   338
     * Used to store if the choice list is closed mode or not. 
williamr@2
   339
     */
williamr@2
   340
    TBool iIsClosed;    
williamr@2
   341
    
williamr@2
   342
    /**
williamr@2
   343
     * Button for opening the choicelist. If choice lists type is 
williamr@2
   344
     * EAknChoiceListWithCurrentSelection this is the arrow button. 
williamr@2
   345
     * Otherwise this is user defined.
williamr@2
   346
     * Own.
williamr@2
   347
     */
williamr@2
   348
    CAknButton* iButton;
williamr@2
   349
    
williamr@2
   350
    /**
williamr@2
   351
     * Label that shows the currently selected item if choice list type is 
williamr@2
   352
     * EAknChoiceListWithCurrentSelection. Otherwise this will not be used. 
williamr@2
   353
     * Own.
williamr@2
   354
     */
williamr@2
   355
    CEikLabel* iLabel;
williamr@2
   356
williamr@2
   357
    /**
williamr@2
   358
     * Array that stores all the items in the choice list. 
williamr@2
   359
     * Own.
williamr@2
   360
     */
williamr@2
   361
    CDesCArray* iArray;    
williamr@2
   362
    
williamr@2
   363
    /**
williamr@2
   364
     * Pointer to current choice list popup window. Popup window is 
williamr@2
   365
     * used only internally and it cannot be accessed from outside.
williamr@2
   366
     * Own.
williamr@2
   367
     */
williamr@2
   368
    CAknChoiceListPopup* iPopup;
williamr@2
   369
williamr@2
   370
    /**
williamr@2
   371
     * Component used to show tooltip
williamr@2
   372
     * Own.
williamr@2
   373
     */
williamr@2
   374
    CAknInfoPopupNoteController* iTooltip;
williamr@2
   375
williamr@2
   376
    /**
williamr@2
   377
     * Stores the text for tooltip
williamr@2
   378
     * Own.
williamr@2
   379
     */
williamr@2
   380
    HBufC* iTooltipText;
williamr@2
   381
williamr@2
   382
    /**
williamr@2
   383
     * Stores the delay in milliseconds when the tooltip is shown
williamr@2
   384
     * Own.
williamr@2
   385
     */
williamr@2
   386
    TInt iTooltipWaitInterval;
williamr@2
   387
williamr@2
   388
    /**
williamr@2
   389
     * Stores the time interval in milliseconds how long the tooltip is shown
williamr@2
   390
     * Own.
williamr@2
   391
     */
williamr@2
   392
    TInt iTooltipInViewInterval;
williamr@2
   393
williamr@2
   394
    /**
williamr@2
   395
     * Stores the tool tip positioning
williamr@2
   396
     * Own.
williamr@2
   397
     */
williamr@2
   398
    TTooltipPosition iTooltipPosition;
williamr@2
   399
williamr@2
   400
    
williamr@2
   401
    };    
williamr@2
   402
williamr@2
   403
#endif // AKNCHOICELIST_H
williamr@2
   404
williamr@2
   405
// end of file