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 "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
10 #include "xfa/fwl/core/cfwl_app.h" | 10 #include "xfa/fwl/core/cfwl_app.h" |
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
220 | 220 |
221 bool CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, | 221 bool CXFA_FFComboBox::GetBBox(CFX_RectF& rtBox, |
222 uint32_t dwStatus, | 222 uint32_t dwStatus, |
223 bool bDrawFocus) { | 223 bool bDrawFocus) { |
224 if (bDrawFocus) | 224 if (bDrawFocus) |
225 return false; | 225 return false; |
226 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); | 226 return CXFA_FFWidget::GetBBox(rtBox, dwStatus); |
227 } | 227 } |
228 | 228 |
229 bool CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { | 229 bool CXFA_FFComboBox::PtInActiveRect(FX_FLOAT fx, FX_FLOAT fy) { |
230 if (!m_pNormalWidget) { | 230 if (!m_pNormalWidget) |
231 return false; | 231 return false; |
232 } | 232 return static_cast<CFWL_ComboBox*>(m_pNormalWidget) |
233 CFX_RectF rtWidget; | 233 ->GetBBox() |
234 ((CFWL_ComboBox*)m_pNormalWidget)->GetBBox(rtWidget); | 234 .Contains(fx, fy); |
235 if (rtWidget.Contains(fx, fy)) { | |
236 return true; | |
237 } | |
238 return false; | |
239 } | 235 } |
| 236 |
240 bool CXFA_FFComboBox::LoadWidget() { | 237 bool CXFA_FFComboBox::LoadWidget() { |
241 CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp()); | 238 CFWL_ComboBox* pComboBox = new CFWL_ComboBox(GetFWLApp()); |
242 m_pNormalWidget = (CFWL_Widget*)pComboBox; | 239 m_pNormalWidget = (CFWL_Widget*)pComboBox; |
243 m_pNormalWidget->SetLayoutItem(this); | 240 m_pNormalWidget->SetLayoutItem(this); |
244 | 241 |
245 CFWL_NoteDriver* pNoteDriver = | 242 CFWL_NoteDriver* pNoteDriver = |
246 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); | 243 m_pNormalWidget->GetOwnerApp()->GetNoteDriver(); |
247 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); | 244 pNoteDriver->RegisterEventTarget(m_pNormalWidget, m_pNormalWidget); |
248 | 245 |
249 m_pOldDelegate = m_pNormalWidget->GetDelegate(); | 246 m_pOldDelegate = m_pNormalWidget->GetDelegate(); |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(true); | 311 ((CFWL_ComboBox*)m_pNormalWidget)->OpenDropDownList(true); |
315 } | 312 } |
316 bool CXFA_FFComboBox::CommitData() { | 313 bool CXFA_FFComboBox::CommitData() { |
317 return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); | 314 return m_pDataAcc->SetValue(m_wsNewValue, XFA_VALUEPICTURE_Raw); |
318 } | 315 } |
319 bool CXFA_FFComboBox::IsDataChanged() { | 316 bool CXFA_FFComboBox::IsDataChanged() { |
320 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); | 317 CFWL_ComboBox* pFWLcombobox = ((CFWL_ComboBox*)m_pNormalWidget); |
321 CFX_WideString wsText = pFWLcombobox->GetEditText(); | 318 CFX_WideString wsText = pFWLcombobox->GetEditText(); |
322 int32_t iCursel = pFWLcombobox->GetCurSel(); | 319 int32_t iCursel = pFWLcombobox->GetCurSel(); |
323 if (iCursel >= 0) { | 320 if (iCursel >= 0) { |
324 CFX_WideString wsSel; | 321 CFX_WideString wsSel = pFWLcombobox->GetTextByIndex(iCursel); |
325 pFWLcombobox->GetTextByIndex(iCursel, wsSel); | 322 if (wsSel == wsText) |
326 if (wsSel == wsText) { | |
327 m_pDataAcc->GetChoiceListItem(wsText, iCursel, true); | 323 m_pDataAcc->GetChoiceListItem(wsText, iCursel, true); |
328 } | |
329 } | 324 } |
| 325 |
330 CFX_WideString wsOldValue; | 326 CFX_WideString wsOldValue; |
331 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); | 327 m_pDataAcc->GetValue(wsOldValue, XFA_VALUEPICTURE_Raw); |
332 if (wsOldValue != wsText) { | 328 if (wsOldValue != wsText) { |
333 m_wsNewValue = wsText; | 329 m_wsNewValue = wsText; |
334 return true; | 330 return true; |
335 } | 331 } |
336 return false; | 332 return false; |
337 } | 333 } |
338 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { | 334 void CXFA_FFComboBox::FWLEventSelChange(CXFA_EventParam* pParam) { |
339 pParam->m_eType = XFA_EVENT_Change; | 335 pParam->m_eType = XFA_EVENT_Change; |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
533 default: | 529 default: |
534 break; | 530 break; |
535 } | 531 } |
536 m_pOldDelegate->OnProcessEvent(pEvent); | 532 m_pOldDelegate->OnProcessEvent(pEvent); |
537 } | 533 } |
538 | 534 |
539 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, | 535 void CXFA_FFComboBox::OnDrawWidget(CFX_Graphics* pGraphics, |
540 const CFX_Matrix* pMatrix) { | 536 const CFX_Matrix* pMatrix) { |
541 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 537 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
542 } | 538 } |
OLD | NEW |