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 <utility> | 9 #include <utility> |
10 | 10 |
11 #include "xfa/fwl/core/fwl_noteimp.h" | 11 #include "xfa/fwl/core/cfwl_notedriver.h" |
12 #include "xfa/fwl/core/ifwl_app.h" | 12 #include "xfa/fwl/core/ifwl_app.h" |
13 #include "xfa/fwl/core/ifwl_form.h" | 13 #include "xfa/fwl/core/ifwl_form.h" |
14 #include "xfa/fxfa/app/xfa_fwladapter.h" | 14 #include "xfa/fxfa/app/xfa_fwladapter.h" |
15 #include "xfa/fxfa/xfa_ffapp.h" | 15 #include "xfa/fxfa/xfa_ffapp.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int kNeedRepaintHitPoints = 12; | 19 const int kNeedRepaintHitPoints = 12; |
20 const int kNeedRepaintHitPiece = 3; | 20 const int kNeedRepaintHitPiece = 3; |
21 | 21 |
22 struct FWL_NEEDREPAINTHITDATA { | 22 struct FWL_NEEDREPAINTHITDATA { |
23 CFX_PointF hitPoint; | 23 CFX_PointF hitPoint; |
24 bool bNotNeedRepaint; | 24 bool bNotNeedRepaint; |
25 bool bNotContainByDirty; | 25 bool bNotContainByDirty; |
26 }; | 26 }; |
27 | 27 |
28 } // namespace | 28 } // namespace |
29 | 29 |
30 bool FWL_UseOffscreen(IFWL_Widget* pWidget) { | 30 bool FWL_UseOffscreen(IFWL_Widget* pWidget) { |
31 #if (_FX_OS_ == _FX_MACOSX_) | 31 #if (_FX_OS_ == _FX_MACOSX_) |
32 return false; | 32 return false; |
33 #else | 33 #else |
34 return !!(pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen); | 34 return !!(pWidget->GetStyles() & FWL_WGTSTYLE_Offscreen); |
35 #endif | 35 #endif |
36 } | 36 } |
37 | 37 |
38 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) | 38 CFWL_WidgetMgr::CFWL_WidgetMgr(CXFA_FFApp* pAdapterNative) |
39 : m_dwCapability(0), m_pAdapter(pAdapterNative->GetWidgetMgr(this)) { | 39 : m_dwCapability(0), m_pAdapter(pAdapterNative->GetWidgetMgr(this)) { |
40 ASSERT(m_pAdapter); | 40 ASSERT(m_pAdapter); |
41 m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); | 41 m_mapWidgetItem[nullptr].reset(new Item); |
npm
2016/11/21 21:21:46
MakeUnique?
dsinclair
2016/11/21 21:57:07
Done.
| |
42 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 42 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
43 m_rtScreen.Reset(); | 43 m_rtScreen.Reset(); |
44 #endif | 44 #endif |
45 } | 45 } |
46 | 46 |
47 CFWL_WidgetMgr::~CFWL_WidgetMgr() {} | 47 CFWL_WidgetMgr::~CFWL_WidgetMgr() {} |
48 | 48 |
49 IFWL_Widget* CFWL_WidgetMgr::GetParentWidget(IFWL_Widget* pWidget) const { | 49 IFWL_Widget* CFWL_WidgetMgr::GetParentWidget(IFWL_Widget* pWidget) const { |
50 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 50 Item* pItem = GetWidgetMgrItem(pWidget); |
51 return pItem && pItem->pParent ? pItem->pParent->pWidget : nullptr; | 51 return pItem && pItem->pParent ? pItem->pParent->pWidget : nullptr; |
52 } | 52 } |
53 | 53 |
54 IFWL_Widget* CFWL_WidgetMgr::GetOwnerWidget(IFWL_Widget* pWidget) const { | 54 IFWL_Widget* CFWL_WidgetMgr::GetOwnerWidget(IFWL_Widget* pWidget) const { |
55 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 55 Item* pItem = GetWidgetMgrItem(pWidget); |
56 return pItem && pItem->pOwner ? pItem->pOwner->pWidget : nullptr; | 56 return pItem && pItem->pOwner ? pItem->pOwner->pWidget : nullptr; |
57 } | 57 } |
58 | 58 |
59 IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const { | 59 IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const { |
60 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 60 Item* pItem = GetWidgetMgrItem(pWidget); |
61 if (!pItem) | 61 if (!pItem) |
62 return nullptr; | 62 return nullptr; |
63 | 63 |
64 pItem = pItem->pPrevious; | 64 pItem = pItem->pPrevious; |
65 while (pItem && pItem->pPrevious) | 65 while (pItem && pItem->pPrevious) |
66 pItem = pItem->pPrevious; | 66 pItem = pItem->pPrevious; |
67 return pItem ? pItem->pWidget : nullptr; | 67 return pItem ? pItem->pWidget : nullptr; |
68 } | 68 } |
69 | 69 |
70 IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { | 70 IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { |
71 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 71 Item* pItem = GetWidgetMgrItem(pWidget); |
72 return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; | 72 return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; |
73 } | 73 } |
74 | 74 |
75 IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { | 75 IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { |
76 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 76 Item* pItem = GetWidgetMgrItem(pWidget); |
77 return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; | 77 return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; |
78 } | 78 } |
79 | 79 |
80 IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { | 80 IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { |
81 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 81 Item* pItem = GetWidgetMgrItem(pWidget); |
82 return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; | 82 return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; |
83 } | 83 } |
84 | 84 |
85 IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { | 85 IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { |
86 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 86 Item* pItem = GetWidgetMgrItem(pWidget); |
87 if (!pItem) | 87 if (!pItem) |
88 return nullptr; | 88 return nullptr; |
89 | 89 |
90 pItem = pItem->pChild; | 90 pItem = pItem->pChild; |
91 while (pItem && pItem->pNext) | 91 while (pItem && pItem->pNext) |
92 pItem = pItem->pNext; | 92 pItem = pItem->pNext; |
93 return pItem ? pItem->pWidget : nullptr; | 93 return pItem ? pItem->pWidget : nullptr; |
94 } | 94 } |
95 | 95 |
96 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { | 96 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { |
97 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 97 Item* pItem = GetWidgetMgrItem(pWidget); |
98 while (pItem) { | 98 while (pItem) { |
99 if (IsAbleNative(pItem->pWidget)) | 99 if (IsAbleNative(pItem->pWidget)) |
100 return pItem->pWidget; | 100 return pItem->pWidget; |
101 pItem = pItem->pParent; | 101 pItem = pItem->pParent; |
102 } | 102 } |
103 return nullptr; | 103 return nullptr; |
104 } | 104 } |
105 | 105 |
106 void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { | 106 void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { |
107 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 107 Item* pItem = GetWidgetMgrItem(pWidget); |
108 if (!pItem) | 108 if (!pItem) |
109 return; | 109 return; |
110 if (!pItem->pParent) | 110 if (!pItem->pParent) |
111 return; | 111 return; |
112 | 112 |
113 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; | 113 Item* pChild = pItem->pParent->pChild; |
114 int32_t i = 0; | 114 int32_t i = 0; |
115 while (pChild) { | 115 while (pChild) { |
116 if (pChild == pItem) { | 116 if (pChild == pItem) { |
117 if (i == nIndex) | 117 if (i == nIndex) |
118 return; | 118 return; |
119 if (pChild->pPrevious) | 119 if (pChild->pPrevious) |
120 pChild->pPrevious->pNext = pChild->pNext; | 120 pChild->pPrevious->pNext = pChild->pNext; |
121 if (pChild->pNext) | 121 if (pChild->pNext) |
122 pChild->pNext->pPrevious = pChild->pPrevious; | 122 pChild->pNext->pPrevious = pChild->pPrevious; |
123 if (pItem->pParent->pChild == pItem) | 123 if (pItem->pParent->pChild == pItem) |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
196 | 196 |
197 pWidget->TransformTo(pNative, rect.left, rect.top); | 197 pWidget->TransformTo(pNative, rect.left, rect.top); |
198 } | 198 } |
199 AddRedrawCounts(pNative); | 199 AddRedrawCounts(pNative); |
200 m_pAdapter->RepaintWidget(pNative, &rect); | 200 m_pAdapter->RepaintWidget(pNative, &rect); |
201 } | 201 } |
202 | 202 |
203 void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, | 203 void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, |
204 IFWL_Widget* pChild, | 204 IFWL_Widget* pChild, |
205 int32_t nIndex) { | 205 int32_t nIndex) { |
206 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); | 206 Item* pParentItem = GetWidgetMgrItem(pParent); |
207 if (!pParentItem) { | 207 if (!pParentItem) { |
208 pParentItem = new CFWL_WidgetMgrItem(pParent); | 208 pParentItem = new Item(pParent); |
209 m_mapWidgetItem[pParent].reset(pParentItem); | 209 m_mapWidgetItem[pParent].reset(pParentItem); |
210 pParentItem->pParent = GetWidgetMgrItem(nullptr); | 210 pParentItem->pParent = GetWidgetMgrItem(nullptr); |
211 SetWidgetIndex(pParent, -1); | 211 SetWidgetIndex(pParent, -1); |
212 } | 212 } |
213 | 213 |
214 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); | 214 Item* pItem = GetWidgetMgrItem(pChild); |
215 if (!pItem) { | 215 if (!pItem) { |
216 pItem = new CFWL_WidgetMgrItem(pChild); | 216 pItem = new Item(pChild); |
217 m_mapWidgetItem[pChild].reset(pItem); | 217 m_mapWidgetItem[pChild].reset(pItem); |
218 } | 218 } |
219 if (pItem->pParent && pItem->pParent != pParentItem) { | 219 if (pItem->pParent && pItem->pParent != pParentItem) { |
220 if (pItem->pPrevious) | 220 if (pItem->pPrevious) |
221 pItem->pPrevious->pNext = pItem->pNext; | 221 pItem->pPrevious->pNext = pItem->pNext; |
222 if (pItem->pNext) | 222 if (pItem->pNext) |
223 pItem->pNext->pPrevious = pItem->pPrevious; | 223 pItem->pNext->pPrevious = pItem->pPrevious; |
224 if (pItem->pParent->pChild == pItem) | 224 if (pItem->pParent->pChild == pItem) |
225 pItem->pParent->pChild = pItem->pNext; | 225 pItem->pParent->pChild = pItem->pNext; |
226 } | 226 } |
227 pItem->pParent = pParentItem; | 227 pItem->pParent = pParentItem; |
228 SetWidgetIndex(pChild, nIndex); | 228 SetWidgetIndex(pChild, nIndex); |
229 } | 229 } |
230 | 230 |
231 void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { | 231 void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { |
232 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 232 Item* pItem = GetWidgetMgrItem(pWidget); |
233 if (!pItem) | 233 if (!pItem) |
234 return; | 234 return; |
235 if (pItem->pPrevious) | 235 if (pItem->pPrevious) |
236 pItem->pPrevious->pNext = pItem->pNext; | 236 pItem->pPrevious->pNext = pItem->pNext; |
237 if (pItem->pNext) | 237 if (pItem->pNext) |
238 pItem->pNext->pPrevious = pItem->pPrevious; | 238 pItem->pNext->pPrevious = pItem->pPrevious; |
239 if (pItem->pParent && pItem->pParent->pChild == pItem) | 239 if (pItem->pParent && pItem->pParent->pChild == pItem) |
240 pItem->pParent->pChild = pItem->pNext; | 240 pItem->pParent->pChild = pItem->pNext; |
241 | 241 |
242 CFWL_WidgetMgrItem* pChild = pItem->pChild; | 242 Item* pChild = pItem->pChild; |
243 while (pChild) { | 243 while (pChild) { |
244 CFWL_WidgetMgrItem* pNext = pChild->pNext; | 244 Item* pNext = pChild->pNext; |
245 RemoveWidget(pChild->pWidget); | 245 RemoveWidget(pChild->pWidget); |
246 pChild = pNext; | 246 pChild = pNext; |
247 } | 247 } |
248 m_mapWidgetItem.erase(pWidget); | 248 m_mapWidgetItem.erase(pWidget); |
249 } | 249 } |
250 | 250 |
251 void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) { | 251 void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) { |
252 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner); | 252 Item* pParentItem = GetWidgetMgrItem(pOwner); |
253 if (!pParentItem) { | 253 if (!pParentItem) { |
254 pParentItem = new CFWL_WidgetMgrItem(pOwner); | 254 pParentItem = new Item(pOwner); |
255 m_mapWidgetItem[pOwner].reset(pParentItem); | 255 m_mapWidgetItem[pOwner].reset(pParentItem); |
256 pParentItem->pParent = GetWidgetMgrItem(nullptr); | 256 pParentItem->pParent = GetWidgetMgrItem(nullptr); |
257 SetWidgetIndex(pOwner, -1); | 257 SetWidgetIndex(pOwner, -1); |
258 } | 258 } |
259 | 259 |
260 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned); | 260 Item* pItem = GetWidgetMgrItem(pOwned); |
261 if (!pItem) { | 261 if (!pItem) { |
262 pItem = new CFWL_WidgetMgrItem(pOwned); | 262 pItem = new Item(pOwned); |
263 m_mapWidgetItem[pOwned].reset(pItem); | 263 m_mapWidgetItem[pOwned].reset(pItem); |
264 } | 264 } |
265 pItem->pOwner = pParentItem; | 265 pItem->pOwner = pParentItem; |
266 } | 266 } |
267 void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { | 267 void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { |
268 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); | 268 Item* pParentItem = GetWidgetMgrItem(pParent); |
269 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); | 269 Item* pItem = GetWidgetMgrItem(pChild); |
270 if (!pItem) | 270 if (!pItem) |
271 return; | 271 return; |
272 if (pItem->pParent && pItem->pParent != pParentItem) { | 272 if (pItem->pParent && pItem->pParent != pParentItem) { |
273 if (pItem->pPrevious) | 273 if (pItem->pPrevious) |
274 pItem->pPrevious->pNext = pItem->pNext; | 274 pItem->pPrevious->pNext = pItem->pNext; |
275 if (pItem->pNext) | 275 if (pItem->pNext) |
276 pItem->pNext->pPrevious = pItem->pPrevious; | 276 pItem->pNext->pPrevious = pItem->pPrevious; |
277 if (pItem->pParent->pChild == pItem) | 277 if (pItem->pParent->pChild == pItem) |
278 pItem->pParent->pChild = pItem->pNext; | 278 pItem->pParent->pChild = pItem->pNext; |
279 | 279 |
280 pItem->pNext = nullptr; | 280 pItem->pNext = nullptr; |
281 pItem->pPrevious = nullptr; | 281 pItem->pPrevious = nullptr; |
282 } | 282 } |
283 pItem->pParent = pParentItem; | 283 pItem->pParent = pParentItem; |
284 SetWidgetIndex(pChild, -1); | 284 SetWidgetIndex(pChild, -1); |
285 } | 285 } |
286 | 286 |
287 void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, | 287 void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, |
288 const CFX_RectF& rect) { | 288 const CFX_RectF& rect) { |
289 if (!FWL_UseOffscreen(pWidget)) | 289 if (!FWL_UseOffscreen(pWidget)) |
290 return; | 290 return; |
291 | 291 |
292 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 292 Item* pItem = GetWidgetMgrItem(pWidget); |
293 pItem->iRedrawCounter++; | 293 pItem->iRedrawCounter++; |
294 if (pItem->pOffscreen) { | 294 if (pItem->pOffscreen) { |
295 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); | 295 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); |
296 if (pDevice && pDevice->GetBitmap()) { | 296 if (pDevice && pDevice->GetBitmap()) { |
297 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); | 297 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); |
298 if (pBitmap->GetWidth() - rect.width > 1 || | 298 if (pBitmap->GetWidth() - rect.width > 1 || |
299 pBitmap->GetHeight() - rect.height > 1) { | 299 pBitmap->GetHeight() - rect.height > 1) { |
300 pItem->pOffscreen.reset(); | 300 pItem->pOffscreen.reset(); |
301 } | 301 } |
302 } | 302 } |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
420 } | 420 } |
421 | 421 |
422 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { | 422 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { |
423 GetWidgetMgrItem(pWidget)->iRedrawCounter++; | 423 GetWidgetMgrItem(pWidget)->iRedrawCounter++; |
424 } | 424 } |
425 | 425 |
426 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { | 426 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { |
427 GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; | 427 GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; |
428 } | 428 } |
429 | 429 |
430 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( | 430 CFWL_WidgetMgr::Item* CFWL_WidgetMgr::GetWidgetMgrItem( |
431 IFWL_Widget* pWidget) const { | 431 IFWL_Widget* pWidget) const { |
432 auto it = m_mapWidgetItem.find(pWidget); | 432 auto it = m_mapWidgetItem.find(pWidget); |
433 return it != m_mapWidgetItem.end() | 433 return it != m_mapWidgetItem.end() ? static_cast<Item*>(it->second.get()) |
434 ? static_cast<CFWL_WidgetMgrItem*>(it->second.get()) | 434 : nullptr; |
435 : nullptr; | |
436 } | 435 } |
437 | 436 |
438 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { | 437 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { |
439 if (!pWidget) | 438 if (!pWidget) |
440 return false; | 439 return false; |
441 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) | 440 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) |
442 return false; | 441 return false; |
443 | 442 |
444 uint32_t dwStyles = pWidget->GetStyles(); | 443 uint32_t dwStyles = pWidget->GetStyles(); |
445 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == | 444 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
584 child = GetNextSiblingWidget(child); | 583 child = GetNextSiblingWidget(child); |
585 } | 584 } |
586 } | 585 } |
587 | 586 |
588 CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(IFWL_Widget* pWidget, | 587 CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(IFWL_Widget* pWidget, |
589 CFX_Graphics* pGraphics, | 588 CFX_Graphics* pGraphics, |
590 const CFX_Matrix* pMatrix) { | 589 const CFX_Matrix* pMatrix) { |
591 if (!FWL_UseOffscreen(pWidget)) | 590 if (!FWL_UseOffscreen(pWidget)) |
592 return pGraphics; | 591 return pGraphics; |
593 | 592 |
594 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 593 Item* pItem = GetWidgetMgrItem(pWidget); |
595 if (!pItem->pOffscreen) { | 594 if (!pItem->pOffscreen) { |
596 pItem->pOffscreen.reset(new CFX_Graphics); | 595 pItem->pOffscreen.reset(new CFX_Graphics); |
597 CFX_RectF rect; | 596 CFX_RectF rect; |
598 pWidget->GetWidgetRect(rect); | 597 pWidget->GetWidgetRect(rect); |
599 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, | 598 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, |
600 FXDIB_Argb); | 599 FXDIB_Argb); |
601 } | 600 } |
602 CFX_RectF rect; | 601 CFX_RectF rect; |
603 pGraphics->GetClipRect(rect); | 602 pGraphics->GetClipRect(rect); |
604 pItem->pOffscreen->SetClipRect(rect); | 603 pItem->pOffscreen->SetClipRect(rect); |
605 return pItem->pOffscreen.get(); | 604 return pItem->pOffscreen.get(); |
606 } | 605 } |
607 | 606 |
608 void CFWL_WidgetMgr::DrawWidgetAfter(IFWL_Widget* pWidget, | 607 void CFWL_WidgetMgr::DrawWidgetAfter(IFWL_Widget* pWidget, |
609 CFX_Graphics* pGraphics, | 608 CFX_Graphics* pGraphics, |
610 CFX_RectF& rtClip, | 609 CFX_RectF& rtClip, |
611 const CFX_Matrix* pMatrix) { | 610 const CFX_Matrix* pMatrix) { |
612 if (FWL_UseOffscreen(pWidget)) { | 611 if (FWL_UseOffscreen(pWidget)) { |
613 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 612 Item* pItem = GetWidgetMgrItem(pWidget); |
614 pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, | 613 pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, |
615 rtClip, pMatrix); | 614 rtClip, pMatrix); |
616 #ifdef _WIN32 | 615 #ifdef _WIN32 |
617 pItem->pOffscreen->ClearClip(); | 616 pItem->pOffscreen->ClearClip(); |
618 #endif | 617 #endif |
619 } | 618 } |
620 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 619 Item* pItem = GetWidgetMgrItem(pWidget); |
621 pItem->iRedrawCounter = 0; | 620 pItem->iRedrawCounter = 0; |
622 } | 621 } |
623 | 622 |
624 bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, | 623 bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, |
625 CFX_Matrix* pMatrix, | 624 CFX_Matrix* pMatrix, |
626 const CFX_RectF& rtDirty) { | 625 const CFX_RectF& rtDirty) { |
627 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 626 Item* pItem = GetWidgetMgrItem(pWidget); |
628 if (pItem && pItem->iRedrawCounter > 0) { | 627 if (pItem && pItem->iRedrawCounter > 0) { |
629 pItem->iRedrawCounter = 0; | 628 pItem->iRedrawCounter = 0; |
630 return true; | 629 return true; |
631 } | 630 } |
632 | 631 |
633 CFX_RectF rtWidget; | 632 CFX_RectF rtWidget; |
634 pWidget->GetWidgetRect(rtWidget); | 633 pWidget->GetWidgetRect(rtWidget); |
635 rtWidget.left = rtWidget.top = 0; | 634 rtWidget.left = rtWidget.top = 0; |
636 pMatrix->TransformRect(rtWidget); | 635 pMatrix->TransformRect(rtWidget); |
637 if (!rtWidget.IntersectWith(rtDirty)) | 636 if (!rtWidget.IntersectWith(rtDirty)) |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
715 if (repaintPoint > 0) | 714 if (repaintPoint > 0) |
716 return true; | 715 return true; |
717 | 716 |
718 pMatrix->TransformRect(rtChilds); | 717 pMatrix->TransformRect(rtChilds); |
719 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) | 718 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) |
720 return false; | 719 return false; |
721 return true; | 720 return true; |
722 } | 721 } |
723 | 722 |
724 bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { | 723 bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { |
725 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 724 Item* pItem = GetWidgetMgrItem(pWidget); |
726 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) | 725 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) |
727 return false; | 726 return false; |
728 | 727 |
729 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 728 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
730 if (pItem->bOutsideChanged) { | 729 if (pItem->bOutsideChanged) { |
731 CFX_RectF r; | 730 CFX_RectF r; |
732 pWidget->GetWidgetRect(r); | 731 pWidget->GetWidgetRect(r); |
733 CFX_RectF temp(m_rtScreen); | 732 CFX_RectF temp(m_rtScreen); |
734 temp.Deflate(50, 50); | 733 temp.Deflate(50, 50); |
735 if (!temp.Contains(r)) | 734 if (!temp.Contains(r)) |
736 return false; | 735 return false; |
737 | 736 |
738 pItem->bOutsideChanged = false; | 737 pItem->bOutsideChanged = false; |
739 } | 738 } |
740 #endif | 739 #endif |
741 | 740 |
742 return pItem->iRedrawCounter == 0; | 741 return pItem->iRedrawCounter == 0; |
743 } | 742 } |
744 | 743 |
745 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} | 744 CFWL_WidgetMgr::Item::Item() : CFWL_WidgetMgr::Item(nullptr) {} |
746 | 745 |
747 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) | 746 CFWL_WidgetMgr::Item::Item(IFWL_Widget* widget) |
748 : pParent(nullptr), | 747 : pParent(nullptr), |
749 pOwner(nullptr), | 748 pOwner(nullptr), |
750 pChild(nullptr), | 749 pChild(nullptr), |
751 pPrevious(nullptr), | 750 pPrevious(nullptr), |
752 pNext(nullptr), | 751 pNext(nullptr), |
753 pWidget(widget), | 752 pWidget(widget), |
754 iRedrawCounter(0) | 753 iRedrawCounter(0) |
755 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 754 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
756 , | 755 , |
757 bOutsideChanged(false) | 756 bOutsideChanged(false) |
758 #endif | 757 #endif |
759 { | 758 { |
760 } | 759 } |
761 | 760 |
762 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} | 761 CFWL_WidgetMgr::Item::~Item() {} |
OLD | NEW |