7#include "xfa/fxfa/cxfa_fffield.h"
12#include "constants/ascii.h"
13#include "third_party/base/check.h"
14#include "xfa/fgas/graphics/cfgas_gecolor.h"
15#include "xfa/fgas/graphics/cfgas_gegraphics.h"
16#include "xfa/fgas/graphics/cfgas_gepath.h"
17#include "xfa/fwl/cfwl_edit.h"
18#include "xfa/fwl/cfwl_eventmouse.h"
19#include "xfa/fwl/cfwl_messagekey.h"
20#include "xfa/fwl/cfwl_messagekillfocus.h"
21#include "xfa/fwl/cfwl_messagemouse.h"
22#include "xfa/fwl/cfwl_messagemousewheel.h"
23#include "xfa/fwl/cfwl_messagesetfocus.h"
24#include "xfa/fwl/cfwl_picturebox.h"
25#include "xfa/fwl/cfwl_widgetmgr.h"
26#include "xfa/fwl/fwl_widgetdef.h"
27#include "xfa/fxfa/cxfa_ffapp.h"
28#include "xfa/fxfa/cxfa_ffdoc.h"
29#include "xfa/fxfa/cxfa_ffdocview.h"
30#include "xfa/fxfa/cxfa_ffpageview.h"
31#include "xfa/fxfa/cxfa_ffwidget.h"
32#include "xfa/fxfa/cxfa_fwltheme.h"
33#include "xfa/fxfa/cxfa_textlayout.h"
34#include "xfa/fxfa/parser/cxfa_border.h"
35#include "xfa/fxfa/parser/cxfa_calculate.h"
36#include "xfa/fxfa/parser/cxfa_caption.h"
37#include "xfa/fxfa/parser/cxfa_margin.h"
38#include "xfa/fxfa/parser/cxfa_node.h"
39#include "xfa/fxfa/parser/cxfa_script.h"
43constexpr float kMinUIHeight = 4.32f;
44constexpr float kDefaultUIHeight = 2.0f;
61 CXFA_FFWidget::Trace(visitor);
62 visitor->Trace(m_pNormalWidget);
69 switch (m_pNode->GetFFWidgetType()) {
70 case XFA_FFWidgetType::kButton:
71 case XFA_FFWidgetType::kCheckButton:
72 case XFA_FFWidgetType::kImageEdit:
73 case XFA_FFWidgetType::kSignature:
74 case XFA_FFWidgetType::kChoiceList:
91 DrawBorder(pGS, m_pNode->GetUIBorder(), m_UIRect, mtRotate);
108 if (m_UIRect.IsEmpty() || !GetDoc()->GetXFADoc()->IsInteractive() ||
109 !m_pNode->IsOpenAccess()) {
124 return m_pNormalWidget;
128 return m_pNormalWidget;
132 m_pNormalWidget = widget;
140 m_pNode->LoadCaption(GetDoc());
153 float fScrollOffset = 0;
157 fScrollOffset = -(m_pNode->GetUIMargin().top);
180 CXFA_Margin* margin = m_pNode->GetMarginIfExists();
188 rtWidget
.Deflate(fLeftInset
, fTopInset
, fRightInset
, fBottomInset
);
200 float fCapReserve = 0;
201 CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
213 fCapReserve =
std::min(fCapReserve, rtWidget
.height);
215 fCapReserve =
std::min(fCapReserve, rtWidget
.width);
231 CXFA_TextLayout* pCapTextLayout = m_pNode->GetCaptionTextLayout();
232 if (fCapReserve <= 0 && pCapTextLayout) {
235 CFX_SizeF size = pCapTextLayout->CalcSize(minSize, maxSize);
238 fCapReserve = size.height;
240 fCapReserve = size.width;
248 switch (iCapPlacement) {
283 CXFA_Border* borderUI = m_pNode->GetUIBorder();
294 CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
304 if (fWidth > rtWidget
.width)
310 }
else if (fHeight > rtWidget
.height) {
320 CFX_RectF rtUIMargin = m_pNode->GetUIMargin();
330 float fHeight = rtUIMargin
.top + rtUIMargin
.height;
331 if (fWidth > rtWidget
.width) {
340 }
else if (fHeight > rtWidget
.height) {
351 CXFA_Node* pUiNode = m_pNode->GetUIChildNode();
363 if (!
GetDoc()->GetXFADoc()->IsInteractive()) {
364 float fFontSize = m_pNode->GetFontSize();
376 Mask<XFA_FWL_KeyFlag>(), CFX_PointF());
387 Mask<XFA_FWL_KeyFlag>(), CFX_PointF());
400 const CFX_PointF& point,
404 if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive())
413 const CFX_PointF& point) {
415 CFWL_MessageMouse msg(GetNormalWidget(),
416 CFWL_MessageMouse::MouseCommand::kLeftButtonDown,
417 dwFlags, FWLToClient(point));
423 const CFX_PointF& point) {
431 CFWL_MessageMouse msg(GetNormalWidget(),
432 CFWL_MessageMouse::MouseCommand::kLeftButtonUp, dwFlags,
439 const CFX_PointF& point) {
443 CFWL_MessageMouse msg(GetNormalWidget(),
444 CFWL_MessageMouse::MouseCommand::kLeftButtonDblClk,
445 dwFlags, FWLToClient(point));
451 const CFX_PointF& point) {
455 CFWL_MessageMouse msg(GetNormalWidget(),
456 CFWL_MessageMouse::MouseCommand::kMove, dwFlags,
463 const CFX_PointF& point,
464 const CFX_Vector& delta) {
468 CFWL_MessageMouseWheel msg(GetNormalWidget(), FWLToClient(point), delta);
474 const CFX_PointF& point) {
477 CFWL_MessageMouse msg(GetNormalWidget(),
478 CFWL_MessageMouse::MouseCommand::kRightButtonDown,
479 dwFlags, FWLToClient(point));
485 const CFX_PointF& point) {
492 CFWL_MessageMouse msg(GetNormalWidget(),
493 CFWL_MessageMouse::MouseCommand::kRightButtonUp,
494 dwFlags, FWLToClient(point));
500 const CFX_PointF& point) {
504 CFWL_MessageMouse msg(GetNormalWidget(),
505 CFWL_MessageMouse::MouseCommand::kRightButtonDblClk,
506 dwFlags, FWLToClient(point));
548 if (!
GetDoc()->GetXFADoc()->IsInteractive())
554 if (!m_pNode->IsOpenAccess())
565 if (pNorm && pNorm->HitTest(FWLToClient(point)) != FWL_WidgetHit::Unknown)
580 CXFA_TextLayout* pCapTextLayout = m_pNode->GetCaptionTextLayout();
590 CXFA_TextLayout* pCapTextLayout = m_pNode->GetCaptionTextLayout();
594 CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
607 pCapTextLayout->DrawString(pRenderDevice, mt, rtClip, 0);
611 if (!m_pNode->IsOpenAccess())
616 m_pDocView->SetChangeMark();
617 m_pDocView->AddValidateNode(m_pNode.Get());
625 CXFA_Node* exclNode = m_pNode->GetExclGroupIfExists();
626 if (!exclNode || !exclNode->IsWidgetReady())
627 return CalculateNode(m_pNode.Get());
660 WideString
::FromASCII(
"You are not allowed to modify this field.")
,
683 wsMessage
+= L"\r\n";
685 WideString
::FromASCII(
"Are you sure you want to modify this field?");
717 GetApp()->GetFWLWidgetMgr()->OnProcessMessageToForm(pMessage);
725 CFWL_EventMouse* event =
static_cast<CFWL_EventMouse*>(pEvent);
729 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::MouseEnter,
733 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::MouseExit,
737 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::MouseDown,
741 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::MouseUp,
748 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Click, &eParam);
#define FWL_STYLEEXT_EDT_ReadOnly
void FillPath(const CFGAS_GEPath &path, CFX_FillRenderOptions::FillType fill_type, const CFX_Matrix &matrix)
CFX_RenderDevice * GetRenderDevice()
void SetFillColor(const CFGAS_GEColor &color)
void AddRectangle(float left, float top, float width, float height)
void AddEllipse(const CFX_RectF &rect)
void SetScrollOffset(float fScrollOffset) override
CFWL_MessageMouse::MouseCommand GetCommand() const
CFWL_MessageKillFocus(CFWL_Widget *pDstTarget)
CFWL_MessageSetFocus(CFWL_Widget *pDstTarget)
CFX_Matrix(float a1, float b1, float c1, float d1, float e1, float f1)
CFX_RectF TransformRect(const CFX_RectF &rect) const
void Concat(const CFX_Matrix &right)
constexpr CFX_RectF()=default
void Intersect(const CFX_RectF &rt)
void Deflate(float off_left, float off_top, float off_right, float off_bottom)
CFX_RectF & operator=(const CFX_RectF &other)=default
bool Contains(const PointType &p) const
CXFA_Script * GetScriptIfExists()
XFA_AttributeValue GetOverride()
WideString GetMessageText() const
CXFA_Margin * GetMarginIfExists()
XFA_AttributeValue GetPlacementType()
CXFA_ContentLayoutItem * GetPrev() const
CXFA_ContentLayoutItem * GetNext() const
CFX_RectF GetAbsoluteRect() const
CXFA_FFWidget * GetFFWidget()
CXFA_ContentLayoutItem * GetFirst()
CXFA_EventParam(XFA_EVENTTYPE type)
virtual int32_t MsgBox(const WideString &wsMessage, const WideString &wsTitle, uint32_t dwIconType, uint32_t dwButtonType)=0
CXFA_FFField(CXFA_Node *pNode)
bool OnMouseEnter() override
bool OnSetFocus(CXFA_FFWidget *pOldWidget) override
void OnProcessMessage(CFWL_Message *pMessage) override
int32_t CalculateOverride()
bool OnMouseExit() override
bool OnLButtonUp(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
virtual bool IsDataChanged()
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void RenderWidget(CFGAS_GEGraphics *pGS, const CFX_Matrix &matrix, HighlightOption highlight) override
int32_t CalculateNode(CXFA_Node *pNode)
bool OnMouseWheel(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point, const CFX_Vector &delta) override
bool OnLButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
const CFWL_Widget * GetNormalWidget() const
bool OnLButtonDblClk(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
bool OnKillFocus(CXFA_FFWidget *pNewWidget) override
CFX_PointF FWLToClient(const CFX_PointF &point)
bool PerformLayout() override
void DrawHighlight(CFGAS_GEGraphics *pGS, const CFX_Matrix &pMatrix, HighlightOption highlight, ShapeOption shape)
bool ProcessCommittedData()
virtual void SetFWLRect()
bool OnRButtonDblClk(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
virtual CXFA_FFDropDown * AsDropDown()
bool LoadWidget() override
void SetEditScrollOffset()
bool OnRButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
CFWL_Widget * GetNormalWidget()
CFX_RectF GetBBox(FocusOption focus) override
bool OnRButtonUp(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
bool AcceptsFocusOnButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point, CFWL_MessageMouse::MouseCommand command) override
void SetNormalWidget(CFWL_Widget *widget)
void CapTopBottomPlacement(const CXFA_Margin *margin, const CFX_RectF &rtWidget, XFA_AttributeValue iCapPlacement)
bool PtInActiveRect(const CFX_PointF &point) override
FWL_WidgetHit HitTest(const CFX_PointF &point) override
void OnProcessEvent(CFWL_Event *pEvent) override
uint32_t UpdateUIProperty()
void RenderCaption(CFGAS_GEGraphics *pGS, const CFX_Matrix &pMatrix)
virtual bool CommitData()
bool OnChar(uint32_t dwChar, Mask< XFA_FWL_KeyFlag > dwFlags) override
void CapLeftRightPlacement(const CXFA_Margin *margin, const CFX_RectF &rtWidget, XFA_AttributeValue iCapPlacement)
void SendMessageToFWLWidget(CFWL_Message *pMessage)
bool OnKeyDown(XFA_FWL_VKEYCODE dwKeyCode, Mask< XFA_FWL_KeyFlag > dwFlags) override
bool OnMouseMove(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
CXFA_FFField * AsField() override
float GetBottomInset() const
float GetLeftInset() const
float GetTopInset() const
float GetRightInset() const
CXFA_Calculate * GetCalculateIfExists() const
void SetFlag(XFA_NodeFlag dwFlag)
CXFA_Node * GetExclGroupFirstMember()
CXFA_Node * GetExclGroupNextMember(CXFA_Node *pNode)
bool IsUserInteractive() const
bool IsWidgetReady() const
CXFA_Margin * GetMarginIfExists() const
XFA_Element GetElementType() const
WideString GetExpression()
float Layout(const CFX_SizeF &size)
WideString & operator+=(const wchar_t *str)
static WideString FromASCII(ByteStringView str)