epoc32/include/mw/eiklbx.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 1997-2009 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:  Base class for an on-screen list box control from
williamr@2
    15
*               which one or more items can be selected.
williamr@2
    16
*
williamr@2
    17
*/
williamr@2
    18
   
williamr@2
    19
#ifndef __EIKLBX_H__
williamr@2
    20
#define __EIKLBX_H__
williamr@2
    21
williamr@2
    22
//  INCLUDES 
williamr@2
    23
#include <gdi.h>
williamr@2
    24
#include <eikbctrl.h>
williamr@2
    25
#include <eiklbo.h>
williamr@2
    26
#include <eiksbfrm.h>
williamr@2
    27
#include <eiklbm.h>
williamr@2
    28
#include <eiklbv.h>
williamr@2
    29
#include <gulbordr.h>
williamr@2
    30
#include <eiklbed.h>
williamr@2
    31
#include <gulutil.h>
williamr@2
    32
#include <lafpublc.h>
williamr@2
    33
williamr@2
    34
//  FORWARD DECLARATIONS
williamr@2
    35
enum TKeyCode;
williamr@2
    36
class RIncrMatcherBase;
williamr@2
    37
class CListItemDrawer;
williamr@2
    38
class CEikScrollBarFrame;
williamr@2
    39
class CEikButtonBase;
williamr@2
    40
class CMatchBuffer;
williamr@2
    41
class CListBoxExt;
williamr@2
    42
class CEikListBox;
williamr@2
    43
williamr@2
    44
//  CLASS DECLARATION
williamr@2
    45
williamr@2
    46
/**
williamr@2
    47
* Item change observer will be notified when list box items have been added or
williamr@2
    48
* removed or the list box has been reset. Observers can be added and removed by
williamr@2
    49
* using @c CEikListBox methods @c AddItemChangeObserverL() and
williamr@2
    50
* @c RemoveItemChangeObserver().
williamr@2
    51
*
williamr@2
    52
* @since 3.0
williamr@2
    53
*/
williamr@2
    54
class MListBoxItemChangeObserver
williamr@2
    55
    {
williamr@2
    56
    public:
williamr@2
    57
        /**
williamr@2
    58
         * Notification and handling of a list box item change.
williamr@2
    59
         *
williamr@2
    60
         * @param aListBox The source list box of this message.
williamr@2
    61
         */
williamr@2
    62
        virtual void ListBoxItemsChanged(CEikListBox* aListBox) = 0;
williamr@2
    63
    };
williamr@2
    64
williamr@2
    65
williamr@2
    66
/**
williamr@2
    67
* Item selection (marking) observer is used to let application control item marking
williamr@2
    68
* (in markable lists). Observers can be added and removed by using
williamr@2
    69
* @c CEikListBox methods @c AddSelectionObserverL() and
williamr@2
    70
* @c RemoveSelectionObserver().
williamr@2
    71
*
williamr@2
    72
* @since 3.2
williamr@2
    73
*/
williamr@2
    74
class MListBoxSelectionObserver
williamr@2
    75
    {
williamr@2
    76
    public:
williamr@2
    77
        /**
williamr@2
    78
         * Notification of entering and leaving marking mode. Marking mode
williamr@2
    79
         * is enabled by long pressing shift, ctrl or hash keys (when hash key marking is enabled).
williamr@2
    80
         *
williamr@2
    81
         * @param aListBox The source list box of this message.
williamr@2
    82
         * @param aSelectionModeEnabled ETrue, when entering selection (marking) mode.
williamr@2
    83
         */
williamr@2
    84
        virtual void SelectionModeChanged(CEikListBox* aListBox, TBool aSelectionModeEnabled) = 0;
williamr@2
    85
    };
williamr@2
    86
williamr@2
    87
williamr@2
    88
// CLASS DECLARATION
williamr@2
    89
    
williamr@2
    90
/**
williamr@2
    91
 * Base class for an on-screen list box control from which one or more items 
williamr@2
    92
 * can be selected.
williamr@2
    93
 *
williamr@2
    94
 * @c CEikListBox implements the basics of a list box. It has a scroll bar 
williamr@2
    95
 * frame, an item drawer, and a model, and reports events to a list box 
williamr@2
    96
 * observer.
williamr@2
    97
 * 
williamr@2
    98
 * List boxes display a number of items within a scrolling frame; the items 
williamr@2
    99
 * in a list box which are visible at one time are represented by a list 
williamr@2
   100
 * box view. 
williamr@2
   101
 * 
williamr@2
   102
 * Writing derived classes: 
williamr@2
   103
 * 
williamr@2
   104
 * This class may be derived from to provide specialisations of the basic 
williamr@2
   105
 * list box behaviour. It is usual when subclassing CEikListBox to also 
williamr@2
   106
 * provide specialisations of CListItemDrawer and CListBoxView for 
williamr@2
   107
 * representing the data of such a list box effectively
williamr@2
   108
 */
williamr@2
   109
class CEikListBox : public CEikBorderedControl, public MEikScrollBarObserver
williamr@2
   110
    {
williamr@2
   111
williamr@2
   112
public:
williamr@2
   113
williamr@2
   114
    friend class CListBoxExt;
williamr@2
   115
williamr@2
   116
public:
williamr@2
   117
williamr@2
   118
    /**
williamr@2
   119
    * Construction flags.
williamr@2
   120
    */
williamr@2
   121
    enum TFlags
williamr@2
   122
        {
williamr@2
   123
        
williamr@2
   124
        /**
williamr@2
   125
         * Construction flag for a list box from which the user can
williamr@2
   126
         * select multiple items.
williamr@2
   127
         */
williamr@2
   128
        EMultipleSelection          = SLafListBox::EMultipleSelection,
williamr@2
   129
        
williamr@2
   130
        /**
williamr@2
   131
         * Construction flag for disabling extended selection. 
williamr@2
   132
         * If this is set the user cannot select multiple items by
williamr@2
   133
         * using @c SHIFT button.
williamr@2
   134
         */
williamr@2
   135
        ENoExtendedSelection        = SLafListBox::ENoExtendedSelection,
williamr@2
   136
        
williamr@2
   137
        /**
williamr@2
   138
         * Construction flag that sets the list box to match user’s keystrokes 
williamr@2
   139
         * incrementally.
williamr@2
   140
         */
williamr@2
   141
        EIncrementalMatching        = SLafListBox::EIncrementalMatching,
williamr@2
   142
        
williamr@2
   143
        /**
williamr@2
   144
         * Construction flag for setting the list box as a pop-out list box. 
williamr@2
   145
         * Pop-out list boxes handle certain keystrokes and events differently.
williamr@2
   146
         */
williamr@2
   147
        EPopout                     = SLafListBox::EPopout,
williamr@2
   148
williamr@2
   149
        /**
williamr@2
   150
         * Construction flag that enables the indication of pointer press 
williamr@2
   151
         * inside the view of the list box.
williamr@2
   152
         */
williamr@2
   153
        ELeftDownInViewRect         = SLafListBox::ELeftDownInViewRect,
williamr@2
   154
        
williamr@2
   155
        /**
williamr@2
   156
         * Construction flag for enabling @c CEiklist box item double click 
williamr@2
   157
         * indication.
williamr@2
   158
         */
williamr@2
   159
        EItemDoubleClicked          = SLafListBox::EItemDoubleClicked,
williamr@2
   160
                
williamr@2
   161
        /**
williamr@2
   162
         * Construction flag for removing the ownership of the supplied list box
williamr@2
   163
         * model from the @c CEikListBox so that the list box model will not be 
williamr@2
   164
         * deleted with the @c CEikListBoxes destruction.
williamr@2
   165
         */
williamr@2
   166
        EKeepModel                  = SLafListBox::EKeepModel,
williamr@2
   167
        
williamr@2
   168
        /**
williamr@2
   169
         * Construction flag for excluding the scroll bar.
williamr@2
   170
         * If the flag is set the scroll bas is drawn ouside the window that 
williamr@2
   171
         * describes the scroll bars extent.
williamr@2
   172
         */
williamr@2
   173
        EScrollBarSizeExcluded      = SLafListBox::EScrollBarSizeExcluded,
williamr@2
   174
williamr@2
   175
        /**
williamr@2
   176
         * Construction flag for enabling @c CEikListBox change indication.
williamr@2
   177
         */
williamr@2
   178
        EStateChanged               = SLafListBox::EStateChanged,
williamr@2
   179
williamr@2
   180
        /**
williamr@2
   181
         * Construction flag that indicates that the list box should be created 
williamr@2
   182
         * to its own window.
williamr@2
   183
         */
williamr@2
   184
        ECreateOwnWindow            = SLafListBox::ECreateOwnWindow,
williamr@2
   185
williamr@2
   186
        /**
williamr@2
   187
         * Construction flag for disabling key matching.
williamr@2
   188
         */
williamr@2
   189
        ENoFirstLetterMatching      = SLafListBox::ENoFirstLetterMatching,
williamr@2
   190
williamr@2
   191
        /**
williamr@2
   192
         * Construction flag for enabling painting of selected items.
williamr@2
   193
         */
williamr@2
   194
        EPaintedSelection           = SLafListBox::EPaintedSelection ,
williamr@2
   195
williamr@2
   196
        /**
williamr@2
   197
         * Construction flag for enabling loop scrolling in which the list box 
williamr@2
   198
         * jumps from the last item to the first item.
williamr@2
   199
         */
williamr@2
   200
        ELoopScrolling = 0x1000,
williamr@2
   201
williamr@2
   202
        /**
williamr@2
   203
         * Construction flag for enabling @c Avkon multiselection list.
williamr@2
   204
         */
williamr@2
   205
        EEnterMarks = 0x2000,       // Avkon multiselection list
williamr@2
   206
williamr@2
   207
        /**
williamr@2
   208
         * Construction flag for enabling Avkon markable list which enables the 
williamr@2
   209
         * marking of several items from the list. 
williamr@2
   210
         */
williamr@2
   211
        EShiftEnterMarks = 0x4000,  // Avkon markable list
williamr@2
   212
williamr@2
   213
        /**
williamr@2
   214
         * Construction flag that combines @c EPageAtOnceScrolling and 
williamr@2
   215
         * @c EDisableHighlight flags
williamr@2
   216
         */
williamr@2
   217
        EViewerFlag = 0x8000,       // combined the two flags to fit to WORD.
williamr@2
   218
williamr@2
   219
        /**
williamr@2
   220
         * Construction flag for enabling scrolling at a page per time so that 
williamr@2
   221
         * the whole list box page is scrolled to the next. 
williamr@2
   222
         */
williamr@2
   223
        EPageAtOnceScrolling = 0x8000, // Avkon viewers
williamr@2
   224
williamr@2
   225
        /**
williamr@2
   226
         * Construction flag for disabling the highlighting of the selected item.
williamr@2
   227
         */
williamr@2
   228
        EDisableHighlight = 0x8000,  // Avkon viewers       
williamr@2
   229
williamr@2
   230
        /**
williamr@2
   231
         * Construction flag for enabling S60 style selection of multiple items 
williamr@2
   232
         * from the list box.
williamr@2
   233
         */
williamr@2
   234
        ES60StyleMultiselection     = SLafListBox::ES60StyleMultiselection,   
williamr@2
   235
        
williamr@2
   236
        /**
williamr@2
   237
         * Construction flag for enabling S60 style markable items.
williamr@2
   238
         */
williamr@2
   239
        ES60StyleMarkable           = SLafListBox::ES60StyleMarkable
williamr@2
   240
        };
williamr@2
   241
    enum {KEikMaxMatchingBufferLength = 2};
williamr@2
   242
williamr@2
   243
    /** 
williamr@2
   244
     * Indicates who owns the scroll bar.
williamr@2
   245
     */ 
williamr@2
   246
    enum TScrollBarOwnerShip
williamr@2
   247
        {
williamr@2
   248
        /**
williamr@2
   249
         * Indicates that the scrollbar is not owned by an external class.
williamr@2
   250
         */
williamr@2
   251
        ENotOwnedExternally=0x0000,
williamr@2
   252
        /**
williamr@2
   253
         * Indicates that the scrollbar is owned by an external class.
williamr@2
   254
         */
williamr@2
   255
        EOwnedExternally   =0x0001
williamr@2
   256
        };
williamr@2
   257
williamr@2
   258
protected:
williamr@2
   259
williamr@2
   260
    /**
williamr@2
   261
     * Used for indicating the reason why the item lost focus.
williamr@2
   262
     */
williamr@2
   263
    enum TReasonForFocusLost
williamr@2
   264
        { 
williamr@2
   265
        /**
williamr@2
   266
         * Focus has been lost from the list box to an external control.
williamr@2
   267
         */
williamr@2
   268
        EFocusLostToExternalControl, 
williamr@2
   269
        /**
williamr@2
   270
         * Focus has been moved from the list box to an internal editor.
williamr@2
   271
         */
williamr@2
   272
        EFocusLostToInternalEditor 
williamr@2
   273
        };
williamr@2
   274
williamr@2
   275
public:
williamr@2
   276
    /**
williamr@2
   277
     * Destructor.
williamr@2
   278
     */
williamr@2
   279
    IMPORT_C ~CEikListBox();
williamr@2
   280
williamr@2
   281
    /**
williamr@2
   282
     * C++ default constructor.
williamr@2
   283
     */
williamr@2
   284
    IMPORT_C CEikListBox();
williamr@2
   285
    /**
williamr@2
   286
     * Handles 2nd phase construction.
williamr@2
   287
     * 
williamr@2
   288
     * Sets list box model and list item drawer. Request another @c ConstructL 
williamr@2
   289
     * to handle @c aParent and @c aFlags. 
williamr@2
   290
     *
williamr@2
   291
     * @param aListBoxModel List box model that is to be used with the list box.
williamr@2
   292
     * @param aListItemDrawer List item drawer that is to be used with the 
williamr@2
   293
     *        list box.
williamr@2
   294
     * @param aParent Host @c CoeControl for the list box.
williamr@2
   295
     * @param aFlags Construction flags (@c TFlags) for the list box.
williamr@2
   296
     */
williamr@2
   297
    IMPORT_C void ConstructL(MListBoxModel* aListBoxModel,
williamr@2
   298
                             CListItemDrawer* aListItemDrawer,
williamr@2
   299
                             const CCoeControl* aParent,
williamr@2
   300
                             TInt aFlags = 0);
williamr@2
   301
    
williamr@2
   302
    /**
williamr@2
   303
     * Handles 2nd phase construction.
williamr@2
   304
     *
williamr@2
   305
     *
williamr@2
   306
     * Sets the border that is to be drawn outside the list box. Request another 
williamr@2
   307
     * @c ConstructL to handle list box model, list item drawer, @c aParent 
williamr@2
   308
     * and @c aFlags. 
williamr@2
   309
     *
williamr@2
   310
     * @param aListBoxModel List box model that is to be used with the list box.
williamr@2
   311
     * @param aListItemDrawer List item drawer that is to be used with the 
williamr@2
   312
     *        list box.
williamr@2
   313
     * @param aParent Host @c CoeControl for the list box.
williamr@2
   314
     * @param aBorder Border to be drawn outside the list box.
williamr@2
   315
     * @param aFlags Construction flags (@c TFlags) for the list box.
williamr@2
   316
     */
williamr@2
   317
    IMPORT_C void ConstructL(MListBoxModel* aListBoxModel,
williamr@2
   318
                             CListItemDrawer* aListItemDrawer,
williamr@2
   319
                             const CCoeControl* aParent, 
williamr@2
   320
                             TGulBorder aBorder, 
williamr@2
   321
                             TInt aFlags = 0);
williamr@2
   322
    /**
williamr@2
   323
     * Informs the @c CEikListbox of a key press.
williamr@2
   324
     *
williamr@2
   325
     * @param aKeyEvent Details of the key event that is being handled.
williamr@2
   326
     * @param aType Defines what kind of key event is being handled e.g. 
williamr@2
   327
     *        @c EEventKeyUp.
williamr@2
   328
     * @return @c EKeyWasConsumed if the key was handled by the method.
williamr@2
   329
     *         @c EKeyWasNotConsumed if the key was not handled.
williamr@2
   330
     */
williamr@2
   331
    IMPORT_C virtual TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
williamr@2
   332
                                                 TEventCode aType);
williamr@2
   333
    
williamr@2
   334
    /**
williamr@2
   335
     * Handling of pointer event within the @c CEikListBox. 
williamr@2
   336
     * Used for e.g. selecting an item from the list box.
williamr@2
   337
     *
williamr@2
   338
     * @param aPointerEvent Details of the pointer event that is being handled.
williamr@2
   339
     */
williamr@2
   340
    IMPORT_C virtual void HandlePointerEventL(
williamr@2
   341
                            const TPointerEvent& aPointerEvent);
williamr@2
   342
    
williamr@2
   343
    /**
williamr@2
   344
     * Creates an own window for the list box or draws the list box to an old 
williamr@2
   345
     * window defined by the @c aContainer.
williamr@2
   346
     *
williamr@2
   347
     * @param aContainer Defines the container where the list box will be drawn.
williamr@2
   348
     */
williamr@2
   349
    IMPORT_C virtual void SetContainerWindowL(const CCoeControl& aContainer);
williamr@2
   350
    
williamr@2
   351
    /**
williamr@2
   352
     * Checks the minimum size needed for the list box.
williamr@2
   353
     *
williamr@2
   354
     * @return The two dimensional minimum size for the list box.
williamr@2
   355
     */
williamr@2
   356
    IMPORT_C virtual TSize MinimumSize();
williamr@2
   357
    
williamr@2
   358
    /**
williamr@2
   359
     * This function sets a flag within the control which indicates 
williamr@2
   360
     * whether or not the control is dimmed (greyed out). 
williamr@2
   361
     *
williamr@2
   362
     * @param aDimmed @c ETrue dimmed. @c EFalse not dimmed.
williamr@2
   363
     */
williamr@2
   364
    IMPORT_C virtual void SetDimmed(TBool aDimmed);
williamr@2
   365
williamr@2
   366
    /**
williamr@2
   367
     * Used for scrolling through the items in the list box. 
williamr@2
   368
     *
williamr@2
   369
     * @param aScrollBar Scroll bar for the list box.
williamr@2
   370
     * @param aEventType Type of the event that occured.
williamr@2
   371
     */
williamr@2
   372
    IMPORT_C virtual void HandleScrollEventL(CEikScrollBar* aScrollBar, 
williamr@2
   373
                                             TEikScrollEvent aEventType);
williamr@2
   374
williamr@2
   375
    // model/view access functions 
williamr@2
   376
    /**
williamr@2
   377
     * Gets the list box data model.
williamr@2
   378
     *
williamr@2
   379
     * @return Interface to the list box data model.
williamr@2
   380
     */
williamr@2
   381
    IMPORT_C MListBoxModel* Model() const;
williamr@2
   382
williamr@2
   383
    /**
williamr@2
   384
     * Gets the list box view.
williamr@2
   385
     *
williamr@2
   386
     * @return Interface to the list box view.
williamr@2
   387
     */
williamr@2
   388
    IMPORT_C CListBoxView* View() const;
williamr@2
   389
williamr@2
   390
    // functions for accessing top/current/bottom item index
williamr@2
   391
    /**
williamr@2
   392
     * Gets the index number of the top item.
williamr@2
   393
     *
williamr@2
   394
     * @return Index number for the top item.
williamr@2
   395
     */
williamr@2
   396
    IMPORT_C TInt TopItemIndex() const;
williamr@2
   397
    
williamr@2
   398
    /**
williamr@2
   399
     * Sets the selected item to be the top item.
williamr@2
   400
     *
williamr@2
   401
     * @param aItemIndex Index for the item to be set as the top item.
williamr@2
   402
     */
williamr@2
   403
    IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex) const;
williamr@2
   404
    
williamr@2
   405
    /**
williamr@2
   406
     * Gets for the bottom items index.
williamr@2
   407
     *
williamr@2
   408
     * @return Index for the bottom item.
williamr@2
   409
     */
williamr@2
   410
    IMPORT_C TInt BottomItemIndex() const;
williamr@2
   411
    
williamr@2
   412
    /**
williamr@2
   413
     * Gets the index number of the selected item.
williamr@2
   414
     *
williamr@2
   415
     * @return Index of the selected item.
williamr@2
   416
     */
williamr@2
   417
    IMPORT_C TInt CurrentItemIndex() const;   
williamr@2
   418
    
williamr@2
   419
    /**
williamr@2
   420
     * Changes the current item index to the selected item index. Does not
williamr@2
   421
     * redraw the list. If the item was not previously visible it is set to the 
williamr@2
   422
     * top item in the view.
williamr@2
   423
     *
williamr@2
   424
     * @param aItemIndex Defines the index of the selected item.
williamr@2
   425
     */
williamr@2
   426
    IMPORT_C void SetCurrentItemIndex(TInt aItemIndex) const;
williamr@2
   427
    
williamr@2
   428
    /**
williamr@2
   429
     * Changes the current item index to the selected item index and 
williamr@2
   430
     * redraws the view.
williamr@2
   431
     *
williamr@2
   432
     * @param aItemIndex Defines the index of the selected item.
williamr@2
   433
     */
williamr@2
   434
    IMPORT_C void SetCurrentItemIndexAndDraw(TInt aItemIndex) const;
williamr@2
   435
williamr@2
   436
    // functions for dealing with the selection state
williamr@2
   437
    /**
williamr@2
   438
     * Gets for list boxes selection indexes.
williamr@2
   439
     *
williamr@2
   440
     * @return Pointer to the list boxes in array of selection indexes.
williamr@2
   441
     */
williamr@2
   442
    IMPORT_C const CListBoxView::CSelectionIndexArray* SelectionIndexes() const;
williamr@2
   443
    
williamr@2
   444
    /**
williamr@2
   445
     * Assigns a array of selection indexes for the list box.
williamr@2
   446
     *
williamr@2
   447
     * @param aArrayOfSelectionIndexes The index array that is to be assigned 
williamr@2
   448
     *        to the list Box.
williamr@2
   449
     */
williamr@2
   450
    IMPORT_C void SetSelectionIndexesL(
williamr@2
   451
                CListBoxView::CSelectionIndexArray* aArrayOfSelectionIndexes);
williamr@2
   452
    
williamr@2
   453
    /**
williamr@2
   454
     * Clears the selection from the view.
williamr@2
   455
     */
williamr@2
   456
    IMPORT_C void ClearSelection(); 
williamr@2
   457
williamr@2
   458
    // Functions for updating a list box's internal state after its model has
williamr@2
   459
    // been updated, all of them will emit item change event to item change
williamr@2
   460
    // observers.
williamr@2
   461
    /**
williamr@2
   462
     * Handles the addition of item to the list box.
williamr@2
   463
     */
williamr@2
   464
    IMPORT_C void HandleItemAdditionL();
williamr@2
   465
    
williamr@2
   466
    /**
williamr@2
   467
     * Handles the removal of an item from the list box.
williamr@2
   468
     */
williamr@2
   469
    IMPORT_C void HandleItemRemovalL();
williamr@2
   470
williamr@2
   471
    /**
williamr@2
   472
     * Handles the addition of new items to the list box and updates 
williamr@2
   473
     * selection indexes array.
williamr@2
   474
     *
williamr@2
   475
     * NOTE. This algorithm can not handle position of the list highlight
williamr@2
   476
     * nor can it update the top item index correctly.
williamr@2
   477
     *
williamr@2
   478
     * @param aArrayOfNewIndexesAfterAddition Array of new indexes to be added.
williamr@2
   479
     */
williamr@2
   480
    IMPORT_C void HandleItemAdditionL(
williamr@2
   481
                    CArrayFix<TInt> &aArrayOfNewIndexesAfterAddition);
williamr@2
   482
    
williamr@2
   483
    /**
williamr@2
   484
     * Handles the removal of items to the list box and updates 
williamr@2
   485
     * selection indexes array.
williamr@2
   486
     *
williamr@2
   487
     * NOTE. This algorithm cannot handle position of the list highlight
williamr@2
   488
     * nor can it update the top item index correctly.
williamr@2
   489
     *
williamr@2
   490
     * @param aArrayOfOldIndexesBeforeRemoval Array of indexes to be removed.
williamr@2
   491
     */
williamr@2
   492
    IMPORT_C void HandleItemRemovalL(
williamr@2
   493
                    CArrayFix<TInt> &aArrayOfOldIndexesBeforeRemoval);
williamr@2
   494
    
williamr@2
   495
    /**
williamr@2
   496
     * Deletes the item editor
williamr@2
   497
     */
williamr@2
   498
    IMPORT_C void Reset();
williamr@2
   499
williamr@2
   500
    /**
williamr@2
   501
    * Adds an item change observer to the listbox. Duplicates are not checked
williamr@2
   502
    * (i.e. adding the same observer multiple times is not prevented).
williamr@2
   503
    *
williamr@2
   504
    * @since 3.0
williamr@2
   505
    * @param aObserver Must be non-NULL.
williamr@2
   506
    */
williamr@2
   507
    IMPORT_C void AddItemChangeObserverL( MListBoxItemChangeObserver* aObserver );
williamr@2
   508
    /**
williamr@2
   509
    * Removes an item change observer from the listbox.
williamr@2
   510
    *
williamr@2
   511
    * @since 3.0
williamr@2
   512
    * @param aObserver The observer to be removed.
williamr@2
   513
    * @return ETrue if removal ok, EFalse if observer was not removed (not
williamr@2
   514
    *         found from the list of observers).
williamr@2
   515
    */
williamr@2
   516
    IMPORT_C TBool RemoveItemChangeObserver( MListBoxItemChangeObserver* aObserver );
williamr@2
   517
williamr@2
   518
    // functions for accessing the item height
williamr@2
   519
    /**
williamr@2
   520
     * Sets the height of the item to the selected value.
williamr@2
   521
     * 
williamr@2
   522
     * @param aHeight New height for the item.
williamr@2
   523
     */
williamr@2
   524
    IMPORT_C virtual void SetItemHeightL(TInt aHeight);
williamr@2
   525
    
williamr@2
   526
    /**
williamr@2
   527
     * Gets height of the item.
williamr@2
   528
     *
williamr@2
   529
     * @return Height of the item.
williamr@2
   530
     */
williamr@2
   531
    IMPORT_C TInt ItemHeight() const;
williamr@2
   532
williamr@2
   533
    // functions for scrollbars
williamr@2
   534
    /**
williamr@2
   535
     * Creates a scrollbar frame.
williamr@2
   536
     *
williamr@2
   537
     * @param  aPreAlloc Boolean defining if there should be initial 
williamr@2
   538
     *         memory allocations.
williamr@2
   539
     * @return The new scroll bar frame.
williamr@2
   540
     */
williamr@2
   541
    IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL(TBool aPreAlloc=EFalse);
williamr@2
   542
williamr@2
   543
    /**
williamr@2
   544
     * Sets the given scroll bar frame for the list box with the given 
williamr@2
   545
     * ownership leve.
williamr@2
   546
     *
williamr@2
   547
     * @param aScrollBarFrame The new frame that is going to be used.
williamr@2
   548
     * @param aOwnerShip Ownership level of the scroll bar frame.
williamr@2
   549
     */
williamr@2
   550
    IMPORT_C void SetScrollBarFrame(CEikScrollBarFrame* aScrollBarFrame, TScrollBarOwnerShip aOwnerShip);
williamr@2
   551
williamr@2
   552
    /**
williamr@2
   553
     * Gets pointer for the scroll bar frame.
williamr@2
   554
     *
williamr@2
   555
     * @return Pointer to the scroll bar frame.
williamr@2
   556
     */
williamr@2
   557
    IMPORT_C CEikScrollBarFrame* const ScrollBarFrame();
williamr@2
   558
williamr@2
   559
    /**
williamr@2
   560
     * Updates all scroll bars.
williamr@2
   561
     */
williamr@2
   562
    IMPORT_C virtual void UpdateScrollBarsL();
williamr@2
   563
williamr@2
   564
    // construction support functions
williamr@2
   565
    /**
williamr@2
   566
     * Gets the size of the rectangle required to display a pop out.
williamr@2
   567
     * 
williamr@2
   568
     * @param aTargetItemIndex The item from which the popout originates.
williamr@2
   569
     * @param aTargetYPos Vertical position of the item from which the popout 
williamr@2
   570
     *        originates.
williamr@2
   571
     * @param aListBoxRect The list box rectangle.
williamr@2
   572
     * @param aMinHeightInNumOfItems The minimum number of items for the popout.
williamr@2
   573
     */
williamr@2
   574
    IMPORT_C void CalculatePopoutRect( TInt aTargetItemIndex,
williamr@2
   575
                                       TInt aTargetYPos,
williamr@2
   576
                                       TRect& aListBoxRect,
williamr@2
   577
                                       TInt aMinHeightInNumOfItems = 1 );
williamr@2
   578
    /**
williamr@2
   579
     * Gets the size of the list box in pixels based on the height of 
williamr@2
   580
     * the list box in items and the length of the items in characters.
williamr@2
   581
     *
williamr@2
   582
     * Returns @c TSize element consisting of two elements, the height 
williamr@2
   583
     * and the width. Height is the number of items times the height 
williamr@2
   584
     * of the font in pixels. Width is the number of characters in a 
williamr@2
   585
     * single line times the width of the font in pixels. 
williamr@2
   586
     *
williamr@2
   587
     * @param aWidthAsNumOfChars Width of list box in characters.
williamr@2
   588
     * @param aHeightAsNumOfItems Height of list box in characters.
williamr@2
   589
     * @return The size of the list box in pixels as TSize.
williamr@2
   590
     */
williamr@2
   591
    IMPORT_C TSize CalcSizeInPixels(TInt aWidthAsNumOfChars, 
williamr@2
   592
                                    TInt aHeightAsNumOfItems) const;
williamr@2
   593
williamr@2
   594
    /**
williamr@2
   595
     * Gets the width of the list box in pixels based on the width of the list 
williamr@2
   596
     * box in characters.
williamr@2
   597
     *
williamr@2
   598
     * Returns the number of characters times the width of a character 
williamr@2
   599
     * in pixels. 
williamr@2
   600
     *
williamr@2
   601
     * @param aNumOfChars The number of characters.
williamr@2
   602
     * @return The width of the list box in pixels.
williamr@2
   603
     */
williamr@2
   604
    IMPORT_C TInt CalcWidthBasedOnNumOfChars(TInt aNumOfChars) const;
williamr@2
   605
    
williamr@2
   606
    /**
williamr@2
   607
     * Gets the height of the list box in pixels based on the width of the 
williamr@2
   608
     * list box in characters.
williamr@2
   609
     *
williamr@2
   610
     * Returns the number of items times the height of the font in pixels.
williamr@2
   611
     *
williamr@2
   612
     * @param aNumOfItems The number of items.
williamr@2
   613
     * @return The height of the list box in pixels.
williamr@2
   614
     */
williamr@2
   615
    IMPORT_C TInt CalcHeightBasedOnNumOfItems(TInt aNumOfItems) const;
williamr@2
   616
    
williamr@2
   617
    /**
williamr@2
   618
     * Gets the width of the list box in pixels based on the width of the 
williamr@2
   619
     * list box text in pixels.
williamr@2
   620
     *
williamr@2
   621
     * returns the width of the whole list box in pixels, which includes 
williamr@2
   622
     * the text width and the width of elements in the list box that have
williamr@2
   623
     * an effect on the overall width.
williamr@2
   624
     *
williamr@2
   625
     * @param aTextWidthInPixels Width of list box text in pixels.
williamr@2
   626
     * @return Required width of whole list box in pixels.
williamr@2
   627
     */
williamr@2
   628
    IMPORT_C TInt CalcWidthBasedOnRequiredItemWidth(
williamr@2
   629
                                TInt aTextWidthInPixels) const;
williamr@2
   630
williamr@2
   631
    // drawing/scrolling functions
williamr@2
   632
    /**
williamr@2
   633
     * Draws a list box item, first scrolling the list to make it visible 
williamr@2
   634
     * if it is not already. 
williamr@2
   635
     *
williamr@2
   636
     * @c DrawItem() panics if there is no list box view currently set.
williamr@2
   637
     * @param aItemIndex Index of the item to reveal.
williamr@2
   638
     */
williamr@2
   639
    IMPORT_C void DrawItem(TInt aItemIndex) const;
williamr@2
   640
williamr@2
   641
    /**
williamr@2
   642
     * Makes an item visible in the list, scrolling it if necessary.
williamr@2
   643
     *
williamr@2
   644
     * @param aItemIndex Index of the item to reveal.
williamr@2
   645
     */
williamr@2
   646
    IMPORT_C void ScrollToMakeItemVisible(TInt aItemIndex) const;
williamr@2
   647
williamr@2
   648
    /**
williamr@2
   649
    * Redraws list item.
williamr@2
   650
    * @param aItemIndex index of item to be redrawn.
williamr@2
   651
    * @since 3.2
williamr@2
   652
    */
williamr@2
   653
    IMPORT_C void RedrawItem( TInt aItemIndex );
williamr@2
   654
williamr@2
   655
    // observer support
williamr@2
   656
    /**
williamr@2
   657
     * Sets the observer for the list box.
williamr@2
   658
     *
williamr@2
   659
     * @param aObserver Wanted observer for the list box.
williamr@2
   660
     */
williamr@2
   661
    IMPORT_C void SetListBoxObserver(MEikListBoxObserver* aObserver);
williamr@2
   662
williamr@2
   663
    
williamr@2
   664
    /**
williamr@2
   665
     * Gets the size of the vertical gap between items. This space is used 
williamr@2
   666
     * by the view to allow a box to be drawn around each item.
williamr@2
   667
     *
williamr@2
   668
     * @return Size of the vertical gap in pixels.
williamr@2
   669
     */
williamr@2
   670
    IMPORT_C TInt VerticalInterItemGap() const;
williamr@2
   671
williamr@2
   672
    // popouts only
williamr@2
   673
    /**
williamr@2
   674
     * Provides a call back mechanism to the button which just launched a 
williamr@2
   675
     * popout menu.
williamr@2
   676
     *
williamr@2
   677
     * @param aButton The button which just launched a popout menu.
williamr@2
   678
     */
williamr@2
   679
    IMPORT_C void SetLaunchingButton(CEikButtonBase* aButton);
williamr@2
   680
williamr@2
   681
    // Editing support
williamr@2
   682
    /**
williamr@2
   683
     * Selects an item editor for the list box.
williamr@2
   684
     *
williamr@2
   685
     * @param aEditor The editor that has been selected for usage.
williamr@2
   686
     */
williamr@2
   687
    IMPORT_C void SetItemEditor(MEikListBoxEditor* aEditor);
williamr@2
   688
    
williamr@2
   689
    /**
williamr@2
   690
     * Resets the list boxes item editor.
williamr@2
   691
     */
williamr@2
   692
    IMPORT_C void ResetItemEditor();
williamr@2
   693
    /**
williamr@2
   694
     * Gets item editor for the current class.
williamr@2
   695
     *
williamr@2
   696
     * @return The item editor used by the list box class.
williamr@2
   697
     */
williamr@2
   698
    IMPORT_C MEikListBoxEditor* ItemEditor();
williamr@2
   699
    
williamr@2
   700
    /**
williamr@2
   701
     * Creates an item editor and starts editing the current item.
williamr@2
   702
     *
williamr@2
   703
     * The editor can edit the current item up to a maximum length of 
williamr@2
   704
     * @c aMaxLength characters. Also reports an @c EEventEditingStarted event 
williamr@2
   705
     * to any list box observer by default.
williamr@2
   706
     *
williamr@2
   707
     * The function only creates a new editor if one does not already exist.
williamr@2
   708
     *
williamr@2
   709
     * @param aMaxLength Maximum length of characters to edit.
williamr@2
   710
     */
williamr@2
   711
    IMPORT_C virtual void EditItemL(TInt aMaxLength);
williamr@2
   712
    
williamr@2
   713
    /**
williamr@2
   714
     * Stops editing and deletes the item editor. 
williamr@2
   715
     *
williamr@2
   716
     * The function reports an @c EEventEditingStopped event to any list box 
williamr@2
   717
     * observer, and updates the list box model if @c aUpdateModel is @c ETrue.
williamr@2
   718
     *
williamr@2
   719
     * @param aUpdateModel If @c ETrue the list box model is updated.
williamr@2
   720
     */
williamr@2
   721
    IMPORT_C void StopEditingL(TBool aUpdateModel);
williamr@2
   722
williamr@2
   723
    // functions needed for Avkon shortcuts, 
williamr@2
   724
    // passing information from one list to another
williamr@2
   725
williamr@2
   726
    /**
williamr@2
   727
     * No Implementation.
williamr@2
   728
     *
williamr@2
   729
     * @return Always returns 0.
williamr@2
   730
     */
williamr@2
   731
    IMPORT_C virtual TInt ShortcutValueForNextList();
williamr@2
   732
    
williamr@2
   733
    /**
williamr@2
   734
     * No Implementation.
williamr@2
   735
     *
williamr@2
   736
     * @param aValue Not Used.
williamr@2
   737
     */
williamr@2
   738
    IMPORT_C virtual void SetShortcutValueFromPrevList(TInt aValue);
williamr@2
   739
williamr@2
   740
    // pop-up positioning support
williamr@2
   741
    /**
williamr@2
   742
     * Gets the position and the size of the list box.
williamr@2
   743
     *
williamr@2
   744
     * @return A rectangle with the correct position data as 
williamr@2
   745
     *         well as size data for the list box.
williamr@2
   746
     */
williamr@2
   747
    IMPORT_C TRect HighlightRect() const;
williamr@2
   748
    
williamr@2
   749
    /**
williamr@2
   750
     * Checks whether background drawing is suppressed on item level i.e. each
williamr@2
   751
	 *  list item doesn't draw its background.
williamr@2
   752
	 *
williamr@2
   753
	 * @since S60 5.0
williamr@2
   754
	 * @return ETrue if background drawing is suppressed.
williamr@2
   755
     */
williamr@2
   756
     IMPORT_C TBool BackgroundDrawingSuppressed() const;
williamr@2
   757
williamr@2
   758
public: // from CCoeControl
williamr@2
   759
williamr@2
   760
    /**
williamr@2
   761
     * From @c CCoeControl
williamr@2
   762
     *
williamr@2
   763
     * Gets the list of logical colours employed in the drawing of the control, 
williamr@2
   764
     * paired with an explanation of how they are used. Appends the list to 
williamr@2
   765
     * @c aColorUseList.
williamr@2
   766
     *
williamr@2
   767
     * @param aColorUseList List of logical colours.
williamr@2
   768
     */
williamr@2
   769
    IMPORT_C virtual void GetColorUseListL(
williamr@2
   770
                        CArrayFix<TCoeColorUse>& aColorUseList) const; 
williamr@2
   771
                        // not available before Release 005u
williamr@2
   772
    
williamr@2
   773
    /**
williamr@2
   774
     * From @c CCoeControl
williamr@2
   775
     *
williamr@2
   776
     * Handles a change to the list box’s resources of type @c aType which are 
williamr@2
   777
     * shared across the environment, colours or fonts for example.
williamr@2
   778
     *
williamr@2
   779
     * @param aType The type of resources that have changed.
williamr@2
   780
     */
williamr@2
   781
    IMPORT_C virtual void HandleResourceChange(TInt aType);         
williamr@2
   782
                // not available before Release 005u
williamr@2
   783
    
williamr@2
   784
    /**
williamr@2
   785
     * From @c CCoeControl
williamr@2
   786
     *
williamr@2
   787
     * Sets the control as ready to be drawn.
williamr@2
   788
     *
williamr@2
   789
     * The application should call this function on all controls that are not 
williamr@2
   790
     * components in a compound control.
williamr@2
   791
     *
williamr@2
   792
     * The purpose of this function is that controls are not always ready to 
williamr@2
   793
     * be drawn as soon as they have been constructed. For example, it may 
williamr@2
   794
     * not be possible to set the control's extent during construction, but 
williamr@2
   795
     * its extent should always be set before it is drawn. Similarly, if a 
williamr@2
   796
     * control is to be made  invisible, this should be done before it is 
williamr@2
   797
     * activated.
williamr@2
   798
     * 
williamr@2
   799
     * The default implementation sets a flag in the control to indicate it is 
williamr@2
   800
     * ready to be drawn. If the control is a compound control, the default 
williamr@2
   801
     * implementation also calls @c ActivateL() for all the control's components. 
williamr@2
   802
     * To get the control's components it uses @c CountComponentControls() and 
williamr@2
   803
     * @c ComponentControl(), which should be implemented by the compound control.
williamr@2
   804
     * 
williamr@2
   805
     * @c ActivateL() is typically called from the control's @c ConstructL() 
williamr@2
   806
     * function.
williamr@2
   807
     *
williamr@2
   808
     * Notes:
williamr@2
   809
     *
williamr@2
   810
     * This function can be overridden. This is useful for doing late 
williamr@2
   811
     * initialisation of the control, using information that was not available 
williamr@2
   812
     * at the time the control was created. For example, a text editor might 
williamr@2
   813
     * override @c ActivateL() and use it to enquire whether it is focused: if 
williamr@2
   814
     * it is, it makes the cursor and any highlighting visible. At the time when 
williamr@2
   815
     * the editor is created, it doesn't know whether or not it has keyboard 
williamr@2
   816
     * focus.
williamr@2
   817
     *
williamr@2
   818
     * If overriding @c ActivateL(), the implementation must include a base 
williamr@2
   819
     * call to @c CCoeControl's @c ActivateL(). 
williamr@2
   820
     */
williamr@2
   821
    IMPORT_C virtual void ActivateL();
williamr@2
   822
    
williamr@2
   823
    /**
williamr@2
   824
     * From @c CCoeControl.
williamr@2
   825
     *
williamr@2
   826
     * Gets the input capabilities of the control and all its components.
williamr@2
   827
     *
williamr@2
   828
     * @return The input capabilities of the control.
williamr@2
   829
     */
williamr@2
   830
    IMPORT_C TCoeInputCapabilities InputCapabilities() const;
williamr@2
   831
williamr@2
   832
private:
williamr@2
   833
    /**
williamr@2
   834
    * From CAknControl
williamr@2
   835
    */
williamr@2
   836
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2
   837
williamr@2
   838
protected:
williamr@2
   839
    // Shortcuts need access to Incremental matching
williamr@2
   840
    // The shortcuts will be used inside OfferkeyEventL().
williamr@2
   841
    friend class AknListBoxShortCutsImplementation;
williamr@2
   842
    // Avkon layout uses SetVerticalMargin, which is protected.
williamr@2
   843
    friend class AknListBoxLayouts;
williamr@2
   844
williamr@2
   845
    /**
williamr@2
   846
     * Responds to a change in focus.
williamr@2
   847
     *
williamr@2
   848
     * This is called whenever the control gains or loses focus, 
williamr@2
   849
     * as a result of a call to @c SetFocus(). A typical use of 
williamr@2
   850
     * @c FocusChanged() is to change the appearance of the control, 
williamr@2
   851
     * for example by drawing a focus rectangle around it.
williamr@2
   852
     *
williamr@2
   853
     * The default implementation is empty, and should be 
williamr@2
   854
     * overridden by the @c CCoeControl-derived class.
williamr@2
   855
     *
williamr@2
   856
     * @param aDrawNow Contains the value that was passed to it 
williamr@2
   857
     *        by @c SetFocus().
williamr@2
   858
     */
williamr@2
   859
    IMPORT_C virtual void FocusChanged(TDrawNow aDrawNow);
williamr@2
   860
    
williamr@2
   861
    /**
williamr@2
   862
     * Responds to changes to the size and position of the contents 
williamr@2
   863
     * of this control.
williamr@2
   864
     * 
williamr@2
   865
     * For a simple control this might include text or graphics. 
williamr@2
   866
     * For a compound control it sets the size and position of the 
williamr@2
   867
     * components. It has an empty default implementation and should 
williamr@2
   868
     * be implemented by the CCoeControl-derived class.
williamr@2
   869
     *
williamr@2
   870
     * The function is called whenever @c SetExtent(), @c SetSize(), 
williamr@2
   871
     * @c SetRect(), @c SetCornerAndSize(), or @c SetExtentToWholeScreen() 
williamr@2
   872
     * are called on the control. Note that the window server does not 
williamr@2
   873
     * generate size-changed events: @c SizeChanged() gets called only as 
williamr@2
   874
     * a result of calling the functions listed above. Therefore, if a 
williamr@2
   875
     * resize of one control affects the size of other controls, it is 
williamr@2
   876
     * up to the application to ensure that it handles the re-sizing 
williamr@2
   877
     * of all affected controls. 
williamr@2
   878
     */
williamr@2
   879
    IMPORT_C virtual void SizeChanged();
williamr@2
   880
williamr@2
   881
    /**
williamr@2
   882
     * Handles the change in case that the size of the view rectangle
williamr@2
   883
     * for the list box changes.
williamr@2
   884
     */
williamr@2
   885
    IMPORT_C virtual void HandleViewRectSizeChangeL();
williamr@2
   886
    
williamr@2
   887
    /**
williamr@2
   888
     * Gets the number of controls contained in a compound control.
williamr@2
   889
     *
williamr@2
   890
     * There are two ways to implement a compound control. One way is to
williamr@2
   891
     * override this function. The other way is to use the @c CCoeControlArray
williamr@2
   892
     * functionality (see the @c InitComponentArrayL method).
williamr@2
   893
     *
williamr@2
   894
     * @return The number of component controls contained by this control.
williamr@2
   895
     */
williamr@2
   896
    IMPORT_C virtual TInt CountComponentControls() const;
williamr@2
   897
    
williamr@2
   898
    /**
williamr@2
   899
     * Gets an indexed component of a compound control.
williamr@2
   900
     *
williamr@2
   901
     * There are two ways to implement a compound control. One way is to 
williamr@2
   902
     * override this function. The other way is to use the @c CCoeControlArray 
williamr@2
   903
     * functionality (see the @c InitComponentArrayL method).
williamr@2
   904
     *
williamr@2
   905
     * Note: Within a compound control each component control is identified 
williamr@2
   906
     * by an index, where the index depends on the order the controls were 
williamr@2
   907
     * added: the first is given an index of 0, the next an index of 1, and
williamr@2
   908
     * so on.
williamr@2
   909
     *
williamr@2
   910
     * @param aIndex The index of the control. 
williamr@2
   911
     * @return The component control with an index of aIndex. 
williamr@2
   912
     */
williamr@2
   913
    IMPORT_C virtual CCoeControl* ComponentControl(TInt aIndex) const;
williamr@2
   914
williamr@2
   915
    // functions that implement first letter and incremental matching
williamr@2
   916
    /**
williamr@2
   917
     * Creates a buffer for checking how well two strings match up.
williamr@2
   918
     */
williamr@2
   919
    IMPORT_C void CreateMatchBufferL();  
williamr@2
   920
williamr@2
   921
    /**
williamr@2
   922
     * Empties the match buffer .
williamr@2
   923
     */
williamr@2
   924
    IMPORT_C void ClearMatchBuffer() const;
williamr@2
   925
williamr@2
   926
    /**
williamr@2
   927
     * Checks matching for the given character.
williamr@2
   928
     *
williamr@2
   929
     * @param aCode Character code.
williamr@2
   930
     */
williamr@2
   931
    IMPORT_C void MatchTypedCharL(TUint aCode);
williamr@2
   932
williamr@2
   933
    /**
williamr@2
   934
     * Undoes changes from the match buffer that have been caused 
williamr@2
   935
     * by the last match with a character.
williamr@2
   936
     */
williamr@2
   937
    IMPORT_C void UndoLastChar();
williamr@2
   938
    /**
williamr@2
   939
     * Checks if the last character matched with the string.
williamr@2
   940
     *
williamr@2
   941
     * @return @c ETrue if a match was found from the buffer with the character.
williamr@2
   942
     */
williamr@2
   943
    IMPORT_C TBool LastCharMatched() const;
williamr@2
   944
williamr@2
   945
    // functions needed for supporting scrollbars
williamr@2
   946
    /**
williamr@2
   947
     * Updates the position of this list box’s scroll bars’ thumbs to reflect 
williamr@2
   948
     * the horizontal and vertical position of the list view within the list.
williamr@2
   949
     */
williamr@2
   950
    IMPORT_C virtual void UpdateScrollBarThumbs() const;
williamr@2
   951
    
williamr@2
   952
    /**
williamr@2
   953
     * Get horizontal scroll granularity in pixels.
williamr@2
   954
     * The granularity is the minimum size of a horizontal move of the client 
williamr@2
   955
     * area.
williamr@2
   956
     *
williamr@2
   957
     * @return Grain size for horizontal scrolling in pixels.
williamr@2
   958
     */
williamr@2
   959
    IMPORT_C virtual TInt HorizScrollGranularityInPixels() const;
williamr@2
   960
    
williamr@2
   961
    /**
williamr@2
   962
     * Gets the number of grains to move horizontally when a nudge button is 
williamr@2
   963
     * tapped. 
williamr@2
   964
     * For simple list boxes, this value is a fraction of the width of the 
williamr@2
   965
     * client area. 
williamr@2
   966
     *
williamr@2
   967
     * @return Number of grains to move left or right on each nudge
williamr@2
   968
     */
williamr@2
   969
    IMPORT_C virtual TInt HorizontalNudgeValue() const;
williamr@2
   970
    
williamr@2
   971
    /**
williamr@2
   972
     * Called by various functions of this class to ensure that the top 
williamr@2
   973
     * item index is always a sane value. The implementation in @c CEikListBox 
williamr@2
   974
     * tries to ensure the minimum amount of white space at the bottom of 
williamr@2
   975
     * the list box. Note that this function does not affect the 
williamr@2
   976
     * current item index.
williamr@2
   977
     */
williamr@2
   978
    IMPORT_C virtual void AdjustTopItemIndex() const;
williamr@2
   979
williamr@2
   980
    // navigation support functions
williamr@2
   981
    /**
williamr@2
   982
     * Simulates an arrow key event. 
williamr@2
   983
     * 
williamr@2
   984
     * If the list box flags include @c EMultipleSelection, this has the effect 
williamr@2
   985
     * of pressing @c SHIFT with the arrow key represented by @c aKeyCode. 
williamr@2
   986
     * Calls @c CEikListBox::OfferKeyEventL() with aKeyCode translated into a 
williamr@2
   987
     * key event.
williamr@2
   988
     *
williamr@2
   989
     * @param aKeyCode A key code.
williamr@2
   990
     */
williamr@2
   991
    IMPORT_C void SimulateArrowKeyEventL(TKeyCode aKeyCode);
williamr@2
   992
    
williamr@2
   993
    /**
williamr@2
   994
     * Handles a left arrow key event.
williamr@2
   995
     *
williamr@2
   996
     * The method used to handle the event depends on the selection mode, e.g. 
williamr@2
   997
     * whether the user has pressed the @c SHIFT or @c CONTROL key. 
williamr@2
   998
     *
williamr@2
   999
     * @param aSelectionMode Not used
williamr@2
  1000
     */
williamr@2
  1001
    IMPORT_C virtual void HandleLeftArrowKeyL(CListBoxView::TSelectionMode aSelectionMode);
williamr@2
  1002
    
williamr@2
  1003
    /**
williamr@2
  1004
     * Handles a right arrow key event.
williamr@2
  1005
     *
williamr@2
  1006
     * The method used to handle the event depends on the selection mode, 
williamr@2
  1007
     * e.g. whether the user has pressed the @c SHIFT or @c CONTROL key. 
williamr@2
  1008
     *
williamr@2
  1009
     * @param aSelectionMode Not used.
williamr@2
  1010
     */
williamr@2
  1011
    IMPORT_C virtual void HandleRightArrowKeyL(CListBoxView::TSelectionMode aSelectionMode);
williamr@2
  1012
williamr@2
  1013
    // construction support functions
williamr@2
  1014
    /**
williamr@2
  1015
     * Restores the list box properties shared by all subclasses from a resource
williamr@2
  1016
     * reader. This function is not called within @c CEikListBox itself, but is 
williamr@2
  1017
     * used by subclasses which support construction from resources.
williamr@2
  1018
     *
williamr@2
  1019
     * @param aReader A resource reader.
williamr@2
  1020
     */
williamr@2
  1021
    IMPORT_C void RestoreCommonListBoxPropertiesL(TResourceReader& aReader); 
williamr@2
  1022
williamr@2
  1023
    /**
williamr@2
  1024
     * Second-phase constructor.
williamr@2
  1025
     *
williamr@2
  1026
     * This protected form is overridden non-virtually by the second-phase 
williamr@2
  1027
     * constructors of each subclass, and should be invoked by them using 
williamr@2
  1028
     * @c CEikListBox::ConstructL().
williamr@2
  1029
     *
williamr@2
  1030
     * @param aParent The parent control. May be NULL. 
williamr@2
  1031
     * @param aFlags Construction flags. 
williamr@2
  1032
     */
williamr@2
  1033
    IMPORT_C virtual void ConstructL(const CCoeControl* aParent, TInt aFlags = 0);
williamr@2
  1034
    
williamr@2
  1035
    /**
williamr@2
  1036
     * Completes the list box view’s construction.
williamr@2
  1037
     *
williamr@2
  1038
     * This function is called by @c ConstructL() to complete construction 
williamr@2
  1039
     * of the resource view, calling its @c ConstructL() with appropriate 
williamr@2
  1040
     * arguments and assigning it to @c iView. Also prepares the view for use.
williamr@2
  1041
     */
williamr@2
  1042
    IMPORT_C virtual void CreateViewL();
williamr@2
  1043
    
williamr@2
  1044
    /**
williamr@2
  1045
     * Creates the list box view.
williamr@2
  1046
     *
williamr@2
  1047
     * The function is called by @c ConstructL() to create an instance of 
williamr@2
  1048
     * the appropriate list box view class for this list box. The returned 
williamr@2
  1049
     * instance is owned by this object, and does not have to have its 
williamr@2
  1050
     * second-phase constructor run. This function is called by @c CreateViewL().
williamr@2
  1051
     *
williamr@2
  1052
     * @return Pointer to a newly constructed list box view for this object.
williamr@2
  1053
     */
williamr@2
  1054
    IMPORT_C virtual CListBoxView* MakeViewClassInstanceL();
williamr@2
  1055
    
williamr@2
  1056
    /**
williamr@2
  1057
     * Sets the view rectangle from the client rectangle making sure a whole 
williamr@2
  1058
     * number of items is displayed.
williamr@2
  1059
     * 
williamr@2
  1060
     * @param aClientRect  The client rectangle
williamr@2
  1061
     */
williamr@2
  1062
    IMPORT_C void SetViewRectFromClientRect(const TRect& aClientRect);
williamr@2
  1063
    
williamr@2
  1064
    /**
williamr@2
  1065
     * Calculates the client area.
williamr@2
  1066
     *
williamr@2
  1067
     * This method is called by various functions of this class to 
williamr@2
  1068
     * recalculate the extent of the client area from @c iViewRect. This
williamr@2
  1069
     * implementation takes into account any rounding of the viewing 
williamr@2
  1070
     * rectangle made to fit a whole number of items.
williamr@2
  1071
     *
williamr@2
  1072
     * @param aClientRect On return contains a size for the client area 
williamr@2
  1073
     *        in pixels.
williamr@2
  1074
     */
williamr@2
  1075
    IMPORT_C virtual void RestoreClientRectFromViewRect( TRect& aClientRect) const;
williamr@2
  1076
williamr@2
  1077
    /**
williamr@2
  1078
     * Rounds down the height of the rectangle (if necessary) so that 
williamr@2
  1079
     * only a whole number of items can be displayed inside the list box.
williamr@2
  1080
     *
williamr@2
  1081
     * @param aRect The rectangle to be modified. 
williamr@2
  1082
     * @return The number of pixels reduced. 
williamr@2
  1083
     */
williamr@2
  1084
    IMPORT_C virtual TInt AdjustRectHeightToWholeNumberOfItems( TRect& aRect) const;
williamr@2
  1085
williamr@2
  1086
    // accessor for Laf members
williamr@2
  1087
    /**
williamr@2
  1088
     * Gets list box margins.
williamr@2
  1089
     *
williamr@2
  1090
     * @return The list box margins in pixels.
williamr@2
  1091
     */
williamr@2
  1092
    IMPORT_C TMargins8 ListBoxMargins() const;
williamr@2
  1093
williamr@2
  1094
    // various accessors for private data members
williamr@2
  1095
    /**
williamr@2
  1096
     * This function gets the horizontal margin. Use 
williamr@2
  1097
     * @c CEikListBox::ListBoxMargins() instead, as this 
williamr@2
  1098
     * provides a more accurate value due to the bit shifting involved.
williamr@2
  1099
     *
williamr@2
  1100
     * @deprecated Use @c CEikListBox::ListBoxMargins()
williamr@2
  1101
     * @return The horizontal margin in pixels.
williamr@2
  1102
     */
williamr@2
  1103
    IMPORT_C TInt HorizontalMargin() const;
williamr@2
  1104
    
williamr@2
  1105
    /**
williamr@2
  1106
     * This function gets the vertical margin. This function 
williamr@2
  1107
     * is deprecated, use @c CEikListBox::ListBoxMargins() instead, 
williamr@2
  1108
     * this provides a more accurate value due to the bit 
williamr@2
  1109
     * shifting involved.
williamr@2
  1110
     *
williamr@2
  1111
     * @deprecated Use @c CEikListBox::ListBoxMargins()
williamr@2
  1112
     * @return The vertical margin in pixels.
williamr@2
  1113
     */
williamr@2
  1114
    IMPORT_C TInt VerticalMargin() const;
williamr@2
  1115
    
williamr@2
  1116
    /**
williamr@2
  1117
     * Sets the horizontal margin.
williamr@2
  1118
     *
williamr@2
  1119
     * @param aMargin The required horizontal margin.
williamr@2
  1120
     */
williamr@2
  1121
    IMPORT_C void SetHorizontalMargin(TInt aMargin);
williamr@2
  1122
    
williamr@2
  1123
    /**
williamr@2
  1124
     * Sets the vertical margin.
williamr@2
  1125
     *
williamr@2
  1126
     * @param aMargin The required vertical margin.
williamr@2
  1127
     */
williamr@2
  1128
    IMPORT_C void SetVerticalMargin(TInt aMargin);
williamr@2
  1129
    
williamr@2
  1130
    /**
williamr@2
  1131
     * Gets a pointer to the match buffer. Returns 
williamr@2
  1132
     * NULL if the match buffer does not exist.
williamr@2
  1133
     *
williamr@2
  1134
     * @return Pointer to the match buffer.
williamr@2
  1135
     */
williamr@2
  1136
    IMPORT_C RIncrMatcherBase* MatchBuffer() const;
williamr@2
  1137
    
williamr@2
  1138
    /**
williamr@2
  1139
     * Gets the view rectangle height adjustment. 
williamr@2
  1140
     *
williamr@2
  1141
     * These are the adjustments that were made to the 
williamr@2
  1142
     * view rectangle when the @c SetViewRectFromClientRect() 
williamr@2
  1143
     * function was called.
williamr@2
  1144
     *
williamr@2
  1145
     * @return Height adjustment.
williamr@2
  1146
     */
williamr@2
  1147
    IMPORT_C TInt ViewRectHeightAdjustment() const;
williamr@2
  1148
    
williamr@2
  1149
    /**
williamr@2
  1150
     * Gets the background colour.
williamr@2
  1151
     *
williamr@2
  1152
     * @return The background colour.
williamr@2
  1153
     */
williamr@2
  1154
    IMPORT_C TRgb BackColor() const;
williamr@2
  1155
    
williamr@2
  1156
    /**
williamr@2
  1157
     * Sets the view rectangle height adjustment. 
williamr@2
  1158
     *
williamr@2
  1159
     * @param aAdjustment New adjustment.
williamr@2
  1160
     */
williamr@2
  1161
    IMPORT_C void SetViewRectHeightAdjustment(TInt aAdjustment);
williamr@2
  1162
williamr@2
  1163
    // misc functions
williamr@2
  1164
    
williamr@2
  1165
    /**
williamr@2
  1166
     * Reports a list box event to any observer of this list box. 
williamr@2
  1167
     * This function returns immediately if no observer is set.
williamr@2
  1168
     *
williamr@2
  1169
     * @param aEvent The event to report.
williamr@2
  1170
     */
williamr@2
  1171
    IMPORT_C virtual void ReportListBoxEventL( MEikListBoxObserver::TListBoxEvent aEvent );
williamr@2
  1172
    
williamr@2
  1173
    /**
williamr@2
  1174
     * Redraws the specified area of this list box into the specified rectangle.
williamr@2
  1175
     *
williamr@2
  1176
     * @param aRect Rectangle to be redrawn. Specified relative to the 
williamr@2
  1177
     *        origin of this control.
williamr@2
  1178
     */
williamr@2
  1179
    IMPORT_C virtual void Draw(const TRect& aRect) const;
williamr@2
  1180
    
williamr@2
  1181
    /**
williamr@2
  1182
     * Clears the list box margins. The list box is redrawn only if redraws 
williamr@2
  1183
     * are enabled for the list box view.
williamr@2
  1184
     */
williamr@2
  1185
    IMPORT_C void ClearMargins() const;
williamr@2
  1186
    
williamr@2
  1187
    /**
williamr@2
  1188
     * Sets an item as the current item, even if it is not currently 
williamr@2
  1189
     * visible. Redraws the list box to reflect the change. This 
williamr@2
  1190
     * should not be called from within another Draw function.
williamr@2
  1191
     * 
williamr@2
  1192
     * @param aItemIndex The index of the list box item to update.
williamr@2
  1193
     */
williamr@2
  1194
    IMPORT_C virtual void UpdateCurrentItem(TInt aItemIndex) const;
williamr@2
  1195
    
williamr@2
  1196
    /**
williamr@2
  1197
     * Handles drag events.
williamr@2
  1198
     *
williamr@2
  1199
     * This function is called by @c HandlePointerEventL() to handle pointer 
williamr@2
  1200
     * drag events appropriately.
williamr@2
  1201
     *
williamr@2
  1202
     * @param aPointerPos The position of the @c TPointerEvent for which this 
williamr@2
  1203
     *        handler is invoked.
williamr@2
  1204
     */
williamr@2
  1205
    IMPORT_C virtual void HandleDragEventL(TPoint aPointerPos);
williamr@2
  1206
    
williamr@2
  1207
    /**
williamr@2
  1208
     * Tests whether an item exists.
williamr@2
  1209
     *
williamr@2
  1210
     * @param aItemIndex Index to test. 
williamr@2
  1211
     * @return @c ETrue if the specified item exists, EFalse otherwise.
williamr@2
  1212
     */
williamr@2
  1213
    IMPORT_C TBool ItemExists(TInt aItemIndex) const;
williamr@2
  1214
    
williamr@2
  1215
    /**
williamr@2
  1216
     * Draws the matcher cursor in the correct location for the current match. 
williamr@2
  1217
     * If there is no match buffer, this function returns immediately; 
williamr@2
  1218
     * otherwise the cursor is drawn on the current item using 
williamr@2
  1219
     * @c CListBoxView::DrawMatcherCursor() after scrolling to make the current 
williamr@2
  1220
     * item visible.
williamr@2
  1221
     * 
williamr@2
  1222
     * A list box control’s matcher cursor is an on-screen cursor which is 
williamr@2
  1223
     * drawn to indicate to the user the location of the current text. Whether 
williamr@2
  1224
     * the cursor is drawn is dependent on the 
williamr@2
  1225
     * @c CListBoxView::TFlags::EHasMatcherCursor flag, which may be set on the 
williamr@2
  1226
     * list box’s view.
williamr@2
  1227
     *
williamr@2
  1228
     * Note, that CListBoxView::DrawMatcherCursor() is not implemented in S60. 
williamr@2
  1229
     */
williamr@2
  1230
    IMPORT_C void DrawMatcherCursor() const;
williamr@2
  1231
williamr@2
  1232
    /**
williamr@2
  1233
     * Gets the vertical gap between elements in the list box. 
williamr@2
  1234
     *
williamr@2
  1235
     * @return The vertical gap between elements in the list box.
williamr@2
  1236
     */
williamr@2
  1237
    IMPORT_C static TInt InterItemGap();
williamr@2
  1238
williamr@2
  1239
    /**
williamr@2
  1240
     * Updates the view colours in line with the colours in effect for the 
williamr@2
  1241
     * Uikon environment. Has no effect if there is no view.
williamr@2
  1242
     */
williamr@2
  1243
    IMPORT_C void UpdateViewColors();
williamr@2
  1244
williamr@2
  1245
    /**
williamr@2
  1246
     * Updates the item drawer colours in line with the colours in effect 
williamr@2
  1247
     * for the Uikon environment. Has no effect if there is no item drawer.
williamr@2
  1248
     */
williamr@2
  1249
    IMPORT_C void UpdateItemDrawerColors();
williamr@2
  1250
williamr@2
  1251
    /**
williamr@2
  1252
     * Notifies item change observers about item change. Subclasses must call
williamr@2
  1253
     * this method if they have implemented item handling functions (e.g.
williamr@2
  1254
     * @c HandleItemAdditionL or @c HandleItemRemovalL).
williamr@2
  1255
     *
williamr@2
  1256
     * @since S60 3.0
williamr@2
  1257
     */
williamr@2
  1258
    IMPORT_C void FireItemChange();
williamr@2
  1259
williamr@2
  1260
williamr@2
  1261
protected:	// functions which deal with extension
williamr@2
  1262
    /**
williamr@2
  1263
     * Sets the reason for the list box’s loss of focus.
williamr@2
  1264
     *
williamr@2
  1265
     * This is required so the list box can determine whether 
williamr@2
  1266
     * loss of focus is due to an external control or an internal component.
williamr@2
  1267
     *
williamr@2
  1268
     * @param aReasonForFocusLost The reason for the loss of focus.
williamr@2
  1269
     */
williamr@2
  1270
    IMPORT_C void SetReasonForFocusLostL( TReasonForFocusLost aReasonForFocusLost );
williamr@2
  1271
williamr@2
  1272
    /**
williamr@2
  1273
     * Gets the reason for the list box’s loss of focus.
williamr@2
  1274
     *
williamr@2
  1275
     * @return The reason for the loss of focus.
williamr@2
  1276
     */
williamr@2
  1277
    IMPORT_C TReasonForFocusLost ReasonForFocusLostL();
williamr@2
  1278
williamr@2
  1279
    /**
williamr@2
  1280
     * Tests whether the list box match buffer exists.
williamr@2
  1281
     *
williamr@2
  1282
     * @return @c ETrue if the list box match buffer exists. 
williamr@2
  1283
               @c EFalse if the list box match buffer does not exist.
williamr@2
  1284
     */
williamr@2
  1285
    IMPORT_C TBool IsMatchBuffer() const;
williamr@2
  1286
williamr@2
  1287
    /**
williamr@2
  1288
     * Checks for a list box extension. Attempts to create one if not present. 
williamr@2
  1289
     *
williamr@2
  1290
     * This function leaves if an extension cannot be created.
williamr@2
  1291
     */
williamr@2
  1292
    void CheckCreateExtensionL();
williamr@2
  1293
williamr@2
  1294
    /**
williamr@2
  1295
     * Checks for a list box extension. Creates one if not present. 
williamr@2
  1296
     *
williamr@2
  1297
     * @return @c ETrue if a list box extension already existed or 
williamr@2
  1298
     *         if there was no previous extension and a new extension 
williamr@2
  1299
     *         class was created successfully. 
williamr@2
  1300
     *         @c EFalse if there was no previous extension and a new one 
williamr@2
  1301
     *         could not be constructed.
williamr@2
  1302
     */
williamr@2
  1303
    TBool CheckCreateExtension();
williamr@2
  1304
williamr@2
  1305
    /**
williamr@2
  1306
     * Checks the list box match buffer exists. If a buffer does not 
williamr@2
  1307
     * exist, one is created.
williamr@2
  1308
     */
williamr@2
  1309
    void CheckCreateBufferL();
williamr@2
  1310
williamr@2
  1311
    /**
williamr@2
  1312
     * Gets the list box match buffer.
williamr@2
  1313
     *
williamr@2
  1314
     * @return The list box match buffer.
williamr@2
  1315
     */
williamr@2
  1316
    CMatchBuffer* Buffer() const;
williamr@2
  1317
williamr@2
  1318
protected:
williamr@2
  1319
    /**
williamr@2
  1320
     * Creates a scroll bar frame layout according to @c aLayout.
williamr@2
  1321
     *
williamr@2
  1322
     * @param aLayout Defines the layout.
williamr@2
  1323
     */
williamr@2
  1324
    IMPORT_C void CreateScrollBarFrameLayout(TEikScrollBarFrameLayout& aLayout) const;
williamr@2
  1325
    
williamr@2
  1326
    /**
williamr@2
  1327
     * If MiddleSoftKey is either Mark or Unmark, this method sets MSK
williamr@2
  1328
     * according to the current item selection state.
williamr@2
  1329
     */
williamr@2
  1330
    void UpdateMarkUnmarkMSKL() const;
williamr@2
  1331
williamr@2
  1332
public:
williamr@2
  1333
    /**
williamr@2
  1334
     * @return Event modifiers for the @c CEikListBox.
williamr@2
  1335
     */
williamr@2
  1336
    IMPORT_C TInt EventModifiers();
williamr@2
  1337
williamr@2
  1338
    /* 
williamr@2
  1339
    * Returns ETrue if list has ES60StyleMultiselection flag. 
williamr@2
  1340
    */
williamr@2
  1341
    IMPORT_C TBool IsMultiselection();
williamr@2
  1342
williamr@2
  1343
    /**
williamr@2
  1344
    * Creates a scrollbar for the listbox. The caller may choose if the scrollbar is requested 
williamr@2
  1345
    * remotely via the mop chain from parent control
williamr@2
  1346
    *
williamr@2
  1347
    * @param	aPreAlloc Is the scrollbar created immediately or when taking in to use
williamr@2
  1348
    * @param	aRemote If True, the scrollbar is obtained via mop-chain from 
williamr@2
  1349
    *           parent control. If used, the listbox only sets the scrollbar 
williamr@2
  1350
    *           values. The scrollbar position and size must set in the parent
williamr@2
  1351
    *           control's code.
williamr@2
  1352
    *
williamr@2
  1353
    * @return	CEikScrollBarFrame*	pointer to scrollbar frame object
williamr@2
  1354
    */	
williamr@2
  1355
    IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL(TBool aPreAlloc, TBool aRemote);
williamr@2
  1356
	
williamr@2
  1357
    /**
williamr@2
  1358
    * Creates a scrollbar for the listbox. The caller may choose if the scrollbar is requested 
williamr@2
  1359
    * remotely via the mop chain from parent control
williamr@2
  1360
    *
williamr@2
  1361
    * @param    aPreAlloc Is the scrollbar created immediately or when taking in to use
williamr@2
  1362
    * @param    aRemote If True, the scrollbar is obtained via mop-chain from 
williamr@2
  1363
    *           parent control. If used, the listbox only sets the scrollbar 
williamr@2
  1364
    *           values. The scrollbar position and size must set in the parent
williamr@2
  1365
    *           control's code.
williamr@2
  1366
    * @param    aWindowOwning Does the created scrollbar create own window or 
williamr@2
  1367
    *           is it compound control. The listbox uses a window owning 
williamr@2
  1368
    *           scrollbar by default.
williamr@2
  1369
    *
williamr@2
  1370
    * @return    CEikScrollBarFrame*    pointer to scrollbar frame object
williamr@2
  1371
    */    
williamr@2
  1372
    IMPORT_C CEikScrollBarFrame* CreateScrollBarFrameL(TBool aPreAlloc, TBool aRemote, TBool aWindowOwning);
williamr@2
  1373
williamr@2
  1374
    /**
williamr@2
  1375
    * By default markable listbox has middle softkey observer, which handles
williamr@2
  1376
    * Mark / Unmark functionality. By this method, the caller may disable default
williamr@2
  1377
    * observer.
williamr@2
  1378
    *
williamr@2
  1379
    * @since S60 3.1
williamr@2
  1380
    *
williamr@2
  1381
    * @param    aEnable If EFalse, disables default middle softkey observer
williamr@2
  1382
    *           for markable lists. ETrue enables observer again.
williamr@2
  1383
    */    
williamr@2
  1384
    IMPORT_C void EnableMSKObserver(TBool aEnable);
williamr@2
  1385
    
williamr@2
  1386
    /**
williamr@2
  1387
    * Called from MSK observer when shift+MSK have been pressed
williamr@2
  1388
    *
williamr@2
  1389
    * @Since S60 3.1
williamr@2
  1390
    */
williamr@2
  1391
    void DoShiftMSKMarkingL();
williamr@2
  1392
williamr@2
  1393
    /**
williamr@2
  1394
    * This method is only called by CEikButtonGroupContainer when MSK observer
williamr@2
  1395
    * is enabled and CEikButtonGroupContainer is deleted.
williamr@2
  1396
    *
williamr@2
  1397
    * @Since S60 3.1
williamr@2
  1398
    */
williamr@2
  1399
    void InformMSKButtonGroupDeletion();
williamr@2
  1400
    
williamr@2
  1401
    /**
williamr@2
  1402
    * Adds a selection (item marking) observer to the listbox. Duplicates are not checked
williamr@2
  1403
    * (i.e. adding the same observer multiple times is not prevented).
williamr@2
  1404
    *
williamr@2
  1405
    * @since 3.2
williamr@2
  1406
    * @param aObserver Must be non-NULL.
williamr@2
  1407
    */
williamr@2
  1408
    IMPORT_C void AddSelectionObserverL( MListBoxSelectionObserver* aObserver );
williamr@2
  1409
    
williamr@2
  1410
    /**
williamr@2
  1411
    * Removes a selection (item marking) observer from the listbox.
williamr@2
  1412
    *
williamr@2
  1413
    * @since 3.2
williamr@2
  1414
    * @param aObserver The observer to be removed.
williamr@2
  1415
    */
williamr@2
  1416
    IMPORT_C void RemoveSelectionObserver( MListBoxSelectionObserver* aObserver );
williamr@2
  1417
williamr@2
  1418
    /**
williamr@2
  1419
    * This switches listbox into selection mode. Basicly only changes MSK and
williamr@2
  1420
    * informs selection observers about the change.
williamr@2
  1421
    *
williamr@2
  1422
    * @since 3.2
williamr@2
  1423
    * @param aEnable ETrue when entering into selection mode, EFalse when leaving
williamr@2
  1424
    */
williamr@2
  1425
    void ChangeSelectionMode(TBool aEnable);
williamr@2
  1426
williamr@2
  1427
    /**
williamr@2
  1428
    * Sets the number of list items that form one grid line.
williamr@2
  1429
	*
williamr@2
  1430
	* @since S60 5.0
williamr@2
  1431
	* @param aItems Number of items in one grid line.
williamr@2
  1432
	*/
williamr@2
  1433
    IMPORT_C void SetItemsInSingleLine(TInt aItems);
williamr@2
  1434
	
williamr@2
  1435
    /**
williamr@2
  1436
    * Removes pointer event filtering for list items.
williamr@2
  1437
    *
williamr@2
  1438
    * When there are two pointer up events on the same item at short interval, 
williamr@2
  1439
    * listbox will only get the first one and drop the second one. This method forces listbox to handle all pointer up events.
williamr@2
  1440
    *
williamr@2
  1441
    * @since S60 5.0
williamr@2
  1442
    *
williamr@2
  1443
    * @param aItemIndexes Array of item indexes to be added.
williamr@2
  1444
    **/
williamr@2
  1445
    IMPORT_C void SetPointerEventFilterDisabledL( const CArrayFix<TInt>& aItemIndexes );
williamr@2
  1446
williamr@2
  1447
    /**
williamr@2
  1448
     * Scrolls the view by the given amount of pixels while keeping the
williamr@2
  1449
     * physics parameters up-to-date.
williamr@2
  1450
     * This should be called when scrolling the list box view except for
williamr@2
  1451
     * when it is done by list dragging (e.g. scrolling with scroll bar).
williamr@2
  1452
     *
williamr@2
  1453
     * @param  aDeltaPixels  Amount of pixels to scroll the view.
williamr@2
  1454
     *
williamr@2
  1455
     * @since 5.0
williamr@2
  1456
     */
williamr@2
  1457
    IMPORT_C void HandlePhysicsScrollEventL( TInt aDeltaPixels );
williamr@2
  1458
williamr@2
  1459
    /**
williamr@2
  1460
     * Disables the kinetic scrolling functionality in the list.
williamr@2
  1461
     * By default the feature is enabled.
williamr@2
  1462
     * 
williamr@2
  1463
     * @param  aDisabled  @c ETrue to disable kinetic scrolling,
williamr@2
  1464
     *                    @c EFalse otherwise.
williamr@2
  1465
     *
williamr@2
  1466
     * @since 5.0
williamr@2
  1467
     */
williamr@2
  1468
    IMPORT_C void DisableScrolling( TBool aDisabled );
williamr@2
  1469
    
williamr@2
  1470
    /**
williamr@2
  1471
     * Checks if the kinetic scrolling is currently enabled in the list.
williamr@2
  1472
     *
williamr@2
  1473
     * @return @c ETrue if kinetic scrolling is enabled, @c EFalse otherwise.
williamr@2
  1474
     *
williamr@2
  1475
     * @since 5.0
williamr@2
  1476
     */
williamr@2
  1477
    IMPORT_C TBool ScrollingDisabled();
williamr@2
  1478
    
williamr@2
  1479
    /**
williamr@2
  1480
     * Suspends transitions effects.
williamr@2
  1481
     *
williamr@2
  1482
     * @since S60 5.0
williamr@2
  1483
     *
williamr@2
  1484
     * @param aSuspend ETrue to suspend effects, EFalse to re-enable them.
williamr@2
  1485
     */
williamr@2
  1486
    IMPORT_C void SuspendEffects( TBool aSuspend );
williamr@2
  1487
williamr@2
  1488
private:
williamr@2
  1489
    IMPORT_C virtual void CEikListBox_Reserved(); // listbox use only
williamr@2
  1490
    void HorizontalScroll(TInt aScrollAmountInPixels);
williamr@2
  1491
    void DrawItemInView(TInt aItemIndex) const;
williamr@2
  1492
    void ClearMargins(CWindowGc& aGc) const;
williamr@2
  1493
    TKeyResponse DoOfferKeyEventL(const TKeyEvent& aKeyEvent,TEventCode aType);
williamr@2
  1494
    void UpdateScrollBarColors(CEikScrollBar* aScrollBar);
williamr@2
  1495
    void UpdateScrollBarsColors();
williamr@2
  1496
williamr@2
  1497
    void HandleItemRemovalWithoutSelectionsL();
williamr@2
  1498
williamr@2
  1499
    /**
williamr@2
  1500
     * Scrolls the view by the given amount of pixels.
williamr@2
  1501
     *
williamr@2
  1502
     * @param  aOffset   Amount of offset in pixels.
williamr@2
  1503
     * @param  aDrawNow  Whether or not the view is be drawn.
williamr@2
  1504
     *                   If @c EFalse then only the logical state is updated.
williamr@2
  1505
     *
williamr@2
  1506
     * @internal
williamr@2
  1507
     * @since 5.0
williamr@2
  1508
     */
williamr@2
  1509
    void ScrollView( const TInt aOffset, TBool aDrawNow );
williamr@2
  1510
    
williamr@2
  1511
    /**
williamr@2
  1512
     * Handles pointer events if physics are enabled.
williamr@2
  1513
     *
williamr@2
  1514
     * @return @c ETrue if the event was consumed by kinetic scrolling.
williamr@2
  1515
     *
williamr@2
  1516
     * @internal
williamr@2
  1517
     * @since 5.0
williamr@2
  1518
     */
williamr@2
  1519
    TBool HandlePhysicsPointerEventL( const TPointerEvent& aPointerEvent );
williamr@2
  1520
    
williamr@2
  1521
    /**
williamr@2
  1522
     * Selects an item and draws highlight to it.
williamr@2
  1523
     * 
williamr@2
  1524
     * @param  aItemIndex  Index of the highlighted item. 
williamr@2
  1525
     * 
williamr@2
  1526
     * @internal
williamr@2
  1527
     * @since 5.0
williamr@2
  1528
     */
williamr@2
  1529
    void UpdateHighlightL( TInt aItemIndex );
williamr@2
  1530
    
williamr@2
  1531
protected:
williamr@2
  1532
    /** Flags for this list box  */
williamr@2
  1533
    TInt iListBoxFlags;
williamr@2
  1534
    
williamr@2
  1535
    /** This List box's view  */
williamr@2
  1536
    CListBoxView* iView;
williamr@2
  1537
    
williamr@2
  1538
    /** Item drawer for this list box */
williamr@2
  1539
    CListItemDrawer* iItemDrawer;
williamr@2
  1540
    
williamr@2
  1541
    /** Data model for this list box */
williamr@2
  1542
    MListBoxModel* iModel;
williamr@2
  1543
    
williamr@2
  1544
    /** Height of each item in the list */
williamr@2
  1545
    TInt iItemHeight;   
williamr@2
  1546
    
williamr@2
  1547
    /** The scroll bar used by this control */
williamr@2
  1548
    CEikScrollBarFrame* iSBFrame;
williamr@2
  1549
    
williamr@2
  1550
    /** Identifies if the scroll bar is owned by this list */
williamr@2
  1551
    TScrollBarOwnerShip iSBFrameOwned;
williamr@2
  1552
    
williamr@2
  1553
    /** The required height of this list box expressed in 
williamr@2
  1554
     * terms of a number of items.
williamr@2
  1555
     */
williamr@2
  1556
    TInt iRequiredHeightInNumOfItems;
williamr@2
  1557
    
williamr@2
  1558
    /**
williamr@2
  1559
     * Defines which button launched the popout.
williamr@2
  1560
     */
williamr@2
  1561
    CEikButtonBase* iLaunchingButton; // only used by popouts
williamr@2
  1562
    
williamr@2
  1563
    /** The button which just launched a popout menu. */
williamr@2
  1564
    MEikListBoxObserver* iListBoxObserver;
williamr@2
  1565
williamr@2
  1566
private:
williamr@2
  1567
williamr@2
  1568
    TRgb iBackColor;
williamr@2
  1569
//  TInt iHorizontalMargin;
williamr@2
  1570
//  TInt iVerticalMargin;
williamr@2
  1571
    TMargins8 iMargins ;
williamr@2
  1572
    CListBoxExt* iListBoxExt;
williamr@2
  1573
    TInt iViewRectHeightAdjustment;
williamr@2
  1574
    MEikListBoxEditor* iItemEditor;
williamr@2
  1575
    TBool* iLbxDestroyed;
williamr@2
  1576
    TBool iLastCharMatched;
williamr@2
  1577
    TInt iSpare;
williamr@2
  1578
    };
williamr@2
  1579
williamr@2
  1580
williamr@2
  1581
williamr@2
  1582
/**
williamr@2
  1583
* This is a list box that scrolls horizontally, displaying its items 
williamr@2
  1584
* in as many vertical columns as needed. Columns are arranged across 
williamr@2
  1585
* the control from left to right; within columns, items are arranged 
williamr@2
  1586
* from top to bottom. The flow of items or text ‘snakes’ across the 
williamr@2
  1587
* face of the control.
williamr@2
  1588
*
williamr@2
  1589
* This is a flexible control class that makes good use of short, wide 
williamr@2
  1590
* display areas; for instance, subclasses of @c CEikSnakingListBox could 
williamr@2
  1591
* be used for file lists or for a control panel. A standard user 
williamr@2
  1592
* subclass, @c CEikSnakingTextListBox, also exists.
williamr@2
  1593
*
williamr@2
  1594
* @since Symbian 5.0
williamr@2
  1595
*/     
williamr@2
  1596
class CEikSnakingListBox : public CEikListBox  
williamr@2
  1597
    {
williamr@2
  1598
public:
williamr@2
  1599
    /**
williamr@2
  1600
     * C++ standard constructor
williamr@2
  1601
     */
williamr@2
  1602
    IMPORT_C CEikSnakingListBox();
williamr@2
  1603
    
williamr@2
  1604
    /**
williamr@2
  1605
     * Destructor
williamr@2
  1606
     */
williamr@2
  1607
    IMPORT_C ~CEikSnakingListBox();
williamr@2
  1608
    
williamr@2
  1609
    /**
williamr@2
  1610
     * Creates an instance of the view class.
williamr@2
  1611
     *
williamr@2
  1612
     * This function is called during construction to create 
williamr@2
  1613
     * (but not second-phase construct) an instance of the correct view 
williamr@2
  1614
     * class for this list box control. In the case of the snaking list 
williamr@2
  1615
     * box, a @c CSnakingListBoxView is returned.
williamr@2
  1616
     *
williamr@2
  1617
     * This function overrides @c CEikListBox::MakeViewClassInstanceL().
williamr@2
  1618
     *
williamr@2
  1619
     * @return The view which will be used by the list box being created
williamr@2
  1620
     */
williamr@2
  1621
    IMPORT_C virtual CListBoxView* MakeViewClassInstanceL();
williamr@2
  1622
    
williamr@2
  1623
    /**
williamr@2
  1624
     * Sets the top item’s index.
williamr@2
  1625
     *
williamr@2
  1626
     * @param aItemIndex Index of the item to set as the top item.
williamr@2
  1627
     */
williamr@2
  1628
    IMPORT_C virtual void SetTopItemIndex(TInt aItemIndex) const;
williamr@2
  1629
    
williamr@2
  1630
    /**
williamr@2
  1631
     * Gets the width of this list box’s columns. 
williamr@2
  1632
     *
williamr@2
  1633
     * @return Width of each column.
williamr@2
  1634
     */
williamr@2
  1635
    IMPORT_C TInt ColumnWidth() const;
williamr@2
  1636
    
williamr@2
  1637
    /**
williamr@2
  1638
     * Sets the width of all columns in the list box.
williamr@2
  1639
     *
williamr@2
  1640
     * @param aColumnWidth New column width.
williamr@2
  1641
     */
williamr@2
  1642
    IMPORT_C void SetColumnWidth(TInt aColumnWidth);
williamr@2
  1643
williamr@2
  1644
public: //from CCoeControl
williamr@2
  1645
    
williamr@2
  1646
    /**
williamr@2
  1647
     * From @c CCoeControl.
williamr@2
  1648
     *
williamr@2
  1649
     * Handles pointer events. 
williamr@2
  1650
     *
williamr@2
  1651
     * @param aPointerEvent The pointer event.
williamr@2
  1652
     */
williamr@2
  1653
    IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@2
  1654
williamr@2
  1655
protected:
williamr@2
  1656
    
williamr@2
  1657
    /**
williamr@2
  1658
     * Handles a change in size of the viewing rectangle.
williamr@2
  1659
     *
williamr@2
  1660
     * This function is called by framework functions to update the content, 
williamr@2
  1661
     * view, and scroll bars of this list box after the viewing rectangle has 
williamr@2
  1662
     * changed size. This implementation ensures that the current item is 
williamr@2
  1663
     * visible after a resize.
williamr@2
  1664
     */
williamr@2
  1665
    IMPORT_C virtual void HandleViewRectSizeChangeL();
williamr@2
  1666
williamr@2
  1667
    /**
williamr@2
  1668
     * Handles a left arrow key event.
williamr@2
  1669
     * 
williamr@2
  1670
     * Moves the cursor into the correct column and clears any matcher buffer 
williamr@2
  1671
     * that may have been built up.
williamr@2
  1672
     *
williamr@2
  1673
     * @param aSelectionMode Not used.
williamr@2
  1674
     */
williamr@2
  1675
    IMPORT_C virtual void HandleLeftArrowKeyL(
williamr@2
  1676
                            CListBoxView::TSelectionMode aSelectionMode);
williamr@2
  1677
    
williamr@2
  1678
    /**
williamr@2
  1679
     * Handles a right arrow key event.
williamr@2
  1680
     * 
williamr@2
  1681
     * Moves the cursor into the correct column and clears any matcher buffer 
williamr@2
  1682
     * that may have been built up.
williamr@2
  1683
     *
williamr@2
  1684
     * @param aSelectionMode Not used.
williamr@2
  1685
     */
williamr@2
  1686
    IMPORT_C virtual void HandleRightArrowKeyL(
williamr@2
  1687
                            CListBoxView::TSelectionMode aSelectionMode);
williamr@2
  1688
    
williamr@2
  1689
    /**
williamr@2
  1690
     * Gets the number of grains to move horizontally when a nudge button 
williamr@2
  1691
     * is tapped. 
williamr@2
  1692
     *
williamr@2
  1693
     * For simple list boxes, this value is a fraction of the width of the
williamr@2
  1694
     * client area. 
williamr@2
  1695
     *
williamr@2
  1696
     * @return Number of grains to move left or right on each nudge.
williamr@2
  1697
     */
williamr@2
  1698
    IMPORT_C virtual TInt HorizontalNudgeValue() const;
williamr@2
  1699
williamr@2
  1700
    /**
williamr@2
  1701
     * Gets the granularity for horizontal scrolls. 
williamr@2
  1702
     *
williamr@2
  1703
     * The granularity is the minimum size of a horizontal move of the 
williamr@2
  1704
     * client area.
williamr@2
  1705
     *
williamr@2
  1706
     * @return Grain size for horizontal scrolling in pixels.
williamr@2
  1707
     */
williamr@2
  1708
    IMPORT_C virtual TInt HorizScrollGranularityInPixels() const;
williamr@2
  1709
williamr@2
  1710
    /**
williamr@2
  1711
     * Called by various functions of this class to ensure that the top 
williamr@2
  1712
     * item index is always a sane value. The implementation in @c CEikListBox 
williamr@2
  1713
     * tries to ensure the minimum amount of white space at the bottom of 
williamr@2
  1714
     * the list box. Note that this function does not affect the current 
williamr@2
  1715
     * item index.
williamr@2
  1716
     */
williamr@2
  1717
    IMPORT_C virtual void AdjustTopItemIndex() const;
williamr@2
  1718
williamr@2
  1719
    /**
williamr@2
  1720
     * Handles drag events.
williamr@2
  1721
     *
williamr@2
  1722
     * This function is called by @c HandlePointerEventL() to handle 
williamr@2
  1723
     * pointer drag events appropriately.
williamr@2
  1724
     *
williamr@2
  1725
     * @param aPointerPos The position of the @c TPointerEvent for which this 
williamr@2
  1726
     *        handler is invoked.
williamr@2
  1727
     */
williamr@2
  1728
    IMPORT_C virtual void HandleDragEventL(TPoint aPointerPos);
williamr@2
  1729
williamr@2
  1730
    /**
williamr@2
  1731
     * Calculates the client area.
williamr@2
  1732
     *
williamr@2
  1733
     * This method is called by various functions of this class to recalculate 
williamr@2
  1734
     * the extent of the client area from @c iViewRect. This implementation 
williamr@2
  1735
     * takes into account any rounding of the viewing rectangle made to fit a 
williamr@2
  1736
     * whole number of items.
williamr@2
  1737
     *
williamr@2
  1738
     * @param aClientRect On return contains a size for the client area in 
williamr@2
  1739
     *        pixels.
williamr@2
  1740
     */
williamr@2
  1741
    IMPORT_C virtual void RestoreClientRectFromViewRect(
williamr@2
  1742
                                                    TRect& aClientRect) const;
williamr@2
  1743
williamr@2
  1744
    /**
williamr@2
  1745
     * Rounds down the height of the rectangle (if necessary) so that only a 
williamr@2
  1746
     * whole number of items can be displayed inside the list box.
williamr@2
  1747
     *
williamr@2
  1748
     * @param aRect The rectangle to be modified. 
williamr@2
  1749
     * @return The number of pixels reduced.
williamr@2
  1750
     */
williamr@2
  1751
    IMPORT_C virtual TInt AdjustRectHeightToWholeNumberOfItems(
williamr@2
  1752
                                                        TRect& aRect) const;
williamr@2
  1753
williamr@2
  1754
    /**
williamr@2
  1755
     * Move to next or previous item according to the given parameter.
williamr@2
  1756
     *
williamr@2
  1757
     * @param aPoint Position which defines the moving direction.
williamr@2
  1758
     */
williamr@2
  1759
    IMPORT_C void MoveToNextOrPreviousItemL(TPoint aPoint);
williamr@2
  1760
williamr@2
  1761
protected: //from CCoeControl
williamr@2
  1762
williamr@2
  1763
    /**
williamr@2
  1764
     * From @c CCoeControl
williamr@2
  1765
     *
williamr@2
  1766
     * Updates the viewing rectangle of this control appropriately. The function
williamr@2
  1767
     * updates the viewing rectangle, and invokes @c HandleViewRectSizeChangeL().
williamr@2
  1768
     */
williamr@2
  1769
    IMPORT_C virtual void SizeChanged();
williamr@2
  1770
    
williamr@2
  1771
    /**
williamr@2
  1772
     * From @c CCoeControl
williamr@2
  1773
     *
williamr@2
  1774
     * Gets the list of logical colours employed in the drawing of the control,
williamr@2
  1775
     * paired with an explanation of how they are used. Appends the list to 
williamr@2
  1776
     * @c aColorUseList.
williamr@2
  1777
     *
williamr@2
  1778
     * @param aColorUseList List of logical colours.
williamr@2
  1779
     */
williamr@2
  1780
    IMPORT_C virtual void GetColorUseListL(
williamr@2
  1781
                    CArrayFix<TCoeColorUse>& aColorUseList) const; 
williamr@2
  1782
                    // not available before Release 005u
williamr@2
  1783
    /**
williamr@2
  1784
     * From @c CCoeControl.
williamr@2
  1785
     *
williamr@2
  1786
     * Handles a change to the list box’s resources of type @c aType which are 
williamr@2
  1787
     * shared across the environment, colours or fonts for example.
williamr@2
  1788
     *
williamr@2
  1789
     * @param aType The type of resources that have changed.
williamr@2
  1790
     */
williamr@2
  1791
    IMPORT_C virtual void HandleResourceChange(TInt aType);         
williamr@2
  1792
                    // not available before Release 005u
williamr@2
  1793
williamr@2
  1794
private: // from CCoeControl
williamr@2
  1795
    IMPORT_C void Reserved_1();
williamr@2
  1796
    
williamr@2
  1797
    IMPORT_C void Reserved_2();
williamr@2
  1798
williamr@2
  1799
private:
williamr@2
  1800
    /**
williamr@2
  1801
    * From CAknControl
williamr@2
  1802
    */
williamr@2
  1803
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2
  1804
williamr@2
  1805
private:
williamr@2
  1806
    IMPORT_C virtual void CEikListBox_Reserved(); // listbox use only
williamr@2
  1807
    };
williamr@2
  1808
williamr@2
  1809
#endif  // __EIKLBX_H__