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, CBackedUpWindow* aParent)
00029 {
00030 _LIT(KFontName,"Swiss");
00031
00032
00033 RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup);
00034
00035 iWindow=RWindow(iClient->iWs);
00036 User::LeaveIfError(iWindow.Construct(*parent, (TUint32)this));
00037
00038 iRect = aRect;
00039
00040 User::LeaveIfError(iWindow.SetExtentErr(iRect.iTl, iRect.Size()));
00041
00042 iWindow.SetBackgroundColor (aColor);
00043
00044 iWindow.SetPointerGrab (ETrue);
00045
00046 TFontSpec fontSpec(KFontName,200);
00047 User::LeaveIfError(iClient->iScreen->GetNearestFontInTwips(iFont,fontSpec));
00048
00049 iWindow.Activate();
00050 }
00051
00052 CWindow::~CWindow()
00053 {
00054 iWindow.FreePointerMoveBuffer();
00055 iWindow.Close();
00056 iClient->iScreen->ReleaseFont(iFont);
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
00074 CFont* CWindow::Font()
00075 {
00076 return iFont;
00077 }
00078
00080 CBackedUpWindow::CBackedUpWindow(CWsClient* aClient)
00081 : iClient(aClient)
00082 {
00083 }
00084
00085 void CBackedUpWindow::ConstructL (const TRect& aRect, CWindow* aParent)
00086 {
00087 _LIT(KFontName,"Swiss");
00088
00089
00090 RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup);
00091
00092 iWindow=RBackedUpWindow(iClient->iWs);
00093 User::LeaveIfError(iWindow.Construct(*parent, EGray4, (TUint32)this));
00094
00095 iRect = aRect;
00096
00097 User::LeaveIfError(iWindow.SetExtentErr(iRect.iTl, iRect.Size()));
00098
00099 iWindow.AllocPointerMoveBuffer(KPointerMoveBufferSize, 0);
00100 iWindow.DisablePointerMoveBuffer();
00101 iWindow.PointerFilter(EPointerFilterDrag, 0);
00102
00103 iWindow.SetPointerGrab (ETrue);
00104
00105 TFontSpec fontSpec(KFontName,200);
00106 User::LeaveIfError(iClient->iScreen->GetNearestFontInTwips(iFont,fontSpec));
00107
00108 iWindow.Activate();
00109 }
00110
00111 CBackedUpWindow::~CBackedUpWindow()
00112 {
00113 iWindow.Close();
00114 iClient->iScreen->ReleaseFont(iFont);
00115 }
00116
00117 RBackedUpWindow& CBackedUpWindow::Window()
00118 {
00119 return iWindow;
00120 }
00121
00122 CWindowGc* CBackedUpWindow::SystemGc()
00123 {
00124 return iClient->iGc;
00125 }
00126
00127 CWsScreenDevice* CBackedUpWindow::Screen()
00128 {
00129 return iClient->iScreen;
00130 }
00131
00132 CFont* CBackedUpWindow::Font()
00133 {
00134 return iFont;
00135 }
00136
00137
00139
00141
00142 CWsRedrawer::CWsRedrawer()
00143 : CActive(CActive::EPriorityLow)
00144 {
00145 }
00146
00147 void CWsRedrawer::ConstructL(CWsClient* aClient)
00148 {
00149 iClient=aClient;
00150 CActiveScheduler::Add(this);
00151 IssueRequest();
00152 }
00153
00154 CWsRedrawer::~CWsRedrawer()
00155 {
00156 Cancel();
00157 }
00158
00159 void CWsRedrawer::IssueRequest()
00160 {
00161 iClient->iWs.RedrawReady(&iStatus);
00162 SetActive();
00163 }
00164
00165 void CWsRedrawer::DoCancel()
00166 {
00167 iClient->iWs.RedrawReadyCancel();
00168 }
00169
00170 void CWsRedrawer::RunL()
00171 {
00172
00173 TWsRedrawEvent redrawEvent;
00174 iClient->iWs.GetRedraw(redrawEvent);
00175 CWindow* window=(CWindow*)(redrawEvent.Handle());
00176 if (window)
00177 {
00178 TRect rect=redrawEvent.Rect();
00179
00180 iClient->iGc->Activate(window->Window());
00181 window->Window().BeginRedraw(rect);
00182 window->Draw(rect);
00183 window->Window().EndRedraw();
00184 iClient->iGc->Deactivate();
00185 }
00186
00187 IssueRequest();
00188 }
00189
00190
00192
00194 CWsClient::CWsClient()
00195 : CActive(CActive::EPriorityStandard)
00196 {
00197 }
00198
00199 void CWsClient::ConstructL()
00200 {
00201
00202 CActiveScheduler::Add(this);
00203
00204 User::LeaveIfError(iWs.Connect());
00205
00206 iGroup=RWindowGroup(iWs);
00207 User::LeaveIfError(iGroup.Construct(2,ETrue));
00208
00209 iScreen=new (ELeave) CWsScreenDevice(iWs);
00210 User::LeaveIfError(iScreen->Construct());
00211 User::LeaveIfError(iScreen->CreateContext(iGc));
00212
00213 iRedrawer=new (ELeave) CWsRedrawer;
00214 iRedrawer->ConstructL(this);
00215
00216 ConstructMainWindowL();
00217
00218 IssueRequest();
00219 }
00220
00221 CWsClient::~CWsClient()
00222 {
00223
00224 Deque();
00225
00226 delete iGc;
00227 delete iScreen;
00228 delete iRedrawer;
00229
00230 iGroup.Close();
00231
00232 iWs.Close();
00233 }
00234
00235 void CWsClient::IssueRequest()
00236 {
00237 iWs.EventReady(&iStatus);
00238 SetActive();
00239 }
00240
00241 void CWsClient::DoCancel()
00242 {
00243 iWs.EventReadyCancel();
00244 }
00245
00246 void CWsClient::ConstructMainWindowL()
00247 {
00248 }
00249