• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 
7 #include "xfa/src/foxitlib.h"
8 #include "xfa/src/fxfa/src/common/xfa_common.h"
9 #include "xfa_fwladapter.h"
10 #include "xfa_ffwidget.h"
11 #include "xfa_fffield.h"
12 #include "xfa_ffpageview.h"
13 #include "xfa_ffdocview.h"
14 #include "xfa_ffchoicelist.h"
15 #include "xfa_ffdoc.h"
CXFA_FFListBox(CXFA_FFPageView * pPageView,CXFA_WidgetAcc * pDataAcc)16 CXFA_FFListBox::CXFA_FFListBox(CXFA_FFPageView* pPageView,
17                                CXFA_WidgetAcc* pDataAcc)
18     : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {}
~CXFA_FFListBox()19 CXFA_FFListBox::~CXFA_FFListBox() {
20   if (m_pNormalWidget) {
21     IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
22     IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
23     pNoteDriver->UnregisterEventTarget(pWidget);
24   }
25 }
LoadWidget()26 FX_BOOL CXFA_FFListBox::LoadWidget() {
27   CFWL_ListBox* pListBox = CFWL_ListBox::Create();
28   pListBox->Initialize();
29   pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll | FWL_WGTSTYLE_NoBackground,
30                          0xFFFFFFFF);
31   m_pNormalWidget = (CFWL_Widget*)pListBox;
32   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
33   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
34   IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
35   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
36   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
37   m_pNormalWidget->LockUpdate();
38   CFX_WideStringArray wsLabelArray;
39   m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE);
40   int32_t iItems = wsLabelArray.GetSize();
41   for (int32_t i = 0; i < iItems; i++) {
42     pListBox->AddString(wsLabelArray[i]);
43   }
44   FX_DWORD dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus;
45   if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) {
46     dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection;
47   }
48   dwExtendedStyle |= GetAlignment();
49   m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
50   CFX_Int32Array iSelArray;
51   m_pDataAcc->GetSelectedItems(iSelArray);
52   int32_t iSelCount = iSelArray.GetSize();
53   for (int32_t j = 0; j < iSelCount; j++) {
54     FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]);
55     pListBox->SetSelItem(item, TRUE);
56   }
57   m_pNormalWidget->UnlockUpdate();
58   return CXFA_FFField::LoadWidget();
59 }
OnKillFocus(CXFA_FFWidget * pNewFocus)60 FX_BOOL CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) {
61   FX_BOOL flag = ProcessCommittedData();
62   if (!flag) {
63     UpdateFWLData();
64   }
65   CXFA_FFField::OnKillFocus(pNewFocus);
66   return TRUE;
67 }
CommitData()68 FX_BOOL CXFA_FFListBox::CommitData() {
69   FXSYS_assert(m_pNormalWidget != NULL);
70   CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
71   int32_t iSels = pListBox->CountSelItems();
72   CFX_Int32Array iSelArray;
73   for (int32_t i = 0; i < iSels; i++) {
74     iSelArray.Add(pListBox->GetSelIndex(i));
75   }
76   m_pDataAcc->SetSelectdItems(iSelArray, TRUE);
77   return TRUE;
78 }
IsDataChanged()79 FX_BOOL CXFA_FFListBox::IsDataChanged() {
80   CFX_Int32Array iSelArray;
81   m_pDataAcc->GetSelectedItems(iSelArray);
82   int32_t iOldSels = iSelArray.GetSize();
83   CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
84   int32_t iSels = pListBox->CountSelItems();
85   if (iOldSels == iSels) {
86     int32_t iIndex = 0;
87     for (; iIndex < iSels; iIndex++) {
88       FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[iIndex]);
89       if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) {
90         break;
91       }
92     }
93     if (iIndex == iSels) {
94       return FALSE;
95     }
96   }
97   return TRUE;
98 }
GetAlignment()99 FX_DWORD CXFA_FFListBox::GetAlignment() {
100   FX_DWORD dwExtendedStyle = 0;
101   if (CXFA_Para para = m_pDataAcc->GetPara()) {
102     int32_t iHorz = para.GetHorizontalAlign();
103     switch (iHorz) {
104       case XFA_ATTRIBUTEENUM_Center:
105         dwExtendedStyle |= FWL_STYLEEXT_LTB_CenterAlign;
106         break;
107       case XFA_ATTRIBUTEENUM_Justify:
108         break;
109       case XFA_ATTRIBUTEENUM_JustifyAll:
110         break;
111       case XFA_ATTRIBUTEENUM_Radix:
112         break;
113       case XFA_ATTRIBUTEENUM_Right:
114         dwExtendedStyle |= FWL_STYLEEXT_LTB_RightAlign;
115         break;
116       default:
117         dwExtendedStyle |= FWL_STYLEEXT_LTB_LeftAlign;
118         break;
119     }
120   }
121   return dwExtendedStyle;
122 }
UpdateFWLData()123 FX_BOOL CXFA_FFListBox::UpdateFWLData() {
124   if (!m_pNormalWidget) {
125     return FALSE;
126   }
127   CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget);
128   CFX_ArrayTemplate<FWL_HLISTITEM> selItemArray;
129   CFX_Int32Array iSelArray;
130   m_pDataAcc->GetSelectedItems(iSelArray);
131   int32_t iSelCount = iSelArray.GetSize();
132   for (int32_t j = 0; j < iSelCount; j++) {
133     FWL_HLISTITEM lpItemSel = pListBox->GetSelItem(iSelArray[j]);
134     selItemArray.Add(lpItemSel);
135   }
136   pListBox->SetSelItem(pListBox->GetSelItem(-1), FALSE);
137   for (int32_t i = 0; i < iSelCount; i++) {
138     ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], TRUE);
139   }
140   m_pNormalWidget->Update();
141   return TRUE;
142 }
OnSelectChanged(IFWL_Widget * pWidget,const CFX_Int32Array & arrSels)143 void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget,
144                                      const CFX_Int32Array& arrSels) {
145   CXFA_EventParam eParam;
146   eParam.m_eType = XFA_EVENT_Change;
147   eParam.m_pTarget = m_pDataAcc;
148   m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw);
149   CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget;
150   int32_t iSels = pListBox->CountSelItems();
151   if (iSels > 0) {
152     pListBox->GetItemText(pListBox->GetSelItem(0), eParam.m_wsNewText);
153   }
154   m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam);
155 }
SetItemState(int32_t nIndex,FX_BOOL bSelected)156 void CXFA_FFListBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) {
157   FWL_HLISTITEM item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex);
158   ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected);
159   m_pNormalWidget->Update();
160   AddInvalidateRect();
161 }
InsertItem(const CFX_WideStringC & wsLabel,int32_t nIndex)162 void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel,
163                                 int32_t nIndex) {
164   CFX_WideString wsTemp(wsLabel);
165   ((CFWL_ListBox*)m_pNormalWidget)->AddString(wsTemp);
166   m_pNormalWidget->Update();
167   AddInvalidateRect();
168 }
DeleteItem(int32_t nIndex)169 void CXFA_FFListBox::DeleteItem(int32_t nIndex) {
170   if (nIndex < 0) {
171     ((CFWL_ListBox*)m_pNormalWidget)->DeleteAll();
172   } else {
173     ((CFWL_ListBox*)m_pNormalWidget)
174         ->DeleteString(((CFWL_ListBox*)m_pNormalWidget)->GetItem(nIndex));
175   }
176   m_pNormalWidget->Update();
177   AddInvalidateRect();
178 }
OnProcessMessage(CFWL_Message * pMessage)179 int32_t CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) {
180   return m_pOldDelegate->OnProcessMessage(pMessage);
181 }
OnProcessEvent(CFWL_Event * pEvent)182 FWL_ERR CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) {
183   CXFA_FFField::OnProcessEvent(pEvent);
184   FX_DWORD dwEventID = pEvent->GetClassID();
185   switch (dwEventID) {
186     case FWL_EVTHASH_LTB_SelChanged: {
187       CFX_Int32Array arrSels;
188       OnSelectChanged(m_pNormalWidget->GetWidget(), arrSels);
189       break;
190     }
191     default: {}
192   }
193   return m_pOldDelegate->OnProcessEvent(pEvent);
194 }
OnDrawWidget(CFX_Graphics * pGraphics,const CFX_Matrix * pMatrix)195 FWL_ERR CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics,
196                                      const CFX_Matrix* pMatrix) {
197   return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
198 }
CXFA_FFComboBox(CXFA_FFPageView * pPageView,CXFA_WidgetAcc * pDataAcc)199 CXFA_FFComboBox::CXFA_FFComboBox(CXFA_FFPageView* pPageView,
200                                  CXFA_WidgetAcc* pDataAcc)
201     : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(NULL) {}
~CXFA_FFComboBox()202 CXFA_FFComboBox::~CXFA_FFComboBox() {}
GetBBox(CFX_RectF & rtBox,FX_DWORD dwStatus,FX_BOOL bDrawFocus)203 FX_BOOL CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox,
204                                  FX_DWORD dwStatus,
205                                  FX_BOOL bDrawFocus) {
206   if (bDrawFocus) {
207     return FALSE;
208   }
209 #ifndef _XFA_EMB
210   return CXFA_FFWidget::GetBBox(rtBox, dwStatus);
211 #endif
212   GetRectWithoutRotate(rtBox);
213   if (m_pNormalWidget) {
214     CFX_RectF rtWidget;
215     ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget);
216     rtBox.Union(rtWidget);
217   }
218   CFX_Matrix mt;
219   GetRotateMatrix(mt);
220   mt.TransformRect(rtBox);
221   return TRUE;
222 }
PtInActiveRect(FX_FLOAT fx,FX_FLOAT fy)223 FX_BOOL CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) {
224   if (!m_pNormalWidget) {
225     return FALSE;
226   }
227   CFX_RectF rtWidget;
228   ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget);
229   if (rtWidget.Contains(fx, fy)) {
230     return TRUE;
231   }
232   return FALSE;
233 }
LoadWidget()234 FX_BOOL CXFA_FFComboBox::LoadWidget() {
235   CFWL_ComboBox* pComboBox = CFWL_ComboBox::Create();
236   pComboBox->Initialize();
237   m_pNormalWidget = (CFWL_Widget*)pComboBox;
238   IFWL_Widget* pWidget = m_pNormalWidget->GetWidget();
239   m_pNormalWidget->SetPrivateData(pWidget, this, NULL);
240   IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver();
241   pNoteDriver->RegisterEventTarget(pWidget, pWidget);
242   m_pOldDelegate = m_pNormalWidget->SetDelegate(this);
243   m_pNormalWidget->LockUpdate();
244   CFX_WideStringArray wsLabelArray;
245   m_pDataAcc->GetChoiceListItems(wsLabelArray, FALSE);
246   int32_t iItems = wsLabelArray.GetSize();
247   for (int32_t i = 0; i < iItems; i++) {
248     pComboBox->AddString(wsLabelArray[i]);
249   }
250   CFX_Int32Array iSelArray;
251   m_pDataAcc->GetSelectedItems(iSelArray);
252   int32_t iSelCount = iSelArray.GetSize();
253   if (iSelCount > 0) {
254     pComboBox->SetCurSel(iSelArray[0]);
255   } else {
256     CFX_WideString wsText;
257     m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
258     pComboBox->SetEditText(wsText);
259   }
260   UpdateWidgetProperty();
261   m_pNormalWidget->UnlockUpdate();
262   return CXFA_FFField::LoadWidget();
263 }
UpdateWidgetProperty()264 void CXFA_FFComboBox::UpdateWidgetProperty() {
265   CFWL_ComboBox* pComboBox = (CFWL_ComboBox*)m_pNormalWidget;
266   if (!pComboBox) {
267     return;
268   }
269   FX_DWORD dwExtendedStyle = 0;
270   FX_DWORD dwEditStyles =
271       FWL_STYLEEXT_EDT_ReadOnly | FWL_STYLEEXT_EDT_LastLineHeight;
272   dwExtendedStyle |= UpdateUIProperty();
273   if (m_pDataAcc->IsChoiceListAllowTextEntry()) {
274     dwEditStyles &= ~FWL_STYLEEXT_EDT_ReadOnly;
275     dwExtendedStyle |= FWL_STYLEEXT_CMB_DropDown;
276   }
277   if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open ||
278       !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) {
279     dwEditStyles |= FWL_STYLEEXT_EDT_ReadOnly;
280     dwExtendedStyle |= FWL_STYLEEXT_CMB_ReadOnly;
281   }
282   dwExtendedStyle |= GetAlignment();
283   m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF);
284   if (m_pDataAcc->GetHorizontalScrollPolicy() != XFA_ATTRIBUTEENUM_Off) {
285     dwEditStyles |= FWL_STYLEEXT_EDT_AutoHScroll;
286   }
287   pComboBox->EditModifyStylesEx(dwEditStyles, 0xFFFFFFFF);
288 }
OnRButtonUp(FX_DWORD dwFlags,FX_FLOAT fx,FX_FLOAT fy)289 FX_BOOL CXFA_FFComboBox::OnRButtonUp(FX_DWORD dwFlags,
290                                      FX_FLOAT fx,
291                                      FX_FLOAT fy) {
292   if (!CXFA_FFField::OnRButtonUp(dwFlags, fx, fy)) {
293     return FALSE;
294   }
295   CFX_PointF pt;
296   pt.Set(fx, fy);
297   GetDoc()->GetDocProvider()->PopupMenu(this, pt, NULL);
298   return TRUE;
299 }
OnKillFocus(CXFA_FFWidget * pNewWidget)300 FX_BOOL CXFA_FFComboBox::OnKillFocus(CXFA_FFWidget* pNewWidget) {
301   FX_BOOL flag = ProcessCommittedData();
302   if (!flag) {
303     UpdateFWLData();
304   }
305   CXFA_FFField::OnKillFocus(pNewWidget);
306   return TRUE;
307 }
OpenDropDownList()308 void CXFA_FFComboBox::OpenDropDownList() {
309   ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(TRUE);
310 }
CommitData()311 FX_BOOL CXFA_FFComboBox::CommitData() {
312   return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw);
313 }
IsDataChanged()314 FX_BOOL CXFA_FFComboBox::IsDataChanged() {
315   CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget);
316   CFX_WideString wsText;
317   pFWLcombobox->GetEditText(wsText);
318   int32_t iCursel = pFWLcombobox->GetCurSel();
319   if (iCursel >= 0) {
320     CFX_WideString wsSel;
321     pFWLcombobox->GetTextByIndex(iCursel, wsSel);
322     if (wsSel == wsText) {
323       m_pDataAcc->GetChoiceListItem(wsText, iCursel, TRUE);
324     }
325   }
326   CFX_WideString wsOldValue;
327   m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw);
328   if (wsOldValue != wsText) {
329     m_wsNewValue = wsText;
330     return TRUE;
331   }
332   return FALSE;
333 }
FWLEventSelChange(CXFA_EventParam * pParam)334 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) {
335   pParam->m_eType = XFA_EVENT_Change;
336   pParam->m_pTarget = m_pDataAcc;
337   CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget);
338   pFWLcombobox->GetEditText(pParam->m_wsNewText);
339   m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, pParam);
340 }
GetAlignment()341 FX_DWORD CXFA_FFComboBox::GetAlignment() {
342   FX_DWORD dwExtendedStyle = 0;
343   if (CXFA_Para para = m_pDataAcc->GetPara()) {
344     int32_t iHorz = para.GetHorizontalAlign();
345     switch (iHorz) {
346       case XFA_ATTRIBUTEENUM_Center:
347         dwExtendedStyle |=
348             FWL_STYLEEXT_CMB_EditHCenter | FWL_STYLEEXT_CMB_ListItemCenterAlign;
349         break;
350       case XFA_ATTRIBUTEENUM_Justify:
351         dwExtendedStyle |= FWL_STYLEEXT_CMB_EditJustified;
352         break;
353       case XFA_ATTRIBUTEENUM_JustifyAll:
354         break;
355       case XFA_ATTRIBUTEENUM_Radix:
356         break;
357       case XFA_ATTRIBUTEENUM_Right:
358         break;
359       default:
360         dwExtendedStyle |=
361             FWL_STYLEEXT_CMB_EditHNear | FWL_STYLEEXT_CMB_ListItemLeftAlign;
362         break;
363     }
364     int32_t iVert = para.GetVerticalAlign();
365     switch (iVert) {
366       case XFA_ATTRIBUTEENUM_Middle:
367         dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVCenter;
368         break;
369       case XFA_ATTRIBUTEENUM_Bottom:
370         dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVFar;
371         break;
372       default:
373         dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear;
374         break;
375     }
376   }
377   return dwExtendedStyle;
378 }
UpdateFWLData()379 FX_BOOL CXFA_FFComboBox::UpdateFWLData() {
380   if (!m_pNormalWidget) {
381     return FALSE;
382   }
383   CFX_Int32Array iSelArray;
384   m_pDataAcc->GetSelectedItems(iSelArray);
385   int32_t iSelCount = iSelArray.GetSize();
386   if (iSelCount > 0) {
387     ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]);
388   } else {
389     CFX_WideString wsText;
390     ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1);
391     m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw);
392     ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText);
393   }
394   m_pNormalWidget->Update();
395   return TRUE;
396 }
CanUndo()397 FX_BOOL CXFA_FFComboBox::CanUndo() {
398   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
399          ((CFWL_ComboBox*)m_pNormalWidget)->EditCanUndo();
400 }
CanRedo()401 FX_BOOL CXFA_FFComboBox::CanRedo() {
402   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
403          ((CFWL_ComboBox*)m_pNormalWidget)->EditCanRedo();
404 }
Undo()405 FX_BOOL CXFA_FFComboBox::Undo() {
406   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
407          ((CFWL_ComboBox*)m_pNormalWidget)->EditUndo();
408 }
Redo()409 FX_BOOL CXFA_FFComboBox::Redo() {
410   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
411          ((CFWL_ComboBox*)m_pNormalWidget)->EditRedo();
412 }
CanCopy()413 FX_BOOL CXFA_FFComboBox::CanCopy() {
414   return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCopy();
415 }
CanCut()416 FX_BOOL CXFA_FFComboBox::CanCut() {
417   if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open) {
418     return FALSE;
419   }
420   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
421          ((CFWL_ComboBox*)m_pNormalWidget)->EditCanCut();
422 }
CanPaste()423 FX_BOOL CXFA_FFComboBox::CanPaste() {
424   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
425          (m_pDataAcc->GetAccess() == XFA_ATTRIBUTEENUM_Open);
426 }
CanSelectAll()427 FX_BOOL CXFA_FFComboBox::CanSelectAll() {
428   return ((CFWL_ComboBox*)m_pNormalWidget)->EditCanSelectAll();
429 }
Copy(CFX_WideString & wsCopy)430 FX_BOOL CXFA_FFComboBox::Copy(CFX_WideString& wsCopy) {
431   return ((CFWL_ComboBox*)m_pNormalWidget)->EditCopy(wsCopy);
432 }
Cut(CFX_WideString & wsCut)433 FX_BOOL CXFA_FFComboBox::Cut(CFX_WideString& wsCut) {
434   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
435          ((CFWL_ComboBox*)m_pNormalWidget)->EditCut(wsCut);
436 }
Paste(const CFX_WideString & wsPaste)437 FX_BOOL CXFA_FFComboBox::Paste(const CFX_WideString& wsPaste) {
438   return m_pDataAcc->IsChoiceListAllowTextEntry() &&
439          ((CFWL_ComboBox*)m_pNormalWidget)->EditPaste(wsPaste);
440 }
SelectAll()441 FX_BOOL CXFA_FFComboBox::SelectAll() {
442   return ((CFWL_ComboBox*)m_pNormalWidget)->EditSelectAll();
443 }
Delete()444 FX_BOOL CXFA_FFComboBox::Delete() {
445   return ((CFWL_ComboBox*)m_pNormalWidget)->EditDelete();
446 }
DeSelect()447 FX_BOOL CXFA_FFComboBox::DeSelect() {
448   return ((CFWL_ComboBox*)m_pNormalWidget)->EditDeSelect();
449 }
SetItemState(int32_t nIndex,FX_BOOL bSelected)450 void CXFA_FFComboBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) {
451   if (bSelected) {
452     ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(nIndex);
453   } else {
454     ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1);
455   }
456   m_pNormalWidget->Update();
457   AddInvalidateRect();
458 }
InsertItem(const CFX_WideStringC & wsLabel,int32_t nIndex)459 void CXFA_FFComboBox::InsertItem(const CFX_WideStringC& wsLabel,
460                                  int32_t nIndex) {
461   ((CFWL_ComboBox*)m_pNormalWidget)->AddString(wsLabel);
462   m_pNormalWidget->Update();
463   AddInvalidateRect();
464 }
DeleteItem(int32_t nIndex)465 void CXFA_FFComboBox::DeleteItem(int32_t nIndex) {
466   if (nIndex < 0) {
467     ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAll();
468   } else {
469     ((CFWL_ComboBox*)m_pNormalWidget)->RemoveAt(nIndex);
470   }
471   m_pNormalWidget->Update();
472   AddInvalidateRect();
473 }
OnTextChanged(IFWL_Widget * pWidget,const CFX_WideString & wsChanged)474 void CXFA_FFComboBox::OnTextChanged(IFWL_Widget* pWidget,
475                                     const CFX_WideString& wsChanged) {
476   CXFA_EventParam eParam;
477   m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw);
478   eParam.m_wsChange = wsChanged;
479   FWLEventSelChange(&eParam);
480 }
OnSelectChanged(IFWL_Widget * pWidget,const CFX_Int32Array & arrSels,FX_BOOL bLButtonUp)481 void CXFA_FFComboBox::OnSelectChanged(IFWL_Widget* pWidget,
482                                       const CFX_Int32Array& arrSels,
483                                       FX_BOOL bLButtonUp) {
484   CXFA_EventParam eParam;
485   m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw);
486   FWLEventSelChange(&eParam);
487   if (m_pDataAcc->GetChoiceListCommitOn() == XFA_ATTRIBUTEENUM_Select &&
488       bLButtonUp) {
489     m_pDocView->SetFocusWidgetAcc(NULL);
490   }
491 }
OnPreOpen(IFWL_Widget * pWidget)492 void CXFA_FFComboBox::OnPreOpen(IFWL_Widget* pWidget) {
493   CXFA_EventParam eParam;
494   eParam.m_eType = XFA_EVENT_PreOpen;
495   eParam.m_pTarget = m_pDataAcc;
496   m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PreOpen, &eParam);
497 }
OnPostOpen(IFWL_Widget * pWidget)498 void CXFA_FFComboBox::OnPostOpen(IFWL_Widget* pWidget) {
499   CXFA_EventParam eParam;
500   eParam.m_eType = XFA_EVENT_PostOpen;
501   eParam.m_pTarget = m_pDataAcc;
502   m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_PostOpen, &eParam);
503 }
OnAddDoRecord(IFWL_Widget * pWidget)504 void CXFA_FFComboBox::OnAddDoRecord(IFWL_Widget* pWidget) {
505   GetDoc()->GetDocProvider()->AddDoRecord(this);
506 }
OnProcessMessage(CFWL_Message * pMessage)507 int32_t CXFA_FFComboBox::OnProcessMessage(CFWL_Message* pMessage) {
508   return m_pOldDelegate->OnProcessMessage(pMessage);
509 }
OnProcessEvent(CFWL_Event * pEvent)510 FWL_ERR CXFA_FFComboBox::OnProcessEvent(CFWL_Event* pEvent) {
511   CXFA_FFField::OnProcessEvent(pEvent);
512   FX_DWORD dwEventID = pEvent->GetClassID();
513   switch (dwEventID) {
514     case FWL_EVTHASH_CMB_SelChanged: {
515       CFWL_EvtCmbSelChanged* postEvent = (CFWL_EvtCmbSelChanged*)pEvent;
516       OnSelectChanged(m_pNormalWidget->GetWidget(), postEvent->iArraySels,
517                       postEvent->bLButtonUp);
518       break;
519     }
520     case FWL_EVTHASH_CMB_EditChanged: {
521       CFX_WideString wsChanged;
522       OnTextChanged(m_pNormalWidget->GetWidget(), wsChanged);
523       break;
524     }
525     case FWL_EVTHASH_CMB_PreDropDown: {
526       OnPreOpen(m_pNormalWidget->GetWidget());
527       break;
528     }
529     case FWL_EVTHASH_CMB_PostDropDown: {
530       OnPostOpen(m_pNormalWidget->GetWidget());
531       break;
532     }
533     default: {}
534   }
535   return m_pOldDelegate->OnProcessEvent(pEvent);
536 }
OnDrawWidget(CFX_Graphics * pGraphics,const CFX_Matrix * pMatrix)537 FWL_ERR CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics,
538                                       const CFX_Matrix* pMatrix) {
539   return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix);
540 }
541