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