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/fwl/core/cfwl_combobox.h" | 7 #include "xfa/fwl/core/cfwl_combobox.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
11 #include <utility> | 11 #include <utility> |
12 | 12 |
13 #include "third_party/base/ptr_util.h" | 13 #include "third_party/base/ptr_util.h" |
14 #include "xfa/fde/cfde_txtedtengine.h" | 14 #include "xfa/fde/cfde_txtedtengine.h" |
15 #include "xfa/fde/tto/fde_textout.h" | 15 #include "xfa/fde/tto/fde_textout.h" |
16 #include "xfa/fwl/core/cfwl_app.h" | 16 #include "xfa/fwl/core/cfwl_app.h" |
17 #include "xfa/fwl/core/cfwl_evteditchanged.h" | 17 #include "xfa/fwl/core/cfwl_event.h" |
18 #include "xfa/fwl/core/cfwl_evtpostdropdown.h" | |
19 #include "xfa/fwl/core/cfwl_evtpredropdown.h" | |
20 #include "xfa/fwl/core/cfwl_evtselectchanged.h" | 18 #include "xfa/fwl/core/cfwl_evtselectchanged.h" |
21 #include "xfa/fwl/core/cfwl_evttextchanged.h" | 19 #include "xfa/fwl/core/cfwl_evttextchanged.h" |
22 #include "xfa/fwl/core/cfwl_formproxy.h" | 20 #include "xfa/fwl/core/cfwl_formproxy.h" |
23 #include "xfa/fwl/core/cfwl_listbox.h" | 21 #include "xfa/fwl/core/cfwl_listbox.h" |
24 #include "xfa/fwl/core/cfwl_msgkey.h" | 22 #include "xfa/fwl/core/cfwl_msgkey.h" |
25 #include "xfa/fwl/core/cfwl_msgkillfocus.h" | 23 #include "xfa/fwl/core/cfwl_msgkillfocus.h" |
26 #include "xfa/fwl/core/cfwl_msgmouse.h" | 24 #include "xfa/fwl/core/cfwl_msgmouse.h" |
27 #include "xfa/fwl/core/cfwl_msgsetfocus.h" | 25 #include "xfa/fwl/core/cfwl_msgsetfocus.h" |
28 #include "xfa/fwl/core/cfwl_notedriver.h" | 26 #include "xfa/fwl/core/cfwl_notedriver.h" |
29 #include "xfa/fwl/core/cfwl_themebackground.h" | 27 #include "xfa/fwl/core/cfwl_themebackground.h" |
(...skipping 362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 m_rtList.top = m_fComboFormHandler; | 390 m_rtList.top = m_fComboFormHandler; |
393 } else { | 391 } else { |
394 m_rtHandler.Set(0, m_rtList.height, m_rtList.width, m_fComboFormHandler); | 392 m_rtHandler.Set(0, m_rtList.height, m_rtList.width, m_fComboFormHandler); |
395 } | 393 } |
396 } | 394 } |
397 m_pComboBoxProxy->SetWidgetRect(m_rtProxy); | 395 m_pComboBoxProxy->SetWidgetRect(m_rtProxy); |
398 m_pComboBoxProxy->Update(); | 396 m_pComboBoxProxy->Update(); |
399 m_pListBox->SetWidgetRect(m_rtList); | 397 m_pListBox->SetWidgetRect(m_rtList); |
400 m_pListBox->Update(); | 398 m_pListBox->Update(); |
401 | 399 |
402 CFWL_EvtPreDropDown ev; | 400 CFWL_Event ev(CFWL_EventType::PreDropDown); |
403 ev.m_pSrcTarget = this; | 401 ev.m_pSrcTarget = this; |
404 DispatchEvent(&ev); | 402 DispatchEvent(&ev); |
405 | 403 |
406 m_fItemHeight = m_pListBox->GetItemHeight(); | 404 m_fItemHeight = m_pListBox->GetItemHeight(); |
407 m_pListBox->SetFocus(true); | 405 m_pListBox->SetFocus(true); |
408 m_pComboBoxProxy->DoModal(); | 406 m_pComboBoxProxy->DoModal(); |
409 m_pListBox->SetFocus(false); | 407 m_pListBox->SetFocus(false); |
410 } | 408 } |
411 | 409 |
412 void CFWL_ComboBox::MatchEditText() { | 410 void CFWL_ComboBox::MatchEditText() { |
(...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 m_pEdit = | 599 m_pEdit = |
602 pdfium::MakeUnique<CFWL_ComboEdit>(m_pOwnerApp, std::move(prop), this); | 600 pdfium::MakeUnique<CFWL_ComboEdit>(m_pOwnerApp, std::move(prop), this); |
603 m_pEdit->SetOuter(this); | 601 m_pEdit->SetOuter(this); |
604 } | 602 } |
605 | 603 |
606 void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { | 604 void CFWL_ComboBox::DisForm_ShowDropList(bool bActivate) { |
607 if (DisForm_IsDropListVisible() == bActivate) | 605 if (DisForm_IsDropListVisible() == bActivate) |
608 return; | 606 return; |
609 | 607 |
610 if (bActivate) { | 608 if (bActivate) { |
611 CFWL_EvtPreDropDown preEvent; | 609 CFWL_Event preEvent(CFWL_EventType::PreDropDown); |
612 preEvent.m_pSrcTarget = this; | 610 preEvent.m_pSrcTarget = this; |
613 DispatchEvent(&preEvent); | 611 DispatchEvent(&preEvent); |
614 | 612 |
615 CFWL_ComboList* pComboList = m_pListBox.get(); | 613 CFWL_ComboList* pComboList = m_pListBox.get(); |
616 int32_t iItems = pComboList->CountItems(nullptr); | 614 int32_t iItems = pComboList->CountItems(nullptr); |
617 if (iItems < 1) | 615 if (iItems < 1) |
618 return; | 616 return; |
619 | 617 |
620 ResetListItemAlignment(); | 618 ResetListItemAlignment(); |
621 pComboList->ChangeSelected(m_iCurSel); | 619 pComboList->ChangeSelected(m_iCurSel); |
(...skipping 13 matching lines...) Expand all Loading... |
635 GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); | 633 GetPopupPos(fPopupMin, fPopupMax, m_pProperties->m_rtWidget, rtList); |
636 | 634 |
637 m_pListBox->SetWidgetRect(rtList); | 635 m_pListBox->SetWidgetRect(rtList); |
638 m_pListBox->Update(); | 636 m_pListBox->Update(); |
639 } else { | 637 } else { |
640 SetFocus(true); | 638 SetFocus(true); |
641 } | 639 } |
642 | 640 |
643 m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate); | 641 m_pListBox->SetStates(FWL_WGTSTATE_Invisible, !bActivate); |
644 if (bActivate) { | 642 if (bActivate) { |
645 CFWL_EvtPostDropDown postEvent; | 643 CFWL_Event postEvent(CFWL_EventType::PostDropDown); |
646 postEvent.m_pSrcTarget = this; | 644 postEvent.m_pSrcTarget = this; |
647 DispatchEvent(&postEvent); | 645 DispatchEvent(&postEvent); |
648 } | 646 } |
649 | 647 |
650 CFX_RectF rect; | 648 CFX_RectF rect; |
651 m_pListBox->GetWidgetRect(rect); | 649 m_pListBox->GetWidgetRect(rect); |
652 rect.Inflate(2, 2); | 650 rect.Inflate(2, 2); |
653 Repaint(&rect); | 651 Repaint(&rect); |
654 } | 652 } |
655 | 653 |
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 void CFWL_ComboBox::OnProcessEvent(CFWL_Event* pEvent) { | 832 void CFWL_ComboBox::OnProcessEvent(CFWL_Event* pEvent) { |
835 CFWL_EventType dwFlag = pEvent->GetClassID(); | 833 CFWL_EventType dwFlag = pEvent->GetClassID(); |
836 if (dwFlag == CFWL_EventType::Scroll) { | 834 if (dwFlag == CFWL_EventType::Scroll) { |
837 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 835 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
838 CFWL_EvtScroll pScrollEv; | 836 CFWL_EvtScroll pScrollEv; |
839 pScrollEv.m_pSrcTarget = this; | 837 pScrollEv.m_pSrcTarget = this; |
840 pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode; | 838 pScrollEv.m_iScrollCode = pScrollEvent->m_iScrollCode; |
841 pScrollEv.m_fPos = pScrollEvent->m_fPos; | 839 pScrollEv.m_fPos = pScrollEvent->m_fPos; |
842 DispatchEvent(&pScrollEv); | 840 DispatchEvent(&pScrollEv); |
843 } else if (dwFlag == CFWL_EventType::TextChanged) { | 841 } else if (dwFlag == CFWL_EventType::TextChanged) { |
844 CFWL_EvtEditChanged pTemp; | 842 CFWL_Event pTemp(CFWL_EventType::EditChanged); |
845 pTemp.m_pSrcTarget = this; | 843 pTemp.m_pSrcTarget = this; |
846 DispatchEvent(&pTemp); | 844 DispatchEvent(&pTemp); |
847 } | 845 } |
848 } | 846 } |
849 | 847 |
850 void CFWL_ComboBox::OnDrawWidget(CFX_Graphics* pGraphics, | 848 void CFWL_ComboBox::OnDrawWidget(CFX_Graphics* pGraphics, |
851 const CFX_Matrix* pMatrix) { | 849 const CFX_Matrix* pMatrix) { |
852 DrawWidget(pGraphics, pMatrix); | 850 DrawWidget(pGraphics, pMatrix); |
853 } | 851 } |
854 | 852 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 if (!IsDropListVisible() && | 925 if (!IsDropListVisible() && |
928 !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == | 926 !((m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) == |
929 FWL_WGTSTATE_Disabled)) { | 927 FWL_WGTSTATE_Disabled)) { |
930 m_iBtnState = CFWL_PartState_Normal; | 928 m_iBtnState = CFWL_PartState_Normal; |
931 Repaint(&m_rtBtn); | 929 Repaint(&m_rtBtn); |
932 } | 930 } |
933 } | 931 } |
934 | 932 |
935 void CFWL_ComboBox::OnKey(CFWL_MsgKey* pMsg) { | 933 void CFWL_ComboBox::OnKey(CFWL_MsgKey* pMsg) { |
936 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 934 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
937 if (dwKeyCode == FWL_VKEY_Tab) { | 935 if (dwKeyCode == FWL_VKEY_Tab) |
938 DispatchKeyEvent(pMsg); | |
939 return; | 936 return; |
940 } | |
941 if (pMsg->m_pDstTarget == this) | 937 if (pMsg->m_pDstTarget == this) |
942 DoSubCtrlKey(pMsg); | 938 DoSubCtrlKey(pMsg); |
943 } | 939 } |
944 | 940 |
945 void CFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) { | 941 void CFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) { |
946 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 942 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
947 const bool bUp = dwKeyCode == FWL_VKEY_Up; | 943 const bool bUp = dwKeyCode == FWL_VKEY_Up; |
948 const bool bDown = dwKeyCode == FWL_VKEY_Down; | 944 const bool bDown = dwKeyCode == FWL_VKEY_Down; |
949 if (bUp || bDown) { | 945 if (bUp || bDown) { |
950 int32_t iCount = m_pListBox->CountItems(nullptr); | 946 int32_t iCount = m_pListBox->CountItems(nullptr); |
(...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1107 else | 1103 else |
1108 iCurSel++; | 1104 iCurSel++; |
1109 } | 1105 } |
1110 m_iCurSel = iCurSel; | 1106 m_iCurSel = iCurSel; |
1111 SyncEditText(m_iCurSel); | 1107 SyncEditText(m_iCurSel); |
1112 return; | 1108 return; |
1113 } | 1109 } |
1114 if (m_pEdit) | 1110 if (m_pEdit) |
1115 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); | 1111 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); |
1116 } | 1112 } |
OLD | NEW |