switch Cyclone to submodule on it's own git repo
[picodrive.git] / platform / uiq2 / launcher / App.cpp
1 /*******************************************************************\r
2  *\r
3  *      File:           App.cpp\r
4  *\r
5  *      Author:         Peter van Sebille (peter@yipton.net)\r
6  *\r
7  *  Modified/adapted for picodriveN by notaz, 2006\r
8  *\r
9  *  (c) Copyright 2006, notaz\r
10  *      (c) Copyright 2002, Peter van Sebille\r
11  *      All Rights Reserved\r
12  *\r
13  *******************************************************************/\r
14 \r
15 #include "app.h"\r
16 // #include "picodriven.mbg" // bitmap identifiers\r
17 #include "picodriven.rsg"\r
18 #include <eikenv.h>\r
19 #include <qbtselectdlg.h>\r
20 //#include <gulutil.h>\r
21 //#include <bautils.h>\r
22 #include <eikmenub.h> // CEikMenuBar\r
23 #include <apgtask.h> // TApaSystemEvent\r
24 \r
25 #include "Dialogs.h"\r
26 \r
27 \r
28 CApaDocument* CPicolApplication::CreateDocumentL()\r
29 {\r
30         return new (ELeave) CPicolDocument(*this);\r
31 }\r
32 \r
33 \r
34 CPicolDocument::CPicolDocument(CEikApplication& aApp)\r
35                 : CEikDocument(aApp)\r
36 {\r
37 }\r
38 \r
39 CPicolDocument::~CPicolDocument()\r
40 {\r
41 }\r
42 \r
43 CEikAppUi* CPicolDocument::CreateAppUiL()\r
44 {\r
45         return new(ELeave) CPicolAppUi;\r
46 }\r
47 \r
48 \r
49 ////////////////////////////////////////////////////////////////\r
50 //\r
51 // class CPicolAppUi\r
52 //\r
53 ////////////////////////////////////////////////////////////////\r
54 \r
55 CPicolAppUi::CPicolAppUi()\r
56 : iCurrentLConfig(iCurrentConfig)\r
57 {\r
58         // set default config\r
59         Mem::FillZ(&iCurrentConfig, sizeof(iCurrentConfig));\r
60         iCurrentConfig.iFlags = 1; // use_sram\r
61         iCurrentConfig.iFrameskip               = TPicoConfig::PFSkipAuto;\r
62         iCurrentConfig.iScreenRotation  = TPicoConfig::PRot90;\r
63 }\r
64 \r
65 CPicolAppUi::~CPicolAppUi()\r
66 {\r
67         delete iAppView;\r
68         DeregisterView(*iFOView);\r
69         delete iFOView;\r
70         DeregisterView(*iFCView);\r
71         delete iFCView;\r
72 }\r
73 \r
74 void CPicolAppUi::ConstructL()\r
75 {\r
76         BaseConstructL();\r
77 \r
78         // load config\r
79         iCurrentLConfig.Load();\r
80 \r
81         iAppView=new(ELeave) CEPicolAppView;\r
82         iAppView->ConstructL(ClientRect());\r
83 \r
84         iFOView=new(ELeave) CPicolFOView(*iAppView);\r
85         RegisterViewL(*iFOView);  \r
86         iFCView=new(ELeave) CPicolFCView(*iAppView);\r
87         RegisterViewL(*iFCView);\r
88 }\r
89 \r
90 \r
91 void CPicolAppUi::HandleCommandL(TInt aCommand)\r
92 {\r
93         TInt oldFrameskip = iCurrentConfig.iFrameskip;\r
94         TInt res;\r
95 \r
96         // give time for config dialog destruction\r
97         if(iAfterConfigDialog) {\r
98                 iAfterConfigDialog = EFalse;\r
99                 TTime now; now.UniversalTime();\r
100                 if(now.MicroSecondsFrom(iConfigDialogClosed).Int64().Low() < 2500*1000)\r
101                         User::After(2500*1000-now.MicroSecondsFrom(iConfigDialogClosed).Int64().Low());\r
102         }\r
103 \r
104         switch (aCommand)\r
105         {\r
106                 case EEikCmdPicoLoadState:\r
107                         if(iGameRunner) {\r
108                                 CEikonEnv::Static()->BusyMsgL(_L("Loading State"));\r
109                                 res = ss.SendReceive(PicoMsgLoadState, 0);\r
110                                 CEikonEnv::Static()->BusyMsgCancel();\r
111                                 // emu doesn't start to run if load fails, so we can display this\r
112                                 if(res) CEikonEnv::Static()->InfoMsg(_L("Load Failed"));\r
113                         }\r
114                         break;\r
115 \r
116                 case EEikCmdPicoSaveState:\r
117                         if(iGameRunner) {\r
118                                 CEikonEnv::Static()->BusyMsgL(_L("Saving State"));\r
119                                 res = ss.SendReceive(PicoMsgSaveState, 0);\r
120                                 CEikonEnv::Static()->BusyMsgCancel();\r
121                                 if(res) CEikonEnv::Static()->InfoMsg(_L("Save Failed"));\r
122                         }\r
123                         break;\r
124 \r
125                 case EEikCmdPicoLoadROM:\r
126                         DisplayOpenROMDialogL();\r
127                         break;\r
128 \r
129                 case EEikCmdPicoResume:\r
130                         ss.Send(PicoMsgResume, 0);\r
131                         iEmuRunning = ETrue;\r
132                         break;\r
133 \r
134                 case EEikCmdPicoReset: \r
135                         ss.Send(PicoMsgReset, 0);\r
136                         iEmuRunning = ETrue;\r
137                         break;\r
138 \r
139                 case EEikCmdPicoKeys:\r
140                         if(!iGameRunner) RunGameL();\r
141                         ss.Send(PicoMsgKeys, 0);\r
142                         iEmuRunning = ETrue;\r
143                         break;\r
144                 \r
145                 case EEikCmdPicoSettings:\r
146                         DisplayConfigDialogL();\r
147                         break;\r
148 \r
149                 case EEikCmdHelpAbout: // EEikCmdPicoAbout:\r
150                         DisplayAboutDialogL();\r
151                         break;\r
152 \r
153                 // standard identifier must be used here, TApaTask::EndTask() and probably others send it\r
154                 case EEikCmdExit: // EEikCmdPicoExit:\r
155                         if(iGameRunner) {\r
156                                 iQuitting = ETrue;\r
157                                 iExitForcer = CExitForcer::NewL(*this, 2000);\r
158                                 ss.Send(PicoMsgQuit, 0);\r
159                         } else {\r
160                                 iCurrentLConfig.Save();\r
161                                 DEBUGPRINT(_L("[app] Exit (menu)"));\r
162                                 Exit();\r
163                         }\r
164                         break;\r
165 \r
166                 // frameskips\r
167                 case EEikCmdPicoFrameskipAuto:\r
168                         iCurrentConfig.iFrameskip = TPicoConfig::PFSkipAuto;\r
169                         break;\r
170 \r
171                 case EEikCmdPicoFrameskip0:\r
172                         iCurrentConfig.iFrameskip = TPicoConfig::PFSkip0;\r
173                         break;\r
174 \r
175                 case EEikCmdPicoFrameskip1:\r
176                         iCurrentConfig.iFrameskip = 1;\r
177                         break;\r
178 \r
179                 case EEikCmdPicoFrameskip2:\r
180                         iCurrentConfig.iFrameskip = 2;\r
181                         break;\r
182 \r
183                 case EEikCmdPicoFrameskip4:\r
184                         iCurrentConfig.iFrameskip = 4;\r
185                         break;\r
186 \r
187                 case EEikCmdPicoFrameskip8:\r
188                         iCurrentConfig.iFrameskip = 8;\r
189                         break;\r
190 \r
191                 case EEikCmdPicoDebugKillEmu:\r
192                         if(iGameRunner) {\r
193                                 iExitForcer = CExitForcer::NewL(*this, 4000);\r
194                                 ss.Send(PicoMsgQuit, 0);\r
195                         }\r
196                         break;\r
197 \r
198                 case EEikCmdPicoDebugInfo:\r
199                         if(iGameRunner)\r
200                                 DisplayDebugDialogL();\r
201                         break;\r
202         }\r
203 \r
204         // send config update if needed\r
205         if(iCurrentConfig.iFrameskip != oldFrameskip)\r
206                 SendConfig();\r
207 }\r
208 \r
209 \r
210 void CPicolAppUi::HandleSystemEventL(const TWsEvent& aEvent)\r
211 {\r
212     TApaSystemEvent event;\r
213     event = *(TApaSystemEvent*)aEvent.EventData();\r
214          \r
215     if(event == EApaSystemEventBroughtToForeground) // application brought to foreground\r
216     {\r
217                 DEBUGPRINT(_L("[app] EApaSystemEventBroughtToForeground, iEmuRunning=%i"), iEmuRunning);\r
218                 // we might have missed flip open event (when moved to background),\r
219                 // so make sure we have correct view active\r
220                 if(iCoeEnv->ScreenDevice()->CurrentScreenMode() == EScreenModeFlipOpen) {\r
221                         ActivateViewL(TVwsViewId(KUidPicolApp, KUidPicolFOView));\r
222                         return;\r
223                 }\r
224         }\r
225     if(event == EApaSystemEventShutdown)\r
226     {\r
227                 DEBUGPRINT(_L("[app] EApaSystemEventShutdown"));\r
228         }\r
229 \r
230         CEikAppUi::HandleSystemEventL(aEvent);\r
231 }\r
232 \r
233 \r
234 // called just before the menu is shown\r
235 void CPicolAppUi::DynInitMenuPaneL(TInt aResourceId, CEikMenuPane* aMenuPane)\r
236 {\r
237         if(aResourceId == R_APP_EMU_MENU) {\r
238                 TBool dimmed = !iGameRunner || !iROMLoaded;\r
239                 aMenuPane->SetItemDimmed(EEikCmdPicoLoadState, dimmed);\r
240                 aMenuPane->SetItemDimmed(EEikCmdPicoSaveState, dimmed);\r
241                 aMenuPane->SetItemDimmed(EEikCmdPicoResume, dimmed);\r
242                 aMenuPane->SetItemDimmed(EEikCmdPicoReset,  dimmed);\r
243         } else if(aResourceId == R_APP_FRAMESKIP_MENU) {\r
244                 TInt itemToCheck = EEikCmdPicoFrameskipAuto;\r
245                 switch(iCurrentConfig.iFrameskip) {\r
246                         case 0: itemToCheck = EEikCmdPicoFrameskip0; break;\r
247                         case 1: itemToCheck = EEikCmdPicoFrameskip1; break;\r
248                         case 2: itemToCheck = EEikCmdPicoFrameskip2; break;\r
249                         case 4: itemToCheck = EEikCmdPicoFrameskip4; break;\r
250                         case 8: itemToCheck = EEikCmdPicoFrameskip8; break;\r
251                 }\r
252                 aMenuPane->SetItemButtonState(itemToCheck, EEikMenuItemSymbolOn);\r
253         }\r
254 }\r
255 \r
256 \r
257 void CPicolAppUi::DisplayAboutDialogL()\r
258 {\r
259         CEikDialog*     dialog = new(ELeave) CAboutDialog;\r
260         TInt iButtonRes = dialog->ExecuteLD(R_DIALOG_ABOUT);\r
261         if(iButtonRes == EEikBidYes) {\r
262                 CCreditsDialog *creditsDialog = new (ELeave) CCreditsDialog();\r
263                 creditsDialog->iMessageResourceID = R_TBUF_CREDITS;\r
264                 creditsDialog->ExecuteLD(R_DIALOG_CREDITS);\r
265         }\r
266 }\r
267 \r
268 \r
269 void CPicolAppUi::DisplayOpenROMDialogL()\r
270 {\r
271 \r
272         TFileName file(iCurrentLConfig.iLastROMFile);\r
273         CEikDialog* dialog = new(ELeave) CEikFileOpenDialog(&file);\r
274         //((CEikFileOpenDialog *)dialog)->SetRequiredExtension(&ext);\r
275 \r
276         if(dialog->ExecuteLD(R_EIK_DIALOG_FILE_OPEN) == EEikBidOk) {\r
277                 CEikonEnv::Static()->BusyMsgL(_L("Loading ROM"));\r
278 \r
279                 // start emu process if it is not running\r
280                 if(!iGameRunner) RunGameL();\r
281                 iROMLoaded = EFalse;\r
282 \r
283                 TBuf8<KMaxFileName> file8;\r
284                 file8.Copy(file);\r
285                 TAny *p[KMaxMessageArguments];\r
286                 p[0]= (TAny*)(&file8);\r
287                 TInt res = ss.SendReceive(PicoMsgLoadROM, &p[0]);\r
288 \r
289                 CEikonEnv::Static()->BusyMsgCancel();\r
290 \r
291                 if(res == 1)\r
292                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to open file."));\r
293                 else if(res == 2)\r
294                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to allocate memory."));\r
295                 else if(res == 3)\r
296                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("The file you selected is not a game ROM."));\r
297                 else if(res == 4)\r
298                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("No game ROMs found in zipfile."));\r
299                 else if(res == 5)\r
300                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed while unzipping ROM."));\r
301                 else if(res < 0)\r
302                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to send request to emu process."));\r
303                 else {\r
304                         iROMLoaded = ETrue;\r
305                         iEmuRunning = ETrue;\r
306                 }\r
307 \r
308                 // sound errors which leave ROM loaded\r
309                 if(res == 6)\r
310                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to allocate sound buffer, disabled sound."));\r
311                 else if(res == 7)\r
312                         CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to start soundsystem, disabled sound."));\r
313                 if(res == 6 || res == 7) iCurrentConfig.iFlags &= ~4;\r
314 \r
315                 iCurrentLConfig.iLastROMFile.Copy(file);\r
316         }\r
317 }\r
318 \r
319 \r
320 void CPicolAppUi::DisplayConfigDialogL()\r
321 {\r
322         CPicoConfigDialog* configDialog = new(ELeave)CPicoConfigDialog(iCurrentConfig, iCurrentLConfig);\r
323         configDialog->ExecuteLD(R_PICO_CONFIG);\r
324 \r
325         if(iGameRunner)\r
326                 SendConfig();\r
327 \r
328         iCurrentLConfig.Save();\r
329 \r
330         // configDialog seems to be actually destroyed later after returning,\r
331         // and this usually happens just after resuming game and causes emu slowdowns :/\r
332         iAfterConfigDialog = ETrue;\r
333         iConfigDialogClosed.UniversalTime();\r
334 }\r
335 \r
336 \r
337 void CPicolAppUi::DisplayDebugDialogL()\r
338 {\r
339         // first get our debug info\r
340         char dtxt[1024];\r
341 \r
342         TAny *p[KMaxMessageArguments];\r
343         TPtr8 descr((TUint8*) dtxt, sizeof(dtxt));\r
344         p[0]= (TAny*)(&descr);\r
345         ss.SendReceive(PicoMsgRetrieveDebugStr, &p[0]);\r
346 \r
347         CEikDialog*     dialog = new(ELeave) CDebugDialog(dtxt);\r
348         dialog->ExecuteLD(R_DIALOG_DEBUG);\r
349 }\r
350 \r
351 \r
352 void CPicolAppUi::SendConfig()\r
353 {\r
354         // send config\r
355         if(iGameRunner) {\r
356                 TAny *p[KMaxMessageArguments];\r
357                 TPtrC8 descr((TUint8*) &iCurrentConfig, sizeof(iCurrentConfig));\r
358                 p[0]= (TAny*)(&descr);\r
359                 ss.Send(PicoMsgConfigChange, &p[0]);\r
360         }\r
361 }\r
362 \r
363 \r
364 // get config from emu proc\r
365 void CPicolAppUi::RetrieveConfig()\r
366 {\r
367         // ask to configure keys and receive new config\r
368         TAny *p[KMaxMessageArguments];\r
369         TPtr8 descr((TUint8*) &iCurrentConfig, sizeof(iCurrentConfig));\r
370         p[0]= (TAny*)(&descr);\r
371         ss.SendReceive(PicoMsgRetrieveConfig, &p[0]);\r
372 \r
373         iCurrentLConfig.Save();\r
374 }\r
375 \r
376 \r
377 void CPicolAppUi::NotifyEmuDeath()\r
378 {\r
379         StopGame();\r
380         if(iQuitting) {\r
381                 DEBUGPRINT(_L("[app] Exit (NotifyEmuDeath)"));\r
382                 iCurrentLConfig.Save();\r
383                 RProcess me;\r
384                 me.Terminate(0);\r
385         }\r
386 }\r
387 \r
388 \r
389 void CPicolAppUi::NotifyForcedExit()\r
390 {\r
391         DEBUGPRINT(_L("[app] Exit (NotifyForcedExit)"));\r
392         StopGame();\r
393         RProcess me;\r
394         me.Terminate(0);\r
395 }\r
396 \r
397 \r
398 TBool CPicolAppUi::EmuRunning() const\r
399 {\r
400         return iEmuRunning;\r
401 }\r
402 \r
403 \r
404 void CPicolAppUi::StopGame()\r
405 {\r
406         // in case we have busyMsg and process crashes\r
407         CEikonEnv::Static()->BusyMsgCancel();\r
408 \r
409         ss.Close();\r
410         if(iGameRunner) delete iGameRunner;\r
411         iGameRunner = NULL;\r
412         if(iExitForcer) delete iExitForcer;\r
413         iExitForcer = NULL;\r
414         if(iThreadWatcher1) delete iThreadWatcher1;\r
415         iThreadWatcher1 = NULL;\r
416         iROMLoaded  = EFalse;\r
417         iEmuRunning = EFalse;\r
418 }\r
419 \r
420 \r
421 void CPicolAppUi::RunGameL()\r
422 {\r
423         TInt res = KErrNone;\r
424 \r
425         // do one connection attemt to emu and ask it to quit if we succeed\r
426         res = ss.Connect();\r
427         if(res == KErrNone) {\r
428                 ss.Send(PicoMsgQuit, 0);\r
429                 ss.Close();\r
430         }\r
431 \r
432         iGameRunner = CGameRunner::NewL(*this);\r
433 \r
434         // Connect to the server\r
435         // we don't want to do complex asynchronous stuff here, so we just\r
436         // wait and do several connection attempts\r
437         User::After(200000);\r
438         for(TInt attempt=0; attempt < 10; attempt++) {\r
439                 res = ss.Connect();\r
440                 if(res == KErrNone) break;\r
441                 User::After(200000);\r
442         }\r
443 \r
444         if(res != KErrNone) {\r
445                 CEikonEnv::Static()->BusyMsgCancel();\r
446                 CEikonEnv::Static()->InfoWinL(_L("Error"), _L("Failed to communicate with the emulation process."));\r
447                 StopGame();\r
448                 RProcess me;\r
449                 me.Terminate(2);\r
450         }\r
451 \r
452         // now we are successfully connected, that means emu process' helper-communication thread is running.\r
453         // we have to keep an eye on it too, because if it crashes, symbian OS leaves it's process\r
454         // alive, but it becomes useless without it's communication thread so we have to detect it's death.\r
455         iThreadWatcher1 = CThreadWatcher::NewL(*this, KServerName);\r
456 \r
457         // send initial config\r
458         SendConfig();\r
459 }\r
460 \r
461 \r
462 /*\r
463 void CPicolAppUi::HandleScreenDeviceChangedL()\r
464 {\r
465         // does not receive when emu is in foreground\r
466         if(iCoeEnv->ScreenDevice()->CurrentScreenMode() == 0) { // flip open\r
467                 // regain focus\r
468                 //iCoeEnv->BringOwnerToFront();\r
469 \r
470         }\r
471 //      ss.Send(PicoMsgFlipChange, 0);\r
472 }\r
473 */\r
474 \r
475 void CPicolAppUi::HandleApplicationSpecificEventL(TInt aType, const TWsEvent& aEvent)\r
476 {\r
477         DEBUGPRINT(_L("[app] event from server: %i"), aEvent.Type());\r
478 \r
479         switch (aEvent.Type())\r
480         {\r
481                 case EEventKeyCfgDone:\r
482                         RetrieveConfig();\r
483                         break;\r
484                 \r
485                 case EEventGamePaused:\r
486                         iEmuRunning = EFalse;\r
487                         break;\r
488         }\r
489 }\r
490 \r
491 ////////////////////////////////////////////////////////////////\r
492 //\r
493 // class CEPicolAppView\r
494 //\r
495 ////////////////////////////////////////////////////////////////\r
496 \r
497 void CEPicolAppView::ConstructL(const TRect& aRect)\r
498 {\r
499         CreateWindowL();\r
500         SetRect(aRect);\r
501         ActivateL();\r
502 \r
503                 /*\r
504                  * Load background image\r
505                  */\r
506 /*\r
507         TBuf<1> name = _L("*");\r
508         TRAPD(err, iBgImage = CEikonEnv::Static()->CreateBitmapL(name, EMbmEdoomDoom));\r
509         if (iBgImage)\r
510         {\r
511                 iImagePosition.iX = (aRect.Size().iWidth - iBgImage->SizeInPixels().iWidth) / 2;\r
512                 iImagePosition.iY = (aRect.Size().iHeight - iBgImage->SizeInPixels().iHeight) / 2;\r
513         }\r
514 */\r
515 }\r
516 \r
517 CEPicolAppView::~CEPicolAppView()\r
518 {\r
519         //if (iBgImage) delete iBgImage;\r
520 }\r
521 \r
522 \r
523 void CEPicolAppView::Draw(const TRect& aRect) const\r
524 {\r
525         CWindowGc& gc = SystemGc();\r
526 \r
527         //if (iBgImage)\r
528         //{\r
529         //      gc.DrawBitmap(iImagePosition, iBgImage);\r
530         //      DrawUtils::ClearBetweenRects(gc, Rect(), TRect(iImagePosition, iBgImage->SizeInPixels()));\r
531         //}\r
532         //else\r
533                 gc.Clear();//aRect);\r
534 }\r
535 \r
536 \r
537 ////////////////////////////////////////////////////////////////\r
538 //\r
539 // class CPicolViewBase\r
540 //\r
541 ////////////////////////////////////////////////////////////////\r
542 \r
543 void CPicolViewBase::ViewActivatedL(const TVwsViewId& /*aPrevViewId*/, TUid /*aCustomMessageId*/, const TDesC8& /*aCustomMessage*/)\r
544 {\r
545         TPixelsAndRotation sizeAndRotation;\r
546         CEikonEnv::Static()->ScreenDevice()->GetDefaultScreenSizeAndRotation(sizeAndRotation);\r
547         CEikonEnv::Static()->ScreenDevice()->SetScreenSizeAndRotation(sizeAndRotation);\r
548         //iAppViewCtl.MakeVisible(ETrue);\r
549 }\r
550 \r
551 void CPicolViewBase::ViewDeactivated()\r
552 {\r
553         //iAppViewCtl.MakeVisible(EFalse);\r
554 }\r
555 \r
556 \r
557 ////////////////////////////////////////////////////////////////\r
558 //\r
559 // class CPicolFOView\r
560 //\r
561 ////////////////////////////////////////////////////////////////\r
562 \r
563 TVwsViewId CPicolFOView::ViewId() const\r
564 {\r
565         return TVwsViewId(KUidPicolApp, KUidPicolFOView);\r
566 }\r
567 \r
568 TVwsViewIdAndMessage CPicolFOView::ViewScreenDeviceChangedL()\r
569 {\r
570         // only handle change to FC mode when emu process is running\r
571         if(static_cast<CPicolAppUi*>(CEikonEnv::Static()->AppUi())->EmuRunning())\r
572                  return TVwsViewIdAndMessage(TVwsViewId(KUidPicolApp, KUidPicolFCView));\r
573         else return MCoeView::ViewScreenDeviceChangedL();\r
574 }\r
575 \r
576 TBool CPicolFOView::ViewScreenModeCompatible(TInt aScreenMode)\r
577 {\r
578         return (aScreenMode == EScreenModeFlipOpen);\r
579 }\r
580 \r
581 void CPicolFOView::ViewActivatedL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage)\r
582 {\r
583         DEBUGPRINT(_L("[app] FO"));\r
584         CPicolViewBase::ViewActivatedL(aPrevViewId, aCustomMessageId, aCustomMessage);\r
585         CEikonEnv::Static()->AppUiFactory()->MenuBar()->MakeVisible(ETrue);\r
586 \r
587         iAppViewCtl.SetRect(static_cast<CEikAppUi*>(CEikonEnv::Static()->AppUi())->ClientRect());\r
588 }\r
589 \r
590 \r
591 ////////////////////////////////////////////////////////////////\r
592 //\r
593 // class CPicolFCView\r
594 //\r
595 ////////////////////////////////////////////////////////////////\r
596 \r
597 TVwsViewId CPicolFCView::ViewId() const\r
598 {\r
599         return TVwsViewId(KUidPicolApp, KUidPicolFCView);\r
600 }\r
601 \r
602 TVwsViewIdAndMessage CPicolFCView::ViewScreenDeviceChangedL()\r
603 {\r
604         return TVwsViewIdAndMessage(TVwsViewId(KUidPicolApp, KUidPicolFOView));\r
605 }\r
606 \r
607 TBool CPicolFCView::ViewScreenModeCompatible(TInt aScreenMode)\r
608 {\r
609         return (aScreenMode == EScreenModeFlipClosed);\r
610 }\r
611 \r
612 void CPicolFCView::ViewActivatedL(const TVwsViewId& aPrevViewId, TUid aCustomMessageId, const TDesC8& aCustomMessage)\r
613 {\r
614         DEBUGPRINT(_L("[app] FC"));\r
615         CPicolViewBase::ViewActivatedL(aPrevViewId, aCustomMessageId, aCustomMessage);\r
616         CEikonEnv::Static()->AppUiFactory()->MenuBar()->MakeVisible(EFalse);\r
617         //iAppViewCtl.ChangeLayout(ETrue);\r
618         iAppViewCtl.SetRect(CEikonEnv::Static()->ScreenDevice()->SizeInPixels());\r
619 }\r
620 \r
621 \r
622 ////////////////////////////////////////////////////////////////\r
623 //\r
624 // framework\r
625 //\r
626 ////////////////////////////////////////////////////////////////\r
627 \r
628 GLDEF_C TInt E32Dll(TDllReason)\r
629 {\r
630         return KErrNone;\r
631 }\r
632 \r
633 \r
634 EXPORT_C CApaApplication* NewApplication()\r
635 {\r
636         return new CPicolApplication;\r
637 }\r
638 \r
639 \r
640 TUid CPicolApplication::AppDllUid() const\r
641 {\r
642         return KUidPicolApp;\r
643 }\r
644 \r