examples/ForumNokia/Document_Handler_Example/HandlerApp/src/handlerAppview.cpp

00001 /* ====================================================================
00002  * File: handlerAppView.cpp
00003  * Created  : 27/06/06 by Forum Nokia
00004  * Author:
00005  * Copyright (c): , All rights reserved
00006  * ==================================================================== */
00007 
00008 #include <coemain.h>
00009 #include <eikenv.h>
00010 #include <eikappui.h>
00011 #include <eikapp.h>
00012 
00013 #include "handlerAppView.h"
00014 #include "handlerDocument.h"
00015 
00016 const TInt KCharsToShowFromEnd = 10;
00017 
00018 CHandlerAppView* CHandlerAppView::NewL(const TRect& aRect)
00019     {
00020     CHandlerAppView* self = CHandlerAppView::NewLC(aRect);
00021     CleanupStack::Pop(self);
00022     return self;
00023     }
00024 
00025 CHandlerAppView* CHandlerAppView::NewLC(const TRect& aRect)
00026     {
00027     CHandlerAppView* self = new (ELeave) CHandlerAppView;
00028     CleanupStack::PushL(self);
00029     self->ConstructL(aRect);
00030     return self;
00031     }
00032 
00033 CHandlerAppView::CHandlerAppView()
00034     {
00035     // no implementation required
00036     }
00037 
00038 CHandlerAppView::~CHandlerAppView()
00039     {
00040     // no implementation required
00041     }
00042 
00043 void CHandlerAppView::ConstructL(const TRect& aRect)
00044     {
00045     // Create a window for this application view
00046     CreateWindowL();
00047 
00048     // Set the windows size
00049     SetRect(aRect);
00050 
00051     // Activate the window, which makes it ready to be drawn
00052     ActivateL();
00053     }
00054 
00055 // Draw this application's view to the screen
00056 void CHandlerAppView::Draw(const TRect& /*aRect*/) const
00057     {
00058     // Get the standard graphics context
00059     CWindowGc& gc = SystemGc();
00060 
00061     // Gets the control's extent
00062     TRect rect = Rect();
00063 
00064     // Clears the screen
00065     gc.Clear(rect);
00066 
00067     const CFont* normalFont = CEikonEnv::Static()->NormalFont();
00068     gc.UseFont( normalFont );
00069 
00070     //get some characters from file path end and show them.
00071     TBuf<KCharsToShowFromEnd> endText = KNullDesC();
00072     endText.Zero();
00073     if( iName.Length() > KCharsToShowFromEnd-2 )
00074         {
00075         endText = iName.Right(KCharsToShowFromEnd-1);
00076         }
00077 
00078     const TPoint KPoint1 = TPoint(1,41);
00079     const TPoint KPoint2 = TPoint(1,21);
00080     const TPoint KPoint3 = TPoint(1,61);
00081 
00082     gc.DrawText(iName, KPoint1 );
00083     gc.DrawText(endText, KPoint2 );
00084     gc.DrawText(iData, KPoint3 );
00085     }
00086 
00087 void CHandlerAppView::SizeChanged()
00088     {
00089     DrawDeferred();
00090     }
00091 
00092 void CHandlerAppView::SetFileData(TFileName& aFileName, TDes8& aData)
00093     {
00094     iName = aFileName;
00095     iData.Copy( aData );
00096     DrawDeferred();
00097     }

Generated by  doxygen 1.6.2