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