Chromium Code Reviews| 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/ifwl_listbox.h" | 7 #include "xfa/fwl/core/ifwl_listbox.h" |
| 8 | 8 |
| 9 #include "third_party/base/ptr_util.h" | 9 #include "third_party/base/ptr_util.h" |
| 10 #include "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
| (...skipping 825 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 836 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { | 836 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { |
| 837 IFWL_ScrollBar* pScrollbar = | 837 IFWL_ScrollBar* pScrollbar = |
| 838 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 838 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 839 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) | 839 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) |
| 840 return false; | 840 return false; |
| 841 return !(m_pProperties->m_dwStyleExes & | 841 return !(m_pProperties->m_dwStyleExes & |
| 842 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 842 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
| 843 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 843 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
| 844 } | 844 } |
| 845 | 845 |
| 846 void IFWL_ListBox::ProcessSelChanged() { | |
| 847 CFWL_EvtLtbSelChanged selEvent; | |
| 848 selEvent.m_pSrcTarget = this; | |
| 849 CFX_Int32Array arrSels; | |
| 850 int32_t iCount = CountSelItems(); | |
| 851 for (int32_t i = 0; i < iCount; i++) { | |
| 852 CFWL_ListItem* item = GetSelItem(i); | |
| 853 if (!item) | |
| 854 continue; | |
| 855 selEvent.iarraySels.Add(i); | |
| 856 } | |
| 857 DispatchEvent(&selEvent); | |
|
npm
2016/11/17 18:39:07
I agree with deletion of unused m_pSrcTarget and i
dsinclair
2016/11/17 18:39:54
All the ones I've seen check the EventType before
npm
2016/11/17 18:45:07
I think there is only one implementation of Dispat
| |
| 858 } | |
| 859 | |
| 860 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { | 846 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { |
| 861 if (!pMessage) | 847 if (!pMessage) |
| 862 return; | 848 return; |
| 863 if (!IsEnabled()) | 849 if (!IsEnabled()) |
| 864 return; | 850 return; |
| 865 | 851 |
| 866 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); | 852 CFWL_MessageType dwMsgCode = pMessage->GetClassID(); |
| 867 switch (dwMsgCode) { | 853 switch (dwMsgCode) { |
| 868 case CFWL_MessageType::SetFocus: | 854 case CFWL_MessageType::SetFocus: |
| 869 OnFocusChanged(pMessage, true); | 855 OnFocusChanged(pMessage, true); |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 967 GetItemCheckRect(hSelectedItem, rtCheck); | 953 GetItemCheckRect(hSelectedItem, rtCheck); |
| 968 bool bChecked = GetItemChecked(pItem); | 954 bool bChecked = GetItemChecked(pItem); |
| 969 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { | 955 if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { |
| 970 SetItemChecked(pItem, !bChecked); | 956 SetItemChecked(pItem, !bChecked); |
| 971 Update(); | 957 Update(); |
| 972 } | 958 } |
| 973 } | 959 } |
| 974 SetFocusItem(pItem); | 960 SetFocusItem(pItem); |
| 975 ScrollToVisible(pItem); | 961 ScrollToVisible(pItem); |
| 976 SetGrab(true); | 962 SetGrab(true); |
| 977 ProcessSelChanged(); | |
| 978 Repaint(&m_rtClient); | 963 Repaint(&m_rtClient); |
| 979 } | 964 } |
| 980 | 965 |
| 981 void IFWL_ListBox::OnLButtonUp(CFWL_MsgMouse* pMsg) { | 966 void IFWL_ListBox::OnLButtonUp(CFWL_MsgMouse* pMsg) { |
| 982 if (!m_bLButtonDown) | 967 if (!m_bLButtonDown) |
| 983 return; | 968 return; |
| 984 | 969 |
| 985 m_bLButtonDown = false; | 970 m_bLButtonDown = false; |
| 986 SetGrab(false); | 971 SetGrab(false); |
| 987 DispatchSelChangedEv(); | |
| 988 } | 972 } |
| 989 | 973 |
| 990 void IFWL_ListBox::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) { | 974 void IFWL_ListBox::OnMouseWheel(CFWL_MsgMouseWheel* pMsg) { |
| 991 if (IsShowScrollBar(true)) | 975 if (IsShowScrollBar(true)) |
| 992 m_pVertScrollBar->GetDelegate()->OnProcessMessage(pMsg); | 976 m_pVertScrollBar->GetDelegate()->OnProcessMessage(pMsg); |
| 993 } | 977 } |
| 994 | 978 |
| 995 void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { | 979 void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { |
| 996 uint32_t dwKeyCode = pMsg->m_dwKeyCode; | 980 uint32_t dwKeyCode = pMsg->m_dwKeyCode; |
| 997 switch (dwKeyCode) { | 981 switch (dwKeyCode) { |
| 998 case FWL_VKEY_Tab: | 982 case FWL_VKEY_Tab: |
| 999 case FWL_VKEY_Up: | 983 case FWL_VKEY_Up: |
| 1000 case FWL_VKEY_Down: | 984 case FWL_VKEY_Down: |
| 1001 case FWL_VKEY_Home: | 985 case FWL_VKEY_Home: |
| 1002 case FWL_VKEY_End: { | 986 case FWL_VKEY_End: { |
| 1003 CFWL_ListItem* pItem = GetFocusedItem(); | 987 CFWL_ListItem* pItem = GetFocusedItem(); |
| 1004 pItem = GetItem(pItem, dwKeyCode); | 988 pItem = GetItem(pItem, dwKeyCode); |
| 1005 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); | 989 bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); |
| 1006 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); | 990 bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); |
| 1007 OnVK(pItem, bShift, bCtrl); | 991 OnVK(pItem, bShift, bCtrl); |
| 1008 DispatchSelChangedEv(); | |
| 1009 ProcessSelChanged(); | |
| 1010 break; | 992 break; |
| 1011 } | 993 } |
| 1012 default: | 994 default: |
| 1013 break; | 995 break; |
| 1014 } | 996 } |
| 1015 } | 997 } |
| 1016 | 998 |
| 1017 void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { | 999 void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { |
| 1018 if (!pItem) | 1000 if (!pItem) |
| 1019 return; | 1001 return; |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1090 case FWL_SCBCODE::EndScroll: | 1072 case FWL_SCBCODE::EndScroll: |
| 1091 return false; | 1073 return false; |
| 1092 } | 1074 } |
| 1093 if (iCurPos != fPos) { | 1075 if (iCurPos != fPos) { |
| 1094 pScrollBar->SetPos(fPos); | 1076 pScrollBar->SetPos(fPos); |
| 1095 pScrollBar->SetTrackPos(fPos); | 1077 pScrollBar->SetTrackPos(fPos); |
| 1096 Repaint(&m_rtClient); | 1078 Repaint(&m_rtClient); |
| 1097 } | 1079 } |
| 1098 return true; | 1080 return true; |
| 1099 } | 1081 } |
| 1100 | |
| 1101 void IFWL_ListBox::DispatchSelChangedEv() { | |
| 1102 CFWL_EvtLtbSelChanged ev; | |
| 1103 ev.m_pSrcTarget = this; | |
| 1104 DispatchEvent(&ev); | |
| 1105 } | |
| OLD | NEW |