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

Generated by  doxygen 1.6.2