4 #include <sdlepocapi.h>
12 #include <aknglobalmsgquery.h>
17 class Ticker
: public CActive
20 Ticker() : CActive(CActive::EPriorityIdle
)
22 CActiveScheduler::Add(this);
25 ~Ticker() { Cancel(); }
32 ////////////////////////////////////////////////////////////////////////
34 class CSDLWin
: public CCoeControl
37 CSDLWin( const TRect
& aRect
);
38 RWindow
& GetWindow() const { return Window(); }
41 void Draw(const TRect
& aRect
) const;
42 void HandlePointerEventL(const TPointerEvent
& aPointerEvent
);
45 CSDLWin::CSDLWin( const TRect
& aRect
)
51 Window().SetRequiredDisplayMode(EColor64K
);
54 void CSDLWin::Draw(const TRect
& /*aRect*/) const
58 void CSDLWin::HandlePointerEventL(const TPointerEvent
& aPointerEvent
)
60 CCoeControl::HandlePointerEventL(aPointerEvent
);
63 event
.SetType(EEventPointer
);
64 memcpy(event
.Pointer(), &aPointerEvent
, sizeof(TPointerEvent
));
65 g_SDL
->AppendWsEvent(event
);
68 ////////////////////////////////////////////////////////////////////////////
70 class CSDLAppUi
: public CAknAppUi
77 void HandleCommandL(int aCommand
);
78 void HandleWsEventL(const TWsEvent
& aEvent
, CCoeControl
* aDestination
);
79 void HandleResourceChangeL(int aType
);
81 void HandleForegroundEventL(TBool aForeground
);
88 CSDLAppUi::~CSDLAppUi()
95 void CSDLAppUi::ConstructL()
97 BaseConstructL(ENoAppResourceFile
|EAknEnableSkin
);
99 iSDLWin
= new CSDLWin(ApplicationRect());
101 iTicker
= new Ticker
;
103 SetKeyBlockMode(ENoKeyBlock
);
105 iSdl
->SetContainerWindowL(iSDLWin
->GetWindow(), iEikonEnv
->WsSession(), *iEikonEnv
->ScreenDevice());
110 void CSDLAppUi::HandleCommandL(int aCommand
)
114 case EAknSoftkeyBack
:
115 case EAknSoftkeyExit
:
120 event
.SetType(EEventSwitchOff
), event
.SetTimeNow();
121 iSdl
->AppendWsEvent(event
);
130 void CSDLAppUi::HandleWsEventL(const TWsEvent
& aEvent
, CCoeControl
* aDestination
)
132 if(aEvent
.Type() == KAknUidValueEndKeyCloseEvent
)
135 event
.SetType(EEventSwitchOff
), event
.SetTimeNow();
136 iSdl
->AppendWsEvent(event
);
141 iSdl
->AppendWsEvent(aEvent
);
144 CAknAppUi::HandleWsEventL(aEvent
, aDestination
);
147 void CSDLAppUi::HandleResourceChangeL(int aType
)
149 CAknAppUi::HandleResourceChangeL(aType
);
150 if(aType
== KEikDynamicLayoutVariantSwitch
)
152 iSDLWin
->SetRect(ApplicationRect());
153 iSdl
->SetContainerWindowL(iSDLWin
->GetWindow(), iEikonEnv
->WsSession(), *iEikonEnv
->ScreenDevice());
158 void CSDLAppUi::HandleForegroundEventL(TBool aForeground
)
160 CAknAppUi::HandleForegroundEventL(aForeground
);
161 g_SDL
->SetFocus(aForeground
);
164 ////////////////////////////////////////////////////////////////////////////
166 class CSDLDocument
: public CEikDocument
169 CSDLDocument(CEikApplication
& aApp
) : CEikDocument(aApp
) {}
172 CEikAppUi
* CreateAppUiL() { return new CSDLAppUi
; }
175 ////////////////////////////////////////////////////////////////////////
177 class CSDLApplication
: public CAknApplication
183 CApaDocument
* CreateDocumentL() { return new CSDLDocument(*this); }
184 TUid
AppDllUid() const { return iUid
; }
189 CSDLApplication::CSDLApplication()
192 User::LeaveIfError(apa
.Connect());
193 CleanupClosePushL(apa
);
194 User::LeaveIfError(apa
.GetAllApps());
195 TFileName name
= RProcess().FileName();
197 while(apa
.GetNextApp(info
) == KErrNone
)
199 if(info
.iFullName
.CompareF(name
) == 0)
205 CleanupStack::PopAndDestroy();
208 ////////////////////////////////////////////////////////////////////////
210 CApaApplication
* NewApplication()
212 return new CSDLApplication();
217 return EikStart::RunApplication(NewApplication
);