| 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" |
| 11 #include "xfa/fwl/core/cfwl_message.h" | 11 #include "xfa/fwl/core/cfwl_message.h" |
| 12 #include "xfa/fwl/core/cfwl_themebackground.h" | 12 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 13 #include "xfa/fwl/core/cfwl_themepart.h" | 13 #include "xfa/fwl/core/cfwl_themepart.h" |
| 14 #include "xfa/fwl/core/cfwl_themetext.h" | 14 #include "xfa/fwl/core/cfwl_themetext.h" |
| 15 #include "xfa/fwl/core/ifwl_app.h" | 15 #include "xfa/fwl/core/ifwl_app.h" |
| 16 #include "xfa/fwl/core/ifwl_themeprovider.h" | 16 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 const int kItemTextMargin = 2; | 20 const int kItemTextMargin = 2; |
| 21 | 21 |
| 22 } // namespace | 22 } // namespace |
| 23 | 23 |
| 24 IFWL_ListBox::IFWL_ListBox(const IFWL_App* app, | 24 IFWL_ListBox::IFWL_ListBox(const IFWL_App* app, |
| 25 const CFWL_WidgetImpProperties& properties, | 25 std::unique_ptr<CFWL_WidgetProperties> properties, |
| 26 IFWL_Widget* pOuter) | 26 IFWL_Widget* pOuter) |
| 27 : IFWL_Widget(app, properties, pOuter), | 27 : IFWL_Widget(app, std::move(properties), pOuter), |
| 28 m_dwTTOStyles(0), | 28 m_dwTTOStyles(0), |
| 29 m_iTTOAligns(0), | 29 m_iTTOAligns(0), |
| 30 m_hAnchor(nullptr), | 30 m_hAnchor(nullptr), |
| 31 m_fScorllBarWidth(0), | 31 m_fScorllBarWidth(0), |
| 32 m_bLButtonDown(false), | 32 m_bLButtonDown(false), |
| 33 m_pScrollBarTP(nullptr) { | 33 m_pScrollBarTP(nullptr) { |
| 34 m_rtClient.Reset(); | 34 m_rtClient.Reset(); |
| 35 m_rtConent.Reset(); | 35 m_rtConent.Reset(); |
| 36 m_rtStatic.Reset(); | 36 m_rtStatic.Reset(); |
| 37 } | 37 } |
| (...skipping 828 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 866 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); | 866 static_cast<FX_FLOAT*>(GetThemeCapacity(CFWL_WidgetCapacity::FontSize)); |
| 867 if (!pfFont) | 867 if (!pfFont) |
| 868 return 20; | 868 return 20; |
| 869 return *pfFont + 2 * kItemTextMargin; | 869 return *pfFont + 2 * kItemTextMargin; |
| 870 } | 870 } |
| 871 | 871 |
| 872 void IFWL_ListBox::InitScrollBar(bool bVert) { | 872 void IFWL_ListBox::InitScrollBar(bool bVert) { |
| 873 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 873 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 874 return; | 874 return; |
| 875 } | 875 } |
| 876 CFWL_WidgetImpProperties prop; | 876 auto prop = pdfium::MakeUnique<CFWL_WidgetProperties>(); |
| 877 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 877 prop->m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 878 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 878 prop->m_dwStates = FWL_WGTSTATE_Invisible; |
| 879 prop.m_pParent = this; | 879 prop->m_pParent = this; |
| 880 prop.m_pThemeProvider = m_pScrollBarTP; | 880 prop->m_pThemeProvider = m_pScrollBarTP; |
| 881 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar) | 881 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar) |
| 882 ->reset(new IFWL_ScrollBar(m_pOwnerApp, prop, this)); | 882 ->reset(new IFWL_ScrollBar(m_pOwnerApp, std::move(prop), this)); |
| 883 } | 883 } |
| 884 | 884 |
| 885 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { | 885 bool IFWL_ListBox::IsShowScrollBar(bool bVert) { |
| 886 IFWL_ScrollBar* pScrollbar = | 886 IFWL_ScrollBar* pScrollbar = |
| 887 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 887 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 888 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { | 888 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { |
| 889 return false; | 889 return false; |
| 890 } | 890 } |
| 891 return !(m_pProperties->m_dwStyleExes & | 891 return !(m_pProperties->m_dwStyleExes & |
| 892 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 892 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1145 Repaint(&m_rtClient); | 1145 Repaint(&m_rtClient); |
| 1146 } | 1146 } |
| 1147 return true; | 1147 return true; |
| 1148 } | 1148 } |
| 1149 | 1149 |
| 1150 void IFWL_ListBox::DispatchSelChangedEv() { | 1150 void IFWL_ListBox::DispatchSelChangedEv() { |
| 1151 CFWL_EvtLtbSelChanged ev; | 1151 CFWL_EvtLtbSelChanged ev; |
| 1152 ev.m_pSrcTarget = this; | 1152 ev.m_pSrcTarget = this; |
| 1153 DispatchEvent(&ev); | 1153 DispatchEvent(&ev); |
| 1154 } | 1154 } |
| OLD | NEW |