222 self->ConstructL(); |
224 self->ConstructL(); |
223 CleanupStack::Pop(self); |
225 CleanupStack::Pop(self); |
224 return self; |
226 return self; |
225 } |
227 } |
226 |
228 |
|
229 _LIT(KOptionScreen, "-screen"); |
|
230 |
|
231 typedef CEGLRendering* (*RendererFactoryFunctionL)(RWindow&); |
|
232 |
227 /** |
233 /** |
228 * Constructor for CWsApp |
234 * Constructor for CWsApp |
229 * |
235 * |
230 * @note This constructor looks at the command line argument, if any, supplied when |
236 * @note This constructor looks at the command line argument, if any, supplied when |
231 * launching the application. If specified, its used as the screen number to |
237 * launching the application. If specified, its used as the screen number to |
234 void CWsApp::ConstructL() |
240 void CWsApp::ConstructL() |
235 { |
241 { |
236 RDebug::Printf("[EBT] CWsApp::ConstructL"); |
242 RDebug::Printf("[EBT] CWsApp::ConstructL"); |
237 |
243 |
238 iScrId = KDefaultScreenNo; |
244 iScrId = KDefaultScreenNo; |
239 if (User::CommandLineLength() > 0) |
245 HBufC* rendererName = 0; |
240 { |
246 CCommandLineArguments* args = CCommandLineArguments::NewLC(); |
241 TBuf<1> arg; |
247 for (TInt i=1; i<args->Count(); ++i) |
242 User::CommandLine(arg); |
248 { |
243 iScrId = (TInt)(arg[0]-'0'); |
249 const TPtrC arg = args->Arg(i); |
244 } |
250 if (!arg.Compare(KOptionScreen)) |
245 |
251 { |
246 RDebug::Printf("[EBT] CWsApp::ConstructL 1"); |
252 if (++i < args->Count()) |
|
253 { |
|
254 TLex lex(args->Arg(i)); |
|
255 User::LeaveIfError(lex.Val(iScrId)); |
|
256 RDebug::Printf("[EBT] CWsApp::ConstructL screenId %d", iScrId); |
|
257 } |
|
258 } |
|
259 else if (!rendererName) |
|
260 { |
|
261 RDebug::Print(_L("[EBT] CWsApp::ConstructL rendererName %S"), &arg); |
|
262 rendererName = HBufC::NewL(arg.Length()); |
|
263 rendererName->Des() = arg; |
|
264 } |
|
265 else |
|
266 { |
|
267 RDebug::Print(_L("[EBT] CWsApp::ConstructL ignoring argument %S"), &arg); |
|
268 } |
|
269 } |
|
270 |
|
271 CleanupStack::PopAndDestroy(args); |
|
272 if (rendererName) |
|
273 { |
|
274 CleanupStack::PushL(rendererName); |
|
275 } |
|
276 |
247 iAppView = CWsCanvas::NewL(iScrId, iPos); |
277 iAppView = CWsCanvas::NewL(iScrId, iPos); |
248 RDebug::Printf("[EBT] CWsApp::ConstructL 2"); |
278 iSz = iAppView->ScreenSize(); |
249 iEventHandler = new (ELeave) CWsEventHandler(iAppView->Session(), iAppView->Window(), *this); |
279 iEventHandler = new (ELeave) CWsEventHandler(iAppView->Session(), iAppView->Window(), *this); |
250 RDebug::Printf("[EBT] CWsApp::ConstructL 3"); |
280 |
251 iDemo = CVGLine::NewL(iAppView->Window()); |
281 RendererFactoryFunctionL factoryFunctionL = CVGLine::NewL; |
252 RDebug::Printf("[EBT] CWsApp::ConstructL 4"); |
282 if (rendererName) |
253 iSz = iAppView->ScreenSize(); |
283 { |
254 RDebug::Printf("[EBT] CWsApp::ConstructL 5"); |
284 if (!rendererName->Des().Compare(CGLES1Cube::Name())) |
|
285 { |
|
286 factoryFunctionL = CGLES1Cube::NewL; |
|
287 } |
|
288 if (!rendererName->Des().Compare(CVGLine::Name())) |
|
289 { |
|
290 factoryFunctionL = CVGLine::NewL; |
|
291 } |
|
292 CleanupStack::PopAndDestroy(rendererName); |
|
293 } |
|
294 iDemo = (*factoryFunctionL)(iAppView->Window()); |
255 } |
295 } |
256 |
296 |
257 void CWsApp::Start() |
297 void CWsApp::Start() |
258 { |
298 { |
259 RDebug::Printf("[EBT] CWsApp::Start"); |
299 RDebug::Printf("[EBT] CWsApp::Start"); |