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_spinbutton.h" | 7 #include "xfa/fwl/core/cfwl_spinbutton.h" |
8 | 8 |
9 #include <memory> | 9 #include <memory> |
10 #include <utility> | 10 #include <utility> |
11 | 11 |
12 #include "third_party/base/ptr_util.h" | 12 #include "third_party/base/ptr_util.h" |
13 #include "xfa/fwl/core/cfwl_event.h" | 13 #include "xfa/fwl/core/cfwl_event.h" |
14 #include "xfa/fwl/core/cfwl_msgkey.h" | 14 #include "xfa/fwl/core/cfwl_msgkey.h" |
15 #include "xfa/fwl/core/cfwl_msgmouse.h" | 15 #include "xfa/fwl/core/cfwl_msgmouse.h" |
16 #include "xfa/fwl/core/cfwl_notedriver.h" | 16 #include "xfa/fwl/core/cfwl_notedriver.h" |
17 #include "xfa/fwl/core/cfwl_themebackground.h" | 17 #include "xfa/fwl/core/cfwl_themebackground.h" |
18 #include "xfa/fwl/core/cfwl_timerinfo.h" | 18 #include "xfa/fwl/core/cfwl_timerinfo.h" |
19 #include "xfa/fwl/core/cfwl_widgetproperties.h" | 19 #include "xfa/fwl/core/cfwl_widgetproperties.h" |
20 #include "xfa/fwl/core/ifwl_themeprovider.h" | 20 #include "xfa/fwl/core/ifwl_themeprovider.h" |
21 | 21 |
22 namespace { | 22 namespace { |
23 | |
24 const int kMinWidth = 18; | |
25 const int kMinHeight = 32; | |
26 const int kElapseTime = 200; | 23 const int kElapseTime = 200; |
27 | 24 |
28 } // namespace | 25 } // namespace |
29 | 26 |
30 CFWL_SpinButton::CFWL_SpinButton( | 27 CFWL_SpinButton::CFWL_SpinButton( |
31 const CFWL_App* app, | 28 const CFWL_App* app, |
32 std::unique_ptr<CFWL_WidgetProperties> properties) | 29 std::unique_ptr<CFWL_WidgetProperties> properties) |
33 : CFWL_Widget(app, std::move(properties), nullptr), | 30 : CFWL_Widget(app, std::move(properties), nullptr), |
34 m_dwUpState(CFWL_PartState_Normal), | 31 m_dwUpState(CFWL_PartState_Normal), |
35 m_dwDnState(CFWL_PartState_Normal), | 32 m_dwDnState(CFWL_PartState_Normal), |
36 m_iButtonIndex(0), | 33 m_iButtonIndex(0), |
37 m_bLButtonDwn(false), | 34 m_bLButtonDwn(false), |
38 m_pTimerInfo(nullptr), | 35 m_pTimerInfo(nullptr), |
39 m_Timer(this) { | 36 m_Timer(this) { |
40 m_rtClient.Reset(); | 37 m_rtClient.Reset(); |
41 m_rtUpButton.Reset(); | 38 m_rtUpButton.Reset(); |
42 m_rtDnButton.Reset(); | 39 m_rtDnButton.Reset(); |
43 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; | 40 m_pProperties->m_dwStyleExes |= FWL_STYLEEXE_SPB_Vert; |
44 } | 41 } |
45 | 42 |
46 CFWL_SpinButton::~CFWL_SpinButton() {} | 43 CFWL_SpinButton::~CFWL_SpinButton() {} |
47 | 44 |
48 FWL_Type CFWL_SpinButton::GetClassID() const { | 45 FWL_Type CFWL_SpinButton::GetClassID() const { |
49 return FWL_Type::SpinButton; | 46 return FWL_Type::SpinButton; |
50 } | 47 } |
51 | 48 |
52 void CFWL_SpinButton::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { | |
53 if (!bAutoSize) { | |
54 rect = m_pProperties->m_rtWidget; | |
55 return; | |
56 } | |
57 | |
58 rect.Set(0, 0, kMinWidth, kMinHeight); | |
59 InflateWidgetRect(rect); | |
60 } | |
61 | |
62 void CFWL_SpinButton::Update() { | 49 void CFWL_SpinButton::Update() { |
63 if (IsLocked()) | 50 if (IsLocked()) |
64 return; | 51 return; |
65 | 52 |
66 GetClientRect(m_rtClient); | 53 GetClientRect(m_rtClient); |
67 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { | 54 if (m_pProperties->m_dwStyleExes & FWL_STYLEEXE_SPB_Vert) { |
68 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, | 55 m_rtUpButton.Set(m_rtClient.top, m_rtClient.left, m_rtClient.width, |
69 m_rtClient.height / 2); | 56 m_rtClient.height / 2); |
70 m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, | 57 m_rtDnButton.Set(m_rtClient.left, m_rtClient.top + m_rtClient.height / 2, |
71 m_rtClient.width, m_rtClient.height / 2); | 58 m_rtClient.width, m_rtClient.height / 2); |
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
367 | 354 |
368 void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { | 355 void CFWL_SpinButton::Timer::Run(CFWL_TimerInfo* pTimerInfo) { |
369 CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget); | 356 CFWL_SpinButton* pButton = static_cast<CFWL_SpinButton*>(m_pWidget); |
370 | 357 |
371 if (!pButton->m_pTimerInfo) | 358 if (!pButton->m_pTimerInfo) |
372 return; | 359 return; |
373 | 360 |
374 CFWL_Event wmPosChanged(CFWL_Event::Type::Click, pButton); | 361 CFWL_Event wmPosChanged(CFWL_Event::Type::Click, pButton); |
375 pButton->DispatchEvent(&wmPosChanged); | 362 pButton->DispatchEvent(&wmPosChanged); |
376 } | 363 } |
OLD | NEW |