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