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