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