Chromium Code Reviews| 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" |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 28 | 28 |
| 29 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), m_pAdapter(pAdapterNative->GetWidgetMgr(this)) { |
| 39 m_pDelegate(new CFWL_WidgetMgrDelegate(this)), | |
| 40 m_pAdapter(pAdapterNative->GetWidgetMgr(m_pDelegate.get())) { | |
| 41 ASSERT(m_pAdapter); | 39 ASSERT(m_pAdapter); |
| 42 m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); | 40 m_mapWidgetItem[nullptr].reset(new CFWL_WidgetMgrItem); |
| 43 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 41 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 44 m_rtScreen.Reset(); | 42 m_rtScreen.Reset(); |
| 45 #endif | 43 #endif |
| 46 } | 44 } |
| 47 | 45 |
| 48 CFWL_WidgetMgr::~CFWL_WidgetMgr() {} | 46 CFWL_WidgetMgr::~CFWL_WidgetMgr() {} |
| 49 | 47 |
| 50 IFWL_Widget* CFWL_WidgetMgr::GetParentWidget(IFWL_Widget* pWidget) const { | 48 IFWL_Widget* CFWL_WidgetMgr::GetParentWidget(IFWL_Widget* pWidget) const { |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 69 IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { | 67 IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { |
| 70 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 68 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 71 return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; | 69 return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; |
| 72 } | 70 } |
| 73 | 71 |
| 74 IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { | 72 IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { |
| 75 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 73 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 76 return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; | 74 return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; |
| 77 } | 75 } |
| 78 | 76 |
| 79 IFWL_Widget* CFWL_WidgetMgr::GetLastSiblingWidget(IFWL_Widget* pWidget) const { | |
| 80 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | |
| 81 pItem = pItem ? pItem->pNext : nullptr; // Not self. | |
| 82 while (pItem && pItem->pNext) | |
| 83 pItem = pItem->pNext; | |
| 84 | |
| 85 return pItem ? pItem->pWidget : nullptr; | |
| 86 } | |
| 87 | |
| 88 IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { | 77 IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { |
| 89 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 78 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 90 return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; | 79 return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; |
| 91 } | 80 } |
| 92 | 81 |
| 93 IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { | 82 IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { |
| 94 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 83 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 95 pItem = pItem ? pItem->pChild : nullptr; | 84 pItem = pItem ? pItem->pChild : nullptr; |
| 96 while (pItem && pItem->pNext) | 85 while (pItem && pItem->pNext) |
| 97 pItem = pItem->pNext; | 86 pItem = pItem->pNext; |
| 98 | 87 |
| 99 return pItem ? pItem->pWidget : nullptr; | 88 return pItem ? pItem->pWidget : nullptr; |
| 100 } | 89 } |
| 101 | 90 |
| 102 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { | 91 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { |
| 103 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 92 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 104 while (pItem) { | 93 while (pItem) { |
| 105 if (IsAbleNative(pItem->pWidget)) | 94 if (IsAbleNative(pItem->pWidget)) |
| 106 return pItem->pWidget; | 95 return pItem->pWidget; |
| 107 pItem = pItem->pParent; | 96 pItem = pItem->pParent; |
| 108 } | 97 } |
| 109 return nullptr; | 98 return nullptr; |
| 110 } | 99 } |
| 111 | 100 |
| 112 bool CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { | 101 void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { |
| 113 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 102 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 114 if (!pItem) | 103 if (!pItem) |
| 115 return false; | 104 return; |
| 116 if (!pItem->pParent) | 105 if (!pItem->pParent) |
| 117 return false; | 106 return; |
| 118 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; | 107 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; |
| 119 int32_t i = 0; | 108 int32_t i = 0; |
| 120 while (pChild) { | 109 while (pChild) { |
| 121 if (pChild == pItem) { | 110 if (pChild == pItem) { |
| 122 if (i == nIndex) { | 111 if (i == nIndex) |
| 123 return true; | 112 return; |
| 124 } | |
| 125 if (pChild->pPrevious) { | 113 if (pChild->pPrevious) { |
| 126 pChild->pPrevious->pNext = pChild->pNext; | 114 pChild->pPrevious->pNext = pChild->pNext; |
| 127 } | 115 } |
| 128 if (pChild->pNext) { | 116 if (pChild->pNext) { |
| 129 pChild->pNext->pPrevious = pChild->pPrevious; | 117 pChild->pNext->pPrevious = pChild->pPrevious; |
| 130 } | 118 } |
| 131 if (pItem->pParent->pChild == pItem) { | 119 if (pItem->pParent->pChild == pItem) { |
| 132 pItem->pParent->pChild = pItem->pNext; | 120 pItem->pParent->pChild = pItem->pNext; |
| 133 } | 121 } |
| 134 pItem->pNext = nullptr; | 122 pItem->pNext = nullptr; |
| 135 pItem->pPrevious = nullptr; | 123 pItem->pPrevious = nullptr; |
| 136 break; | 124 break; |
| 137 } | 125 } |
| 138 if (!pChild->pNext) { | 126 if (!pChild->pNext) { |
| 139 break; | 127 break; |
| 140 } | 128 } |
| 141 pChild = pChild->pNext; | 129 pChild = pChild->pNext; |
| 142 ++i; | 130 ++i; |
| 143 } | 131 } |
| 144 pChild = pItem->pParent->pChild; | 132 pChild = pItem->pParent->pChild; |
| 145 if (pChild) { | 133 if (pChild) { |
| 146 if (nIndex < 0) { | 134 if (nIndex < 0) { |
| 147 while (pChild->pNext) { | 135 while (pChild->pNext) { |
| 148 pChild = pChild->pNext; | 136 pChild = pChild->pNext; |
| 149 } | 137 } |
| 150 pChild->pNext = pItem; | 138 pChild->pNext = pItem; |
| 151 pItem->pPrevious = pChild; | 139 pItem->pPrevious = pChild; |
| 152 pItem->pNext = nullptr; | 140 pItem->pNext = nullptr; |
| 153 return true; | 141 return; |
| 154 } | 142 } |
| 155 i = 0; | 143 i = 0; |
| 156 while (i < nIndex && pChild->pNext) { | 144 while (i < nIndex && pChild->pNext) { |
| 157 pChild = pChild->pNext; | 145 pChild = pChild->pNext; |
| 158 ++i; | 146 ++i; |
| 159 } | 147 } |
| 160 if (!pChild->pNext) { | 148 if (!pChild->pNext) { |
| 161 pChild->pNext = pItem; | 149 pChild->pNext = pItem; |
| 162 pItem->pPrevious = pChild; | 150 pItem->pPrevious = pChild; |
| 163 pItem->pNext = nullptr; | 151 pItem->pNext = nullptr; |
| 164 return true; | 152 return; |
| 165 } | 153 } |
| 166 if (pChild->pPrevious) { | 154 if (pChild->pPrevious) { |
| 167 pItem->pPrevious = pChild->pPrevious; | 155 pItem->pPrevious = pChild->pPrevious; |
| 168 pChild->pPrevious->pNext = pItem; | 156 pChild->pPrevious->pNext = pItem; |
| 169 } | 157 } |
| 170 pChild->pPrevious = pItem; | 158 pChild->pPrevious = pItem; |
| 171 pItem->pNext = pChild; | 159 pItem->pNext = pChild; |
| 172 if (pItem->pParent->pChild == pChild) { | 160 if (pItem->pParent->pChild == pChild) { |
| 173 pItem->pParent->pChild = pItem; | 161 pItem->pParent->pChild = pItem; |
| 174 } | 162 } |
| 175 } else { | 163 } else { |
| 176 pItem->pParent->pChild = pItem; | 164 pItem->pParent->pChild = pItem; |
| 177 pItem->pPrevious = nullptr; | 165 pItem->pPrevious = nullptr; |
| 178 pItem->pNext = nullptr; | 166 pItem->pNext = nullptr; |
| 179 } | 167 } |
| 180 return true; | |
| 181 } | 168 } |
| 182 FWL_Error CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, | 169 |
| 183 const CFX_RectF* pRect) { | 170 void CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, |
| 171 const CFX_RectF* pRect) { | |
| 184 if (!m_pAdapter) | 172 if (!m_pAdapter) |
| 185 return FWL_Error::Indefinite; | 173 return; |
| 174 | |
| 186 IFWL_Widget* pNative = pWidget; | 175 IFWL_Widget* pNative = pWidget; |
| 187 CFX_RectF rect(*pRect); | 176 CFX_RectF rect(*pRect); |
| 188 if (IsFormDisabled()) { | 177 if (IsFormDisabled()) { |
| 189 IFWL_Widget* pOuter = pWidget->GetOuter(); | 178 IFWL_Widget* pOuter = pWidget->GetOuter(); |
| 190 while (pOuter) { | 179 while (pOuter) { |
| 191 CFX_RectF rtTemp; | 180 CFX_RectF rtTemp; |
| 192 pNative->GetWidgetRect(rtTemp); | 181 pNative->GetWidgetRect(rtTemp); |
| 193 rect.left += rtTemp.left; | 182 rect.left += rtTemp.left; |
| 194 rect.top += rtTemp.top; | 183 rect.top += rtTemp.top; |
| 195 pNative = pOuter; | 184 pNative = pOuter; |
| 196 pOuter = pOuter->GetOuter(); | 185 pOuter = pOuter->GetOuter(); |
| 197 } | 186 } |
| 198 } else if (!IsAbleNative(pWidget)) { | 187 } else if (!IsAbleNative(pWidget)) { |
| 199 pNative = GetSystemFormWidget(pWidget); | 188 pNative = GetSystemFormWidget(pWidget); |
| 200 if (!pNative) | 189 if (!pNative) |
| 201 return FWL_Error::Indefinite; | 190 return; |
| 191 | |
| 202 pWidget->TransformTo(pNative, rect.left, rect.top); | 192 pWidget->TransformTo(pNative, rect.left, rect.top); |
| 203 } | 193 } |
| 204 AddRedrawCounts(pNative); | 194 AddRedrawCounts(pNative); |
| 205 return m_pAdapter->RepaintWidget(pNative, &rect); | 195 m_pAdapter->RepaintWidget(pNative, &rect); |
| 206 } | 196 } |
| 207 void CFWL_WidgetMgr::AddWidget(IFWL_Widget* pWidget) { | 197 |
| 208 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(nullptr); | |
| 209 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | |
| 210 if (!pItem) { | |
| 211 pItem = new CFWL_WidgetMgrItem(pWidget); | |
| 212 m_mapWidgetItem[pWidget].reset(pItem); | |
| 213 } | |
| 214 if (pItem->pParent && pItem->pParent != pParentItem) { | |
| 215 if (pItem->pPrevious) { | |
| 216 pItem->pPrevious->pNext = pItem->pNext; | |
| 217 } | |
| 218 if (pItem->pNext) { | |
| 219 pItem->pNext->pPrevious = pItem->pPrevious; | |
| 220 } | |
| 221 if (pItem->pParent->pChild == pItem) { | |
| 222 pItem->pParent->pChild = pItem->pNext; | |
| 223 } | |
| 224 } | |
| 225 pItem->pParent = pParentItem; | |
| 226 SetWidgetIndex(pWidget, -1); | |
| 227 } | |
| 228 void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, | 198 void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, |
| 229 IFWL_Widget* pChild, | 199 IFWL_Widget* pChild, |
| 230 int32_t nIndex) { | 200 int32_t nIndex) { |
| 231 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); | 201 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); |
| 232 if (!pParentItem) { | 202 if (!pParentItem) { |
| 233 pParentItem = new CFWL_WidgetMgrItem(pParent); | 203 pParentItem = new CFWL_WidgetMgrItem(pParent); |
| 234 m_mapWidgetItem[pParent].reset(pParentItem); | 204 m_mapWidgetItem[pParent].reset(pParentItem); |
| 235 pParentItem->pParent = GetWidgetMgrItem(nullptr); | 205 pParentItem->pParent = GetWidgetMgrItem(nullptr); |
| 236 SetWidgetIndex(pParent, -1); | 206 SetWidgetIndex(pParent, -1); |
| 237 } | 207 } |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 306 if (pItem->pParent->pChild == pItem) { | 276 if (pItem->pParent->pChild == pItem) { |
| 307 pItem->pParent->pChild = pItem->pNext; | 277 pItem->pParent->pChild = pItem->pNext; |
| 308 } | 278 } |
| 309 pItem->pNext = nullptr; | 279 pItem->pNext = nullptr; |
| 310 pItem->pPrevious = nullptr; | 280 pItem->pPrevious = nullptr; |
| 311 } | 281 } |
| 312 pItem->pParent = pParentItem; | 282 pItem->pParent = pParentItem; |
| 313 SetWidgetIndex(pChild, -1); | 283 SetWidgetIndex(pChild, -1); |
| 314 } | 284 } |
| 315 | 285 |
| 316 bool CFWL_WidgetMgr::IsChild(IFWL_Widget* pChild, IFWL_Widget* pParent) { | 286 void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, |
| 317 IFWL_Widget* pTemp = pChild; | 287 const CFX_RectF& rect) { |
| 318 do { | |
| 319 if (pTemp == pParent) | |
| 320 return true; | |
| 321 pTemp = GetParentWidget(pTemp); | |
| 322 } while (pTemp); | |
| 323 return false; | |
| 324 } | |
| 325 | |
| 326 FWL_Error CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, | |
| 327 const CFX_RectF& rect) { | |
| 328 if (FWL_UseOffscreen(pWidget)) { | 288 if (FWL_UseOffscreen(pWidget)) { |
| 329 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 289 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 330 pItem->iRedrawCounter++; | 290 pItem->iRedrawCounter++; |
| 331 if (pItem->pOffscreen) { | 291 if (pItem->pOffscreen) { |
| 332 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); | 292 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); |
| 333 if (pDevice && pDevice->GetBitmap()) { | 293 if (pDevice && pDevice->GetBitmap()) { |
| 334 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); | 294 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); |
| 335 if (pBitmap->GetWidth() - rect.width > 1 || | 295 if (pBitmap->GetWidth() - rect.width > 1 || |
| 336 pBitmap->GetHeight() - rect.height > 1) { | 296 pBitmap->GetHeight() - rect.height > 1) { |
| 337 pItem->pOffscreen.reset(); | 297 pItem->pOffscreen.reset(); |
| 338 } | 298 } |
| 339 } | 299 } |
| 340 } | 300 } |
| 341 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 301 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 342 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); | 302 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); |
| 343 #endif | 303 #endif |
| 344 } | 304 } |
| 345 return FWL_Error::Succeeded; | |
| 346 } | 305 } |
| 347 | 306 |
| 348 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, | 307 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, |
| 349 FX_FLOAT x, | 308 FX_FLOAT x, |
| 350 FX_FLOAT y) { | 309 FX_FLOAT y) { |
| 351 if (!parent) | 310 if (!parent) |
| 352 return nullptr; | 311 return nullptr; |
| 353 FX_FLOAT x1; | 312 FX_FLOAT x1; |
| 354 FX_FLOAT y1; | 313 FX_FLOAT y1; |
| 355 IFWL_Widget* child = GetLastChildWidget(parent); | 314 IFWL_Widget* child = GetLastChildWidget(parent); |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 376 return parent; | 335 return parent; |
| 377 } | 336 } |
| 378 | 337 |
| 379 void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, | 338 void CFWL_WidgetMgr::NotifySizeChanged(IFWL_Widget* pForm, |
| 380 FX_FLOAT fx, | 339 FX_FLOAT fx, |
| 381 FX_FLOAT fy) { | 340 FX_FLOAT fy) { |
| 382 if (FWL_UseOffscreen(pForm)) | 341 if (FWL_UseOffscreen(pForm)) |
| 383 GetWidgetMgrItem(pForm)->pOffscreen.reset(); | 342 GetWidgetMgrItem(pForm)->pOffscreen.reset(); |
| 384 } | 343 } |
| 385 | 344 |
| 386 IFWL_Widget* CFWL_WidgetMgr::nextTab(IFWL_Widget* parent, | 345 IFWL_Widget* CFWL_WidgetMgr::NextTab(IFWL_Widget* parent, |
| 387 IFWL_Widget* focus, | 346 IFWL_Widget* focus, |
| 388 bool& bFind) { | 347 bool& bFind) { |
| 389 CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); | 348 CFWL_WidgetMgr* pMgr = parent->GetOwnerApp()->GetWidgetMgr(); |
| 390 IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); | 349 IFWL_Widget* child = pMgr->GetFirstChildWidget(parent); |
| 391 while (child) { | 350 while (child) { |
| 392 if (focus == child) | 351 if (focus == child) |
| 393 bFind = true; | 352 bFind = true; |
| 394 | 353 |
| 395 if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && | 354 if ((child->GetStyles() & FWL_WGTSTYLE_TabStop) && |
| 396 (!focus || (focus != child && bFind))) { | 355 (!focus || (focus != child && bFind))) { |
| 397 return child; | 356 return child; |
| 398 } | 357 } |
| 399 IFWL_Widget* bRet = nextTab(child, focus, bFind); | 358 IFWL_Widget* bRet = NextTab(child, focus, bFind); |
| 400 if (bRet) | 359 if (bRet) |
| 401 return bRet; | 360 return bRet; |
| 402 | 361 |
| 403 child = pMgr->GetNextSiblingWidget(child); | 362 child = pMgr->GetNextSiblingWidget(child); |
| 404 } | 363 } |
| 405 return nullptr; | 364 return nullptr; |
| 406 } | 365 } |
| 407 | 366 |
| 408 int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) { | 367 int32_t CFWL_WidgetMgr::CountRadioButtonGroup(IFWL_Widget* pFirst) const { |
| 409 int32_t iRet = 0; | 368 int32_t iRet = 0; |
| 410 IFWL_Widget* pChild = pFirst; | 369 IFWL_Widget* pChild = pFirst; |
| 411 while (pChild) { | 370 while (pChild) { |
| 412 pChild = GetNextSiblingWidget(pChild); | 371 pChild = GetNextSiblingWidget(pChild); |
| 413 ++iRet; | 372 ++iRet; |
| 414 } | 373 } |
| 415 return iRet; | 374 return iRet; |
| 416 } | 375 } |
| 417 IFWL_Widget* CFWL_WidgetMgr::GetSiblingRadioButton(IFWL_Widget* pWidget, | 376 |
|
dsinclair
2016/11/14 22:08:41
Always nullptr, which caused a bunch of the cleanu
| |
| 418 bool bNext) { | 377 IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( |
| 378 IFWL_Widget* pRadioButton) const { | |
| 379 IFWL_Widget* pNext = pRadioButton; | |
| 380 if (pNext && (pNext->GetStyles() & FWL_WGTSTYLE_Group)) | |
| 381 return pNext; | |
| 419 return nullptr; | 382 return nullptr; |
| 420 } | 383 } |
| 421 IFWL_Widget* CFWL_WidgetMgr::GetRadioButtonGroupHeader( | 384 |
| 422 IFWL_Widget* pRadioButton) { | |
| 423 IFWL_Widget* pNext = pRadioButton; | |
| 424 while (pNext) { | |
| 425 if (pNext->GetStyles() & FWL_WGTSTYLE_Group) | |
| 426 return pNext; | |
| 427 pNext = GetSiblingRadioButton(pNext, false); | |
| 428 } | |
| 429 pNext = GetLastSiblingWidget(pRadioButton); | |
| 430 while ((pNext = GetSiblingRadioButton(pNext, false)) != nullptr && | |
| 431 pNext != pRadioButton) { | |
| 432 if (pNext->GetStyles() & FWL_WGTSTYLE_Group) | |
| 433 return pNext; | |
| 434 } | |
| 435 pNext = GetFirstSiblingWidget(pRadioButton); | |
| 436 return GetSiblingRadioButton(pNext, true); | |
| 437 } | |
| 438 void CFWL_WidgetMgr::GetSameGroupRadioButton( | 385 void CFWL_WidgetMgr::GetSameGroupRadioButton( |
| 439 IFWL_Widget* pRadioButton, | 386 IFWL_Widget* pRadioButton, |
| 440 CFX_ArrayTemplate<IFWL_Widget*>& group) { | 387 CFX_ArrayTemplate<IFWL_Widget*>& group) const { |
| 441 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); | 388 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); |
| 442 if (!pFirst) { | 389 if (!pFirst) { |
| 443 pFirst = pRadioButton; | 390 pFirst = pRadioButton; |
| 444 } | 391 } |
| 445 int32_t iGroup = CountRadioButtonGroup(pFirst); | 392 int32_t iGroup = CountRadioButtonGroup(pFirst); |
| 446 if (iGroup < 2) { | 393 if (iGroup < 2) |
| 447 IFWL_Widget* pNext = pFirst; | |
| 448 while ((pNext = GetSiblingRadioButton(pNext, true)) != nullptr) { | |
| 449 group.Add(pNext); | |
| 450 } | |
| 451 return; | 394 return; |
| 452 } | 395 group.Add(GetRadioButtonGroupHeader(pRadioButton)); |
| 453 IFWL_Widget* pNext = GetRadioButtonGroupHeader(pRadioButton); | |
| 454 do { | |
| 455 group.Add(pNext); | |
| 456 pNext = GetSiblingRadioButton(pNext, true); | |
| 457 if (!pNext) | |
| 458 pNext = GetSiblingRadioButton(pFirst, true); | |
| 459 } while (pNext && ((pNext->GetStyles() & FWL_WGTSTYLE_Group) == 0)); | |
| 460 } | 396 } |
| 461 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) { | 397 |
| 398 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) const { | |
| 462 if ((pParent->GetClassID() == FWL_Type::PushButton) && | 399 if ((pParent->GetClassID() == FWL_Type::PushButton) && |
| 463 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { | 400 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { |
| 464 return pParent; | 401 return pParent; |
| 465 } | 402 } |
| 466 IFWL_Widget* child = | 403 IFWL_Widget* child = |
| 467 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent); | 404 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent); |
| 468 while (child) { | 405 while (child) { |
| 469 if ((child->GetClassID() == FWL_Type::PushButton) && | 406 if ((child->GetClassID() == FWL_Type::PushButton) && |
| 470 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { | 407 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { |
| 471 return child; | 408 return child; |
| 472 } | 409 } |
| 473 IFWL_Widget* find = GetDefaultButton(child); | 410 IFWL_Widget* find = GetDefaultButton(child); |
| 474 if (find) { | 411 if (find) { |
| 475 return find; | 412 return find; |
| 476 } | 413 } |
| 477 child = child->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(child); | 414 child = child->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(child); |
| 478 } | 415 } |
| 479 return nullptr; | 416 return nullptr; |
| 480 } | 417 } |
| 418 | |
| 481 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { | 419 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { |
| 482 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 420 GetWidgetMgrItem(pWidget)->iRedrawCounter++; |
| 483 (pItem->iRedrawCounter)++; | |
| 484 } | 421 } |
| 422 | |
| 485 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { | 423 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { |
| 486 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); | 424 GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; |
| 487 pItem->iRedrawCounter = 0; | |
| 488 } | 425 } |
| 426 | |
| 489 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( | 427 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( |
| 490 IFWL_Widget* pWidget) const { | 428 IFWL_Widget* pWidget) const { |
| 491 auto it = m_mapWidgetItem.find(pWidget); | 429 auto it = m_mapWidgetItem.find(pWidget); |
| 492 return it != m_mapWidgetItem.end() | 430 return it != m_mapWidgetItem.end() |
| 493 ? static_cast<CFWL_WidgetMgrItem*>(it->second.get()) | 431 ? static_cast<CFWL_WidgetMgrItem*>(it->second.get()) |
| 494 : nullptr; | 432 : nullptr; |
| 495 } | 433 } |
| 496 int32_t CFWL_WidgetMgr::TravelWidgetMgr(CFWL_WidgetMgrItem* pParent, | |
| 497 int32_t* pIndex, | |
| 498 CFWL_WidgetMgrItem* pItem, | |
| 499 IFWL_Widget** pWidget) { | |
| 500 if (!pParent) { | |
| 501 return 0; | |
| 502 } | |
| 503 int32_t iCount = 0; | |
| 504 CFWL_WidgetMgrItem* pChild = pParent->pChild; | |
| 505 while (pChild) { | |
| 506 iCount++; | |
| 507 if (pIndex) { | |
| 508 if (*pIndex == 0) { | |
| 509 *pWidget = pChild->pWidget; | |
| 510 return iCount; | |
| 511 } | |
| 512 pIndex--; | |
| 513 } | |
| 514 if (pItem && pItem == pChild) { | |
| 515 return iCount - 1; | |
| 516 } | |
| 517 pChild = pChild->pNext; | |
| 518 } | |
| 519 if (pIndex) { | |
| 520 return 0; | |
| 521 } else if (pItem) { | |
| 522 return -1; | |
| 523 } | |
| 524 return iCount - 1; | |
| 525 } | |
| 526 | 434 |
| 527 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { | 435 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { |
| 528 if (!pWidget) | 436 if (!pWidget) |
| 529 return false; | 437 return false; |
| 530 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { | 438 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { |
| 531 return false; | 439 return false; |
| 532 } | 440 } |
| 533 uint32_t dwStyles = pWidget->GetStyles(); | 441 uint32_t dwStyles = pWidget->GetStyles(); |
| 534 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == | 442 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == |
| 535 FWL_WGTSTYLE_OverLapper) || | 443 FWL_WGTSTYLE_OverLapper) || |
| 536 (dwStyles & FWL_WGTSTYLE_Popup); | 444 (dwStyles & FWL_WGTSTYLE_Popup); |
| 537 } | 445 } |
| 538 | 446 |
| 539 bool CFWL_WidgetMgr::IsThreadEnabled() { | 447 void CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, |
| 540 return !(m_dwCapability & FWL_WGTMGR_DisableThread); | |
| 541 } | |
| 542 | |
| 543 bool CFWL_WidgetMgr::IsFormDisabled() { | |
| 544 return !!(m_dwCapability & FWL_WGTMGR_DisableForm); | |
| 545 } | |
| 546 | |
| 547 bool CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, | |
| 548 FX_FLOAT fMinHeight, | 448 FX_FLOAT fMinHeight, |
| 549 FX_FLOAT fMaxHeight, | 449 FX_FLOAT fMaxHeight, |
| 550 const CFX_RectF& rtAnchor, | 450 const CFX_RectF& rtAnchor, |
| 551 CFX_RectF& rtPopup) { | 451 CFX_RectF& rtPopup) const { |
| 552 CXFA_FWLAdapterWidgetMgr* pSDApapter = GetAdapterWidgetMgr(); | 452 m_pAdapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, rtPopup); |
| 553 return pSDApapter->GetPopupPos(pWidget, fMinHeight, fMaxHeight, rtAnchor, | |
| 554 rtPopup); | |
| 555 } | |
| 556 CFWL_WidgetMgrDelegate::CFWL_WidgetMgrDelegate(CFWL_WidgetMgr* pWidgetMgr) | |
| 557 : m_pWidgetMgr(pWidgetMgr) {} | |
| 558 FWL_Error CFWL_WidgetMgrDelegate::OnSetCapability(uint32_t dwCapability) { | |
| 559 m_pWidgetMgr->m_dwCapability = dwCapability; | |
| 560 return FWL_Error::Succeeded; | |
| 561 } | 453 } |
| 562 | 454 |
| 563 void CFWL_WidgetMgrDelegate::OnProcessMessageToForm(CFWL_Message* pMessage) { | 455 void CFWL_WidgetMgr::OnSetCapability(uint32_t dwCapability) { |
| 456 m_dwCapability = dwCapability; | |
| 457 } | |
| 458 | |
| 459 void CFWL_WidgetMgr::OnProcessMessageToForm(CFWL_Message* pMessage) { | |
| 564 if (!pMessage) | 460 if (!pMessage) |
| 565 return; | 461 return; |
| 566 if (!pMessage->m_pDstTarget) | 462 if (!pMessage->m_pDstTarget) |
| 567 return; | 463 return; |
| 568 | 464 |
| 569 IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; | 465 IFWL_Widget* pDstWidget = pMessage->m_pDstTarget; |
| 570 const IFWL_App* pApp = pDstWidget->GetOwnerApp(); | 466 const IFWL_App* pApp = pDstWidget->GetOwnerApp(); |
| 571 if (!pApp) | 467 if (!pApp) |
| 572 return; | 468 return; |
| 573 | 469 |
| 574 CFWL_NoteDriver* pNoteDriver = | 470 CFWL_NoteDriver* pNoteDriver = |
| 575 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); | 471 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); |
| 576 if (!pNoteDriver) | 472 if (!pNoteDriver) |
| 577 return; | 473 return; |
| 578 | 474 |
| 579 if (m_pWidgetMgr->IsThreadEnabled()) | 475 if (IsThreadEnabled()) |
| 580 pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); | 476 pMessage = static_cast<CFWL_Message*>(pMessage->Clone()); |
| 581 if (m_pWidgetMgr->IsFormDisabled()) | 477 if (IsFormDisabled()) |
| 582 pNoteDriver->ProcessMessage(pMessage); | 478 pNoteDriver->ProcessMessage(pMessage); |
| 583 else | 479 else |
| 584 pNoteDriver->QueueMessage(pMessage); | 480 pNoteDriver->QueueMessage(pMessage); |
| 585 | 481 |
| 586 #if (_FX_OS_ == _FX_MACOSX_) | 482 #if (_FX_OS_ == _FX_MACOSX_) |
| 587 CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); | 483 CFWL_NoteLoop* pTopLoop = pNoteDriver->GetTopLoop(); |
| 588 if (pTopLoop) | 484 if (pTopLoop) |
| 589 pNoteDriver->UnqueueMessage(pTopLoop); | 485 pNoteDriver->UnqueueMessage(pTopLoop); |
| 590 #endif | 486 #endif |
| 591 | 487 |
| 592 if (m_pWidgetMgr->IsThreadEnabled()) | 488 if (IsThreadEnabled()) |
| 593 pMessage->Release(); | 489 pMessage->Release(); |
| 594 | 490 |
| 595 return; | 491 return; |
| 596 } | 492 } |
| 597 | 493 |
| 598 void CFWL_WidgetMgrDelegate::OnDrawWidget(IFWL_Widget* pWidget, | 494 void CFWL_WidgetMgr::OnDrawWidget(IFWL_Widget* pWidget, |
| 599 CFX_Graphics* pGraphics, | 495 CFX_Graphics* pGraphics, |
| 600 const CFX_Matrix* pMatrix) { | 496 const CFX_Matrix* pMatrix) { |
| 601 if (!pWidget || !pGraphics) | 497 if (!pWidget || !pGraphics) |
| 602 return; | 498 return; |
| 603 | 499 |
| 604 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); | 500 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); |
| 605 CFX_RectF clipCopy; | 501 CFX_RectF clipCopy; |
| 606 pWidget->GetWidgetRect(clipCopy); | 502 pWidget->GetWidgetRect(clipCopy); |
| 607 clipCopy.left = clipCopy.top = 0; | 503 clipCopy.left = clipCopy.top = 0; |
| 608 if (bUseOffscreenDirect(pWidget)) { | 504 if (UseOffscreenDirect(pWidget)) { |
| 609 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); | 505 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); |
| 610 return; | 506 return; |
| 611 } | 507 } |
| 612 CFX_RectF clipBounds; | 508 CFX_RectF clipBounds; |
| 613 | 509 |
| 614 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \ | 510 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \ |
| 615 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ | 511 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ |
| 616 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); | 512 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); |
| 617 pGraphics->GetClipRect(clipBounds); | 513 pGraphics->GetClipRect(clipBounds); |
| 618 clipCopy = clipBounds; | 514 clipCopy = clipBounds; |
| 619 #elif _FX_OS_ == _FX_MACOSX_ | 515 #elif _FX_OS_ == _FX_MACOSX_ |
| 620 if (m_pWidgetMgr->IsFormDisabled()) { | 516 if (IsFormDisabled()) { |
| 621 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); | 517 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); |
| 622 pGraphics->GetClipRect(clipBounds); | 518 pGraphics->GetClipRect(clipBounds); |
| 623 clipCopy = clipBounds; | 519 clipCopy = clipBounds; |
| 624 } else { | 520 } else { |
| 625 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); | 521 clipBounds.Set(pMatrix->a, pMatrix->b, pMatrix->c, pMatrix->d); |
| 626 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. | 522 const_cast<CFX_Matrix*>(pMatrix)->SetIdentity(); // FIXME: const cast. |
| 627 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); | 523 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); |
| 628 } | 524 } |
| 629 #endif // _FX_OS_ == _FX_MACOSX_ | 525 #endif // _FX_OS_ == _FX_MACOSX_ |
| 630 | 526 |
| 631 if (!m_pWidgetMgr->IsFormDisabled()) { | 527 if (!IsFormDisabled()) { |
| 632 CFX_RectF rtClient; | 528 CFX_RectF rtClient; |
| 633 pWidget->GetClientRect(rtClient); | 529 pWidget->GetClientRect(rtClient); |
| 634 clipBounds.Intersect(rtClient); | 530 clipBounds.Intersect(rtClient); |
| 635 } | 531 } |
| 636 if (!clipBounds.IsEmpty()) | 532 if (!clipBounds.IsEmpty()) |
| 637 DrawChild(pWidget, clipBounds, pTemp, pMatrix); | 533 DrawChild(pWidget, clipBounds, pTemp, pMatrix); |
| 638 | 534 |
| 639 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); | 535 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); |
| 640 m_pWidgetMgr->ResetRedrawCounts(pWidget); | 536 ResetRedrawCounts(pWidget); |
| 641 } | 537 } |
| 642 | 538 |
| 643 void CFWL_WidgetMgrDelegate::DrawChild(IFWL_Widget* parent, | 539 void CFWL_WidgetMgr::DrawChild(IFWL_Widget* parent, |
| 644 const CFX_RectF& rtClip, | 540 const CFX_RectF& rtClip, |
| 645 CFX_Graphics* pGraphics, | 541 CFX_Graphics* pGraphics, |
| 646 const CFX_Matrix* pMatrix) { | 542 const CFX_Matrix* pMatrix) { |
| 647 if (!parent) | 543 if (!parent) |
| 648 return; | 544 return; |
| 649 | 545 |
| 650 bool bFormDisable = m_pWidgetMgr->IsFormDisabled(); | 546 bool bFormDisable = IsFormDisabled(); |
| 651 IFWL_Widget* pNextChild = m_pWidgetMgr->GetFirstChildWidget(parent); | 547 IFWL_Widget* pNextChild = GetFirstChildWidget(parent); |
| 652 while (pNextChild) { | 548 while (pNextChild) { |
| 653 IFWL_Widget* child = pNextChild; | 549 IFWL_Widget* child = pNextChild; |
| 654 pNextChild = m_pWidgetMgr->GetNextSiblingWidget(child); | 550 pNextChild = GetNextSiblingWidget(child); |
| 655 if (child->GetStates() & FWL_WGTSTATE_Invisible) | 551 if (child->GetStates() & FWL_WGTSTATE_Invisible) |
| 656 continue; | 552 continue; |
| 657 | 553 |
| 658 CFX_RectF rtWidget; | 554 CFX_RectF rtWidget; |
| 659 child->GetWidgetRect(rtWidget); | 555 child->GetWidgetRect(rtWidget); |
| 660 if (rtWidget.IsEmpty()) | 556 if (rtWidget.IsEmpty()) |
| 661 continue; | 557 continue; |
| 662 | 558 |
| 663 CFX_Matrix widgetMatrix; | 559 CFX_Matrix widgetMatrix; |
| 664 CFX_RectF clipBounds(rtWidget); | 560 CFX_RectF clipBounds(rtWidget); |
| 665 if (!bFormDisable) | 561 if (!bFormDisable) |
| 666 child->GetMatrix(widgetMatrix, true); | 562 child->GetMatrix(widgetMatrix, true); |
| 667 if (pMatrix) | 563 if (pMatrix) |
| 668 widgetMatrix.Concat(*pMatrix); | 564 widgetMatrix.Concat(*pMatrix); |
| 669 | 565 |
| 670 if (!bFormDisable) { | 566 if (!bFormDisable) { |
| 671 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); | 567 widgetMatrix.TransformPoint(clipBounds.left, clipBounds.top); |
| 672 clipBounds.Intersect(rtClip); | 568 clipBounds.Intersect(rtClip); |
| 673 if (clipBounds.IsEmpty()) | 569 if (clipBounds.IsEmpty()) |
| 674 continue; | 570 continue; |
| 675 | 571 |
| 676 pGraphics->SaveGraphState(); | 572 pGraphics->SaveGraphState(); |
| 677 pGraphics->SetClipRect(clipBounds); | 573 pGraphics->SetClipRect(clipBounds); |
| 678 } | 574 } |
| 679 widgetMatrix.Translate(rtWidget.left, rtWidget.top, true); | 575 widgetMatrix.Translate(rtWidget.left, rtWidget.top, true); |
| 680 | 576 |
| 681 if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { | 577 if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { |
| 682 if (m_pWidgetMgr->IsFormDisabled() || | 578 if (IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip)) { |
| 683 IsNeedRepaint(child, &widgetMatrix, rtClip)) { | |
| 684 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); | 579 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); |
| 685 } | 580 } |
| 686 } | 581 } |
| 687 if (!bFormDisable) | 582 if (!bFormDisable) |
| 688 pGraphics->RestoreGraphState(); | 583 pGraphics->RestoreGraphState(); |
| 689 | 584 |
| 690 DrawChild(child, clipBounds, pGraphics, | 585 DrawChild(child, clipBounds, pGraphics, |
| 691 bFormDisable ? &widgetMatrix : pMatrix); | 586 bFormDisable ? &widgetMatrix : pMatrix); |
| 692 child = m_pWidgetMgr->GetNextSiblingWidget(child); | 587 child = GetNextSiblingWidget(child); |
| 693 } | 588 } |
| 694 } | 589 } |
| 695 | 590 |
| 696 CFX_Graphics* CFWL_WidgetMgrDelegate::DrawWidgetBefore( | 591 CFX_Graphics* CFWL_WidgetMgr::DrawWidgetBefore(IFWL_Widget* pWidget, |
| 697 IFWL_Widget* pWidget, | 592 CFX_Graphics* pGraphics, |
| 698 CFX_Graphics* pGraphics, | 593 const CFX_Matrix* pMatrix) { |
| 699 const CFX_Matrix* pMatrix) { | |
| 700 if (!FWL_UseOffscreen(pWidget)) | 594 if (!FWL_UseOffscreen(pWidget)) |
| 701 return pGraphics; | 595 return pGraphics; |
| 702 | 596 |
| 703 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 597 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 704 if (!pItem->pOffscreen) { | 598 if (!pItem->pOffscreen) { |
| 705 pItem->pOffscreen.reset(new CFX_Graphics); | 599 pItem->pOffscreen.reset(new CFX_Graphics); |
| 706 CFX_RectF rect; | 600 CFX_RectF rect; |
| 707 pWidget->GetWidgetRect(rect); | 601 pWidget->GetWidgetRect(rect); |
| 708 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, | 602 pItem->pOffscreen->Create((int32_t)rect.width, (int32_t)rect.height, |
| 709 FXDIB_Argb); | 603 FXDIB_Argb); |
| 710 } | 604 } |
| 711 CFX_RectF rect; | 605 CFX_RectF rect; |
| 712 pGraphics->GetClipRect(rect); | 606 pGraphics->GetClipRect(rect); |
| 713 pItem->pOffscreen->SetClipRect(rect); | 607 pItem->pOffscreen->SetClipRect(rect); |
| 714 return pItem->pOffscreen.get(); | 608 return pItem->pOffscreen.get(); |
| 715 } | 609 } |
| 716 | 610 |
| 717 void CFWL_WidgetMgrDelegate::DrawWidgetAfter(IFWL_Widget* pWidget, | 611 void CFWL_WidgetMgr::DrawWidgetAfter(IFWL_Widget* pWidget, |
| 718 CFX_Graphics* pGraphics, | 612 CFX_Graphics* pGraphics, |
| 719 CFX_RectF& rtClip, | 613 CFX_RectF& rtClip, |
| 720 const CFX_Matrix* pMatrix) { | 614 const CFX_Matrix* pMatrix) { |
| 721 if (FWL_UseOffscreen(pWidget)) { | 615 if (FWL_UseOffscreen(pWidget)) { |
| 722 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 616 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 723 pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, | 617 pGraphics->Transfer(pItem->pOffscreen.get(), rtClip.left, rtClip.top, |
| 724 rtClip, pMatrix); | 618 rtClip, pMatrix); |
| 725 #ifdef _WIN32 | 619 #ifdef _WIN32 |
| 726 pItem->pOffscreen->ClearClip(); | 620 pItem->pOffscreen->ClearClip(); |
| 727 #endif | 621 #endif |
| 728 } | 622 } |
| 729 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 623 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 730 pItem->iRedrawCounter = 0; | 624 pItem->iRedrawCounter = 0; |
| 731 } | 625 } |
| 732 | 626 |
| 733 bool CFWL_WidgetMgrDelegate::IsNeedRepaint(IFWL_Widget* pWidget, | 627 bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, |
| 734 CFX_Matrix* pMatrix, | 628 CFX_Matrix* pMatrix, |
| 735 const CFX_RectF& rtDirty) { | 629 const CFX_RectF& rtDirty) { |
| 736 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 630 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 737 if (pItem && pItem->iRedrawCounter > 0) { | 631 if (pItem && pItem->iRedrawCounter > 0) { |
| 738 pItem->iRedrawCounter = 0; | 632 pItem->iRedrawCounter = 0; |
| 739 return true; | 633 return true; |
| 740 } | 634 } |
| 741 CFX_RectF rtWidget; | 635 CFX_RectF rtWidget; |
| 742 pWidget->GetWidgetRect(rtWidget); | 636 pWidget->GetWidgetRect(rtWidget); |
| 743 rtWidget.left = rtWidget.top = 0; | 637 rtWidget.left = rtWidget.top = 0; |
| 744 pMatrix->TransformRect(rtWidget); | 638 pMatrix->TransformRect(rtWidget); |
| 745 if (!rtWidget.IntersectWith(rtDirty)) | 639 if (!rtWidget.IntersectWith(rtDirty)) |
| 746 return false; | 640 return false; |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 822 } | 716 } |
| 823 if (repaintPoint > 0) | 717 if (repaintPoint > 0) |
| 824 return true; | 718 return true; |
| 825 | 719 |
| 826 pMatrix->TransformRect(rtChilds); | 720 pMatrix->TransformRect(rtChilds); |
| 827 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) | 721 if (rtChilds.Contains(rtDirty) || rtChilds.Contains(rtWidget)) |
| 828 return false; | 722 return false; |
| 829 return true; | 723 return true; |
| 830 } | 724 } |
| 831 | 725 |
| 832 bool CFWL_WidgetMgrDelegate::bUseOffscreenDirect(IFWL_Widget* pWidget) { | 726 bool CFWL_WidgetMgr::UseOffscreenDirect(IFWL_Widget* pWidget) const { |
| 833 CFWL_WidgetMgrItem* pItem = m_pWidgetMgr->GetWidgetMgrItem(pWidget); | 727 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); |
| 834 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) | 728 if (!FWL_UseOffscreen(pWidget) || !(pItem->pOffscreen)) |
| 835 return false; | 729 return false; |
| 836 | 730 |
| 837 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 731 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 838 if (pItem->bOutsideChanged) { | 732 if (pItem->bOutsideChanged) { |
| 839 CFX_RectF r; | 733 CFX_RectF r; |
| 840 pWidget->GetWidgetRect(r); | 734 pWidget->GetWidgetRect(r); |
| 841 CFX_RectF temp(m_pWidgetMgr->m_rtScreen); | 735 CFX_RectF temp(m_rtScreen); |
| 842 temp.Deflate(50, 50); | 736 temp.Deflate(50, 50); |
| 843 if (!temp.Contains(r)) | 737 if (!temp.Contains(r)) |
| 844 return false; | 738 return false; |
| 845 | 739 |
| 846 pItem->bOutsideChanged = false; | 740 pItem->bOutsideChanged = false; |
| 847 } | 741 } |
| 848 #endif | 742 #endif |
| 849 | 743 |
| 850 return pItem->iRedrawCounter == 0; | 744 return pItem->iRedrawCounter == 0; |
| 851 } | 745 } |
| 852 | 746 |
| 853 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} | 747 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem() : CFWL_WidgetMgrItem(nullptr) {} |
| 854 | 748 |
| 855 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) | 749 CFWL_WidgetMgrItem::CFWL_WidgetMgrItem(IFWL_Widget* widget) |
| 856 : pParent(nullptr), | 750 : pParent(nullptr), |
| 857 pOwner(nullptr), | 751 pOwner(nullptr), |
| 858 pChild(nullptr), | 752 pChild(nullptr), |
| 859 pPrevious(nullptr), | 753 pPrevious(nullptr), |
| 860 pNext(nullptr), | 754 pNext(nullptr), |
| 861 pWidget(widget), | 755 pWidget(widget), |
| 862 iRedrawCounter(0) | 756 iRedrawCounter(0) |
| 863 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) | 757 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) |
| 864 , | 758 , |
| 865 bOutsideChanged(false) | 759 bOutsideChanged(false) |
| 866 #endif | 760 #endif |
| 867 { | 761 { |
| 868 } | 762 } |
| 869 | 763 |
| 870 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} | 764 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} |
| OLD | NEW |