|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : DirectoryLocalizerExContainer.cpp 00004 * Part of : DirectoryLocalizerEx 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 "directorylocalizerexcontainer.h" 00017 #include <directorylocalizerex.rsg> 00018 #include <aknnotewrappers.h> 00019 #include <COEMAIN.H> 00020 #include <barsread.h> 00021 #include <f32file.h> 00022 #include <e32des8.h> 00023 00024 #define KAknAtListGray TRgb(0xaaaaaa) 00025 00026 00027 _LIT( KDLTestExistsDir, "c:\\example\\" ); 00028 _LIT( strNote, "Not Localized" ); 00029 00030 // ============================== CONSTANTS ================================== 00031 const TInt KMaxString = 20; 00032 00033 // =========================== MEMBER FUNCTIONS ============================== 00034 00035 // --------------------------------------------------------------------------- 00036 // C++ default Constructor 00037 // --------------------------------------------------------------------------- 00038 // 00039 CDirectoryLocalizerExContainer::CDirectoryLocalizerExContainer() 00040 { 00041 } 00042 00043 // --------------------------------------------------------------------------- 00044 // Destructor 00045 // --------------------------------------------------------------------------- 00046 // 00047 CDirectoryLocalizerExContainer::~CDirectoryLocalizerExContainer() 00048 { 00049 ResetControl(); 00050 } 00051 00052 // --------------------------------------------------------------------------- 00053 // Symbian 2nd Constructor 00054 // --------------------------------------------------------------------------- 00055 // 00056 void CDirectoryLocalizerExContainer::ConstructL( const TRect& aRect ) 00057 { 00058 CreateWindowL(); 00059 SetRect( aRect ); 00060 ActivateL(); 00061 } 00062 00063 // ---------------------------------------------------------------------------- 00064 // CDirectoryLocalizerContainer::Draw 00065 // Fills the window's rectangle. 00066 // ---------------------------------------------------------------------------- 00067 // 00068 void CDirectoryLocalizerExContainer::Draw( const TRect& aRect ) const 00069 { 00070 CWindowGc& gc = SystemGc(); 00071 gc.SetPenStyle( CGraphicsContext::ENullPen ); 00072 gc.SetBrushColor( KAknAtListGray ); 00073 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 00074 gc.DrawRect( aRect ); 00075 } 00076 00077 // --------------------------------------------------------------------------- 00078 // CDirectoryLocalizerContainer::CountComponentControls 00079 // --------------------------------------------------------------------------- 00080 // 00081 TInt CDirectoryLocalizerExContainer::CountComponentControls() const 00082 { 00083 if ( iControl ) 00084 { 00085 return 1; 00086 } 00087 else 00088 { 00089 return 0; 00090 } 00091 } 00092 00093 // --------------------------------------------------------------------------- 00094 // CDirectoryLocalizerContainer::ComponentControl 00095 // --------------------------------------------------------------------------- 00096 // 00097 CCoeControl* CDirectoryLocalizerExContainer::ComponentControl( TInt ) const 00098 { 00099 return iControl; 00100 } 00101 00102 // --------------------------------------------------------------------------- 00103 // CDirectoryLocalizerContainer::SetControlL 00104 // --------------------------------------------------------------------------- 00105 // 00106 void CDirectoryLocalizerExContainer::SetControlL( CCoeControl* aControl ) 00107 { 00108 iControl = aControl; 00109 if ( iControl ) 00110 { 00111 // You can change the position and size 00112 iControl->SetExtent( Rect().iTl, Rect().Size() ); 00113 iControl->ActivateL(); 00114 DrawNow(); 00115 } 00116 } 00117 00118 // --------------------------------------------------------------------------- 00119 // CDirectoryLocalizerContainer::ResetControl 00120 // --------------------------------------------------------------------------- 00121 // 00122 void CDirectoryLocalizerExContainer::ResetControl() 00123 { 00124 delete iControl; 00125 iControl = NULL; 00126 } 00127 // --------------------------------------------------------------------------- 00128 // CDirectoryLocalizerContainer::SetupFromResRdL 00129 // --------------------------------------------------------------------------- 00130 // 00131 00132 void CDirectoryLocalizerExContainer::SetupFromResRdL() 00133 { 00134 TResourceReader reader; 00135 CCoeEnv::Static()->CreateResourceReaderLC( reader, 00136 R_EXAMPLE_LOCALIZER_ENTRIES ); 00137 CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL( reader ); 00138 CleanupStack::PushL(localizer); // localizer 00139 00140 localizer->SetFullPath( KDLTestExistsDir ); 00141 TBool success = localizer->IsLocalized(); 00142 00143 CAknInformationNote *note = new ( ELeave ) CAknInformationNote(); 00144 if( success ) 00145 { 00146 const TPtrC strNote = localizer->LocalizedName(); 00147 note->ExecuteLD( strNote ); 00148 } 00149 else 00150 { 00151 note->ExecuteLD( strNote ); 00152 } 00153 00154 CleanupStack::PopAndDestroy(); // localizer 00155 CleanupStack::PopAndDestroy(); // reader 00156 } 00157 // --------------------------------------------------------------------------- 00158 // CDirectoryLocalizerContainer::SetupFromResIdL 00159 // --------------------------------------------------------------------------- 00160 // 00161 void CDirectoryLocalizerExContainer::SetupFromResIdL() 00162 { 00163 // construct with default data 00164 CDirectoryLocalizer* localizer = CDirectoryLocalizer 00165 ::NewL( R_EXAMPLE_LOCALIZER_ENTRIES ); 00166 CleanupStack::PushL(localizer); // localizer 00167 00168 localizer->SetFullPath( KDLTestExistsDir ); 00169 TBool success = localizer->IsLocalized(); 00170 00171 CAknInformationNote *note = new ( ELeave ) CAknInformationNote(); 00172 if( success ) 00173 { 00174 const TPtrC strNote = localizer->LocalizedName(); 00175 note->ExecuteLD( strNote ); 00176 } 00177 else 00178 { 00179 note->ExecuteLD( strNote ); 00180 } 00181 00182 CleanupStack::PopAndDestroy(); // localizer 00183 } 00184 // --------------------------------------------------------------------------- 00185 // CDirectoryLocalizerContainer::LocalizedFromResIdL 00186 // --------------------------------------------------------------------------- 00187 // 00188 00189 void CDirectoryLocalizerExContainer::LocalizedFromResIdL() 00190 { 00191 // construct with default data 00192 CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL(); 00193 CleanupStack::PushL(localizer); // localizer 00194 00195 localizer->AddFromResourceL( R_EXAMPLE_LOCALIZER_ENTRIES ); 00196 localizer->SetFullPath( KDLTestExistsDir ); 00197 TBool success = localizer->IsLocalized(); 00198 00199 CAknInformationNote *note = new ( ELeave ) CAknInformationNote(); 00200 if( success ) 00201 { 00202 const TPtrC strNote = localizer->LocalizedName(); 00203 note->ExecuteLD( strNote ); 00204 } 00205 else 00206 { 00207 note->ExecuteLD( strNote ); 00208 } 00209 00210 CleanupStack::PopAndDestroy(); // localizer 00211 } 00212 00213 // --------------------------------------------------------------------------- 00214 // CDirectoryLocalizerContainer::GetExtraDataL 00215 // --------------------------------------------------------------------------- 00216 // 00217 void CDirectoryLocalizerExContainer::GetExtraDataL() 00218 { 00219 // construct with default data 00220 CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL(); 00221 CleanupStack::PushL(localizer); // localizer 00222 00223 localizer->AddFromResourceL( R_EXAMPLE_LOCALIZER_ENTRIES ); 00224 localizer->SetFullPath( KDLTestExistsDir ); 00225 TBool success = localizer->IsLocalized(); 00226 00227 CAknInformationNote *note = new ( ELeave ) CAknInformationNote(); 00228 if( success ) 00229 { 00230 const TPtrC strNote = localizer->ExtraData(); 00231 note->ExecuteLD( strNote ); 00232 } 00233 else 00234 { 00235 note->ExecuteLD( strNote ); 00236 } 00237 00238 CleanupStack::PopAndDestroy(); // localizer 00239 } 00240 // --------------------------------------------------------------------------- 00241 // CDirectoryLocalizerContainer::GetIconIndexL 00242 // --------------------------------------------------------------------------- 00243 // 00244 void CDirectoryLocalizerExContainer::GetIconIndexL() 00245 { 00246 // construct with default data 00247 CDirectoryLocalizer* localizer = CDirectoryLocalizer::NewL(); 00248 CleanupStack::PushL(localizer); // localizer 00249 00250 localizer->AddFromResourceL( R_EXAMPLE_LOCALIZER_ENTRIES ); 00251 localizer->SetFullPath( KDLTestExistsDir ); 00252 TBool success = localizer->IsLocalized(); 00253 00254 CAknInformationNote *note = new ( ELeave ) CAknInformationNote(); 00255 if( success ) 00256 { 00257 TInt iconIndex = localizer->Icon(); 00258 TBuf<KMaxString> strIndex; 00259 strIndex.AppendNum( iconIndex ); 00260 note->ExecuteLD( strIndex ); 00261 } 00262 else 00263 { 00264 note->ExecuteLD( strNote ); 00265 } 00266 00267 CleanupStack::PopAndDestroy(); // localizer 00268 }
|
© Nokia 2009 |