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