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_listbox.h" | 7 #include "xfa/fwl/core/cfwl_listbox.h" |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <memory> | 10 #include <memory> |
(...skipping 754 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
765 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 765 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
766 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 766 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
767 } | 767 } |
768 | 768 |
769 void CFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { | 769 void CFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { |
770 if (!pMessage) | 770 if (!pMessage) |
771 return; | 771 return; |
772 if (!IsEnabled()) | 772 if (!IsEnabled()) |
773 return; | 773 return; |
774 | 774 |
775 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 775 switch (pMessage->GetType()) { |
776 switch (dwMsgCode) { | 776 case CFWL_Message::Type::SetFocus: |
777 case CFWL_MessageType::SetFocus: | |
778 OnFocusChanged(pMessage, true); | 777 OnFocusChanged(pMessage, true); |
779 break; | 778 break; |
780 case CFWL_MessageType::KillFocus: | 779 case CFWL_Message::Type::KillFocus: |
781 OnFocusChanged(pMessage, false); | 780 OnFocusChanged(pMessage, false); |
782 break; | 781 break; |
783 case CFWL_MessageType::Mouse: { | 782 case CFWL_Message::Type::Mouse: { |
784 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 783 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
785 switch (pMsg->m_dwCmd) { | 784 switch (pMsg->m_dwCmd) { |
786 case FWL_MouseCommand::LeftButtonDown: | 785 case FWL_MouseCommand::LeftButtonDown: |
787 OnLButtonDown(pMsg); | 786 OnLButtonDown(pMsg); |
788 break; | 787 break; |
789 case FWL_MouseCommand::LeftButtonUp: | 788 case FWL_MouseCommand::LeftButtonUp: |
790 OnLButtonUp(pMsg); | 789 OnLButtonUp(pMsg); |
791 break; | 790 break; |
792 default: | 791 default: |
793 break; | 792 break; |
794 } | 793 } |
795 break; | 794 break; |
796 } | 795 } |
797 case CFWL_MessageType::MouseWheel: | 796 case CFWL_Message::Type::MouseWheel: |
798 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); | 797 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); |
799 break; | 798 break; |
800 case CFWL_MessageType::Key: { | 799 case CFWL_Message::Type::Key: { |
801 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); | 800 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); |
802 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) | 801 if (pMsg->m_dwCmd == FWL_KeyCommand::KeyDown) |
803 OnKeyDown(pMsg); | 802 OnKeyDown(pMsg); |
804 break; | 803 break; |
805 } | 804 } |
806 default: | 805 default: |
807 break; | 806 break; |
808 } | 807 } |
809 CFWL_Widget::OnProcessMessage(pMessage); | 808 CFWL_Widget::OnProcessMessage(pMessage); |
810 } | 809 } |
811 | 810 |
812 void CFWL_ListBox::OnProcessEvent(CFWL_Event* pEvent) { | 811 void CFWL_ListBox::OnProcessEvent(CFWL_Event* pEvent) { |
813 if (!pEvent) | 812 if (!pEvent) |
814 return; | 813 return; |
815 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 814 if (pEvent->GetType() != CFWL_Event::Type::Scroll) |
816 return; | 815 return; |
817 | 816 |
818 CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 817 CFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
819 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || | 818 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || |
820 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { | 819 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { |
821 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 820 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
822 OnScroll(static_cast<CFWL_ScrollBar*>(pSrcTarget), | 821 OnScroll(static_cast<CFWL_ScrollBar*>(pSrcTarget), |
823 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 822 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
824 } | 823 } |
825 } | 824 } |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
942 SetFocusItem(pItem); | 941 SetFocusItem(pItem); |
943 ScrollToVisible(pItem); | 942 ScrollToVisible(pItem); |
944 | 943 |
945 CFX_RectF rtInvalidate; | 944 CFX_RectF rtInvalidate; |
946 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 945 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
947 m_pProperties->m_rtWidget.height); | 946 m_pProperties->m_rtWidget.height); |
948 Repaint(&rtInvalidate); | 947 Repaint(&rtInvalidate); |
949 } | 948 } |
950 | 949 |
951 bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar, | 950 bool CFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar, |
952 FWL_SCBCODE dwCode, | 951 CFWL_EvtScroll::Code dwCode, |
953 FX_FLOAT fPos) { | 952 FX_FLOAT fPos) { |
954 CFX_SizeF fs; | 953 CFX_SizeF fs; |
955 pScrollBar->GetRange(&fs.x, &fs.y); | 954 pScrollBar->GetRange(&fs.x, &fs.y); |
956 FX_FLOAT iCurPos = pScrollBar->GetPos(); | 955 FX_FLOAT iCurPos = pScrollBar->GetPos(); |
957 FX_FLOAT fStep = pScrollBar->GetStepSize(); | 956 FX_FLOAT fStep = pScrollBar->GetStepSize(); |
958 switch (dwCode) { | 957 switch (dwCode) { |
959 case FWL_SCBCODE::Min: { | 958 case CFWL_EvtScroll::Code::Min: { |
960 fPos = fs.x; | 959 fPos = fs.x; |
961 break; | 960 break; |
962 } | 961 } |
963 case FWL_SCBCODE::Max: { | 962 case CFWL_EvtScroll::Code::Max: { |
964 fPos = fs.y; | 963 fPos = fs.y; |
965 break; | 964 break; |
966 } | 965 } |
967 case FWL_SCBCODE::StepBackward: { | 966 case CFWL_EvtScroll::Code::StepBackward: { |
968 fPos -= fStep; | 967 fPos -= fStep; |
969 if (fPos < fs.x + fStep / 2) | 968 if (fPos < fs.x + fStep / 2) |
970 fPos = fs.x; | 969 fPos = fs.x; |
971 break; | 970 break; |
972 } | 971 } |
973 case FWL_SCBCODE::StepForward: { | 972 case CFWL_EvtScroll::Code::StepForward: { |
974 fPos += fStep; | 973 fPos += fStep; |
975 if (fPos > fs.y - fStep / 2) | 974 if (fPos > fs.y - fStep / 2) |
976 fPos = fs.y; | 975 fPos = fs.y; |
977 break; | 976 break; |
978 } | 977 } |
979 case FWL_SCBCODE::PageBackward: { | 978 case CFWL_EvtScroll::Code::PageBackward: { |
980 fPos -= pScrollBar->GetPageSize(); | 979 fPos -= pScrollBar->GetPageSize(); |
981 if (fPos < fs.x) | 980 if (fPos < fs.x) |
982 fPos = fs.x; | 981 fPos = fs.x; |
983 break; | 982 break; |
984 } | 983 } |
985 case FWL_SCBCODE::PageForward: { | 984 case CFWL_EvtScroll::Code::PageForward: { |
986 fPos += pScrollBar->GetPageSize(); | 985 fPos += pScrollBar->GetPageSize(); |
987 if (fPos > fs.y) | 986 if (fPos > fs.y) |
988 fPos = fs.y; | 987 fPos = fs.y; |
989 break; | 988 break; |
990 } | 989 } |
991 case FWL_SCBCODE::Pos: | 990 case CFWL_EvtScroll::Code::Pos: |
992 case FWL_SCBCODE::TrackPos: | 991 case CFWL_EvtScroll::Code::TrackPos: |
993 case FWL_SCBCODE::None: | 992 case CFWL_EvtScroll::Code::None: |
994 break; | 993 break; |
995 case FWL_SCBCODE::EndScroll: | 994 case CFWL_EvtScroll::Code::EndScroll: |
996 return false; | 995 return false; |
997 } | 996 } |
998 if (iCurPos != fPos) { | 997 if (iCurPos != fPos) { |
999 pScrollBar->SetPos(fPos); | 998 pScrollBar->SetPos(fPos); |
1000 pScrollBar->SetTrackPos(fPos); | 999 pScrollBar->SetTrackPos(fPos); |
1001 Repaint(&m_rtClient); | 1000 Repaint(&m_rtClient); |
1002 } | 1001 } |
1003 return true; | 1002 return true; |
1004 } | 1003 } |
1005 | 1004 |
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 void CFWL_ListBox::DeleteAll() { | 1122 void CFWL_ListBox::DeleteAll() { |
1124 m_ItemArray.clear(); | 1123 m_ItemArray.clear(); |
1125 } | 1124 } |
1126 | 1125 |
1127 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { | 1126 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { |
1128 if (!pItem) | 1127 if (!pItem) |
1129 return 0; | 1128 return 0; |
1130 return pItem->m_dwStates | pItem->m_dwCheckState; | 1129 return pItem->m_dwStates | pItem->m_dwCheckState; |
1131 } | 1130 } |
1132 | 1131 |
OLD | NEW |