7#include "xfa/fxfa/cxfa_ffpushbutton.h"
9#include "third_party/base/check.h"
10#include "v8/include/cppgc/visitor.h"
11#include "xfa/fgas/graphics/cfgas_gecolor.h"
12#include "xfa/fgas/graphics/cfgas_gepath.h"
13#include "xfa/fwl/cfwl_notedriver.h"
14#include "xfa/fwl/cfwl_pushbutton.h"
15#include "xfa/fwl/cfwl_widgetmgr.h"
16#include "xfa/fxfa/cxfa_ffapp.h"
17#include "xfa/fxfa/cxfa_ffdoc.h"
18#include "xfa/fxfa/cxfa_fffield.h"
19#include "xfa/fxfa/cxfa_ffpageview.h"
20#include "xfa/fxfa/cxfa_ffwidget.h"
21#include "xfa/fxfa/cxfa_textlayout.h"
22#include "xfa/fxfa/cxfa_textprovider.h"
23#include "xfa/fxfa/parser/cxfa_border.h"
24#include "xfa/fxfa/parser/cxfa_button.h"
25#include "xfa/fxfa/parser/cxfa_caption.h"
26#include "xfa/fxfa/parser/cxfa_edge.h"
28CXFA_FFPushButton::CXFA_FFPushButton(
CXFA_Node* pNode, CXFA_Button* button)
33void CXFA_FFPushButton::
Trace(
cppgc::Visitor* visitor)
const {
34 CXFA_FFField::Trace(visitor);
35 visitor->Trace(m_pRolloverTextLayout);
36 visitor->Trace(m_pDownTextLayout);
37 visitor->Trace(m_pRollProvider);
38 visitor->Trace(m_pDownProvider);
39 visitor->Trace(m_pOldDelegate);
40 visitor->Trace(button_);
53 RenderHighlightCaption(pGS, &mtRotate);
58 GetApp()->GetFWLWidgetMgr()->OnDrawWidget(GetNormalWidget(), pGS, mt);
64 CFWL_PushButton* pPushButton = cppgc::MakeGarbageCollected<CFWL_PushButton>(
65 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp());
66 m_pOldDelegate = pPushButton->GetDelegate();
71 CFWL_NoteDriver* pNoteDriver = pPushButton
->GetFWLApp()->GetNoteDriver();
77 LoadHighlightCaption();
84 uint32_t dwStyleEx = 0;
85 switch (button_->GetHighlight()) {
86 case XFA_AttributeValue::Inverted:
89 case XFA_AttributeValue::Outline:
92 case XFA_AttributeValue::Push:
98 GetNormalWidget()->ModifyStyleExts(dwStyleEx, 0xFFFFFFFF);
106 CXFA_Margin* margin = m_pNode->GetMarginIfExists();
111 CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
115 LayoutHighlightCaption();
117 if (GetNormalWidget())
118 GetNormalWidget()->Update();
123float CXFA_FFPushButton::GetLineWidth() {
124 CXFA_Border* border = m_pNode->GetBorderIfExists();
126 CXFA_Edge* edge = border->GetEdgeIfExists(0);
132FX_ARGB CXFA_FFPushButton::GetLineColor() {
136FX_ARGB CXFA_FFPushButton::GetFillColor() {
140void CXFA_FFPushButton::LoadHighlightCaption() {
141 CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
145 if (m_pNode->HasButtonRollover()) {
146 if (!m_pRollProvider) {
147 m_pRollProvider = cppgc::MakeGarbageCollected<CXFA_TextProvider>(
148 GetDoc()->GetHeap()->GetAllocationHandle(), m_pNode.Get(),
149 CXFA_TextProvider::Type::kRollover);
151 m_pRolloverTextLayout = cppgc::MakeGarbageCollected<CXFA_TextLayout>(
152 GetDoc()->GetHeap()->GetAllocationHandle(), GetDoc(), m_pRollProvider);
154 if (m_pNode->HasButtonDown()) {
155 if (!m_pDownProvider) {
156 m_pDownProvider = cppgc::MakeGarbageCollected<CXFA_TextProvider>(
157 GetDoc()->GetHeap()->GetAllocationHandle(), m_pNode.Get(),
158 CXFA_TextProvider::Type::kDown);
160 m_pDownTextLayout = cppgc::MakeGarbageCollected<CXFA_TextLayout>(
161 GetDoc()->GetHeap()->GetAllocationHandle(), GetDoc(), m_pDownProvider);
165void CXFA_FFPushButton::LayoutHighlightCaption() {
166 CFX_SizeF sz(m_CaptionRect.width, m_CaptionRect.height);
168 if (m_pRolloverTextLayout)
169 m_pRolloverTextLayout->Layout(sz);
170 if (m_pDownTextLayout)
171 m_pDownTextLayout->Layout(sz);
176 CXFA_TextLayout* pCapTextLayout = m_pNode->GetCaptionTextLayout();
177 CXFA_Caption* caption = m_pNode->GetCaptionIfExists();
190 uint32_t dwState = GetNormalWidget()->GetStates();
193 if (m_pDownTextLayout->DrawString(pRenderDevice, mt, rtClip, 0))
196 if (m_pRolloverTextLayout->DrawString(pRenderDevice, mt, rtClip, 0))
201 pCapTextLayout->DrawString(pRenderDevice, mt, rtClip, 0);
205 m_pOldDelegate->OnProcessMessage(pMessage);
209 m_pOldDelegate->OnProcessEvent(pEvent);
215 auto* pWidget = GetNormalWidget();
219 CFX_RectF rtFill(0, 0, pWidget->GetWidgetRect().Size());
220 float fLineWith = GetLineWidth();
234 float fLineWidth = GetLineWidth();
239 CFX_RectF rect = pWidget->GetWidgetRect();
247 return FormFieldType::kXFA_PushButton;
CFGAS_GEColor(const FX_ARGB argb)
void FillPath(const CFGAS_GEPath &path, CFX_FillRenderOptions::FillType fill_type, const CFX_Matrix &matrix)
void SetLineWidth(float lineWidth)
CFX_RenderDevice * GetRenderDevice()
void SetStrokeColor(const CFGAS_GEColor &color)
void SetFillColor(const CFGAS_GEColor &color)
void StrokePath(const CFGAS_GEPath &path, const CFX_Matrix &matrix)
void AddRectangle(float left, float top, float width, float height)
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
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)
void Intersect(const CFX_RectF &rt)
CFX_RectF & operator=(const CFX_RectF &other)=default
void Deflate(float x, float y)
XFA_AttributeValue GetPresence()
CXFA_Margin * GetMarginIfExists()
CXFA_FFField(CXFA_Node *pNode)
virtual void SetFWLRect()
bool LoadWidget() override
void SetNormalWidget(CFWL_Widget *widget)
void OnProcessEvent(CFWL_Event *pEvent) override
float GetThickness() const
constexpr FX_ARGB ArgbEncode(uint32_t a, uint32_t r, uint32_t g, uint32_t b)