examples/S60CppExamples/helloworldbasic/src/helloworldbasicappview.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : helloworldbasicappview.cpp
00004 *  Part of     : Helloworldbasic
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 FILES
00017 #include <coemain.h>
00018 #include <aknutils.h>
00019 #include "HelloWorldBasicAppView.h"
00020 
00021 // ============================ MEMBER FUNCTIONS ===============================
00022 
00023 // -----------------------------------------------------------------------------
00024 // CHelloWorldBasicAppView::NewL()
00025 // Two-phased constructor.
00026 // -----------------------------------------------------------------------------
00027 //
00028 CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewL( const TRect& aRect )
00029     {
00030     CHelloWorldBasicAppView* self = CHelloWorldBasicAppView::NewLC( aRect );
00031     CleanupStack::Pop( self );
00032     return self;
00033     }
00034 
00035 // -----------------------------------------------------------------------------
00036 // CHelloWorldBasicAppView::NewLC()
00037 // Two-phased constructor.
00038 // -----------------------------------------------------------------------------
00039 //
00040 CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewLC( const TRect& aRect )
00041     {
00042     CHelloWorldBasicAppView* self = new ( ELeave ) CHelloWorldBasicAppView;
00043     CleanupStack::PushL( self );
00044     self->ConstructL( aRect );
00045     return self;
00046     }
00047 
00048 // -----------------------------------------------------------------------------
00049 // CHelloWorldBasicAppView::ConstructL()
00050 // Symbian 2nd phase constructor can leave.
00051 // -----------------------------------------------------------------------------
00052 //
00053 void CHelloWorldBasicAppView::ConstructL( const TRect& aRect )
00054     {
00055     // Create a window for this application view
00056     CreateWindowL();
00057 
00058     // set the font
00059     iFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont);
00060 
00061     iText.Zero();
00062 
00063     // Set the windows size
00064     SetRect( aRect );
00065 
00066     // Activate the window, which makes it ready to be drawn
00067     ActivateL();
00068     }
00069 
00070 // -----------------------------------------------------------------------------
00071 // CHelloWorldBasicAppView::CHelloWorldBasicAppView()
00072 // C++ default constructor can NOT contain any code, that might leave.
00073 // -----------------------------------------------------------------------------
00074 //
00075 CHelloWorldBasicAppView::CHelloWorldBasicAppView()
00076     {
00077     // No implementation required
00078     }
00079 
00080 
00081 // -----------------------------------------------------------------------------
00082 // CHelloWorldBasicAppView::~CHelloWorldBasicAppView()
00083 // Destructor.
00084 // -----------------------------------------------------------------------------
00085 //
00086 CHelloWorldBasicAppView::~CHelloWorldBasicAppView()
00087     {
00088     // No implementation required
00089     }
00090 
00091 
00092 // -----------------------------------------------------------------------------
00093 // CHelloWorldBasicAppView::Draw()
00094 // Draws the display.
00095 // -----------------------------------------------------------------------------
00096 //
00097 void CHelloWorldBasicAppView::Draw( const TRect& /*aRect*/ ) const
00098     {
00099     // note that the whole screen is drawn everytime, so aRect-parameter
00100     // is ignored
00101 
00102     // Get the standard graphics context
00103     CWindowGc& gc = SystemGc();
00104     gc.SetPenStyle( CGraphicsContext::ENullPen );
00105     gc.SetBrushColor( KRgbWhite);
00106     gc.SetBrushStyle( CGraphicsContext::ESolidBrush );
00107 
00108     // Gets the control's extent
00109     TRect rect( Rect());
00110 
00111     // draw also text, if user has given it via dialog
00112     if (iText.Length() > 0)
00113         {
00114         gc.UseFont(iFont);
00115         gc.DrawText(iText, rect, Rect().Height()/3, CGraphicsContext::ECenter );
00116         gc.DiscardFont();
00117         }
00118     else
00119         {
00120         gc.Clear( rect );
00121         }
00122     }
00123 
00124 // -----------------------------------------------------------------------------
00125 // CHelloWorldBasicAppView::SizeChanged()
00126 // Called by framework when the view size is changed.
00127 // -----------------------------------------------------------------------------
00128 //
00129 void CHelloWorldBasicAppView::SizeChanged()
00130     {
00131     }
00132 
00133 // -----------------------------------------------------------------------------
00134 // CHelloWorldBasicAppView::GetText()
00135 // Called by AppUi to either set the text (via dialog) or zero the contents.
00136 // -----------------------------------------------------------------------------
00137 //
00138 TDes & CHelloWorldBasicAppView::GetText()
00139     {
00140     return iText;
00141     }
00142 
00143 // End of File
00144 

Generated by  doxygen 1.6.2