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_scrollbar.h" | 7 #include "xfa/fwl/core/ifwl_scrollbar.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 20 matching lines...) Expand all Loading... |
31 m_fTrackPos(0), | 31 m_fTrackPos(0), |
32 m_iMinButtonState(CFWL_PartState_Normal), | 32 m_iMinButtonState(CFWL_PartState_Normal), |
33 m_iMaxButtonState(CFWL_PartState_Normal), | 33 m_iMaxButtonState(CFWL_PartState_Normal), |
34 m_iThumbButtonState(CFWL_PartState_Normal), | 34 m_iThumbButtonState(CFWL_PartState_Normal), |
35 m_iMinTrackState(CFWL_PartState_Normal), | 35 m_iMinTrackState(CFWL_PartState_Normal), |
36 m_iMaxTrackState(CFWL_PartState_Normal), | 36 m_iMaxTrackState(CFWL_PartState_Normal), |
37 m_fLastTrackPos(0), | 37 m_fLastTrackPos(0), |
38 m_cpTrackPointX(0), | 38 m_cpTrackPointX(0), |
39 m_cpTrackPointY(0), | 39 m_cpTrackPointY(0), |
40 m_iMouseWheel(0), | 40 m_iMouseWheel(0), |
41 m_bTrackMouseLeave(false), | |
42 m_bMouseHover(false), | |
43 m_bMouseDown(false), | 41 m_bMouseDown(false), |
44 m_bRepaintThumb(false), | |
45 m_fButtonLen(0), | 42 m_fButtonLen(0), |
46 m_bMinSize(false), | 43 m_bMinSize(false), |
47 m_bCustomLayout(false), | 44 m_bCustomLayout(false), |
48 m_fMinThumb(FWL_SCROLLBAR_MinThumb), | 45 m_fMinThumb(FWL_SCROLLBAR_MinThumb), |
49 m_Timer(this) { | 46 m_Timer(this) { |
50 m_rtClient.Reset(); | 47 m_rtClient.Reset(); |
51 m_rtThumb.Reset(); | 48 m_rtThumb.Reset(); |
52 m_rtMinBtn.Reset(); | 49 m_rtMinBtn.Reset(); |
53 m_rtMaxBtn.Reset(); | 50 m_rtMaxBtn.Reset(); |
54 m_rtMinTrack.Reset(); | 51 m_rtMinTrack.Reset(); |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 if (HasEdge()) { | 99 if (HasEdge()) { |
103 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); | 100 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); |
104 } | 101 } |
105 DrawTrack(pGraphics, pTheme, true, pMatrix); | 102 DrawTrack(pGraphics, pTheme, true, pMatrix); |
106 DrawTrack(pGraphics, pTheme, false, pMatrix); | 103 DrawTrack(pGraphics, pTheme, false, pMatrix); |
107 DrawArrowBtn(pGraphics, pTheme, true, pMatrix); | 104 DrawArrowBtn(pGraphics, pTheme, true, pMatrix); |
108 DrawArrowBtn(pGraphics, pTheme, false, pMatrix); | 105 DrawArrowBtn(pGraphics, pTheme, false, pMatrix); |
109 DrawThumb(pGraphics, pTheme, pMatrix); | 106 DrawThumb(pGraphics, pTheme, pMatrix); |
110 } | 107 } |
111 | 108 |
112 inline bool IFWL_ScrollBar::IsVertical() { | 109 void IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { |
113 return m_pProperties->m_dwStyleExes & FWL_STYLEEXT_SCB_Vert; | |
114 } | |
115 | |
116 FWL_Error IFWL_ScrollBar::GetRange(FX_FLOAT& fMin, FX_FLOAT& fMax) { | |
117 fMin = m_fRangeMin; | |
118 fMax = m_fRangeMax; | |
119 return FWL_Error::Succeeded; | |
120 } | |
121 | |
122 FWL_Error IFWL_ScrollBar::SetRange(FX_FLOAT fMin, FX_FLOAT fMax) { | |
123 m_fRangeMin = fMin; | |
124 m_fRangeMax = fMax; | |
125 return FWL_Error::Succeeded; | |
126 } | |
127 | |
128 FX_FLOAT IFWL_ScrollBar::GetPageSize() { | |
129 return m_fPageSize; | |
130 } | |
131 | |
132 FWL_Error IFWL_ScrollBar::SetPageSize(FX_FLOAT fPageSize) { | |
133 m_fPageSize = fPageSize; | |
134 return FWL_Error::Succeeded; | |
135 } | |
136 | |
137 FX_FLOAT IFWL_ScrollBar::GetStepSize() { | |
138 return m_fStepSize; | |
139 } | |
140 | |
141 FWL_Error IFWL_ScrollBar::SetStepSize(FX_FLOAT fStepSize) { | |
142 m_fStepSize = fStepSize; | |
143 return FWL_Error::Succeeded; | |
144 } | |
145 | |
146 FX_FLOAT IFWL_ScrollBar::GetPos() { | |
147 return m_fPos; | |
148 } | |
149 | |
150 FWL_Error IFWL_ScrollBar::SetPos(FX_FLOAT fPos) { | |
151 m_fPos = fPos; | |
152 return FWL_Error::Succeeded; | |
153 } | |
154 | |
155 FX_FLOAT IFWL_ScrollBar::GetTrackPos() { | |
156 return m_fTrackPos; | |
157 } | |
158 | |
159 FWL_Error IFWL_ScrollBar::SetTrackPos(FX_FLOAT fTrackPos) { | |
160 m_fTrackPos = fTrackPos; | 110 m_fTrackPos = fTrackPos; |
161 CalcThumbButtonRect(m_rtThumb); | 111 CalcThumbButtonRect(m_rtThumb); |
162 CalcMinTrackRect(m_rtMinTrack); | 112 CalcMinTrackRect(m_rtMinTrack); |
163 CalcMaxTrackRect(m_rtMaxTrack); | 113 CalcMaxTrackRect(m_rtMaxTrack); |
164 return FWL_Error::Succeeded; | |
165 } | 114 } |
166 | 115 |
167 bool IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { | 116 bool IFWL_ScrollBar::DoScroll(uint32_t dwCode, FX_FLOAT fPos) { |
168 switch (dwCode) { | 117 switch (dwCode) { |
169 case FWL_SCBCODE_Min: | 118 case FWL_SCBCODE_Min: |
170 case FWL_SCBCODE_Max: | 119 case FWL_SCBCODE_Max: |
171 case FWL_SCBCODE_PageBackward: | 120 case FWL_SCBCODE_PageBackward: |
172 case FWL_SCBCODE_PageForward: | 121 case FWL_SCBCODE_PageForward: |
173 case FWL_SCBCODE_StepBackward: | 122 case FWL_SCBCODE_StepBackward: |
174 break; | |
175 case FWL_SCBCODE_StepForward: | 123 case FWL_SCBCODE_StepForward: |
176 break; | |
177 case FWL_SCBCODE_Pos: | 124 case FWL_SCBCODE_Pos: |
178 case FWL_SCBCODE_TrackPos: | 125 case FWL_SCBCODE_TrackPos: |
179 case FWL_SCBCODE_EndScroll: | 126 case FWL_SCBCODE_EndScroll: |
180 break; | 127 break; |
181 default: { return false; } | 128 default: |
| 129 return false; |
182 } | 130 } |
183 return OnScroll(dwCode, fPos); | 131 return OnScroll(dwCode, fPos); |
184 } | 132 } |
185 | 133 |
186 FWL_Error IFWL_ScrollBar::SetOuter(IFWL_Widget* pOuter) { | |
187 m_pOuter = pOuter; | |
188 return FWL_Error::Succeeded; | |
189 } | |
190 | |
191 void IFWL_ScrollBar::DrawTrack(CFX_Graphics* pGraphics, | 134 void IFWL_ScrollBar::DrawTrack(CFX_Graphics* pGraphics, |
192 IFWL_ThemeProvider* pTheme, | 135 IFWL_ThemeProvider* pTheme, |
193 bool bLower, | 136 bool bLower, |
194 const CFX_Matrix* pMatrix) { | 137 const CFX_Matrix* pMatrix) { |
195 CFWL_ThemeBackground param; | 138 CFWL_ThemeBackground param; |
196 param.m_pWidget = this; | 139 param.m_pWidget = this; |
197 param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack; | 140 param.m_iPart = bLower ? CFWL_Part::LowerTrack : CFWL_Part::UpperTrack; |
198 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) | 141 param.m_dwStates = (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) |
199 ? CFWL_PartState_Disabled | 142 ? CFWL_PartState_Disabled |
200 : (bLower ? m_iMinTrackState : m_iMaxTrackState); | 143 : (bLower ? m_iMinTrackState : m_iMaxTrackState); |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
733 | 676 |
734 void IFWL_ScrollBar::Timer::Run(IFWL_TimerInfo* pTimerInfo) { | 677 void IFWL_ScrollBar::Timer::Run(IFWL_TimerInfo* pTimerInfo) { |
735 IFWL_ScrollBar* pButton = static_cast<IFWL_ScrollBar*>(m_pWidget); | 678 IFWL_ScrollBar* pButton = static_cast<IFWL_ScrollBar*>(m_pWidget); |
736 | 679 |
737 if (pButton->m_pTimerInfo) | 680 if (pButton->m_pTimerInfo) |
738 pButton->m_pTimerInfo->StopTimer(); | 681 pButton->m_pTimerInfo->StopTimer(); |
739 | 682 |
740 if (!pButton->SendEvent()) | 683 if (!pButton->SendEvent()) |
741 pButton->m_pTimerInfo = StartTimer(0, true); | 684 pButton->m_pTimerInfo = StartTimer(0, true); |
742 } | 685 } |
OLD | NEW |