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 |
11 #include "xfa/fwl/core/cfwl_datetimepicker.h" | 11 #include "xfa/fwl/core/cfwl_datetimepicker.h" |
12 #include "xfa/fwl/core/cfwl_edit.h" | 12 #include "xfa/fwl/core/cfwl_edit.h" |
13 #include "xfa/fwl/core/cfwl_message.h" | 13 #include "xfa/fwl/core/cfwl_message.h" |
14 #include "xfa/fwl/core/fwl_noteimp.h" | 14 #include "xfa/fwl/core/fwl_noteimp.h" |
15 #include "xfa/fwl/core/ifwl_edit.h" | 15 #include "xfa/fwl/core/ifwl_edit.h" |
16 #include "xfa/fxfa/app/xfa_fffield.h" | 16 #include "xfa/fxfa/app/xfa_fffield.h" |
17 #include "xfa/fxfa/app/xfa_fwladapter.h" | 17 #include "xfa/fxfa/app/xfa_fwladapter.h" |
18 #include "xfa/fxfa/app/xfa_textlayout.h" | 18 #include "xfa/fxfa/app/xfa_textlayout.h" |
19 #include "xfa/fxfa/cxfa_eventparam.h" | 19 #include "xfa/fxfa/cxfa_eventparam.h" |
20 #include "xfa/fxfa/parser/xfa_localevalue.h" | 20 #include "xfa/fxfa/parser/xfa_localevalue.h" |
21 #include "xfa/fxfa/xfa_ffapp.h" | 21 #include "xfa/fxfa/xfa_ffapp.h" |
22 #include "xfa/fxfa/xfa_ffdoc.h" | 22 #include "xfa/fxfa/xfa_ffdoc.h" |
23 #include "xfa/fxfa/xfa_ffdocview.h" | 23 #include "xfa/fxfa/xfa_ffdocview.h" |
24 #include "xfa/fxfa/xfa_ffpageview.h" | 24 #include "xfa/fxfa/xfa_ffpageview.h" |
25 #include "xfa/fxfa/xfa_ffwidget.h" | 25 #include "xfa/fxfa/xfa_ffwidget.h" |
26 | 26 |
27 CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, | 27 CXFA_FFTextEdit::CXFA_FFTextEdit(CXFA_FFPageView* pPageView, |
28 CXFA_WidgetAcc* pDataAcc) | 28 CXFA_WidgetAcc* pDataAcc) |
29 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} | 29 : CXFA_FFField(pPageView, pDataAcc), m_pOldDelegate(nullptr) {} |
| 30 |
30 CXFA_FFTextEdit::~CXFA_FFTextEdit() { | 31 CXFA_FFTextEdit::~CXFA_FFTextEdit() { |
31 if (m_pNormalWidget) { | 32 if (m_pNormalWidget) { |
32 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 33 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
33 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 34 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
34 pNoteDriver->UnregisterEventTarget(pWidget); | 35 pNoteDriver->UnregisterEventTarget(pWidget); |
35 } | 36 } |
36 } | 37 } |
| 38 |
37 FX_BOOL CXFA_FFTextEdit::LoadWidget() { | 39 FX_BOOL CXFA_FFTextEdit::LoadWidget() { |
38 CFWL_Edit* pFWLEdit = new CFWL_Edit; | 40 CFWL_Edit* pFWLEdit = new CFWL_Edit(GetFWLApp()); |
39 pFWLEdit->Initialize(); | 41 pFWLEdit->Initialize(nullptr); |
40 m_pNormalWidget = pFWLEdit; | 42 m_pNormalWidget = pFWLEdit; |
41 m_pNormalWidget->SetLayoutItem(this); | 43 m_pNormalWidget->SetLayoutItem(this); |
| 44 |
42 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); | 45 IFWL_Widget* pWidget = m_pNormalWidget->GetWidget(); |
43 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 46 CFWL_NoteDriver* pNoteDriver = pWidget->GetOwnerApp()->GetNoteDriver(); |
44 pNoteDriver->RegisterEventTarget(pWidget, pWidget); | 47 pNoteDriver->RegisterEventTarget(pWidget, pWidget); |
45 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); | 48 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); |
46 m_pNormalWidget->LockUpdate(); | 49 m_pNormalWidget->LockUpdate(); |
47 UpdateWidgetProperty(); | 50 UpdateWidgetProperty(); |
48 CFX_WideString wsText; | 51 CFX_WideString wsText; |
49 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 52 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
50 pFWLEdit->SetText(wsText); | 53 pFWLEdit->SetText(wsText); |
51 m_pNormalWidget->UnlockUpdate(); | 54 m_pNormalWidget->UnlockUpdate(); |
52 return CXFA_FFField::LoadWidget(); | 55 return CXFA_FFField::LoadWidget(); |
53 } | 56 } |
(...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, | 432 void CXFA_FFTextEdit::OnDrawWidget(CFX_Graphics* pGraphics, |
430 const CFX_Matrix* pMatrix) { | 433 const CFX_Matrix* pMatrix) { |
431 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); | 434 m_pOldDelegate->OnDrawWidget(pGraphics, pMatrix); |
432 } | 435 } |
433 | 436 |
434 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, | 437 CXFA_FFNumericEdit::CXFA_FFNumericEdit(CXFA_FFPageView* pPageView, |
435 CXFA_WidgetAcc* pDataAcc) | 438 CXFA_WidgetAcc* pDataAcc) |
436 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 439 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
437 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} | 440 CXFA_FFNumericEdit::~CXFA_FFNumericEdit() {} |
438 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { | 441 FX_BOOL CXFA_FFNumericEdit::LoadWidget() { |
439 CFWL_Edit* pWidget = new CFWL_Edit; | 442 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); |
440 pWidget->Initialize(); | 443 pWidget->Initialize(nullptr); |
441 m_pNormalWidget = pWidget; | 444 m_pNormalWidget = pWidget; |
| 445 |
442 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 446 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
443 m_pNormalWidget->SetLayoutItem(this); | 447 m_pNormalWidget->SetLayoutItem(this); |
444 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 448 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); |
445 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 449 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
446 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); | 450 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); |
447 m_pNormalWidget->LockUpdate(); | 451 m_pNormalWidget->LockUpdate(); |
448 CFX_WideString wsText; | 452 CFX_WideString wsText; |
449 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 453 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
450 pWidget->SetText(wsText); | 454 pWidget->SetText(wsText); |
451 UpdateWidgetProperty(); | 455 UpdateWidgetProperty(); |
452 m_pNormalWidget->UnlockUpdate(); | 456 m_pNormalWidget->UnlockUpdate(); |
453 return CXFA_FFField::LoadWidget(); | 457 return CXFA_FFField::LoadWidget(); |
454 } | 458 } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
501 m_pDataAcc->GetFracDigits(iFracs); | 505 m_pDataAcc->GetFracDigits(iFracs); |
502 CFX_WideString wsFormat; | 506 CFX_WideString wsFormat; |
503 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); | 507 CXFA_LocaleValue widgetValue = XFA_GetLocaleValue(m_pDataAcc); |
504 widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); | 508 widgetValue.GetNumbericFormat(wsFormat, iLeads, iFracs); |
505 return widgetValue.ValidateNumericTemp(wsText, wsFormat, | 509 return widgetValue.ValidateNumericTemp(wsText, wsFormat, |
506 m_pDataAcc->GetLocal()); | 510 m_pDataAcc->GetLocal()); |
507 } | 511 } |
508 CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, | 512 CXFA_FFPasswordEdit::CXFA_FFPasswordEdit(CXFA_FFPageView* pPageView, |
509 CXFA_WidgetAcc* pDataAcc) | 513 CXFA_WidgetAcc* pDataAcc) |
510 : CXFA_FFTextEdit(pPageView, pDataAcc) {} | 514 : CXFA_FFTextEdit(pPageView, pDataAcc) {} |
| 515 |
511 CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} | 516 CXFA_FFPasswordEdit::~CXFA_FFPasswordEdit() {} |
| 517 |
512 FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { | 518 FX_BOOL CXFA_FFPasswordEdit::LoadWidget() { |
513 CFWL_Edit* pWidget = new CFWL_Edit; | 519 CFWL_Edit* pWidget = new CFWL_Edit(GetFWLApp()); |
514 pWidget->Initialize(); | 520 pWidget->Initialize(nullptr); |
515 m_pNormalWidget = pWidget; | 521 m_pNormalWidget = pWidget; |
516 m_pNormalWidget->SetLayoutItem(this); | 522 m_pNormalWidget->SetLayoutItem(this); |
| 523 |
517 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 524 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
518 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 525 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); |
519 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 526 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
520 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); | 527 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); |
521 m_pNormalWidget->LockUpdate(); | 528 m_pNormalWidget->LockUpdate(); |
522 CFX_WideString wsText; | 529 CFX_WideString wsText; |
523 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 530 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
524 pWidget->SetText(wsText); | 531 pWidget->SetText(wsText); |
525 UpdateWidgetProperty(); | 532 UpdateWidgetProperty(); |
526 m_pNormalWidget->UnlockUpdate(); | 533 m_pNormalWidget->UnlockUpdate(); |
527 return CXFA_FFField::LoadWidget(); | 534 return CXFA_FFField::LoadWidget(); |
528 } | 535 } |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
569 return FALSE; | 576 return FALSE; |
570 } | 577 } |
571 CFX_RectF rtWidget; | 578 CFX_RectF rtWidget; |
572 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); | 579 ((CFWL_DateTimePicker*)m_pNormalWidget)->GetBBox(rtWidget); |
573 if (rtWidget.Contains(fx, fy)) { | 580 if (rtWidget.Contains(fx, fy)) { |
574 return TRUE; | 581 return TRUE; |
575 } | 582 } |
576 return FALSE; | 583 return FALSE; |
577 } | 584 } |
578 FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { | 585 FX_BOOL CXFA_FFDateTimeEdit::LoadWidget() { |
579 CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker; | 586 CFWL_DateTimePicker* pWidget = new CFWL_DateTimePicker(GetFWLApp()); |
580 pWidget->Initialize(); | 587 pWidget->Initialize(nullptr); |
581 m_pNormalWidget = pWidget; | 588 m_pNormalWidget = pWidget; |
582 m_pNormalWidget->SetLayoutItem(this); | 589 m_pNormalWidget->SetLayoutItem(this); |
583 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); | 590 IFWL_Widget* pIWidget = m_pNormalWidget->GetWidget(); |
584 CFWL_NoteDriver* pNoteDriver = FWL_GetApp()->GetNoteDriver(); | 591 CFWL_NoteDriver* pNoteDriver = pIWidget->GetOwnerApp()->GetNoteDriver(); |
585 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); | 592 pNoteDriver->RegisterEventTarget(pIWidget, pIWidget); |
586 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); | 593 m_pOldDelegate = m_pNormalWidget->SetDelegate(this); |
587 m_pNormalWidget->LockUpdate(); | 594 m_pNormalWidget->LockUpdate(); |
588 CFX_WideString wsText; | 595 CFX_WideString wsText; |
589 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); | 596 m_pDataAcc->GetValue(wsText, XFA_VALUEPICTURE_Display); |
590 pWidget->SetEditText(wsText); | 597 pWidget->SetEditText(wsText); |
591 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { | 598 if (CXFA_Value value = m_pDataAcc->GetFormValue()) { |
592 switch (value.GetChildValueClassID()) { | 599 switch (value.GetChildValueClassID()) { |
593 case XFA_Element::Date: { | 600 case XFA_Element::Date: { |
594 if (!wsText.IsEmpty()) { | 601 if (!wsText.IsEmpty()) { |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
782 | 789 |
783 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { | 790 void CXFA_FFDateTimeEdit::OnProcessEvent(CFWL_Event* pEvent) { |
784 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { | 791 if (pEvent->GetClassID() == CFWL_EventType::SelectChanged) { |
785 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; | 792 CFWL_Event_DtpSelectChanged* event = (CFWL_Event_DtpSelectChanged*)pEvent; |
786 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, | 793 OnSelectChanged(m_pNormalWidget->GetWidget(), event->iYear, event->iMonth, |
787 event->iDay); | 794 event->iDay); |
788 return; | 795 return; |
789 } | 796 } |
790 CXFA_FFTextEdit::OnProcessEvent(pEvent); | 797 CXFA_FFTextEdit::OnProcessEvent(pEvent); |
791 } | 798 } |
OLD | NEW |