|
Nokia N97 SDK Example Applications Guide |
00001 /* 00002 * ============================================================================== 00003 * Name : OpenCHelloGlibEventExView.cpp 00004 * Part of : Open C Hello World with Glib Events Example 00005 * Interface : 00006 * Description : 00007 * Version : 00008 * 00009 * Copyright (c) 2007 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 <coemain.h> 00018 #include "OpenCHelloGlibEventExView.h" 00019 #include <eikenv.h> 00020 // ============================ MEMBER FUNCTIONS =============================== 00021 00022 // ----------------------------------------------------------------------------- 00023 // COpenCHelloGlibEventExView::NewL() 00024 // Two-phased constructor. 00025 // ----------------------------------------------------------------------------- 00026 // 00027 COpenCHelloGlibEventExView* COpenCHelloGlibEventExView::NewL( const TRect& aRect ) 00028 { 00029 COpenCHelloGlibEventExView* self = COpenCHelloGlibEventExView::NewLC( aRect ); 00030 CleanupStack::Pop( self ); 00031 return self; 00032 } 00033 00034 // ----------------------------------------------------------------------------- 00035 // COpenCHelloGlibEventExView::NewLC() 00036 // Two-phased constructor. 00037 // ----------------------------------------------------------------------------- 00038 // 00039 COpenCHelloGlibEventExView* COpenCHelloGlibEventExView::NewLC( const TRect& aRect ) 00040 { 00041 COpenCHelloGlibEventExView* self = new ( ELeave ) COpenCHelloGlibEventExView; 00042 CleanupStack::PushL( self ); 00043 self->ConstructL( aRect ); 00044 return self; 00045 } 00046 00047 // ----------------------------------------------------------------------------- 00048 // COpenCHelloGlibEventExView::ConstructL() 00049 // Symbian 2nd phase constructor can leave. 00050 // ----------------------------------------------------------------------------- 00051 // 00052 void COpenCHelloGlibEventExView::ConstructL( const TRect& aRect ) 00053 { 00054 // Create a window for this application view 00055 CreateWindowL(); 00056 00057 // Set the windows size 00058 SetRect( aRect ); 00059 00060 // Activate the window, which makes it ready to be drawn 00061 ActivateL(); 00062 } 00063 00064 // ----------------------------------------------------------------------------- 00065 // COpenCHelloGlibEventExView::COpenCHelloGlibEventExView() 00066 // C++ default constructor can NOT contain any code, that might leave. 00067 // ----------------------------------------------------------------------------- 00068 // 00069 COpenCHelloGlibEventExView::COpenCHelloGlibEventExView() 00070 { 00071 // No implementation required 00072 } 00073 00074 00075 // ----------------------------------------------------------------------------- 00076 // CHelloWorldBasicAppView::~CHelloWorldBasicAppView() 00077 // Destructor. 00078 // ----------------------------------------------------------------------------- 00079 // 00080 COpenCHelloGlibEventExView::~COpenCHelloGlibEventExView() 00081 { 00082 // No implementation required 00083 } 00084 00085 00086 // ----------------------------------------------------------------------------- 00087 // CHelloWorldBasicAppView::Draw() 00088 // Draws the display. 00089 // ----------------------------------------------------------------------------- 00090 // 00091 void COpenCHelloGlibEventExView::Draw( const TRect& /*aRect*/ ) const 00092 { 00093 // Get the standard graphics context 00094 CWindowGc& gc = SystemGc(); 00095 00096 // Gets the control's extent 00097 TRect drawRect( Rect()); 00098 00099 // Clears the screen 00100 gc.Clear( drawRect ); 00101 00102 gc.UseFont(CEikonEnv::Static()->NormalFont()); 00103 gc.DrawText(iText, TPoint(2, drawRect.Height()/2 + CEikonEnv::Static()->NormalFont()->HeightInPixels()/2)); 00104 gc.DiscardFont(); 00105 00106 } 00107 00108 // ----------------------------------------------------------------------------- 00109 // COpenCHelloGlibEventExView::SizeChanged() 00110 // Called by framework when the view size is changed. 00111 // ----------------------------------------------------------------------------- 00112 // 00113 void COpenCHelloGlibEventExView::SizeChanged() 00114 { 00115 DrawNow(); 00116 } 00117 00118 // ----------------------------------------------------------------------------- 00119 // COpenCHelloGlibEventExView::SetText() 00120 // API to set the text to be displayed by the View 00121 // ----------------------------------------------------------------------------- 00122 // 00123 void COpenCHelloGlibEventExView::SetText(TDesC& aText) 00124 { 00125 iText.Copy(aText); 00126 } 00127 00128 // End of File
|
© Nokia 2009 |