| 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 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 CFWL_Widget* widget, | 129 CFWL_Widget* widget, |
| 130 CFWL_NoteDriver* noteDriver) { | 130 CFWL_NoteDriver* noteDriver) { |
| 131 CFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget); | 131 CFWL_Widget* child = widgetMgr->GetFirstChildWidget(widget); |
| 132 while (child) { | 132 while (child) { |
| 133 noteDriver->NotifyTargetHide(child); | 133 noteDriver->NotifyTargetHide(child); |
| 134 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 134 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
| 135 child = widgetMgr->GetNextSiblingWidget(child); | 135 child = widgetMgr->GetNextSiblingWidget(child); |
| 136 } | 136 } |
| 137 } | 137 } |
| 138 | 138 |
| 139 void CFWL_Widget::SetStates(uint32_t dwStates, bool bSet) { | 139 void CFWL_Widget::SetStates(uint32_t dwStates) { |
| 140 bSet ? (m_pProperties->m_dwStates |= dwStates) | 140 m_pProperties->m_dwStates |= dwStates; |
| 141 : (m_pProperties->m_dwStates &= ~dwStates); | 141 if (!(dwStates & FWL_WGTSTATE_Invisible)) |
| 142 if (!(dwStates & FWL_WGTSTATE_Invisible) || !bSet) | |
| 143 return; | 142 return; |
| 144 | 143 |
| 145 CFWL_NoteDriver* noteDriver = | 144 CFWL_NoteDriver* noteDriver = |
| 146 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); | 145 static_cast<CFWL_NoteDriver*>(GetOwnerApp()->GetNoteDriver()); |
| 147 CFWL_WidgetMgr* widgetMgr = GetOwnerApp()->GetWidgetMgr(); | 146 CFWL_WidgetMgr* widgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 148 noteDriver->NotifyTargetHide(this); | 147 noteDriver->NotifyTargetHide(this); |
| 149 CFWL_Widget* child = widgetMgr->GetFirstChildWidget(this); | 148 CFWL_Widget* child = widgetMgr->GetFirstChildWidget(this); |
| 150 while (child) { | 149 while (child) { |
| 151 noteDriver->NotifyTargetHide(child); | 150 noteDriver->NotifyTargetHide(child); |
| 152 NotifyHideChildWidget(widgetMgr, child, noteDriver); | 151 NotifyHideChildWidget(widgetMgr, child, noteDriver); |
| 153 child = widgetMgr->GetNextSiblingWidget(child); | 152 child = widgetMgr->GetNextSiblingWidget(child); |
| 154 } | 153 } |
| 155 return; | 154 return; |
| 156 } | 155 } |
| 157 | 156 |
| 157 void CFWL_Widget::RemoveStates(uint32_t dwStates) { |
| 158 m_pProperties->m_dwStates &= ~dwStates; |
| 159 } |
| 160 |
| 158 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 161 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
| 159 CFX_RectF rtClient; | 162 CFX_RectF rtClient; |
| 160 GetClientRect(rtClient); | 163 GetClientRect(rtClient); |
| 161 if (rtClient.Contains(fx, fy)) | 164 if (rtClient.Contains(fx, fy)) |
| 162 return FWL_WidgetHit::Client; | 165 return FWL_WidgetHit::Client; |
| 163 if (HasEdge()) { | 166 if (HasEdge()) { |
| 164 CFX_RectF rtEdge; | 167 CFX_RectF rtEdge; |
| 165 GetEdgeRect(rtEdge); | 168 GetEdgeRect(rtEdge); |
| 166 if (rtEdge.Contains(fx, fy)) | 169 if (rtEdge.Contains(fx, fy)) |
| 167 return FWL_WidgetHit::Edge; | 170 return FWL_WidgetHit::Edge; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 188 szOffset.y = -szOffset.y; | 191 szOffset.y = -szOffset.y; |
| 189 } | 192 } |
| 190 fx += szOffset.x; | 193 fx += szOffset.x; |
| 191 fy += szOffset.y; | 194 fy += szOffset.y; |
| 192 return; | 195 return; |
| 193 } | 196 } |
| 194 CFX_RectF r; | 197 CFX_RectF r; |
| 195 CFX_Matrix m; | 198 CFX_Matrix m; |
| 196 CFWL_Widget* parent = GetParent(); | 199 CFWL_Widget* parent = GetParent(); |
| 197 if (parent) { | 200 if (parent) { |
| 198 GetWidgetRect(r); | 201 GetWidgetRect(r, false); |
| 199 fx += r.left; | 202 fx += r.left; |
| 200 fy += r.top; | 203 fy += r.top; |
| 201 GetMatrix(m, true); | 204 GetMatrix(m, true); |
| 202 m.TransformPoint(fx, fy); | 205 m.TransformPoint(fx, fy); |
| 203 } | 206 } |
| 204 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); | 207 CFWL_Widget* form1 = m_pWidgetMgr->GetSystemFormWidget(this); |
| 205 if (!form1) | 208 if (!form1) |
| 206 return; | 209 return; |
| 207 if (!pWidget) { | 210 if (!pWidget) { |
| 208 form1->GetWidgetRect(r); | 211 form1->GetWidgetRect(r, false); |
| 209 fx += r.left; | 212 fx += r.left; |
| 210 fy += r.top; | 213 fy += r.top; |
| 211 return; | 214 return; |
| 212 } | 215 } |
| 213 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); | 216 CFWL_Widget* form2 = m_pWidgetMgr->GetSystemFormWidget(pWidget); |
| 214 if (!form2) | 217 if (!form2) |
| 215 return; | 218 return; |
| 216 if (form1 != form2) { | 219 if (form1 != form2) { |
| 217 form1->GetWidgetRect(r); | 220 form1->GetWidgetRect(r, false); |
| 218 fx += r.left; | 221 fx += r.left; |
| 219 fy += r.top; | 222 fy += r.top; |
| 220 form2->GetWidgetRect(r); | 223 form2->GetWidgetRect(r, false); |
| 221 fx -= r.left; | 224 fx -= r.left; |
| 222 fy -= r.top; | 225 fy -= r.top; |
| 223 } | 226 } |
| 224 parent = pWidget->GetParent(); | 227 parent = pWidget->GetParent(); |
| 225 if (parent) { | 228 if (parent) { |
| 226 pWidget->GetMatrix(m, true); | 229 pWidget->GetMatrix(m, true); |
| 227 CFX_Matrix m1; | 230 CFX_Matrix m1; |
| 228 m1.SetIdentity(); | 231 m1.SetIdentity(); |
| 229 m1.SetReverse(m); | 232 m1.SetReverse(m); |
| 230 m1.TransformPoint(fx, fy); | 233 m1.TransformPoint(fx, fy); |
| 231 pWidget->GetWidgetRect(r); | 234 pWidget->GetWidgetRect(r, false); |
| 232 fx -= r.left; | 235 fx -= r.left; |
| 233 fy -= r.top; | 236 fy -= r.top; |
| 234 } | 237 } |
| 235 } | 238 } |
| 236 | 239 |
| 237 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { | 240 void CFWL_Widget::GetMatrix(CFX_Matrix& matrix, bool bGlobal) { |
| 238 if (!m_pProperties) | 241 if (!m_pProperties) |
| 239 return; | 242 return; |
| 240 if (!bGlobal) { | 243 if (!bGlobal) { |
| 241 matrix.SetIdentity(); | 244 matrix.SetIdentity(); |
| 242 return; | 245 return; |
| 243 } | 246 } |
| 244 | 247 |
| 245 CFWL_Widget* parent = GetParent(); | 248 CFWL_Widget* parent = GetParent(); |
| 246 CFX_ArrayTemplate<CFWL_Widget*> parents; | 249 CFX_ArrayTemplate<CFWL_Widget*> parents; |
| 247 while (parent) { | 250 while (parent) { |
| 248 parents.Add(parent); | 251 parents.Add(parent); |
| 249 parent = parent->GetParent(); | 252 parent = parent->GetParent(); |
| 250 } | 253 } |
| 251 matrix.SetIdentity(); | 254 matrix.SetIdentity(); |
| 252 CFX_Matrix ctmOnParent; | 255 CFX_Matrix ctmOnParent; |
| 253 CFX_RectF rect; | 256 CFX_RectF rect; |
| 254 int32_t count = parents.GetSize(); | 257 int32_t count = parents.GetSize(); |
| 255 for (int32_t i = count - 2; i >= 0; i--) { | 258 for (int32_t i = count - 2; i >= 0; i--) { |
| 256 parent = parents.GetAt(i); | 259 parent = parents.GetAt(i); |
| 257 parent->GetMatrix(ctmOnParent, false); | 260 parent->GetMatrix(ctmOnParent, false); |
| 258 parent->GetWidgetRect(rect); | 261 parent->GetWidgetRect(rect, false); |
| 259 matrix.Concat(ctmOnParent, true); | 262 matrix.Concat(ctmOnParent, true); |
| 260 matrix.Translate(rect.left, rect.top, true); | 263 matrix.Translate(rect.left, rect.top, true); |
| 261 } | 264 } |
| 262 CFX_Matrix m; | 265 CFX_Matrix m; |
| 263 m.SetIdentity(); | 266 m.SetIdentity(); |
| 264 matrix.Concat(m, true); | 267 matrix.Concat(m, true); |
| 265 parents.RemoveAll(); | 268 parents.RemoveAll(); |
| 266 } | 269 } |
| 267 | 270 |
| 268 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { | 271 IFWL_ThemeProvider* CFWL_Widget::GetThemeProvider() const { |
| (...skipping 408 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 677 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); | 680 CFWL_WidgetMgr* pWidgetMgr = GetOwnerApp()->GetWidgetMgr(); |
| 678 if (!pWidgetMgr) | 681 if (!pWidgetMgr) |
| 679 return CFX_SizeF(); | 682 return CFX_SizeF(); |
| 680 | 683 |
| 681 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, | 684 CFX_SizeF szRet(m_pProperties->m_rtWidget.left, |
| 682 m_pProperties->m_rtWidget.top); | 685 m_pProperties->m_rtWidget.top); |
| 683 | 686 |
| 684 CFWL_Widget* pDstWidget = GetParent(); | 687 CFWL_Widget* pDstWidget = GetParent(); |
| 685 while (pDstWidget && pDstWidget != pParent) { | 688 while (pDstWidget && pDstWidget != pParent) { |
| 686 CFX_RectF rtDst; | 689 CFX_RectF rtDst; |
| 687 pDstWidget->GetWidgetRect(rtDst); | 690 pDstWidget->GetWidgetRect(rtDst, false); |
| 688 szRet += CFX_SizeF(rtDst.left, rtDst.top); | 691 szRet += CFX_SizeF(rtDst.left, rtDst.top); |
| 689 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); | 692 pDstWidget = pWidgetMgr->GetParentWidget(pDstWidget); |
| 690 } | 693 } |
| 691 return szRet; | 694 return szRet; |
| 692 } | 695 } |
| 693 | 696 |
| 694 bool CFWL_Widget::IsParent(CFWL_Widget* pParent) { | 697 bool CFWL_Widget::IsParent(CFWL_Widget* pParent) { |
| 695 CFWL_Widget* pUpWidget = GetParent(); | 698 CFWL_Widget* pUpWidget = GetParent(); |
| 696 while (pUpWidget) { | 699 while (pUpWidget) { |
| 697 if (pUpWidget == pParent) | 700 if (pUpWidget == pParent) |
| (...skipping 21 matching lines...) Expand all Loading... |
| 719 } | 722 } |
| 720 default: | 723 default: |
| 721 break; | 724 break; |
| 722 } | 725 } |
| 723 } | 726 } |
| 724 | 727 |
| 725 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} | 728 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} |
| 726 | 729 |
| 727 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, | 730 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, |
| 728 const CFX_Matrix* pMatrix) {} | 731 const CFX_Matrix* pMatrix) {} |
| OLD | NEW |