OLD | NEW |
1 // Copyright 2014 PDFium Authors. All rights reserved. | 1 // Copyright 2014 PDFium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com | 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
6 | 6 |
7 #include "xfa/fxfa/app/xfa_ffchoicelist.h" | 7 #include "xfa/fxfa/app/xfa_ffchoicelist.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 int32_t iItems = pdfium::CollectionSize<int32_t>(wsLabelArray); | 58 int32_t iItems = pdfium::CollectionSize<int32_t>(wsLabelArray); |
59 for (int32_t i = 0; i < iItems; i++) { | 59 for (int32_t i = 0; i < iItems; i++) { |
60 pListBox->AddString(wsLabelArray[i].AsStringC()); | 60 pListBox->AddString(wsLabelArray[i].AsStringC()); |
61 } | 61 } |
62 uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; | 62 uint32_t dwExtendedStyle = FWL_STYLEEXT_LTB_ShowScrollBarFocus; |
63 if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { | 63 if (m_pDataAcc->GetChoiceListOpen() == XFA_ATTRIBUTEENUM_MultiSelect) { |
64 dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; | 64 dwExtendedStyle |= FWL_STYLEEXT_LTB_MultiSelection; |
65 } | 65 } |
66 dwExtendedStyle |= GetAlignment(); | 66 dwExtendedStyle |= GetAlignment(); |
67 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 67 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
68 CFX_Int32Array iSelArray; | 68 CFX_ArrayTemplate<int32_t> iSelArray; |
69 m_pDataAcc->GetSelectedItems(iSelArray); | 69 m_pDataAcc->GetSelectedItems(iSelArray); |
70 int32_t iSelCount = iSelArray.GetSize(); | 70 int32_t iSelCount = iSelArray.GetSize(); |
71 for (int32_t j = 0; j < iSelCount; j++) { | 71 for (int32_t j = 0; j < iSelCount; j++) { |
72 CFWL_ListItem* item = pListBox->GetItem(nullptr, iSelArray[j]); | 72 CFWL_ListItem* item = pListBox->GetItem(nullptr, iSelArray[j]); |
73 pListBox->SetSelItem(item, true); | 73 pListBox->SetSelItem(item, true); |
74 } | 74 } |
75 m_pNormalWidget->UnlockUpdate(); | 75 m_pNormalWidget->UnlockUpdate(); |
76 return CXFA_FFField::LoadWidget(); | 76 return CXFA_FFField::LoadWidget(); |
77 } | 77 } |
78 | 78 |
79 bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { | 79 bool CXFA_FFListBox::OnKillFocus(CXFA_FFWidget* pNewFocus) { |
80 if (!ProcessCommittedData()) | 80 if (!ProcessCommittedData()) |
81 UpdateFWLData(); | 81 UpdateFWLData(); |
82 CXFA_FFField::OnKillFocus(pNewFocus); | 82 CXFA_FFField::OnKillFocus(pNewFocus); |
83 return true; | 83 return true; |
84 } | 84 } |
85 | 85 |
86 bool CXFA_FFListBox::CommitData() { | 86 bool CXFA_FFListBox::CommitData() { |
87 CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget); | 87 CFWL_ListBox* pListBox = static_cast<CFWL_ListBox*>(m_pNormalWidget); |
88 int32_t iSels = pListBox->CountSelItems(); | 88 int32_t iSels = pListBox->CountSelItems(); |
89 CFX_Int32Array iSelArray; | 89 CFX_ArrayTemplate<int32_t> iSelArray; |
90 for (int32_t i = 0; i < iSels; ++i) | 90 for (int32_t i = 0; i < iSels; ++i) |
91 iSelArray.Add(pListBox->GetSelIndex(i)); | 91 iSelArray.Add(pListBox->GetSelIndex(i)); |
92 m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); | 92 m_pDataAcc->SetSelectedItems(iSelArray, true, false, true); |
93 return true; | 93 return true; |
94 } | 94 } |
95 | 95 |
96 bool CXFA_FFListBox::IsDataChanged() { | 96 bool CXFA_FFListBox::IsDataChanged() { |
97 CFX_Int32Array iSelArray; | 97 CFX_ArrayTemplate<int32_t> iSelArray; |
98 m_pDataAcc->GetSelectedItems(iSelArray); | 98 m_pDataAcc->GetSelectedItems(iSelArray); |
99 int32_t iOldSels = iSelArray.GetSize(); | 99 int32_t iOldSels = iSelArray.GetSize(); |
100 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; | 100 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; |
101 int32_t iSels = pListBox->CountSelItems(); | 101 int32_t iSels = pListBox->CountSelItems(); |
102 if (iOldSels != iSels) | 102 if (iOldSels != iSels) |
103 return true; | 103 return true; |
104 | 104 |
105 for (int32_t i = 0; i < iSels; ++i) { | 105 for (int32_t i = 0; i < iSels; ++i) { |
106 CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); | 106 CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); |
107 if (!(hlistItem->GetStates() & FWL_ITEMSTATE_LTB_Selected)) | 107 if (!(hlistItem->GetStates() & FWL_ITEMSTATE_LTB_Selected)) |
(...skipping 25 matching lines...) Expand all Loading... |
133 } | 133 } |
134 } | 134 } |
135 return dwExtendedStyle; | 135 return dwExtendedStyle; |
136 } | 136 } |
137 bool CXFA_FFListBox::UpdateFWLData() { | 137 bool CXFA_FFListBox::UpdateFWLData() { |
138 if (!m_pNormalWidget) { | 138 if (!m_pNormalWidget) { |
139 return false; | 139 return false; |
140 } | 140 } |
141 CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); | 141 CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); |
142 CFX_ArrayTemplate<CFWL_ListItem*> selItemArray; | 142 CFX_ArrayTemplate<CFWL_ListItem*> selItemArray; |
143 CFX_Int32Array iSelArray; | 143 CFX_ArrayTemplate<int32_t> iSelArray; |
144 m_pDataAcc->GetSelectedItems(iSelArray); | 144 m_pDataAcc->GetSelectedItems(iSelArray); |
145 int32_t iSelCount = iSelArray.GetSize(); | 145 int32_t iSelCount = iSelArray.GetSize(); |
146 for (int32_t j = 0; j < iSelCount; j++) { | 146 for (int32_t j = 0; j < iSelCount; j++) { |
147 CFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); | 147 CFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); |
148 selItemArray.Add(lpItemSel); | 148 selItemArray.Add(lpItemSel); |
149 } | 149 } |
150 pListBox->SetSelItem(pListBox->GetSelItem(-1), false); | 150 pListBox->SetSelItem(pListBox->GetSelItem(-1), false); |
151 for (int32_t i = 0; i < iSelCount; i++) { | 151 for (int32_t i = 0; i < iSelCount; i++) { |
152 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], true); | 152 ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(selItemArray[i], true); |
153 } | 153 } |
154 m_pNormalWidget->Update(); | 154 m_pNormalWidget->Update(); |
155 return true; | 155 return true; |
156 } | 156 } |
157 void CXFA_FFListBox::OnSelectChanged(CFWL_Widget* pWidget, | 157 void CXFA_FFListBox::OnSelectChanged( |
158 const CFX_Int32Array& arrSels) { | 158 CFWL_Widget* pWidget, |
| 159 const CFX_ArrayTemplate<int32_t>& arrSels) { |
159 CXFA_EventParam eParam; | 160 CXFA_EventParam eParam; |
160 eParam.m_eType = XFA_EVENT_Change; | 161 eParam.m_eType = XFA_EVENT_Change; |
161 eParam.m_pTarget = m_pDataAcc; | 162 eParam.m_pTarget = m_pDataAcc; |
162 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); | 163 m_pDataAcc->GetValue(eParam.m_wsPrevText, XFA_VALUEPICTURE_Raw); |
163 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; | 164 CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; |
164 int32_t iSels = pListBox->CountSelItems(); | 165 int32_t iSels = pListBox->CountSelItems(); |
165 if (iSels > 0) { | 166 if (iSels > 0) { |
166 CFWL_ListItem* item = pListBox->GetSelItem(0); | 167 CFWL_ListItem* item = pListBox->GetSelItem(0); |
167 eParam.m_wsNewText = item ? item->GetText() : L""; | 168 eParam.m_wsNewText = item ? item->GetText() : L""; |
168 } | 169 } |
(...skipping 25 matching lines...) Expand all Loading... |
194 } | 195 } |
195 | 196 |
196 void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { | 197 void CXFA_FFListBox::OnProcessMessage(CFWL_Message* pMessage) { |
197 m_pOldDelegate->OnProcessMessage(pMessage); | 198 m_pOldDelegate->OnProcessMessage(pMessage); |
198 } | 199 } |
199 | 200 |
200 void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { | 201 void CXFA_FFListBox::OnProcessEvent(CFWL_Event* pEvent) { |
201 CXFA_FFField::OnProcessEvent(pEvent); | 202 CXFA_FFField::OnProcessEvent(pEvent); |
202 switch (pEvent->GetType()) { | 203 switch (pEvent->GetType()) { |
203 case CFWL_Event::Type::SelectChanged: { | 204 case CFWL_Event::Type::SelectChanged: { |
204 CFX_Int32Array arrSels; | 205 CFX_ArrayTemplate<int32_t> arrSels; |
205 OnSelectChanged(m_pNormalWidget, arrSels); | 206 OnSelectChanged(m_pNormalWidget, arrSels); |
206 break; | 207 break; |
207 } | 208 } |
208 default: | 209 default: |
209 break; | 210 break; |
210 } | 211 } |
211 m_pOldDelegate->OnProcessEvent(pEvent); | 212 m_pOldDelegate->OnProcessEvent(pEvent); |
212 } | 213 } |
213 void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, | 214 void CXFA_FFListBox::OnDrawWidget(CFX_Graphics* pGraphics, |
214 const CFX_Matrix* pMatrix) { | 215 const CFX_Matrix* pMatrix) { |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
249 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 250 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
250 m_pNormalWidget->SetDelegate(this); | 251 m_pNormalWidget->SetDelegate(this); |
251 m_pNormalWidget->LockUpdate(); | 252 m_pNormalWidget->LockUpdate(); |
252 | 253 |
253 std::vector<CFX_WideString> wsLabelArray; | 254 std::vector<CFX_WideString> wsLabelArray; |
254 m_pDataAcc->GetChoiceListItems(wsLabelArray, false); | 255 m_pDataAcc->GetChoiceListItems(wsLabelArray, false); |
255 int32_t iItems = pdfium::CollectionSize<int32_t>(wsLabelArray); | 256 int32_t iItems = pdfium::CollectionSize<int32_t>(wsLabelArray); |
256 for (int32_t i = 0; i < iItems; i++) { | 257 for (int32_t i = 0; i < iItems; i++) { |
257 pComboBox->AddString(wsLabelArray[i].AsStringC()); | 258 pComboBox->AddString(wsLabelArray[i].AsStringC()); |
258 } | 259 } |
259 CFX_Int32Array iSelArray; | 260 CFX_ArrayTemplate<int32_t> iSelArray; |
260 m_pDataAcc->GetSelectedItems(iSelArray); | 261 m_pDataAcc->GetSelectedItems(iSelArray); |
261 int32_t iSelCount = iSelArray.GetSize(); | 262 int32_t iSelCount = iSelArray.GetSize(); |
262 if (iSelCount > 0) { | 263 if (iSelCount > 0) { |
263 pComboBox->SetCurSel(iSelArray[0]); | 264 pComboBox->SetCurSel(iSelArray[0]); |
264 } else { | 265 } else { |
265 CFX_WideString wsText; | 266 CFX_WideString wsText; |
266 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); | 267 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); |
267 pComboBox->SetEditText(wsText); | 268 pComboBox->SetEditText(wsText); |
268 } | 269 } |
269 UpdateWidgetProperty(); | 270 UpdateWidgetProperty(); |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
376 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; | 377 dwExtendedStyle |= FWL_STYLEEXT_CMB_EditVNear; |
377 break; | 378 break; |
378 } | 379 } |
379 } | 380 } |
380 return dwExtendedStyle; | 381 return dwExtendedStyle; |
381 } | 382 } |
382 bool CXFA_FFComboBox::UpdateFWLData() { | 383 bool CXFA_FFComboBox::UpdateFWLData() { |
383 if (!m_pNormalWidget) { | 384 if (!m_pNormalWidget) { |
384 return false; | 385 return false; |
385 } | 386 } |
386 CFX_Int32Array iSelArray; | 387 CFX_ArrayTemplate<int32_t> iSelArray; |
387 m_pDataAcc->GetSelectedItems(iSelArray); | 388 m_pDataAcc->GetSelectedItems(iSelArray); |
388 int32_t iSelCount = iSelArray.GetSize(); | 389 int32_t iSelCount = iSelArray.GetSize(); |
389 if (iSelCount > 0) { | 390 if (iSelCount > 0) { |
390 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]); | 391 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(iSelArray[0]); |
391 } else { | 392 } else { |
392 CFX_WideString wsText; | 393 CFX_WideString wsText; |
393 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); | 394 ((CFWL_ComboBox*)m_pNormalWidget)->SetCurSel(-1); |
394 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); | 395 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Raw); |
395 ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText); | 396 ((CFWL_ComboBox*)m_pNormalWidget)->SetEditText(wsText); |
396 } | 397 } |
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
532 default: | 533 default: |
533 break; | 534 break; |
534 } | 535 } |
535 m_pOldDelegate->OnProcessEvent(pEvent); | 536 m_pOldDelegate->OnProcessEvent(pEvent); |
536 } | 537 } |
537 | 538 |
538 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, | 539 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, |
539 const CFX_Matrix* pMatrix) { | 540 const CFX_Matrix* pMatrix) { |
540 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 541 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
541 } | 542 } |
OLD | NEW |