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