EmailExampleAui.cpp
上传用户:sempras
上传日期:2007-03-04
资源大小:821k
文件大小:4k
源码类别:

Symbian

开发平台:

C/C++

  1. /*
  2. * ============================================================================
  3. *  Name     : CEmailExampleAppUi from EmailExampleAppUi.cpp
  4. *  Part of  : EmailExample
  5. *  Created  : 09/11/2003 by Forum Nokia
  6. *  Implementation notes:
  7. * Basic framework class constructed initially with appwizard
  8. *
  9. *  Version  : 1.0
  10. *  Copyright: Nokia Corporation
  11. * ============================================================================
  12. */
  13. //application
  14. #include "EmailExampleAui.h"
  15. #include "EmailExampleWin.h"
  16. #include "EmailExampleVer.h"
  17. #include "EmailExample.hrh"
  18. //symbian
  19. #include <EikEnv.h>
  20. #include <EikApp.h>
  21. #include <EikDoc.h>
  22. #include <EikTBar.h> //for CEikButtonGroup
  23. #include <EikMenuP.h> //for menupane
  24. #include <eikspane.h> //for statuspane
  25. //resource specific
  26. #include <EmailExample.rsg>
  27. #include <Eikon.rsg>
  28. CEmailExampleAppUi::CEmailExampleAppUi()
  29. {}
  30. CEmailExampleAppUi::~CEmailExampleAppUi()
  31. {
  32. RemoveFromStack(iMainWindow);
  33. delete iMainWindow;
  34. }
  35. void CEmailExampleAppUi::ConstructL()
  36. {
  37.     BaseConstructL();
  38. iMainWindow=new(ELeave) CEmailMainWindow(*this);
  39. iMainWindow->ConstructL();
  40. LoadIniFileL();
  41. iMainWindow->ActivateL();
  42. ShowToolBar();
  43. AddToStackL(iMainWindow);
  44. }
  45. // save current applciation settings to INI file
  46. void CEmailExampleAppUi::SaveIniFileL()
  47. {
  48. CEikApplication* app=(CEikApplication*)Document()->Application();
  49. CDictionaryStore* iniFile=app->OpenIniFileLC(iEikonEnv->FsSession());
  50. if(!iniFile)
  51. {
  52. return;
  53. }
  54. RDictionaryWriteStream writeStream;
  55. writeStream.AssignLC(*iniFile,KUidEmailExample);
  56. writeStream.WriteInt32L(iFullScreen);
  57. writeStream.CommitL();
  58. CleanupStack::PopAndDestroy(); // writeStream
  59. iniFile->CommitL();
  60. CleanupStack::PopAndDestroy(); // iniFile
  61. }
  62. // load application settings from INI file
  63. void CEmailExampleAppUi::LoadIniFileL()
  64. {
  65. CEikApplication* app=(CEikApplication*)Document()->Application();
  66. CDictionaryStore* iniFile=app->OpenIniFileLC(iEikonEnv->FsSession());
  67. TBool missingOrCorrupt=ETrue;
  68. if(iniFile)
  69. {
  70. TBool present=EFalse;
  71. TRAPD(err,present=iniFile->IsPresentL(KUidEmailExample));
  72. if(present)
  73. {
  74. RDictionaryReadStream readStream;
  75. readStream.OpenLC(*iniFile,KUidEmailExample);
  76. TRAP(err,iFullScreen=readStream.ReadInt32L());
  77. if(err==KErrNone)
  78. {
  79. if(err==KErrNone)
  80. {
  81. missingOrCorrupt=EFalse;
  82. }
  83. }
  84. CleanupStack::PopAndDestroy(); // readStream
  85. }
  86. CleanupStack::PopAndDestroy(); // iniFile
  87. }
  88. if(missingOrCorrupt)
  89. { // INI file missing or corrupt - use default settings
  90. iFullScreen=EFalse;
  91. }
  92. }
  93. void CEmailExampleAppUi::ShowToolBar()
  94. {
  95. iEikonEnv->AppUiFactory()->ToolBar()->MakeVisible(!iFullScreen);
  96. CEikStatusPane* statusPane=iEikonEnv->AppUiFactory()->StatusPane();
  97. if (statusPane)
  98. {
  99. statusPane->MakeVisible(!iFullScreen);
  100. }
  101. iMainWindow->SetRect(ClientRect());
  102. }
  103. TBool CEmailExampleAppUi::ProcessCommandParametersL(TApaCommand aCommand,TFileName& aDocumentName,const TDesC& /*aTail*/)
  104. {
  105. return CEikAppUi::ProcessCommandParametersL(aCommand,aDocumentName);
  106. }
  107. void CEmailExampleAppUi::DynInitMenuPaneL(TInt aResource,CEikMenuPane* aMenuPane)
  108. {
  109. switch(aResource)
  110. {
  111. case R_EMAILEXAMPLEAPP_VIEW_MENU:
  112. if(iFullScreen)
  113. {
  114. aMenuPane->SetItemButtonState(EEmailExampleCmdFullScreen,EEikMenuItemSymbolOn);
  115. }
  116. break;
  117. default:
  118. break;
  119. }
  120. }
  121. void CEmailExampleAppUi::HandleCommandL(TInt aCommand)
  122. {
  123. switch(aCommand)
  124. {
  125. case EEmailExampleCmdFullScreen:
  126. {
  127. iFullScreen=!iFullScreen;
  128. ShowToolBar();
  129. iMainWindow->DrawDeferred();
  130. }
  131. break;
  132. case EEikCmdExit:
  133. {
  134. SaveIniFileL();
  135. SaveL();
  136. Exit();
  137. }
  138. break;
  139. default:
  140. {
  141. iMainWindow->HandleCommandL(aCommand);
  142. }
  143. break;
  144. }
  145. }
  146. void CEmailExampleAppUi::HandleForegroundEventL(TBool /*aForeground*/)
  147. {}