Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(14)

Side by Side Diff: xfa/fwl/core/cfwl_listbox.cpp

Issue 2533623002: Cleanup default FWL params part I (Closed)
Patch Set: Rebase to master Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « xfa/fwl/core/cfwl_listbox.h ('k') | xfa/fwl/core/cfwl_monthcalendar.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
823 } 823 }
824 } 824 }
825 825
826 void CFWL_ListBox::OnDrawWidget(CFX_Graphics* pGraphics, 826 void CFWL_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 CFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) { 831 void CFWL_ListBox::OnFocusChanged(CFWL_Message* pMsg, bool bSet) {
832 if (GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) { 832 if (GetStylesEx() & FWL_STYLEEXT_LTB_ShowScrollBarFocus) {
833 if (m_pVertScrollBar) 833 if (m_pVertScrollBar) {
834 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); 834 if (bSet)
835 if (m_pHorzScrollBar) 835 m_pVertScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
836 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible, !bSet); 836 else
837 m_pVertScrollBar->SetStates(FWL_WGTSTATE_Invisible);
838 }
839 if (m_pHorzScrollBar) {
840 if (bSet)
841 m_pHorzScrollBar->RemoveStates(FWL_WGTSTATE_Invisible);
842 else
843 m_pHorzScrollBar->SetStates(FWL_WGTSTATE_Invisible);
844 }
837 } 845 }
838 if (bSet) 846 if (bSet)
839 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused); 847 m_pProperties->m_dwStates |= (FWL_WGTSTATE_Focused);
840 else 848 else
841 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused); 849 m_pProperties->m_dwStates &= ~(FWL_WGTSTATE_Focused);
842 850
843 Repaint(&m_rtClient); 851 Repaint(&m_rtClient);
844 } 852 }
845 853
846 void CFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { 854 void CFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) {
(...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after
1122 void CFWL_ListBox::DeleteAll() { 1130 void CFWL_ListBox::DeleteAll() {
1123 m_ItemArray.clear(); 1131 m_ItemArray.clear();
1124 } 1132 }
1125 1133
1126 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { 1134 uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) {
1127 if (!pItem) 1135 if (!pItem)
1128 return 0; 1136 return 0;
1129 return pItem->m_dwStates | pItem->m_dwCheckState; 1137 return pItem->m_dwStates | pItem->m_dwCheckState;
1130 } 1138 }
1131 1139
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_listbox.h ('k') | xfa/fwl/core/cfwl_monthcalendar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698