Initial commit.
[pdfium.git] / fpdfsdk / src / pdfwindow / PWL_SpecialButton.cpp
1 // Copyright 2014 PDFium Authors. All rights reserved.\r
2 // Use of this source code is governed by a BSD-style license that can be\r
3 // found in the LICENSE file.\r
4  \r
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com\r
6 \r
7 #include "../../include/pdfwindow/PDFWindow.h"\r
8 #include "../../include/pdfwindow/PWL_Wnd.h"\r
9 #include "../../include/pdfwindow/PWL_Button.h"\r
10 #include "../../include/pdfwindow/PWL_SpecialButton.h"\r
11 #include "../../include/pdfwindow/PWL_Utils.h"\r
12 \r
13 /* --------------------------- CPWL_PushButton ---------------------------- */\r
14 \r
15 CPWL_PushButton::CPWL_PushButton()\r
16 {\r
17 }\r
18 \r
19 CPWL_PushButton::~CPWL_PushButton()\r
20 {\r
21 }\r
22 \r
23 CFX_ByteString CPWL_PushButton::GetClassName() const\r
24 {\r
25         return "CPWL_PushButton";\r
26 }\r
27 \r
28 CPDF_Rect CPWL_PushButton::GetFocusRect() const\r
29 {\r
30         return CPWL_Utils::DeflateRect(this->GetWindowRect(),(FX_FLOAT)GetBorderWidth());\r
31 }\r
32 \r
33 /* --------------------------- CPWL_CheckBox ---------------------------- */\r
34 \r
35 CPWL_CheckBox::CPWL_CheckBox() : m_bChecked(FALSE)\r
36 {\r
37 }\r
38 \r
39 CPWL_CheckBox::~CPWL_CheckBox()\r
40 {\r
41 }\r
42 \r
43 CFX_ByteString CPWL_CheckBox::GetClassName() const\r
44 {\r
45         return "CPWL_CheckBox";\r
46 }\r
47 \r
48 void CPWL_CheckBox::SetCheck(FX_BOOL bCheck)\r
49 {\r
50         m_bChecked = bCheck;\r
51 }\r
52 \r
53 FX_BOOL CPWL_CheckBox::IsChecked() const\r
54 {\r
55         return m_bChecked;\r
56 }\r
57 \r
58 FX_BOOL CPWL_CheckBox::OnLButtonUp(const CPDF_Point & point)\r
59 {\r
60         if (IsReadOnly()) return FALSE;\r
61 \r
62         SetCheck(!IsChecked());\r
63         return TRUE;\r
64 }\r
65 \r
66 FX_BOOL CPWL_CheckBox::OnChar(FX_WORD nChar)\r
67 {\r
68         SetCheck(!IsChecked());\r
69         return TRUE;\r
70 }\r
71 \r
72 /* --------------------------- CPWL_RadioButton ---------------------------- */\r
73 \r
74 CPWL_RadioButton::CPWL_RadioButton() : m_bChecked(FALSE)\r
75 {\r
76 }\r
77 \r
78 CPWL_RadioButton::~CPWL_RadioButton()\r
79 {\r
80 }\r
81 \r
82 CFX_ByteString CPWL_RadioButton::GetClassName() const\r
83 {\r
84         return "CPWL_RadioButton";\r
85 }\r
86 \r
87 FX_BOOL CPWL_RadioButton::OnLButtonUp(const CPDF_Point & point)\r
88 {\r
89         if (IsReadOnly()) return FALSE;\r
90 \r
91         SetCheck(TRUE);\r
92         return TRUE;\r
93 }\r
94 \r
95 void CPWL_RadioButton::SetCheck(FX_BOOL bCheck)\r
96 {\r
97         m_bChecked = bCheck;\r
98 }\r
99 \r
100 FX_BOOL CPWL_RadioButton::IsChecked() const\r
101 {\r
102         return m_bChecked;\r
103 }\r
104 \r
105 FX_BOOL CPWL_RadioButton::OnChar(FX_WORD nChar)\r
106 {\r
107         SetCheck(TRUE);\r
108         return TRUE;\r
109 }\r
110 \r