7#include "xfa/fxfa/cxfa_ffcheckbutton.h"
9#include "third_party/base/check.h"
10#include "v8/include/cppgc/visitor.h"
11#include "xfa/fwl/cfwl_checkbox.h"
12#include "xfa/fwl/cfwl_messagemouse.h"
13#include "xfa/fwl/cfwl_notedriver.h"
14#include "xfa/fwl/cfwl_widgetmgr.h"
15#include "xfa/fxfa/cxfa_ffapp.h"
16#include "xfa/fxfa/cxfa_ffdoc.h"
17#include "xfa/fxfa/cxfa_ffdocview.h"
18#include "xfa/fxfa/cxfa_ffexclgroup.h"
19#include "xfa/fxfa/cxfa_fffield.h"
20#include "xfa/fxfa/cxfa_ffpageview.h"
21#include "xfa/fxfa/cxfa_ffwidget.h"
22#include "xfa/fxfa/parser/cxfa_border.h"
23#include "xfa/fxfa/parser/cxfa_caption.h"
24#include "xfa/fxfa/parser/cxfa_checkbutton.h"
25#include "xfa/fxfa/parser/cxfa_para.h"
27CXFA_FFCheckButton::CXFA_FFCheckButton(
CXFA_Node* pNode,
28 CXFA_CheckButton* button)
33void CXFA_FFCheckButton::
Trace(
cppgc::Visitor* visitor)
const {
34 CXFA_FFField::Trace(visitor);
35 visitor->Trace(m_pOldDelegate);
36 visitor->Trace(button_);
42 CFWL_CheckBox* pCheckBox = cppgc::MakeGarbageCollected<CFWL_CheckBox>(
43 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp());
47 CFWL_NoteDriver* pNoteDriver = pCheckBox
->GetFWLApp()->GetNoteDriver();
49 m_pOldDelegate = pCheckBox->GetDelegate();
51 if (m_pNode->IsRadioButton())
57 SetFWLCheckState(m_pNode->GetCheckState());
64 auto* pCheckBox =
static_cast<CFWL_CheckBox*>(GetNormalWidget());
68 pCheckBox->SetBoxSize(m_pNode->GetCheckButtonSize());
70 switch (button_->GetMark()) {
71 case XFA_AttributeValue::Check:
74 case XFA_AttributeValue::Circle:
77 case XFA_AttributeValue::Cross:
79 case XFA_AttributeValue::Diamond:
82 case XFA_AttributeValue::Square:
85 case XFA_AttributeValue::Star:
89 if (button_->IsRound())
93 if (button_->IsAllowNeutral())
96 pCheckBox->ModifyStyleExts(
103 float fCheckSize = m_pNode->GetCheckButtonSize();
104 CXFA_Margin* margin = m_pNode->GetMarginIfExists();
109 float fCapReserve = 0;
110 CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
115 if (fCapReserve <= 0) {
118 fCapReserve = rtWidget
.height - fCheckSize;
120 fCapReserve = rtWidget
.width - fCheckSize;
127 CXFA_Para* para = m_pNode->GetParaIfExists();
135 switch (iCapPlacement) {
138 CapLeftRightPlacement(captionMargin);
153 CapLeftRightPlacement(captionMargin);
183 AddUIMargin(iCapPlacement);
185 CXFA_Border* borderUI = m_pNode->GetUIBorder();
194 if (GetNormalWidget())
195 GetNormalWidget()->Update();
200void CXFA_FFCheckButton::CapLeftRightPlacement(
201 const CXFA_Margin* captionMargin) {
212 CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
215 float fLeftAddRight = rtUIMargin
.left + rtUIMargin
.width;
216 float fTopAddBottom = rtUIMargin
.top + rtUIMargin
.height;
245 DrawBorderWithFlag(pGS, m_pNode->GetUIBorder(), m_UIRect, mtRotate,
248 DrawHighlight(pGS, mtRotate, highlight,
249 button_->IsRound() ? kRoundShape : kSquareShape);
252 GetApp()->GetFWLWidgetMgr()->OnDrawWidget(GetNormalWidget(), pGS, mt);
256 const CFX_PointF& point) {
261 CFWL_MessageMouse msg(GetNormalWidget(),
269 uint32_t dwState = GetNormalWidget()->GetStates();
278 m_pNode->SetCheckState(FWLState2XFAState());
284 return m_pNode->GetCheckState() != eCheckState;
297 if (!GetNormalWidget())
300 SetFWLCheckState(m_pNode->GetCheckState());
301 GetNormalWidget()->Update();
306 m_pOldDelegate->OnProcessMessage(pMessage);
314 eParam.m_wsPrevText = m_pNode->GetValue(XFA_ValuePicture::kRaw);
315 CXFA_Node* exclNode = m_pNode->GetExclGroupIfExists();
318 m_pDocView->AddValidateNode(exclNode);
319 m_pDocView->AddCalculateNode(exclNode);
323 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Change,
326 SetFWLCheckState(m_pNode->GetCheckState());
332 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Click, &eParam);
338 m_pOldDelegate->OnProcessEvent(pEvent);
343 m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
347 return FormFieldType::kXFA_CheckBox;
#define FWL_STYLEEXT_CKB_SignShapeMask
#define FWL_STYLEEXT_CKB_SignShapeSquare
#define FWL_STATE_CKB_Neutral
#define FWL_STYLEEXT_CKB_SignShapeCheck
#define FWL_STYLEEXT_CKB_SignShapeStar
#define FWL_STATE_CKB_Checked
#define FWL_STYLEEXT_CKB_SignShapeCircle
#define FWL_STYLEEXT_CKB_3State
#define FWL_STYLEEXT_CKB_RadioButton
#define FWL_STYLEEXT_CKB_SignShapeDiamond
#define FWL_STYLEEXT_CKB_SignShapeCross
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
void Concat(const CFX_Matrix &right)
CFX_RectF & operator=(const CFX_RectF &other)=default
CXFA_Margin * GetMarginIfExists()
XFA_AttributeValue GetPlacementType()
CXFA_EventParam(XFA_EVENTTYPE type)
CXFA_FFField(CXFA_Node *pNode)
CFX_PointF FWLToClient(const CFX_PointF &point)
bool ProcessCommittedData()
virtual void SetFWLRect()
bool LoadWidget() override
void SetNormalWidget(CFWL_Widget *widget)
void OnProcessEvent(CFWL_Event *pEvent) override
void RenderCaption(CFGAS_GEGraphics *pGS, const CFX_Matrix &pMatrix)
void SendMessageToFWLWidget(CFWL_Message *pMessage)
XFA_EventError ProcessEvent(CXFA_FFDocView *pDocView, XFA_AttributeValue iActivity, CXFA_EventParam *pEventParam)
CXFA_Margin * GetMarginIfExists() const
XFA_AttributeValue GetHorizontalAlign()
XFA_AttributeValue GetVerticalAlign()