• 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/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_SystemHandler::PerWindowData> pAttachedData)14 CPWL_PushButton::CPWL_PushButton(
15     const CreateParams& cp,
16     std::unique_ptr<IPWL_SystemHandler::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_SystemHandler::PerWindowData> pAttachedData)26 CPWL_CheckBox::CPWL_CheckBox(
27     const CreateParams& cp,
28     std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
29     : CPWL_Button(cp, std::move(pAttachedData)) {}
30 
31 CPWL_CheckBox::~CPWL_CheckBox() = default;
32 
OnLButtonUp(const CFX_PointF & point,uint32_t nFlag)33 bool CPWL_CheckBox::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
34   if (IsReadOnly())
35     return false;
36 
37   SetCheck(!IsChecked());
38   return true;
39 }
40 
OnChar(uint16_t nChar,uint32_t nFlag)41 bool CPWL_CheckBox::OnChar(uint16_t nChar, uint32_t nFlag) {
42   SetCheck(!IsChecked());
43   return true;
44 }
45 
CPWL_RadioButton(const CreateParams & cp,std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)46 CPWL_RadioButton::CPWL_RadioButton(
47     const CreateParams& cp,
48     std::unique_ptr<IPWL_SystemHandler::PerWindowData> pAttachedData)
49     : CPWL_Button(cp, std::move(pAttachedData)) {}
50 
51 CPWL_RadioButton::~CPWL_RadioButton() = default;
52 
OnLButtonUp(const CFX_PointF & point,uint32_t nFlag)53 bool CPWL_RadioButton::OnLButtonUp(const CFX_PointF& point, uint32_t nFlag) {
54   if (IsReadOnly())
55     return false;
56 
57   SetCheck(true);
58   return true;
59 }
60 
OnChar(uint16_t nChar,uint32_t nFlag)61 bool CPWL_RadioButton::OnChar(uint16_t nChar, uint32_t nFlag) {
62   SetCheck(true);
63   return true;
64 }
65