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_fftextedit.h" | 7 #include "xfa/fxfa/app/xfa_fftextedit.h" |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
396 const CFX_ByteStringC& sWord, | 396 const CFX_ByteStringC& sWord, |
397 std::vector<CFX_ByteString>& sSuggest) { | 397 std::vector<CFX_ByteString>& sSuggest) { |
398 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { | 398 if (m_pDataAcc->GetUIType() != XFA_ELEMENT_TextEdit) { |
399 return FALSE; | 399 return FALSE; |
400 } | 400 } |
401 return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); | 401 return GetDoc()->GetDocProvider()->GetSuggestWords(GetDoc(), sWord, sSuggest); |
402 } | 402 } |
403 int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { | 403 int32_t CXFA_FFTextEdit::OnProcessMessage(CFWL_Message* pMessage) { |
404 return m_pOldDelegate->OnProcessMessage(pMessage); | 404 return m_pOldDelegate->OnProcessMessage(pMessage); |
405 } | 405 } |
| 406 |
406 FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { | 407 FWL_ERR CXFA_FFTextEdit::OnProcessEvent(CFWL_Event* pEvent) { |
407 CXFA_FFField::OnProcessEvent(pEvent); | 408 CXFA_FFField::OnProcessEvent(pEvent); |
408 uint32_t dwEventID = pEvent->GetClassID(); | 409 switch (pEvent->GetClassID()) { |
409 switch (dwEventID) { | 410 case CFWL_EventType::TextChanged: { |
410 case FWL_EVTHASH_EDT_TextChanged: { | |
411 CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; | 411 CFWL_EvtEdtTextChanged* event = (CFWL_EvtEdtTextChanged*)pEvent; |
412 CFX_WideString wsChange; | 412 CFX_WideString wsChange; |
413 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); | 413 OnTextChanged(m_pNormalWidget->GetWidget(), wsChange, event->wsPrevText); |
414 break; | 414 break; |
415 } | 415 } |
416 case FWL_EVTHASH_EDT_TextFull: { | 416 case CFWL_EventType::TextFull: { |
417 OnTextFull(m_pNormalWidget->GetWidget()); | 417 OnTextFull(m_pNormalWidget->GetWidget()); |
418 break; | 418 break; |
419 } | 419 } |
420 case FWL_EVTHASH_EDT_CheckWord: { | 420 case CFWL_EventType::CheckWord: { |
421 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); | 421 CFX_WideString wstr(L"FWL_EVENT_DTP_SelectChanged"); |
422 CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; | 422 CFWL_EvtEdtCheckWord* event = (CFWL_EvtEdtCheckWord*)pEvent; |
423 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); | 423 event->bCheckWord = CheckWord(event->bsWord.AsStringC()); |
424 break; | 424 break; |
425 } | 425 } |
426 case FWL_EVTHASH_EDT_GetSuggestWords: { | 426 case CFWL_EventType::GetSuggestedWords: { |
427 CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; | 427 CFWL_EvtEdtGetSuggestWords* event = (CFWL_EvtEdtGetSuggestWords*)pEvent; |
428 event->bSuggestWords = GetSuggestWords(event->bsWord.AsStringC(), | 428 event->bSuggestWords = GetSuggestWords(event->bsWord.AsStringC(), |
429 event->bsArraySuggestWords); | 429 event->bsArraySuggestWords); |
430 break; | 430 break; |
431 } | 431 } |
432 default: {} | 432 default: |
| 433 break; |
433 } | 434 } |
434 return m_pOldDelegate->OnProcessEvent(pEvent); | 435 return m_pOldDelegate->OnProcessEvent(pEvent); |
435 } | 436 } |
| 437 |
436 FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 438 FWL_ERR CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
437 const CFX_Matrix* pMatrix) { | 439 const CFX_Matrix* pMatrix) { |
438 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 440 return m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
439 } | 441 } |
440 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, | 442 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, |
441 CXFA_WidgetAcc* pDataAcc) | 443 CXFA_WidgetAcc* pDataAcc) |
442 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 444 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
443 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} | 445 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} |
444 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { | 446 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { |
445 CFWL_Edit* pWidget = CFWL_Edit::Create(); | 447 CFWL_Edit* pWidget = CFWL_Edit::Create(); |
(...skipping 30 matching lines...) Expand all Loading... |
476 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; | 478 dwExtendedStyle |= FWL_STYLEEXT_EDT_CombText; |
477 pWidget->SetLimit(iNumCells); | 479 pWidget->SetLimit(iNumCells); |
478 } | 480 } |
479 dwExtendedStyle |= GetAlignment(); | 481 dwExtendedStyle |= GetAlignment(); |
480 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || | 482 if (m_pDataAcc->GetAccess() != XFA_ATTRIBUTEENUM_Open || |
481 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { | 483 !m_pDataAcc->GetDoc()->GetXFADoc()->IsInteractive()) { |
482 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; | 484 dwExtendedStyle |= FWL_STYLEEXT_EDT_ReadOnly; |
483 } | 485 } |
484 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); | 486 m_pNormalWidget->ModifyStylesEx(dwExtendedStyle, 0xFFFFFFFF); |
485 } | 487 } |
| 488 |
486 FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { | 489 FWL_ERR CXFA_FFNumericEdit::OnProcessEvent(CFWL_Event* pEvent) { |
487 uint32_t dwEventID = pEvent->GetClassID(); | 490 if (pEvent->GetClassID() == CFWL_EventType::Validate) { |
488 if (dwEventID == FWL_EVTHASH_EDT_Validate) { | |
489 CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; | 491 CFWL_EvtEdtValidate* event = (CFWL_EvtEdtValidate*)pEvent; |
490 CFX_WideString wsChange = event->wsInsert; | 492 CFX_WideString wsChange = event->wsInsert; |
491 event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); | 493 event->bValidate = OnValidate(m_pNormalWidget->GetWidget(), wsChange); |
492 return event->bValidate; | 494 return event->bValidate; |
493 } else { | |
494 return CXFA_FFTextEdit::OnProcessEvent(pEvent); | |
495 } | 495 } |
| 496 return CXFA_FFTextEdit::OnProcessEvent(pEvent); |
496 } | 497 } |
| 498 |
497 FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, | 499 FX_BOOL CXFA_FFNumericEdit::OnValidate(IFWL_Widget* pWidget, |
498 CFX_WideString& wsText) { | 500 CFX_WideString& wsText) { |
499 CFX_WideString wsPattern; | 501 CFX_WideString wsPattern; |
500 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); | 502 m_pDataAcc->GetPictureContent(wsPattern, XFA_VALUEPICTURE_Edit); |
501 if (!wsPattern.IsEmpty()) { | 503 if (!wsPattern.IsEmpty()) { |
502 return TRUE; | 504 return TRUE; |
503 } | 505 } |
504 int32_t iLeads = 0; | 506 int32_t iLeads = 0; |
505 m_pDataAcc->GetLeadDigits(iLeads); | 507 m_pDataAcc->GetLeadDigits(iLeads); |
506 int32_t iFracs = 0; | 508 int32_t iFracs = 0; |
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
778 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; | 780 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; |
779 pDateTime->SetEditText(wsDate); | 781 pDateTime->SetEditText(wsDate); |
780 pDateTime->Update(); | 782 pDateTime->Update(); |
781 GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); | 783 GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); |
782 CXFA_EventParam eParam; | 784 CXFA_EventParam eParam; |
783 eParam.m_eType = XFA_EVENT_Change; | 785 eParam.m_eType = XFA_EVENT_Change; |
784 eParam.m_pTarget = m_pDataAcc; | 786 eParam.m_pTarget = m_pDataAcc; |
785 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); | 787 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); |
786 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 788 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
787 } | 789 } |
| 790 |
788 FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 791 FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
789 uint32_t dwEventID = pEvent->GetClassID(); | 792 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { |
790 if (dwEventID == FWL_EVTHASH_DTP_SelectChanged) { | |
791 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; | 793 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; |
792 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, | 794 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, |
793 event->iDay); | 795 event->iDay); |
794 return TRUE; | 796 return TRUE; |
795 } else { | |
796 return CXFA_FFTextEdit::OnProcessEvent(pEvent); | |
797 } | 797 } |
| 798 return CXFA_FFTextEdit::OnProcessEvent(pEvent); |
798 } | 799 } |
OLD | NEW |