00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "CLifeEngine.h"
00017 #include "Direct.h"
00018 #include "CDirectDisplayLife.h"
00019
00020 #include <eikenv.h>
00021 #include <eikmenub.h>
00022
00023 #include <eikspane.h>
00024
00025 #include <eikstart.h>
00026
00027
00028
00029
00030
00031 CExampleAppView::CExampleAppView(CLifeEngine& aLifeEngine)
00032 : iLifeEngine(aLifeEngine)
00033 {
00034 }
00035
00036 void CExampleAppView::ConstructL(const TRect& aRect)
00037 {
00038
00039 CreateWindowL();
00040 SetRect(aRect);
00041
00042
00043 iDirectDisplayLife = new (ELeave) CDirectDisplayLife (
00044 iEikonEnv->WsSession(),
00045 Window(),
00046 iLifeEngine);
00047 iDirectDisplayLife -> ConstructL();
00048
00049 ActivateL();
00050 }
00051
00052 CExampleAppView::~CExampleAppView()
00053 {
00054 delete iDirectDisplayLife;
00055 }
00056
00057
00058 void CExampleAppView::StartDirectL()
00059 {
00060 iDirectDisplayLife -> StartL();
00061 iState = EDirectStarted;
00062 }
00063
00064
00065 void CExampleAppView::PauseDirect()
00066 {
00067 iState = EDirectPaused;
00068 iDirectDisplayLife -> Cancel();
00069 }
00070
00071
00072 void CExampleAppView::RestartDirect()
00073 {
00074 iState = EDirectStarted;
00075 iDirectDisplayLife -> Restart(RDirectScreenAccess::ETerminateCancel);
00076 }
00077
00078
00079 TInt CExampleAppView::State() const
00080 {
00081 return iState;
00082 }
00083
00084
00085 void CExampleAppView::Draw(const TRect& ) const
00086 {
00087 CWindowGc& gc = SystemGc();
00088
00089 TRect rect=Rect();
00090 gc.SetPenStyle(CGraphicsContext::ENullPen);
00091 gc.SetBrushStyle(CGraphicsContext::ESolidBrush);
00092 gc.SetBrushColor(KRgbWhite);
00093 gc.DrawRect(rect);
00094
00095 rect.Shrink(10,10);
00096 gc.SetBrushStyle(CGraphicsContext::ENullBrush);
00097 gc.SetPenStyle(CGraphicsContext::ESolidPen);
00098 gc.DrawRect(rect);
00099 }
00100
00101
00102
00103
00104
00105
00106 void CExampleAppUi::ConstructL()
00107 {
00108 BaseConstructL();
00109
00110
00111 iAppView=new(ELeave) CExampleAppView(static_cast<CExampleDocument*>(Document())->LifeEngine());
00112 iAppView->ConstructL(ClientRect());
00113
00114
00115 iOverlayDialog = new (ELeave) COverlayDialog();
00116 CActiveScheduler::Add(iOverlayDialog);
00117 }
00118
00119 CExampleAppUi::~CExampleAppUi()
00120 {
00121 delete iAppView;
00122 iOverlayDialog->Cancel();
00123 delete iOverlayDialog;
00124 }
00125
00126
00127 void CExampleAppUi::HandleCommandL(TInt aCommand)
00128 {
00129 switch (aCommand)
00130 {
00131
00132 case EExampleCmd1:
00133
00134
00135 if (iAppView -> State() == CExampleAppView::EDirectNotStarted)
00136 iAppView -> StartDirectL();
00137 else
00138 {
00139 iAppView -> PauseDirect();
00140 static_cast<CExampleDocument*>(Document())->LifeEngine().Reset();
00141 iAppView -> RestartDirect();
00142 }
00143 break;
00144
00145 case EExampleCmd2:
00146 iOverlayDialog->ShowDialog();
00147 break;
00148
00149 case EEikCmdExit:
00150 Exit();
00151 break;
00152 }
00153 }
00154
00155
00156
00157
00158
00159 CExampleAppUi::COverlayDialog::COverlayDialog()
00160 :CActive(EPriorityStandard)
00161 {
00162 iNotifier.Connect();
00163 }
00164
00165 CExampleAppUi::COverlayDialog::~COverlayDialog()
00166 {
00167 Cancel();
00168 iNotifier.Close();
00169 }
00170
00171 void CExampleAppUi::COverlayDialog::ShowDialog()
00172 {
00173 _LIT(KLine1,"Overlaying dialog");
00174 _LIT(KLine2,"Owned by another thread");
00175 _LIT(KBut,"OK");
00176
00177
00178 iNotifier.Notify(KLine1,KLine2,KBut,KBut,iR,iStatus);
00179 SetActive();
00180 }
00181
00182 void CExampleAppUi::COverlayDialog::RunL()
00183 {
00184
00185 }
00186
00187 void CExampleAppUi::COverlayDialog::DoCancel()
00188 {
00189 }
00190
00191
00192
00193
00194
00195 CExampleDocument::CExampleDocument(CEikApplication& aApp)
00196 : CEikDocument(aApp)
00197 {
00198 }
00199
00200 CExampleDocument::~CExampleDocument()
00201 {
00202 delete iLifeEngine;
00203 }
00204
00205 CLifeEngine& CExampleDocument::LifeEngine() const
00206 {
00207 return *iLifeEngine;
00208 }
00209
00210 CEikAppUi* CExampleDocument::CreateAppUiL()
00211 {
00212
00213 User::After(1);
00214 TTime now;
00215 now.HomeTime();
00216
00217
00218 iLifeEngine = new (ELeave) CLifeEngine(now.Int64());
00219 return new(ELeave) CExampleAppUi;
00220 }
00221
00222
00223
00224
00225
00226 TUid CExampleApplication::AppDllUid() const
00227 {
00228 return KUidExample;
00229 }
00230
00231 CApaDocument* CExampleApplication::CreateDocumentL()
00232 {
00233 return new (ELeave) CExampleDocument(*this);
00234 }
00235
00236
00237
00238
00239
00240 EXPORT_C CApaApplication* NewApplication()
00241 {
00242 return new CExampleApplication;
00243 }
00244
00245
00246 extern TInt E32Main()
00247 {
00248 return EikStart::RunApplication(NewApplication);
00249 }