|
Nokia N97 SDK Example Applications Guide |
#include <localizationappui.h>
Inheritance diagram for CLocalizationAppUi:

Definition at line 35 of file localizationappui.h.
Public Member Functions |
|
| void | ConstructL () |
| CLocalizationAppUi () | |
| virtual | ~CLocalizationAppUi () |
Private Member Functions |
|
| void | HandleCommandL (TInt aCommand) |
| void | HandleStatusPaneSizeChange () |
Private Attributes |
|
| CLocalizationAppView * | iAppView |
|
|
CLocalizationAppUi. C++ default constructor. This needs to be public due to the way the framework constructs the AppUi Definition at line 53 of file localizationappui.cpp.
|
|
|
~CLocalizationAppUi. Virtual Destructor. Definition at line 63 of file localizationappui.cpp. References iAppView. 00064 { 00065 if ( iAppView ) 00066 { 00067 delete iAppView; 00068 iAppView = NULL; 00069 } 00070 00071 }
|
|
|
ConstructL. 2nd phase constructor. Definition at line 39 of file localizationappui.cpp. References iAppView, and CLocalizationAppView::NewL(). 00040 { 00041 // Initialise app UI with standard value. 00042 BaseConstructL(EAknEnableSkin); 00043 // Create view object 00044 iAppView = CLocalizationAppView::NewL( ClientRect() ); 00045 00046 00047 }
|
|
|
From CEikAppUi, HandleCommandL. Takes care of command handling.
Definition at line 78 of file localizationappui.cpp. References CLocalizationAppView::DrawImage(), and iAppView. 00079 { 00080 switch( aCommand ) 00081 { 00082 case EEikCmdExit: 00083 case EAknSoftkeyExit: 00084 Exit(); 00085 break; 00086 00087 // Number 00088 case ELocalizationCommandNumber: 00089 { 00090 // buffer for localized text 00091 TBuf<50> myBuf; 00092 00093 // Amount to show 00094 TReal myAmount = 1234.567; 00095 00096 // Real number formatter, initialized with system's current locale settings 00097 TRealFormat myFormat; 00098 00099 // Format real with current locales decimal separator setting 00100 myBuf.AppendNum(myAmount, myFormat); 00101 00102 // Show formatted text 00103 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; 00104 informationNote->ExecuteLD( myBuf ); 00105 } 00106 break; 00107 00108 // Currency 00109 case ELocalizationCommandCurrency: 00110 { 00111 // locale is initialized with system's current locale settings 00112 TLocale myLocale; 00113 00114 // buffer for localized text 00115 TBuf<50> myBuf; 00116 00117 // amount is integer, but it is treated as last two digits 00118 // were decimal digits e.g. 1249 = 12.49, 2 = 0.02 ... 00119 TInt myAmount = 123456789; 00120 00121 // Format currency according to current locale settings 00122 myLocale.FormatCurrency(myBuf, myAmount); 00123 00124 // Show formatted text 00125 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; 00126 informationNote->ExecuteLD( myBuf ); 00127 } 00128 break; 00129 00130 // Date 00131 case ELocalizationCommandDate: 00132 { 00133 // buffer for localized text 00134 TBuf<50> myBuf; 00135 00136 // Object for datetime data 00137 TTime myDate; 00138 00139 // Set current datetime to object 00140 myDate.HomeTime(); 00141 00142 // Format date according to current locale settings 00143 // Format string is universal, so that whatever the locale is, 00144 // date is always formatted correctly 00145 myDate.FormatL(myBuf, _L("%/0%1%/1%2%/2%3%/3%X")); 00146 00147 // Show formatted text 00148 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; 00149 informationNote->ExecuteLD( myBuf ); 00150 } 00151 break; 00152 00153 // Time 00154 case ELocalizationCommandTime: 00155 { 00156 // buffer for localized text 00157 TBuf<50> myBuf; 00158 00159 // Object for datetime data 00160 TTime myTime; 00161 00162 // Set current datetime to object 00163 myTime.HomeTime(); 00164 00165 // Format time to current locale 00166 // Format string is universal, so that whatever the locale is, 00167 // time is always formatted correctly 00168 myTime.FormatL(myBuf, _L("%-B%:0%J%:1%T%:2%S%:3%+B")); 00169 00170 // Show formatted text 00171 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; 00172 informationNote->ExecuteLD( myBuf ); 00173 } 00174 break; 00175 00176 // Text 00177 case ELocalizationCommandText: 00178 { 00179 // buffer for string parameters that may change order 00180 CDesCArrayFlat* strings = new CDesCArrayFlat( 2 ); 00181 CleanupStack::PushL( strings ); 00182 00183 // Initialize parameter buffer 00184 00185 // First parameter 00186 strings->AppendL( _L("Heidi") ); 00187 00188 // Second parameter 00189 strings->AppendL( _L("2") ); 00190 00191 // Load a string from the resource file, and append parameters into it 00192 HBufC* textResource = StringLoader::LoadL( R_LOC_COMMANDTEXT_TEXT, *strings ); 00193 CleanupStack::PushL( textResource ); 00194 00195 // Show formatted text 00196 CAknInformationNote* informationNote = new ( ELeave ) CAknInformationNote; 00197 informationNote->ExecuteLD( *textResource ); 00198 00199 // Cleanupstack 00200 CleanupStack::PopAndDestroy( textResource ); 00201 CleanupStack::PopAndDestroy( strings ); 00202 } 00203 break; 00204 00205 // Image 00206 case ELocalizationCommandImage: 00207 { 00208 // find the drive where the app has been installed 00209 TParse parse; 00210 parse.Set(Application()->AppFullName(),0,0); 00211 00212 // Load bitmap name from the resource file 00213 HBufC* bmpFile = StringLoader::LoadLC( R_LOC_COMMANDIMAGE_BMPFILE, parse.Drive()); 00214 00215 // bitmap pointer 00216 CFbsBitmap* bitmap; 00217 00218 // Create and Load the Bitmap 00219 bitmap = new( ELeave )CFbsBitmap; 00220 CleanupStack::PushL( bitmap ); 00221 00222 // Load the first bitmap (index 0) from multi-bitmap file 00223 User::LeaveIfError(bitmap->Load( *bmpFile, 0 )); 00224 00225 CleanupStack::Pop( bitmap ); 00226 // Draw bitmap to screen 00227 // ownership of bitmap is transferred to view 00228 iAppView->DrawImage( bitmap ); 00229 00230 // Cleanupstack 00231 CleanupStack::PopAndDestroy( bmpFile ); 00232 } 00233 break; 00234 00235 // Default case 00236 default: 00237 break; 00238 } 00239 }
|
|
|
HandleStatusPaneSizeChange. Called by the framework when the application status pane size is changed. Definition at line 246 of file localizationappui.cpp. References iAppView. 00247 { 00248 iAppView->SetRect( ClientRect() ); 00249 00250 }
|
|
|
The application view Owned by CLocalizationAppUi Definition at line 80 of file localizationappui.h. Referenced by ConstructL(), HandleCommandL(), HandleStatusPaneSizeChange(), and ~CLocalizationAppUi(). |
|
© Nokia 2009 |