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, CWindow* 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 iWindow.SetExtent(iRect.iTl, iRect.Size());
00056
00057 iWindow.SetBackgroundColor (aColor);
00058
00059 TFontSpec fontSpec(KFontName,200);
00060 User::LeaveIfError(iClient->iScreen->GetNearestFontInTwips(iFont,fontSpec));
00061
00062 iWindow.Activate();
00063 }
00064
00065 CWindow::~CWindow()
00066 {
00067 iWindow.Close();
00068 iClient->iScreen->ReleaseFont(iFont);
00069 }
00070
00071 RWindow& CWindow::Window()
00072 {
00073 return iWindow;
00074 }
00075
00076 CWindowGc* CWindow::SystemGc()
00077 {
00078 return iClient->iGc;
00079 }
00080
00081 CWsScreenDevice* CWindow::Screen()
00082 {
00083 return iClient->iScreen;
00084 }
00085
00086 CFont* CWindow::Font()
00087 {
00088 return iFont;
00089 }
00090
00091
00093
00095
00096 CWsRedrawer::CWsRedrawer()
00097 : CActive(CActive::EPriorityLow)
00098 {
00099 }
00100
00101 void CWsRedrawer::ConstructL(CWsClient* aClient)
00102 {
00103 iClient=aClient;
00104 CActiveScheduler::Add(this);
00105 IssueRequest();
00106 }
00107
00108 CWsRedrawer::~CWsRedrawer()
00109 {
00110 Cancel();
00111 }
00112
00113 void CWsRedrawer::IssueRequest()
00114 {
00115 iClient->iWs.RedrawReady(&iStatus);
00116 SetActive();
00117 }
00118
00119 void CWsRedrawer::DoCancel()
00120 {
00121 iClient->iWs.RedrawReadyCancel();
00122 }
00123
00124 void CWsRedrawer::RunL()
00125 {
00126
00127 TWsRedrawEvent redrawEvent;
00128 iClient->iWs.GetRedraw(redrawEvent);
00129 CWindow* window=(CWindow*)(redrawEvent.Handle());
00130 if (window)
00131 {
00132 TRect rect=redrawEvent.Rect();
00133
00134 iClient->iGc->Activate(window->Window());
00135 window->Window().BeginRedraw();
00136 window->Draw(rect);
00137 window->Window().EndRedraw();
00138 iClient->iGc->Deactivate();
00139 }
00140
00141 IssueRequest();
00142 }
00143
00144
00146
00148 CWsClient::CWsClient()
00149 : CActive(CActive::EPriorityStandard)
00150 {
00151 }
00152
00153 void CWsClient::ConstructL()
00154 {
00155
00156 CActiveScheduler::Add(this);
00157
00158 User::LeaveIfError(iWs.Connect());
00159
00160 iGroup=RWindowGroup(iWs);
00161 User::LeaveIfError(iGroup.Construct(2,ETrue));
00162
00163 iScreen=new (ELeave) CWsScreenDevice(iWs);
00164 User::LeaveIfError(iScreen->Construct());
00165 User::LeaveIfError(iScreen->CreateContext(iGc));
00166
00167 iRedrawer=new (ELeave) CWsRedrawer;
00168 iRedrawer->ConstructL(this);
00169
00170 ConstructMainWindowL();
00171
00172 IssueRequest();
00173 }
00174
00175 CWsClient::~CWsClient()
00176 {
00177
00178 Deque();
00179
00180 delete iGc;
00181 delete iScreen;
00182 delete iRedrawer;
00183
00184 iGroup.Close();
00185
00186 iWs.Close();
00187 }
00188
00189 void CWsClient::IssueRequest()
00190 {
00191 iWs.EventReady(&iStatus);
00192 SetActive();
00193 }
00194
00195 void CWsClient::DoCancel()
00196 {
00197 iWs.EventReadyCancel();
00198 }
00199
00200 void CWsClient::ConstructMainWindowL()
00201 {
00202 }
00203