examples/S60CppExamples/ClientServerAsync/client/src/csasyncappview.cpp

00001 /*
00002 * ==============================================================================
00003 *  Name        : csasyncappview.cpp
00004 *  Part of     : CSAsync
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 
00017 // INCLUDE FILES
00018 #include <coemain.h>
00019 #include <eikenv.h>
00020 #include <avkon.rsg>
00021 
00022 #include "CSAsyncAppView.h"
00023 #include "CSAsyncDocument.h"
00024 
00025 // ========================= MEMBER FUNCTIONS ==================================
00026 
00027 // -----------------------------------------------------------------------------
00028 // CCSAsyncAppView::NewL()
00029 // Two-phased constructor.
00030 // -----------------------------------------------------------------------------
00031 //
00032 CCSAsyncAppView* CCSAsyncAppView::NewL( const TRect& aRect,
00033                                         CCSAsyncDocument& aDocument )
00034     {
00035     CCSAsyncAppView* self = CCSAsyncAppView::NewLC( aRect, aDocument );
00036     CleanupStack::Pop( self );
00037     return self;
00038     }
00039 
00040 // -----------------------------------------------------------------------------
00041 // CCSAsyncAppView::NewLC()
00042 // Two-phased constructor.
00043 // -----------------------------------------------------------------------------
00044 //
00045 CCSAsyncAppView* CCSAsyncAppView::NewLC( const TRect& aRect,
00046                                          CCSAsyncDocument& aDocument )
00047     {
00048     CCSAsyncAppView* self = new ( ELeave ) CCSAsyncAppView( aDocument );
00049     CleanupStack::PushL( self );
00050     self->ConstructL( aRect );
00051     return self;
00052     }
00053 
00054 // -----------------------------------------------------------------------------
00055 // CCSAsyncAppView::ConstructL()
00056 // Symbian 2nd phase constructor can leave.
00057 // -----------------------------------------------------------------------------
00058 //
00059 void CCSAsyncAppView::ConstructL( const TRect& aRect )
00060     {
00061     // Create a window for this application view
00062     CreateWindowL();
00063 
00064     // Set the windows size
00065     SetRect( aRect );
00066 
00067     // Activate the window, which makes it ready to be drawn
00068     ActivateL();
00069     }
00070 
00071 // -----------------------------------------------------------------------------
00072 // CCSAsyncAppView::CCSAsyncAppView()
00073 // C++ default constructor can NOT contain any code, that might leave.
00074 // -----------------------------------------------------------------------------
00075 //
00076 CCSAsyncAppView::CCSAsyncAppView( CCSAsyncDocument& aDocument )
00077 : iDocument( aDocument )
00078     {
00079     // No implementation required
00080     }
00081 
00082 // -----------------------------------------------------------------------------
00083 // CCSAsyncAppView::~CCSAsyncAppView()
00084 // Destructor.
00085 // -----------------------------------------------------------------------------
00086 //
00087 CCSAsyncAppView::~CCSAsyncAppView()
00088     {
00089     // No implementation required
00090     }
00091 
00092 // -----------------------------------------------------------------------------
00093 // CCSAsyncAppView::Draw()
00094 // Draws this CCSAsyncAppView to the screen.
00095 // -----------------------------------------------------------------------------
00096 //
00097 void CCSAsyncAppView::Draw( const TRect& /*aRect*/ ) const
00098     {
00099 
00100     // Clear the screen
00101     CWindowGc& gc = SystemGc();
00102     gc.Clear( Rect() );
00103 
00104     TBuf<30> des;
00105     const TTime& time = iDocument.Time();
00106 
00107     // Read time format string from AVKON resource
00108     HBufC* timeFormatString = iEikonEnv->AllocReadResourceLC(R_QTN_TIME_LONG);
00109     // It would also be possible to define your own format string instead, 
00110     // for example like this:
00111     // _LIT( KHoursMinsSecs, "%-B%:0%J%:1%T%:2%S%:3%+B" );
00112 
00113     TRAPD( err, time.FormatL( des, *timeFormatString ) );
00114     CleanupStack::PopAndDestroy(); // timeFormatString
00115 
00116     if ( err == KErrNone )
00117         {
00118         const CFont* font = iEikonEnv->NormalFont();
00119         gc.UseFont( font );
00120         gc.DrawText( des, TPoint( 10,20 ) );
00121         }
00122     }
00123 
00124 
00125 // End of File
00126 

Generated by  doxygen 1.6.2