7#include "xfa/fxfa/cxfa_fflistbox.h"
13#include "core/fxcrt/stl_util.h"
14#include "third_party/base/check.h"
15#include "v8/include/cppgc/visitor.h"
16#include "xfa/fwl/cfwl_listbox.h"
17#include "xfa/fwl/cfwl_notedriver.h"
18#include "xfa/fwl/cfwl_widget.h"
19#include "xfa/fxfa/cxfa_eventparam.h"
20#include "xfa/fxfa/parser/cxfa_para.h"
35 if (GetNormalWidget()) {
36 CFWL_NoteDriver* pNoteDriver =
37 GetNormalWidget()->GetFWLApp()->GetNoteDriver();
42void CXFA_FFListBox::Trace(
cppgc::Visitor* visitor)
const {
43 CXFA_FFDropDown::Trace(visitor);
44 visitor->Trace(m_pOldDelegate);
50 CFWL_ListBox* pListBox = cppgc::MakeGarbageCollected<CFWL_ListBox>(
51 GetFWLApp()->GetHeap()->GetAllocationHandle(), GetFWLApp(),
52 CFWL_Widget::Properties(),
nullptr);
58 CFWL_NoteDriver* pNoteDriver = pListBox
->GetFWLApp()->GetNoteDriver();
60 m_pOldDelegate = pListBox->GetDelegate();
65 std::vector<WideString> displayables = m_pNode->GetChoiceListItems(
false);
66 std::vector<WideString> settables = m_pNode->GetChoiceListItems(
true);
67 if (displayables.size() > settables.size())
68 displayables.resize(settables.size());
70 for (
const auto& label : displayables)
71 pListBox->AddString(label);
74 if (m_pNode->IsChoiceListMultiSelect())
77 dwExtendedStyle |= GetAlignment();
79 for (int32_t selected : m_pNode->GetSelectedItems())
80 pListBox->SetSelItem(pListBox->GetItem(
nullptr, selected),
true);
94 auto* pListBox = ToListBox(GetNormalWidget());
95 std::vector<int32_t> iSelArray;
96 int32_t iSels = pListBox->CountSelItems();
97 for (int32_t i = 0; i < iSels; ++i)
98 iSelArray.push_back(pListBox->GetSelIndex(i));
100 m_pNode->SetSelectedItems(iSelArray,
true,
false,
true);
105 std::vector<int32_t> iSelArray = m_pNode->GetSelectedItems();
106 int32_t iOldSels =
fxcrt::CollectionSize<int32_t>(iSelArray);
107 auto* pListBox = ToListBox(GetNormalWidget());
108 int32_t iSels = pListBox->CountSelItems();
109 if (iOldSels != iSels)
112 for (int32_t i = 0; i < iSels; ++i) {
120uint32_t CXFA_FFListBox::GetAlignment() {
121 CXFA_Para* para = m_pNode->GetParaIfExists();
125 uint32_t dwExtendedStyle = 0;
143 return dwExtendedStyle;
147 auto* pListBox = ToListBox(GetNormalWidget());
151 std::vector<int32_t> iSelArray = m_pNode->GetSelectedItems();
152 std::vector<CFWL_ListBox::Item*> selItemArray(iSelArray.size());
153 std::transform(iSelArray.begin(), iSelArray.end(), selItemArray.begin(),
154 [pListBox](int32_t val) {
return pListBox->GetSelItem(val); });
156 pListBox->SetSelItem(pListBox->GetSelItem(-1),
false);
157 for (CFWL_ListBox::Item* pItem : selItemArray)
158 pListBox->SetSelItem(pItem,
true);
160 GetNormalWidget()->Update();
166 eParam.m_wsPrevText = m_pNode->GetValue(XFA_ValuePicture::kRaw);
167 m_pNode->ProcessEvent(GetDocView(), XFA_AttributeValue::Change, &eParam);
171 auto* pListBox = ToListBox(GetNormalWidget());
172 pListBox->SetSelItem(pListBox->GetSelItem(nIndex), bSelected);
173 GetNormalWidget()->Update();
177void CXFA_FFListBox::
InsertItem(
const WideString& wsLabel, int32_t nIndex) {
178 ToListBox(GetNormalWidget())->AddString(wsLabel);
179 GetNormalWidget()->Update();
184 auto* pListBox = ToListBox(GetNormalWidget());
186 pListBox->DeleteAll();
188 pListBox->DeleteString(pListBox->GetItem(
nullptr, nIndex));
195 m_pOldDelegate->OnProcessMessage(pMessage);
207 m_pOldDelegate->OnProcessEvent(pEvent);
212 m_pOldDelegate->OnDrawWidget(pGraphics, matrix);
216 return FormFieldType::kXFA_ListBox;
#define FWL_STYLEEXT_LTB_MultiSelection
#define FWL_STYLEEXT_LTB_ShowScrollBarFocus
#define FWL_STYLEEXT_LTB_CenterAlign
#define FWL_STYLEEXT_LTB_RightAlign
#define FWL_STYLEEXT_LTB_LeftAlign
void UnregisterEventTarget(CFWL_Widget *pListener)
void RegisterEventTarget(CFWL_Widget *pListener, CFWL_Widget *pEventSource)
CXFA_EventParam(XFA_EVENTTYPE type)
CXFA_FFDropDown(CXFA_Node *pNode)
bool OnKillFocus(CXFA_FFWidget *pNewWidget) override
bool ProcessCommittedData()
bool LoadWidget() override
void SetNormalWidget(CFWL_Widget *widget)
void OnProcessEvent(CFWL_Event *pEvent) override
bool UpdateFWLData() override
void DeleteItem(int32_t nIndex) override
void InsertItem(const WideString &wsLabel, int32_t nIndex) override
~CXFA_FFListBox() override
void OnProcessMessage(CFWL_Message *pMessage) override
void SetItemState(int32_t nIndex, bool bSelected)
void OnProcessEvent(CFWL_Event *pEvent) override
void OnSelectChanged(CFWL_Widget *pWidget)
bool CommitData() override
bool OnKillFocus(CXFA_FFWidget *pNewWidget) override
FormFieldType GetFormFieldType() override
void OnDrawWidget(CFGAS_GEGraphics *pGraphics, const CFX_Matrix &matrix) override
bool LoadWidget() override
bool IsDataChanged() override
XFA_AttributeValue GetHorizontalAlign()