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