| 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/basewidget/fwl_listboximp.h" | 7 #include "xfa/fwl/basewidget/fwl_listboximp.h" |
| 8 | 8 |
| 9 #include "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" | 10 #include "xfa/fwl/basewidget/fwl_comboboximp.h" |
| (...skipping 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 int32_t iCount = CountSelItems(); | 975 int32_t iCount = CountSelItems(); |
| 976 for (int32_t i = 0; i < iCount; i++) { | 976 for (int32_t i = 0; i < iCount; i++) { |
| 977 FWL_HLISTITEM item = GetSelItem(i); | 977 FWL_HLISTITEM item = GetSelItem(i); |
| 978 if (item == NULL) { | 978 if (item == NULL) { |
| 979 continue; | 979 continue; |
| 980 } | 980 } |
| 981 selEvent.iarraySels.Add(i); | 981 selEvent.iarraySels.Add(i); |
| 982 } | 982 } |
| 983 DispatchEvent(&selEvent); | 983 DispatchEvent(&selEvent); |
| 984 } | 984 } |
| 985 |
| 985 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) | 986 CFWL_ListBoxImpDelegate::CFWL_ListBoxImpDelegate(CFWL_ListBoxImp* pOwner) |
| 986 : m_pOwner(pOwner) {} | 987 : m_pOwner(pOwner) {} |
| 988 |
| 987 int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { | 989 int32_t CFWL_ListBoxImpDelegate::OnProcessMessage(CFWL_Message* pMessage) { |
| 988 if (!pMessage) | 990 if (!pMessage) |
| 989 return 0; | 991 return 0; |
| 990 if (!m_pOwner->IsEnabled()) { | 992 if (!m_pOwner->IsEnabled()) |
| 991 return 1; | 993 return 1; |
| 992 } | 994 |
| 993 uint32_t dwMsgCode = pMessage->GetClassID(); | 995 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 994 int32_t iRet = 1; | 996 int32_t iRet = 1; |
| 995 switch (dwMsgCode) { | 997 switch (dwMsgCode) { |
| 996 case FWL_MSGHASH_SetFocus: | 998 case CFWL_MessageType::SetFocus: { |
| 997 case FWL_MSGHASH_KillFocus: { | 999 OnFocusChanged(pMessage, TRUE); |
| 998 OnFocusChanged(pMessage, dwMsgCode == FWL_MSGHASH_SetFocus); | |
| 999 break; | 1000 break; |
| 1000 } | 1001 } |
| 1001 case FWL_MSGHASH_Mouse: { | 1002 case CFWL_MessageType::KillFocus: { |
| 1003 OnFocusChanged(pMessage, FALSE); |
| 1004 break; |
| 1005 } |
| 1006 case CFWL_MessageType::Mouse: { |
| 1002 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); | 1007 CFWL_MsgMouse* pMsg = static_cast<CFWL_MsgMouse*>(pMessage); |
| 1003 uint32_t dwCmd = pMsg->m_dwCmd; | 1008 switch (pMsg->m_dwCmd) { |
| 1004 switch (dwCmd) { | |
| 1005 case FWL_MSGMOUSECMD_LButtonDown: { | 1009 case FWL_MSGMOUSECMD_LButtonDown: { |
| 1006 OnLButtonDown(pMsg); | 1010 OnLButtonDown(pMsg); |
| 1007 break; | 1011 break; |
| 1008 } | 1012 } |
| 1009 case FWL_MSGMOUSECMD_LButtonUp: { | 1013 case FWL_MSGMOUSECMD_LButtonUp: { |
| 1010 OnLButtonUp(pMsg); | 1014 OnLButtonUp(pMsg); |
| 1011 break; | 1015 break; |
| 1012 } | 1016 } |
| 1013 default: {} | 1017 default: |
| 1018 break; |
| 1014 } | 1019 } |
| 1015 break; | 1020 break; |
| 1016 } | 1021 } |
| 1017 case FWL_MSGHASH_MouseWheel: { | 1022 case CFWL_MessageType::MouseWheel: { |
| 1018 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); | 1023 OnMouseWheel(static_cast<CFWL_MsgMouseWheel*>(pMessage)); |
| 1019 break; | 1024 break; |
| 1020 } | 1025 } |
| 1021 case FWL_MSGHASH_Key: { | 1026 case CFWL_MessageType::Key: { |
| 1022 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); | 1027 CFWL_MsgKey* pMsg = static_cast<CFWL_MsgKey*>(pMessage); |
| 1023 if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) | 1028 if (pMsg->m_dwCmd == FWL_MSGKEYCMD_KeyDown) |
| 1024 OnKeyDown(pMsg); | 1029 OnKeyDown(pMsg); |
| 1025 break; | 1030 break; |
| 1026 } | 1031 } |
| 1027 default: { iRet = 0; } | 1032 default: { |
| 1033 iRet = 0; |
| 1034 break; |
| 1035 } |
| 1028 } | 1036 } |
| 1029 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); | 1037 CFWL_WidgetImpDelegate::OnProcessMessage(pMessage); |
| 1030 return iRet; | 1038 return iRet; |
| 1031 } | 1039 } |
| 1040 |
| 1032 FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { | 1041 FWL_ERR CFWL_ListBoxImpDelegate::OnProcessEvent(CFWL_Event* pEvent) { |
| 1033 if (!pEvent) | 1042 if (!pEvent) |
| 1034 return FWL_ERR_Indefinite; | 1043 return FWL_ERR_Indefinite; |
| 1035 if (pEvent->GetClassID() != FWL_EVTHASH_Scroll) { | 1044 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
| 1036 return FWL_ERR_Succeeded; | 1045 return FWL_ERR_Succeeded; |
| 1037 } | 1046 |
| 1038 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 1047 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
| 1039 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && | 1048 if ((pSrcTarget == m_pOwner->m_pVertScrollBar.get() && |
| 1040 m_pOwner->m_pVertScrollBar) || | 1049 m_pOwner->m_pVertScrollBar) || |
| 1041 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && | 1050 (pSrcTarget == m_pOwner->m_pHorzScrollBar.get() && |
| 1042 m_pOwner->m_pHorzScrollBar)) { | 1051 m_pOwner->m_pHorzScrollBar)) { |
| 1043 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 1052 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
| 1044 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 1053 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), |
| 1045 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 1054 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
| 1046 } | 1055 } |
| 1047 return FWL_ERR_Succeeded; | 1056 return FWL_ERR_Succeeded; |
| 1048 } | 1057 } |
| 1058 |
| 1049 FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, | 1059 FWL_ERR CFWL_ListBoxImpDelegate::OnDrawWidget(CFX_Graphics* pGraphics, |
| 1050 const CFX_Matrix* pMatrix) { | 1060 const CFX_Matrix* pMatrix) { |
| 1051 return m_pOwner->DrawWidget(pGraphics, pMatrix); | 1061 return m_pOwner->DrawWidget(pGraphics, pMatrix); |
| 1052 } | 1062 } |
| 1053 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { | 1063 void CFWL_ListBoxImpDelegate::OnFocusChanged(CFWL_Message* pMsg, FX_BOOL bSet) { |
| 1054 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { | 1064 if (m_pOwner->GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { |
| 1055 if (m_pOwner->m_pVertScrollBar) { | 1065 if (m_pOwner->m_pVertScrollBar) { |
| 1056 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 1066 m_pOwner->m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); |
| 1057 } | 1067 } |
| 1058 if (m_pOwner->m_pHorzScrollBar) { | 1068 if (m_pOwner->m_pHorzScrollBar) { |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1236 pScrollBar->SetTrackPos(fPos); | 1246 pScrollBar->SetTrackPos(fPos); |
| 1237 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1247 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1238 } | 1248 } |
| 1239 return TRUE; | 1249 return TRUE; |
| 1240 } | 1250 } |
| 1241 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1251 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
| 1242 CFWL_EvtLtbSelChanged ev; | 1252 CFWL_EvtLtbSelChanged ev; |
| 1243 ev.m_pSrcTarget = m_pOwner->m_pInterface; | 1253 ev.m_pSrcTarget = m_pOwner->m_pInterface; |
| 1244 m_pOwner->DispatchEvent(&ev); | 1254 m_pOwner->DispatchEvent(&ev); |
| 1245 } | 1255 } |
| OLD | NEW |