|
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 // This file contains the implementation for the class defined in |
|
15 // MsgUrlHandlerApp.h |
|
16 // |
|
17 // |
|
18 |
|
19 /** |
|
20 @file |
|
21 @see MsgUrlHandlerApp.h |
|
22 */ |
|
23 |
|
24 #include "MsgUrlHandlerApp.h" |
|
25 |
|
26 |
|
27 const TInt KSize = 10; |
|
28 |
|
29 // |
|
30 // Constructor for the view. |
|
31 // |
|
32 CMsgUrlHandlerAppView::CMsgUrlHandlerAppView() |
|
33 { |
|
34 } |
|
35 |
|
36 |
|
37 // Static NewL() function to start the standard two |
|
38 // phase construction. |
|
39 // |
|
40 CMsgUrlHandlerAppView* CMsgUrlHandlerAppView::NewL(const TRect& aRect) |
|
41 { |
|
42 CMsgUrlHandlerAppView* self = new(ELeave) CMsgUrlHandlerAppView(); |
|
43 CleanupStack::PushL(self); |
|
44 self->ConstructL(aRect); |
|
45 CleanupStack::Pop(self); |
|
46 return self; |
|
47 } |
|
48 |
|
49 |
|
50 // |
|
51 // Destructor for the view. |
|
52 // |
|
53 CMsgUrlHandlerAppView::~CMsgUrlHandlerAppView() |
|
54 { |
|
55 delete iText; |
|
56 } |
|
57 |
|
58 |
|
59 // Second phase construction. |
|
60 // |
|
61 void CMsgUrlHandlerAppView::ConstructL(const TRect& aRect) |
|
62 { |
|
63 // Fetch the text from the resource file. |
|
64 iText = iEikonEnv->AllocReadResourceL(R_MYAPP_TEXT); |
|
65 // Control is a window owning control |
|
66 CreateWindowL(); |
|
67 // Extent of the control. This is |
|
68 // the whole rectangle available to application. |
|
69 // The rectangle is passed to us from the application UI. |
|
70 SetRect(aRect); |
|
71 // At this stage, the control is ready to draw so |
|
72 // we tell the UI framework by activating it. |
|
73 ActivateL(); |
|
74 } |
|
75 |
|
76 |
|
77 // Drawing the view - in this application, |
|
78 // consists of drawing a simple outline rectangle |
|
79 // and then drawing the text in the middle. |
|
80 // We use the Normal font supplied by the UI. |
|
81 |
|
82 void CMsgUrlHandlerAppView::Draw(const TRect& /*aRect*/) const |
|
83 { |
|
84 // Window graphics context |
|
85 CWindowGc& gc = SystemGc(); |
|
86 // Area in which we shall draw |
|
87 TRect drawRect = Rect(); |
|
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(KSize,KSize); |
|
95 gc.DrawRect(drawRect); |
|
96 |
|
97 // Font used for drawing text |
|
98 const CFont* fontUsed; |
|
99 // Use the title font supplied by the UI |
|
100 fontUsed = iEikonEnv->TitleFont(); |
|
101 gc.UseFont(fontUsed); |
|
102 // Draw the text in the middle of the rectangle. |
|
103 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
104 gc.DrawText(*iText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
105 // Finished using the font |
|
106 gc.DiscardFont(); |
|
107 } |
|
108 |
|
109 |
|
110 |