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/ifwl_spinbutton.h" | 7 #include "xfa/fwl/core/ifwl_spinbutton.h" |
8 | 8 |
9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
(...skipping 28 matching lines...) Expand all Loading... |
39 m_rtDnButton.Reset(); | 39 m_rtDnButton.Reset(); |
40 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; | 40 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; |
41 } | 41 } |
42 | 42 |
43 IFWL_SpinButton::~IFWL_SpinButton() {} | 43 IFWL_SpinButton::~IFWL_SpinButton() {} |
44 | 44 |
45 FWL_Type IFWL_SpinButton::GetClassID() const { | 45 FWL_Type IFWL_SpinButton::GetClassID() const { |
46 return FWL_Type::SpinButton; | 46 return FWL_Type::SpinButton; |
47 } | 47 } |
48 | 48 |
49 FWL_Error IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | 49 void IFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { |
50 if (bAutoSize) { | 50 if (bAutoSize) { |
51 rect.Set(0, 0, kMinWidth, kMinHeight); | 51 rect.Set(0, 0, kMinWidth, kMinHeight); |
52 IFWL_Widget::GetWidgetRect(rect, true); | 52 IFWL_Widget::GetWidgetRect(rect, true); |
53 } else { | 53 } else { |
54 rect = m_pProperties->m_rtWidget; | 54 rect = m_pProperties->m_rtWidget; |
55 } | 55 } |
56 return FWL_Error::Succeeded; | |
57 } | 56 } |
58 | 57 |
59 FWL_Error IFWL_SpinButton::Update() { | 58 void IFWL_SpinButton::Update() { |
60 if (IsLocked()) { | 59 if (IsLocked()) { |
61 return FWL_Error::Indefinite; | 60 return; |
62 } | 61 } |
63 GetClientRect(m_rtClient); | 62 GetClientRect(m_rtClient); |
64 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { | 63 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { |
65 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, | 64 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, |
66 m_rtClient.height / 2); | 65 m_rtClient.height / 2); |
67 m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, | 66 m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, |
68 m_rtClient.width, m_rtClient.height / 2); | 67 m_rtClient.width, m_rtClient.height / 2); |
69 } else { | 68 } else { |
70 m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, | 69 m_rtUpButton.Set(m_rtClient.left, m_rtClient.top, m_rtClient.width / 2, |
71 m_rtClient.height); | 70 m_rtClient.height); |
72 m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, | 71 m_rtDnButton.Set(m_rtClient.left + m_rtClient.width / 2, m_rtClient.top, |
73 m_rtClient.width / 2, m_rtClient.height); | 72 m_rtClient.width / 2, m_rtClient.height); |
74 } | 73 } |
75 return FWL_Error::Succeeded; | |
76 } | 74 } |
77 | 75 |
78 FWL_WidgetHit IFWL_SpinButton::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 76 FWL_WidgetHit IFWL_SpinButton::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
79 if (m_rtClient.Contains(fx, fy)) | 77 if (m_rtClient.Contains(fx, fy)) |
80 return FWL_WidgetHit::Client; | 78 return FWL_WidgetHit::Client; |
81 if (HasBorder() && (m_rtClient.Contains(fx, fy))) | 79 if (HasBorder() && (m_rtClient.Contains(fx, fy))) |
82 return FWL_WidgetHit::Border; | 80 return FWL_WidgetHit::Border; |
83 if (HasEdge()) { | 81 if (HasEdge()) { |
84 CFX_RectF rtEdge; | 82 CFX_RectF rtEdge; |
85 GetEdgeRect(rtEdge); | 83 GetEdgeRect(rtEdge); |
86 if (rtEdge.Contains(fx, fy)) | 84 if (rtEdge.Contains(fx, fy)) |
87 return FWL_WidgetHit::Left; | 85 return FWL_WidgetHit::Left; |
88 } | 86 } |
89 if (m_rtUpButton.Contains(fx, fy)) | 87 if (m_rtUpButton.Contains(fx, fy)) |
90 return FWL_WidgetHit::UpButton; | 88 return FWL_WidgetHit::UpButton; |
91 if (m_rtDnButton.Contains(fx, fy)) | 89 if (m_rtDnButton.Contains(fx, fy)) |
92 return FWL_WidgetHit::DownButton; | 90 return FWL_WidgetHit::DownButton; |
93 return FWL_WidgetHit::Unknown; | 91 return FWL_WidgetHit::Unknown; |
94 } | 92 } |
95 | 93 |
96 FWL_Error IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, | 94 void IFWL_SpinButton::DrawWidget(CFX_Graphics* pGraphics, |
97 const CFX_Matrix* pMatrix) { | 95 const CFX_Matrix* pMatrix) { |
98 if (!pGraphics) | 96 if (!pGraphics) |
99 return FWL_Error::Indefinite; | 97 return; |
100 | 98 |
101 CFX_RectF rtClip(m_rtClient); | 99 CFX_RectF rtClip(m_rtClient); |
102 if (pMatrix) | 100 if (pMatrix) |
103 pMatrix->TransformRect(rtClip); | 101 pMatrix->TransformRect(rtClip); |
104 | 102 |
105 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); | 103 IFWL_ThemeProvider* pTheme = GetAvailableTheme(); |
106 if (HasBorder()) | 104 if (HasBorder()) |
107 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); | 105 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); |
108 if (HasEdge()) | 106 if (HasEdge()) |
109 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 107 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
110 | 108 |
111 DrawUpButton(pGraphics, pTheme, pMatrix); | 109 DrawUpButton(pGraphics, pTheme, pMatrix); |
112 DrawDownButton(pGraphics, pTheme, pMatrix); | 110 DrawDownButton(pGraphics, pTheme, pMatrix); |
113 return FWL_Error::Succeeded; | |
114 } | 111 } |
115 | 112 |
116 FWL_Error IFWL_SpinButton::EnableButton(bool bEnable, bool bUp) { | 113 FWL_Error IFWL_SpinButton::EnableButton(bool bEnable, bool bUp) { |
117 if (bUp) | 114 if (bUp) |
118 m_dwUpState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; | 115 m_dwUpState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; |
119 else | 116 else |
120 m_dwDnState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; | 117 m_dwDnState = bEnable ? CFWL_PartState_Normal : CFWL_PartState_Disabled; |
121 | 118 |
122 return FWL_Error::Succeeded; | 119 return FWL_Error::Succeeded; |
123 } | 120 } |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
380 IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget); | 377 IFWL_SpinButton* pButton = static_cast<IFWL_SpinButton*>(m_pWidget); |
381 | 378 |
382 if (!pButton->m_pTimerInfo) | 379 if (!pButton->m_pTimerInfo) |
383 return; | 380 return; |
384 | 381 |
385 CFWL_EvtSpbClick wmPosChanged; | 382 CFWL_EvtSpbClick wmPosChanged; |
386 wmPosChanged.m_pSrcTarget = pButton; | 383 wmPosChanged.m_pSrcTarget = pButton; |
387 wmPosChanged.m_bUp = pButton->m_iButtonIndex == 0; | 384 wmPosChanged.m_bUp = pButton->m_iButtonIndex == 0; |
388 pButton->DispatchEvent(&wmPosChanged); | 385 pButton->DispatchEvent(&wmPosChanged); |
389 } | 386 } |
OLD | NEW |