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