xref: /aosp_15_r20/external/pdfium/fpdfsdk/pwl/cpwl_special_button.cpp (revision 3ac0a46f773bac49fa9476ec2b1cf3f8da5ec3a4)
1 // Copyright 2014 The PDFium Authors
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/pwl/cpwl_special_button.h"
8 
9 #include <utility>
10 
11 #include "fpdfsdk/pwl/cpwl_button.h"
12 #include "fpdfsdk/pwl/cpwl_wnd.h"
13 
CPWL_PushButton(const CreateParams & cp,std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)14 CPWL_PushButton::CPWL_PushButton(
15     const CreateParams& cp,
16     std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)
17     : CPWL_Button(cp, std::move(pAttachedData)) {}
18 
19 CPWL_PushButton::~CPWL_PushButton() = default;
20 
GetFocusRect() const21 CFX_FloatRect CPWL_PushButton::GetFocusRect() const {
22   return GetWindowRect().GetDeflated(static_cast<float>(GetBorderWidth()),
23                                      static_cast<float>(GetBorderWidth()));
24 }
25 
CPWL_CheckBox(const CreateParams & cp,std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)26 CPWL_CheckBox::CPWL_CheckBox(
27     const CreateParams& cp,
28     std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)
29     : CPWL_Button(cp, std::move(pAttachedData)) {}
30 
31 CPWL_CheckBox::~CPWL_CheckBox() = default;
32 
OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,const CFX_PointF & point)33 bool CPWL_CheckBox::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
34                                 const CFX_PointF& point) {
35   if (IsReadOnly())
36     return false;
37 
38   SetCheck(!IsChecked());
39   return true;
40 }
41 
OnChar(uint16_t nChar,Mask<FWL_EVENTFLAG> nFlag)42 bool CPWL_CheckBox::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
43   if (IsReadOnly())
44     return false;
45 
46   SetCheck(!IsChecked());
47   return true;
48 }
49 
CPWL_RadioButton(const CreateParams & cp,std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)50 CPWL_RadioButton::CPWL_RadioButton(
51     const CreateParams& cp,
52     std::unique_ptr<IPWL_FillerNotify::PerWindowData> pAttachedData)
53     : CPWL_Button(cp, std::move(pAttachedData)) {}
54 
55 CPWL_RadioButton::~CPWL_RadioButton() = default;
56 
OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,const CFX_PointF & point)57 bool CPWL_RadioButton::OnLButtonUp(Mask<FWL_EVENTFLAG> nFlag,
58                                    const CFX_PointF& point) {
59   if (IsReadOnly())
60     return false;
61 
62   SetCheck(true);
63   return true;
64 }
65 
OnChar(uint16_t nChar,Mask<FWL_EVENTFLAG> nFlag)66 bool CPWL_RadioButton::OnChar(uint16_t nChar, Mask<FWL_EVENTFLAG> nFlag) {
67   if (IsReadOnly())
68     return false;
69 
70   SetCheck(true);
71   return true;
72 }
73