|
1 // Copyright (c) 2001-2009 Nokia Corporation and/or its subsidiary(-ies). |
|
2 // All rights reserved. |
|
3 // This component and the accompanying materials are made available |
|
4 // under the terms of "Eclipse Public License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // MsgUrlHandlerAppView.cpp |
|
15 // This file contains the implementation for the class defined in |
|
16 // TestMsgUrlHandlerApp.h |
|
17 // |
|
18 // |
|
19 |
|
20 /** |
|
21 @file |
|
22 @see TestMsgUrlHandlerApp.h |
|
23 */ |
|
24 |
|
25 #include "TestMsgUrlHandlerApp.H" |
|
26 |
|
27 // |
|
28 // Constructor for the view. |
|
29 // |
|
30 CTestMsgUrlHandlerAppView::CTestMsgUrlHandlerAppView() |
|
31 { |
|
32 } |
|
33 |
|
34 |
|
35 // Static NewL() function to start the standard two |
|
36 // phase construction. |
|
37 // |
|
38 CTestMsgUrlHandlerAppView* CTestMsgUrlHandlerAppView::NewL(const TRect& aRect) |
|
39 { |
|
40 CTestMsgUrlHandlerAppView* self = new(ELeave) CTestMsgUrlHandlerAppView(); |
|
41 CleanupStack::PushL(self); |
|
42 self->ConstructL(aRect); |
|
43 CleanupStack::Pop(); |
|
44 return self; |
|
45 } |
|
46 |
|
47 |
|
48 // |
|
49 // Destructor for the view. |
|
50 // |
|
51 CTestMsgUrlHandlerAppView::~CTestMsgUrlHandlerAppView() |
|
52 { |
|
53 delete iText; |
|
54 } |
|
55 |
|
56 |
|
57 // Second phase construction. |
|
58 // |
|
59 void CTestMsgUrlHandlerAppView::ConstructL(const TRect& aRect) |
|
60 { |
|
61 // Fetch the text from the resource file. |
|
62 iText = iEikonEnv->AllocReadResourceL(R_TEXT); |
|
63 // Control is a window owning control |
|
64 CreateWindowL(); |
|
65 // Extent of the control. This is |
|
66 // the whole rectangle available to application. |
|
67 // The rectangle is passed to us from the application UI. |
|
68 SetRect(aRect); |
|
69 // At this stage, the control is ready to draw so |
|
70 // we tell the UI framework by activating it. |
|
71 ActivateL(); |
|
72 } |
|
73 |
|
74 |
|
75 // Drawing the view - in this application, |
|
76 // consists of drawing a simple outline rectangle |
|
77 // and then drawing the text in the middle. |
|
78 // We use the Normal font supplied by the UI. |
|
79 |
|
80 void CTestMsgUrlHandlerAppView::Draw(const TRect& /*aRect*/) const |
|
81 { |
|
82 // Window graphics context |
|
83 CWindowGc& gc = SystemGc(); |
|
84 // Area in which we shall draw |
|
85 TRect drawRect = Rect(); |
|
86 // Font used for drawing text |
|
87 const CFont* fontUsed; |
|
88 |
|
89 // Start with a clear screen |
|
90 gc.Clear(); |
|
91 // Draw an outline rectangle (the default pen |
|
92 // and brush styles ensure this) slightly |
|
93 // smaller than the drawing area. |
|
94 drawRect.Shrink(10,10); |
|
95 gc.DrawRect(drawRect); |
|
96 // Use the title font supplied by the UI |
|
97 fontUsed = iEikonEnv->TitleFont(); |
|
98 gc.UseFont(fontUsed); |
|
99 // Draw the text in the middle of the rectangle. |
|
100 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
101 gc.DrawText(*iText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
102 // Finished using the font |
|
103 gc.DiscardFont(); |
|
104 } |
|
105 |
|
106 |
|
107 |