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 "fpdfsdk/include/pdfwindow/PDFWindow.h" | |
8 #include "fpdfsdk/include/pdfwindow/PWL_Button.h" | 7 #include "fpdfsdk/include/pdfwindow/PWL_Button.h" |
9 #include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h" | 8 #include "fpdfsdk/include/pdfwindow/PWL_SpecialButton.h" |
10 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" | 9 #include "fpdfsdk/include/pdfwindow/PWL_Utils.h" |
11 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" | 10 #include "fpdfsdk/include/pdfwindow/PWL_Wnd.h" |
12 | 11 |
13 /* --------------------------- CPWL_PushButton ---------------------------- */ | |
14 | |
15 CPWL_PushButton::CPWL_PushButton() {} | 12 CPWL_PushButton::CPWL_PushButton() {} |
16 | 13 |
17 CPWL_PushButton::~CPWL_PushButton() {} | 14 CPWL_PushButton::~CPWL_PushButton() {} |
18 | 15 |
19 CFX_ByteString CPWL_PushButton::GetClassName() const { | 16 CFX_ByteString CPWL_PushButton::GetClassName() const { |
20 return "CPWL_PushButton"; | 17 return "CPWL_PushButton"; |
21 } | 18 } |
22 | 19 |
23 CPDF_Rect CPWL_PushButton::GetFocusRect() const { | 20 CPDF_Rect CPWL_PushButton::GetFocusRect() const { |
24 return CPWL_Utils::DeflateRect(GetWindowRect(), (FX_FLOAT)GetBorderWidth()); | 21 return CPWL_Utils::DeflateRect(GetWindowRect(), (FX_FLOAT)GetBorderWidth()); |
25 } | 22 } |
26 | 23 |
27 /* --------------------------- CPWL_CheckBox ---------------------------- */ | |
28 | |
29 CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE) {} | 24 CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE) {} |
30 | 25 |
31 CPWL_CheckBox::~CPWL_CheckBox() {} | 26 CPWL_CheckBox::~CPWL_CheckBox() {} |
32 | 27 |
33 CFX_ByteString CPWL_CheckBox::GetClassName() const { | 28 CFX_ByteString CPWL_CheckBox::GetClassName() const { |
34 return "CPWL_CheckBox"; | 29 return "CPWL_CheckBox"; |
35 } | 30 } |
36 | 31 |
37 void CPWL_CheckBox::SetCheck(FX_BOOL bCheck) { | 32 void CPWL_CheckBox::SetCheck(FX_BOOL bCheck) { |
38 m_bChecked = bCheck; | 33 m_bChecked = bCheck; |
39 } | 34 } |
40 | 35 |
41 FX_BOOL CPWL_CheckBox::IsChecked() const { | 36 FX_BOOL CPWL_CheckBox::IsChecked() const { |
42 return m_bChecked; | 37 return m_bChecked; |
43 } | 38 } |
44 | 39 |
45 FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { | 40 FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
46 if (IsReadOnly()) | 41 if (IsReadOnly()) |
47 return FALSE; | 42 return FALSE; |
48 | 43 |
49 SetCheck(!IsChecked()); | 44 SetCheck(!IsChecked()); |
50 return TRUE; | 45 return TRUE; |
51 } | 46 } |
52 | 47 |
53 FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { | 48 FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar, FX_DWORD nFlag) { |
54 SetCheck(!IsChecked()); | 49 SetCheck(!IsChecked()); |
55 return TRUE; | 50 return TRUE; |
56 } | 51 } |
57 | 52 |
58 /* --------------------------- CPWL_RadioButton ---------------------------- */ | |
59 | |
60 CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(FALSE) {} | 53 CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(FALSE) {} |
61 | 54 |
62 CPWL_RadioButton::~CPWL_RadioButton() {} | 55 CPWL_RadioButton::~CPWL_RadioButton() {} |
63 | 56 |
64 CFX_ByteString CPWL_RadioButton::GetClassName() const { | 57 CFX_ByteString CPWL_RadioButton::GetClassName() const { |
65 return "CPWL_RadioButton"; | 58 return "CPWL_RadioButton"; |
66 } | 59 } |
67 | 60 |
68 FX_BOOL CPWL_RadioButton::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { | 61 FX_BOOL CPWL_RadioButton::OnLButtonUp(const CPDF_Point& point, FX_DWORD nFlag) { |
69 if (IsReadOnly()) | 62 if (IsReadOnly()) |
70 return FALSE; | 63 return FALSE; |
71 | 64 |
72 SetCheck(TRUE); | 65 SetCheck(TRUE); |
73 return TRUE; | 66 return TRUE; |
74 } | 67 } |
75 | 68 |
76 void CPWL_RadioButton::SetCheck(FX_BOOL bCheck) { | 69 void CPWL_RadioButton::SetCheck(FX_BOOL bCheck) { |
77 m_bChecked = bCheck; | 70 m_bChecked = bCheck; |
78 } | 71 } |
79 | 72 |
80 FX_BOOL CPWL_RadioButton::IsChecked() const { | 73 FX_BOOL CPWL_RadioButton::IsChecked() const { |
81 return m_bChecked; | 74 return m_bChecked; |
82 } | 75 } |
83 | 76 |
84 FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar, FX_DWORD nFlag) { | 77 FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar, FX_DWORD nFlag) { |
85 SetCheck(TRUE); | 78 SetCheck(TRUE); |
86 return TRUE; | 79 return TRUE; |
87 } | 80 } |
OLD | NEW |