| 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 "../../include/formfiller/FormFiller.h" | 7 #include "../../include/formfiller/FormFiller.h" |
| 8 #include "../../include/formfiller/FFL_FormFiller.h" | 8 #include "../../include/formfiller/FFL_FormFiller.h" |
| 9 #include "../../include/formfiller/FFL_ListBox.h" | 9 #include "../../include/formfiller/FFL_ListBox.h" |
| 10 //#include "../../include/formfiller/FFL_Module.h" | 10 //#include "../../include/formfiller/FFL_Module.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); | 66 CFFL_IFormFiller* pIFormFiller = m_pApp->GetIFormFiller(); |
| 67 pWnd->SetFillerNotify(pIFormFiller); | 67 pWnd->SetFillerNotify(pIFormFiller); |
| 68 | 68 |
| 69 for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++) | 69 for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++) |
| 70 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); | 70 pWnd->AddString(m_pWidget->GetOptionLabel(i).c_str()); |
| 71 | 71 |
| 72 if (pWnd->HasFlag(PLBS_MULTIPLESEL)) | 72 if (pWnd->HasFlag(PLBS_MULTIPLESEL)) |
| 73 { | 73 { |
| 74 m_OriginSelections.clear(); | 74 m_OriginSelections.clear(); |
| 75 | 75 |
| 76 » » bool bSetCaret = false; | 76 » » FX_BOOL bSetCaret = FALSE; |
| 77 for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++) | 77 for (int32_t i=0,sz=m_pWidget->CountOptions(); i<sz; i++) |
| 78 { | 78 { |
| 79 if (m_pWidget->IsOptionSelected(i)) | 79 if (m_pWidget->IsOptionSelected(i)) |
| 80 { | 80 { |
| 81 if (!bSetCaret) | 81 if (!bSetCaret) |
| 82 { | 82 { |
| 83 pWnd->SetCaret(i); | 83 pWnd->SetCaret(i); |
| 84 » » » » » bSetCaret = true; | 84 » » » » » bSetCaret = TRUE; |
| 85 } | 85 } |
| 86 pWnd->Select(i); | 86 pWnd->Select(i); |
| 87 m_OriginSelections.insert(i); | 87 m_OriginSelections.insert(i); |
| 88 } | 88 } |
| 89 } | 89 } |
| 90 } | 90 } |
| 91 else | 91 else |
| 92 { | 92 { |
| 93 for (int i=0,sz=m_pWidget->CountOptions(); i<sz; i++) | 93 for (int i=0,sz=m_pWidget->CountOptions(); i<sz; i++) |
| 94 { | 94 { |
| 95 if (m_pWidget->IsOptionSelected(i)) | 95 if (m_pWidget->IsOptionSelected(i)) |
| 96 { | 96 { |
| 97 pWnd->Select(i); | 97 pWnd->Select(i); |
| 98 break; | 98 break; |
| 99 } | 99 } |
| 100 } | 100 } |
| 101 } | 101 } |
| 102 | 102 |
| 103 pWnd->SetTopVisibleIndex(m_pWidget->GetTopVisibleIndex()); | 103 pWnd->SetTopVisibleIndex(m_pWidget->GetTopVisibleIndex()); |
| 104 | 104 |
| 105 return pWnd; | 105 return pWnd; |
| 106 } | 106 } |
| 107 | 107 |
| 108 | 108 |
| 109 bool» CFFL_ListBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlag
s) | 109 FX_BOOL»CFFL_ListBox::OnChar(CPDFSDK_Annot* pAnnot, FX_UINT nChar, FX_UINT nFlag
s) |
| 110 { | 110 { |
| 111 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); | 111 return CFFL_FormFiller::OnChar(pAnnot, nChar, nFlags); |
| 112 } | 112 } |
| 113 | 113 |
| 114 bool CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView) | 114 FX_BOOL CFFL_ListBox::IsDataChanged(CPDFSDK_PageView* pPageView) |
| 115 { | 115 { |
| 116 CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, false); | 116 CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALSE); |
| 117 if (!pListBox) | 117 if (!pListBox) |
| 118 return false; | 118 return FALSE; |
| 119 | 119 |
| 120 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { | 120 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) { |
| 121 int nSelCount = 0; | 121 int nSelCount = 0; |
| 122 for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; ++i) { | 122 for (int32_t i = 0, sz = pListBox->GetCount(); i < sz; ++i) { |
| 123 if (pListBox->IsItemSelected(i)) { | 123 if (pListBox->IsItemSelected(i)) { |
| 124 if (m_OriginSelections.count(i) == 0) | 124 if (m_OriginSelections.count(i) == 0) |
| 125 return true; | 125 return TRUE; |
| 126 | 126 |
| 127 nSelCount++; | 127 nSelCount++; |
| 128 } | 128 } |
| 129 } | 129 } |
| 130 | 130 |
| 131 return nSelCount != m_OriginSelections.size(); | 131 return nSelCount != m_OriginSelections.size(); |
| 132 } | 132 } |
| 133 return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0); | 133 return pListBox->GetCurSel() != m_pWidget->GetSelectedIndex(0); |
| 134 } | 134 } |
| 135 | 135 |
| 136 void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) | 136 void CFFL_ListBox::SaveData(CPDFSDK_PageView* pPageView) |
| 137 { | 137 { |
| 138 ASSERT(m_pWidget != NULL); | 138 ASSERT(m_pWidget != NULL); |
| 139 | 139 |
| 140 » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, fals
e)) | 140 » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALS
E)) |
| 141 { | 141 { |
| 142 CFX_IntArray aOldSelect, aNewSelect; | 142 CFX_IntArray aOldSelect, aNewSelect; |
| 143 | 143 |
| 144 { | 144 { |
| 145 for (int i=0,sz=m_pWidget->CountOptions(); i<sz; i++) | 145 for (int i=0,sz=m_pWidget->CountOptions(); i<sz; i++) |
| 146 { | 146 { |
| 147 if (m_pWidget->IsOptionSelected(i)) | 147 if (m_pWidget->IsOptionSelected(i)) |
| 148 { | 148 { |
| 149 aOldSelect.Add(i); | 149 aOldSelect.Add(i); |
| 150 } | 150 } |
| 151 } | 151 } |
| 152 } | 152 } |
| 153 | 153 |
| 154 | 154 |
| 155 int32_t nNewTopIndex = pListBox->GetTopVisibleIndex(); | 155 int32_t nNewTopIndex = pListBox->GetTopVisibleIndex(); |
| 156 | 156 |
| 157 » » m_pWidget->ClearSelection(false); | 157 » » m_pWidget->ClearSelection(FALSE); |
| 158 | 158 |
| 159 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) | 159 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) |
| 160 { | 160 { |
| 161 for (int32_t i=0,sz=pListBox->GetCount(); i<sz; i++) | 161 for (int32_t i=0,sz=pListBox->GetCount(); i<sz; i++) |
| 162 { | 162 { |
| 163 if (pListBox->IsItemSelected(i)) | 163 if (pListBox->IsItemSelected(i)) |
| 164 { | 164 { |
| 165 » » » » » m_pWidget->SetOptionSelection(i, true, f
alse); | 165 » » » » » m_pWidget->SetOptionSelection(i, TRUE, F
ALSE); |
| 166 aNewSelect.Add(i); | 166 aNewSelect.Add(i); |
| 167 } | 167 } |
| 168 } | 168 } |
| 169 } | 169 } |
| 170 else | 170 else |
| 171 { | 171 { |
| 172 » » » m_pWidget->SetOptionSelection(pListBox->GetCurSel(), tru
e, false); | 172 » » » m_pWidget->SetOptionSelection(pListBox->GetCurSel(), TRU
E, FALSE); |
| 173 aNewSelect.Add(pListBox->GetCurSel()); | 173 aNewSelect.Add(pListBox->GetCurSel()); |
| 174 } | 174 } |
| 175 | 175 |
| 176 m_pWidget->SetTopVisibleIndex(nNewTopIndex); | 176 m_pWidget->SetTopVisibleIndex(nNewTopIndex); |
| 177 » » m_pWidget->ResetFieldAppearance(true); | 177 » » m_pWidget->ResetFieldAppearance(TRUE); |
| 178 m_pWidget->UpdateField(); | 178 m_pWidget->UpdateField(); |
| 179 SetChangeMark(); | 179 SetChangeMark(); |
| 180 } | 180 } |
| 181 } | 181 } |
| 182 | 182 |
| 183 void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAct
ionType type, | 183 void CFFL_ListBox::GetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAct
ionType type, |
| 184 PDFSDK_FieldAction& fa) | 184 PDFSDK_FieldAction& fa) |
| 185 { | 185 { |
| 186 switch (type) | 186 switch (type) |
| 187 { | 187 { |
| 188 case CPDF_AAction::Validate: | 188 case CPDF_AAction::Validate: |
| 189 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) | 189 if (m_pWidget->GetFieldFlags() & FIELDFLAG_MULTISELECT) |
| 190 { | 190 { |
| 191 fa.sValue = L""; | 191 fa.sValue = L""; |
| 192 } | 192 } |
| 193 else | 193 else |
| 194 { | 194 { |
| 195 » » » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow
(pPageView, false)) | 195 » » » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow
(pPageView, FALSE)) |
| 196 { | 196 { |
| 197 ASSERT(m_pWidget != NULL); | 197 ASSERT(m_pWidget != NULL); |
| 198 int32_t nCurSel = pListBox->GetCurSel(); | 198 int32_t nCurSel = pListBox->GetCurSel(); |
| 199 if (nCurSel >= 0) | 199 if (nCurSel >= 0) |
| 200 fa.sValue = m_pWidget->GetOptionLabel(nC
urSel); | 200 fa.sValue = m_pWidget->GetOptionLabel(nC
urSel); |
| 201 } | 201 } |
| 202 } | 202 } |
| 203 break; | 203 break; |
| 204 case CPDF_AAction::LoseFocus: | 204 case CPDF_AAction::LoseFocus: |
| 205 case CPDF_AAction::GetFocus: | 205 case CPDF_AAction::GetFocus: |
| (...skipping 17 matching lines...) Expand all Loading... |
| 223 | 223 |
| 224 void CFFL_ListBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAct
ionType type, | 224 void CFFL_ListBox::SetActionData(CPDFSDK_PageView* pPageView, CPDF_AAction::AAct
ionType type, |
| 225 const PDFSDK_Fie
ldAction& fa) | 225 const PDFSDK_Fie
ldAction& fa) |
| 226 { | 226 { |
| 227 } | 227 } |
| 228 | 228 |
| 229 void CFFL_ListBox::SaveState(CPDFSDK_PageView* pPageView) | 229 void CFFL_ListBox::SaveState(CPDFSDK_PageView* pPageView) |
| 230 { | 230 { |
| 231 ASSERT(pPageView != NULL); | 231 ASSERT(pPageView != NULL); |
| 232 | 232 |
| 233 » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, fals
e)) | 233 » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALS
E)) |
| 234 { | 234 { |
| 235 for (int32_t i=0,sz=pListBox->GetCount(); i<sz; i++) | 235 for (int32_t i=0,sz=pListBox->GetCount(); i<sz; i++) |
| 236 { | 236 { |
| 237 if (pListBox->IsItemSelected(i)) | 237 if (pListBox->IsItemSelected(i)) |
| 238 { | 238 { |
| 239 m_State.Add(i); | 239 m_State.Add(i); |
| 240 } | 240 } |
| 241 } | 241 } |
| 242 } | 242 } |
| 243 } | 243 } |
| 244 | 244 |
| 245 void CFFL_ListBox::RestoreState(CPDFSDK_PageView* pPageView) | 245 void CFFL_ListBox::RestoreState(CPDFSDK_PageView* pPageView) |
| 246 { | 246 { |
| 247 » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, fals
e)) | 247 » if (CPWL_ListBox* pListBox = (CPWL_ListBox*)GetPDFWindow(pPageView, FALS
E)) |
| 248 { | 248 { |
| 249 for (int i=0,sz=m_State.GetSize(); i<sz; i++) | 249 for (int i=0,sz=m_State.GetSize(); i<sz; i++) |
| 250 pListBox->Select(m_State[i]); | 250 pListBox->Select(m_State[i]); |
| 251 } | 251 } |
| 252 } | 252 } |
| 253 | 253 |
| 254 CPWL_Wnd* CFFL_ListBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, bool bRestor
eValue) | 254 CPWL_Wnd* CFFL_ListBox::ResetPDFWindow(CPDFSDK_PageView* pPageView, FX_BOOL bRes
toreValue) |
| 255 { | 255 { |
| 256 if (bRestoreValue) | 256 if (bRestoreValue) |
| 257 SaveState(pPageView); | 257 SaveState(pPageView); |
| 258 | 258 |
| 259 DestroyPDFWindow(pPageView); | 259 DestroyPDFWindow(pPageView); |
| 260 | 260 |
| 261 CPWL_Wnd* pRet = NULL; | 261 CPWL_Wnd* pRet = NULL; |
| 262 | 262 |
| 263 if (bRestoreValue) | 263 if (bRestoreValue) |
| 264 { | 264 { |
| 265 RestoreState(pPageView); | 265 RestoreState(pPageView); |
| 266 » » pRet = GetPDFWindow(pPageView, false); | 266 » » pRet = GetPDFWindow(pPageView, FALSE); |
| 267 } | 267 } |
| 268 else | 268 else |
| 269 » » pRet = GetPDFWindow(pPageView, true); | 269 » » pRet = GetPDFWindow(pPageView, TRUE); |
| 270 | 270 |
| 271 m_pWidget->UpdateField(); | 271 m_pWidget->UpdateField(); |
| 272 | 272 |
| 273 return pRet; | 273 return pRet; |
| 274 } | 274 } |
| 275 | 275 |
| 276 void CFFL_ListBox::OnKeyStroke(bool bKeyDown, FX_DWORD nFlag) | 276 void CFFL_ListBox::OnKeyStroke(FX_BOOL bKeyDown, FX_DWORD nFlag) |
| 277 { | 277 { |
| 278 ASSERT(m_pWidget != NULL); | 278 ASSERT(m_pWidget != NULL); |
| 279 | 279 |
| 280 int nFlags = m_pWidget->GetFieldFlags(); | 280 int nFlags = m_pWidget->GetFieldFlags(); |
| 281 | 281 |
| 282 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) | 282 if (nFlags & FIELDFLAG_COMMITONSELCHANGE) |
| 283 { | 283 { |
| 284 if (m_bValid) | 284 if (m_bValid) |
| 285 { | 285 { |
| 286 CPDFSDK_PageView* pPageView = GetCurPageView(); | 286 CPDFSDK_PageView* pPageView = GetCurPageView(); |
| 287 ASSERT(pPageView != NULL); | 287 ASSERT(pPageView != NULL); |
| 288 | 288 |
| 289 if (CommitData(pPageView, nFlag)) | 289 if (CommitData(pPageView, nFlag)) |
| 290 { | 290 { |
| 291 DestroyPDFWindow(pPageView); | 291 DestroyPDFWindow(pPageView); |
| 292 » » » » m_bValid = false; | 292 » » » » m_bValid = FALSE; |
| 293 } | 293 } |
| 294 } | 294 } |
| 295 } | 295 } |
| 296 } | 296 } |
| 297 | 297 |
| OLD | NEW |