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 "fpdfsdk/formfiller/cffl_combobox.h" | 7 #include "fpdfsdk/formfiller/cffl_combobox.h" |
8 | 8 |
9 #include "fpdfsdk/formfiller/cba_fontmap.h" | 9 #include "fpdfsdk/formfiller/cba_fontmap.h" |
10 #include "fpdfsdk/formfiller/cffl_formfiller.h" | 10 #include "fpdfsdk/formfiller/cffl_formfiller.h" |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
58 pWnd->SetFillerNotify(pFormFiller); | 58 pWnd->SetFillerNotify(pFormFiller); |
59 | 59 |
60 int32_t nCurSel = m_pWidget->GetSelectedIndex(0); | 60 int32_t nCurSel = m_pWidget->GetSelectedIndex(0); |
61 CFX_WideString swText; | 61 CFX_WideString swText; |
62 if (nCurSel < 0) | 62 if (nCurSel < 0) |
63 swText = m_pWidget->GetValue(); | 63 swText = m_pWidget->GetValue(); |
64 else | 64 else |
65 swText = m_pWidget->GetOptionLabel(nCurSel); | 65 swText = m_pWidget->GetOptionLabel(nCurSel); |
66 | 66 |
67 for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) { | 67 for (int32_t i = 0, sz = m_pWidget->CountOptions(); i < sz; i++) { |
68 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); | 68 pWnd->AddString(m_pWidget->GetOptionLabel(i)); |
69 } | 69 } |
70 | 70 |
71 pWnd->SetSelect(nCurSel); | 71 pWnd->SetSelect(nCurSel); |
72 pWnd->SetText(swText.c_str()); | 72 pWnd->SetText(swText); |
73 return pWnd; | 73 return pWnd; |
74 } | 74 } |
75 | 75 |
76 FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, | 76 FX_BOOL CFFL_ComboBox::OnChar(CPDFSDK_Annot* pAnnot, |
77 FX_UINT nChar, | 77 FX_UINT nChar, |
78 FX_UINT nFlags) { | 78 FX_UINT nFlags) { |
79 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 79 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
80 } | 80 } |
81 | 81 |
82 FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) { | 82 FX_BOOL CFFL_ComboBox::IsDataChanged(CPDFSDK_PageView* pPageView) { |
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 | 165 |
166 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, | 166 void CFFL_ComboBox::SetActionData(CPDFSDK_PageView* pPageView, |
167 CPDF_AAction::AActionType type, | 167 CPDF_AAction::AActionType type, |
168 const PDFSDK_FieldAction& fa) { | 168 const PDFSDK_FieldAction& fa) { |
169 switch (type) { | 169 switch (type) { |
170 case CPDF_AAction::KeyStroke: | 170 case CPDF_AAction::KeyStroke: |
171 if (CPWL_ComboBox* pComboBox = | 171 if (CPWL_ComboBox* pComboBox = |
172 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { | 172 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, FALSE))) { |
173 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { | 173 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
174 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); | 174 pEdit->SetSel(fa.nSelStart, fa.nSelEnd); |
175 pEdit->ReplaceSel(fa.sChange.c_str()); | 175 pEdit->ReplaceSel(fa.sChange); |
176 } | 176 } |
177 } | 177 } |
178 break; | 178 break; |
179 default: | 179 default: |
180 break; | 180 break; |
181 } | 181 } |
182 } | 182 } |
183 | 183 |
184 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, | 184 FX_BOOL CFFL_ComboBox::IsActionDataChanged(CPDF_AAction::AActionType type, |
185 const PDFSDK_FieldAction& faOld, | 185 const PDFSDK_FieldAction& faOld, |
(...skipping 26 matching lines...) Expand all Loading... |
212 | 212 |
213 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { | 213 void CFFL_ComboBox::RestoreState(CPDFSDK_PageView* pPageView) { |
214 ASSERT(pPageView); | 214 ASSERT(pPageView); |
215 | 215 |
216 if (CPWL_ComboBox* pComboBox = | 216 if (CPWL_ComboBox* pComboBox = |
217 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) { | 217 static_cast<CPWL_ComboBox*>(GetPDFWindow(pPageView, TRUE))) { |
218 if (m_State.nIndex >= 0) { | 218 if (m_State.nIndex >= 0) { |
219 pComboBox->SetSelect(m_State.nIndex); | 219 pComboBox->SetSelect(m_State.nIndex); |
220 } else { | 220 } else { |
221 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { | 221 if (CPWL_Edit* pEdit = pComboBox->GetEdit()) { |
222 pEdit->SetText(m_State.sValue.c_str()); | 222 pEdit->SetText(m_State.sValue); |
223 pEdit->SetSel(m_State.nStart, m_State.nEnd); | 223 pEdit->SetSel(m_State.nStart, m_State.nEnd); |
224 } | 224 } |
225 } | 225 } |
226 } | 226 } |
227 } | 227 } |
228 | 228 |
229 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, | 229 CPWL_Wnd* CFFL_ComboBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, |
230 FX_BOOL bRestoreValue) { | 230 FX_BOOL bRestoreValue) { |
231 if (bRestoreValue) | 231 if (bRestoreValue) |
232 SaveState(pPageView); | 232 SaveState(pPageView); |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
289 if (nExport >= 0) { | 289 if (nExport >= 0) { |
290 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { | 290 if (CPDF_FormField* pFormField = m_pWidget->GetFormField()) { |
291 swRet = pFormField->GetOptionValue(nExport); | 291 swRet = pFormField->GetOptionValue(nExport); |
292 if (swRet.IsEmpty()) | 292 if (swRet.IsEmpty()) |
293 swRet = pFormField->GetOptionLabel(nExport); | 293 swRet = pFormField->GetOptionLabel(nExport); |
294 } | 294 } |
295 } | 295 } |
296 | 296 |
297 return swRet; | 297 return swRet; |
298 } | 298 } |
OLD | NEW |