diff -r f345bda72bc4 -r 43e37759235e Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/cssyncappview_8cpp_source.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Symbian3/Examples/guid-6013a680-57f9-415b-8851-c4fa63356636/cssyncappview_8cpp_source.html Tue Mar 30 16:16:55 2010 +0100 @@ -0,0 +1,142 @@ + + +
+ +00001 /* +00002 * ============================================================================== +00003 * Name : cssyncappview.cpp +00004 * Part of : CSSync +00005 * Interface : +00006 * Description : +00007 * Version : +00008 * +00009 * Copyright (c) 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 +00021 #include <avkon.rsg> +00022 #include "CSSyncAppView.h" +00023 #include "CSSyncDocument.h" +00024 +00025 // ========================= MEMBER FUNCTIONS ================================== +00026 +00027 // ----------------------------------------------------------------------------- +00028 // CCSSyncAppView::NewL() +00029 // Two-phased constructor. +00030 // ----------------------------------------------------------------------------- +00031 // +00032 CCSSyncAppView* CCSSyncAppView::NewL( const TRect& aRect, +00033 CCSSyncDocument& aDocument ) +00034 { +00035 CCSSyncAppView* self = CCSSyncAppView::NewLC( aRect, aDocument ); +00036 CleanupStack::Pop( self ); +00037 return self; +00038 } +00039 +00040 // ----------------------------------------------------------------------------- +00041 // CCSSyncAppView::NewLC() +00042 // Two-phased constructor. +00043 // ----------------------------------------------------------------------------- +00044 // +00045 CCSSyncAppView* CCSSyncAppView::NewLC( const TRect& aRect, +00046 CCSSyncDocument& aDocument ) +00047 { +00048 CCSSyncAppView* self = new ( ELeave ) CCSSyncAppView( aDocument ); +00049 CleanupStack::PushL( self ); +00050 self->ConstructL( aRect ); +00051 return self; +00052 } +00053 +00054 // ----------------------------------------------------------------------------- +00055 // CCSSyncAppView::ConstructL() +00056 // Symbian 2nd phase constructor can leave. +00057 // ----------------------------------------------------------------------------- +00058 // +00059 void CCSSyncAppView::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 // CCSSyncAppView::CCSSyncAppView() +00073 // C++ default constructor can NOT contain any code, that might leave. +00074 // ----------------------------------------------------------------------------- +00075 // +00076 CCSSyncAppView::CCSSyncAppView( CCSSyncDocument& aDocument ) +00077 : iDocument( aDocument ) +00078 { +00079 // No implementation required +00080 } +00081 +00082 // ----------------------------------------------------------------------------- +00083 // CCSSyncAppView::~CCSSyncAppView() +00084 // Destructor. +00085 // ----------------------------------------------------------------------------- +00086 // +00087 CCSSyncAppView::~CCSSyncAppView() +00088 { +00089 // No implementation required +00090 } +00091 +00092 // ----------------------------------------------------------------------------- +00093 // CCSSyncAppView::Draw() +00094 // Draws this CCSSyncAppView to the screen. +00095 // ----------------------------------------------------------------------------- +00096 // +00097 void CCSSyncAppView::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 +