Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(185)

Side by Side Diff: fpdfsdk/src/pdfwindow/PWL_Wnd.cpp

Issue 1265503005: clang-format all pdfium code. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: sigh Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include <map> 7 #include <map>
8 8
9 #include "../../include/pdfwindow/PDFWindow.h" 9 #include "../../include/pdfwindow/PDFWindow.h"
10 #include "../../include/pdfwindow/PWL_Wnd.h" 10 #include "../../include/pdfwindow/PWL_Wnd.h"
11 #include "../../include/pdfwindow/PWL_Utils.h" 11 #include "../../include/pdfwindow/PWL_Utils.h"
12 #include "../../include/pdfwindow/PWL_ScrollBar.h" 12 #include "../../include/pdfwindow/PWL_ScrollBar.h"
13 13
14 /* -------------------------- CPWL_Timer -------------------------- */ 14 /* -------------------------- CPWL_Timer -------------------------- */
15 15
16 static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() 16 static std::map<int32_t, CPWL_Timer*>& GetPWLTimeMap() {
17 {
18 // Leak the object at shutdown. 17 // Leak the object at shutdown.
19 static auto timeMap = new std::map<int32_t, CPWL_Timer*>; 18 static auto timeMap = new std::map<int32_t, CPWL_Timer*>;
20 return *timeMap; 19 return *timeMap;
21 } 20 }
22 21
23 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemH andler) : 22 CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached,
24 m_nTimerID(0), 23 IFX_SystemHandler* pSystemHandler)
25 m_pAttached(pAttached), 24 : m_nTimerID(0), m_pAttached(pAttached), m_pSystemHandler(pSystemHandler) {
26 m_pSystemHandler(pSystemHandler) 25 ASSERT(m_pAttached != NULL);
27 { 26 ASSERT(m_pSystemHandler != NULL);
28 ASSERT(m_pAttached != NULL); 27 }
29 ASSERT(m_pSystemHandler != NULL); 28
30 } 29 CPWL_Timer::~CPWL_Timer() {
31 30 KillPWLTimer();
32 CPWL_Timer::~CPWL_Timer() 31 }
33 { 32
33 int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) {
34 if (m_nTimerID != 0)
34 KillPWLTimer(); 35 KillPWLTimer();
35 } 36 m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
36 37
37 int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse) 38 GetPWLTimeMap()[m_nTimerID] = this;
38 { 39 return m_nTimerID;
39 if (m_nTimerID != 0) 40 }
40 KillPWLTimer(); 41
41 m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc); 42 void CPWL_Timer::KillPWLTimer() {
42 43 if (m_nTimerID == 0)
43 GetPWLTimeMap()[m_nTimerID] = this; 44 return;
44 return m_nTimerID; 45
45 } 46 m_pSystemHandler->KillTimer(m_nTimerID);
46 47 GetPWLTimeMap().erase(m_nTimerID);
47 void CPWL_Timer::KillPWLTimer() 48 m_nTimerID = 0;
48 { 49 }
49 if (m_nTimerID == 0) 50
50 return; 51 void CPWL_Timer::TimerProc(int32_t idEvent) {
51 52 auto it = GetPWLTimeMap().find(idEvent);
52 m_pSystemHandler->KillTimer(m_nTimerID); 53 if (it == GetPWLTimeMap().end())
53 GetPWLTimeMap().erase(m_nTimerID); 54 return;
54 m_nTimerID = 0; 55
55 } 56 CPWL_Timer* pTimer = it->second;
56 57 if (pTimer->m_pAttached)
57 void CPWL_Timer::TimerProc(int32_t idEvent) 58 pTimer->m_pAttached->TimerProc();
58 {
59 auto it = GetPWLTimeMap().find(idEvent);
60 if (it == GetPWLTimeMap().end())
61 return;
62
63 CPWL_Timer* pTimer = it->second;
64 if (pTimer->m_pAttached)
65 pTimer->m_pAttached->TimerProc();
66 } 59 }
67 60
68 /* -------------------------- CPWL_TimerHandler -------------------------- */ 61 /* -------------------------- CPWL_TimerHandler -------------------------- */
69 62
70 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) 63 CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL) {}
71 { 64
72 } 65 CPWL_TimerHandler::~CPWL_TimerHandler() {
73 66 delete m_pTimer;
74 CPWL_TimerHandler::~CPWL_TimerHandler() 67 }
75 { 68
76 delete m_pTimer; 69 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) {
77 } 70 if (!m_pTimer)
78 71 m_pTimer = new CPWL_Timer(this, GetSystemHandler());
79 void CPWL_TimerHandler::BeginTimer(int32_t nElapse) 72
80 { 73 if (m_pTimer)
81 if (!m_pTimer) 74 m_pTimer->SetPWLTimer(nElapse);
82 m_pTimer = new CPWL_Timer(this, GetSystemHandler()); 75 }
83 76
84 if (m_pTimer) 77 void CPWL_TimerHandler::EndTimer() {
85 m_pTimer->SetPWLTimer(nElapse); 78 if (m_pTimer)
86 } 79 m_pTimer->KillPWLTimer();
87 80 }
88 void CPWL_TimerHandler::EndTimer() 81
89 { 82 void CPWL_TimerHandler::TimerProc() {}
90 if (m_pTimer)
91 m_pTimer->KillPWLTimer();
92 }
93
94 void CPWL_TimerHandler::TimerProc()
95 {
96 }
97 83
98 /* --------------------------- CPWL_MsgControl ---------------------------- */ 84 /* --------------------------- CPWL_MsgControl ---------------------------- */
99 85
100 class CPWL_MsgControl 86 class CPWL_MsgControl {
101 { 87 friend class CPWL_Wnd;
102 friend class CPWL_Wnd; 88
103 89 public:
104 public: 90 CPWL_MsgControl(CPWL_Wnd* pWnd) {
105 CPWL_MsgControl(CPWL_Wnd * pWnd) 91 // PWL_TRACE("new CPWL_MsgControl\n");
106 { 92 m_pCreatedWnd = pWnd;
107 // PWL_TRACE("new CPWL_MsgControl\n"); 93 Default();
108 m_pCreatedWnd = pWnd; 94 }
109 Default(); 95
110 } 96 ~CPWL_MsgControl() {
111 97 // PWL_TRACE("~CPWL_MsgControl\n");
112 ~CPWL_MsgControl() 98 Default();
113 { 99 }
114 // PWL_TRACE("~CPWL_MsgControl\n"); 100
115 Default(); 101 void Default() {
116 } 102 m_aMousePath.RemoveAll();
117 103 m_aKeyboardPath.RemoveAll();
118 void Default() 104 m_pMainMouseWnd = NULL;
119 { 105 m_pMainKeyboardWnd = NULL;
120 m_aMousePath.RemoveAll(); 106 }
121 m_aKeyboardPath.RemoveAll(); 107
122 m_pMainMouseWnd = NULL; 108 FX_BOOL IsWndCreated(const CPWL_Wnd* pWnd) const {
123 m_pMainKeyboardWnd = NULL; 109 return m_pCreatedWnd == pWnd;
124 } 110 }
125 111
126 FX_BOOL IsWndCreated(const CPWL_Wnd * pWnd) const 112 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd* pWnd) const {
127 { 113 return pWnd == m_pMainMouseWnd;
128 return m_pCreatedWnd == pWnd; 114 }
129 } 115
130 116 FX_BOOL IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
131 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd * pWnd) const 117 if (pWnd)
132 { 118 for (int32_t i = 0, sz = m_aMousePath.GetSize(); i < sz; i++)
133 return pWnd == m_pMainMouseWnd; 119 if (m_aMousePath.GetAt(i) == pWnd)
134 } 120 return TRUE;
135 121
136 FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const 122 return FALSE;
137 { 123 }
138 if (pWnd) 124
139 for( int32_t i=0,sz=m_aMousePath.GetSize(); i<sz; i++) 125 FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd* pWnd) const {
140 if (m_aMousePath.GetAt(i) == pWnd) 126 return pWnd == m_pMainKeyboardWnd;
141 return TRUE; 127 }
142 128
143 return FALSE; 129 FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
144 } 130 if (pWnd)
145 131 for (int32_t i = 0, sz = m_aKeyboardPath.GetSize(); i < sz; i++)
146 FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd * pWnd) const 132 if (m_aKeyboardPath.GetAt(i) == pWnd)
147 { 133 return TRUE;
148 return pWnd == m_pMainKeyboardWnd; 134
149 } 135 return FALSE;
150 136 }
151 137
152 FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const 138 void SetFocus(CPWL_Wnd* pWnd) {
153 { 139 m_aKeyboardPath.RemoveAll();
154 if (pWnd) 140
155 for( int32_t i=0,sz=m_aKeyboardPath.GetSize(); i<sz; i++) 141 if (pWnd) {
156 if (m_aKeyboardPath.GetAt(i) == pWnd) 142 m_pMainKeyboardWnd = pWnd;
157 return TRUE; 143
158 144 CPWL_Wnd* pParent = pWnd;
159 return FALSE; 145 while (pParent) {
160 } 146 m_aKeyboardPath.Add(pParent);
161 147 pParent = pParent->GetParentWindow();
162 void SetFocus(CPWL_Wnd * pWnd) 148 }
163 { 149
164 m_aKeyboardPath.RemoveAll(); 150 pWnd->OnSetFocus();
165 151 }
166 if (pWnd) 152 }
167 { 153
168 m_pMainKeyboardWnd = pWnd; 154 void KillFocus() {
169 155 if (m_aKeyboardPath.GetSize() > 0)
170 CPWL_Wnd * pParent = pWnd; 156 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
171 while (pParent) 157 pWnd->OnKillFocus();
172 { 158
173 m_aKeyboardPath.Add(pParent); 159 m_pMainKeyboardWnd = NULL;
174 pParent = pParent->GetParentWindow(); 160 m_aKeyboardPath.RemoveAll();
175 } 161 }
176 162
177 pWnd->OnSetFocus(); 163 void SetCapture(CPWL_Wnd* pWnd) {
178 } 164 m_aMousePath.RemoveAll();
179 } 165
180 166 if (pWnd) {
181 void KillFocus() 167 m_pMainMouseWnd = pWnd;
182 { 168
183 if (m_aKeyboardPath.GetSize() > 0) 169 CPWL_Wnd* pParent = pWnd;
184 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0)) 170 while (pParent) {
185 pWnd->OnKillFocus(); 171 m_aMousePath.Add(pParent);
186 172 pParent = pParent->GetParentWindow();
187 m_pMainKeyboardWnd = NULL; 173 }
188 m_aKeyboardPath.RemoveAll(); 174 }
189 } 175 }
190 176
191 void SetCapture(CPWL_Wnd * pWnd) 177 void ReleaseCapture() {
192 { 178 m_pMainMouseWnd = NULL;
193 m_aMousePath.RemoveAll(); 179 m_aMousePath.RemoveAll();
194 180 }
195 if (pWnd) 181
196 { 182 private:
197 m_pMainMouseWnd = pWnd; 183 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
198 184 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
199 CPWL_Wnd * pParent = pWnd; 185 CPWL_Wnd* m_pCreatedWnd;
200 while (pParent) 186 CPWL_Wnd* m_pMainMouseWnd;
201 { 187 CPWL_Wnd* m_pMainKeyboardWnd;
202 m_aMousePath.Add(pParent);
203 pParent = pParent->GetParentWindow();
204 }
205 }
206 }
207
208 void ReleaseCapture()
209 {
210 m_pMainMouseWnd = NULL;
211 m_aMousePath.RemoveAll();
212 }
213
214 private:
215 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
216 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
217 CPWL_Wnd* m_pCreatedWnd;
218 CPWL_Wnd* m_pMainMouseWnd;
219 CPWL_Wnd* m_pMainKeyboardWnd;
220 }; 188 };
221 189
222 /* --------------------------- CPWL_Wnd ---------------------------- */ 190 /* --------------------------- CPWL_Wnd ---------------------------- */
223 191
224 CPWL_Wnd::CPWL_Wnd() : 192 CPWL_Wnd::CPWL_Wnd()
225 m_pVScrollBar(NULL), 193 : m_pVScrollBar(NULL),
226 m_rcWindow(), 194 m_rcWindow(),
227 m_rcClip(), 195 m_rcClip(),
228 m_bCreated(FALSE), 196 m_bCreated(FALSE),
229 m_bVisible(FALSE), 197 m_bVisible(FALSE),
230 m_bNotifying(FALSE), 198 m_bNotifying(FALSE),
231 m_bEnabled(TRUE) 199 m_bEnabled(TRUE) {}
232 { 200
233 } 201 CPWL_Wnd::~CPWL_Wnd() {
234 202 ASSERT(m_bCreated == FALSE);
235 CPWL_Wnd::~CPWL_Wnd() 203 }
236 { 204
237 ASSERT(m_bCreated == FALSE); 205 CFX_ByteString CPWL_Wnd::GetClassName() const {
238 } 206 return "CPWL_Wnd";
239 207 }
240 CFX_ByteString CPWL_Wnd::GetClassName() const 208
241 { 209 void CPWL_Wnd::Create(const PWL_CREATEPARAM& cp) {
242 return "CPWL_Wnd"; 210 if (!IsValid()) {
243 } 211 m_sPrivateParam = cp;
244 212
245 void CPWL_Wnd::Create(const PWL_CREATEPARAM & cp) 213 OnCreate(m_sPrivateParam);
246 { 214
247 if (!IsValid()) 215 m_sPrivateParam.rcRectWnd.Normalize();
248 { 216 m_rcWindow = m_sPrivateParam.rcRectWnd;
249 m_sPrivateParam = cp; 217 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow, 1.0f);
250 218
251 OnCreate(m_sPrivateParam); 219 CreateMsgControl();
252 220
253 m_sPrivateParam.rcRectWnd.Normalize(); 221 if (m_sPrivateParam.pParentWnd)
254 m_rcWindow = m_sPrivateParam.rcRectWnd; 222 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
255 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f); 223
256 224 PWL_CREATEPARAM ccp = m_sPrivateParam;
257 CreateMsgControl(); 225
258 226 ccp.dwFlags &= 0xFFFF0000L; // remove sub styles
259 if (m_sPrivateParam.pParentWnd) 227 ccp.mtChild = CPDF_Matrix(1, 0, 0, 1, 0, 0);
260 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD); 228
261 229 CreateScrollBar(ccp);
262 PWL_CREATEPARAM ccp = m_sPrivateParam; 230 CreateChildWnd(ccp);
263 231
264 ccp.dwFlags &= 0xFFFF0000L; //remove sub styles 232 m_bVisible = HasFlag(PWS_VISIBLE);
265 ccp.mtChild = CPDF_Matrix(1,0,0,1,0,0); 233
266 234 OnCreated();
267 CreateScrollBar(ccp); 235
268 CreateChildWnd(ccp); 236 RePosChildWnd();
269 237 m_bCreated = TRUE;
270 m_bVisible = HasFlag(PWS_VISIBLE); 238 }
271 239 }
272 OnCreated(); 240
273 241 void CPWL_Wnd::OnCreate(PWL_CREATEPARAM& cp) {}
242
243 void CPWL_Wnd::OnCreated() {}
244
245 void CPWL_Wnd::OnDestroy() {}
246
247 void CPWL_Wnd::Destroy() {
248 KillFocus();
249
250 OnDestroy();
251
252 if (m_bCreated) {
253 for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
254 if (CPWL_Wnd* pChild = m_aChildren[i]) {
255 pChild->Destroy();
256 delete pChild;
257 pChild = NULL;
258 }
259 }
260
261 if (m_sPrivateParam.pParentWnd)
262 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
263 m_bCreated = FALSE;
264 }
265
266 DestroyMsgControl();
267
268 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
269 m_aChildren.RemoveAll();
270 m_pVScrollBar = NULL;
271 }
272
273 void CPWL_Wnd::Move(const CPDF_Rect& rcNew, FX_BOOL bReset, FX_BOOL bRefresh) {
274 if (IsValid()) {
275 CPDF_Rect rcOld = GetWindowRect();
276
277 m_rcWindow = rcNew;
278 m_rcWindow.Normalize();
279
280 if (rcOld.left != rcNew.left || rcOld.right != rcNew.right ||
281 rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) {
282 if (bReset) {
274 RePosChildWnd(); 283 RePosChildWnd();
275 m_bCreated = TRUE; 284 }
276 } 285 }
277 } 286 if (bRefresh) {
278 287 InvalidateRectMove(rcOld, rcNew);
279 void CPWL_Wnd::OnCreate(PWL_CREATEPARAM & cp) 288 }
280 { 289
281 } 290 m_sPrivateParam.rcRectWnd = m_rcWindow;
282 291 }
283 void CPWL_Wnd::OnCreated() 292 }
284 { 293
285 } 294 void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect& rcOld,
286 295 const CPDF_Rect& rcNew) {
287 void CPWL_Wnd::OnDestroy() 296 CPDF_Rect rcUnion = rcOld;
288 { 297 rcUnion.Union(rcNew);
289 } 298
290 299 InvalidateRect(&rcUnion);
291 void CPWL_Wnd::Destroy() 300 }
292 { 301
293 KillFocus(); 302 void CPWL_Wnd::GetAppearanceStream(CFX_ByteString& sAppStream) {
294 303 if (IsValid()) {
295 OnDestroy(); 304 CFX_ByteTextBuf sTextBuf;
296 305 GetAppearanceStream(sTextBuf);
297 if (m_bCreated) 306 sAppStream += sTextBuf.GetByteString();
298 { 307 }
299 for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --) 308 }
300 { 309
301 if (CPWL_Wnd * pChild = m_aChildren[i]) 310 void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf& sAppStream) {
302 { 311 if (IsValid() && IsVisible()) {
303 pChild->Destroy(); 312 GetThisAppearanceStream(sAppStream);
304 delete pChild; 313 GetChildAppearanceStream(sAppStream);
305 pChild = NULL; 314 }
306 } 315 }
307 } 316
308 317 // if don't set,Get default apperance stream
309 if (m_sPrivateParam.pParentWnd) 318 void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf& sAppStream) {
310 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD); 319 CPDF_Rect rectWnd = GetWindowRect();
311 m_bCreated = FALSE; 320 if (!rectWnd.IsEmpty()) {
312 } 321 CFX_ByteTextBuf sThis;
313 322
314 DestroyMsgControl(); 323 if (HasFlag(PWS_BACKGROUND))
315 324 sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor());
316 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM)); 325
317 m_aChildren.RemoveAll(); 326 if (HasFlag(PWS_BORDER)) {
318 m_pVScrollBar = NULL; 327 sThis << CPWL_Utils::GetBorderAppStream(
319 } 328 rectWnd, (FX_FLOAT)GetBorderWidth(), GetBorderColor(),
320 329 GetBorderLeftTopColor(GetBorderStyle()),
321 void CPWL_Wnd::Move(const CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh) 330 GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
322 { 331 GetBorderDash());
323 if (IsValid()) 332 }
324 { 333
325 CPDF_Rect rcOld = GetWindowRect(); 334 sAppStream << sThis;
326 335 }
327 m_rcWindow = rcNew; 336 }
328 m_rcWindow.Normalize(); 337
329 338 void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf& sAppStream) {
330 if (rcOld.left != rcNew.left || rcOld.right != rcNew.right || 339 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
331 rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom) 340 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
332 { 341 pChild->GetAppearanceStream(sAppStream);
333 if (bReset) 342 }
334 { 343 }
335 RePosChildWnd(); 344 }
336 } 345
337 346 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice,
338 } 347 CPDF_Matrix* pUser2Device) {
339 if (bRefresh) 348 if (IsValid() && IsVisible()) {
340 { 349 DrawThisAppearance(pDevice, pUser2Device);
341 InvalidateRectMove(rcOld,rcNew); 350 DrawChildAppearance(pDevice, pUser2Device);
342 } 351 }
343 352 }
344 m_sPrivateParam.rcRectWnd = m_rcWindow; 353
345 } 354 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice,
346 } 355 CPDF_Matrix* pUser2Device) {
347 356 CPDF_Rect rectWnd = GetWindowRect();
348 void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rc New) 357 if (!rectWnd.IsEmpty()) {
349 { 358 if (HasFlag(PWS_BACKGROUND)) {
350 CPDF_Rect rcUnion = rcOld; 359 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(
351 rcUnion.Union(rcNew); 360 rectWnd, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
352 361 CPWL_Utils::DrawFillRect(pDevice, pUser2Device, rcClient,
353 InvalidateRect(&rcUnion); 362 GetBackgroundColor(), GetTransparency());
354 } 363 }
355 364
356 void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream) 365 if (HasFlag(PWS_BORDER))
357 { 366 CPWL_Utils::DrawBorder(
358 if (IsValid()) 367 pDevice, pUser2Device, rectWnd, (FX_FLOAT)GetBorderWidth(),
359 { 368 GetBorderColor(), GetBorderLeftTopColor(GetBorderStyle()),
360 CFX_ByteTextBuf sTextBuf; 369 GetBorderRightBottomColor(GetBorderStyle()), GetBorderStyle(),
361 GetAppearanceStream(sTextBuf); 370 GetBorderDash(), GetTransparency());
362 sAppStream += sTextBuf.GetByteString(); 371 }
363 } 372 }
364 } 373
365 374 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice,
366 void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf & sAppStream) 375 CPDF_Matrix* pUser2Device) {
367 { 376 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
368 if (IsValid() && IsVisible()) 377 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
369 { 378 CPDF_Matrix mt = pChild->GetChildMatrix();
370 GetThisAppearanceStream(sAppStream); 379 if (mt.IsIdentity()) {
371 GetChildAppearanceStream(sAppStream); 380 pChild->DrawAppearance(pDevice, pUser2Device);
372 } 381 } else {
373 } 382 mt.Concat(*pUser2Device);
374 383 pChild->DrawAppearance(pDevice, &mt);
375 //if don't set,Get default apperance stream 384 }
376 void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream) 385 }
377 { 386 }
378 CPDF_Rect rectWnd = GetWindowRect(); 387 }
379 if (!rectWnd.IsEmpty()) { 388
380 CFX_ByteTextBuf sThis; 389 void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect) {
381 390 if (IsValid()) {
382 if (HasFlag(PWS_BACKGROUND)) 391 CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
383 sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColo r()); 392
384 393 if (!HasFlag(PWS_NOREFRESHCLIP)) {
385 if (HasFlag(PWS_BORDER)) { 394 CPDF_Rect rcClip = GetClipRect();
386 sThis << CPWL_Utils::GetBorderAppStream( 395 if (!rcClip.IsEmpty()) {
387 rectWnd, 396 rcRefresh.Intersect(rcClip);
388 (FX_FLOAT)GetBorderWidth(), 397 }
389 GetBorderColor(), 398 }
390 GetBorderLeftTopColor(GetBorderStyle()), 399
391 GetBorderRightBottomColor(GetBorderStyle()), 400 FX_RECT rcWin = PWLtoWnd(rcRefresh);
392 GetBorderStyle(), 401 rcWin.left -= PWL_INVALIDATE_INFLATE;
393 GetBorderDash()); 402 rcWin.top -= PWL_INVALIDATE_INFLATE;
394 } 403 rcWin.right += PWL_INVALIDATE_INFLATE;
395 404 rcWin.bottom += PWL_INVALIDATE_INFLATE;
396 sAppStream << sThis; 405
397 } 406 if (IFX_SystemHandler* pSH = GetSystemHandler()) {
398 } 407 if (FX_HWND hWnd = GetAttachedHWnd()) {
399 408 pSH->InvalidateRect(hWnd, rcWin);
400 void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream) 409 }
401 { 410 }
402 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) 411 }
403 { 412 }
404 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) 413
405 { 414 #define PWL_IMPLEMENT_KEY_METHOD(key_method_name) \
406 pChild->GetAppearanceStream(sAppStream); 415 FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag) { \
407 } 416 if (IsValid() && IsVisible() && IsEnabled()) { \
408 } 417 if (IsWndCaptureKeyboard(this)) { \
409 } 418 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
410 419 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
411 void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Devi ce) 420 if (IsWndCaptureKeyboard(pChild)) { \
412 { 421 return pChild->key_method_name(nChar, nFlag); \
413 if (IsValid() && IsVisible()) 422 } \
414 { 423 } \
415 DrawThisAppearance(pDevice,pUser2Device); 424 } \
416 DrawChildAppearance(pDevice,pUser2Device); 425 } \
417 } 426 } \
418 } 427 return FALSE; \
419 428 }
420 void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2 Device) 429
421 { 430 #define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name) \
422 CPDF_Rect rectWnd = GetWindowRect(); 431 FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point& point, \
423 if (!rectWnd.IsEmpty()) 432 FX_DWORD nFlag) { \
424 { 433 if (IsValid() && IsVisible() && IsEnabled()) { \
425 if (HasFlag(PWS_BACKGROUND)) 434 if (IsWndCaptureMouse(this)) { \
426 { 435 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
427 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX_FLOAT)(GetB orderWidth()+GetInnerBorderWidth())); 436 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
428 CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient, GetBackgroun dColor(), GetTransparency()); 437 if (IsWndCaptureMouse(pChild)) { \
429 } 438 return pChild->mouse_method_name(pChild->ParentToChild(point), \
430 439 nFlag); \
431 if (HasFlag(PWS_BORDER)) 440 } \
432 CPWL_Utils::DrawBorder(pDevice, 441 } \
433 pUser2Device, 442 } \
434 rectWnd, 443 SetCursor(); \
435 (FX_FLOAT)GetBorderWidth(), 444 } else { \
436 GetBorderColor(), 445 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) { \
437 GetBorderLeftTopColor(GetBorderStyle()), 446 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) { \
438 GetBorderRightBottomColor(GetBorderStyle()), 447 if (pChild->WndHitTest(pChild->ParentToChild(point))) { \
439 GetBorderStyle(), 448 return pChild->mouse_method_name(pChild->ParentToChild(point), \
440 GetBorderDash(), 449 nFlag); \
441 GetTransparency()); 450 } \
442 } 451 } \
443 } 452 } \
444 453 if (WndHitTest(point)) \
445 void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser 2Device) 454 SetCursor(); \
446 { 455 } \
447 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) 456 } \
448 { 457 return FALSE; \
449 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) 458 }
450 {
451 CPDF_Matrix mt = pChild->GetChildMatrix();
452 if (mt.IsIdentity())
453 {
454 pChild->DrawAppearance(pDevice,pUser2Device);
455 }
456 else
457 {
458 mt.Concat(*pUser2Device);
459 pChild->DrawAppearance(pDevice,&mt);
460 }
461 }
462 }
463 }
464
465 void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect)
466 {
467 if (IsValid())
468 {
469 CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
470
471 if (!HasFlag(PWS_NOREFRESHCLIP))
472 {
473 CPDF_Rect rcClip = GetClipRect();
474 if (!rcClip.IsEmpty())
475 {
476 rcRefresh.Intersect(rcClip);
477 }
478 }
479
480 FX_RECT rcWin = PWLtoWnd(rcRefresh);
481 rcWin.left -= PWL_INVALIDATE_INFLATE;
482 rcWin.top -= PWL_INVALIDATE_INFLATE;
483 rcWin.right += PWL_INVALIDATE_INFLATE;
484 rcWin.bottom += PWL_INVALIDATE_INFLATE;
485
486 if (IFX_SystemHandler* pSH = GetSystemHandler())
487 {
488 if (FX_HWND hWnd = GetAttachedHWnd())
489 {
490 pSH->InvalidateRect(hWnd, rcWin);
491 }
492 }
493 }
494 }
495
496 #define PWL_IMPLEMENT_KEY_METHOD(key_method_name)\
497 FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag)\
498 {\
499 if (IsValid() && IsVisible() && IsEnabled())\
500 {\
501 if (IsWndCaptureKeyboard(this))\
502 {\
503 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
504 {\
505 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
506 {\
507 if (IsWndCaptureKeyboard(pChild))\
508 {\
509 return pChild->key_method_name(nChar,nFlag);\
510 }\
511 }\
512 }\
513 }\
514 }\
515 return FALSE;\
516 }
517
518 #define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)\
519 FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point & point, FX_DWORD nFlag)\
520 {\
521 if (IsValid() && IsVisible() && IsEnabled())\
522 {\
523 if (IsWndCaptureMouse(this))\
524 {\
525 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
526 {\
527 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
528 {\
529 if (IsWndCaptureMouse(pChild))\
530 {\
531 return pChild->mouse_method_name(pChild->ParentToChild(p oint),nFlag);\
532 }\
533 }\
534 }\
535 SetCursor();\
536 }\
537 else\
538 {\
539 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
540 {\
541 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
542 {\
543 if (pChild->WndHitTest(pChild->ParentToChild(point)))\
544 {\
545 return pChild->mouse_method_name(pChild->ParentToChild(p oint),nFlag);\
546 }\
547 }\
548 }\
549 if (WndHitTest(point))\
550 SetCursor();\
551 }\
552 }\
553 return FALSE;\
554 }
555 459
556 PWL_IMPLEMENT_KEY_METHOD(OnKeyDown) 460 PWL_IMPLEMENT_KEY_METHOD(OnKeyDown)
557 PWL_IMPLEMENT_KEY_METHOD(OnKeyUp) 461 PWL_IMPLEMENT_KEY_METHOD(OnKeyUp)
558 PWL_IMPLEMENT_KEY_METHOD(OnChar) 462 PWL_IMPLEMENT_KEY_METHOD(OnChar)
559 463
560 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk) 464 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk)
561 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown) 465 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown)
562 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp) 466 PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp)
563 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk) 467 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk)
564 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown) 468 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown)
565 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp) 469 PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp)
566 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown) 470 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown)
567 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp) 471 PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
568 PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove) 472 PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
569 473
570 FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag) 474 FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta,
571 { 475 const CPDF_Point& point,
572 if (IsValid() && IsVisible() && IsEnabled()) 476 FX_DWORD nFlag) {
573 { 477 if (IsValid() && IsVisible() && IsEnabled()) {
574 SetCursor(); 478 SetCursor();
575 if (IsWndCaptureKeyboard(this)) 479 if (IsWndCaptureKeyboard(this)) {
576 { 480 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
577 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) 481 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
578 { 482 if (IsWndCaptureKeyboard(pChild)) {
579 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i)) 483 return pChild->OnMouseWheel(zDelta, pChild->ParentToChild(point),
580 { 484 nFlag);
581 if (IsWndCaptureKeyboard(pChild)) 485 }
582 {
583 return pChild->OnMouseWheel(zDelta,pChild->ParentToChild (point), nFlag);
584 }
585 }
586 }
587 } 486 }
588 } 487 }
589 return FALSE; 488 }
590 } 489 }
591 490 return FALSE;
592 void CPWL_Wnd::AddChild(CPWL_Wnd * pWnd) 491 }
593 { 492
594 m_aChildren.Add(pWnd); 493 void CPWL_Wnd::AddChild(CPWL_Wnd* pWnd) {
595 } 494 m_aChildren.Add(pWnd);
596 495 }
597 void CPWL_Wnd::RemoveChild(CPWL_Wnd * pWnd) 496
598 { 497 void CPWL_Wnd::RemoveChild(CPWL_Wnd* pWnd) {
599 for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --) 498 for (int32_t i = m_aChildren.GetSize() - 1; i >= 0; i--) {
600 { 499 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
601 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) 500 if (pChild == pWnd) {
602 { 501 m_aChildren.RemoveAt(i);
603 if (pChild == pWnd) 502 break;
604 { 503 }
605 m_aChildren.RemoveAt(i); 504 }
606 break; 505 }
607 } 506 }
608 } 507
609 } 508 void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd,
610 } 509 FX_DWORD msg,
611 510 intptr_t wParam,
612 void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam) 511 intptr_t lParam) {
613 { 512 switch (msg) {
614 switch (msg)
615 {
616 case PNM_ADDCHILD: 513 case PNM_ADDCHILD:
617 AddChild(pWnd); 514 AddChild(pWnd);
618 break; 515 break;
619 case PNM_REMOVECHILD: 516 case PNM_REMOVECHILD:
620 RemoveChild(pWnd); 517 RemoveChild(pWnd);
621 break; 518 break;
622 default: 519 default:
623 break; 520 break;
624 } 521 }
625 } 522 }
626 523
627 FX_BOOL CPWL_Wnd::IsValid() const 524 FX_BOOL CPWL_Wnd::IsValid() const {
628 { 525 return m_bCreated;
629 return m_bCreated; 526 }
630 } 527
631 528 PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const {
632 PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const 529 return m_sPrivateParam;
633 { 530 }
634 return m_sPrivateParam; 531
635 } 532 CPWL_Wnd* CPWL_Wnd::GetParentWindow() const {
636 533 return m_sPrivateParam.pParentWnd;
637 CPWL_Wnd* CPWL_Wnd::GetParentWindow() const 534 }
638 { 535
639 return m_sPrivateParam.pParentWnd; 536 CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const {
640 } 537 return m_sPrivateParam.rcRectWnd;
641 538 }
642 CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const 539
643 { 540 CPDF_Rect CPWL_Wnd::GetWindowRect() const {
644 return m_sPrivateParam.rcRectWnd; 541 return m_rcWindow;
645 } 542 }
646 543
647 CPDF_Rect CPWL_Wnd::GetWindowRect() const 544 CPDF_Rect CPWL_Wnd::GetClientRect() const {
648 { 545 CPDF_Rect rcWindow = GetWindowRect();
649 return m_rcWindow; 546 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(
650 } 547 rcWindow, (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
651 548 if (CPWL_ScrollBar* pVSB = GetVScrollBar())
652 CPDF_Rect CPWL_Wnd::GetClientRect() const 549 rcClient.right -= pVSB->GetScrollBarWidth();
653 { 550
654 CPDF_Rect rcWindow = GetWindowRect(); 551 rcClient.Normalize();
655 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWi dth()+GetInnerBorderWidth())); 552 return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect();
656 if (CPWL_ScrollBar* pVSB = GetVScrollBar()) 553 }
657 rcClient.right -= pVSB->GetScrollBarWidth(); 554
658 555 CPDF_Point CPWL_Wnd::GetCenterPoint() const {
659 rcClient.Normalize(); 556 CPDF_Rect rcClient = GetClientRect();
660 return rcWindow.Contains(rcClient) ? rcClient : CPDF_Rect(); 557 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
661 } 558 (rcClient.top + rcClient.bottom) * 0.5f);
662 559 }
663 CPDF_Point CPWL_Wnd::GetCenterPoint() const 560
664 { 561 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const {
665 CPDF_Rect rcClient = GetClientRect(); 562 return CPWL_Utils::GetCenterSquare(GetClientRect());
666 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f, 563 }
667 (rcClient.top + rcClient.bottom) * 0.5f); 564
668 } 565 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const {
669 566 return CPWL_Utils::GetCenterSquare(
670 CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const 567 CPWL_Utils::DeflateRect(GetWindowRect(), 0.1f));
671 { 568 }
672 return CPWL_Utils::GetCenterSquare(GetClientRect()); 569
673 } 570 FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const {
674 571 return (m_sPrivateParam.dwFlags & dwFlags) != 0;
675 CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const 572 }
676 { 573
677 return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0 .1f)); 574 void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) {
678 } 575 m_sPrivateParam.dwFlags &= ~dwFlags;
679 576 }
680 FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const 577
681 { 578 void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) {
682 return (m_sPrivateParam.dwFlags & dwFlags) != 0; 579 m_sPrivateParam.dwFlags |= dwFlags;
683 } 580 }
684 581
685 void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags) 582 CPWL_Color CPWL_Wnd::GetBackgroundColor() const {
686 { 583 return m_sPrivateParam.sBackgroundColor;
687 m_sPrivateParam.dwFlags &= ~dwFlags; 584 }
688 } 585
689 586 void CPWL_Wnd::SetBackgroundColor(const CPWL_Color& color) {
690 void CPWL_Wnd::AddFlag(FX_DWORD dwFlags) 587 m_sPrivateParam.sBackgroundColor = color;
691 { 588 }
692 m_sPrivateParam.dwFlags |= dwFlags; 589
693 } 590 void CPWL_Wnd::SetTextColor(const CPWL_Color& color) {
694 591 m_sPrivateParam.sTextColor = color;
695 CPWL_Color CPWL_Wnd::GetBackgroundColor() const 592 }
696 { 593
697 return m_sPrivateParam.sBackgroundColor; 594 void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color& color) {
698 } 595 m_sPrivateParam.sTextStrokeColor = color;
699 596 }
700 void CPWL_Wnd::SetBackgroundColor(const CPWL_Color & color) 597
701 { 598 CPWL_Color CPWL_Wnd::GetTextColor() const {
702 m_sPrivateParam.sBackgroundColor = color; 599 return m_sPrivateParam.sTextColor;
703 } 600 }
704 601
705 void CPWL_Wnd::SetTextColor(const CPWL_Color & color) 602 CPWL_Color CPWL_Wnd::GetTextStrokeColor() const {
706 { 603 return m_sPrivateParam.sTextStrokeColor;
707 m_sPrivateParam.sTextColor = color; 604 }
708 } 605
709 606 int32_t CPWL_Wnd::GetBorderStyle() const {
710 void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color & color) 607 return m_sPrivateParam.nBorderStyle;
711 { 608 }
712 m_sPrivateParam.sTextStrokeColor = color; 609
713 } 610 void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) {
714 611 if (HasFlag(PWS_BORDER))
715 CPWL_Color CPWL_Wnd::GetTextColor() const 612 m_sPrivateParam.nBorderStyle = nBorderStyle;
716 { 613 }
717 return m_sPrivateParam.sTextColor; 614
718 } 615 int32_t CPWL_Wnd::GetBorderWidth() const {
719 616 if (HasFlag(PWS_BORDER))
720 CPWL_Color CPWL_Wnd::GetTextStrokeColor() const 617 return m_sPrivateParam.dwBorderWidth;
721 { 618
722 return m_sPrivateParam.sTextStrokeColor; 619 return 0;
723 } 620 }
724 621
725 int32_t CPWL_Wnd::GetBorderStyle() const 622 int32_t CPWL_Wnd::GetInnerBorderWidth() const {
726 { 623 /*
727 return m_sPrivateParam.nBorderStyle; 624 switch (GetBorderStyle())
728 } 625 {
729 626 case PBS_BEVELED:
730 void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle) 627 case PBS_INSET:
731 { 628 return GetBorderWidth() / 2;
732 if (HasFlag(PWS_BORDER)) 629 }
733 m_sPrivateParam.nBorderStyle = nBorderStyle; 630 */
734 } 631 return 0;
735 632 }
736 int32_t CPWL_Wnd::GetBorderWidth() const 633
737 { 634 void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) {
738 if (HasFlag(PWS_BORDER)) 635 if (HasFlag(PWS_BORDER))
739 return m_sPrivateParam.dwBorderWidth; 636 m_sPrivateParam.dwBorderWidth = nBorderWidth;
740 637 }
741 return 0; 638
742 } 639 CPWL_Color CPWL_Wnd::GetBorderColor() const {
743 640 if (HasFlag(PWS_BORDER))
744 int32_t CPWL_Wnd::GetInnerBorderWidth() const 641 return m_sPrivateParam.sBorderColor;
745 { 642
746 /* 643 return CPWL_Color();
747 switch (GetBorderStyle()) 644 }
748 { 645
646 void CPWL_Wnd::SetBorderColor(const CPWL_Color& color) {
647 if (HasFlag(PWS_BORDER))
648 m_sPrivateParam.sBorderColor = color;
649 }
650
651 CPWL_Dash CPWL_Wnd::GetBorderDash() const {
652 return m_sPrivateParam.sDash;
653 }
654
655 void* CPWL_Wnd::GetAttachedData() const {
656 return m_sPrivateParam.pAttachedData;
657 }
658
659 void CPWL_Wnd::SetBorderDash(const CPWL_Dash& sDash) {
660 if (HasFlag(PWS_BORDER))
661 m_sPrivateParam.sDash = sDash;
662 }
663
664 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const {
665 if (HasFlag(PWS_VSCROLL))
666 return m_pVScrollBar;
667
668 return NULL;
669 }
670
671 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM& cp) {
672 CreateVScrollBar(cp);
673 }
674
675 void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM& cp) {
676 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL)) {
677 PWL_CREATEPARAM scp = cp;
678
679 // flags
680 scp.dwFlags =
681 PWS_CHILD | PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
682
683 scp.pParentWnd = this;
684 scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
685 scp.eCursorType = FXCT_ARROW;
686 scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY;
687
688 if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL)))
689 m_pVScrollBar->Create(scp);
690 }
691 }
692
693 void CPWL_Wnd::SetCapture() {
694 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl())
695 pMsgCtrl->SetCapture(this);
696 }
697
698 void CPWL_Wnd::ReleaseCapture() {
699 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++)
700 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
701 pChild->ReleaseCapture();
702
703 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl())
704 pMsgCtrl->ReleaseCapture();
705 }
706
707 void CPWL_Wnd::SetFocus() {
708 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
709 if (!pMsgCtrl->IsMainCaptureKeyboard(this))
710 pMsgCtrl->KillFocus();
711 pMsgCtrl->SetFocus(this);
712 }
713 }
714
715 void CPWL_Wnd::KillFocus() {
716 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
717 if (pMsgCtrl->IsWndCaptureKeyboard(this))
718 pMsgCtrl->KillFocus();
719 }
720 }
721
722 void CPWL_Wnd::OnSetFocus() {}
723
724 void CPWL_Wnd::OnKillFocus() {}
725
726 FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point& point) const {
727 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x, point.y);
728 }
729
730 FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point& point) const {
731 return IsValid() && IsVisible() && GetClientRect().Contains(point.x, point.y);
732 }
733
734 const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const {
735 if (m_sPrivateParam.pParentWnd)
736 return m_sPrivateParam.pParentWnd->GetRootWnd();
737
738 return this;
739 }
740
741 void CPWL_Wnd::SetVisible(FX_BOOL bVisible) {
742 if (IsValid()) {
743 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
744 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
745 pChild->SetVisible(bVisible);
746 }
747 }
748
749 if (bVisible != m_bVisible) {
750 m_bVisible = bVisible;
751 RePosChildWnd();
752 InvalidateRect();
753 }
754 }
755 }
756
757 void CPWL_Wnd::SetClipRect(const CPDF_Rect& rect) {
758 m_rcClip = rect;
759 m_rcClip.Normalize();
760 }
761
762 CPDF_Rect CPWL_Wnd::GetClipRect() const {
763 return m_rcClip;
764 }
765
766 FX_BOOL CPWL_Wnd::IsReadOnly() const {
767 return HasFlag(PWS_READONLY);
768 }
769
770 void CPWL_Wnd::RePosChildWnd() {
771 CPDF_Rect rcContent = CPWL_Utils::DeflateRect(
772 GetWindowRect(), (FX_FLOAT)(GetBorderWidth() + GetInnerBorderWidth()));
773
774 CPWL_ScrollBar* pVSB = GetVScrollBar();
775
776 CPDF_Rect rcVScroll =
777 CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH, rcContent.bottom,
778 rcContent.right - 1.0f, rcContent.top);
779
780 if (pVSB)
781 pVSB->Move(rcVScroll, TRUE, FALSE);
782 }
783
784 void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM& cp) {}
785
786 void CPWL_Wnd::SetCursor() {
787 if (IsValid()) {
788 if (IFX_SystemHandler* pSH = GetSystemHandler()) {
789 int32_t nCursorType = GetCreationParam().eCursorType;
790 pSH->SetCursor(nCursorType);
791 }
792 }
793 }
794
795 void CPWL_Wnd::CreateMsgControl() {
796 if (!m_sPrivateParam.pMsgControl)
797 m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
798 }
799
800 void CPWL_Wnd::DestroyMsgControl() {
801 if (CPWL_MsgControl* pMsgControl = GetMsgControl())
802 if (pMsgControl->IsWndCreated(this))
803 delete pMsgControl;
804 }
805
806 CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const {
807 return m_sPrivateParam.pMsgControl;
808 }
809
810 FX_BOOL CPWL_Wnd::IsCaptureMouse() const {
811 return IsWndCaptureMouse(this);
812 }
813
814 FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd* pWnd) const {
815 if (CPWL_MsgControl* pCtrl = GetMsgControl())
816 return pCtrl->IsWndCaptureMouse(pWnd);
817
818 return FALSE;
819 }
820
821 FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd* pWnd) const {
822 if (CPWL_MsgControl* pCtrl = GetMsgControl())
823 return pCtrl->IsWndCaptureKeyboard(pWnd);
824
825 return FALSE;
826 }
827
828 FX_BOOL CPWL_Wnd::IsFocused() const {
829 if (CPWL_MsgControl* pCtrl = GetMsgControl())
830 return pCtrl->IsMainCaptureKeyboard(this);
831
832 return FALSE;
833 }
834
835 CPDF_Rect CPWL_Wnd::GetFocusRect() const {
836 return CPWL_Utils::InflateRect(GetWindowRect(), 1);
837 }
838
839 FX_FLOAT CPWL_Wnd::GetFontSize() const {
840 return m_sPrivateParam.fFontSize;
841 }
842
843 void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize) {
844 m_sPrivateParam.fFontSize = fFontSize;
845 }
846
847 IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const {
848 return m_sPrivateParam.pSystemHandler;
849 }
850
851 IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const {
852 return m_sPrivateParam.pFocusHandler;
853 }
854
855 IPWL_Provider* CPWL_Wnd::GetProvider() const {
856 return m_sPrivateParam.pProvider;
857 }
858
859 IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const {
860 return m_sPrivateParam.pFontMap;
861 }
862
863 CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const {
864 CPWL_Color color;
865
866 switch (nBorderStyle) {
867 case PBS_SOLID:
868 break;
869 case PBS_DASH:
870 break;
749 case PBS_BEVELED: 871 case PBS_BEVELED:
872 color = CPWL_Color(COLORTYPE_GRAY, 1);
873 break;
750 case PBS_INSET: 874 case PBS_INSET:
751 return GetBorderWidth() / 2; 875 color = CPWL_Color(COLORTYPE_GRAY, 0.5f);
752 } 876 break;
753 */ 877 case PBS_UNDERLINED:
754 return 0; 878 break;
755 } 879 }
756 880
757 void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth) 881 return color;
758 { 882 }
759 if (HasFlag(PWS_BORDER)) 883
760 m_sPrivateParam.dwBorderWidth = nBorderWidth; 884 CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const {
761 } 885 CPWL_Color color;
762 886
763 CPWL_Color CPWL_Wnd::GetBorderColor() const 887 switch (nBorderStyle) {
764 { 888 case PBS_SOLID:
765 if (HasFlag(PWS_BORDER)) 889 break;
766 return m_sPrivateParam.sBorderColor; 890 case PBS_DASH:
767 891 break;
768 return CPWL_Color(); 892 case PBS_BEVELED:
769 } 893 color = CPWL_Utils::DevideColor(GetBackgroundColor(), 2);
770 894 break;
771 void CPWL_Wnd::SetBorderColor(const CPWL_Color & color) 895 case PBS_INSET:
772 { 896 color = CPWL_Color(COLORTYPE_GRAY, 0.75f);
773 if (HasFlag(PWS_BORDER)) 897 break;
774 m_sPrivateParam.sBorderColor = color; 898 case PBS_UNDERLINED:
775 } 899 break;
776 900 }
777 CPWL_Dash CPWL_Wnd::GetBorderDash() const 901
778 { 902 return color;
779 return m_sPrivateParam.sDash;
780 }
781
782 void* CPWL_Wnd::GetAttachedData() const
783 {
784 return m_sPrivateParam.pAttachedData;
785 }
786
787 void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash)
788 {
789 if (HasFlag(PWS_BORDER))
790 m_sPrivateParam.sDash = sDash;
791 }
792
793 CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const
794 {
795 if (HasFlag(PWS_VSCROLL))
796 return m_pVScrollBar;
797
798 return NULL;
799 }
800
801 void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM & cp)
802 {
803 CreateVScrollBar(cp);
804 }
805
806 void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM & cp)
807 {
808 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL))
809 {
810 PWL_CREATEPARAM scp = cp;
811
812 //flags
813 scp.dwFlags = PWS_CHILD| PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NORE FRESHCLIP;
814
815 scp.pParentWnd = this;
816 scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
817 scp.eCursorType = FXCT_ARROW;
818 scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY;
819
820 if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL)))
821 m_pVScrollBar->Create(scp);
822 }
823 }
824
825 void CPWL_Wnd::SetCapture()
826 {
827 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
828 pMsgCtrl->SetCapture(this);
829 }
830
831 void CPWL_Wnd::ReleaseCapture()
832 {
833 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
834 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
835 pChild->ReleaseCapture();
836
837 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
838 pMsgCtrl->ReleaseCapture();
839 }
840
841 void CPWL_Wnd::SetFocus()
842 {
843 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
844 {
845 if (!pMsgCtrl->IsMainCaptureKeyboard(this))
846 pMsgCtrl->KillFocus();
847 pMsgCtrl->SetFocus(this);
848 }
849 }
850
851 void CPWL_Wnd::KillFocus()
852 {
853 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
854 {
855 if (pMsgCtrl->IsWndCaptureKeyboard(this))
856 pMsgCtrl->KillFocus();
857 }
858 }
859
860 void CPWL_Wnd::OnSetFocus()
861 {
862 }
863
864 void CPWL_Wnd::OnKillFocus()
865 {
866 }
867
868 FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const
869 {
870 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y) ;
871 }
872
873 FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & point) const
874 {
875 return IsValid() && IsVisible() && GetClientRect().Contains(point.x,point.y) ;
876 }
877
878 const CPWL_Wnd* CPWL_Wnd::GetRootWnd() const
879 {
880 if (m_sPrivateParam.pParentWnd)
881 return m_sPrivateParam.pParentWnd->GetRootWnd();
882
883 return this;
884 }
885
886 void CPWL_Wnd::SetVisible(FX_BOOL bVisible)
887 {
888 if (IsValid())
889 {
890 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
891 {
892 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
893 {
894 pChild->SetVisible(bVisible);
895 }
896 }
897
898 if (bVisible != m_bVisible)
899 {
900 m_bVisible = bVisible;
901 RePosChildWnd();
902 InvalidateRect();
903 }
904 }
905 }
906
907 void CPWL_Wnd::SetClipRect(const CPDF_Rect & rect)
908 {
909 m_rcClip = rect;
910 m_rcClip.Normalize();
911 }
912
913 CPDF_Rect CPWL_Wnd::GetClipRect() const
914 {
915 return m_rcClip;
916 }
917
918 FX_BOOL CPWL_Wnd::IsReadOnly() const
919 {
920 return HasFlag(PWS_READONLY);
921 }
922
923 void CPWL_Wnd::RePosChildWnd()
924 {
925 CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(Get BorderWidth()+GetInnerBorderWidth()));
926
927 CPWL_ScrollBar * pVSB = GetVScrollBar();
928
929 CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH,
930 rcContent.bottom,
931 rcContent.right-1.0f,
932 rcContent.top);
933
934 if (pVSB) pVSB->Move(rcVScroll,TRUE,FALSE);
935 }
936
937 void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM & cp)
938 {
939 }
940
941 void CPWL_Wnd::SetCursor()
942 {
943 if (IsValid())
944 {
945 if (IFX_SystemHandler* pSH = GetSystemHandler())
946 {
947 int32_t nCursorType = GetCreationParam().eCursorType;
948 pSH->SetCursor(nCursorType);
949 }
950 }
951 }
952
953 void CPWL_Wnd::CreateMsgControl()
954 {
955 if (!m_sPrivateParam.pMsgControl)
956 m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
957 }
958
959 void CPWL_Wnd::DestroyMsgControl()
960 {
961 if (CPWL_MsgControl* pMsgControl = GetMsgControl())
962 if (pMsgControl->IsWndCreated(this))
963 delete pMsgControl;
964 }
965
966 CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const
967 {
968 return m_sPrivateParam.pMsgControl;
969 }
970
971 FX_BOOL CPWL_Wnd::IsCaptureMouse() const
972 {
973 return IsWndCaptureMouse(this);
974 }
975
976 FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd * pWnd) const
977 {
978 if (CPWL_MsgControl * pCtrl = GetMsgControl())
979 return pCtrl->IsWndCaptureMouse(pWnd);
980
981 return FALSE;
982 }
983
984 FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
985 {
986 if (CPWL_MsgControl * pCtrl = GetMsgControl())
987 return pCtrl->IsWndCaptureKeyboard(pWnd);
988
989 return FALSE;
990 }
991
992 FX_BOOL CPWL_Wnd::IsFocused() const
993 {
994 if (CPWL_MsgControl * pCtrl = GetMsgControl())
995 return pCtrl->IsMainCaptureKeyboard(this);
996
997 return FALSE;
998 }
999
1000 CPDF_Rect CPWL_Wnd::GetFocusRect() const
1001 {
1002 return CPWL_Utils::InflateRect(GetWindowRect(),1);
1003 }
1004
1005 FX_FLOAT CPWL_Wnd::GetFontSize() const
1006 {
1007 return m_sPrivateParam.fFontSize;
1008 }
1009
1010 void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize)
1011 {
1012 m_sPrivateParam.fFontSize = fFontSize;
1013 }
1014
1015 IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const
1016 {
1017 return m_sPrivateParam.pSystemHandler;
1018 }
1019
1020 IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const
1021 {
1022 return m_sPrivateParam.pFocusHandler;
1023 }
1024
1025 IPWL_Provider* CPWL_Wnd::GetProvider() const
1026 {
1027 return m_sPrivateParam.pProvider;
1028 }
1029
1030 IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const
1031 {
1032 return m_sPrivateParam.pFontMap;
1033 }
1034
1035 CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const
1036 {
1037 CPWL_Color color;
1038
1039 switch (nBorderStyle)
1040 {
1041 case PBS_SOLID:
1042 break;
1043 case PBS_DASH:
1044 break;
1045 case PBS_BEVELED:
1046 color = CPWL_Color(COLORTYPE_GRAY,1);
1047 break;
1048 case PBS_INSET:
1049 color = CPWL_Color(COLORTYPE_GRAY,0.5f);
1050 break;
1051 case PBS_UNDERLINED:
1052 break;
1053 }
1054
1055 return color;
1056 }
1057
1058 CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const
1059 {
1060 CPWL_Color color;
1061
1062 switch (nBorderStyle)
1063 {
1064 case PBS_SOLID:
1065 break;
1066 case PBS_DASH:
1067 break;
1068 case PBS_BEVELED:
1069 color = CPWL_Utils::DevideColor(GetBackgroundColor(),2);
1070 break;
1071 case PBS_INSET:
1072 color = CPWL_Color(COLORTYPE_GRAY,0.75f);
1073 break;
1074 case PBS_UNDERLINED:
1075 break;
1076 }
1077
1078 return color;
1079 } 903 }
1080 904
1081 /* ----------------------------------------------------------------- */ 905 /* ----------------------------------------------------------------- */
1082 906
1083 int32_t CPWL_Wnd::GetTransparency() 907 int32_t CPWL_Wnd::GetTransparency() {
1084 { 908 return m_sPrivateParam.nTransparency;
1085 return m_sPrivateParam.nTransparency; 909 }
1086 } 910
1087 911 void CPWL_Wnd::SetTransparency(int32_t nTransparency) {
1088 void CPWL_Wnd::SetTransparency(int32_t nTransparency) 912 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
1089 { 913 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
1090 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) 914 pChild->SetTransparency(nTransparency);
1091 { 915 }
1092 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) 916 }
1093 { 917
1094 pChild->SetTransparency(nTransparency); 918 m_sPrivateParam.nTransparency = nTransparency;
1095 } 919 }
1096 } 920
1097 921 CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const {
1098 m_sPrivateParam.nTransparency = nTransparency; 922 CPDF_Matrix mt = GetChildToRoot();
1099 } 923
1100 924 if (IPWL_Provider* pProvider = GetProvider()) {
1101 CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const 925 mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
1102 {
1103 CPDF_Matrix mt = GetChildToRoot();
1104
1105 if (IPWL_Provider* pProvider = GetProvider())
1106 {
1107 mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
1108 return mt;
1109 }
1110
1111 return mt; 926 return mt;
1112 } 927 }
1113 928
1114 void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const 929 return mt;
1115 { 930 }
1116 CPDF_Matrix mt = GetWindowMatrix(); 931
1117 CPDF_Point pt = point; 932 void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const {
1118 mt.Transform(pt.x,pt.y); 933 CPDF_Matrix mt = GetWindowMatrix();
1119 x = (int32_t)(pt.x+0.5); 934 CPDF_Point pt = point;
1120 y = (int32_t)(pt.y+0.5); 935 mt.Transform(pt.x, pt.y);
1121 } 936 x = (int32_t)(pt.x + 0.5);
1122 937 y = (int32_t)(pt.y + 0.5);
1123 FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const 938 }
1124 { 939
1125 CPDF_Rect rcTemp = rect; 940 FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect& rect) const {
1126 CPDF_Matrix mt = GetWindowMatrix(); 941 CPDF_Rect rcTemp = rect;
1127 mt.TransformRect(rcTemp); 942 CPDF_Matrix mt = GetWindowMatrix();
1128 return FX_RECT((int32_t)(rcTemp.left+0.5), (int32_t)(rcTemp.bottom+0.5), (in t32_t)(rcTemp.right+0.5), (int32_t)(rcTemp.top+0.5)); 943 mt.TransformRect(rcTemp);
1129 } 944 return FX_RECT((int32_t)(rcTemp.left + 0.5), (int32_t)(rcTemp.bottom + 0.5),
1130 945 (int32_t)(rcTemp.right + 0.5), (int32_t)(rcTemp.top + 0.5));
1131 FX_HWND CPWL_Wnd::GetAttachedHWnd() const 946 }
1132 { 947
1133 return m_sPrivateParam.hAttachedWnd; 948 FX_HWND CPWL_Wnd::GetAttachedHWnd() const {
1134 } 949 return m_sPrivateParam.hAttachedWnd;
1135 950 }
1136 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const 951
1137 { 952 CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const {
1138 CPDF_Matrix mt = GetChildMatrix(); 953 CPDF_Matrix mt = GetChildMatrix();
1139 if (mt.IsIdentity()) 954 if (mt.IsIdentity())
1140 return point; 955 return point;
1141 956
1142 CPDF_Point pt = point; 957 CPDF_Point pt = point;
1143 mt.Transform(pt.x,pt.y); 958 mt.Transform(pt.x, pt.y);
1144 return pt; 959 return pt;
1145 } 960 }
1146 961
1147 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const 962 CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const {
1148 { 963 CPDF_Matrix mt = GetChildMatrix();
1149 CPDF_Matrix mt = GetChildMatrix(); 964 if (mt.IsIdentity())
1150 if (mt.IsIdentity()) 965 return rect;
1151 return rect; 966
1152 967 CPDF_Rect rc = rect;
1153 CPDF_Rect rc = rect; 968 mt.TransformRect(rc);
1154 mt.TransformRect(rc); 969 return rc;
1155 return rc; 970 }
1156 } 971
1157 972 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const {
1158 CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const 973 CPDF_Matrix mt = GetChildMatrix();
1159 { 974 if (mt.IsIdentity())
1160 CPDF_Matrix mt = GetChildMatrix(); 975 return point;
1161 if (mt.IsIdentity()) 976
1162 return point; 977 mt.SetReverse(mt);
1163 978 CPDF_Point pt = point;
1164 mt.SetReverse(mt); 979 mt.Transform(pt.x, pt.y);
1165 CPDF_Point pt = point; 980 return pt;
1166 mt.Transform(pt.x,pt.y); 981 }
1167 return pt; 982
1168 } 983 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const {
1169 984 CPDF_Matrix mt = GetChildMatrix();
1170 CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const 985 if (mt.IsIdentity())
1171 { 986 return rect;
1172 CPDF_Matrix mt = GetChildMatrix(); 987
1173 if (mt.IsIdentity()) 988 mt.SetReverse(mt);
1174 return rect; 989 CPDF_Rect rc = rect;
1175 990 mt.TransformRect(rc);
1176 mt.SetReverse(mt); 991 return rc;
1177 CPDF_Rect rc = rect; 992 }
1178 mt.TransformRect(rc); 993
1179 return rc; 994 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const {
1180 } 995 CPDF_Matrix mt(1, 0, 0, 1, 0, 0);
1181 996 if (HasFlag(PWS_CHILD)) {
1182 CPDF_Matrix CPWL_Wnd::GetChildToRoot() const 997 const CPWL_Wnd* pParent = this;
1183 { 998 while (pParent) {
1184 CPDF_Matrix mt(1, 0, 0, 1, 0, 0); 999 mt.Concat(pParent->GetChildMatrix());
1185 if (HasFlag(PWS_CHILD)) 1000 pParent = pParent->GetParentWindow();
1186 { 1001 }
1187 const CPWL_Wnd* pParent = this; 1002 }
1188 while (pParent) 1003 return mt;
1189 { 1004 }
1190 mt.Concat(pParent->GetChildMatrix()); 1005
1191 pParent = pParent->GetParentWindow(); 1006 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const {
1192 } 1007 if (HasFlag(PWS_CHILD))
1193 } 1008 return m_sPrivateParam.mtChild;
1194 return mt; 1009
1195 } 1010 return CPDF_Matrix(1, 0, 0, 1, 0, 0);
1196 1011 }
1197 CPDF_Matrix CPWL_Wnd::GetChildMatrix() const 1012
1198 { 1013 void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt) {
1199 if (HasFlag(PWS_CHILD)) 1014 m_sPrivateParam.mtChild = mt;
1200 return m_sPrivateParam.mtChild; 1015 }
1201 1016
1202 return CPDF_Matrix(1,0,0,1,0,0); 1017 const CPWL_Wnd* CPWL_Wnd::GetFocused() const {
1203 } 1018 if (CPWL_MsgControl* pMsgCtrl = GetMsgControl()) {
1204 1019 return pMsgCtrl->m_pMainKeyboardWnd;
1205 void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt) 1020 }
1206 { 1021
1207 m_sPrivateParam.mtChild = mt; 1022 return NULL;
1208 } 1023 }
1209 1024
1210 const CPWL_Wnd* CPWL_Wnd::GetFocused() const 1025 void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) {
1211 { 1026 if (m_bEnabled != bEnable) {
1212 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl()) 1027 for (int32_t i = 0, sz = m_aChildren.GetSize(); i < sz; i++) {
1213 { 1028 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) {
1214 return pMsgCtrl->m_pMainKeyboardWnd; 1029 pChild->EnableWindow(bEnable);
1215 } 1030 }
1216 1031 }
1217 return NULL; 1032
1218 } 1033 m_bEnabled = bEnable;
1219 1034
1220 void CPWL_Wnd::EnableWindow(FX_BOOL bEnable) 1035 if (bEnable)
1221 { 1036 OnEnabled();
1222 if (m_bEnabled != bEnable) 1037 else
1223 { 1038 OnDisabled();
1224 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++) 1039 }
1225 { 1040 }
1226 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i)) 1041
1227 { 1042 FX_BOOL CPWL_Wnd::IsEnabled() {
1228 pChild->EnableWindow(bEnable); 1043 return m_bEnabled;
1229 } 1044 }
1230 } 1045
1231 1046 void CPWL_Wnd::OnEnabled() {}
1232 m_bEnabled = bEnable; 1047
1233 1048 void CPWL_Wnd::OnDisabled() {}
1234 if (bEnable) 1049
1235 OnEnabled(); 1050 FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const {
1236 else 1051 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1237 OnDisabled(); 1052 return pSystemHandler->IsCTRLKeyDown(nFlag);
1238 } 1053 }
1239 } 1054
1240 1055 return FALSE;
1241 FX_BOOL CPWL_Wnd::IsEnabled() 1056 }
1242 { 1057
1243 return m_bEnabled; 1058 FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const {
1244 } 1059 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1245 1060 return pSystemHandler->IsSHIFTKeyDown(nFlag);
1246 void CPWL_Wnd::OnEnabled() 1061 }
1247 { 1062
1248 } 1063 return FALSE;
1249 1064 }
1250 void CPWL_Wnd::OnDisabled() 1065
1251 { 1066 FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const {
1252 } 1067 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1253 1068 return pSystemHandler->IsALTKeyDown(nFlag);
1254 FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const 1069 }
1255 { 1070
1256 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) 1071 return FALSE;
1257 { 1072 }
1258 return pSystemHandler->IsCTRLKeyDown(nFlag); 1073
1259 } 1074 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const {
1260 1075 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler()) {
1261 return FALSE; 1076 return pSystemHandler->IsINSERTKeyDown(nFlag);
1262 } 1077 }
1263 1078
1264 FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const 1079 return FALSE;
1265 { 1080 }
1266 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1267 {
1268 return pSystemHandler->IsSHIFTKeyDown(nFlag);
1269 }
1270
1271 return FALSE;
1272 }
1273
1274 FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const
1275 {
1276 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1277 {
1278 return pSystemHandler->IsALTKeyDown(nFlag);
1279 }
1280
1281 return FALSE;
1282 }
1283
1284 FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const
1285 {
1286 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1287 {
1288 return pSystemHandler->IsINSERTKeyDown(nFlag);
1289 }
1290
1291 return FALSE;
1292 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698