00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #include <w32std.h>
00019 #include "Base.h"
00020 #include "PointerMoveBuffer.h"
00021
00022
00023
00025
00027
00028
00029
00030
00031
00032
00033 CMainWindow::CMainWindow (CWsClient* aClient)
00034 : CWindow (aClient)
00035 {
00036 }
00037
00038
00039 CMainWindow::~CMainWindow ()
00040 {
00041 iWindow.Close();
00042 }
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 void CMainWindow::Draw(const TRect& aRect)
00053 {
00054 CWindowGc* gc=SystemGc();
00055 gc->SetClippingRect(aRect);
00056 gc->Clear(aRect);
00057 }
00058
00059
00060
00061
00062
00063 void CMainWindow::HandlePointerMoveBufferReady ()
00064 {
00065 TPoint pnts[KPointerMoveBufferSize];
00066 TPtr8 ptr((TUint8 *)&pnts,sizeof(pnts));
00067 TInt numPnts=Window().RetrievePointerMoveBuffer(ptr);
00068 TSize size = Window().Size();
00069 TPoint position = Window().Position();
00070 TRect redrawRect (position, size);
00071 CWindowGc* gc=SystemGc();
00072 gc->Activate(Window());
00073 Window().Invalidate();
00074 Window().BeginRedraw(redrawRect);
00075
00076 for(TInt index=0;index<numPnts;index++) gc->DrawLineTo(pnts[index]);
00077 Window().EndRedraw();
00078 gc->Deactivate();
00079 }
00080
00081
00082
00083
00084
00085
00086
00087
00088 void CMainWindow::HandlePointerEvent (TPointerEvent& aPointerEvent)
00089 {
00090 switch (aPointerEvent.iType)
00091 {
00092 case TPointerEvent::EButton1Down:
00093 {
00094 if (aPointerEvent.iModifiers&EModifierShift)
00095 {
00096 Window().EnablePointerMoveBuffer();
00097 CWindowGc* gc = SystemGc();
00098 gc->Activate(Window());
00099 gc->MoveTo(aPointerEvent.iPosition);
00100 gc->Deactivate();
00101 }
00102 break;
00103 }
00104 case TPointerEvent::EButton1Up:
00105 {
00106 Window().DisablePointerMoveBuffer();
00107 break;
00108 }
00109 default:
00110 break;
00111 }
00112 }
00113
00114
00116
00118
00119 CExampleWsClient* CExampleWsClient::NewL(const TRect& aRect)
00120 {
00121
00122 CExampleWsClient* client=new (ELeave) CExampleWsClient(aRect);
00123 CleanupStack::PushL(client);
00124 client->ConstructL();
00125 CleanupStack::Pop();
00126 return client;
00127 }
00128
00129
00130
00131
00132
00133
00134
00135 CExampleWsClient::CExampleWsClient(const TRect& aRect)
00136 :iRect(aRect)
00137 {
00138 }
00139
00140 CExampleWsClient::~CExampleWsClient ()
00141 {
00142 delete iMainWindow;
00143 }
00144
00145
00146
00147
00148
00149
00150
00151
00152
00153 void CExampleWsClient::ConstructMainWindowL()
00154 {
00155
00156 iMainWindow=new (ELeave) CMainWindow(this);
00157 iMainWindow->ConstructL(iRect, TRgb (255,255,255));
00158 }
00159
00160
00161
00162
00163
00164 void CExampleWsClient::HandleKeyEventL (TKeyEvent& )
00165 {
00166 }
00167
00168
00169
00170
00171
00172
00173
00174
00175
00176
00177 void CExampleWsClient::RunL()
00178 {
00179
00180 iWs.GetEvent(iWsEvent);
00181 TInt eventType=iWsEvent.Type();
00182
00183 switch (eventType)
00184 {
00185
00186 case EEventNull:
00187 case EEventKey:
00188 case EEventModifiersChanged:
00189 case EEventKeyUp:
00190 case EEventKeyDown:
00191 case EEventFocusLost:
00192 case EEventFocusGained:
00193 case EEventSwitchOn:
00194 case EEventPassword:
00195 case EEventWindowGroupsChanged:
00196 case EEventErrorMessage:
00197 break;
00198
00199 case EEventPointer:
00200 {
00201 CWindow* window=(CWindow*)(iWsEvent.Handle());
00202 TPointerEvent& pointerEvent=*iWsEvent.Pointer();
00203 window->HandlePointerEvent (pointerEvent);
00204 break;
00205 }
00206 case EEventPointerExit:
00207 case EEventPointerEnter:
00208 break;
00209 case EEventPointerBufferReady:
00210 {
00211 CWindow* window=(CWindow*)(iWsEvent.Handle());
00212 window->HandlePointerMoveBufferReady ();
00213 break;
00214 }
00215 case EEventDragDrop:
00216 break;
00217 default:
00218 break;
00219 }
00220 IssueRequest();
00221 }