blob: 8ee9967763c3cd9b3eb9e7862e76a843d504ca6b [file] [log] [blame]
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001// Copyright 2014 PDFium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
Lei Zhang60f507b2015-06-13 00:41:00 -07004
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07005// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6
7#include "../../include/pdfwindow/PDFWindow.h"
8#include "../../include/pdfwindow/PWL_Wnd.h"
9#include "../../include/pdfwindow/PWL_Utils.h"
10#include "../../include/pdfwindow/PWL_ScrollBar.h"
11
12/* -------------------------- CPWL_Timer -------------------------- */
13
Tom Sepezbfa9a822015-06-09 13:24:12 -070014static CFX_MapPtrTemplate<int32_t, CPWL_Timer*>& GetPWLTimeMap()
Bruce Dawson26d96ff2015-01-05 15:31:49 -080015{
16 // Leak the object at shutdown.
Tom Sepezbfa9a822015-06-09 13:24:12 -070017 static auto timeMap = new CFX_MapPtrTemplate<int32_t, CPWL_Timer*>;
Bruce Dawson26d96ff2015-01-05 15:31:49 -080018 return *timeMap;
19}
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070020
Lei Zhang60f507b2015-06-13 00:41:00 -070021CPWL_Timer::CPWL_Timer(CPWL_TimerHandler* pAttached, IFX_SystemHandler* pSystemHandler) :
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070022 m_nTimerID(0),
Nico Weber6c554952014-07-29 10:13:17 -070023 m_pAttached(pAttached),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070024 m_pSystemHandler(pSystemHandler)
25{
26 ASSERT(m_pAttached != NULL);
27 ASSERT(m_pSystemHandler != NULL);
28}
29
30CPWL_Timer::~CPWL_Timer()
31{
32 KillPWLTimer();
33}
34
Tom Sepezbfa9a822015-06-09 13:24:12 -070035int32_t CPWL_Timer::SetPWLTimer(int32_t nElapse)
Lei Zhang60f507b2015-06-13 00:41:00 -070036{
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070037 if (m_nTimerID != 0) KillPWLTimer();
38 m_nTimerID = m_pSystemHandler->SetTimer(nElapse, TimerProc);
Bruce Dawson26d96ff2015-01-05 15:31:49 -080039 GetPWLTimeMap().SetAt(m_nTimerID, this);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070040 return m_nTimerID;
41}
42
43void CPWL_Timer::KillPWLTimer()
44{
45 if (m_nTimerID != 0)
46 {
47 m_pSystemHandler->KillTimer(m_nTimerID);
Bruce Dawson26d96ff2015-01-05 15:31:49 -080048 GetPWLTimeMap().RemoveKey(m_nTimerID);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070049 m_nTimerID = 0;
50 }
51}
52
Tom Sepezbfa9a822015-06-09 13:24:12 -070053void CPWL_Timer::TimerProc(int32_t idEvent)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070054{
55 CPWL_Timer* pTimer = NULL;
Bruce Dawson26d96ff2015-01-05 15:31:49 -080056 if (GetPWLTimeMap().Lookup(idEvent, pTimer))
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070057 {
58 if (pTimer)
Lei Zhang60f507b2015-06-13 00:41:00 -070059 {
60 if (pTimer->m_pAttached)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070061 pTimer->m_pAttached->TimerProc();
62 }
63 }
64}
65
66/* -------------------------- CPWL_TimerHandler -------------------------- */
67
68CPWL_TimerHandler::CPWL_TimerHandler() : m_pTimer(NULL)
69{
70}
71
72CPWL_TimerHandler::~CPWL_TimerHandler()
73{
74 if (m_pTimer) delete m_pTimer;
75}
76
Tom Sepezbfa9a822015-06-09 13:24:12 -070077void CPWL_TimerHandler::BeginTimer(int32_t nElapse)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -070078{
79 if (!m_pTimer)
80 m_pTimer = new CPWL_Timer(this, GetSystemHandler());
81
82 if (m_pTimer)
83 m_pTimer->SetPWLTimer(nElapse);
84}
85
86void CPWL_TimerHandler::EndTimer()
87{
88 if (m_pTimer)
89 m_pTimer->KillPWLTimer();
90}
91
92void CPWL_TimerHandler::TimerProc()
93{
94}
95
96/* --------------------------- CPWL_MsgControl ---------------------------- */
97
98class CPWL_MsgControl
99{
100 friend class CPWL_Wnd;
101
102public:
103 CPWL_MsgControl(CPWL_Wnd * pWnd)
104 {
105// PWL_TRACE("new CPWL_MsgControl\n");
106 m_pCreatedWnd = pWnd;
107 Default();
108 }
109
110 ~CPWL_MsgControl()
111 {
112// PWL_TRACE("~CPWL_MsgControl\n");
113 Default();
114 }
115
116 void Default()
117 {
118 m_aMousePath.RemoveAll();
119 m_aKeyboardPath.RemoveAll();
120 m_pMainMouseWnd = NULL;
121 m_pMainKeyboardWnd = NULL;
122 }
123
124 FX_BOOL IsWndCreated(const CPWL_Wnd * pWnd) const
125 {
126 return m_pCreatedWnd == pWnd;
127 }
128
129 FX_BOOL IsMainCaptureMouse(const CPWL_Wnd * pWnd) const
130 {
131 return pWnd == m_pMainMouseWnd;
132 }
133
134 FX_BOOL IsWndCaptureMouse(const CPWL_Wnd * pWnd) const
135 {
136 if (pWnd)
Tom Sepezbfa9a822015-06-09 13:24:12 -0700137 for( int32_t i=0,sz=m_aMousePath.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700138 if (m_aMousePath.GetAt(i) == pWnd)
139 return TRUE;
140
141 return FALSE;
142 }
143
144 FX_BOOL IsMainCaptureKeyboard(const CPWL_Wnd * pWnd) const
145 {
146 return pWnd == m_pMainKeyboardWnd;
147 }
148
149
150 FX_BOOL IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
151 {
152 if (pWnd)
Tom Sepezbfa9a822015-06-09 13:24:12 -0700153 for( int32_t i=0,sz=m_aKeyboardPath.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700154 if (m_aKeyboardPath.GetAt(i) == pWnd)
155 return TRUE;
Lei Zhang60f507b2015-06-13 00:41:00 -0700156
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700157 return FALSE;
158 }
159
160 void SetFocus(CPWL_Wnd * pWnd)
161 {
162 m_aKeyboardPath.RemoveAll();
163
164 if (pWnd)
165 {
166 m_pMainKeyboardWnd = pWnd;
167
168 CPWL_Wnd * pParent = pWnd;
169 while (pParent)
170 {
171 m_aKeyboardPath.Add(pParent);
172 pParent = pParent->GetParentWindow();
173 }
174
175 pWnd->OnSetFocus();
176 }
177 }
178
179 void KillFocus()
180 {
181 if (m_aKeyboardPath.GetSize() > 0)
182 if (CPWL_Wnd* pWnd = m_aKeyboardPath.GetAt(0))
183 pWnd->OnKillFocus();
184
185 m_pMainKeyboardWnd = NULL;
186 m_aKeyboardPath.RemoveAll();
187 }
188
189 void SetCapture(CPWL_Wnd * pWnd)
190 {
191 m_aMousePath.RemoveAll();
192
193 if (pWnd)
194 {
195 m_pMainMouseWnd = pWnd;
196
197 CPWL_Wnd * pParent = pWnd;
198 while (pParent)
199 {
200 m_aMousePath.Add(pParent);
201 pParent = pParent->GetParentWindow();
202 }
203 }
204 }
205
206 void ReleaseCapture()
207 {
208 m_pMainMouseWnd = NULL;
209 m_aMousePath.RemoveAll();
210 }
211
212private:
213 CFX_ArrayTemplate<CPWL_Wnd*> m_aMousePath;
214 CFX_ArrayTemplate<CPWL_Wnd*> m_aKeyboardPath;
215 CPWL_Wnd* m_pCreatedWnd;
216 CPWL_Wnd* m_pMainMouseWnd;
217 CPWL_Wnd* m_pMainKeyboardWnd;
218};
219
220/* --------------------------- CPWL_Wnd ---------------------------- */
221
222CPWL_Wnd::CPWL_Wnd() :
223 m_pVScrollBar(NULL),
224 m_rcWindow(),
225 m_rcClip(),
Lei Zhang60f507b2015-06-13 00:41:00 -0700226 m_bCreated(FALSE),
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700227 m_bVisible(FALSE),
228 m_bNotifying(FALSE),
229 m_bEnabled(TRUE)
230{
231}
232
233CPWL_Wnd::~CPWL_Wnd()
234{
235 ASSERT(m_bCreated == FALSE);
236}
237
238CFX_ByteString CPWL_Wnd::GetClassName() const
239{
240 return "CPWL_Wnd";
241}
242
243void CPWL_Wnd::Create(const PWL_CREATEPARAM & cp)
244{
245 if (!IsValid())
246 {
247 m_sPrivateParam = cp;
248
249 OnCreate(m_sPrivateParam);
250
251 m_sPrivateParam.rcRectWnd.Normalize();
252 m_rcWindow = m_sPrivateParam.rcRectWnd;
253 m_rcClip = CPWL_Utils::InflateRect(m_rcWindow,1.0f);
254
255 CreateMsgControl();
256
257 if (m_sPrivateParam.pParentWnd)
258 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_ADDCHILD);
259
260 PWL_CREATEPARAM ccp = m_sPrivateParam;
261
262 ccp.dwFlags &= 0xFFFF0000L; //remove sub styles
263 ccp.mtChild = CPDF_Matrix(1,0,0,1,0,0);
Lei Zhang60f507b2015-06-13 00:41:00 -0700264
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700265 CreateScrollBar(ccp);
Lei Zhang60f507b2015-06-13 00:41:00 -0700266 CreateChildWnd(ccp);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700267
268 m_bVisible = HasFlag(PWS_VISIBLE);
269
270 OnCreated();
271
272 RePosChildWnd();
273 m_bCreated = TRUE;
274 }
275}
276
277void CPWL_Wnd::OnCreate(PWL_CREATEPARAM & cp)
278{
279}
280
281void CPWL_Wnd::OnCreated()
282{
283}
284
285void CPWL_Wnd::OnDestroy()
286{
287}
288
289void CPWL_Wnd::Destroy()
290{
291 KillFocus();
292
293 OnDestroy();
294
295 if (m_bCreated)
296 {
Tom Sepezbfa9a822015-06-09 13:24:12 -0700297 for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700298 {
299 if (CPWL_Wnd * pChild = m_aChildren[i])
300 {
301 pChild->Destroy();
302 delete pChild;
303 pChild = NULL;
304 }
305 }
306
307 if (m_sPrivateParam.pParentWnd)
308 m_sPrivateParam.pParentWnd->OnNotify(this, PNM_REMOVECHILD);
309 m_bCreated = FALSE;
310 }
311
312 DestroyMsgControl();
313
314 FXSYS_memset(&m_sPrivateParam, 0, sizeof(PWL_CREATEPARAM));
Lei Zhang60f507b2015-06-13 00:41:00 -0700315 m_aChildren.RemoveAll();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700316 m_pVScrollBar = NULL;
317}
318
319void CPWL_Wnd::Move(const CPDF_Rect & rcNew, FX_BOOL bReset,FX_BOOL bRefresh)
320{
321 if (IsValid())
322 {
Lei Zhang60f507b2015-06-13 00:41:00 -0700323 CPDF_Rect rcOld = GetWindowRect();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700324
325 m_rcWindow = rcNew;
326 m_rcWindow.Normalize();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700327
328 if (rcOld.left != rcNew.left || rcOld.right != rcNew.right ||
329 rcOld.top != rcNew.top || rcOld.bottom != rcNew.bottom)
330 {
331 if (bReset)
332 {
Lei Zhang60f507b2015-06-13 00:41:00 -0700333 RePosChildWnd();
334 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700335
336 }
337 if (bRefresh)
Lei Zhang60f507b2015-06-13 00:41:00 -0700338 {
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700339 InvalidateRectMove(rcOld,rcNew);
340 }
341
342 m_sPrivateParam.rcRectWnd = m_rcWindow;
343 }
344}
345
346void CPWL_Wnd::InvalidateRectMove(const CPDF_Rect & rcOld, const CPDF_Rect & rcNew)
347{
348 CPDF_Rect rcUnion = rcOld;
349 rcUnion.Union(rcNew);
350
351 InvalidateRect(&rcUnion);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700352}
353
354void CPWL_Wnd::GetAppearanceStream(CFX_ByteString & sAppStream)
355{
356 if (IsValid())
357 {
358 CFX_ByteTextBuf sTextBuf;
359 GetAppearanceStream(sTextBuf);
360 sAppStream += sTextBuf.GetByteString();
361 }
362}
363
364void CPWL_Wnd::GetAppearanceStream(CFX_ByteTextBuf & sAppStream)
365{
366 if (IsValid() && IsVisible())
367 {
368 GetThisAppearanceStream(sAppStream);
369 GetChildAppearanceStream(sAppStream);
370 }
371}
372
373//if don't set,Get default apperance stream
374void CPWL_Wnd::GetThisAppearanceStream(CFX_ByteTextBuf & sAppStream)
375{
Lei Zhang60f507b2015-06-13 00:41:00 -0700376 CPDF_Rect rectWnd = GetWindowRect();
377 if (!rectWnd.IsEmpty()) {
378 CFX_ByteTextBuf sThis;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700379
Lei Zhang60f507b2015-06-13 00:41:00 -0700380 if (HasFlag(PWS_BACKGROUND))
381 sThis << CPWL_Utils::GetRectFillAppStream(rectWnd, GetBackgroundColor());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700382
Lei Zhang60f507b2015-06-13 00:41:00 -0700383 if (HasFlag(PWS_BORDER)) {
384 sThis << CPWL_Utils::GetBorderAppStream(
385 rectWnd,
386 (FX_FLOAT)GetBorderWidth(),
387 GetBorderColor(),
388 GetBorderLeftTopColor(GetBorderStyle()),
389 GetBorderRightBottomColor(GetBorderStyle()),
390 GetBorderStyle(),
391 GetBorderDash());
392 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700393
Lei Zhang60f507b2015-06-13 00:41:00 -0700394 sAppStream << sThis;
395 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700396}
397
398void CPWL_Wnd::GetChildAppearanceStream(CFX_ByteTextBuf & sAppStream)
399{
Tom Sepezbfa9a822015-06-09 13:24:12 -0700400 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700401 {
402 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
403 {
404 pChild->GetAppearanceStream(sAppStream);
405 }
406 }
407}
408
409void CPWL_Wnd::DrawAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
410{
411 if (IsValid() && IsVisible())
412 {
413 DrawThisAppearance(pDevice,pUser2Device);
414 DrawChildAppearance(pDevice,pUser2Device);
415 }
416}
417
418void CPWL_Wnd::DrawThisAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
419{
420 CPDF_Rect rectWnd = GetWindowRect();
421 if (!rectWnd.IsEmpty())
Lei Zhang60f507b2015-06-13 00:41:00 -0700422 {
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700423 if (HasFlag(PWS_BACKGROUND))
424 {
425 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rectWnd,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
Lei Zhang60f507b2015-06-13 00:41:00 -0700426 CPWL_Utils::DrawFillRect(pDevice,pUser2Device,rcClient, GetBackgroundColor(), GetTransparency());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700427 }
428
429 if (HasFlag(PWS_BORDER))
430 CPWL_Utils::DrawBorder(pDevice,
431 pUser2Device,
432 rectWnd,
433 (FX_FLOAT)GetBorderWidth(),
434 GetBorderColor(),
Lei Zhang60f507b2015-06-13 00:41:00 -0700435 GetBorderLeftTopColor(GetBorderStyle()),
436 GetBorderRightBottomColor(GetBorderStyle()),
437 GetBorderStyle(),
438 GetBorderDash(),
439 GetTransparency());
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700440 }
441}
442
443void CPWL_Wnd::DrawChildAppearance(CFX_RenderDevice* pDevice, CPDF_Matrix* pUser2Device)
444{
Tom Sepezbfa9a822015-06-09 13:24:12 -0700445 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700446 {
447 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
448 {
449 CPDF_Matrix mt = pChild->GetChildMatrix();
450 if (mt.IsIdentity())
451 {
452 pChild->DrawAppearance(pDevice,pUser2Device);
453 }
454 else
455 {
456 mt.Concat(*pUser2Device);
457 pChild->DrawAppearance(pDevice,&mt);
458 }
459 }
460 }
461}
462
463void CPWL_Wnd::InvalidateRect(CPDF_Rect* pRect)
464{
465 if (IsValid())
466 {
467 CPDF_Rect rcRefresh = pRect ? *pRect : GetWindowRect();
468
469 if (!HasFlag(PWS_NOREFRESHCLIP))
470 {
Lei Zhang60f507b2015-06-13 00:41:00 -0700471 CPDF_Rect rcClip = GetClipRect();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700472 if (!rcClip.IsEmpty())
473 {
474 rcRefresh.Intersect(rcClip);
475 }
476 }
477
478 FX_RECT rcWin = PWLtoWnd(rcRefresh);
479 rcWin.left -= PWL_INVALIDATE_INFLATE;
480 rcWin.top -= PWL_INVALIDATE_INFLATE;
481 rcWin.right += PWL_INVALIDATE_INFLATE;
482 rcWin.bottom += PWL_INVALIDATE_INFLATE;
483
484 if (IFX_SystemHandler* pSH = GetSystemHandler())
485 {
486 if (FX_HWND hWnd = GetAttachedHWnd())
487 {
488 pSH->InvalidateRect(hWnd, rcWin);
489 }
490 }
491 }
492}
493
494#define PWL_IMPLEMENT_KEY_METHOD(key_method_name)\
495FX_BOOL CPWL_Wnd::key_method_name(FX_WORD nChar, FX_DWORD nFlag)\
496{\
497 if (IsValid() && IsVisible() && IsEnabled())\
498 {\
499 if (IsWndCaptureKeyboard(this))\
500 {\
Tom Sepezbfa9a822015-06-09 13:24:12 -0700501 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700502 {\
503 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
504 {\
505 if (IsWndCaptureKeyboard(pChild))\
506 {\
507 return pChild->key_method_name(nChar,nFlag);\
508 }\
509 }\
510 }\
511 }\
512 }\
513 return FALSE;\
514}
515
516#define PWL_IMPLEMENT_MOUSE_METHOD(mouse_method_name)\
517FX_BOOL CPWL_Wnd::mouse_method_name(const CPDF_Point & point, FX_DWORD nFlag)\
518{\
519 if (IsValid() && IsVisible() && IsEnabled())\
520 {\
521 if (IsWndCaptureMouse(this))\
522 {\
Tom Sepezbfa9a822015-06-09 13:24:12 -0700523 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700524 {\
525 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
526 {\
527 if (IsWndCaptureMouse(pChild))\
528 {\
529 return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
530 }\
531 }\
532 }\
533 SetCursor();\
534 }\
535 else\
536 {\
Tom Sepezbfa9a822015-06-09 13:24:12 -0700537 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)\
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700538 {\
539 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))\
540 {\
541 if (pChild->WndHitTest(pChild->ParentToChild(point)))\
542 {\
543 return pChild->mouse_method_name(pChild->ParentToChild(point),nFlag);\
544 }\
545 }\
546 }\
Lei Zhang60f507b2015-06-13 00:41:00 -0700547 if (WndHitTest(point))\
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700548 SetCursor();\
549 }\
550 }\
551 return FALSE;\
552}
553
554PWL_IMPLEMENT_KEY_METHOD(OnKeyDown)
555PWL_IMPLEMENT_KEY_METHOD(OnKeyUp)
556PWL_IMPLEMENT_KEY_METHOD(OnChar)
557
558PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDblClk)
559PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonDown)
560PWL_IMPLEMENT_MOUSE_METHOD(OnLButtonUp)
561PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDblClk)
562PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonDown)
563PWL_IMPLEMENT_MOUSE_METHOD(OnMButtonUp)
564PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDblClk)
565PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonDown)
566PWL_IMPLEMENT_MOUSE_METHOD(OnRButtonUp)
567PWL_IMPLEMENT_MOUSE_METHOD(OnMouseMove)
568
569FX_BOOL CPWL_Wnd::OnMouseWheel(short zDelta, const CPDF_Point & point, FX_DWORD nFlag)
570{
571 if (IsValid() && IsVisible() && IsEnabled())
572 {
573 SetCursor();
574 if (IsWndCaptureKeyboard(this))
575 {
Tom Sepezbfa9a822015-06-09 13:24:12 -0700576 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700577 {
578 if (CPWL_Wnd * pChild = m_aChildren.GetAt(i))
579 {
580 if (IsWndCaptureKeyboard(pChild))
581 {
582 return pChild->OnMouseWheel(zDelta,pChild->ParentToChild(point), nFlag);
583 }
584 }
585 }
586 }
587 }
588 return FALSE;
589}
590
591void CPWL_Wnd::AddChild(CPWL_Wnd * pWnd)
592{
593 m_aChildren.Add(pWnd);
594}
595
596void CPWL_Wnd::RemoveChild(CPWL_Wnd * pWnd)
597{
Tom Sepezbfa9a822015-06-09 13:24:12 -0700598 for (int32_t i = m_aChildren.GetSize()-1; i >= 0; i --)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700599 {
600 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
601 {
602 if (pChild == pWnd)
603 {
604 m_aChildren.RemoveAt(i);
605 break;
606 }
607 }
608 }
609}
610
Tom Sepezbfa9a822015-06-09 13:24:12 -0700611void CPWL_Wnd::OnNotify(CPWL_Wnd* pWnd, FX_DWORD msg, intptr_t wParam, intptr_t lParam)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700612{
613 switch (msg)
614 {
615 case PNM_ADDCHILD:
Lei Zhang60f507b2015-06-13 00:41:00 -0700616 AddChild(pWnd);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700617 break;
618 case PNM_REMOVECHILD:
Lei Zhang60f507b2015-06-13 00:41:00 -0700619 RemoveChild(pWnd);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700620 break;
621 default:
622 break;
623 }
624}
625
626FX_BOOL CPWL_Wnd::IsValid() const
627{
628 return m_bCreated;
629}
630
631PWL_CREATEPARAM CPWL_Wnd::GetCreationParam() const
632{
633 return m_sPrivateParam;
634}
635
636CPWL_Wnd* CPWL_Wnd::GetParentWindow() const
637{
638 return m_sPrivateParam.pParentWnd;
639}
640
641CPDF_Rect CPWL_Wnd::GetOriginWindowRect() const
642{
643 return m_sPrivateParam.rcRectWnd;
644}
645
646CPDF_Rect CPWL_Wnd::GetWindowRect() const
647{
648 return m_rcWindow;
649}
650
651CPDF_Rect CPWL_Wnd::GetClientRect() const
652{
653 CPDF_Rect rcWindow = GetWindowRect();
654 CPDF_Rect rcClient = CPWL_Utils::DeflateRect(rcWindow,(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
655
Lei Zhang60f507b2015-06-13 00:41:00 -0700656 if (CPWL_ScrollBar * pVSB = GetVScrollBar())
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700657 rcClient.right -= pVSB->GetScrollBarWidth();
658
659 rcClient.Normalize();
660
661 if (rcWindow.Contains(rcClient))
662 return rcClient;
663 else
664 return CPDF_Rect();
665}
666
667CPDF_Point CPWL_Wnd::GetCenterPoint() const
668{
669 CPDF_Rect rcClient = GetClientRect();
670
671 return CPDF_Point((rcClient.left + rcClient.right) * 0.5f,
672 (rcClient.top + rcClient.bottom) * 0.5f);
673}
674
675CPDF_Rect CPWL_Wnd::GetClientCenterSquare() const
676{
677 return CPWL_Utils::GetCenterSquare(GetClientRect());
678}
679
680CPDF_Rect CPWL_Wnd::GetWindowCenterSquare() const
681{
682 return CPWL_Utils::GetCenterSquare(CPWL_Utils::DeflateRect(GetWindowRect(),0.1f));
683}
684
685FX_BOOL CPWL_Wnd::HasFlag(FX_DWORD dwFlags) const
686{
687 return (m_sPrivateParam.dwFlags & dwFlags) != 0;
688}
689
690void CPWL_Wnd::RemoveFlag(FX_DWORD dwFlags)
691{
692 m_sPrivateParam.dwFlags &= ~dwFlags;
693}
694
695void CPWL_Wnd::AddFlag(FX_DWORD dwFlags)
696{
697 m_sPrivateParam.dwFlags |= dwFlags;
698}
699
700CPWL_Color CPWL_Wnd::GetBackgroundColor() const
701{
702 return m_sPrivateParam.sBackgroundColor;
703}
704
705void CPWL_Wnd::SetBackgroundColor(const CPWL_Color & color)
706{
707 m_sPrivateParam.sBackgroundColor = color;
708}
709
710void CPWL_Wnd::SetTextColor(const CPWL_Color & color)
711{
712 m_sPrivateParam.sTextColor = color;
713}
714
715void CPWL_Wnd::SetTextStrokeColor(const CPWL_Color & color)
716{
717 m_sPrivateParam.sTextStrokeColor = color;
718}
719
720CPWL_Color CPWL_Wnd::GetTextColor() const
721{
722 return m_sPrivateParam.sTextColor;
723}
724
725CPWL_Color CPWL_Wnd::GetTextStrokeColor() const
726{
727 return m_sPrivateParam.sTextStrokeColor;
728}
729
Tom Sepezbfa9a822015-06-09 13:24:12 -0700730int32_t CPWL_Wnd::GetBorderStyle() const
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700731{
732 return m_sPrivateParam.nBorderStyle;
733}
734
Tom Sepezbfa9a822015-06-09 13:24:12 -0700735void CPWL_Wnd::SetBorderStyle(int32_t nBorderStyle)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700736{
737 if (HasFlag(PWS_BORDER))
738 m_sPrivateParam.nBorderStyle = nBorderStyle;
739}
740
Tom Sepezbfa9a822015-06-09 13:24:12 -0700741int32_t CPWL_Wnd::GetBorderWidth() const
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700742{
743 if (HasFlag(PWS_BORDER))
744 return m_sPrivateParam.dwBorderWidth;
745
746 return 0;
747}
748
Tom Sepezbfa9a822015-06-09 13:24:12 -0700749int32_t CPWL_Wnd::GetInnerBorderWidth() const
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700750{
751 /*
752 switch (GetBorderStyle())
753 {
754 case PBS_BEVELED:
755 case PBS_INSET:
756 return GetBorderWidth() / 2;
757 }
758 */
759 return 0;
760}
761
Tom Sepezbfa9a822015-06-09 13:24:12 -0700762void CPWL_Wnd::SetBorderWidth(int32_t nBorderWidth)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700763{
764 if (HasFlag(PWS_BORDER))
765 m_sPrivateParam.dwBorderWidth = nBorderWidth;
766}
767
768CPWL_Color CPWL_Wnd::GetBorderColor() const
769{
770 if (HasFlag(PWS_BORDER))
771 return m_sPrivateParam.sBorderColor;
772
773 return CPWL_Color();
774}
775
776void CPWL_Wnd::SetBorderColor(const CPWL_Color & color)
777{
778 if (HasFlag(PWS_BORDER))
779 m_sPrivateParam.sBorderColor = color;
780}
781
782CPWL_Dash CPWL_Wnd::GetBorderDash() const
783{
784 return m_sPrivateParam.sDash;
785}
786
787void* CPWL_Wnd::GetAttachedData() const
788{
789 return m_sPrivateParam.pAttachedData;
790}
791
792void CPWL_Wnd::SetBorderDash(const CPWL_Dash & sDash)
793{
794 if (HasFlag(PWS_BORDER))
795 m_sPrivateParam.sDash = sDash;
796}
797
798CPWL_ScrollBar* CPWL_Wnd::GetVScrollBar() const
799{
800 if (HasFlag(PWS_VSCROLL))
801 return m_pVScrollBar;
802
803 return NULL;
804}
805
806void CPWL_Wnd::CreateScrollBar(const PWL_CREATEPARAM & cp)
807{
808 CreateVScrollBar(cp);
809}
810
811void CPWL_Wnd::CreateVScrollBar(const PWL_CREATEPARAM & cp)
812{
813 if (!m_pVScrollBar && HasFlag(PWS_VSCROLL))
814 {
815 PWL_CREATEPARAM scp = cp;
816
817 //flags
818 scp.dwFlags = PWS_CHILD| PWS_BACKGROUND | PWS_AUTOTRANSPARENT | PWS_NOREFRESHCLIP;
Lei Zhang60f507b2015-06-13 00:41:00 -0700819
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700820 scp.pParentWnd = this;
821 scp.sBackgroundColor = PWL_DEFAULT_WHITECOLOR;
822 scp.eCursorType = FXCT_ARROW;
823 scp.nTransparency = PWL_SCROLLBAR_TRANSPARANCY;
824
825 if ((m_pVScrollBar = new CPWL_ScrollBar(SBT_VSCROLL)))
826 m_pVScrollBar->Create(scp);
827 }
828}
829
830void CPWL_Wnd::SetCapture()
831{
832 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
833 pMsgCtrl->SetCapture(this);
834}
835
836void CPWL_Wnd::ReleaseCapture()
837{
Tom Sepezbfa9a822015-06-09 13:24:12 -0700838 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700839 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
840 pChild->ReleaseCapture();
841
842 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
843 pMsgCtrl->ReleaseCapture();
844}
845
846void CPWL_Wnd::SetFocus()
847{
848 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
849 {
850 if (!pMsgCtrl->IsMainCaptureKeyboard(this))
851 pMsgCtrl->KillFocus();
852 pMsgCtrl->SetFocus(this);
853 }
854}
855
856void CPWL_Wnd::KillFocus()
857{
858 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
859 {
860 if (pMsgCtrl->IsWndCaptureKeyboard(this))
861 pMsgCtrl->KillFocus();
862 }
863}
864
865void CPWL_Wnd::OnSetFocus()
866{
867}
868
869void CPWL_Wnd::OnKillFocus()
870{
871}
872
873FX_BOOL CPWL_Wnd::WndHitTest(const CPDF_Point & point) const
874{
875 return IsValid() && IsVisible() && GetWindowRect().Contains(point.x,point.y);
876}
877
878FX_BOOL CPWL_Wnd::ClientHitTest(const CPDF_Point & point) const
879{
880 return IsValid() && IsVisible() && GetClientRect().Contains(point.x,point.y);
881}
882
883const CPWL_Wnd * CPWL_Wnd::GetRootWnd() const
884{
885 if (m_sPrivateParam.pParentWnd)
886 return m_sPrivateParam.pParentWnd->GetRootWnd();
887 else
888 return this;
889}
890
891void CPWL_Wnd::SetVisible(FX_BOOL bVisible)
892{
893 if (IsValid())
894 {
Tom Sepezbfa9a822015-06-09 13:24:12 -0700895 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700896 {
897 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
898 {
899 pChild->SetVisible(bVisible);
900 }
901 }
902
903 if (bVisible != m_bVisible)
904 {
905 m_bVisible = bVisible;
Lei Zhang60f507b2015-06-13 00:41:00 -0700906 RePosChildWnd();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700907 InvalidateRect();
Lei Zhang60f507b2015-06-13 00:41:00 -0700908 }
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700909 }
910}
911
912void CPWL_Wnd::SetClipRect(const CPDF_Rect & rect)
913{
914 m_rcClip = rect;
915 m_rcClip.Normalize();
916}
917
918CPDF_Rect CPWL_Wnd::GetClipRect() const
919{
920 return m_rcClip;
921}
922
923FX_BOOL CPWL_Wnd::IsReadOnly() const
924{
925 return HasFlag(PWS_READONLY);
926}
927
928void CPWL_Wnd::RePosChildWnd()
929{
930 CPDF_Rect rcContent = CPWL_Utils::DeflateRect(GetWindowRect(),(FX_FLOAT)(GetBorderWidth()+GetInnerBorderWidth()));
931
Lei Zhang60f507b2015-06-13 00:41:00 -0700932 CPWL_ScrollBar * pVSB = GetVScrollBar();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700933
934 CPDF_Rect rcVScroll = CPDF_Rect(rcContent.right - PWL_SCROLLBAR_WIDTH,
935 rcContent.bottom,
936 rcContent.right-1.0f,
937 rcContent.top);
938
939 if (pVSB) pVSB->Move(rcVScroll,TRUE,FALSE);
940}
941
942void CPWL_Wnd::CreateChildWnd(const PWL_CREATEPARAM & cp)
943{
944}
945
946void CPWL_Wnd::SetCursor()
947{
Lei Zhang60f507b2015-06-13 00:41:00 -0700948 if (IsValid())
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700949 {
950 if (IFX_SystemHandler* pSH = GetSystemHandler())
951 {
Lei Zhang60f507b2015-06-13 00:41:00 -0700952 int32_t nCursorType = GetCreationParam().eCursorType;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -0700953 pSH->SetCursor(nCursorType);
954 }
955 }
956}
957
958void CPWL_Wnd::CreateMsgControl()
959{
960 if (!m_sPrivateParam.pMsgControl)
961 m_sPrivateParam.pMsgControl = new CPWL_MsgControl(this);
962}
963
964void CPWL_Wnd::DestroyMsgControl()
965{
966 if (CPWL_MsgControl* pMsgControl = GetMsgControl())
967 if (pMsgControl->IsWndCreated(this))
968 delete pMsgControl;
969}
970
971CPWL_MsgControl* CPWL_Wnd::GetMsgControl() const
972{
973 return m_sPrivateParam.pMsgControl;
974}
975
976FX_BOOL CPWL_Wnd::IsCaptureMouse() const
977{
978 return IsWndCaptureMouse(this);
979}
980
981FX_BOOL CPWL_Wnd::IsWndCaptureMouse(const CPWL_Wnd * pWnd) const
982{
983 if (CPWL_MsgControl * pCtrl = GetMsgControl())
984 return pCtrl->IsWndCaptureMouse(pWnd);
985
986 return FALSE;
987}
988
989FX_BOOL CPWL_Wnd::IsWndCaptureKeyboard(const CPWL_Wnd * pWnd) const
990{
991 if (CPWL_MsgControl * pCtrl = GetMsgControl())
992 return pCtrl->IsWndCaptureKeyboard(pWnd);
993
994 return FALSE;
995}
996
997FX_BOOL CPWL_Wnd::IsFocused() const
998{
999 if (CPWL_MsgControl * pCtrl = GetMsgControl())
1000 return pCtrl->IsMainCaptureKeyboard(this);
1001
1002 return FALSE;
1003}
1004
1005CPDF_Rect CPWL_Wnd::GetFocusRect() const
1006{
Lei Zhang60f507b2015-06-13 00:41:00 -07001007 return CPWL_Utils::InflateRect(GetWindowRect(),1);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001008}
1009
1010FX_FLOAT CPWL_Wnd::GetFontSize() const
1011{
Lei Zhang60f507b2015-06-13 00:41:00 -07001012 return m_sPrivateParam.fFontSize;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001013}
1014
1015void CPWL_Wnd::SetFontSize(FX_FLOAT fFontSize)
1016{
Lei Zhang60f507b2015-06-13 00:41:00 -07001017 m_sPrivateParam.fFontSize = fFontSize;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001018}
1019
1020IFX_SystemHandler* CPWL_Wnd::GetSystemHandler() const
1021{
1022 return m_sPrivateParam.pSystemHandler;
1023}
1024
1025IPWL_FocusHandler* CPWL_Wnd::GetFocusHandler() const
1026{
1027 return m_sPrivateParam.pFocusHandler;
1028}
1029
1030IPWL_Provider* CPWL_Wnd::GetProvider() const
1031{
1032 return m_sPrivateParam.pProvider;
1033}
1034
1035IFX_Edit_FontMap* CPWL_Wnd::GetFontMap() const
1036{
1037 return m_sPrivateParam.pFontMap;
1038}
1039
Tom Sepezbfa9a822015-06-09 13:24:12 -07001040CPWL_Color CPWL_Wnd::GetBorderLeftTopColor(int32_t nBorderStyle) const
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001041{
1042 CPWL_Color color;
1043
1044 switch (nBorderStyle)
1045 {
1046 case PBS_SOLID:
1047 break;
1048 case PBS_DASH:
1049 break;
1050 case PBS_BEVELED:
1051 color = CPWL_Color(COLORTYPE_GRAY,1);
1052 break;
1053 case PBS_INSET:
1054 color = CPWL_Color(COLORTYPE_GRAY,0.5f);
1055 break;
1056 case PBS_UNDERLINED:
1057 break;
1058 }
1059
1060 return color;
1061}
1062
Tom Sepezbfa9a822015-06-09 13:24:12 -07001063CPWL_Color CPWL_Wnd::GetBorderRightBottomColor(int32_t nBorderStyle) const
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001064{
1065 CPWL_Color color;
1066
1067 switch (nBorderStyle)
1068 {
1069 case PBS_SOLID:
1070 break;
1071 case PBS_DASH:
1072 break;
1073 case PBS_BEVELED:
1074 color = CPWL_Utils::DevideColor(GetBackgroundColor(),2);
1075 break;
1076 case PBS_INSET:
1077 color = CPWL_Color(COLORTYPE_GRAY,0.75f);
1078 break;
1079 case PBS_UNDERLINED:
1080 break;
1081 }
1082
1083 return color;
1084}
1085
1086/* ----------------------------------------------------------------- */
1087
Tom Sepezbfa9a822015-06-09 13:24:12 -07001088int32_t CPWL_Wnd::GetTransparency()
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001089{
1090 return m_sPrivateParam.nTransparency;
1091}
1092
Tom Sepezbfa9a822015-06-09 13:24:12 -07001093void CPWL_Wnd::SetTransparency(int32_t nTransparency)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001094{
Tom Sepezbfa9a822015-06-09 13:24:12 -07001095 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001096 {
1097 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
1098 {
1099 pChild->SetTransparency(nTransparency);
1100 }
1101 }
1102
1103 m_sPrivateParam.nTransparency = nTransparency;
1104}
1105
1106CPDF_Matrix CPWL_Wnd::GetWindowMatrix() const
1107{
Lei Zhang60f507b2015-06-13 00:41:00 -07001108 CPDF_Matrix mt = GetChildToRoot();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001109
1110 if (IPWL_Provider* pProvider = GetProvider())
1111 {
1112 mt.Concat(pProvider->GetWindowMatrix(GetAttachedData()));
1113 return mt;
1114 }
1115
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001116 return mt;
1117}
1118
Tom Sepezbfa9a822015-06-09 13:24:12 -07001119void CPWL_Wnd::PWLtoWnd(const CPDF_Point& point, int32_t& x, int32_t& y) const
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001120{
1121 CPDF_Matrix mt = GetWindowMatrix();
1122 CPDF_Point pt = point;
1123 mt.Transform(pt.x,pt.y);
Tom Sepezbfa9a822015-06-09 13:24:12 -07001124 x = (int32_t)(pt.x+0.5);
1125 y = (int32_t)(pt.y+0.5);
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001126}
1127
1128FX_RECT CPWL_Wnd::PWLtoWnd(const CPDF_Rect & rect) const
1129{
1130 CPDF_Rect rcTemp = rect;
1131 CPDF_Matrix mt = GetWindowMatrix();
Lei Zhang60f507b2015-06-13 00:41:00 -07001132 mt.TransformRect(rcTemp);
Tom Sepezbfa9a822015-06-09 13:24:12 -07001133 return FX_RECT((int32_t)(rcTemp.left+0.5), (int32_t)(rcTemp.bottom+0.5), (int32_t)(rcTemp.right+0.5), (int32_t)(rcTemp.top+0.5));
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001134}
1135
1136FX_HWND CPWL_Wnd::GetAttachedHWnd() const
1137{
1138 return m_sPrivateParam.hAttachedWnd;
1139}
1140
1141CPDF_Point CPWL_Wnd::ChildToParent(const CPDF_Point& point) const
1142{
1143 CPDF_Matrix mt = GetChildMatrix();
1144 if (mt.IsIdentity())
1145 return point;
1146 else
1147 {
1148 CPDF_Point pt = point;
1149 mt.Transform(pt.x,pt.y);
1150 return pt;
1151 }
1152}
1153
1154CPDF_Rect CPWL_Wnd::ChildToParent(const CPDF_Rect& rect) const
1155{
1156 CPDF_Matrix mt = GetChildMatrix();
1157 if (mt.IsIdentity())
1158 return rect;
1159 else
1160 {
1161 CPDF_Rect rc = rect;
1162 mt.TransformRect(rc);
1163 return rc;
1164 }
1165}
1166
1167CPDF_Point CPWL_Wnd::ParentToChild(const CPDF_Point& point) const
1168{
1169 CPDF_Matrix mt = GetChildMatrix();
1170 if (mt.IsIdentity())
1171 return point;
1172 else
1173 {
1174 mt.SetReverse(mt);
1175 CPDF_Point pt = point;
1176 mt.Transform(pt.x,pt.y);
1177 return pt;
1178 }
1179}
1180
1181CPDF_Rect CPWL_Wnd::ParentToChild(const CPDF_Rect& rect) const
1182{
1183 CPDF_Matrix mt = GetChildMatrix();
1184 if (mt.IsIdentity())
1185 return rect;
1186 else
1187 {
1188 mt.SetReverse(mt);
1189 CPDF_Rect rc = rect;
1190 mt.TransformRect(rc);
1191 return rc;
1192 }
1193}
1194
1195CPDF_Matrix CPWL_Wnd::GetChildToRoot() const
1196{
1197 CPDF_Matrix mt(1,0,0,1,0,0);
Lei Zhang60f507b2015-06-13 00:41:00 -07001198
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001199 if (HasFlag(PWS_CHILD))
1200 {
1201 const CPWL_Wnd* pParent = this;
1202 while (pParent)
1203 {
1204 mt.Concat(pParent->GetChildMatrix());
1205 pParent = pParent->GetParentWindow();
1206 }
1207 }
1208
1209 return mt;
1210}
1211
1212CPDF_Matrix CPWL_Wnd::GetChildMatrix() const
1213{
1214 if (HasFlag(PWS_CHILD))
1215 return m_sPrivateParam.mtChild;
1216
1217 return CPDF_Matrix(1,0,0,1,0,0);
1218}
1219
1220void CPWL_Wnd::SetChildMatrix(const CPDF_Matrix& mt)
1221{
1222 m_sPrivateParam.mtChild = mt;
1223}
1224
1225const CPWL_Wnd* CPWL_Wnd::GetFocused() const
1226{
1227 if (CPWL_MsgControl * pMsgCtrl = GetMsgControl())
1228 {
1229 return pMsgCtrl->m_pMainKeyboardWnd;
1230 }
1231
1232 return NULL;
1233}
1234
1235void CPWL_Wnd::EnableWindow(FX_BOOL bEnable)
1236{
1237 if (m_bEnabled != bEnable)
1238 {
Tom Sepezbfa9a822015-06-09 13:24:12 -07001239 for (int32_t i=0,sz=m_aChildren.GetSize(); i<sz; i++)
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001240 {
1241 if (CPWL_Wnd* pChild = m_aChildren.GetAt(i))
1242 {
1243 pChild->EnableWindow(bEnable);
1244 }
1245 }
1246
Lei Zhang60f507b2015-06-13 00:41:00 -07001247 m_bEnabled = bEnable;
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001248
1249 if (bEnable)
Lei Zhang60f507b2015-06-13 00:41:00 -07001250 OnEnabled();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001251 else
Lei Zhang60f507b2015-06-13 00:41:00 -07001252 OnDisabled();
John Abd-El-Malek3f3b45c2014-05-23 17:28:10 -07001253 }
1254}
1255
1256FX_BOOL CPWL_Wnd::IsEnabled()
1257{
1258 return m_bEnabled;
1259}
1260
1261void CPWL_Wnd::OnEnabled()
1262{
1263}
1264
1265void CPWL_Wnd::OnDisabled()
1266{
1267}
1268
1269FX_BOOL CPWL_Wnd::IsCTRLpressed(FX_DWORD nFlag) const
1270{
1271 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1272 {
1273 return pSystemHandler->IsCTRLKeyDown(nFlag);
1274 }
1275
1276 return FALSE;
1277}
1278
1279FX_BOOL CPWL_Wnd::IsSHIFTpressed(FX_DWORD nFlag) const
1280{
1281 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1282 {
1283 return pSystemHandler->IsSHIFTKeyDown(nFlag);
1284 }
1285
1286 return FALSE;
1287}
1288
1289FX_BOOL CPWL_Wnd::IsALTpressed(FX_DWORD nFlag) const
1290{
1291 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1292 {
1293 return pSystemHandler->IsALTKeyDown(nFlag);
1294 }
1295
1296 return FALSE;
1297}
1298
1299FX_BOOL CPWL_Wnd::IsINSERTpressed(FX_DWORD nFlag) const
1300{
1301 if (IFX_SystemHandler* pSystemHandler = GetSystemHandler())
1302 {
1303 return pSystemHandler->IsINSERTKeyDown(nFlag);
1304 }
1305
1306 return FALSE;
1307}
1308