Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(267)

Side by Side Diff: xfa/fwl/core/cfwl_widgetmgr.cpp

Issue 2506493003: Continue nit cleanup in fwl/core (Closed)
Patch Set: review feedback Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/cfwl_widget.cpp ('k') | xfa/fwl/core/cfx_barcode.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 return pItem && pItem->pParent ? pItem->pParent->pWidget : nullptr; 50 return pItem && pItem->pParent ? pItem->pParent->pWidget : nullptr;
51 } 51 }
52 52
53 IFWL_Widget* CFWL_WidgetMgr::GetOwnerWidget(IFWL_Widget* pWidget) const { 53 IFWL_Widget* CFWL_WidgetMgr::GetOwnerWidget(IFWL_Widget* pWidget) const {
54 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 54 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
55 return pItem && pItem->pOwner ? pItem->pOwner->pWidget : nullptr; 55 return pItem && pItem->pOwner ? pItem->pOwner->pWidget : nullptr;
56 } 56 }
57 57
58 IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const { 58 IFWL_Widget* CFWL_WidgetMgr::GetFirstSiblingWidget(IFWL_Widget* pWidget) const {
59 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 59 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
60 pItem = pItem ? pItem->pPrevious : nullptr; // Not self. 60 if (!pItem)
61 return nullptr;
62
63 pItem = pItem->pPrevious;
61 while (pItem && pItem->pPrevious) 64 while (pItem && pItem->pPrevious)
62 pItem = pItem->pPrevious; 65 pItem = pItem->pPrevious;
63
64 return pItem ? pItem->pWidget : nullptr; 66 return pItem ? pItem->pWidget : nullptr;
65 } 67 }
66 68
67 IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const { 69 IFWL_Widget* CFWL_WidgetMgr::GetPriorSiblingWidget(IFWL_Widget* pWidget) const {
68 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 70 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
69 return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr; 71 return pItem && pItem->pPrevious ? pItem->pPrevious->pWidget : nullptr;
70 } 72 }
71 73
72 IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const { 74 IFWL_Widget* CFWL_WidgetMgr::GetNextSiblingWidget(IFWL_Widget* pWidget) const {
73 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 75 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
74 return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr; 76 return pItem && pItem->pNext ? pItem->pNext->pWidget : nullptr;
75 } 77 }
76 78
77 IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const { 79 IFWL_Widget* CFWL_WidgetMgr::GetFirstChildWidget(IFWL_Widget* pWidget) const {
78 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 80 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
79 return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr; 81 return pItem && pItem->pChild ? pItem->pChild->pWidget : nullptr;
80 } 82 }
81 83
82 IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const { 84 IFWL_Widget* CFWL_WidgetMgr::GetLastChildWidget(IFWL_Widget* pWidget) const {
83 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 85 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
84 pItem = pItem ? pItem->pChild : nullptr; 86 if (!pItem)
87 return nullptr;
88
89 pItem = pItem->pChild;
85 while (pItem && pItem->pNext) 90 while (pItem && pItem->pNext)
86 pItem = pItem->pNext; 91 pItem = pItem->pNext;
87
88 return pItem ? pItem->pWidget : nullptr; 92 return pItem ? pItem->pWidget : nullptr;
89 } 93 }
90 94
91 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const { 95 IFWL_Widget* CFWL_WidgetMgr::GetSystemFormWidget(IFWL_Widget* pWidget) const {
92 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 96 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
93 while (pItem) { 97 while (pItem) {
94 if (IsAbleNative(pItem->pWidget)) 98 if (IsAbleNative(pItem->pWidget))
95 return pItem->pWidget; 99 return pItem->pWidget;
96 pItem = pItem->pParent; 100 pItem = pItem->pParent;
97 } 101 }
98 return nullptr; 102 return nullptr;
99 } 103 }
100 104
101 void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) { 105 void CFWL_WidgetMgr::SetWidgetIndex(IFWL_Widget* pWidget, int32_t nIndex) {
102 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 106 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
103 if (!pItem) 107 if (!pItem)
104 return; 108 return;
105 if (!pItem->pParent) 109 if (!pItem->pParent)
106 return; 110 return;
111
107 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild; 112 CFWL_WidgetMgrItem* pChild = pItem->pParent->pChild;
108 int32_t i = 0; 113 int32_t i = 0;
109 while (pChild) { 114 while (pChild) {
110 if (pChild == pItem) { 115 if (pChild == pItem) {
111 if (i == nIndex) 116 if (i == nIndex)
112 return; 117 return;
113 if (pChild->pPrevious) { 118 if (pChild->pPrevious)
114 pChild->pPrevious->pNext = pChild->pNext; 119 pChild->pPrevious->pNext = pChild->pNext;
115 } 120 if (pChild->pNext)
116 if (pChild->pNext) {
117 pChild->pNext->pPrevious = pChild->pPrevious; 121 pChild->pNext->pPrevious = pChild->pPrevious;
118 } 122 if (pItem->pParent->pChild == pItem)
119 if (pItem->pParent->pChild == pItem) {
120 pItem->pParent->pChild = pItem->pNext; 123 pItem->pParent->pChild = pItem->pNext;
121 } 124
122 pItem->pNext = nullptr; 125 pItem->pNext = nullptr;
123 pItem->pPrevious = nullptr; 126 pItem->pPrevious = nullptr;
124 break; 127 break;
125 } 128 }
126 if (!pChild->pNext) { 129 if (!pChild->pNext)
127 break; 130 break;
128 } 131
129 pChild = pChild->pNext; 132 pChild = pChild->pNext;
130 ++i; 133 ++i;
131 } 134 }
135
132 pChild = pItem->pParent->pChild; 136 pChild = pItem->pParent->pChild;
133 if (pChild) { 137 if (pChild) {
134 if (nIndex < 0) { 138 if (nIndex < 0) {
135 while (pChild->pNext) { 139 while (pChild->pNext)
136 pChild = pChild->pNext; 140 pChild = pChild->pNext;
137 } 141
138 pChild->pNext = pItem; 142 pChild->pNext = pItem;
139 pItem->pPrevious = pChild; 143 pItem->pPrevious = pChild;
140 pItem->pNext = nullptr; 144 pItem->pNext = nullptr;
141 return; 145 return;
142 } 146 }
147
143 i = 0; 148 i = 0;
144 while (i < nIndex && pChild->pNext) { 149 while (i < nIndex && pChild->pNext) {
145 pChild = pChild->pNext; 150 pChild = pChild->pNext;
146 ++i; 151 ++i;
147 } 152 }
148 if (!pChild->pNext) { 153 if (!pChild->pNext) {
149 pChild->pNext = pItem; 154 pChild->pNext = pItem;
150 pItem->pPrevious = pChild; 155 pItem->pPrevious = pChild;
151 pItem->pNext = nullptr; 156 pItem->pNext = nullptr;
152 return; 157 return;
153 } 158 }
154 if (pChild->pPrevious) { 159 if (pChild->pPrevious) {
155 pItem->pPrevious = pChild->pPrevious; 160 pItem->pPrevious = pChild->pPrevious;
156 pChild->pPrevious->pNext = pItem; 161 pChild->pPrevious->pNext = pItem;
157 } 162 }
158 pChild->pPrevious = pItem; 163 pChild->pPrevious = pItem;
159 pItem->pNext = pChild; 164 pItem->pNext = pChild;
160 if (pItem->pParent->pChild == pChild) { 165 if (pItem->pParent->pChild == pChild)
161 pItem->pParent->pChild = pItem; 166 pItem->pParent->pChild = pItem;
162 }
163 } else { 167 } else {
164 pItem->pParent->pChild = pItem; 168 pItem->pParent->pChild = pItem;
165 pItem->pPrevious = nullptr; 169 pItem->pPrevious = nullptr;
166 pItem->pNext = nullptr; 170 pItem->pNext = nullptr;
167 } 171 }
168 } 172 }
169 173
170 void CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget, 174 void CFWL_WidgetMgr::RepaintWidget(IFWL_Widget* pWidget,
171 const CFX_RectF* pRect) { 175 const CFX_RectF* pRect) {
172 if (!m_pAdapter) 176 if (!m_pAdapter)
(...skipping 25 matching lines...) Expand all
198 void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent, 202 void CFWL_WidgetMgr::InsertWidget(IFWL_Widget* pParent,
199 IFWL_Widget* pChild, 203 IFWL_Widget* pChild,
200 int32_t nIndex) { 204 int32_t nIndex) {
201 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); 205 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
202 if (!pParentItem) { 206 if (!pParentItem) {
203 pParentItem = new CFWL_WidgetMgrItem(pParent); 207 pParentItem = new CFWL_WidgetMgrItem(pParent);
204 m_mapWidgetItem[pParent].reset(pParentItem); 208 m_mapWidgetItem[pParent].reset(pParentItem);
205 pParentItem->pParent = GetWidgetMgrItem(nullptr); 209 pParentItem->pParent = GetWidgetMgrItem(nullptr);
206 SetWidgetIndex(pParent, -1); 210 SetWidgetIndex(pParent, -1);
207 } 211 }
212
208 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); 213 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild);
209 if (!pItem) { 214 if (!pItem) {
210 pItem = new CFWL_WidgetMgrItem(pChild); 215 pItem = new CFWL_WidgetMgrItem(pChild);
211 m_mapWidgetItem[pChild].reset(pItem); 216 m_mapWidgetItem[pChild].reset(pItem);
212 } 217 }
213 if (pItem->pParent && pItem->pParent != pParentItem) { 218 if (pItem->pParent && pItem->pParent != pParentItem) {
214 if (pItem->pPrevious) { 219 if (pItem->pPrevious)
215 pItem->pPrevious->pNext = pItem->pNext; 220 pItem->pPrevious->pNext = pItem->pNext;
216 } 221 if (pItem->pNext)
217 if (pItem->pNext) {
218 pItem->pNext->pPrevious = pItem->pPrevious; 222 pItem->pNext->pPrevious = pItem->pPrevious;
219 } 223 if (pItem->pParent->pChild == pItem)
220 if (pItem->pParent->pChild == pItem) {
221 pItem->pParent->pChild = pItem->pNext; 224 pItem->pParent->pChild = pItem->pNext;
222 }
223 } 225 }
224 pItem->pParent = pParentItem; 226 pItem->pParent = pParentItem;
225 SetWidgetIndex(pChild, nIndex); 227 SetWidgetIndex(pChild, nIndex);
226 } 228 }
229
227 void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) { 230 void CFWL_WidgetMgr::RemoveWidget(IFWL_Widget* pWidget) {
228 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 231 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
229 if (!pItem) { 232 if (!pItem)
230 return; 233 return;
231 } 234 if (pItem->pPrevious)
232 if (pItem->pPrevious) {
233 pItem->pPrevious->pNext = pItem->pNext; 235 pItem->pPrevious->pNext = pItem->pNext;
234 } 236 if (pItem->pNext)
235 if (pItem->pNext) {
236 pItem->pNext->pPrevious = pItem->pPrevious; 237 pItem->pNext->pPrevious = pItem->pPrevious;
237 } 238 if (pItem->pParent && pItem->pParent->pChild == pItem)
238 if (pItem->pParent && pItem->pParent->pChild == pItem) {
239 pItem->pParent->pChild = pItem->pNext; 239 pItem->pParent->pChild = pItem->pNext;
240 } 240
241 CFWL_WidgetMgrItem* pChild = pItem->pChild; 241 CFWL_WidgetMgrItem* pChild = pItem->pChild;
242 while (pChild) { 242 while (pChild) {
243 CFWL_WidgetMgrItem* pNext = pChild->pNext; 243 CFWL_WidgetMgrItem* pNext = pChild->pNext;
244 RemoveWidget(pChild->pWidget); 244 RemoveWidget(pChild->pWidget);
245 pChild = pNext; 245 pChild = pNext;
246 } 246 }
247 m_mapWidgetItem.erase(pWidget); 247 m_mapWidgetItem.erase(pWidget);
248 } 248 }
249
249 void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) { 250 void CFWL_WidgetMgr::SetOwner(IFWL_Widget* pOwner, IFWL_Widget* pOwned) {
250 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner); 251 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pOwner);
251 if (!pParentItem) { 252 if (!pParentItem) {
252 pParentItem = new CFWL_WidgetMgrItem(pOwner); 253 pParentItem = new CFWL_WidgetMgrItem(pOwner);
253 m_mapWidgetItem[pOwner].reset(pParentItem); 254 m_mapWidgetItem[pOwner].reset(pParentItem);
254 pParentItem->pParent = GetWidgetMgrItem(nullptr); 255 pParentItem->pParent = GetWidgetMgrItem(nullptr);
255 SetWidgetIndex(pOwner, -1); 256 SetWidgetIndex(pOwner, -1);
256 } 257 }
258
257 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned); 259 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pOwned);
258 if (!pItem) { 260 if (!pItem) {
259 pItem = new CFWL_WidgetMgrItem(pOwned); 261 pItem = new CFWL_WidgetMgrItem(pOwned);
260 m_mapWidgetItem[pOwned].reset(pItem); 262 m_mapWidgetItem[pOwned].reset(pItem);
261 } 263 }
262 pItem->pOwner = pParentItem; 264 pItem->pOwner = pParentItem;
263 } 265 }
264 void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) { 266 void CFWL_WidgetMgr::SetParent(IFWL_Widget* pParent, IFWL_Widget* pChild) {
265 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent); 267 CFWL_WidgetMgrItem* pParentItem = GetWidgetMgrItem(pParent);
266 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild); 268 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pChild);
267 if (!pItem) 269 if (!pItem)
268 return; 270 return;
269 if (pItem->pParent && pItem->pParent != pParentItem) { 271 if (pItem->pParent && pItem->pParent != pParentItem) {
270 if (pItem->pPrevious) { 272 if (pItem->pPrevious)
271 pItem->pPrevious->pNext = pItem->pNext; 273 pItem->pPrevious->pNext = pItem->pNext;
272 } 274 if (pItem->pNext)
273 if (pItem->pNext) {
274 pItem->pNext->pPrevious = pItem->pPrevious; 275 pItem->pNext->pPrevious = pItem->pPrevious;
275 } 276 if (pItem->pParent->pChild == pItem)
276 if (pItem->pParent->pChild == pItem) {
277 pItem->pParent->pChild = pItem->pNext; 277 pItem->pParent->pChild = pItem->pNext;
278 } 278
279 pItem->pNext = nullptr; 279 pItem->pNext = nullptr;
280 pItem->pPrevious = nullptr; 280 pItem->pPrevious = nullptr;
281 } 281 }
282 pItem->pParent = pParentItem; 282 pItem->pParent = pParentItem;
283 SetWidgetIndex(pChild, -1); 283 SetWidgetIndex(pChild, -1);
284 } 284 }
285 285
286 void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget, 286 void CFWL_WidgetMgr::SetWidgetRect_Native(IFWL_Widget* pWidget,
287 const CFX_RectF& rect) { 287 const CFX_RectF& rect) {
288 if (FWL_UseOffscreen(pWidget)) { 288 if (!FWL_UseOffscreen(pWidget))
289 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 289 return;
290 pItem->iRedrawCounter++; 290
291 if (pItem->pOffscreen) { 291 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
292 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice(); 292 pItem->iRedrawCounter++;
293 if (pDevice && pDevice->GetBitmap()) { 293 if (pItem->pOffscreen) {
294 CFX_DIBitmap* pBitmap = pDevice->GetBitmap(); 294 CFX_RenderDevice* pDevice = pItem->pOffscreen->GetRenderDevice();
295 if (pBitmap->GetWidth() - rect.width > 1 || 295 if (pDevice && pDevice->GetBitmap()) {
296 pBitmap->GetHeight() - rect.height > 1) { 296 CFX_DIBitmap* pBitmap = pDevice->GetBitmap();
297 pItem->pOffscreen.reset(); 297 if (pBitmap->GetWidth() - rect.width > 1 ||
298 } 298 pBitmap->GetHeight() - rect.height > 1) {
299 pItem->pOffscreen.reset();
299 } 300 }
300 } 301 }
302 }
301 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 303 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
302 pItem->bOutsideChanged = !m_rtScreen.Contains(rect); 304 pItem->bOutsideChanged = !m_rtScreen.Contains(rect);
303 #endif 305 #endif
304 }
305 } 306 }
306 307
307 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent, 308 IFWL_Widget* CFWL_WidgetMgr::GetWidgetAtPoint(IFWL_Widget* parent,
308 FX_FLOAT x, 309 FX_FLOAT x,
309 FX_FLOAT y) { 310 FX_FLOAT y) {
310 if (!parent) 311 if (!parent)
311 return nullptr; 312 return nullptr;
313
312 FX_FLOAT x1; 314 FX_FLOAT x1;
313 FX_FLOAT y1; 315 FX_FLOAT y1;
314 IFWL_Widget* child = GetLastChildWidget(parent); 316 IFWL_Widget* child = GetLastChildWidget(parent);
315 while (child) { 317 while (child) {
316 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) { 318 if ((child->GetStates() & FWL_WGTSTATE_Invisible) == 0) {
317 x1 = x; 319 x1 = x;
318 y1 = y; 320 y1 = y;
319 CFX_Matrix matrixOnParent; 321 CFX_Matrix matrixOnParent;
320 child->GetMatrix(matrixOnParent); 322 child->GetMatrix(matrixOnParent);
321 CFX_Matrix m; 323 CFX_Matrix m;
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
379 IFWL_Widget* pNext = pRadioButton; 381 IFWL_Widget* pNext = pRadioButton;
380 if (pNext && (pNext->GetStyles() & FWL_WGTSTYLE_Group)) 382 if (pNext && (pNext->GetStyles() & FWL_WGTSTYLE_Group))
381 return pNext; 383 return pNext;
382 return nullptr; 384 return nullptr;
383 } 385 }
384 386
385 void CFWL_WidgetMgr::GetSameGroupRadioButton( 387 void CFWL_WidgetMgr::GetSameGroupRadioButton(
386 IFWL_Widget* pRadioButton, 388 IFWL_Widget* pRadioButton,
387 CFX_ArrayTemplate<IFWL_Widget*>& group) const { 389 CFX_ArrayTemplate<IFWL_Widget*>& group) const {
388 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton); 390 IFWL_Widget* pFirst = GetFirstSiblingWidget(pRadioButton);
389 if (!pFirst) { 391 if (!pFirst)
390 pFirst = pRadioButton; 392 pFirst = pRadioButton;
391 } 393
392 int32_t iGroup = CountRadioButtonGroup(pFirst); 394 int32_t iGroup = CountRadioButtonGroup(pFirst);
393 if (iGroup < 2) 395 if (iGroup < 2)
394 return; 396 return;
395 group.Add(GetRadioButtonGroupHeader(pRadioButton)); 397 group.Add(GetRadioButtonGroupHeader(pRadioButton));
396 } 398 }
397 399
398 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) const { 400 IFWL_Widget* CFWL_WidgetMgr::GetDefaultButton(IFWL_Widget* pParent) const {
399 if ((pParent->GetClassID() == FWL_Type::PushButton) && 401 if ((pParent->GetClassID() == FWL_Type::PushButton) &&
400 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { 402 (pParent->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
401 return pParent; 403 return pParent;
402 } 404 }
405
403 IFWL_Widget* child = 406 IFWL_Widget* child =
404 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent); 407 pParent->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pParent);
405 while (child) { 408 while (child) {
406 if ((child->GetClassID() == FWL_Type::PushButton) && 409 if ((child->GetClassID() == FWL_Type::PushButton) &&
407 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) { 410 (child->GetStates() & (1 << (FWL_WGTSTATE_MAX + 2)))) {
408 return child; 411 return child;
409 } 412 }
410 IFWL_Widget* find = GetDefaultButton(child); 413 if (IFWL_Widget* find = GetDefaultButton(child))
411 if (find) {
412 return find; 414 return find;
413 } 415
414 child = child->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(child); 416 child = child->GetOwnerApp()->GetWidgetMgr()->GetNextSiblingWidget(child);
415 } 417 }
416 return nullptr; 418 return nullptr;
417 } 419 }
418 420
419 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) { 421 void CFWL_WidgetMgr::AddRedrawCounts(IFWL_Widget* pWidget) {
420 GetWidgetMgrItem(pWidget)->iRedrawCounter++; 422 GetWidgetMgrItem(pWidget)->iRedrawCounter++;
421 } 423 }
422 424
423 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) { 425 void CFWL_WidgetMgr::ResetRedrawCounts(IFWL_Widget* pWidget) {
424 GetWidgetMgrItem(pWidget)->iRedrawCounter = 0; 426 GetWidgetMgrItem(pWidget)->iRedrawCounter = 0;
425 } 427 }
426 428
427 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem( 429 CFWL_WidgetMgrItem* CFWL_WidgetMgr::GetWidgetMgrItem(
428 IFWL_Widget* pWidget) const { 430 IFWL_Widget* pWidget) const {
429 auto it = m_mapWidgetItem.find(pWidget); 431 auto it = m_mapWidgetItem.find(pWidget);
430 return it != m_mapWidgetItem.end() 432 return it != m_mapWidgetItem.end()
431 ? static_cast<CFWL_WidgetMgrItem*>(it->second.get()) 433 ? static_cast<CFWL_WidgetMgrItem*>(it->second.get())
432 : nullptr; 434 : nullptr;
433 } 435 }
434 436
435 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const { 437 bool CFWL_WidgetMgr::IsAbleNative(IFWL_Widget* pWidget) const {
436 if (!pWidget) 438 if (!pWidget)
437 return false; 439 return false;
438 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form))) { 440 if (!pWidget->IsInstance(FX_WSTRC(FWL_CLASS_Form)))
439 return false; 441 return false;
440 } 442
441 uint32_t dwStyles = pWidget->GetStyles(); 443 uint32_t dwStyles = pWidget->GetStyles();
442 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) == 444 return ((dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
443 FWL_WGTSTYLE_OverLapper) || 445 FWL_WGTSTYLE_OverLapper) ||
444 (dwStyles & FWL_WGTSTYLE_Popup); 446 (dwStyles & FWL_WGTSTYLE_Popup);
445 } 447 }
446 448
447 void CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget, 449 void CFWL_WidgetMgr::GetAdapterPopupPos(IFWL_Widget* pWidget,
448 FX_FLOAT fMinHeight, 450 FX_FLOAT fMinHeight,
449 FX_FLOAT fMaxHeight, 451 FX_FLOAT fMaxHeight,
450 const CFX_RectF& rtAnchor, 452 const CFX_RectF& rtAnchor,
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
494 void CFWL_WidgetMgr::OnDrawWidget(IFWL_Widget* pWidget, 496 void CFWL_WidgetMgr::OnDrawWidget(IFWL_Widget* pWidget,
495 CFX_Graphics* pGraphics, 497 CFX_Graphics* pGraphics,
496 const CFX_Matrix* pMatrix) { 498 const CFX_Matrix* pMatrix) {
497 if (!pWidget || !pGraphics) 499 if (!pWidget || !pGraphics)
498 return; 500 return;
499 501
500 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix); 502 CFX_Graphics* pTemp = DrawWidgetBefore(pWidget, pGraphics, pMatrix);
501 CFX_RectF clipCopy; 503 CFX_RectF clipCopy;
502 pWidget->GetWidgetRect(clipCopy); 504 pWidget->GetWidgetRect(clipCopy);
503 clipCopy.left = clipCopy.top = 0; 505 clipCopy.left = clipCopy.top = 0;
506
504 if (UseOffscreenDirect(pWidget)) { 507 if (UseOffscreenDirect(pWidget)) {
505 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix); 508 DrawWidgetAfter(pWidget, pGraphics, clipCopy, pMatrix);
506 return; 509 return;
507 } 510 }
508 CFX_RectF clipBounds; 511 CFX_RectF clipBounds;
509 512
510 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \ 513 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || \
511 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_ 514 _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_ANDROID_
512 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix); 515 pWidget->GetDelegate()->OnDrawWidget(pTemp, pMatrix);
513 pGraphics->GetClipRect(clipBounds); 516 pGraphics->GetClipRect(clipBounds);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
568 clipBounds.Intersect(rtClip); 571 clipBounds.Intersect(rtClip);
569 if (clipBounds.IsEmpty()) 572 if (clipBounds.IsEmpty())
570 continue; 573 continue;
571 574
572 pGraphics->SaveGraphState(); 575 pGraphics->SaveGraphState();
573 pGraphics->SetClipRect(clipBounds); 576 pGraphics->SetClipRect(clipBounds);
574 } 577 }
575 widgetMatrix.Translate(rtWidget.left, rtWidget.top, true); 578 widgetMatrix.Translate(rtWidget.left, rtWidget.top, true);
576 579
577 if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) { 580 if (IFWL_WidgetDelegate* pDelegate = child->GetDelegate()) {
578 if (IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip)) { 581 if (IsFormDisabled() || IsNeedRepaint(child, &widgetMatrix, rtClip))
579 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix); 582 pDelegate->OnDrawWidget(pGraphics, &widgetMatrix);
580 }
581 } 583 }
582 if (!bFormDisable) 584 if (!bFormDisable)
583 pGraphics->RestoreGraphState(); 585 pGraphics->RestoreGraphState();
584 586
585 DrawChild(child, clipBounds, pGraphics, 587 DrawChild(child, clipBounds, pGraphics,
586 bFormDisable ? &widgetMatrix : pMatrix); 588 bFormDisable ? &widgetMatrix : pMatrix);
587 child = GetNextSiblingWidget(child); 589 child = GetNextSiblingWidget(child);
588 } 590 }
589 } 591 }
590 592
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
625 } 627 }
626 628
627 bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget, 629 bool CFWL_WidgetMgr::IsNeedRepaint(IFWL_Widget* pWidget,
628 CFX_Matrix* pMatrix, 630 CFX_Matrix* pMatrix,
629 const CFX_RectF& rtDirty) { 631 const CFX_RectF& rtDirty) {
630 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget); 632 CFWL_WidgetMgrItem* pItem = GetWidgetMgrItem(pWidget);
631 if (pItem && pItem->iRedrawCounter > 0) { 633 if (pItem && pItem->iRedrawCounter > 0) {
632 pItem->iRedrawCounter = 0; 634 pItem->iRedrawCounter = 0;
633 return true; 635 return true;
634 } 636 }
637
635 CFX_RectF rtWidget; 638 CFX_RectF rtWidget;
636 pWidget->GetWidgetRect(rtWidget); 639 pWidget->GetWidgetRect(rtWidget);
637 rtWidget.left = rtWidget.top = 0; 640 rtWidget.left = rtWidget.top = 0;
638 pMatrix->TransformRect(rtWidget); 641 pMatrix->TransformRect(rtWidget);
639 if (!rtWidget.IntersectWith(rtDirty)) 642 if (!rtWidget.IntersectWith(rtDirty))
640 return false; 643 return false;
641 644
642 IFWL_Widget* pChild = 645 IFWL_Widget* pChild =
643 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget); 646 pWidget->GetOwnerApp()->GetWidgetMgr()->GetFirstChildWidget(pWidget);
644 if (!pChild) 647 if (!pChild)
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
755 pWidget(widget), 758 pWidget(widget),
756 iRedrawCounter(0) 759 iRedrawCounter(0)
757 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_) 760 #if (_FX_OS_ == _FX_WIN32_DESKTOP_) || (_FX_OS_ == _FX_WIN64_)
758 , 761 ,
759 bOutsideChanged(false) 762 bOutsideChanged(false)
760 #endif 763 #endif
761 { 764 {
762 } 765 }
763 766
764 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {} 767 CFWL_WidgetMgrItem::~CFWL_WidgetMgrItem() {}
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_widget.cpp ('k') | xfa/fwl/core/cfx_barcode.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698