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 575 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
586 pWidget->Initialize(); | 586 pWidget->Initialize(); |
587 m_pNormalWidget = (CFWL_Widget*)pWidget; | 587 m_pNormalWidget = (CFWL_Widget*)pWidget; |
588 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 588 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
589 m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); | 589 m_pNormalWidget->SetPrivateData(pIWidget, this, NULL); |
590 IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 590 IFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); |
591 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 591 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
592 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); | 592 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); |
593 m_pNormalWidget->LockUpdate(); | 593 m_pNormalWidget->LockUpdate(); |
594 CFX_WideString wsText; | 594 CFX_WideString wsText; |
595 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 595 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
596 pWidget->SetEditText(wsText.AsStringC()); | 596 pWidget->SetEditText(wsText); |
597 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { | 597 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { |
598 switch (value.GetChildValueClassID()) { | 598 switch (value.GetChildValueClassID()) { |
599 case XFA_ELEMENT_Date: { | 599 case XFA_ELEMENT_Date: { |
600 if (!wsText.IsEmpty()) { | 600 if (!wsText.IsEmpty()) { |
601 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); | 601 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); |
602 CFX_Unitime date = lcValue.GetDate(); | 602 CFX_Unitime date = lcValue.GetDate(); |
603 if ((FX_UNITIME)date != 0) { | 603 if ((FX_UNITIME)date != 0) { |
604 pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); | 604 pWidget->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); |
605 } | 605 } |
606 } | 606 } |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
686 FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() { | 686 FX_BOOL CXFA_FFDateTimeEdit::UpdateFWLData() { |
687 if (!m_pNormalWidget) { | 687 if (!m_pNormalWidget) { |
688 return FALSE; | 688 return FALSE; |
689 } | 689 } |
690 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; | 690 XFA_VALUEPICTURE eType = XFA_VALUEPICTURE_Display; |
691 if (IsFocused()) { | 691 if (IsFocused()) { |
692 eType = XFA_VALUEPICTURE_Edit; | 692 eType = XFA_VALUEPICTURE_Edit; |
693 } | 693 } |
694 CFX_WideString wsText; | 694 CFX_WideString wsText; |
695 m_pDataAcc->GetValue(wsText, eType); | 695 m_pDataAcc->GetValue(wsText, eType); |
696 ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText.AsStringC()); | 696 ((CFWL_DateTimePicker*)m_pNormalWidget)->SetEditText(wsText); |
697 if (IsFocused() && !wsText.IsEmpty()) { | 697 if (IsFocused() && !wsText.IsEmpty()) { |
698 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); | 698 CXFA_LocaleValue lcValue = XFA_GetLocaleValue(m_pDataAcc); |
699 CFX_Unitime date = lcValue.GetDate(); | 699 CFX_Unitime date = lcValue.GetDate(); |
700 if (lcValue.IsValid()) { | 700 if (lcValue.IsValid()) { |
701 if ((FX_UNITIME)date != 0) { | 701 if ((FX_UNITIME)date != 0) { |
702 ((CFWL_DateTimePicker*)m_pNormalWidget) | 702 ((CFWL_DateTimePicker*)m_pNormalWidget) |
703 ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); | 703 ->SetCurSel(date.GetYear(), date.GetMonth(), date.GetDay()); |
704 } | 704 } |
705 } | 705 } |
706 } | 706 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
769 CFX_WideString wsPicture; | 769 CFX_WideString wsPicture; |
770 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); | 770 m_pDataAcc->GetPictureContent(wsPicture, XFA_VALUEPICTURE_Edit); |
771 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); | 771 CXFA_LocaleValue date(XFA_VT_DATE, GetDoc()->GetXFADoc()->GetLocalMgr()); |
772 CFX_Unitime dt; | 772 CFX_Unitime dt; |
773 dt.Set(iYear, iMonth, iDay); | 773 dt.Set(iYear, iMonth, iDay); |
774 date.SetDate(dt); | 774 date.SetDate(dt); |
775 CFX_WideString wsDate; | 775 CFX_WideString wsDate; |
776 date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), | 776 date.FormatPatterns(wsDate, wsPicture, m_pDataAcc->GetLocal(), |
777 XFA_VALUEPICTURE_Edit); | 777 XFA_VALUEPICTURE_Edit); |
778 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; | 778 CFWL_DateTimePicker* pDateTime = (CFWL_DateTimePicker*)m_pNormalWidget; |
779 pDateTime->SetEditText(wsDate.AsStringC()); | 779 pDateTime->SetEditText(wsDate); |
780 pDateTime->Update(); | 780 pDateTime->Update(); |
781 GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); | 781 GetDoc()->GetDocProvider()->SetFocusWidget(GetDoc(), NULL); |
782 CXFA_EventParam eParam; | 782 CXFA_EventParam eParam; |
783 eParam.m_eType = XFA_EVENT_Change; | 783 eParam.m_eType = XFA_EVENT_Change; |
784 eParam.m_pTarget = m_pDataAcc; | 784 eParam.m_pTarget = m_pDataAcc; |
785 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); | 785 m_pDataAcc->GetValue(eParam.m_wsNewText, XFA_VALUEPICTURE_Raw); |
786 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); | 786 m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); |
787 } | 787 } |
788 FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 788 FWL_ERR CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
789 uint32_t dwEventID = pEvent->GetClassID(); | 789 uint32_t dwEventID = pEvent->GetClassID(); |
790 if (dwEventID == FWL_EVTHASH_DTP_SelectChanged) { | 790 if (dwEventID == FWL_EVTHASH_DTP_SelectChanged) { |
791 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; | 791 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; |
792 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, | 792 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, |
793 event->iDay); | 793 event->iDay); |
794 return TRUE; | 794 return TRUE; |
795 } else { | 795 } else { |
796 return CXFA_FFTextEdit::OnProcessEvent(pEvent); | 796 return CXFA_FFTextEdit::OnProcessEvent(pEvent); |
797 } | 797 } |
798 } | 798 } |
OLD | NEW |