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