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
00037
00038 CWindow::CWindow(CWsClient* aClient)
00039 : iClient(aClient)
00040 {
00041 }
00042
00043 void CWindow::ConstructL (const TRect& aRect, CWindow* aParent)
00044 {
00045
00046
00047 RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup);
00048 iWindow=RWindow(iClient->iWs);
00049 User::LeaveIfError(iWindow.Construct(*parent,(TUint32)this));
00050 iRect = aRect;
00051 iWindow.SetExtent(iRect.iTl, iRect.Size());
00052 iWindow.Activate();
00053 }
00054
00055
00056 CWindow::~CWindow()
00057 {
00058 iWindow.Close();
00059 }
00060
00061 RWindow& CWindow::Window()
00062 {
00063 return iWindow;
00064 }
00065
00066 CWindowGc* CWindow::SystemGc()
00067 {
00068 return iClient->iGc;
00069 }
00070
00071
00075
00076 CWsRedrawer::CWsRedrawer()
00077 : CActive(CActive::EPriorityLow)
00078 {
00079 }
00080
00081 void CWsRedrawer::ConstructL(CWsClient* aClient)
00082 {
00083 iClient=aClient;
00084 CActiveScheduler::Add(this);
00085 IssueRequest();
00086 }
00087
00088 CWsRedrawer::~CWsRedrawer()
00089 {
00090 Cancel();
00091 }
00092
00093 void CWsRedrawer::IssueRequest()
00094 {
00095 iClient->iWs.RedrawReady(&iStatus);
00096 SetActive();
00097 }
00098
00099 void CWsRedrawer::DoCancel()
00100 {
00101 iClient->iWs.RedrawReadyCancel();
00102 }
00103
00104 void CWsRedrawer::RunL()
00105 {
00106
00107 TWsRedrawEvent redrawEvent;
00108 iClient->iWs.GetRedraw(redrawEvent);
00109 CWindow* window=(CWindow*)(redrawEvent.Handle());
00110 if (window)
00111 {
00112 TRect rect=redrawEvent.Rect();
00113
00114 iClient->iGc->Activate(window->Window());
00115 window->Window().BeginRedraw(rect);
00116 window->Draw(rect);
00117 window->Window().EndRedraw();
00118 iClient->iGc->Deactivate();
00119 }
00120
00121 IssueRequest();
00122 }
00123
00124
00128 CWsClient::CWsClient()
00129 : CActive(CActive::EPriorityHigh)
00130 {
00131 }
00132
00133 void CWsClient::ConstructL()
00134 {
00135
00136 CActiveScheduler::Add(this);
00137
00138 User::LeaveIfError(iWs.Connect());
00139
00140 iGroup=RWindowGroup(iWs);
00141 User::LeaveIfError(iGroup.Construct(2,ETrue));
00142
00143 iScreen=new (ELeave) CWsScreenDevice(iWs);
00144 User::LeaveIfError(iScreen->Construct());
00145 User::LeaveIfError(iScreen->CreateContext(iGc));
00146
00147 iRedrawer=new (ELeave) CWsRedrawer;
00148 iRedrawer->ConstructL(this);
00149
00150 ConstructMainWindowL();
00151
00152 IssueRequest();
00153 }
00154
00155 CWsClient::~CWsClient()
00156 {
00157
00158 Deque();
00159
00160 delete iGc;
00161 delete iScreen;
00162 delete iRedrawer;
00163
00164 iGroup.Close();
00165
00166 iWs.Close();
00167 }
00168
00169 void CWsClient::IssueRequest()
00170 {
00171 iWs.EventReady(&iStatus);
00172 SetActive();
00173 }
00174
00175 void CWsClient::DoCancel()
00176 {
00177 iWs.EventReadyCancel();
00178 }
00179
00180 void CWsClient::ConstructMainWindowL()
00181 {
00182 }
00183