|
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 // Supporting application for use by other test programs that need |
|
15 // to query the apparc server for applications which define |
|
16 // different embeddability values in their AIF files. |
|
17 // |
|
18 // |
|
19 |
|
20 |
|
21 |
|
22 /** |
|
23 @file |
|
24 @internalComponent - Internal Symbian test code |
|
25 */ |
|
26 |
|
27 #include <coeccntx.h> |
|
28 |
|
29 #include <apgtask.h> |
|
30 #include <eikenv.h> |
|
31 #include <eikappui.h> |
|
32 #include <eikapp.h> |
|
33 #include <eikdoc.h> |
|
34 #include <eikmenup.h> |
|
35 |
|
36 #include <ecom.h> |
|
37 #include <implementationproxy.h> |
|
38 |
|
39 #include "TAppEmbedUids.h" |
|
40 |
|
41 _LIT(KExampleText, "This test application defines KAppEmbeddable in it's AIF file"); |
|
42 |
|
43 |
|
44 //////////////////////////////////////////////////////////////////////// |
|
45 // |
|
46 // CExampleAppView |
|
47 // |
|
48 //////////////////////////////////////////////////////////////////////// |
|
49 class CExampleAppView : public CCoeControl |
|
50 { |
|
51 public: |
|
52 static CExampleAppView* NewL(const TRect& aRect); |
|
53 CExampleAppView(); |
|
54 ~CExampleAppView(); |
|
55 void ConstructL(const TRect& aRect); |
|
56 |
|
57 private: |
|
58 // from CCoeControl |
|
59 void Draw(const TRect& /*aRect*/) const; |
|
60 private: |
|
61 HBufC* iExampleText; |
|
62 }; |
|
63 |
|
64 CExampleAppView::CExampleAppView() |
|
65 { |
|
66 } |
|
67 |
|
68 CExampleAppView* CExampleAppView::NewL(const TRect& aRect) |
|
69 { |
|
70 CExampleAppView* self = new(ELeave) CExampleAppView(); |
|
71 CleanupStack::PushL(self); |
|
72 self->ConstructL(aRect); |
|
73 CleanupStack::Pop(); |
|
74 return self; |
|
75 } |
|
76 |
|
77 CExampleAppView::~CExampleAppView() |
|
78 { |
|
79 delete iExampleText; |
|
80 } |
|
81 |
|
82 void CExampleAppView::ConstructL(const TRect& aRect) |
|
83 { |
|
84 TPtrC ptr(KExampleText); |
|
85 iExampleText = ptr.AllocL(); |
|
86 CreateWindowL(); |
|
87 SetRect(aRect); |
|
88 ActivateL(); |
|
89 } |
|
90 |
|
91 void CExampleAppView::Draw(const TRect& /*aRect*/) const |
|
92 { |
|
93 CWindowGc& gc = SystemGc(); |
|
94 TRect drawRect = Rect(); |
|
95 const CFont* fontUsed; |
|
96 |
|
97 gc.Clear(); |
|
98 fontUsed = iEikonEnv->TitleFont(); |
|
99 gc.UseFont(fontUsed); |
|
100 TInt baselineOffset=(drawRect.Height() - fontUsed->HeightInPixels())/2; |
|
101 gc.DrawText(*iExampleText,drawRect,baselineOffset,CGraphicsContext::ECenter, 0); |
|
102 gc.DiscardFont(); |
|
103 } |
|
104 |
|
105 |
|
106 //////////////////////////////////////////////////////////////////////// |
|
107 // |
|
108 // CExampleAppUi |
|
109 // |
|
110 //////////////////////////////////////////////////////////////////////// |
|
111 class CExampleAppUi : public CEikAppUi |
|
112 { |
|
113 public: |
|
114 void ConstructL(); |
|
115 ~CExampleAppUi(); |
|
116 |
|
117 private: |
|
118 // from CEikAppUi |
|
119 void HandleCommandL(TInt aCommand); |
|
120 private: |
|
121 CCoeControl* iAppView; |
|
122 }; |
|
123 |
|
124 |
|
125 void CExampleAppUi::ConstructL() |
|
126 { |
|
127 BaseConstructL(ENoAppResourceFile | ENoScreenFurniture); |
|
128 iAppView = CExampleAppView::NewL(ClientRect()); |
|
129 HandleCommandL(EEikCmdExit); |
|
130 } |
|
131 |
|
132 CExampleAppUi::~CExampleAppUi() |
|
133 { |
|
134 delete iAppView; |
|
135 } |
|
136 |
|
137 void CExampleAppUi::HandleCommandL(TInt aCommand) |
|
138 { |
|
139 switch (aCommand) |
|
140 { |
|
141 case EEikCmdExit: |
|
142 Exit(); |
|
143 break; |
|
144 } |
|
145 } |
|
146 |
|
147 |
|
148 //////////////////////////////////////////////////////////////////////// |
|
149 // |
|
150 // CExampleDocument |
|
151 // |
|
152 //////////////////////////////////////////////////////////////////////// |
|
153 class CExampleDocument : public CEikDocument |
|
154 { |
|
155 public: |
|
156 static CExampleDocument* NewL(CEikApplication& aApp); |
|
157 CExampleDocument(CEikApplication& aApp); |
|
158 void ConstructL(); |
|
159 private: |
|
160 // Inherited from CEikDocument |
|
161 CEikAppUi* CreateAppUiL(); |
|
162 }; |
|
163 |
|
164 CExampleDocument::CExampleDocument(CEikApplication& aApp) |
|
165 : CEikDocument(aApp) |
|
166 { |
|
167 } |
|
168 |
|
169 CEikAppUi* CExampleDocument::CreateAppUiL() |
|
170 { |
|
171 return new(ELeave) CExampleAppUi; |
|
172 } |
|
173 |
|
174 |
|
175 |
|
176 //////////////////////////////////////////////////////////////////////// |
|
177 // |
|
178 // CExampleApplication |
|
179 // |
|
180 //////////////////////////////////////////////////////////////////////// |
|
181 |
|
182 class CExampleApplication : public CEikApplication |
|
183 { |
|
184 private: |
|
185 // from CApaApplication |
|
186 CApaDocument* CreateDocumentL(); |
|
187 TUid AppDllUid() const; |
|
188 private: |
|
189 TFileName ResourceFileName() const; |
|
190 private: |
|
191 CApaDocument* CreateDocumentL(CApaProcess* a) { return CEikApplication::CreateDocumentL(a); } |
|
192 // |
|
193 }; |
|
194 |
|
195 CApaDocument* CExampleApplication::CreateDocumentL() |
|
196 { |
|
197 return new (ELeave) CExampleDocument(*this); |
|
198 } |
|
199 |
|
200 TUid CExampleApplication::AppDllUid() const |
|
201 { |
|
202 return KUidAppEmbeddable; |
|
203 } |
|
204 |
|
205 TFileName CExampleApplication::ResourceFileName() const |
|
206 { |
|
207 return TFileName(); // this app doesn't have a resource file |
|
208 } |
|
209 |
|
210 |
|
211 GLDEF_C TInt E32Dll( |
|
212 ) |
|
213 { |
|
214 return KErrNone; |
|
215 } |
|
216 |
|
217 LOCAL_C CApaApplication* NewApplication() |
|
218 { |
|
219 return new CExampleApplication; |
|
220 } |
|
221 |
|
222 LOCAL_D const TImplementationProxy ImplementationTable[]= |
|
223 { |
|
224 IMPLEMENTATION_PROXY_ENTRY(0x10004c48, NewApplication) |
|
225 }; |
|
226 |
|
227 EXPORT_C const TImplementationProxy* ImplementationGroupProxy(TInt& aTableCount) |
|
228 { |
|
229 aTableCount=sizeof(ImplementationTable)/sizeof(ImplementationTable[0]); |
|
230 return ImplementationTable; |
|
231 } |