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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; | 89 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; |
90 | 90 |
91 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; | 91 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; |
92 m_fScorllBarWidth = GetScrollWidth(); | 92 m_fScorllBarWidth = GetScrollWidth(); |
93 CalcSize(); | 93 CalcSize(); |
94 } | 94 } |
95 | 95 |
96 FWL_WidgetHit CFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { | 96 FWL_WidgetHit CFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { |
97 if (IsShowScrollBar(false)) { | 97 if (IsShowScrollBar(false)) { |
98 CFX_RectF rect; | 98 CFX_RectF rect; |
99 m_pHorzScrollBar->GetWidgetRect(rect); | 99 m_pHorzScrollBar->GetWidgetRect(rect, false); |
100 if (rect.Contains(fx, fy)) | 100 if (rect.Contains(fx, fy)) |
101 return FWL_WidgetHit::HScrollBar; | 101 return FWL_WidgetHit::HScrollBar; |
102 } | 102 } |
103 if (IsShowScrollBar(true)) { | 103 if (IsShowScrollBar(true)) { |
104 CFX_RectF rect; | 104 CFX_RectF rect; |
105 m_pVertScrollBar->GetWidgetRect(rect); | 105 m_pVertScrollBar->GetWidgetRect(rect, false); |
106 if (rect.Contains(fx, fy)) | 106 if (rect.Contains(fx, fy)) |
107 return FWL_WidgetHit::VScrollBar; | 107 return FWL_WidgetHit::VScrollBar; |
108 } | 108 } |
109 if (m_rtClient.Contains(fx, fy)) | 109 if (m_rtClient.Contains(fx, fy)) |
110 return FWL_WidgetHit::Client; | 110 return FWL_WidgetHit::Client; |
111 return FWL_WidgetHit::Unknown; | 111 return FWL_WidgetHit::Unknown; |
112 } | 112 } |
113 | 113 |
114 void CFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics, | 114 void CFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics, |
115 const CFX_Matrix* pMatrix) { | 115 const CFX_Matrix* pMatrix) { |
(...skipping 522 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
638 m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10); | 638 m_pVertScrollBar->SetPageSize(rtScrollBar.height * 9 / 10); |
639 m_pVertScrollBar->SetStepSize(m_fItemHeight); | 639 m_pVertScrollBar->SetStepSize(m_fItemHeight); |
640 | 640 |
641 FX_FLOAT fPos = | 641 FX_FLOAT fPos = |
642 std::min(std::max(m_pVertScrollBar->GetPos(), 0.f), szRange.y); | 642 std::min(std::max(m_pVertScrollBar->GetPos(), 0.f), szRange.y); |
643 m_pVertScrollBar->SetPos(fPos); | 643 m_pVertScrollBar->SetPos(fPos); |
644 m_pVertScrollBar->SetTrackPos(fPos); | 644 m_pVertScrollBar->SetTrackPos(fPos); |
645 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == | 645 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == |
646 0 || | 646 0 || |
647 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { | 647 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { |
648 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, false); | 648 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); |
649 } | 649 } |
650 m_pVertScrollBar->Update(); | 650 m_pVertScrollBar->Update(); |
651 } else if (m_pVertScrollBar) { | 651 } else if (m_pVertScrollBar) { |
652 m_pVertScrollBar->SetPos(0); | 652 m_pVertScrollBar->SetPos(0); |
653 m_pVertScrollBar->SetTrackPos(0); | 653 m_pVertScrollBar->SetTrackPos(0); |
654 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); | 654 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible); |
655 } | 655 } |
656 if (bShowHorzScr) { | 656 if (bShowHorzScr) { |
657 if (!m_pHorzScrollBar) | 657 if (!m_pHorzScrollBar) |
658 InitScrollBar(false); | 658 InitScrollBar(false); |
659 | 659 |
660 CFX_RectF rtScrollBar; | 660 CFX_RectF rtScrollBar; |
661 rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, | 661 rtScrollBar.Set(m_rtClient.left, m_rtClient.bottom() - m_fScorllBarWidth, |
662 m_rtClient.width, m_fScorllBarWidth); | 662 m_rtClient.width, m_fScorllBarWidth); |
663 if (bShowVertScr) | 663 if (bShowVertScr) |
664 rtScrollBar.width -= m_fScorllBarWidth; | 664 rtScrollBar.width -= m_fScorllBarWidth; |
665 | 665 |
666 m_pHorzScrollBar->SetWidgetRect(rtScrollBar); | 666 m_pHorzScrollBar->SetWidgetRect(rtScrollBar); |
667 szRange.x = 0, szRange.y = fs.x - rtScrollBar.width; | 667 szRange.x = 0, szRange.y = fs.x - rtScrollBar.width; |
668 m_pHorzScrollBar->SetRange(szRange.x, szRange.y); | 668 m_pHorzScrollBar->SetRange(szRange.x, szRange.y); |
669 m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10); | 669 m_pHorzScrollBar->SetPageSize(fWidth * 9 / 10); |
670 m_pHorzScrollBar->SetStepSize(fWidth / 10); | 670 m_pHorzScrollBar->SetStepSize(fWidth / 10); |
671 | 671 |
672 FX_FLOAT fPos = | 672 FX_FLOAT fPos = |
673 std::min(std::max(m_pHorzScrollBar->GetPos(), 0.f), szRange.y); | 673 std::min(std::max(m_pHorzScrollBar->GetPos(), 0.f), szRange.y); |
674 m_pHorzScrollBar->SetPos(fPos); | 674 m_pHorzScrollBar->SetPos(fPos); |
675 m_pHorzScrollBar->SetTrackPos(fPos); | 675 m_pHorzScrollBar->SetTrackPos(fPos); |
676 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == | 676 if ((m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_ShowScrollBarFocus) == |
677 0 || | 677 0 || |
678 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { | 678 (m_pProperties->m_dwStates & FWL_WGTSTATE_Focused)) { |
679 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, false); | 679 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); |
680 } | 680 } |
681 m_pHorzScrollBar->Update(); | 681 m_pHorzScrollBar->Update(); |
682 } else if (m_pHorzScrollBar) { | 682 } else if (m_pHorzScrollBar) { |
683 m_pHorzScrollBar->SetPos(0); | 683 m_pHorzScrollBar->SetPos(0); |
684 m_pHorzScrollBar->SetTrackPos(0); | 684 m_pHorzScrollBar->SetTrackPos(0); |
685 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, true); | 685 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); |
686 } | 686 } |
687 if (bShowVertScr && bShowHorzScr) { | 687 if (bShowVertScr && bShowHorzScr) { |
688 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, | 688 m_rtStatic.Set(m_rtClient.right() - m_fScorllBarWidth, |
689 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, | 689 m_rtClient.bottom() - m_fScorllBarWidth, m_fScorllBarWidth, |
690 m_fScorllBarWidth); | 690 m_fScorllBarWidth); |
691 } | 691 } |
692 return fs; | 692 return fs; |
693 } | 693 } |
694 | 694 |
695 void CFWL_ListBox::GetItemSize(CFX_SizeF& size, | 695 void CFWL_ListBox::GetItemSize(CFX_SizeF& size, |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
824 } | 824 } |
825 } | 825 } |
826 | 826 |
827 void CFWL_ListBox::OnDrawWidget(CFX_Graphics* pGraphics, | 827 void CFWL_ListBox::OnDrawWidget(CFX_Graphics* pGraphics, |
828 const CFX_Matrix* pMatrix) { | 828 const CFX_Matrix* pMatrix) { |
829 DrawWidget(pGraphics, pMatrix); | 829 DrawWidget(pGraphics, pMatrix); |
830 } | 830 } |
831 | 831 |
832 void CFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { | 832 void CFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { |
833 if (GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { | 833 if (GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { |
834 if (m_pVertScrollBar) | 834 if (m_pVertScrollBar) { |
835 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 835 if (bSet) |
836 if (m_pHorzScrollBar) | 836 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); |
837 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); | 837 else |
| 838 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible); |
| 839 } |
| 840 if (m_pHorzScrollBar) { |
| 841 if (bSet) |
| 842 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible); |
| 843 else |
| 844 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible); |
| 845 } |
838 } | 846 } |
839 if (bSet) | 847 if (bSet) |
840 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); | 848 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); |
841 else | 849 else |
842 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); | 850 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); |
843 | 851 |
844 Repaint(&m_rtClient); | 852 Repaint(&m_rtClient); |
845 } | 853 } |
846 | 854 |
847 void CFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { | 855 void CFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { |
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1123 void CFWL_ListBox::DeleteAll() { | 1131 void CFWL_ListBox::DeleteAll() { |
1124 m_ItemArray.clear(); | 1132 m_ItemArray.clear(); |
1125 } | 1133 } |
1126 | 1134 |
1127 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { | 1135 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { |
1128 if (!pItem) | 1136 if (!pItem) |
1129 return 0; | 1137 return 0; |
1130 return pItem->m_dwStates | pItem->m_dwCheckState; | 1138 return pItem->m_dwStates | pItem->m_dwCheckState; |
1131 } | 1139 } |
1132 | 1140 |
OLD | NEW |