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