|
Nokia N97 SDK Example Applications Guide |
00001 /* Copyright (c) 2005-2006 Nokia Corporation. 00002 * This material, including documentation and any related 00003 * computer programs, is protected by copyright controlled by 00004 * Nokia Corporation. 00005 */ 00006 00007 00008 // INCLUDE FILES 00009 #include <coemain.h> 00010 #include <eiklabel.h> 00011 #include <stringloader.h> 00012 #include <cshelp/aiwe.hlp.hrh> 00013 #include <AIWConsumerBasics.rsg> 00014 #include "AIWConsumerBasicsAppView.h" 00015 #include "AIWConsumerBasicsAppUi.h" 00016 00017 const TInt KLeftMargin = 5; 00018 const TInt KTopMargin = 30; 00019 const TInt KSpaceBetweenRows = 30; 00020 00021 // ============================ MEMBER FUNCTIONS =============================== 00022 00023 // ----------------------------------------------------------------------------- 00024 // CAIWConsumerBasicsAppView::NewL() 00025 // Two-phased constructor. 00026 // ----------------------------------------------------------------------------- 00027 // 00028 CAIWConsumerBasicsAppView* CAIWConsumerBasicsAppView::NewL( const TRect& aRect, 00029 CAIWConsumerBasicsAppUi& aAppUi ) 00030 { 00031 CAIWConsumerBasicsAppView* self = CAIWConsumerBasicsAppView::NewLC( aRect, aAppUi ); 00032 CleanupStack::Pop( self ); 00033 return self; 00034 } 00035 00036 // ----------------------------------------------------------------------------- 00037 // CAIWConsumerBasicsAppView::NewLC() 00038 // Two-phased constructor. 00039 // ----------------------------------------------------------------------------- 00040 // 00041 CAIWConsumerBasicsAppView* CAIWConsumerBasicsAppView::NewLC( const TRect& aRect, 00042 CAIWConsumerBasicsAppUi& aAppUi ) 00043 { 00044 CAIWConsumerBasicsAppView* self = new ( ELeave ) CAIWConsumerBasicsAppView( aAppUi ); 00045 CleanupStack::PushL( self ); 00046 self->ConstructL( aRect ); 00047 return self; 00048 } 00049 00050 // ----------------------------------------------------------------------------- 00051 // CAIWConsumerBasicsAppView::ConstructL() 00052 // Symbian 2nd phase constructor can leave. 00053 // ----------------------------------------------------------------------------- 00054 // 00055 void CAIWConsumerBasicsAppView::ConstructL( const TRect& aRect ) 00056 { 00057 iCoeEnv = CCoeEnv::Static(); 00058 00059 // Create a window for this application view 00060 CreateWindowL(); 00061 00062 // Set the windows size 00063 SetRect( aRect ); 00064 00065 iAttachedText = iCoeEnv->AllocReadResourceL( R_AIWE_ATTACHED ); 00066 iDetachedText = iCoeEnv->AllocReadResourceL( R_AIWE_DETACHED ); 00067 iMakeAttachText = iCoeEnv->AllocReadResourceL( R_AIWE_MAKE_ATTACH ); 00068 iMakeDetachText = iCoeEnv->AllocReadResourceL( R_AIWE_MAKE_DETACH ); 00069 00070 00071 // Activate the window, which makes it ready to be drawn 00072 ActivateL(); 00073 } 00074 00075 // ----------------------------------------------------------------------------- 00076 // CAIWConsumerBasicsAppView::CAIWConsumerBasicsAppView() 00077 // C++ default constructor can NOT contain any code, that might leave. 00078 // ----------------------------------------------------------------------------- 00079 // 00080 CAIWConsumerBasicsAppView::CAIWConsumerBasicsAppView( CAIWConsumerBasicsAppUi& aAppUi ) 00081 : iAppUi(aAppUi) 00082 { 00083 // No implementation required 00084 } 00085 00086 00087 // ----------------------------------------------------------------------------- 00088 // CAIWConsumerBasicsAppView::~CAIWConsumerBasicsAppView() 00089 // Destructor. 00090 // ----------------------------------------------------------------------------- 00091 // 00092 CAIWConsumerBasicsAppView::~CAIWConsumerBasicsAppView() 00093 { 00094 delete iAttachedText; 00095 delete iDetachedText; 00096 delete iMakeAttachText; 00097 delete iMakeDetachText; 00098 } 00099 00100 00101 // ----------------------------------------------------------------------------- 00102 // CAIWConsumerBasicsAppView::Draw() 00103 // Draws the display. 00104 // ----------------------------------------------------------------------------- 00105 // 00106 void CAIWConsumerBasicsAppView::Draw( const TRect& /*aRect*/ ) const 00107 { 00108 // Get the standard graphics context 00109 CWindowGc& gc = SystemGc(); 00110 00111 // Gets the control's extent 00112 TRect drawRect( Rect()); 00113 00114 // Clears the screen 00115 gc.Clear( drawRect ); 00116 00117 gc.SetBrushColor( TRgb(0,0,0) ); 00118 gc.UseFont( iCoeEnv->NormalFont() ); 00119 00120 // Write help texts to the screen. 00121 HBufC* providersTxt = StringLoader::LoadLC( R_AIWE_NBR_OF_PROVIDERS, iAppUi.NumberOfProviders() ); 00122 if(iAppUi.IsAttached()) 00123 { 00124 gc.DrawText( *iAttachedText, TPoint(KLeftMargin, KTopMargin + 0*KSpaceBetweenRows) ); 00125 gc.DrawText( *providersTxt, TPoint(KLeftMargin, KTopMargin + 1*KSpaceBetweenRows) ); 00126 gc.DrawText( *iMakeDetachText, TPoint(KLeftMargin, KTopMargin + 3*KSpaceBetweenRows) ); 00127 } 00128 else 00129 { 00130 gc.DrawText( *iDetachedText, TPoint(KLeftMargin, KTopMargin + 0*KSpaceBetweenRows) ); 00131 gc.DrawText( *providersTxt, TPoint(KLeftMargin, KTopMargin + 1*KSpaceBetweenRows) ); 00132 gc.DrawText( *iMakeAttachText, TPoint(KLeftMargin, KTopMargin + 3*KSpaceBetweenRows) ); 00133 } 00134 CleanupStack::PopAndDestroy( providersTxt ); 00135 } 00136 00137 // ----------------------------------------------------------------------------- 00138 // CAIWConsumerBasicsAppView::SizeChanged() 00139 // Called by framework when the view size is changed. 00140 // ----------------------------------------------------------------------------- 00141 // 00142 void CAIWConsumerBasicsAppView::SizeChanged() 00143 { 00144 DrawNow(); 00145 } 00146 00147 // ----------------------------------------------------------------------------- 00148 // CAIWConsumerBasicsAppView::GetHelpContext() 00149 // 00150 // ----------------------------------------------------------------------------- 00151 // 00152 void CAIWConsumerBasicsAppView::GetHelpContext(TCoeHelpContext& aContext) const 00153 { 00154 aContext.iMajor = TUid::Uid(0x10282909); 00155 aContext.iContext = KAIWE_HLP_OVERVIEW; 00156 } 00157 00158 // End of File
|
© Nokia 2009 |