7#include "xfa/fxfa/cxfa_fftextedit.h"
11#include "core/fxcrt/check.h"
12#include "xfa/fwl/cfwl_datetimepicker.h"
13#include "xfa/fwl/cfwl_edit.h"
14#include "xfa/fwl/cfwl_eventtextwillchange.h"
15#include "xfa/fwl/cfwl_messagekillfocus.h"
16#include "xfa/fwl/cfwl_messagesetfocus.h"
17#include "xfa/fwl/cfwl_notedriver.h"
18#include "xfa/fxfa/cxfa_eventparam.h"
19#include "xfa/fxfa/cxfa_ffapp.h"
20#include "xfa/fxfa/cxfa_ffdoc.h"
21#include "xfa/fxfa/cxfa_ffdocview.h"
22#include "xfa/fxfa/parser/cxfa_barcode.h"
23#include "xfa/fxfa/parser/cxfa_node.h"
24#include "xfa/fxfa/parser/cxfa_para.h"
39 if (GetNormalWidget()) {
40 CFWL_NoteDriver* pNoteDriver =
41 GetNormalWidget()->GetFWLApp()->GetNoteDriver();
47 CXFA_FFField::Trace(visitor);
48 visitor->Trace(m_pOldDelegate);
54 CFWL_Edit* pFWLEdit = cppgc::MakeGarbageCollected<CFWL_Edit>(
55 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp(),
56 CFWL_Widget::Properties(),
nullptr);
60 CFWL_NoteDriver* pNoteDriver = pFWLEdit
->GetFWLApp()->GetNoteDriver();
62 m_pOldDelegate = pFWLEdit->GetDelegate();
68 pFWLEdit->SetText(m_pNode->GetValue(XFA_ValuePicture::kDisplay));
75 CFWL_Edit* pWidget = ToEdit(GetNormalWidget());
80 uint32_t dwExtendedStyle =
83 if (m_pNode->IsMultiLine()) {
85 if (!m_pNode->IsVerticalScrollPolicyOff()) {
89 }
else if (!m_pNode->IsHorizontalScrollPolicyOff()) {
92 if (!m_pNode->IsOpenAccess() || !GetDoc()->GetXFADoc()->IsInteractive()) {
97 auto [eType, iMaxChars] = m_pNode->GetMaxChars();
98 if (eType == XFA_Element::ExData)
101 std::optional<int32_t> numCells = m_pNode->GetNumberOfCells();
102 if (!numCells.has_value()) {
104 }
else if (numCells == 0) {
113 GetNormalWidget()->ModifyStyles(dwStyle, 0xFFFFFFFF);
114 GetNormalWidget()->ModifyStyleExts(dwExtendedStyle, 0xFFFFFFFF);
121 if (command == CFWL_MessageMouse::MouseCommand::kRightButtonDown &&
122 !m_pNode->IsOpenAccess()) {
139 CFWL_MessageMouse msg(GetNormalWidget(),
154 CFWL_MessageMouse msg(
nullptr,
166 GetDoc()->PopupMenu(
this, point);
180 CFWL_MessageSetFocus msg(GetNormalWidget());
186 CFWL_MessageKillFocus msg(GetNormalWidget());
203 WideString wsText = ToEdit(GetNormalWidget())->GetText();
204 if (m_pNode->SetValue(XFA_ValuePicture::kEdit, wsText)) {
205 GetDoc()->GetDocView()->UpdateUIDisplay(m_pNode.Get(),
this);
208 ValidateNumberField(wsText);
233 CXFA_Para* para = m_pNode->GetParaIfExists();
237 uint32_t dwExtendedStyle = 0;
267 return dwExtendedStyle;
271 CFWL_Edit* pEdit = ToEdit(GetNormalWidget());
279 bool bUpdate =
false;
280 if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kTextEdit &&
281 !m_pNode->GetNumberOfCells().has_value()) {
282 auto [elementType, iMaxChars] = m_pNode->GetMaxChars();
283 if (elementType == XFA_Element::ExData)
284 iMaxChars = eType == XFA_ValuePicture::kEdit ? iMaxChars : 0;
289 }
else if (m_pNode->GetFFWidgetType() == XFA_FFWidgetType::kBarcode) {
290 int32_t nDataLen = 0;
292 nDataLen =
static_cast<CXFA_Barcode*>(m_pNode->GetUIChildNode())
307 GetNormalWidget()->Update();
313 CFWL_EventTextWillChange* event) {
319 eParam
.m_iSelStart =
static_cast<int32_t>(event->GetSelectionStart());
320 eParam
.m_iSelEnd =
static_cast<int32_t>(event->GetSelectionEnd());
321 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Change, &eParam);
327 event->SetSelectionStart(
static_cast<size_t>(eParam
.m_iSelStart));
328 event->SetSelectionEnd(
static_cast<size_t>(eParam
.m_iSelEnd));
333 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Full, &eParam);
337 m_pOldDelegate->OnProcessMessage(pMessage);
345 static_cast<CFWL_EventTextWillChange*>(pEvent)
);
353 m_pOldDelegate->OnProcessEvent(pEvent);
358 m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
362 return ToEdit(GetNormalWidget())->CanUndo();
366 return ToEdit(GetNormalWidget())->CanRedo();
370 return ToEdit(GetNormalWidget())->HasSelection();
376 return ToEdit(GetNormalWidget())->HasSelection();
380 return !(ToEdit(GetNormalWidget())->GetStyleExts() &
385 return ToEdit(GetNormalWidget())->GetTextLength() > 0;
389 return ToEdit(GetNormalWidget())->Undo();
393 return ToEdit(GetNormalWidget())->Redo();
397 return ToEdit(GetNormalWidget())->Copy();
401 return ToEdit(GetNormalWidget())->Cut();
405 return ToEdit(GetNormalWidget())->Paste(wsPaste);
409 ToEdit(GetNormalWidget())->SelectAll();
413 ToEdit(GetNormalWidget())->ClearText();
417 ToEdit(GetNormalWidget())->ClearSelection();
421 return ToEdit(GetNormalWidget())->GetText();
425 return FormFieldType::kXFA_TextField;
#define FWL_STYLEEXT_EDT_MultiLine
#define FWL_STYLEEXT_EDT_HFar
#define FWL_STYLEEXT_EDT_ShowScrollbarFocus
#define FWL_STYLEEXT_EDT_WantReturn
#define FWL_STYLEEXT_EDT_VNear
#define FWL_STYLEEXT_EDT_VCenter
#define FWL_STYLEEXT_EDT_OuterScrollbar
#define FWL_STYLEEXT_EDT_AutoHScroll
#define FWL_STYLEEXT_EDT_ReadOnly
#define FWL_STYLEEXT_EDT_VFar
#define FWL_STYLEEXT_EDT_AutoVScroll
#define FWL_STYLEEXT_EDT_HNear
#define FWL_STYLEEXT_EDT_Justified
#define FWL_STYLEEXT_EDT_CombText
#define FWL_STYLEEXT_EDT_HCenter
CXFA_EventParam(XFA_EVENTTYPE type)
virtual WideString GetAppTitle() const =0
virtual int32_t MsgBox(const WideString &wsMessage, const WideString &wsTitle, uint32_t dwIconType, uint32_t dwButtonType)=0
CXFA_FFField(CXFA_Node *pNode)
void OnProcessEvent(pdfium::CFWL_Event *pEvent) override
CFX_PointF FWLToClient(const CFX_PointF &point)
bool ProcessCommittedData()
bool LoadWidget() override
void SetEditScrollOffset()
bool OnRButtonUp(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
void SetNormalWidget(CFWL_Widget *widget)
bool PtInActiveRect(const CFX_PointF &point) override
uint32_t UpdateUIProperty()
void SendMessageToFWLWidget(CFWL_Message *pMessage)
std::optional< WideString > Copy() override
bool OnKillFocus(CXFA_FFWidget *pNewWidget) override
void SelectAll() override
bool OnLButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
void OnProcessMessage(CFWL_Message *pMessage) override
void OnProcessEvent(pdfium::CFWL_Event *pEvent) override
bool CanSelectAll() override
bool OnRButtonUp(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
~CXFA_FFTextEdit() override
void OnTextWillChange(pdfium::CFWL_Widget *pWidget, pdfium::CFWL_EventTextWillChange *change)
bool CommitData() override
std::optional< WideString > Cut() override
bool OnSetFocus(CXFA_FFWidget *pOldWidget) override
bool AcceptsFocusOnButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point, CFWL_MessageMouse::MouseCommand command) override
bool UpdateFWLData() override
bool LoadWidget() override
bool Paste(const WideString &wsPaste) override
CXFA_FFTextEdit(CXFA_Node *pNode)
void UpdateWidgetProperty() override
void OnTextFull(CFWL_Widget *pWidget)
FormFieldType GetFormFieldType() override
bool OnRButtonDown(Mask< XFA_FWL_KeyFlag > dwFlags, const CFX_PointF &point) override
bool IsDataChanged() override
WideString GetText() override
XFA_AttributeValue GetHorizontalAlign()
XFA_AttributeValue GetVerticalAlign()
bool operator!=(const WideString &other) const
static WideString FromASCII(ByteStringView str)
WideString GetText() const
virtual void SetTextSkipNotify(const WideString &wsText)
void SetLimit(int32_t nLimit)
void SetChangeText(const WideString &change_text)
void SetCancelled(bool cancelled)
WideString GetChangeText() const
WideString GetPreviousText() const
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
void UnregisterEventTarget(CFWL_Widget *pListener)
CFX_PTemplate< float > CFX_PointF
fxcrt::WideString WideString