• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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/pdfwindow/PWL_Button.h"
8 #include "fpdfsdk/pdfwindow/PWL_SpecialButton.h"
9 #include "fpdfsdk/pdfwindow/PWL_Utils.h"
10 #include "fpdfsdk/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 CFX_FloatRect 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(bool bCheck)32 void CPWL_CheckBox::SetCheck(bool bCheck) {
33   m_bChecked = bCheck;
34 }
35 
IsChecked() const36 bool CPWL_CheckBox::IsChecked() const {
37   return m_bChecked;
38 }
39 
OnLButtonUp(const CFX_PointF & point,uint32_t nFlag)40 bool CPWL_CheckBox::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
41   if (IsReadOnly())
42     return false;
43 
44   SetCheck(!IsChecked());
45   return true;
46 }
47 
OnChar(uint16_t nChar,uint32_t nFlag)48 bool CPWL_CheckBox::OnChar(uint16_t nChar, uint32_t 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 CFX_PointF & point,uint32_t nFlag)61 bool CPWL_RadioButton::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
62   if (IsReadOnly())
63     return false;
64 
65   SetCheck(true);
66   return true;
67 }
68 
SetCheck(bool bCheck)69 void CPWL_RadioButton::SetCheck(bool bCheck) {
70   m_bChecked = bCheck;
71 }
72 
IsChecked() const73 bool CPWL_RadioButton::IsChecked() const {
74   return m_bChecked;
75 }
76 
OnChar(uint16_t nChar,uint32_t nFlag)77 bool CPWL_RadioButton::OnChar(uint16_t nChar, uint32_t nFlag) {
78   SetCheck(true);
79   return true;
80 }
81