diff options
-rw-r--r-- | xfa/fxfa/cxfa_ffcheckbutton.cpp | 14 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffcheckbutton.h | 8 | ||||
-rw-r--r-- | xfa/fxfa/cxfa_ffnotify.cpp | 18 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_checkbutton.cpp | 8 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_checkbutton.h | 3 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.cpp | 15 | ||||
-rw-r--r-- | xfa/fxfa/parser/cxfa_node.h | 2 |
7 files changed, 37 insertions, 31 deletions
diff --git a/xfa/fxfa/cxfa_ffcheckbutton.cpp b/xfa/fxfa/cxfa_ffcheckbutton.cpp index 6902966470..57233a0f56 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.cpp +++ b/xfa/fxfa/cxfa_ffcheckbutton.cpp @@ -21,10 +21,12 @@ #include "xfa/fxfa/cxfa_ffwidget.h" #include "xfa/fxfa/parser/cxfa_border.h" #include "xfa/fxfa/parser/cxfa_caption.h" +#include "xfa/fxfa/parser/cxfa_checkbutton.h" #include "xfa/fxfa/parser/cxfa_para.h" -CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_Node* pNode) - : CXFA_FFField(pNode), m_pOldDelegate(nullptr) {} +CXFA_FFCheckButton::CXFA_FFCheckButton(CXFA_Node* pNode, + CXFA_CheckButton* button) + : CXFA_FFField(pNode), button_(button) {} CXFA_FFCheckButton::~CXFA_FFCheckButton() {} @@ -57,7 +59,7 @@ void CXFA_FFCheckButton::UpdateWidgetProperty() { pCheckBox->SetBoxSize(m_pNode->GetCheckButtonSize()); uint32_t dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCross; - switch (m_pNode->GetCheckButtonMark()) { + switch (button_->GetMark()) { case XFA_AttributeEnum::Check: dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCheck; break; @@ -76,7 +78,7 @@ void CXFA_FFCheckButton::UpdateWidgetProperty() { dwStyleEx = FWL_STYLEEXT_CKB_SignShapeStar; break; default: { - if (m_pNode->IsCheckButtonRound()) + if (button_->IsRound()) dwStyleEx = FWL_STYLEEXT_CKB_SignShapeCircle; } break; } @@ -235,9 +237,9 @@ void CXFA_FFCheckButton::RenderWidget(CXFA_Graphics* pGS, CXFA_FFWidget::RenderWidget(pGS, mtRotate, dwStatus); DrawBorderWithFlag(pGS, m_pNode->GetUIBorder(), m_rtUI, mtRotate, - m_pNode->IsCheckButtonRound()); + button_->IsRound()); RenderCaption(pGS, &mtRotate); - DrawHighlight(pGS, &mtRotate, dwStatus, m_pNode->IsCheckButtonRound()); + DrawHighlight(pGS, &mtRotate, dwStatus, button_->IsRound()); CFX_Matrix mt(1, 0, 0, 1, m_rtCheckBox.left, m_rtCheckBox.top); mt.Concat(mtRotate); GetApp()->GetFWLWidgetMgr()->OnDrawWidget(m_pNormalWidget.get(), pGS, mt); diff --git a/xfa/fxfa/cxfa_ffcheckbutton.h b/xfa/fxfa/cxfa_ffcheckbutton.h index 230695f85a..d1fb21c47d 100644 --- a/xfa/fxfa/cxfa_ffcheckbutton.h +++ b/xfa/fxfa/cxfa_ffcheckbutton.h @@ -7,13 +7,16 @@ #ifndef XFA_FXFA_CXFA_FFCHECKBUTTON_H_ #define XFA_FXFA_CXFA_FFCHECKBUTTON_H_ +#include "core/fxcrt/unowned_ptr.h" #include "xfa/fxfa/cxfa_fffield.h" #include "xfa/fxfa/cxfa_ffpageview.h" #include "xfa/fxfa/parser/cxfa_node.h" +class CXFA_CheckButton; + class CXFA_FFCheckButton : public CXFA_FFField { public: - explicit CXFA_FFCheckButton(CXFA_Node* pNode); + explicit CXFA_FFCheckButton(CXFA_Node* pNode, CXFA_CheckButton* button); ~CXFA_FFCheckButton() override; // CXFA_FFField @@ -41,8 +44,9 @@ class CXFA_FFCheckButton : public CXFA_FFField { void AddUIMargin(XFA_AttributeEnum iCapPlacement); XFA_CHECKSTATE FWLState2XFAState(); - IFWL_WidgetDelegate* m_pOldDelegate; + IFWL_WidgetDelegate* m_pOldDelegate = nullptr; CFX_RectF m_rtCheckBox; + UnownedPtr<CXFA_CheckButton> button_; }; #endif // XFA_FXFA_CXFA_FFCHECKBUTTON_H_ diff --git a/xfa/fxfa/cxfa_ffnotify.cpp b/xfa/fxfa/cxfa_ffnotify.cpp index a7cb91185b..a929e1a57c 100644 --- a/xfa/fxfa/cxfa_ffnotify.cpp +++ b/xfa/fxfa/cxfa_ffnotify.cpp @@ -37,6 +37,7 @@ #include "xfa/fxfa/cxfa_textprovider.h" #include "xfa/fxfa/parser/cxfa_barcode.h" #include "xfa/fxfa/parser/cxfa_binditems.h" +#include "xfa/fxfa/parser/cxfa_checkbutton.h" #include "xfa/fxfa/parser/cxfa_node.h" namespace { @@ -111,17 +112,22 @@ CXFA_ContentLayoutItem* CXFA_FFNotify::OnCreateContentLayoutItem( CXFA_FFWidget* pWidget = nullptr; switch (pNode->GetFFWidgetType()) { - case XFA_FFWidgetType::kBarcode: - ASSERT(pNode->GetUIChildNode()->GetElementType() == XFA_Element::Barcode); - pWidget = new CXFA_FFBarcode( - pNode, static_cast<CXFA_Barcode*>(pNode->GetUIChildNode())); + case XFA_FFWidgetType::kBarcode: { + CXFA_Node* child = pNode->GetUIChildNode(); + ASSERT(child->GetElementType() == XFA_Element::Barcode); + pWidget = new CXFA_FFBarcode(pNode, static_cast<CXFA_Barcode*>(child)); break; + } case XFA_FFWidgetType::kButton: pWidget = new CXFA_FFPushButton(pNode); break; - case XFA_FFWidgetType::kCheckButton: - pWidget = new CXFA_FFCheckButton(pNode); + case XFA_FFWidgetType::kCheckButton: { + CXFA_Node* child = pNode->GetUIChildNode(); + ASSERT(child->GetElementType() == XFA_Element::CheckButton); + pWidget = + new CXFA_FFCheckButton(pNode, static_cast<CXFA_CheckButton*>(child)); break; + } case XFA_FFWidgetType::kChoiceList: { if (pNode->IsListBox()) pWidget = new CXFA_FFListBox(pNode); diff --git a/xfa/fxfa/parser/cxfa_checkbutton.cpp b/xfa/fxfa/parser/cxfa_checkbutton.cpp index 0e40e574b2..59afe5ac98 100644 --- a/xfa/fxfa/parser/cxfa_checkbutton.cpp +++ b/xfa/fxfa/parser/cxfa_checkbutton.cpp @@ -47,3 +47,11 @@ CXFA_CheckButton::~CXFA_CheckButton() {} XFA_FFWidgetType CXFA_CheckButton::GetDefaultFFWidgetType() const { return XFA_FFWidgetType::kCheckButton; } + +bool CXFA_CheckButton::IsRound() { + return JSObject()->GetEnum(XFA_Attribute::Shape) == XFA_AttributeEnum::Round; +} + +XFA_AttributeEnum CXFA_CheckButton::GetMark() { + return JSObject()->GetEnum(XFA_Attribute::Mark); +} diff --git a/xfa/fxfa/parser/cxfa_checkbutton.h b/xfa/fxfa/parser/cxfa_checkbutton.h index f107de3206..b603dd0ca1 100644 --- a/xfa/fxfa/parser/cxfa_checkbutton.h +++ b/xfa/fxfa/parser/cxfa_checkbutton.h @@ -15,6 +15,9 @@ class CXFA_CheckButton : public CXFA_Node { ~CXFA_CheckButton() override; XFA_FFWidgetType GetDefaultFFWidgetType() const override; + + bool IsRound(); + XFA_AttributeEnum GetMark(); }; #endif // XFA_FXFA_PARSER_CXFA_CHECKBUTTON_H_ diff --git a/xfa/fxfa/parser/cxfa_node.cpp b/xfa/fxfa/parser/cxfa_node.cpp index 1b53b6b7b0..0c28f4b5c6 100644 --- a/xfa/fxfa/parser/cxfa_node.cpp +++ b/xfa/fxfa/parser/cxfa_node.cpp @@ -3556,21 +3556,6 @@ bool CXFA_Node::HasButtonDown() { return false; } -bool CXFA_Node::IsCheckButtonRound() { - CXFA_Node* pUIChild = GetUIChildNode(); - if (pUIChild) - return pUIChild->JSObject()->GetEnum(XFA_Attribute::Shape) == - XFA_AttributeEnum::Round; - return false; -} - -XFA_AttributeEnum CXFA_Node::GetCheckButtonMark() { - CXFA_Node* pUIChild = GetUIChildNode(); - if (pUIChild) - return pUIChild->JSObject()->GetEnum(XFA_Attribute::Mark); - return XFA_AttributeEnum::Default; -} - bool CXFA_Node::IsRadioButton() { CXFA_Node* pParent = GetParent(); return pParent && pParent->GetElementType() == XFA_Element::ExclGroup; diff --git a/xfa/fxfa/parser/cxfa_node.h b/xfa/fxfa/parser/cxfa_node.h index 87f5a475bd..819b2f9a40 100644 --- a/xfa/fxfa/parser/cxfa_node.h +++ b/xfa/fxfa/parser/cxfa_node.h @@ -318,8 +318,6 @@ class CXFA_Node : public CXFA_Object { bool HasButtonRollover(); bool HasButtonDown(); - bool IsCheckButtonRound(); - XFA_AttributeEnum GetCheckButtonMark(); float GetCheckButtonSize(); XFA_CHECKSTATE GetCheckState(); |