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

Side by Side Diff: xfa/fwl/cfwl_widget.cpp

Issue 2575093002: Cleanup widget edge related code (Closed)
Patch Set: Rebase to master Created 4 years 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/cfwl_widget.h ('k') | xfa/fwl/theme/cfwl_barcodetp.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/cfwl_widget.h" 7 #include "xfa/fwl/cfwl_widget.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <utility> 10 #include <utility>
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
67 67
68 CFX_RectF CFWL_Widget::GetAutosizedWidgetRect() { 68 CFX_RectF CFWL_Widget::GetAutosizedWidgetRect() {
69 return CFX_RectF(); 69 return CFX_RectF();
70 } 70 }
71 71
72 CFX_RectF CFWL_Widget::GetWidgetRect() { 72 CFX_RectF CFWL_Widget::GetWidgetRect() {
73 return m_pProperties->m_rtWidget; 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()) {
78 FX_FLOAT fEdge = GetEdgeWidth();
79 rect.Inflate(fEdge, fEdge);
80 }
81 if (HasBorder()) { 77 if (HasBorder()) {
82 FX_FLOAT fBorder = GetBorderSize(true); 78 FX_FLOAT fBorder = GetBorderSize(true);
83 rect.Inflate(fBorder, fBorder); 79 rect.Inflate(fBorder, fBorder);
84 } 80 }
85 } 81 }
86 82
87 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) { 83 void CFWL_Widget::SetWidgetRect(const CFX_RectF& rect) {
88 m_pProperties->m_rtWidget = rect; 84 m_pProperties->m_rtWidget = rect;
89 if (IsChild()) 85 if (IsChild())
90 return; 86 return;
91 87
92 m_pWidgetMgr->SetWidgetRect_Native(this, rect); 88 m_pWidgetMgr->SetWidgetRect_Native(this, rect);
93 } 89 }
94 90
95 CFX_RectF CFWL_Widget::GetClientRect() { 91 CFX_RectF CFWL_Widget::GetClientRect() {
96 CFX_RectF rect = GetEdgeRect(); 92 return GetEdgeRect();
97 if (HasEdge()) {
98 FX_FLOAT fEdge = GetEdgeWidth();
99 rect.Deflate(fEdge, fEdge);
100 }
101 return rect;
102 } 93 }
103 94
104 void CFWL_Widget::SetParent(CFWL_Widget* pParent) { 95 void CFWL_Widget::SetParent(CFWL_Widget* pParent) {
105 m_pProperties->m_pParent = pParent; 96 m_pProperties->m_pParent = pParent;
106 m_pWidgetMgr->SetParent(pParent, this); 97 m_pWidgetMgr->SetParent(pParent, this);
107 } 98 }
108 99
109 uint32_t CFWL_Widget::GetStyles() const { 100 uint32_t CFWL_Widget::GetStyles() const {
110 return m_pProperties->m_dwStyles; 101 return m_pProperties->m_dwStyles;
111 } 102 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
158 return; 149 return;
159 } 150 }
160 151
161 void CFWL_Widget::RemoveStates(uint32_t dwStates) { 152 void CFWL_Widget::RemoveStates(uint32_t dwStates) {
162 m_pProperties->m_dwStates &= ~dwStates; 153 m_pProperties->m_dwStates &= ~dwStates;
163 } 154 }
164 155
165 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 156 FWL_WidgetHit CFWL_Widget::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
166 if (GetClientRect().Contains(fx, fy)) 157 if (GetClientRect().Contains(fx, fy))
167 return FWL_WidgetHit::Client; 158 return FWL_WidgetHit::Client;
168 if (HasEdge() && GetEdgeRect().Contains(fx, fy))
169 return FWL_WidgetHit::Edge;
170 if (HasBorder() && GetRelativeRect().Contains(fx, fy)) 159 if (HasBorder() && GetRelativeRect().Contains(fx, fy))
171 return FWL_WidgetHit::Border; 160 return FWL_WidgetHit::Border;
172 return FWL_WidgetHit::Unknown; 161 return FWL_WidgetHit::Unknown;
173 } 162 }
174 163
175 void CFWL_Widget::TransformTo(CFWL_Widget* pWidget, 164 void CFWL_Widget::TransformTo(CFWL_Widget* pWidget,
176 FX_FLOAT& fx, 165 FX_FLOAT& fx,
177 FX_FLOAT& fy) { 166 FX_FLOAT& fy) {
178 if (m_pWidgetMgr->IsFormDisabled()) { 167 if (m_pWidgetMgr->IsFormDisabled()) {
179 CFX_SizeF szOffset; 168 CFX_SizeF szOffset;
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
271 } 260 }
272 261
273 bool CFWL_Widget::IsEnabled() const { 262 bool CFWL_Widget::IsEnabled() const {
274 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0; 263 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == 0;
275 } 264 }
276 265
277 bool CFWL_Widget::HasBorder() const { 266 bool CFWL_Widget::HasBorder() const {
278 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border); 267 return !!(m_pProperties->m_dwStyles & FWL_WGTSTYLE_Border);
279 } 268 }
280 269
281 bool CFWL_Widget::HasEdge() const {
282 return false;
283 }
284
285 bool CFWL_Widget::IsVisible() const { 270 bool CFWL_Widget::IsVisible() const {
286 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0; 271 return (m_pProperties->m_dwStates & FWL_WGTSTATE_Invisible) == 0;
287 } 272 }
288 273
289 bool CFWL_Widget::IsOverLapper() const { 274 bool CFWL_Widget::IsOverLapper() const {
290 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) == 275 return (m_pProperties->m_dwStyles & FWL_WGTSTYLE_WindowTypeMask) ==
291 FWL_WGTSTYLE_OverLapper; 276 FWL_WGTSTYLE_OverLapper;
292 } 277 }
293 278
294 bool CFWL_Widget::IsPopup() const { 279 bool CFWL_Widget::IsPopup() const {
(...skipping 20 matching lines...) Expand all
315 } 300 }
316 301
317 FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) { 302 FX_FLOAT CFWL_Widget::GetBorderSize(bool bCX) {
318 FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity( 303 FX_FLOAT* pfBorder = static_cast<FX_FLOAT*>(GetThemeCapacity(
319 bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder)); 304 bCX ? CFWL_WidgetCapacity::CXBorder : CFWL_WidgetCapacity::CYBorder));
320 if (!pfBorder) 305 if (!pfBorder)
321 return 0; 306 return 0;
322 return *pfBorder; 307 return *pfBorder;
323 } 308 }
324 309
325 FX_FLOAT CFWL_Widget::GetEdgeWidth() {
326 return 0;
327 }
328
329 CFX_RectF CFWL_Widget::GetRelativeRect() { 310 CFX_RectF CFWL_Widget::GetRelativeRect() {
330 CFX_RectF rect = m_pProperties->m_rtWidget; 311 CFX_RectF rect = m_pProperties->m_rtWidget;
331 rect.left = 0; 312 rect.left = 0;
332 rect.top = 0; 313 rect.top = 0;
333 return rect; 314 return rect;
334 } 315 }
335 316
336 void* CFWL_Widget::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) { 317 void* CFWL_Widget::GetThemeCapacity(CFWL_WidgetCapacity dwCapacity) {
337 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); 318 IFWL_ThemeProvider* pTheme = GetAvailableTheme();
338 if (!pTheme) 319 if (!pTheme)
(...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after
605 CFWL_ThemeBackground param; 586 CFWL_ThemeBackground param;
606 param.m_pWidget = this; 587 param.m_pWidget = this;
607 param.m_iPart = iPartBorder; 588 param.m_iPart = iPartBorder;
608 param.m_pGraphics = pGraphics; 589 param.m_pGraphics = pGraphics;
609 if (pMatrix) 590 if (pMatrix)
610 param.m_matrix.Concat(*pMatrix, true); 591 param.m_matrix.Concat(*pMatrix, true);
611 param.m_rtPart = GetRelativeRect(); 592 param.m_rtPart = GetRelativeRect();
612 pTheme->DrawBackground(&param); 593 pTheme->DrawBackground(&param);
613 } 594 }
614 595
615 void CFWL_Widget::DrawEdge(CFX_Graphics* pGraphics,
616 CFWL_Part iPartEdge,
617 IFWL_ThemeProvider* pTheme,
618 const CFX_Matrix* pMatrix) {
619 CFWL_ThemeBackground param;
620 param.m_pWidget = this;
621 param.m_iPart = iPartEdge;
622 param.m_pGraphics = pGraphics;
623 if (pMatrix)
624 param.m_matrix.Concat(*pMatrix, true);
625 param.m_rtPart = GetEdgeRect();
626 pTheme->DrawBackground(&param);
627 }
628
629 void CFWL_Widget::NotifyDriver() { 596 void CFWL_Widget::NotifyDriver() {
630 const CFWL_App* pApp = GetOwnerApp(); 597 const CFWL_App* pApp = GetOwnerApp();
631 if (!pApp) 598 if (!pApp)
632 return; 599 return;
633 600
634 CFWL_NoteDriver* pDriver = 601 CFWL_NoteDriver* pDriver =
635 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver()); 602 static_cast<CFWL_NoteDriver*>(pApp->GetNoteDriver());
636 if (!pDriver) 603 if (!pDriver)
637 return; 604 return;
638 605
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
685 } 652 }
686 default: 653 default:
687 break; 654 break;
688 } 655 }
689 } 656 }
690 657
691 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {} 658 void CFWL_Widget::OnProcessEvent(CFWL_Event* pEvent) {}
692 659
693 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics, 660 void CFWL_Widget::OnDrawWidget(CFX_Graphics* pGraphics,
694 const CFX_Matrix* pMatrix) {} 661 const CFX_Matrix* pMatrix) {}
OLDNEW
« no previous file with comments | « xfa/fwl/cfwl_widget.h ('k') | xfa/fwl/theme/cfwl_barcodetp.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698