|
1 // Copyright (c) 2007-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 the License "Symbian Foundation License v1.0" |
|
5 // which accompanies this distribution, and is available |
|
6 // at the URL "http://www.symbianfoundation.org/legal/sfl-v10.html". |
|
7 // |
|
8 // Initial Contributors: |
|
9 // Nokia Corporation - initial contribution. |
|
10 // |
|
11 // Contributors: |
|
12 // |
|
13 // Description: |
|
14 // |
|
15 |
|
16 |
|
17 |
|
18 /** |
|
19 @file |
|
20 @test |
|
21 @internalComponent - Internal Symbian test code |
|
22 */ |
|
23 |
|
24 #include <eikstart.h> |
|
25 |
|
26 |
|
27 #include "tupgradeiconapp.h" |
|
28 |
|
29 const TUid KUidUpgradeIconApp = { 0xA0003195 }; |
|
30 |
|
31 |
|
32 //////////////////////////////////////////////////////////////////////// |
|
33 // |
|
34 // Implementation of the application class - CExampleApplication |
|
35 // |
|
36 //////////////////////////////////////////////////////////////////////// |
|
37 |
|
38 TUid CExampleApplication::AppDllUid() const |
|
39 { |
|
40 return KUidUpgradeIconApp; |
|
41 } |
|
42 |
|
43 CApaDocument* CExampleApplication::CreateDocumentL() |
|
44 { |
|
45 return new (ELeave) CExampleDocument(*this); |
|
46 } |
|
47 |
|
48 |
|
49 //////////////////////////////////////////////////////////////////////// |
|
50 // |
|
51 // Implementation of the appui class - CExampleAppUi |
|
52 // |
|
53 //////////////////////////////////////////////////////////////////////// |
|
54 |
|
55 void CExampleAppUi::ConstructL() |
|
56 { |
|
57 BaseConstructL(); |
|
58 iAppView = CExampleAppView::NewL(ClientRect()); |
|
59 } |
|
60 |
|
61 CExampleAppUi::~CExampleAppUi() |
|
62 { |
|
63 delete iAppView; |
|
64 } |
|
65 |
|
66 void CExampleAppUi::HandleCommandL(TInt aCommand) |
|
67 { |
|
68 switch (aCommand) |
|
69 { |
|
70 case EEikCmdExit: |
|
71 Exit(); |
|
72 break; |
|
73 } |
|
74 } |
|
75 |
|
76 |
|
77 |
|
78 //////////////////////////////////////////////////////////////////////// |
|
79 // |
|
80 // Implementation of the view class - CExampleAppView |
|
81 // |
|
82 //////////////////////////////////////////////////////////////////////// |
|
83 |
|
84 CExampleAppView::CExampleAppView() |
|
85 { |
|
86 } |
|
87 |
|
88 CExampleAppView* CExampleAppView::NewL(const TRect& aRect) |
|
89 { |
|
90 CExampleAppView* self = new(ELeave) CExampleAppView(); |
|
91 CleanupStack::PushL(self); |
|
92 self->ConstructL(aRect); |
|
93 CleanupStack::Pop(); |
|
94 return self; |
|
95 } |
|
96 |
|
97 CExampleAppView::~CExampleAppView() |
|
98 { |
|
99 delete iExampleText; |
|
100 } |
|
101 |
|
102 void CExampleAppView::ConstructL(const TRect& aRect) |
|
103 { |
|
104 // Fetch the text from the resource file. |
|
105 iExampleText = iEikonEnv->AllocReadResourceL(R_UPGRADEICONAPP_TEXT_TESTAPP); |
|
106 |
|
107 // Control is a window owning control |
|
108 CreateWindowL(); |
|
109 |
|
110 // Extent of the control. This is |
|
111 // the whole rectangle available to application. |
|
112 // The rectangle is passed to us from the application UI. |
|
113 SetRect(aRect); |
|
114 |
|
115 // At this stage, the control is ready to draw so |
|
116 // we tell the UI framework by activating it. |
|
117 ActivateL(); |
|
118 } |
|
119 |
|
120 |
|
121 void CExampleAppView::Draw(const TRect& /*aRect*/) const |
|
122 { |
|
123 CWindowGc& gc = SystemGc(); // Window graphics context |
|
124 TRect drawRect = Rect(); // Area in which we shall draw |
|
125 const CFont* fontUsed; // Font used for drawing text |
|
126 |
|
127 // Start with a clear screen |
|
128 gc.Clear(); |
|
129 |
|
130 // Draw an outline rectangle (the default pen and brush styles ensure this) slightly smaller than the drawing area. |
|
131 drawRect.Shrink(10,10); |
|
132 gc.DrawRect(drawRect); |
|
133 |
|
134 // Use the title font supplied by the UI |
|
135 fontUsed = iEikonEnv->TitleFont(); |
|
136 gc.UseFont(fontUsed); |
|
137 |
|
138 // Draw the text in the middle of the rectangle. |
|
139 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
140 gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
141 |
|
142 // Finished using the font |
|
143 gc.DiscardFont(); |
|
144 } |
|
145 |
|
146 |
|
147 |
|
148 //////////////////////////////////////////////////////////////////////// |
|
149 // |
|
150 // Implementation of the document class - CExampleDocument |
|
151 // |
|
152 //////////////////////////////////////////////////////////////////////// |
|
153 |
|
154 CExampleDocument::CExampleDocument(CEikApplication& aApp) |
|
155 : CEikDocument(aApp) |
|
156 { |
|
157 } |
|
158 |
|
159 CEikAppUi* CExampleDocument::CreateAppUiL() |
|
160 { |
|
161 return new(ELeave) CExampleAppUi; |
|
162 } |
|
163 |
|
164 |
|
165 LOCAL_C CApaApplication* NewApplication() |
|
166 { |
|
167 return new CExampleApplication; |
|
168 } |
|
169 |
|
170 GLDEF_C TInt E32Main() |
|
171 { |
|
172 return EikStart::RunApplication(NewApplication); |
|
173 } |
|
174 |