OLD | NEW |
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 "xfa/fwl/core/cfwl_widgetmgr.h" | 7 #include "xfa/fwl/core/cfwl_widgetmgr.h" |
8 | 8 |
9 #include "xfa/fwl/core/cfwl_message.h" | 9 #include "xfa/fwl/core/cfwl_message.h" |
10 #include "xfa/fwl/core/fwl_noteimp.h" | 10 #include "xfa/fwl/core/fwl_noteimp.h" |
11 #include "xfa/fwl/core/ifwl_app.h" | 11 #include "xfa/fwl/core/ifwl_app.h" |
12 #include "xfa/fwl/core/ifwl_form.h" | 12 #include "xfa/fwl/core/ifwl_form.h" |
13 #include "xfa/fxfa/app/xfa_fwladapter.h" | 13 #include "xfa/fxfa/app/xfa_fwladapter.h" |
14 #include "xfa/fxfa/xfa_ffapp.h" | 14 #include "xfa/fxfa/xfa_ffapp.h" |
15 | 15 |
16 namespace { | 16 namespace { |
17 | 17 |
18 const int kNeedRepaintHitPoints = 12; | 18 const int kNeedRepaintHitPoints = 12; |
19 const int kNeedRepaintHitPiece = 3; | 19 const int kNeedRepaintHitPiece = 3; |
20 | 20 |
21 struct FWL_NEEDREPAINTHITDATA { | 21 struct FWL_NEEDREPAINTHITDATA { |
22 CFX_PointF hitPoint; | 22 CFX_PointF hitPoint; |
23 bool bNotNeedRepaint; | 23 bool bNotNeedRepaint; |
24 bool bNotContainByDirty; | 24 bool bNotContainByDirty; |
25 }; | 25 }; |
26 | 26 |
27 } // namespace | 27 } // namespace |
28 | 28 |
29 FX_BOOL FWL_UseOffscreen(IFWL_Widget* pWidget) { | 29 bool FWL_UseOffscreen(IFWL_Widget* pWidget) { |
30 #if (_FX_OS_ == _FX_MACOSX_) | 30 #if (_FX_OS_ == _FX_MACOSX_) |
31 return FALSE; | 31 return false; |
32 #else | 32 #else |
33 return !!(pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen); | 33 return !!(pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen); |
34 #endif | 34 #endif |
35 } | 35 } |
36 | 36 |
37 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) | 37 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) |
38 : m_dwCapability(0), | 38 : m_dwCapability(0), |
39 m_pDelegate(new CFWL_WidgetMgrDelegate(this)), | 39 m_pDelegate(new CFWL_WidgetMgrDelegate(this)), |
40 m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { | 40 m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { |
41 ASSERT(m_pAdapter); | 41 ASSERT(m_pAdapter); |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { | 102 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { |
103 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 103 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
104 while (pItem) { | 104 while (pItem) { |
105 if (IsAbleNative(pItem->pWidget)) | 105 if (IsAbleNative(pItem->pWidget)) |
106 return pItem->pWidget; | 106 return pItem->pWidget; |
107 pItem = pItem->pParent; | 107 pItem = pItem->pParent; |
108 } | 108 } |
109 return nullptr; | 109 return nullptr; |
110 } | 110 } |
111 | 111 |
112 FX_BOOL CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { | 112 bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { |
113 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 113 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
114 if (!pItem) | 114 if (!pItem) |
115 return FALSE; | 115 return false; |
116 if (!pItem->pParent) | 116 if (!pItem->pParent) |
117 return FALSE; | 117 return false; |
118 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; | 118 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; |
119 int32_t i = 0; | 119 int32_t i = 0; |
120 while (pChild) { | 120 while (pChild) { |
121 if (pChild == pItem) { | 121 if (pChild == pItem) { |
122 if (i == nIndex) { | 122 if (i == nIndex) { |
123 return TRUE; | 123 return true; |
124 } | 124 } |
125 if (pChild->pPrevious) { | 125 if (pChild->pPrevious) { |
126 pChild->pPrevious->pNext = pChild->pNext; | 126 pChild->pPrevious->pNext = pChild->pNext; |
127 } | 127 } |
128 if (pChild->pNext) { | 128 if (pChild->pNext) { |
129 pChild->pNext->pPrevious = pChild->pPrevious; | 129 pChild->pNext->pPrevious = pChild->pPrevious; |
130 } | 130 } |
131 if (pItem->pParent->pChild == pItem) { | 131 if (pItem->pParent->pChild == pItem) { |
132 pItem->pParent->pChild = pItem->pNext; | 132 pItem->pParent->pChild = pItem->pNext; |
133 } | 133 } |
134 pItem->pNext = nullptr; | 134 pItem->pNext = nullptr; |
135 pItem->pPrevious = nullptr; | 135 pItem->pPrevious = nullptr; |
136 break; | 136 break; |
137 } | 137 } |
138 if (!pChild->pNext) { | 138 if (!pChild->pNext) { |
139 break; | 139 break; |
140 } | 140 } |
141 pChild = pChild->pNext; | 141 pChild = pChild->pNext; |
142 ++i; | 142 ++i; |
143 } | 143 } |
144 pChild = pItem->pParent->pChild; | 144 pChild = pItem->pParent->pChild; |
145 if (pChild) { | 145 if (pChild) { |
146 if (nIndex < 0) { | 146 if (nIndex < 0) { |
147 while (pChild->pNext) { | 147 while (pChild->pNext) { |
148 pChild = pChild->pNext; | 148 pChild = pChild->pNext; |
149 } | 149 } |
150 pChild->pNext = pItem; | 150 pChild->pNext = pItem; |
151 pItem->pPrevious = pChild; | 151 pItem->pPrevious = pChild; |
152 pItem->pNext = nullptr; | 152 pItem->pNext = nullptr; |
153 return TRUE; | 153 return true; |
154 } | 154 } |
155 i = 0; | 155 i = 0; |
156 while (i < nIndex && pChild->pNext) { | 156 while (i < nIndex && pChild->pNext) { |
157 pChild = pChild->pNext; | 157 pChild = pChild->pNext; |
158 ++i; | 158 ++i; |
159 } | 159 } |
160 if (!pChild->pNext) { | 160 if (!pChild->pNext) { |
161 pChild->pNext = pItem; | 161 pChild->pNext = pItem; |
162 pItem->pPrevious = pChild; | 162 pItem->pPrevious = pChild; |
163 pItem->pNext = nullptr; | 163 pItem->pNext = nullptr; |
164 return TRUE; | 164 return true; |
165 } | 165 } |
166 if (pChild->pPrevious) { | 166 if (pChild->pPrevious) { |
167 pItem->pPrevious = pChild->pPrevious; | 167 pItem->pPrevious = pChild->pPrevious; |
168 pChild->pPrevious->pNext = pItem; | 168 pChild->pPrevious->pNext = pItem; |
169 } | 169 } |
170 pChild->pPrevious = pItem; | 170 pChild->pPrevious = pItem; |
171 pItem->pNext = pChild; | 171 pItem->pNext = pChild; |
172 if (pItem->pParent->pChild == pChild) { | 172 if (pItem->pParent->pChild == pChild) { |
173 pItem->pParent->pChild = pItem; | 173 pItem->pParent->pChild = pItem; |
174 } | 174 } |
175 } else { | 175 } else { |
176 pItem->pParent->pChild = pItem; | 176 pItem->pParent->pChild = pItem; |
177 pItem->pPrevious = nullptr; | 177 pItem->pPrevious = nullptr; |
178 pItem->pNext = nullptr; | 178 pItem->pNext = nullptr; |
179 } | 179 } |
180 return TRUE; | 180 return true; |
181 } | 181 } |
182 FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, | 182 FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, |
183 const CFX_RectF* pRect) { | 183 const CFX_RectF* pRect) { |
184 if (!m_pAdapter) | 184 if (!m_pAdapter) |
185 return FWL_Error::Indefinite; | 185 return FWL_Error::Indefinite; |
186 IFWL_Widget* pNative = pWidget; | 186 IFWL_Widget* pNative = pWidget; |
187 CFX_RectF rect(*pRect); | 187 CFX_RectF rect(*pRect); |
188 if (IsFormDisabled()) { | 188 if (IsFormDisabled()) { |
189 IFWL_Widget* pOuter = pWidget->GetOuter(); | 189 IFWL_Widget* pOuter = pWidget->GetOuter(); |
190 while (pOuter) { | 190 while (pOuter) { |
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 if (pItem->pParent->pChild == pItem) { | 306 if (pItem->pParent->pChild == pItem) { |
307 pItem->pParent->pChild = pItem->pNext; | 307 pItem->pParent->pChild = pItem->pNext; |
308 } | 308 } |
309 pItem->pNext = nullptr; | 309 pItem->pNext = nullptr; |
310 pItem->pPrevious = nullptr; | 310 pItem->pPrevious = nullptr; |
311 } | 311 } |
312 pItem->pParent = pParentItem; | 312 pItem->pParent = pParentItem; |
313 SetWidgetIndex(pChild, -1); | 313 SetWidgetIndex(pChild, -1); |
314 } | 314 } |
315 | 315 |
316 FX_BOOL CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { | 316 bool CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { |
317 IFWL_Widget* pTemp = pChild; | 317 IFWL_Widget* pTemp = pChild; |
318 do { | 318 do { |
319 if (pTemp == pParent) | 319 if (pTemp == pParent) |
320 return TRUE; | 320 return true; |
321 pTemp = GetParentWidget(pTemp); | 321 pTemp = GetParentWidget(pTemp); |
322 } while (pTemp); | 322 } while (pTemp); |
323 return FALSE; | 323 return false; |
324 } | 324 } |
325 | 325 |
326 FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, | 326 FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, |
327 const CFX_RectF& rect) { | 327 const CFX_RectF& rect) { |
328 if (FWL_UseOffscreen(pWidget)) { | 328 if (FWL_UseOffscreen(pWidget)) { |
329 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 329 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
330 pItem->iRedrawCounter++; | 330 pItem->iRedrawCounter++; |
331 if (pItem->pOffscreen) { | 331 if (pItem->pOffscreen) { |
332 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); | 332 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); |
333 if (pDevice && pDevice->GetBitmap()) { | 333 if (pDevice && pDevice->GetBitmap()) { |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 | 378 |
379 void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, | 379 void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, |
380 FX_FLOAT fx, | 380 FX_FLOAT fx, |
381 FX_FLOAT fy) { | 381 FX_FLOAT fy) { |
382 if (FWL_UseOffscreen(pForm)) | 382 if (FWL_UseOffscreen(pForm)) |
383 GetWidgetMgrItem(pForm)->pOffscreen.reset(); | 383 GetWidgetMgrItem(pForm)->pOffscreen.reset(); |
384 } | 384 } |
385 | 385 |
386 IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, | 386 IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, |
387 IFWL_Widget* focus, | 387 IFWL_Widget* focus, |
388 FX_BOOL& bFind) { | 388 bool& bFind) { |
389 CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); | 389 CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); |
390 IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); | 390 IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); |
391 while (child) { | 391 while (child) { |
392 if (focus == child) | 392 if (focus == child) |
393 bFind = TRUE; | 393 bFind = true; |
394 | 394 |
395 if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && | 395 if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && |
396 (!focus || (focus != child && bFind))) { | 396 (!focus || (focus != child && bFind))) { |
397 return child; | 397 return child; |
398 } | 398 } |
399 IFWL_Widget* bRet = nextTab(child, focus, bFind); | 399 IFWL_Widget* bRet = nextTab(child, focus, bFind); |
400 if (bRet) | 400 if (bRet) |
401 return bRet; | 401 return bRet; |
402 | 402 |
403 child = pMgr->GetNextSiblingWidget(child); | 403 child = pMgr->GetNextSiblingWidget(child); |
404 } | 404 } |
405 return nullptr; | 405 return nullptr; |
406 } | 406 } |
407 | 407 |
408 int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { | 408 int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { |
409 int32_t iRet = 0; | 409 int32_t iRet = 0; |
410 IFWL_Widget* pChild = pFirst; | 410 IFWL_Widget* pChild = pFirst; |
411 while (pChild) { | 411 while (pChild) { |
412 pChild = GetNextSiblingWidget(pChild); | 412 pChild = GetNextSiblingWidget(pChild); |
413 ++iRet; | 413 ++iRet; |
414 } | 414 } |
415 return iRet; | 415 return iRet; |
416 } | 416 } |
417 IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget, | 417 IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget, |
418 FX_BOOL bNext) { | 418 bool bNext) { |
419 return nullptr; | 419 return nullptr; |
420 } | 420 } |
421 IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( | 421 IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( |
422 IFWL_Widget* pRadioButton) { | 422 IFWL_Widget* pRadioButton) { |
423 IFWL_Widget* pNext = pRadioButton; | 423 IFWL_Widget* pNext = pRadioButton; |
424 while (pNext) { | 424 while (pNext) { |
425 if (pNext->GetStyles() & FWL_WGTSTYLE_Group) | 425 if (pNext->GetStyles() & FWL_WGTSTYLE_Group) |
426 return pNext; | 426 return pNext; |
427 pNext = GetSiblingRadioButton(pNext, FALSE); | 427 pNext = GetSiblingRadioButton(pNext, false); |
428 } | 428 } |
429 pNext = GetLastSiblingWidget(pRadioButton); | 429 pNext = GetLastSiblingWidget(pRadioButton); |
430 while ((pNext = GetSiblingRadioButton(pNext, FALSE)) != nullptr && | 430 while ((pNext = GetSiblingRadioButton(pNext, false)) != nullptr && |
431 pNext != pRadioButton) { | 431 pNext != pRadioButton) { |
432 if (pNext->GetStyles() & FWL_WGTSTYLE_Group) | 432 if (pNext->GetStyles() & FWL_WGTSTYLE_Group) |
433 return pNext; | 433 return pNext; |
434 } | 434 } |
435 pNext = GetFirstSiblingWidget(pRadioButton); | 435 pNext = GetFirstSiblingWidget(pRadioButton); |
436 return GetSiblingRadioButton(pNext, TRUE); | 436 return GetSiblingRadioButton(pNext, true); |
437 } | 437 } |
438 void CFWL_WidgetMgr::GetSameGroupRadioButton( | 438 void CFWL_WidgetMgr::GetSameGroupRadioButton( |
439 IFWL_Widget* pRadioButton, | 439 IFWL_Widget* pRadioButton, |
440 CFX_ArrayTemplate<IFWL_Widget*>& group) { | 440 CFX_ArrayTemplate<IFWL_Widget*>& group) { |
441 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); | 441 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); |
442 if (!pFirst) { | 442 if (!pFirst) { |
443 pFirst = pRadioButton; | 443 pFirst = pRadioButton; |
444 } | 444 } |
445 int32_t iGroup = CountRadioButtonGroup(pFirst); | 445 int32_t iGroup = CountRadioButtonGroup(pFirst); |
446 if (iGroup < 2) { | 446 if (iGroup < 2) { |
447 IFWL_Widget* pNext = pFirst; | 447 IFWL_Widget* pNext = pFirst; |
448 while ((pNext = GetSiblingRadioButton(pNext, TRUE)) != nullptr) { | 448 while ((pNext = GetSiblingRadioButton(pNext, true)) != nullptr) { |
449 group.Add(pNext); | 449 group.Add(pNext); |
450 } | 450 } |
451 return; | 451 return; |
452 } | 452 } |
453 IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); | 453 IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); |
454 do { | 454 do { |
455 group.Add(pNext); | 455 group.Add(pNext); |
456 pNext = GetSiblingRadioButton(pNext, TRUE); | 456 pNext = GetSiblingRadioButton(pNext, true); |
457 if (!pNext) | 457 if (!pNext) |
458 pNext = GetSiblingRadioButton(pFirst, TRUE); | 458 pNext = GetSiblingRadioButton(pFirst, true); |
459 } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); | 459 } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); |
460 } | 460 } |
461 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { | 461 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { |
462 if ((pParent->GetClassID() == FWL_Type::PushButton) && | 462 if ((pParent->GetClassID() == FWL_Type::PushButton) && |
463 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { | 463 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { |
464 return pParent; | 464 return pParent; |
465 } | 465 } |
466 IFWL_Widget* child = | 466 IFWL_Widget* child = |
467 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent); | 467 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent); |
468 while (child) { | 468 while (child) { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
517 pChild = pChild->pNext; | 517 pChild = pChild->pNext; |
518 } | 518 } |
519 if (pIndex) { | 519 if (pIndex) { |
520 return 0; | 520 return 0; |
521 } else if (pItem) { | 521 } else if (pItem) { |
522 return -1; | 522 return -1; |
523 } | 523 } |
524 return iCount - 1; | 524 return iCount - 1; |
525 } | 525 } |
526 | 526 |
527 FX_BOOL CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { | 527 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { |
528 if (!pWidget) | 528 if (!pWidget) |
529 return FALSE; | 529 return false; |
530 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { | 530 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { |
531 return FALSE; | 531 return false; |
532 } | 532 } |
533 uint32_t dwStyles = pWidget->GetStyles(); | 533 uint32_t dwStyles = pWidget->GetStyles(); |
534 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == | 534 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == |
535 FWL_WGTSTYLE_OverLapper) || | 535 FWL_WGTSTYLE_OverLapper) || |
536 (dwStyles & FWL_WGTSTYLE_Popup); | 536 (dwStyles & FWL_WGTSTYLE_Popup); |
537 } | 537 } |
538 | 538 |
539 bool CFWL_WidgetMgr::IsThreadEnabled() { | 539 bool CFWL_WidgetMgr::IsThreadEnabled() { |
540 return !(m_dwCapability & FWL_WGTMGR_DisableThread); | 540 return !(m_dwCapability & FWL_WGTMGR_DisableThread); |
541 } | 541 } |
542 | 542 |
543 bool CFWL_WidgetMgr::IsFormDisabled() { | 543 bool CFWL_WidgetMgr::IsFormDisabled() { |
544 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); | 544 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); |
545 } | 545 } |
546 | 546 |
547 FX_BOOL CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, | 547 bool CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, |
548 FX_FLOAT fMinHeight, | 548 FX_FLOAT fMinHeight, |
549 FX_FLOAT fMaxHeight, | 549 FX_FLOAT fMaxHeight, |
550 const CFX_RectF& rtAnchor, | 550 const CFX_RectF& rtAnchor, |
551 CFX_RectF& rtPopup) { | 551 CFX_RectF& rtPopup) { |
552 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); | 552 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); |
553 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, | 553 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, |
554 rtPopup); | 554 rtPopup); |
555 } | 555 } |
556 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) | 556 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) |
557 : m_pWidgetMgr(pWidgetMgr) {} | 557 : m_pWidgetMgr(pWidgetMgr) {} |
558 FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { | 558 FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { |
559 m_pWidgetMgr->m_dwCapability = dwCapability; | 559 m_pWidgetMgr->m_dwCapability = dwCapability; |
560 return FWL_Error::Succeeded; | 560 return FWL_Error::Succeeded; |
561 } | 561 } |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
640 m_pWidgetMgr->ResetRedrawCounts(pWidget); | 640 m_pWidgetMgr->ResetRedrawCounts(pWidget); |
641 } | 641 } |
642 | 642 |
643 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, | 643 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, |
644 const CFX_RectF& rtClip, | 644 const CFX_RectF& rtClip, |
645 CFX_Graphics* pGraphics, | 645 CFX_Graphics* pGraphics, |
646 const CFX_Matrix* pMatrix) { | 646 const CFX_Matrix* pMatrix) { |
647 if (!parent) | 647 if (!parent) |
648 return; | 648 return; |
649 | 649 |
650 FX_BOOL bFormDisable = m_pWidgetMgr->IsFormDisabled(); | 650 bool bFormDisable = m_pWidgetMgr->IsFormDisabled(); |
651 IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); | 651 IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); |
652 while (pNextChild) { | 652 while (pNextChild) { |
653 IFWL_Widget* child = pNextChild; | 653 IFWL_Widget* child = pNextChild; |
654 pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); | 654 pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); |
655 if (child->GetStates() & FWL_WGTSTATE_Invisible) | 655 if (child->GetStates() & FWL_WGTSTATE_Invisible) |
656 continue; | 656 continue; |
657 | 657 |
658 CFX_RectF rtWidget; | 658 CFX_RectF rtWidget; |
659 child->GetWidgetRect(rtWidget); | 659 child->GetWidgetRect(rtWidget); |
660 if (rtWidget.IsEmpty()) | 660 if (rtWidget.IsEmpty()) |
661 continue; | 661 continue; |
662 | 662 |
663 CFX_Matrix widgetMatrix; | 663 CFX_Matrix widgetMatrix; |
664 CFX_RectF clipBounds(rtWidget); | 664 CFX_RectF clipBounds(rtWidget); |
665 if (!bFormDisable) | 665 if (!bFormDisable) |
666 child->GetMatrix(widgetMatrix, TRUE); | 666 child->GetMatrix(widgetMatrix, true); |
667 if (pMatrix) | 667 if (pMatrix) |
668 widgetMatrix.Concat(*pMatrix); | 668 widgetMatrix.Concat(*pMatrix); |
669 | 669 |
670 if (!bFormDisable) { | 670 if (!bFormDisable) { |
671 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); | 671 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); |
672 clipBounds.Intersect(rtClip); | 672 clipBounds.Intersect(rtClip); |
673 if (clipBounds.IsEmpty()) | 673 if (clipBounds.IsEmpty()) |
674 continue; | 674 continue; |
675 | 675 |
676 pGraphics->SaveGraphState(); | 676 pGraphics->SaveGraphState(); |
677 pGraphics->SetClipRect(clipBounds); | 677 pGraphics->SetClipRect(clipBounds); |
678 } | 678 } |
679 widgetMatrix.Translate(rtWidget.left, rtWidget.top, TRUE); | 679 widgetMatrix.Translate(rtWidget.left, rtWidget.top, true); |
680 | 680 |
681 if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { | 681 if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { |
682 if (m_pWidgetMgr->IsFormDisabled() || | 682 if (m_pWidgetMgr->IsFormDisabled() || |
683 IsNeedRepaint(child, &widgetMatrix, rtClip)) { | 683 IsNeedRepaint(child, &widgetMatrix, rtClip)) { |
684 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); | 684 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); |
685 } | 685 } |
686 } | 686 } |
687 if (!bFormDisable) | 687 if (!bFormDisable) |
688 pGraphics->RestoreGraphState(); | 688 pGraphics->RestoreGraphState(); |
689 | 689 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
723 pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, | 723 pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, |
724 rtClip, pMatrix); | 724 rtClip, pMatrix); |
725 #ifdef _WIN32 | 725 #ifdef _WIN32 |
726 pItem->pOffscreen->ClearClip(); | 726 pItem->pOffscreen->ClearClip(); |
727 #endif | 727 #endif |
728 } | 728 } |
729 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 729 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
730 pItem->iRedrawCounter = 0; | 730 pItem->iRedrawCounter = 0; |
731 } | 731 } |
732 | 732 |
733 FX_BOOL CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, | 733 bool CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, |
734 CFX_Matrix* pMatrix, | 734 CFX_Matrix* pMatrix, |
735 const CFX_RectF& rtDirty) { | 735 const CFX_RectF& rtDirty) { |
736 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 736 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
737 if (pItem && pItem->iRedrawCounter > 0) { | 737 if (pItem && pItem->iRedrawCounter > 0) { |
738 pItem->iRedrawCounter = 0; | 738 pItem->iRedrawCounter = 0; |
739 return TRUE; | 739 return true; |
740 } | 740 } |
741 CFX_RectF rtWidget; | 741 CFX_RectF rtWidget; |
742 pWidget->GetWidgetRect(rtWidget); | 742 pWidget->GetWidgetRect(rtWidget); |
743 rtWidget.left = rtWidget.top = 0; | 743 rtWidget.left = rtWidget.top = 0; |
744 pMatrix->TransformRect(rtWidget); | 744 pMatrix->TransformRect(rtWidget); |
745 if (!rtWidget.IntersectWith(rtDirty)) | 745 if (!rtWidget.IntersectWith(rtDirty)) |
746 return FALSE; | 746 return false; |
747 | 747 |
748 IFWL_Widget* pChild = | 748 IFWL_Widget* pChild = |
749 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget); | 749 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget); |
750 if (!pChild) | 750 if (!pChild) |
751 return TRUE; | 751 return true; |
752 | 752 |
753 CFX_RectF rtChilds; | 753 CFX_RectF rtChilds; |
754 rtChilds.Empty(); | 754 rtChilds.Empty(); |
755 FX_BOOL bChildIntersectWithDirty = FALSE; | 755 bool bChildIntersectWithDirty = false; |
756 FX_BOOL bOrginPtIntersectWidthChild = FALSE; | 756 bool bOrginPtIntersectWidthChild = false; |
757 FX_BOOL bOrginPtIntersectWidthDirty = | 757 bool bOrginPtIntersectWidthDirty = |
758 rtDirty.Contains(rtWidget.left, rtWidget.top); | 758 rtDirty.Contains(rtWidget.left, rtWidget.top); |
759 static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; | 759 static FWL_NEEDREPAINTHITDATA hitPoint[kNeedRepaintHitPoints]; |
760 FXSYS_memset(hitPoint, 0, sizeof(hitPoint)); | 760 FXSYS_memset(hitPoint, 0, sizeof(hitPoint)); |
761 FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece; | 761 FX_FLOAT fxPiece = rtWidget.width / kNeedRepaintHitPiece; |
762 FX_FLOAT fyPiece = rtWidget.height / kNeedRepaintHitPiece; | 762 FX_FLOAT fyPiece = rtWidget.height / kNeedRepaintHitPiece; |
763 hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; | 763 hitPoint[2].hitPoint.x = hitPoint[6].hitPoint.x = rtWidget.left; |
764 hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = | 764 hitPoint[0].hitPoint.x = hitPoint[3].hitPoint.x = hitPoint[7].hitPoint.x = |
765 hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; | 765 hitPoint[10].hitPoint.x = fxPiece + rtWidget.left; |
766 hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = | 766 hitPoint[1].hitPoint.x = hitPoint[4].hitPoint.x = hitPoint[8].hitPoint.x = |
767 hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; | 767 hitPoint[11].hitPoint.x = fxPiece * 2 + rtWidget.left; |
768 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = | 768 hitPoint[5].hitPoint.x = hitPoint[9].hitPoint.x = |
769 rtWidget.width + rtWidget.left; | 769 rtWidget.width + rtWidget.left; |
770 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; | 770 hitPoint[0].hitPoint.y = hitPoint[1].hitPoint.y = rtWidget.top; |
771 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = | 771 hitPoint[2].hitPoint.y = hitPoint[3].hitPoint.y = hitPoint[4].hitPoint.y = |
772 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; | 772 hitPoint[5].hitPoint.y = fyPiece + rtWidget.top; |
773 hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = | 773 hitPoint[6].hitPoint.y = hitPoint[7].hitPoint.y = hitPoint[8].hitPoint.y = |
774 hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; | 774 hitPoint[9].hitPoint.y = fyPiece * 2 + rtWidget.top; |
775 hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = | 775 hitPoint[10].hitPoint.y = hitPoint[11].hitPoint.y = |
776 rtWidget.height + rtWidget.top; | 776 rtWidget.height + rtWidget.top; |
777 do { | 777 do { |
778 CFX_RectF rect; | 778 CFX_RectF rect; |
779 pChild->GetWidgetRect(rect); | 779 pChild->GetWidgetRect(rect); |
780 CFX_RectF r = rect; | 780 CFX_RectF r = rect; |
781 r.left += rtWidget.left; | 781 r.left += rtWidget.left; |
782 r.top += rtWidget.top; | 782 r.top += rtWidget.top; |
783 if (r.IsEmpty()) | 783 if (r.IsEmpty()) |
784 continue; | 784 continue; |
785 if (r.Contains(rtDirty)) | 785 if (r.Contains(rtDirty)) |
786 return FALSE; | 786 return false; |
787 if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) | 787 if (!bChildIntersectWithDirty && r.IntersectWith(rtDirty)) |
788 bChildIntersectWithDirty = TRUE; | 788 bChildIntersectWithDirty = true; |
789 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) | 789 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) |
790 bOrginPtIntersectWidthChild = rect.Contains(0, 0); | 790 bOrginPtIntersectWidthChild = rect.Contains(0, 0); |
791 | 791 |
792 if (rtChilds.IsEmpty()) | 792 if (rtChilds.IsEmpty()) |
793 rtChilds = rect; | 793 rtChilds = rect; |
794 else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) | 794 else if (!(pChild->GetStates() & FWL_WGTSTATE_Invisible)) |
795 rtChilds.Union(rect); | 795 rtChilds.Union(rect); |
796 | 796 |
797 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { | 797 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { |
798 if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) | 798 if (hitPoint[i].bNotContainByDirty || hitPoint[i].bNotNeedRepaint) |
799 continue; | 799 continue; |
800 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { | 800 if (!rtDirty.Contains(hitPoint[i].hitPoint)) { |
801 hitPoint[i].bNotContainByDirty = true; | 801 hitPoint[i].bNotContainByDirty = true; |
802 continue; | 802 continue; |
803 } | 803 } |
804 if (r.Contains(hitPoint[i].hitPoint)) | 804 if (r.Contains(hitPoint[i].hitPoint)) |
805 hitPoint[i].bNotNeedRepaint = true; | 805 hitPoint[i].bNotNeedRepaint = true; |
806 } | 806 } |
807 pChild = | 807 pChild = |
808 pChild->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(pChild); | 808 pChild->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(pChild); |
809 } while (pChild); | 809 } while (pChild); |
810 | 810 |
811 if (!bChildIntersectWithDirty) | 811 if (!bChildIntersectWithDirty) |
812 return TRUE; | 812 return true; |
813 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) | 813 if (bOrginPtIntersectWidthDirty && !bOrginPtIntersectWidthChild) |
814 return TRUE; | 814 return true; |
815 if (rtChilds.IsEmpty()) | 815 if (rtChilds.IsEmpty()) |
816 return TRUE; | 816 return true; |
817 | 817 |
818 int32_t repaintPoint = kNeedRepaintHitPoints; | 818 int32_t repaintPoint = kNeedRepaintHitPoints; |
819 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { | 819 for (int32_t i = 0; i < kNeedRepaintHitPoints; i++) { |
820 if (hitPoint[i].bNotNeedRepaint) | 820 if (hitPoint[i].bNotNeedRepaint) |
821 repaintPoint--; | 821 repaintPoint--; |
822 } | 822 } |
823 if (repaintPoint > 0) | 823 if (repaintPoint > 0) |
824 return TRUE; | 824 return true; |
825 | 825 |
826 pMatrix->TransformRect(rtChilds); | 826 pMatrix->TransformRect(rtChilds); |
827 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) | 827 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) |
828 return FALSE; | 828 return false; |
829 return TRUE; | 829 return true; |
830 } | 830 } |
831 | 831 |
832 FX_BOOL CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { | 832 bool CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { |
833 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 833 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); |
834 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) | 834 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) |
835 return FALSE; | 835 return false; |
836 | 836 |
837 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 837 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
838 if (pItem->bOutsideChanged) { | 838 if (pItem->bOutsideChanged) { |
839 CFX_RectF r; | 839 CFX_RectF r; |
840 pWidget->GetWidgetRect(r); | 840 pWidget->GetWidgetRect(r); |
841 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); | 841 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); |
842 temp.Deflate(50, 50); | 842 temp.Deflate(50, 50); |
843 if (!temp.Contains(r)) | 843 if (!temp.Contains(r)) |
844 return FALSE; | 844 return false; |
845 | 845 |
846 pItem->bOutsideChanged = FALSE; | 846 pItem->bOutsideChanged = false; |
847 } | 847 } |
848 #endif | 848 #endif |
849 | 849 |
850 return pItem->iRedrawCounter == 0; | 850 return pItem->iRedrawCounter == 0; |
851 } | 851 } |
852 | 852 |
853 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} | 853 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} |
854 | 854 |
855 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) | 855 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) |
856 : pParent(nullptr), | 856 : pParent(nullptr), |
857 pOwner(nullptr), | 857 pOwner(nullptr), |
858 pChild(nullptr), | 858 pChild(nullptr), |
859 pPrevious(nullptr), | 859 pPrevious(nullptr), |
860 pNext(nullptr), | 860 pNext(nullptr), |
861 pWidget(widget), | 861 pWidget(widget), |
862 iRedrawCounter(0) | 862 iRedrawCounter(0) |
863 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 863 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
864 , | 864 , |
865 bOutsideChanged(FALSE) | 865 bOutsideChanged(false) |
866 #endif | 866 #endif |
867 { | 867 { |
868 } | 868 } |
869 | 869 |
870 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} | 870 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} |
OLD | NEW |