|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : aknexpopfieldcontainer.cpp 00004 * Part of : Popup-field example 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2004 - 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 <aknutils.h> // for AKN_LAF_COLOR 00018 #include <eikappui.h> 00019 #include <eikenv.h> 00020 #include <eiklabel.h> // for label 00021 #include <aknform.h> // for form control 00022 #include <aknexpopfield.rsg> 00023 00024 #include "AknExPopField.hrh" 00025 #include "AknExPopFieldView.h" 00026 #include "AknExPopFieldContainer.h" 00027 #include "AknExPopFieldTextValueDialog.h" 00028 #include "AknExPopFieldOptionalListDialog.h" 00029 #include "AknExPopFieldManyLineDialog.h" 00030 #include "AknExPopFieldMultiPageDialog.h" 00031 #include "AknExPopFieldAttribSetDialog.h" 00032 00033 00034 00035 // MACROS 00036 /** 00037 * Define background color with AKN_LAF_COLOR macro: 00038 * DO NOT CALL it in SizeChanged(), ConstructL() or ActivateL() method, 00039 * because it messes up color scheme changes. Especially if you're using 00040 * colors 226-248. If you store color values, be prepared to update 00041 * TRgb's you store when color palette is changed! Best thing to do 00042 * is to make your Draw() methods call AKN_LAF_COLOR(). 00043 */ 00044 #define AKNEXPOPFIELD_BACKGROUND_COLOR AKN_LAF_COLOR( 219 ) 00045 00046 00047 // ================= MEMBER FUNCTIONS ========================================= 00048 00049 // ---------------------------------------------------------------------------- 00050 // CAknExPopFieldContainer::CAknExPopFieldContainer() 00051 // C++ default constructor can NOT contain any code, that might leave. 00052 // ---------------------------------------------------------------------------- 00053 // 00054 CAknExPopFieldContainer::CAknExPopFieldContainer( CAknExPopFieldView* aView ) 00055 : iView( aView ), iLabel( NULL ) 00056 { 00057 // No implementation required 00058 } 00059 00060 // ---------------------------------------------------------------------------- 00061 // CAknExPopFieldContainer::ConstructL() 00062 // Symbian 2nd phase constructor can leave. 00063 // ---------------------------------------------------------------------------- 00064 // 00065 void CAknExPopFieldContainer::ConstructL( const TRect& aRect ) 00066 { 00067 // Creates window. 00068 CreateWindowL(); 00069 00070 // Creates label object. 00071 CreateLabelL(); 00072 00073 SetRect( aRect ); // Sets rectangle of frame. 00074 ActivateL(); // Activates the window. (Ready to draw) 00075 } 00076 00077 // ---------------------------------------------------------------------------- 00078 // CAknExPopFieldContainer::~CAknExPopFieldContainer() 00079 // Destructor. 00080 // ---------------------------------------------------------------------------- 00081 // 00082 CAknExPopFieldContainer::~CAknExPopFieldContainer() 00083 { 00084 delete iLabel; 00085 } 00086 00087 // ---------------------------------------------------------------------------- 00088 // void CAknExPopFieldContainer::SetTextToLabelL() 00089 // 00090 // ---------------------------------------------------------------------------- 00091 // 00092 void CAknExPopFieldContainer::SetTextToLabelL( TInt aResourceId ) 00093 { 00094 TBuf<KAknExPopFieldMessageBufLength> messageString; 00095 iCoeEnv->ReadResource( messageString , aResourceId ); 00096 iLabel->SetTextL( messageString ); 00097 } 00098 00099 // ---------------------------------------------------------------------------- 00100 // CAknExPopFieldContainer::DisplayTextPopFieldL() 00101 // Display Text PopField 00102 // ---------------------------------------------------------------------------- 00103 // 00104 void CAknExPopFieldContainer::DisplayTextPopFieldL( TInt aResourceId ) 00105 { 00106 CAknExPopFieldTextValueDialog* dlg = 00107 CAknExPopFieldTextValueDialog::NewLC(); 00108 CleanupStack::Pop(); 00109 dlg->ExecuteLD( aResourceId ); 00110 } 00111 00112 // ---------------------------------------------------------------------------- 00113 // CAknExPopFieldContainer::DisplayOptionalTextPopFieldL() 00114 // Display Optional TextPopField 00115 // ---------------------------------------------------------------------------- 00116 // 00117 void CAknExPopFieldContainer::DisplayOptionalTextPopFieldL( TInt aResourceId ) 00118 { 00119 CAknExPopFieldOptionalListDialog* dlg = 00120 CAknExPopFieldOptionalListDialog::NewLC(); 00121 CleanupStack::Pop(); 00122 dlg->ExecuteLD( aResourceId ); 00123 } 00124 00125 // ---------------------------------------------------------------------------- 00126 // CAknExPopFieldContainer::DisplayManyLineTextPopFieldL() 00127 // Display ManyLine Text PopField 00128 // ---------------------------------------------------------------------------- 00129 // 00130 void CAknExPopFieldContainer::DisplayManyLineTextPopFieldL( TInt aResourceId ) 00131 { 00132 CAknExPopFieldManyLineDialog* dlg = 00133 CAknExPopFieldManyLineDialog::NewLC(); 00134 CleanupStack::Pop(); 00135 dlg->ExecuteLD( aResourceId ); 00136 } 00137 00138 // ---------------------------------------------------------------------------- 00139 // CAknExPopFieldContainer::DisplayMultiPagePopFieldL( ) 00140 // Display MultiPage PopField 00141 // ---------------------------------------------------------------------------- 00142 // 00143 void CAknExPopFieldContainer::DisplayMultiPagePopFieldL( TInt aResourceId ) 00144 { 00145 CAknExPopFieldMultiPageDialog* dlg = 00146 CAknExPopFieldMultiPageDialog::NewLC(); 00147 CleanupStack::Pop(); 00148 dlg->ExecuteLD( aResourceId ); 00149 } 00150 00151 // ---------------------------------------------------------------------------- 00152 // CAknExPopFieldContainer::DisplaySetAttribsPopFieldL() 00153 // Display Set Attribs PopField 00154 // ---------------------------------------------------------------------------- 00155 // 00156 void CAknExPopFieldContainer::DisplaySetAttribsPopFieldL( TInt aResourceId ) 00157 { 00158 CAknExPopFieldAttribSetDialog* dlg = 00159 CAknExPopFieldAttribSetDialog::NewLC(); 00160 CleanupStack::Pop(); 00161 dlg->ExecuteLD( aResourceId ); 00162 } 00163 00164 // ---------------------------------------------------------------------------- 00165 // CAknExPopFieldContainer::CreateLabelL() 00166 // Creates label object. 00167 // ---------------------------------------------------------------------------- 00168 // 00169 void CAknExPopFieldContainer::CreateLabelL() 00170 { 00171 if ( !iLabel ) 00172 { 00173 iLabel = new ( ELeave ) CEikLabel; 00174 iLabel->SetContainerWindowL( *this ); 00175 iLabel->SetAlignment( EHCenterVCenter ); 00176 iLabel->SetFont( LatinBold19() ); 00177 } 00178 SetTextToLabelL( R_AKNEXPOPFIELD_TEXT_LABEL_TITLE ); 00179 } 00180 00181 // ---------------------------------------------------------------------------- 00182 // TKeyResponse CAknExPopFieldContainer::OfferKeyEventL() 00183 // Handles the key events. 00184 // ---------------------------------------------------------------------------- 00185 // 00186 TKeyResponse CAknExPopFieldContainer::OfferKeyEventL( 00187 const TKeyEvent& aKeyEvent, TEventCode aType ) 00188 { 00189 if ( aType != EEventKey ) // Is not key event? 00190 { 00191 return EKeyWasNotConsumed; 00192 } 00193 switch ( aKeyEvent.iCode ) // The code of key event is... 00194 { 00195 case EKeySpace: // Space key. 00196 // Requires to display next outline screen. 00197 iView->DisplayNextOutlineL(); 00198 DrawNow(); 00199 break; 00200 default: 00201 return EKeyWasNotConsumed; 00202 } 00203 return EKeyWasConsumed; 00204 } 00205 00206 // ---------------------------------------------------------------------------- 00207 // CAknExPopFieldContainer::SizeChanged() 00208 // Called by framework when the view size is changed 00209 // ---------------------------------------------------------------------------- 00210 // 00211 void CAknExPopFieldContainer::SizeChanged() 00212 { 00213 iLabel->SetRect( Rect() ); 00214 } 00215 00216 // ---------------------------------------------------------------------------- 00217 // CAknExPopFieldContainer::CountComponentControls() 00218 // Returns number of component. 00219 // ---------------------------------------------------------------------------- 00220 // 00221 TInt CAknExPopFieldContainer::CountComponentControls() const 00222 { 00223 // returns nbr of controls inside this container 00224 return KAknExPopFieldCountComponent; 00225 } 00226 00227 // ---------------------------------------------------------------------------- 00228 // CCoeControl* CAknExPopFieldContainer::ComponentControl() 00229 // Returns pointer to particular component. 00230 // ---------------------------------------------------------------------------- 00231 // 00232 CCoeControl* CAknExPopFieldContainer::ComponentControl( TInt aIndex ) const 00233 { 00234 switch ( aIndex ) // Component is... 00235 { 00236 case EAknExPopFieldComponentLabel: // Label object. 00237 return iLabel; 00238 default: // Exception : returns NULL value. 00239 return NULL; 00240 } 00241 } 00242 00243 // ---------------------------------------------------------------------------- 00244 // CAknExPopFieldContainer::Draw() 00245 // Clears the window's rectangle. 00246 // ---------------------------------------------------------------------------- 00247 // 00248 void CAknExPopFieldContainer::Draw( const TRect& aRect ) const 00249 { 00250 CWindowGc& gc = SystemGc(); 00251 gc.SetPenStyle( CGraphicsContext::ENullPen ); 00252 gc.SetBrushColor( AKNEXPOPFIELD_BACKGROUND_COLOR); 00253 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); 00254 gc.DrawRect( aRect ); 00255 } 00256 00257 // End of File
|
© Nokia 2009 |