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