00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #include <w32std.h>
00032 #include "Base.h"
00033
00035
00037
00038 CWindow::CWindow(CWsClient* aClient)
00039 : iClient(aClient)
00040 {
00041 }
00042
00043 void CWindow::ConstructL (const TRect& aRect, const TRgb& aColor, CWindow* aParent)
00044 {
00045
00046
00047 RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup);
00048
00049 iWindow=RWindow(iClient->iWs);
00050 User::LeaveIfError(iWindow.Construct(*parent,(TUint32)this));
00051
00052 iRect = aRect;
00053
00054 iWindow.SetExtent(iRect.iTl, iRect.Size());
00055
00056 iWindow.SetBackgroundColor (aColor);
00057
00058 iWindow.SetPointerGrab (ETrue);
00059
00060 iWindow.AllocPointerMoveBuffer(KPointerMoveBufferSize, 0);
00061 iWindow.DisablePointerMoveBuffer();
00062
00063 iWindow.PointerFilter(EPointerFilterDrag, 0);
00064
00065 iWindow.Activate();
00066 }
00067
00068 CWindow::~CWindow()
00069 {
00070 iWindow.FreePointerMoveBuffer();
00071 iWindow.Close();
00072 }
00073
00074 RWindow& CWindow::Window()
00075 {
00076 return iWindow;
00077 }
00078
00079 CWindowGc* CWindow::SystemGc()
00080 {
00081 return iClient->iGc;
00082 }
00083
00084 CWsScreenDevice* CWindow::Screen()
00085 {
00086 return iClient->iScreen;
00087 }
00088
00090
00092
00093 CWsRedrawer::CWsRedrawer()
00094 : CActive(CActive::EPriorityLow)
00095 {
00096 }
00097
00098 void CWsRedrawer::ConstructL(CWsClient* aClient)
00099 {
00100 iClient=aClient;
00101 CActiveScheduler::Add(this);
00102 IssueRequest();
00103 }
00104
00105 CWsRedrawer::~CWsRedrawer()
00106 {
00107 Cancel();
00108 }
00109
00110 void CWsRedrawer::IssueRequest()
00111 {
00112 iClient->iWs.RedrawReady(&iStatus);
00113 SetActive();
00114 }
00115
00116 void CWsRedrawer::DoCancel()
00117 {
00118 iClient->iWs.RedrawReadyCancel();
00119 }
00120
00121 void CWsRedrawer::RunL()
00122 {
00123
00124 TWsRedrawEvent redrawEvent;
00125 iClient->iWs.GetRedraw(redrawEvent);
00126 CWindow* window=(CWindow*)(redrawEvent.Handle());
00127 if (window)
00128 {
00129 TRect rect=redrawEvent.Rect();
00130
00131 iClient->iGc->Activate(window->Window());
00132 window->Window().BeginRedraw();
00133 window->Draw(rect);
00134 window->Window().EndRedraw();
00135 iClient->iGc->Deactivate();
00136 }
00137
00138 IssueRequest();
00139 }
00140
00141
00143
00145 CWsClient::CWsClient()
00146 : CActive(CActive::EPriorityStandard)
00147 {
00148 }
00149
00150 void CWsClient::ConstructL()
00151 {
00152
00153 CActiveScheduler::Add(this);
00154
00155 User::LeaveIfError(iWs.Connect());
00156
00157 iGroup=RWindowGroup(iWs);
00158 User::LeaveIfError(iGroup.Construct(2,ETrue));
00159
00160 iScreen=new (ELeave) CWsScreenDevice(iWs);
00161 User::LeaveIfError(iScreen->Construct());
00162 User::LeaveIfError(iScreen->CreateContext(iGc));
00163
00164 iRedrawer=new (ELeave) CWsRedrawer;
00165 iRedrawer->ConstructL(this);
00166
00167 ConstructMainWindowL();
00168
00169 IssueRequest();
00170 }
00171
00172 CWsClient::~CWsClient()
00173 {
00174
00175 Deque();
00176
00177 delete iGc;
00178 delete iScreen;
00179 delete iRedrawer;
00180
00181 iGroup.Close();
00182
00183 iWs.Close();
00184 }
00185
00186 void CWsClient::IssueRequest()
00187 {
00188 iWs.EventReady(&iStatus);
00189 SetActive();
00190 }
00191
00192 void CWsClient::DoCancel()
00193 {
00194 iWs.EventReadyCancel();
00195 }
00196
00197 void CWsClient::ConstructMainWindowL()
00198 {
00199 }
00200