| 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 <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 730 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 741 | 741 |
| 742 void IFWL_ListBox::InitScrollBar(bool bVert) { | 742 void IFWL_ListBox::InitScrollBar(bool bVert) { |
| 743 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) | 743 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) |
| 744 return; | 744 return; |
| 745 | 745 |
| 746 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); | 746 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
| 747 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 747 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 748 prop->m_dwStates = FWL_WGTSTATE_Invisible; | 748 prop->m_dwStates = FWL_WGTSTATE_Invisible; |
| 749 prop->m_pParent = this; | 749 prop->m_pParent = this; |
| 750 prop->m_pThemeProvider = m_pScrollBarTP; | 750 prop->m_pThemeProvider = m_pScrollBarTP; |
| 751 IFWL_ScrollBar* sb = new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); | 751 CFWL_ScrollBar* sb = new CFWL_ScrollBar(m_pOwnerApp, std::move(prop), this); |
| 752 if (bVert) | 752 if (bVert) |
| 753 m_pVertScrollBar.reset(sb); | 753 m_pVertScrollBar.reset(sb); |
| 754 else | 754 else |
| 755 m_pHorzScrollBar.reset(sb); | 755 m_pHorzScrollBar.reset(sb); |
| 756 } | 756 } |
| 757 | 757 |
| 758 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { | 758 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { |
| 759 IFWL_ScrollBar* pScrollbar = | 759 CFWL_ScrollBar* pScrollbar = |
| 760 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 760 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 761 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) | 761 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) |
| 762 return false; | 762 return false; |
| 763 return !(m_pProperties->m_dwStyleExes & | 763 return !(m_pProperties->m_dwStyleExes & |
| 764 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 764 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
| 765 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); | 765 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused); |
| 766 } | 766 } |
| 767 | 767 |
| 768 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { | 768 void IFWL_ListBox::OnProcessMessage(CFWL_Message* pMessage) { |
| 769 if (!pMessage) | 769 if (!pMessage) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 void IFWL_ListBox::OnProcessEvent(CFWL_Event* pEvent) { | 811 void IFWL_ListBox::OnProcessEvent(CFWL_Event* pEvent) { |
| 812 if (!pEvent) | 812 if (!pEvent) |
| 813 return; | 813 return; |
| 814 if (pEvent->GetClassID() != CFWL_EventType::Scroll) | 814 if (pEvent->GetClassID() != CFWL_EventType::Scroll) |
| 815 return; | 815 return; |
| 816 | 816 |
| 817 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; | 817 IFWL_Widget* pSrcTarget = pEvent->m_pSrcTarget; |
| 818 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || | 818 if ((pSrcTarget == m_pVertScrollBar.get() && m_pVertScrollBar) || |
| 819 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { | 819 (pSrcTarget == m_pHorzScrollBar.get() && m_pHorzScrollBar)) { |
| 820 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); | 820 CFWL_EvtScroll* pScrollEvent = static_cast<CFWL_EvtScroll*>(pEvent); |
| 821 OnScroll(static_cast<IFWL_ScrollBar*>(pSrcTarget), | 821 OnScroll(static_cast<CFWL_ScrollBar*>(pSrcTarget), |
| 822 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); | 822 pScrollEvent->m_iScrollCode, pScrollEvent->m_fPos); |
| 823 } | 823 } |
| 824 } | 824 } |
| 825 | 825 |
| 826 void IFWL_ListBox::OnDrawWidget(CFX_Graphics* pGraphics, | 826 void IFWL_ListBox::OnDrawWidget(CFX_Graphics* pGraphics, |
| 827 const CFX_Matrix* pMatrix) { | 827 const CFX_Matrix* pMatrix) { |
| 828 DrawWidget(pGraphics, pMatrix); | 828 DrawWidget(pGraphics, pMatrix); |
| 829 } | 829 } |
| 830 | 830 |
| 831 void IFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { | 831 void IFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 940 |
| 941 SetFocusItem(pItem); | 941 SetFocusItem(pItem); |
| 942 ScrollToVisible(pItem); | 942 ScrollToVisible(pItem); |
| 943 | 943 |
| 944 CFX_RectF rtInvalidate; | 944 CFX_RectF rtInvalidate; |
| 945 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, | 945 rtInvalidate.Set(0, 0, m_pProperties->m_rtWidget.width, |
| 946 m_pProperties->m_rtWidget.height); | 946 m_pProperties->m_rtWidget.height); |
| 947 Repaint(&rtInvalidate); | 947 Repaint(&rtInvalidate); |
| 948 } | 948 } |
| 949 | 949 |
| 950 bool IFWL_ListBox::OnScroll(IFWL_ScrollBar* pScrollBar, | 950 bool IFWL_ListBox::OnScroll(CFWL_ScrollBar* pScrollBar, |
| 951 FWL_SCBCODE dwCode, | 951 FWL_SCBCODE dwCode, |
| 952 FX_FLOAT fPos) { | 952 FX_FLOAT fPos) { |
| 953 CFX_SizeF fs; | 953 CFX_SizeF fs; |
| 954 pScrollBar->GetRange(&fs.x, &fs.y); | 954 pScrollBar->GetRange(&fs.x, &fs.y); |
| 955 FX_FLOAT iCurPos = pScrollBar->GetPos(); | 955 FX_FLOAT iCurPos = pScrollBar->GetPos(); |
| 956 FX_FLOAT fStep = pScrollBar->GetStepSize(); | 956 FX_FLOAT fStep = pScrollBar->GetStepSize(); |
| 957 switch (dwCode) { | 957 switch (dwCode) { |
| 958 case FWL_SCBCODE::Min: { | 958 case FWL_SCBCODE::Min: { |
| 959 fPos = fs.x; | 959 fPos = fs.x; |
| 960 break; | 960 break; |
| (...skipping 156 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1117 CFWL_ListItem* pSel = static_cast<CFWL_ListItem*>(GetItem(this, iSel)); | 1117 CFWL_ListItem* pSel = static_cast<CFWL_ListItem*>(GetItem(this, iSel)); |
| 1118 pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected; | 1118 pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected; |
| 1119 } | 1119 } |
| 1120 m_ItemArray.erase(m_ItemArray.begin() + nIndex); | 1120 m_ItemArray.erase(m_ItemArray.begin() + nIndex); |
| 1121 return true; | 1121 return true; |
| 1122 } | 1122 } |
| 1123 | 1123 |
| 1124 void IFWL_ListBox::DeleteAll() { | 1124 void IFWL_ListBox::DeleteAll() { |
| 1125 m_ItemArray.clear(); | 1125 m_ItemArray.clear(); |
| 1126 } | 1126 } |
| OLD | NEW |