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