Nokia N97 SDK
Example Applications Guide

RegistrationListbox.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : RegistrationListbox.cpp
00004 *  Part of     : Registration
00005 *  Interface   : 
00006 *  Description : 
00007 *  Version     : 
00008 *
00009 *  Copyright (c) 2005-2006 Nokia Corporation.
00010 *  This material, including documentation and any related 
00011 *  computer programs, is protected by copyright controlled by 
00012 *  Nokia Corporation.
00013 * ==============================================================================
00014 */
00015 
00016 // INCLUDE FILES
00017 #include "RegistrationListbox.h"
00018 #include "RegistrationView.h"
00019 
00020 // ============================ MEMBER FUNCTIONS ==============================
00021 
00022 // ----------------------------------------------------------------------------
00023 // CRegistrationListbox::CreateSettingItemL()
00024 // Updates descriptor array for list box
00025 // ----------------------------------------------------------------------------
00026 //
00027 CAknSettingItem* CRegistrationListbox::CreateSettingItemL( TInt aIdentifier  )
00028     {
00029 
00030     CAknSettingItem* settingItem = NULL;
00031 
00032     switch ( aIdentifier )
00033         {
00034         case ERegistrationSettingName:
00035             settingItem = new ( ELeave ) CAknTextSettingItem( aIdentifier, 
00036                                                           iItemData->iName );
00037             break;
00038         
00039         case ERegistrationSettingEmail:
00040             settingItem = new ( ELeave ) CAknTextSettingItem( aIdentifier, 
00041                                                           iItemData->iEmail );
00042             break;
00043         
00044         case ERegistrationSettingPhone:
00045             settingItem = new ( ELeave ) CAknTextSettingItem( aIdentifier, 
00046                                                           iItemData->iPhone );
00047             break;
00048 
00049         case ERegistrationSettingDate:
00050             settingItem = new ( ELeave ) CAknTimeOrDateSettingItem( 
00051                   aIdentifier, CAknTimeOrDateSettingItem::EDate, iItemData->iDate );
00052             break;
00053 
00054         case ERegistrationSettingTime:
00055             settingItem = new ( ELeave ) CAknTimeOrDateSettingItem( 
00056                   aIdentifier, CAknTimeOrDateSettingItem::ETime, iItemData->iTime );
00057             break;
00058 
00059         case ERegistrationSettingGender:
00060             settingItem = new ( ELeave ) CAknBinaryPopupSettingItem( 
00061                                                   aIdentifier, iItemData->iGender );
00062             break;
00063         
00064         case ERegistrationSettingLogin:
00065             settingItem = new ( ELeave ) CAknTextSettingItem( aIdentifier, 
00066                                                           iItemData->iLogin );
00067             break;
00068 
00069         case ERegistrationSettingPassWord:
00070             settingItem = new ( ELeave ) CAknPasswordSettingItem( 
00071                      aIdentifier, CAknPasswordSettingItem::EAlpha, iItemData->iPw );
00072             break;
00073 
00074         case ERegistrationSettingSlider:
00075             settingItem = new ( ELeave ) CAknSliderSettingItem( 
00076                                 aIdentifier, iItemData->iSliderValue );
00077             break;
00078     
00079         case ERegistrationSettingAccept:
00080             settingItem = new ( ELeave ) CAknBinaryPopupSettingItem( 
00081                                                   aIdentifier, iItemData->iAccept );
00082             break;
00083 
00084         default:
00085             break;
00086         }
00087     return settingItem;
00088     }
00089     
00090 // ----------------------------------------------------------------------------
00091 // CRegistrationListbox::EditItemL(TInt aIndex, TBool aCalledFromMenu)
00092 // Edit data
00093 // ----------------------------------------------------------------------------
00094 //    
00095 void CRegistrationListbox::EditItemL( TInt aIndex, TBool aCalledFromMenu )
00096   {
00097   CAknSettingItemList::EditItemL( aIndex, aCalledFromMenu );
00098   ( *SettingItemArray() )[aIndex]->UpdateListBoxTextL();
00099   ( *SettingItemArray() )[aIndex]->StoreL();
00100   }
00101 
00102 // ----------------------------------------------------------------------------
00103 // CRegistrationListbox::SetData()
00104 // Set ListItem data
00105 // ----------------------------------------------------------------------------
00106 //
00107 void CRegistrationListbox::SetData( TRegistrationItemdata* aItemData )
00108     {
00109     iItemData = aItemData;
00110     }
00111 
00112 // ----------------------------------------------------------------------------
00113 // TKeyResponse CRegistrationListbox::OfferKeyEventL()
00114 // Handles the key events.
00115 // ----------------------------------------------------------------------------
00116 //
00117 TKeyResponse CRegistrationListbox::OfferKeyEventL( const TKeyEvent& aKeyEvent,
00118                                                        TEventCode aType  )
00119     {
00120     // No action if not key event
00121     if ( aType != EEventKey )
00122         {
00123         return EKeyWasNotConsumed;
00124         }
00125 
00126     // The code of key event is checked
00127     switch ( aKeyEvent.iCode ) 
00128         {
00129         // These events have no function in this application
00130         case EKeySpace:
00131         case EKeyRightArrow:         
00132         case EKeyLeftArrow:          
00133             break;
00134 
00135         default:
00136             CAknSettingItemList::OfferKeyEventL( aKeyEvent, aType );
00137             break;
00138         }
00139     return EKeyWasConsumed;
00140     }
00141 
00142 // ----------------------------------------------------------------------------
00143 // CRegistrationListbox::SizeChanged()
00144 // Called by framework when the view size is changed.
00145 // ----------------------------------------------------------------------------
00146 //
00147 void CRegistrationListbox::SizeChanged()
00148     {
00149     if ( ListBox() ) 
00150         {
00151         ListBox()->SetRect( Rect() );
00152         }
00153     }
00154 
00155 // End of File

© Nokia 2009

Back to top