|
1 /* |
|
2 * Copyright (c) 2009 Nokia Corporation and/or its subsidiary(-ies). |
|
3 * All rights reserved. |
|
4 * This component and the accompanying materials are made available |
|
5 * under the terms of "Eclipse Public License v1.0" |
|
6 * which accompanies this distribution, and is available |
|
7 * at the URL "http://www.eclipse.org/legal/epl-v10.html". |
|
8 * |
|
9 * Initial Contributors: |
|
10 * Nokia Corporation - initial contribution. |
|
11 * |
|
12 * Contributors: |
|
13 * |
|
14 * Description: |
|
15 * |
|
16 */ |
|
17 |
|
18 // INCLUDE FILES |
|
19 #include <coemain.h> |
|
20 #include <aknutils.h> |
|
21 #include "HelloWorldBasicAppView.h" |
|
22 |
|
23 // ============================ MEMBER FUNCTIONS =============================== |
|
24 |
|
25 // ----------------------------------------------------------------------------- |
|
26 // CHelloWorldBasicAppView::NewL() |
|
27 // Two-phased constructor. |
|
28 // ----------------------------------------------------------------------------- |
|
29 // |
|
30 CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewL( const TRect& aRect ) |
|
31 { |
|
32 CHelloWorldBasicAppView* self = CHelloWorldBasicAppView::NewLC( aRect ); |
|
33 CleanupStack::Pop( self ); |
|
34 return self; |
|
35 } |
|
36 |
|
37 // ----------------------------------------------------------------------------- |
|
38 // CHelloWorldBasicAppView::NewLC() |
|
39 // Two-phased constructor. |
|
40 // ----------------------------------------------------------------------------- |
|
41 // |
|
42 CHelloWorldBasicAppView* CHelloWorldBasicAppView::NewLC( const TRect& aRect ) |
|
43 { |
|
44 CHelloWorldBasicAppView* self = new ( ELeave ) CHelloWorldBasicAppView; |
|
45 CleanupStack::PushL( self ); |
|
46 self->ConstructL( aRect ); |
|
47 return self; |
|
48 } |
|
49 |
|
50 // ----------------------------------------------------------------------------- |
|
51 // CHelloWorldBasicAppView::ConstructL() |
|
52 // Symbian 2nd phase constructor can leave. |
|
53 // ----------------------------------------------------------------------------- |
|
54 // |
|
55 void CHelloWorldBasicAppView::ConstructL( const TRect& aRect ) |
|
56 { |
|
57 // Create a window for this application view |
|
58 CreateWindowL(); |
|
59 |
|
60 // set the font |
|
61 iFont = AknLayoutUtils::FontFromId(EAknLogicalFontPrimaryFont); |
|
62 |
|
63 iText.Zero(); |
|
64 |
|
65 // Set the windows size |
|
66 SetRect( aRect ); |
|
67 |
|
68 // Activate the window, which makes it ready to be drawn |
|
69 ActivateL(); |
|
70 } |
|
71 |
|
72 // ----------------------------------------------------------------------------- |
|
73 // CHelloWorldBasicAppView::CHelloWorldBasicAppView() |
|
74 // C++ default constructor can NOT contain any code, that might leave. |
|
75 // ----------------------------------------------------------------------------- |
|
76 // |
|
77 CHelloWorldBasicAppView::CHelloWorldBasicAppView() |
|
78 { |
|
79 // No implementation required |
|
80 } |
|
81 |
|
82 |
|
83 // ----------------------------------------------------------------------------- |
|
84 // CHelloWorldBasicAppView::~CHelloWorldBasicAppView() |
|
85 // Destructor. |
|
86 // ----------------------------------------------------------------------------- |
|
87 // |
|
88 CHelloWorldBasicAppView::~CHelloWorldBasicAppView() |
|
89 { |
|
90 // No implementation required |
|
91 } |
|
92 |
|
93 |
|
94 // ----------------------------------------------------------------------------- |
|
95 // CHelloWorldBasicAppView::Draw() |
|
96 // Draws the display. |
|
97 // ----------------------------------------------------------------------------- |
|
98 // |
|
99 void CHelloWorldBasicAppView::Draw( const TRect& /*aRect*/ ) const |
|
100 { |
|
101 // note that the whole screen is drawn everytime, so aRect-parameter |
|
102 // is ignored |
|
103 |
|
104 // Get the standard graphics context |
|
105 CWindowGc& gc = SystemGc(); |
|
106 gc.SetPenStyle( CGraphicsContext::ENullPen ); |
|
107 gc.SetBrushColor( KRgbWhite); |
|
108 gc.SetBrushStyle( CGraphicsContext::ESolidBrush ); |
|
109 |
|
110 // Gets the control's extent |
|
111 TRect rect( Rect()); |
|
112 |
|
113 // draw also text, if user has given it via dialog |
|
114 if (iText.Length() > 0) |
|
115 { |
|
116 gc.UseFont(iFont); |
|
117 gc.DrawText(iText, rect, Rect().Height()/3, CGraphicsContext::ECenter ); |
|
118 gc.DiscardFont(); |
|
119 } |
|
120 else |
|
121 { |
|
122 gc.Clear( rect ); |
|
123 } |
|
124 } |
|
125 |
|
126 // ----------------------------------------------------------------------------- |
|
127 // CHelloWorldBasicAppView::SizeChanged() |
|
128 // Called by framework when the view size is changed. |
|
129 // ----------------------------------------------------------------------------- |
|
130 // |
|
131 void CHelloWorldBasicAppView::SizeChanged() |
|
132 { |
|
133 } |
|
134 |
|
135 // ----------------------------------------------------------------------------- |
|
136 // CHelloWorldBasicAppView::GetText() |
|
137 // Called by AppUi to either set the text (via dialog) or zero the contents. |
|
138 // ----------------------------------------------------------------------------- |
|
139 // |
|
140 TDes & CHelloWorldBasicAppView::GetText() |
|
141 { |
|
142 return iText; |
|
143 } |
|
144 |
|
145 // End of File |
|
146 |