Nokia N97 SDK
Example Applications Guide

ChoiceListExContainer.h

00001 /**
00002  * Copyright (c) 2007 Nokia Corporation.
00003  * This material, including documentation and any related
00004  * computer programs, is protected by
00005  * copyright controlled by Nokia Corporation.
00006  */
00007 
00008 #ifndef __CHOICELISTEX_CONTAINER_H__
00009 #define __CHOICELISTEX_CONTAINER_H__
00010 
00011 #include <coecntrl.h>
00012 #include <aknchoicelist.h>
00013 
00014 
00015 /**
00016  * Container class
00017  */
00018 
00019 class CChoiceListExContainer : public CCoeControl, 
00020                                public MCoeControlObserver
00021     {
00022     
00023 public: // constructor and destructor
00024     
00025    /*
00026     * C++ default constructor 
00027     */
00028     CChoiceListExContainer();
00029     
00030    /*
00031     * Destructor 
00032     */
00033     virtual ~CChoiceListExContainer();
00034     
00035    /*
00036     * Symbian 2nd constructor 
00037     * aParam aRect The rect for ChoiceListEx
00038     */
00039     void ConstructL( const TRect& aRect );
00040     
00041 public: // new functions
00042 
00043    /*
00044     * Creates a default choice list
00045     */
00046     void CreateDefaultChoiceListL();    
00047 
00048    /*
00049     * Creates a choice list with button
00050     */
00051     void CreateButtonChoiceListL();
00052     
00053    /*
00054     * Creates an empty choice list and adds
00055     * items to it from a resource
00056     */
00057     void CreateResourceChoiceListL();
00058     
00059    /*
00060     * Opens the choice list 
00061     */
00062     void ShowListL();
00063     
00064    /*
00065     * Closes the choice list
00066     */
00067     void HideListL();
00068     
00069    /*
00070     * Adds an item to a choice list
00071     */
00072     void AddItemL();
00073     
00074    /*
00075     * Inserts an item to a choice list
00076     */
00077     void InsertItemL();
00078     
00079    /*
00080     * Removes an item from a choice list
00081     */
00082     void RemoveItemL();
00083     
00084    /*
00085     * Selects an item from a choice list
00086     */
00087     void SelectItemL();
00088        
00089    /*
00090     * Changes choice list flag settings ( positioning )
00091     * @Param aFlag New position flag of choice list popup
00092     */
00093     void ChangeListFlagsL( CAknChoiceList::TAknChoiceListFlags aFlag );
00094     
00095 public: // from CCoeControl
00096     
00097    /*
00098     * From CCoeControl, Draw
00099     * Draws the application area 
00100     * @param aRect Region of the control to be drawn
00101     */
00102     void Draw( const TRect& aRect ) const;
00103 
00104    /*
00105     * From CCoeControl, CountcomponentControls
00106     * Returns the number of controls 
00107     * @return Number of controls
00108     */
00109     TInt CountComponentControls() const;
00110     
00111    /*
00112     * From CCoeControl, ComponentControl
00113     * Returns pointer to a particular component
00114     * @param aIndex Index of the control
00115     * @return Pointer to component control identified by index
00116     */
00117     CCoeControl* ComponentControl( TInt aIndex ) const;
00118     
00119    /* 
00120     * From CCoeControl, OfferKeyEventL
00121     * Handles key events from the framework
00122     * @param aKeyEvent the key event    
00123     * @param aType The type of key event
00124     * @return Indicates whether or not the keyevent was used
00125     */
00126     TKeyResponse OfferKeyEventL( const TKeyEvent& aKeyEvent,TEventCode aType );
00127 
00128    /* 
00129     * From CCoeControl, HandleResourceChange
00130     * Handles a change to the control's resources.
00131     * @param aType TA message UID value
00132     */
00133     void HandleResourceChange( TInt aType );
00134    
00135    /* 
00136     * From CCoeControl, HandleResourceChange
00137     * Responds to changes to the size and position of the contents of this control.
00138     */ 
00139     void SizeChanged();
00140     
00141 public: // from MCoeControlObserver
00142 
00143    /*
00144     * From MCoeControlObserver, HandleControlEventL
00145     * Handles control events from choice list
00146     * @param aControl The control that sent the event
00147     * @param aEventType The event type
00148     */
00149     void HandleControlEventL( CCoeControl* aControl, TCoeEvent aEventType );
00150 
00151 private: // Help functions
00152 
00153    /*
00154     * Calculates array resource's size
00155     * @param aResourceId Id of resource
00156     * @return Number of items in array
00157     */
00158     TInt ArraySizeL( TInt aResourceId );
00159          
00160 private: // data
00161 
00162    /*
00163     * Label for showing messages
00164     */
00165     CEikLabel* iLabel; // Own
00166     
00167    /*
00168     *  Choice list
00169     */ 
00170     CAknChoiceList* iChoiceList; // Own
00171 
00172    /*
00173     * Background context 
00174     */
00175     CAknsBasicBackgroundControlContext* iBgContext;  // Own
00176 
00177    /*
00178     * Amount of items in choice list
00179     */
00180     TInt iArraySize;
00181     
00182    /*  
00183     * Selected item index
00184     */
00185     TInt iSelection;
00186     
00187     };
00188 
00189 #endif // __CHOICELISTEX_CONTAINER_H__

© Nokia 2009

Back to top