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

Generated by  doxygen 1.6.2