|
1 // Copyright (c) 2005-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 @internalComponent - Internal Symbian test code |
|
21 */ |
|
22 |
|
23 #include <e32uid.h> |
|
24 #include <e32base.h> |
|
25 #include <e32test.h> |
|
26 #include <apgctl.h> |
|
27 |
|
28 #include <coeccntx.h> |
|
29 |
|
30 #include <apgtask.h> |
|
31 #include <eikenv.h> |
|
32 #include <eikappui.h> |
|
33 #include <eikapp.h> |
|
34 #include <eikdoc.h> |
|
35 #include <eikmenup.h> |
|
36 #include <apgcli.h> |
|
37 |
|
38 #include <eikon.hrh> |
|
39 |
|
40 #include <App_CTRL.rsg> |
|
41 #include "App_CTRL.hrh" |
|
42 |
|
43 #include <eikstart.h> |
|
44 |
|
45 |
|
46 //////////////////////////////////////////////////////////////////////// |
|
47 // |
|
48 // CExampleAppView |
|
49 // |
|
50 //////////////////////////////////////////////////////////////////////// |
|
51 class CExampleAppView : public CCoeControl |
|
52 { |
|
53 public: |
|
54 static CExampleAppView* NewL(const TRect& aRect); |
|
55 CExampleAppView(); |
|
56 ~CExampleAppView(); |
|
57 void ConstructL(const TRect& aRect); |
|
58 |
|
59 private: |
|
60 // Inherited from CCoeControl |
|
61 void Draw(const TRect& /*aRect*/) const; |
|
62 |
|
63 private: |
|
64 HBufC* iExampleText; |
|
65 }; |
|
66 |
|
67 CExampleAppView::CExampleAppView() |
|
68 { |
|
69 } |
|
70 |
|
71 CExampleAppView* CExampleAppView::NewL(const TRect& aRect) |
|
72 { |
|
73 CExampleAppView* self = new(ELeave) CExampleAppView(); |
|
74 CleanupStack::PushL(self); |
|
75 self->ConstructL(aRect); |
|
76 CleanupStack::Pop(); |
|
77 return self; |
|
78 } |
|
79 |
|
80 CExampleAppView::~CExampleAppView() |
|
81 { |
|
82 delete iExampleText; |
|
83 } |
|
84 |
|
85 void CExampleAppView::ConstructL(const TRect& aRect) |
|
86 { |
|
87 iExampleText = iEikonEnv->AllocReadResourceL(R_EXAMPLE_TEXT_TITLE); |
|
88 CreateWindowL(); |
|
89 SetRect(aRect); |
|
90 ActivateL(); |
|
91 } |
|
92 |
|
93 void CExampleAppView::Draw(const TRect& /*aRect*/) const |
|
94 { |
|
95 CWindowGc& gc = SystemGc(); |
|
96 TRect drawRect = Rect(); |
|
97 const CFont* fontUsed; |
|
98 |
|
99 gc.Clear(); |
|
100 fontUsed = iEikonEnv->TitleFont(); |
|
101 gc.UseFont(fontUsed); |
|
102 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
103 gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
104 gc.DiscardFont(); |
|
105 } |
|
106 |
|
107 |
|
108 //////////////////////////////////////////////////////////////////////// |
|
109 // |
|
110 // CExampleAppUi |
|
111 // |
|
112 //////////////////////////////////////////////////////////////////////// |
|
113 class CExampleAppUi : public CEikAppUi |
|
114 { |
|
115 public: |
|
116 void ConstructL(); |
|
117 ~CExampleAppUi(); |
|
118 private: |
|
119 // Inherirted from class CEikAppUi |
|
120 void HandleCommandL(TInt aCommand); |
|
121 |
|
122 // From CCoeAppUi |
|
123 void HandleSystemEventL(const TWsEvent& aEvent); |
|
124 |
|
125 private: |
|
126 CCoeControl* iAppView; |
|
127 }; |
|
128 |
|
129 |
|
130 void CExampleAppUi::ConstructL() |
|
131 { |
|
132 BaseConstructL(); |
|
133 iAppView = CExampleAppView::NewL(ClientRect()); |
|
134 } |
|
135 |
|
136 CExampleAppUi::~CExampleAppUi() |
|
137 { |
|
138 delete iAppView; |
|
139 } |
|
140 |
|
141 void CExampleAppUi::HandleCommandL(TInt aCommand) |
|
142 { |
|
143 switch (aCommand) |
|
144 { |
|
145 // Just issue simple info messages to show that |
|
146 // the menu items have been selected |
|
147 case EExampleItem0: |
|
148 iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM0); |
|
149 break; |
|
150 |
|
151 |
|
152 case EExampleItem1: |
|
153 iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM1); |
|
154 break; |
|
155 |
|
156 case EExampleItem2: |
|
157 iEikonEnv->InfoMsg(R_EXAMPLE_TEXT_ITEM2); |
|
158 break; |
|
159 case EEikCmdExit: |
|
160 Exit(); |
|
161 break; |
|
162 } |
|
163 } |
|
164 |
|
165 |
|
166 void CExampleAppUi::HandleSystemEventL(const TWsEvent& /*aEvent*/) |
|
167 { |
|
168 } |
|
169 |
|
170 //////////////////////////////////////////////////////////////////////// |
|
171 // |
|
172 // CExampleDocument |
|
173 // |
|
174 //////////////////////////////////////////////////////////////////////// |
|
175 class CExampleDocument : public CEikDocument |
|
176 { |
|
177 public: |
|
178 static CExampleDocument* NewL(CEikApplication& aApp); |
|
179 CExampleDocument(CEikApplication& aApp); |
|
180 void ConstructL(); |
|
181 private: |
|
182 // Inherited from CEikDocument |
|
183 CEikAppUi* CreateAppUiL(); |
|
184 }; |
|
185 |
|
186 CExampleDocument::CExampleDocument(CEikApplication& aApp) |
|
187 : CEikDocument(aApp) |
|
188 { |
|
189 } |
|
190 |
|
191 CEikAppUi* CExampleDocument::CreateAppUiL() |
|
192 { |
|
193 return new(ELeave) CExampleAppUi; |
|
194 } |
|
195 |
|
196 |
|
197 //////////////////////////////////////////////////////////////////////// |
|
198 // |
|
199 // CExampleApplication |
|
200 // |
|
201 //////////////////////////////////////////////////////////////////////// |
|
202 |
|
203 class CExampleApplication : public CEikApplication |
|
204 { |
|
205 private: |
|
206 // Inherited from class CApaApplication |
|
207 CApaDocument* CreateDocumentL(); |
|
208 TUid AppDllUid() const; |
|
209 private: |
|
210 CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); } |
|
211 // |
|
212 }; |
|
213 |
|
214 const TUid KUidSimpleApp = { 0X13008ACE }; |
|
215 |
|
216 TUid CExampleApplication::AppDllUid() const |
|
217 { |
|
218 return KUidSimpleApp; |
|
219 } |
|
220 |
|
221 CApaDocument* CExampleApplication::CreateDocumentL() |
|
222 { |
|
223 return new (ELeave) CExampleDocument(*this); |
|
224 } |
|
225 |
|
226 |
|
227 LOCAL_C CApaApplication* NewApplication() |
|
228 { |
|
229 return new CExampleApplication; |
|
230 } |
|
231 |
|
232 GLDEF_C TInt E32Main() |
|
233 { |
|
234 return EikStart::RunApplication(NewApplication); |
|
235 } |