epoc32/include/mw/aknpopup.h
author William Roberts <williamr@symbian.org>
Tue, 16 Mar 2010 16:12:26 +0000
branchSymbian2
changeset 2 2fe1408b6811
parent 1 666f914201fb
child 4 837f303aceeb
permissions -rw-r--r--
Final list of Symbian^2 public API header files
williamr@2
     1
/*
williamr@2
     2
* Copyright (c) 2002 Nokia Corporation and/or its subsidiary(-ies).
williamr@2
     3
* All rights reserved.
williamr@2
     4
* This component and the accompanying materials are made available
williamr@2
     5
* under the terms of the License "Symbian Foundation License v1.0" to Symbian Foundation members and "Symbian Foundation End User License Agreement v1.0" to non-members
williamr@2
     6
* which accompanies this distribution, and is available
williamr@2
     7
* at the URL "http://www.symbianfoundation.org/legal/licencesv10.html".
williamr@2
     8
*
williamr@2
     9
* Initial Contributors:
williamr@2
    10
* Nokia Corporation - initial contribution.
williamr@2
    11
*
williamr@2
    12
* Contributors:
williamr@2
    13
*
williamr@2
    14
* Description: 
williamr@2
    15
* Support for Avkon Popped-up lists
williamr@2
    16
*
williamr@2
    17
*
williamr@2
    18
*/
williamr@2
    19
williamr@2
    20
williamr@2
    21
#if !defined(__AKNPOPUP_H__)
williamr@2
    22
#define __AKNPOPUP_H__
williamr@2
    23
williamr@2
    24
#include <coecntrl.h>
williamr@2
    25
#include <eikcmobs.h>
williamr@2
    26
#include <eiklbx.h>
williamr@2
    27
#include <aknpopuplayout.h>
williamr@2
    28
#include <aknintermediate.h>
williamr@2
    29
#include <aknpopupfader.h>
williamr@2
    30
williamr@2
    31
class CAknPopupHeadingPane;
williamr@2
    32
class CEikButtonGroupContainer;
williamr@2
    33
class CEikListBox;
williamr@2
    34
class CAknSearchField;
williamr@2
    35
class CAknPopupListExtension;
williamr@2
    36
williamr@2
    37
/** Used to popup a list or grid. Takes an existing listbox control and
williamr@2
    38
 *  puts it into a popup frame together with an optional title.
williamr@2
    39
 *
williamr@2
    40
 * @c CAknPopupList is not a dialog!
williamr@2
    41
 *
williamr@2
    42
 * There are two standard usages of @c CAknPopupList:
williamr@2
    43
 *
williamr@2
    44
 * @code 
williamr@2
    45
 *  CAknPopupList *plist = CAknPopupList::NewL(...);
williamr@2
    46
 *  CleanupStack::PushL(plist);
williamr@2
    47
 *  ...
williamr@2
    48
 *  TInt popupOk = plist->ExecuteLD(...);
williamr@2
    49
 *  // No leaving functions allowed between ExecuteLD and
williamr@2
    50
 *  // CleanupStack::Pop().
williamr@2
    51
 *  CleanupStack::Pop(); // plist
williamr@2
    52
 *  if (popupOk) { ... } else { ... } 
williamr@2
    53
 * @endcode
williamr@2
    54
 *
williamr@2
    55
 * And then another way:
williamr@2
    56
 * @code
williamr@2
    57
 *  iPList = CAknPopupList::NewL(...);
williamr@2
    58
 *  ...
williamr@2
    59
 *  TInt popupOk = iPlist->ExecuteLD(...);
williamr@2
    60
 *  // No leaving functions allowed between ExecuteLD and iPlist=NULL;
williamr@2
    61
 *  iPlist = NULL;
williamr@2
    62
 *  if (popupOk) {... } else {... }
williamr@2
    63
 *  // note, destructor deletes the iPlist instance.
williamr@2
    64
 * @endcode
williamr@2
    65
 * 
williamr@2
    66
 * Both these work corretly and leave-safe way. Notice this usage is pretty
williamr@2
    67
 * different of how dialogs work. With dialogs you _always_ want to do 
williamr@2
    68
 * @c CleanupStack::Pop() before calling @c ExecuteLD().
williamr@2
    69
 */
williamr@2
    70
class CAknPopupList : public CEikBorderedControl,
williamr@2
    71
                      public MEikCommandObserver,
williamr@2
    72
                      public MEikListBoxObserver,
williamr@2
    73
                      public MCoeControlObserver,
williamr@2
    74
                      public MAknIntermediateState,
williamr@2
    75
                      public MAknFadedComponent
williamr@2
    76
    {
williamr@2
    77
public:	// enums 
williamr@2
    78
williamr@2
    79
    DECLARE_TYPE_ID(0x20018439)
williamr@2
    80
williamr@2
    81
public:
williamr@2
    82
williamr@2
    83
    /**
williamr@2
    84
     * Two-phased constructor.
williamr@2
    85
     *
williamr@2
    86
     * Creates the pop-up list.
williamr@2
    87
     *
williamr@2
    88
     * @param aListBox Pre-existing listbox-derived class.
williamr@2
    89
     * @param aCbaResource Softkey pane to display while pop-up is active.
williamr@2
    90
     * @param aType The layout used.
williamr@2
    91
     * @return A pointer to a pop-up list object.
williamr@2
    92
     */
williamr@2
    93
    IMPORT_C static CAknPopupList* NewL( 
williamr@2
    94
       CEikListBox* aListBox, 
williamr@2
    95
       TInt aCbaResource,
williamr@2
    96
       AknPopupLayouts::TAknPopupLayouts aType = AknPopupLayouts::EMenuWindow);
williamr@2
    97
williamr@2
    98
    /**
williamr@2
    99
     * Executes the pop-up selection list. Function returns when the user have
williamr@2
   100
     * accepted or cancelled the pop-up.
williamr@2
   101
     *
williamr@2
   102
     * @return @c ETrue if the popup was accepted. @c EFalse if 
williamr@2
   103
     *            the popup was cancelled.
williamr@2
   104
     */
williamr@2
   105
	IMPORT_C TBool ExecuteLD();
williamr@2
   106
williamr@2
   107
    /**
williamr@2
   108
     * Sets the title for the selection list.
williamr@2
   109
     *
williamr@2
   110
     * @param aTitle Title to be displayed.
williamr@2
   111
     */
williamr@2
   112
    IMPORT_C void SetTitleL(const TDesC& aTitle);
williamr@2
   113
williamr@2
   114
    /**
williamr@2
   115
     * Cancels the current popup. The popup @c ExecuteLD will return with 
williamr@2
   116
     * @c EFalse.
williamr@2
   117
     */
williamr@2
   118
	IMPORT_C void CancelPopup();
williamr@2
   119
public: // Access methods
williamr@2
   120
williamr@2
   121
    /**
williamr@2
   122
     * Gets a button group container.
williamr@2
   123
     *
williamr@2
   124
     * @return The button group.
williamr@2
   125
     */
williamr@2
   126
	IMPORT_C CEikButtonGroupContainer* ButtonGroupContainer();
williamr@2
   127
    /**
williamr@2
   128
     * Gets the popup header.
williamr@2
   129
     *
williamr@2
   130
     * @return Header properties of the pop-up menu.
williamr@2
   131
     */
williamr@2
   132
	IMPORT_C CAknPopupHeadingPane* Heading();
williamr@2
   133
williamr@2
   134
    /**
williamr@2
   135
     * Gets the popup header.
williamr@2
   136
     *
williamr@2
   137
     * @return Header properties of the pop-up menu.
williamr@2
   138
     */
williamr@2
   139
	IMPORT_C CAknPopupHeadingPane* Heading() const;
williamr@2
   140
williamr@2
   141
    /**
williamr@2
   142
     * Gets the list box.
williamr@2
   143
     *
williamr@2
   144
     * @return The list box.
williamr@2
   145
     */
williamr@2
   146
	IMPORT_C CEikListBox* ListBox();
williamr@2
   147
	
williamr@2
   148
    /**
williamr@2
   149
     * Sets the maximum height for the popup frame.
williamr@2
   150
     *
williamr@2
   151
     * @param aItems The maximum height.
williamr@2
   152
     */
williamr@2
   153
	IMPORT_C void SetMaximumHeight(TInt aItems);
williamr@2
   154
williamr@2
   155
    /**
williamr@2
   156
     * Enables the findbox of the popup list.
williamr@2
   157
     *
williamr@2
   158
     * @param aEnable Enables (default) or disables the findbox.
williamr@2
   159
     * @return @c ETrue if enabling/disabling was successfull.
williamr@2
   160
     */
williamr@2
   161
    IMPORT_C TBool EnableFind(TBool aEnable=ETrue);
williamr@2
   162
williamr@2
   163
    /**
williamr@2
   164
     * Enables the findbox with adaptive search of the popup list.
williamr@2
   165
     *
williamr@2
   166
     * @since 5.0
williamr@2
   167
     * @param aEnable Enables (default) or disables the adaptive findbox.
williamr@2
   168
     * @return @c ETrue if enabling/disabling was successfull.
williamr@2
   169
     */
williamr@2
   170
    IMPORT_C TBool EnableAdaptiveFind(TBool aEnable=ETrue);
williamr@2
   171
williamr@2
   172
    /**
williamr@2
   173
     * Gets the search field control.
williamr@2
   174
     *
williamr@2
   175
     * @return Search field control.
williamr@2
   176
     */
williamr@2
   177
    IMPORT_C CAknSearchField* FindBox() const;
williamr@2
   178
public:
williamr@2
   179
    /**
williamr@2
   180
     * From @c CCoeControl.
williamr@2
   181
     * 
williamr@2
   182
     * Handles pointer events of popups.
williamr@2
   183
     *
williamr@2
   184
     * @param aPointerEvent Pointer event to be handled.
williamr@2
   185
     */
williamr@2
   186
    IMPORT_C void HandlePointerEventL(const TPointerEvent& aPointerEvent);
williamr@2
   187
protected:
williamr@2
   188
    /**
williamr@2
   189
     * From @c MEikCommandObserver.
williamr@2
   190
     *
williamr@2
   191
     * Processes events from the softkeys. Responds to @c EAknSoftkeyOk and 
williamr@2
   192
     * @c EAknSoftkeyBack to accept or cancel the pop-up.
williamr@2
   193
     *
williamr@2
   194
     * @param aCommandId Event Id from the soft-key.
williamr@2
   195
     */
williamr@2
   196
    IMPORT_C void ProcessCommandL(TInt aCommandId);
williamr@2
   197
williamr@2
   198
    /**
williamr@2
   199
     * From @c MEikListBoxObserver.
williamr@2
   200
     *
williamr@2
   201
     * Processes key events from the listbox. Responds to 
williamr@2
   202
     * @c EEventEnterKeyPressed to accept the pop-up.
williamr@2
   203
     *
williamr@2
   204
     * @param aListBox Listbox being observed.
williamr@2
   205
     * @param aEventType Event being observed.
williamr@2
   206
     */
williamr@2
   207
    IMPORT_C void HandleListBoxEventL(CEikListBox* aListBox, 
williamr@2
   208
                                      TListBoxEvent aEventType);
williamr@2
   209
    /**
williamr@2
   210
     * From @c MCoeControlObserver.
williamr@2
   211
     *
williamr@2
   212
     * Handles an event from an observed control.
williamr@2
   213
     *
williamr@2
   214
     * @param aControl Control being observed.
williamr@2
   215
     * @param aEventType Event observed.
williamr@2
   216
     */
williamr@2
   217
    IMPORT_C void HandleControlEventL(CCoeControl* aControl,
williamr@2
   218
                                      TCoeEvent aEventType);
williamr@2
   219
protected:
williamr@2
   220
williamr@2
   221
    /**
williamr@2
   222
     * C++ default constructor.
williamr@2
   223
     */
williamr@2
   224
    IMPORT_C CAknPopupList();
williamr@2
   225
williamr@2
   226
    /**
williamr@2
   227
     * Destructor.
williamr@2
   228
     */
williamr@2
   229
    IMPORT_C ~CAknPopupList();
williamr@2
   230
williamr@2
   231
    /**
williamr@2
   232
     * Handles 2nd phase construction.
williamr@2
   233
     * 
williamr@2
   234
     * @param aListBox Pre-existing listbox-derived class.
williamr@2
   235
     * @param aCbaResource Softkey pane to display while pop-up is active.
williamr@2
   236
     * @param aType The layout used.
williamr@2
   237
     */
williamr@2
   238
    IMPORT_C void ConstructL(CEikListBox* aListBox, 
williamr@2
   239
                             TInt aCbaResource,
williamr@2
   240
                             AknPopupLayouts::TAknPopupLayouts aType );
williamr@2
   241
williamr@2
   242
    /**
williamr@2
   243
     * Called when the user accepts or cancels the listbox.
williamr@2
   244
     *
williamr@2
   245
     * @param aAccept @c ETrue if the user has accepted, @c EFalse if the user 
williamr@2
   246
     *                   has cancelled the listbox.
williamr@2
   247
     */
williamr@2
   248
    IMPORT_C virtual void AttemptExitL(TBool aAccept);
williamr@2
   249
williamr@2
   250
    /**
williamr@2
   251
     * Setup the whole window layout; window position, grid and heading 
williamr@2
   252
     * position, shadow for the window.
williamr@2
   253
     *
williamr@2
   254
     * @param aType A choice of layout.  
williamr@2
   255
     */
williamr@2
   256
    IMPORT_C virtual void SetupWindowLayout(
williamr@2
   257
                                     AknPopupLayouts::TAknPopupLayouts aType);
williamr@2
   258
williamr@2
   259
    /** 
williamr@2
   260
     * Returns the listbox being used.
williamr@2
   261
     *
williamr@2
   262
     * @return Listbox contained in the pop-up.
williamr@2
   263
     */
williamr@2
   264
    IMPORT_C CEikListBox* ListBox() const;
williamr@2
   265
williamr@2
   266
    /**
williamr@2
   267
     * Gets the layout definitions for the popup list.
williamr@2
   268
     *
williamr@2
   269
     * @return Collects all LAF specification lines that are needed for popup 
williamr@2
   270
     *         windows.
williamr@2
   271
     */
williamr@2
   272
    IMPORT_C const TAknPopupWindowLayoutDef& Layout() const;
williamr@2
   273
williamr@2
   274
    /**
williamr@2
   275
     * Gets the layout definitions for the popup list.
williamr@2
   276
     *
williamr@2
   277
     * @return Collects all LAF specification lines that are needed for popup 
williamr@2
   278
     *         windows.
williamr@2
   279
     */
williamr@2
   280
    IMPORT_C TAknPopupWindowLayoutDef& Layout();
williamr@2
   281
williamr@2
   282
protected:
williamr@2
   283
williamr@2
   284
    /**
williamr@2
   285
     * From @c MopSupplyObject.
williamr@2
   286
     *
williamr@2
   287
     * Retrieves an object of the same type as that encapsulated in @c aId.
williamr@2
   288
     *
williamr@2
   289
     * @param aId Encapsulated object type ID.
williamr@2
   290
     * @return Encapsulates the pointer to the object provided.
williamr@2
   291
     *         Note that the encapsulated pointer may be NULL.
williamr@2
   292
     */
williamr@2
   293
    IMPORT_C TTypeUid::Ptr MopSupplyObject(TTypeUid aId);
williamr@2
   294
williamr@2
   295
protected:
williamr@2
   296
williamr@2
   297
    /**
williamr@2
   298
     * From @c CCoeControl.
williamr@2
   299
     *
williamr@2
   300
     * Handles a change to the control's resources.
williamr@2
   301
     *
williamr@2
   302
     * @param aType A message UID value.
williamr@2
   303
     */
williamr@2
   304
    IMPORT_C void HandleResourceChange(TInt aType);
williamr@2
   305
williamr@2
   306
protected:
williamr@2
   307
	IMPORT_C void FadeBehindPopup(TBool aFade);
williamr@2
   308
williamr@2
   309
williamr@2
   310
williamr@2
   311
private:
williamr@2
   312
	// the following needs to be imported, because they need to be
williamr@2
   313
	// used in virtual table of any derived class.
williamr@2
   314
	IMPORT_C TSize MinimumSize();
williamr@2
   315
	IMPORT_C CCoeControl* ComponentControl(TInt aIndex) const;
williamr@2
   316
	IMPORT_C TInt CountComponentControls() const;
williamr@2
   317
	IMPORT_C void Draw(const TRect& aRect) const;
williamr@2
   318
	IMPORT_C TKeyResponse OfferKeyEventL(const TKeyEvent& aKeyEvent,
williamr@2
   319
	                                     TEventCode aType);
williamr@2
   320
	IMPORT_C void FocusChanged(TDrawNow aDrawNow);
williamr@2
   321
williamr@2
   322
	IMPORT_C void CloseState();
williamr@2
   323
	// From MAknFadedComponent
williamr@2
   324
	IMPORT_C virtual TInt CountFadedComponents();
williamr@2
   325
	IMPORT_C virtual CCoeControl* FadedComponent(TInt aIndex);
williamr@2
   326
williamr@2
   327
private:
williamr@2
   328
    /**
williamr@2
   329
    * From CAknControl
williamr@2
   330
    */
williamr@2
   331
    IMPORT_C void* ExtensionInterface( TUid aInterface );
williamr@2
   332
williamr@2
   333
private:
williamr@2
   334
	void RemoveFindFiltering();
williamr@2
   335
williamr@2
   336
protected: // these are protected to allow overriding virtual functions.
williamr@2
   337
	CEikListBox*				iListBox;
williamr@2
   338
    
williamr@2
   339
    /**
williamr@2
   340
     * A button group container - a wrapper around the different button 
williamr@2
   341
     * arrays.
williamr@2
   342
     */
williamr@2
   343
    CEikButtonGroupContainer* iPopoutCba;
williamr@2
   344
    
williamr@2
   345
    /** 
williamr@2
   346
     * Header control for queries. Defines properties of the header of the 
williamr@2
   347
     * pop-up menu.
williamr@2
   348
     */
williamr@2
   349
    CAknPopupHeadingPane* iTitle;
williamr@2
   350
    
williamr@2
   351
    /** The address to hold the return value from the popup */
williamr@2
   352
    TBool* iReturn;
williamr@2
   353
    
williamr@2
   354
    /**  */
williamr@2
   355
    TBool iMarkable;
williamr@2
   356
    
williamr@2
   357
    /**  */
williamr@2
   358
    TInt iCurrentResource;
williamr@2
   359
    
williamr@2
   360
    /** Popup layout type. */
williamr@2
   361
	AknPopupLayouts::TAknPopupLayouts iWindowType;
williamr@2
   362
    
williamr@2
   363
    /**
williamr@2
   364
     * collects all LAF specification lines that are needed for popup window.
williamr@2
   365
     */
williamr@2
   366
    TAknPopupWindowLayoutDef iLayout;
williamr@2
   367
williamr@2
   368
williamr@2
   369
    /**  */
williamr@2
   370
    TBool iAppBroughtForwards;
williamr@2
   371
    
williamr@2
   372
    /**  */
williamr@2
   373
    TAknPopupFader iPopupFader;
williamr@2
   374
    
williamr@2
   375
    /**  */
williamr@2
   376
    CIdle *iIdle;
williamr@2
   377
williamr@2
   378
williamr@2
   379
    /**  */
williamr@2
   380
	CActiveSchedulerWait iWait;		// owned, safe to use as direct member data.
williamr@2
   381
private:
williamr@2
   382
    CAknPopupListExtension* iPopupListExtension;    // owned
williamr@2
   383
	};
williamr@2
   384
williamr@2
   385
#endif
williamr@2
   386
williamr@2
   387
williamr@2
   388