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_widget.h" | 7 #include "xfa/fwl/core/cfwl_widget.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <utility> | 10 #include <utility> |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 | 58 |
59 CFWL_Widget::~CFWL_Widget() { | 59 CFWL_Widget::~CFWL_Widget() { |
60 NotifyDriver(); | 60 NotifyDriver(); |
61 m_pWidgetMgr->RemoveWidget(this); | 61 m_pWidgetMgr->RemoveWidget(this); |
62 } | 62 } |
63 | 63 |
64 bool CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { | 64 bool CFWL_Widget::IsInstance(const CFX_WideStringC& wsClass) const { |
65 return false; | 65 return false; |
66 } | 66 } |
67 | 67 |
68 void CFWL_Widget::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 68 CFX_RectF CFWL_Widget::GetAutosizedWidgetRect() { |
69 if (!bAutoSize) { | 69 return CFX_RectF(); |
70 rect = m_pProperties->m_rtWidget; | 70 } |
71 return; | 71 |
72 } | 72 CFX_RectF CFWL_Widget::GetWidgetRect() { |
73 InflateWidgetRect(rect); | 73 return m_pProperties->m_rtWidget; |
74 } | 74 } |
75 | 75 |
76 void CFWL_Widget::InflateWidgetRect(CFX_RectF& rect) { | 76 void CFWL_Widget::InflateWidgetRect(CFX_RectF& rect) { |
77 if (HasEdge()) { | 77 if (HasEdge()) { |
78 FX_FLOAT fEdge = GetEdgeWidth(); | 78 FX_FLOAT fEdge = GetEdgeWidth(); |
79 rect.Inflate(fEdge, fEdge); | 79 rect.Inflate(fEdge, fEdge); |
80 } | 80 } |
81 if (HasBorder()) { | 81 if (HasBorder()) { |
82 FX_FLOAT fBorder = GetBorderSize(true); | 82 FX_FLOAT fBorder = GetBorderSize(true); |
83 rect.Inflate(fBorder, fBorder); | 83 rect.Inflate(fBorder, fBorder); |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 szOffset.y = -szOffset.y; | 194 szOffset.y = -szOffset.y; |
195 } | 195 } |
196 fx += szOffset.x; | 196 fx += szOffset.x; |
197 fy += szOffset.y; | 197 fy += szOffset.y; |
198 return; | 198 return; |
199 } | 199 } |
200 CFX_RectF r; | 200 CFX_RectF r; |
201 CFX_Matrix m; | 201 CFX_Matrix m; |
202 CFWL_Widget* parent = GetParent(); | 202 CFWL_Widget* parent = GetParent(); |
203 if (parent) { | 203 if (parent) { |
204 GetWidgetRect(r, false); | 204 r = GetWidgetRect(); |
205 fx += r.left; | 205 fx += r.left; |
206 fy += r.top; | 206 fy += r.top; |
207 GetMatrix(m, true); | 207 GetMatrix(m, true); |
208 m.TransformPoint(fx, fy); | 208 m.TransformPoint(fx, fy); |
209 } | 209 } |
210 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); | 210 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); |
211 if (!form1) | 211 if (!form1) |
212 return; | 212 return; |
| 213 |
213 if (!pWidget) { | 214 if (!pWidget) { |
214 form1->GetWidgetRect(r, false); | 215 r = form1->GetWidgetRect(); |
215 fx += r.left; | 216 fx += r.left; |
216 fy += r.top; | 217 fy += r.top; |
217 return; | 218 return; |
218 } | 219 } |
219 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); | 220 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); |
220 if (!form2) | 221 if (!form2) |
221 return; | 222 return; |
222 if (form1 != form2) { | 223 if (form1 != form2) { |
223 form1->GetWidgetRect(r, false); | 224 r = form1->GetWidgetRect(); |
224 fx += r.left; | 225 fx += r.left; |
225 fy += r.top; | 226 fy += r.top; |
226 form2->GetWidgetRect(r, false); | 227 r = form2->GetWidgetRect(); |
227 fx -= r.left; | 228 fx -= r.left; |
228 fy -= r.top; | 229 fy -= r.top; |
229 } | 230 } |
230 parent = pWidget->GetParent(); | 231 parent = pWidget->GetParent(); |
231 if (parent) { | 232 if (parent) { |
232 pWidget->GetMatrix(m, true); | 233 pWidget->GetMatrix(m, true); |
233 CFX_Matrix m1; | 234 CFX_Matrix m1; |
234 m1.SetIdentity(); | 235 m1.SetIdentity(); |
235 m1.SetReverse(m); | 236 m1.SetReverse(m); |
236 m1.TransformPoint(fx, fy); | 237 m1.TransformPoint(fx, fy); |
237 pWidget->GetWidgetRect(r, false); | 238 r = pWidget->GetWidgetRect(); |
238 fx -= r.left; | 239 fx -= r.left; |
239 fy -= r.top; | 240 fy -= r.top; |
240 } | 241 } |
241 } | 242 } |
242 | 243 |
243 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { | 244 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { |
244 if (!m_pProperties) | 245 if (!m_pProperties) |
245 return; | 246 return; |
246 if (!bGlobal) { | 247 if (!bGlobal) { |
247 matrix.SetIdentity(); | 248 matrix.SetIdentity(); |
248 return; | 249 return; |
249 } | 250 } |
250 | 251 |
251 CFWL_Widget* parent = GetParent(); | 252 CFWL_Widget* parent = GetParent(); |
252 CFX_ArrayTemplate<CFWL_Widget*> parents; | 253 CFX_ArrayTemplate<CFWL_Widget*> parents; |
253 while (parent) { | 254 while (parent) { |
254 parents.Add(parent); | 255 parents.Add(parent); |
255 parent = parent->GetParent(); | 256 parent = parent->GetParent(); |
256 } | 257 } |
257 matrix.SetIdentity(); | 258 matrix.SetIdentity(); |
258 CFX_Matrix ctmOnParent; | 259 CFX_Matrix ctmOnParent; |
259 CFX_RectF rect; | 260 CFX_RectF rect; |
260 int32_t count = parents.GetSize(); | 261 int32_t count = parents.GetSize(); |
261 for (int32_t i = count - 2; i >= 0; i--) { | 262 for (int32_t i = count - 2; i >= 0; i--) { |
262 parent = parents.GetAt(i); | 263 parent = parents.GetAt(i); |
263 parent->GetMatrix(ctmOnParent, false); | 264 parent->GetMatrix(ctmOnParent, false); |
264 parent->GetWidgetRect(rect, false); | 265 rect = parent->GetWidgetRect(); |
265 matrix.Concat(ctmOnParent, true); | 266 matrix.Concat(ctmOnParent, true); |
266 matrix.Translate(rect.left, rect.top, true); | 267 matrix.Translate(rect.left, rect.top, true); |
267 } | 268 } |
268 CFX_Matrix m; | 269 CFX_Matrix m; |
269 m.SetIdentity(); | 270 m.SetIdentity(); |
270 matrix.Concat(m, true); | 271 matrix.Concat(m, true); |
271 parents.RemoveAll(); | 272 parents.RemoveAll(); |
272 } | 273 } |
273 | 274 |
274 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { | 275 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
679 | 680 |
680 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 681 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
681 if (!pWidgetMgr) | 682 if (!pWidgetMgr) |
682 return CFX_SizeF(); | 683 return CFX_SizeF(); |
683 | 684 |
684 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, | 685 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, |
685 m_pProperties->m_rtWidget.top); | 686 m_pProperties->m_rtWidget.top); |
686 | 687 |
687 CFWL_Widget* pDstWidget = GetParent(); | 688 CFWL_Widget* pDstWidget = GetParent(); |
688 while (pDstWidget && pDstWidget != pParent) { | 689 while (pDstWidget && pDstWidget != pParent) { |
689 CFX_RectF rtDst; | 690 CFX_RectF rtDst = pDstWidget->GetWidgetRect(); |
690 pDstWidget->GetWidgetRect(rtDst, false); | |
691 szRet += CFX_SizeF(rtDst.left, rtDst.top); | 691 szRet += CFX_SizeF(rtDst.left, rtDst.top); |
692 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); | 692 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); |
693 } | 693 } |
694 return szRet; | 694 return szRet; |
695 } | 695 } |
696 | 696 |
697 bool CFWL_Widget::IsParent(CFWL_Widget* pParent) { | 697 bool CFWL_Widget::IsParent(CFWL_Widget* pParent) { |
698 CFWL_Widget* pUpWidget = GetParent(); | 698 CFWL_Widget* pUpWidget = GetParent(); |
699 while (pUpWidget) { | 699 while (pUpWidget) { |
700 if (pUpWidget == pParent) | 700 if (pUpWidget == pParent) |
(...skipping 19 matching lines...) Expand all Loading... |
720 } | 720 } |
721 default: | 721 default: |
722 break; | 722 break; |
723 } | 723 } |
724 } | 724 } |
725 | 725 |
726 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} | 726 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} |
727 | 727 |
728 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, | 728 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, |
729 const CFX_Matrix* pMatrix) {} | 729 const CFX_Matrix* pMatrix) {} |
OLD | NEW |