00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include <w32std.h>
00018 #include "Base.h"
00019
00021
00023
00024 CWindow::CWindow(CWsClient* aClient)
00025 : iClient(aClient)
00026 {
00027 }
00028
00029 void CWindow::ConstructL (const TRect& aRect, const TRgb& aColor, CWindow* aParent)
00030 {
00031 _LIT(KFontName,"Swiss");
00032
00033
00034 RWindowTreeNode* parent= aParent ? (RWindowTreeNode*) &(aParent->Window()) : &(iClient->iGroup);
00035
00036 iWindow=RWindow(iClient->iWs);
00037 User::LeaveIfError(iWindow.Construct(*parent,(TUint32)this));
00038
00039 iRect = aRect;
00040
00041 iWindow.SetExtent(iRect.iTl, iRect.Size());
00042
00043 iWindow.SetBackgroundColor (aColor);
00044
00045 TFontSpec fontSpec(KFontName,200);
00046 User::LeaveIfError(iClient->iScreen->GetNearestFontInTwips(iFont,fontSpec));
00047
00048 iWindow.Activate();
00049 }
00050
00051 CWindow::~CWindow()
00052 {
00053 iWindow.Close();
00054 iClient->iScreen->ReleaseFont(iFont);
00055 }
00056
00057 RWindow& CWindow::Window()
00058 {
00059 return iWindow;
00060 }
00061
00062 CWindowGc* CWindow::SystemGc()
00063 {
00064 return iClient->iGc;
00065 }
00066
00067 CWsScreenDevice* CWindow::Screen()
00068 {
00069 return iClient->iScreen;
00070 }
00071
00072 CFont* CWindow::Font()
00073 {
00074 return iFont;
00075 }
00076
00077
00079
00081
00082 CWsRedrawer::CWsRedrawer()
00083 : CActive(CActive::EPriorityLow)
00084 {
00085 }
00086
00087 void CWsRedrawer::ConstructL(CWsClient* aClient)
00088 {
00089 iClient=aClient;
00090 CActiveScheduler::Add(this);
00091 IssueRequest();
00092 }
00093
00094 CWsRedrawer::~CWsRedrawer()
00095 {
00096 Cancel();
00097 }
00098
00099 void CWsRedrawer::IssueRequest()
00100 {
00101 iClient->iWs.RedrawReady(&iStatus);
00102 SetActive();
00103 }
00104
00105 void CWsRedrawer::DoCancel()
00106 {
00107 iClient->iWs.RedrawReadyCancel();
00108 }
00109
00110 void CWsRedrawer::RunL()
00111 {
00112
00113 TWsRedrawEvent redrawEvent;
00114 iClient->iWs.GetRedraw(redrawEvent);
00115 CWindow* window=(CWindow*)(redrawEvent.Handle());
00116 if (window)
00117 {
00118 TRect rect=redrawEvent.Rect();
00119
00120 iClient->iGc->Activate(window->Window());
00121 window->Window().BeginRedraw();
00122 window->Draw(rect);
00123 window->Window().EndRedraw();
00124 iClient->iGc->Deactivate();
00125 }
00126
00127 IssueRequest();
00128 }
00129
00130
00132
00134 CWsClient::CWsClient()
00135 : CActive(CActive::EPriorityStandard)
00136 {
00137 }
00138
00139 void CWsClient::ConstructL()
00140 {
00141
00142 CActiveScheduler::Add(this);
00143
00144 User::LeaveIfError(iWs.Connect());
00145
00146 iGroup=RWindowGroup(iWs);
00147 User::LeaveIfError(iGroup.Construct(2,ETrue));
00148
00149 iScreen=new (ELeave) CWsScreenDevice(iWs);
00150 User::LeaveIfError(iScreen->Construct());
00151 User::LeaveIfError(iScreen->CreateContext(iGc));
00152
00153 iRedrawer=new (ELeave) CWsRedrawer;
00154 iRedrawer->ConstructL(this);
00155
00156 ConstructMainWindowL();
00157
00158 IssueRequest();
00159 }
00160
00161 CWsClient::~CWsClient()
00162 {
00163
00164 Deque();
00165
00166 delete iGc;
00167 delete iScreen;
00168 delete iRedrawer;
00169
00170 iGroup.Close();
00171
00172 iWs.Close();
00173 }
00174
00175 void CWsClient::IssueRequest()
00176 {
00177 iWs.EventReady(&iStatus);
00178 SetActive();
00179 }
00180
00181 void CWsClient::DoCancel()
00182 {
00183 iWs.EventReadyCancel();
00184 }
00185
00186 void CWsClient::ConstructMainWindowL()
00187 {
00188 }
00189