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