| 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 "xfa/fde/tto/fde_textout.h" | 10 #include "xfa/fde/tto/fde_textout.h" |
| 10 #include "xfa/fwl/core/cfwl_message.h" | 11 #include "xfa/fwl/core/cfwl_message.h" |
| 11 #include "xfa/fwl/core/cfwl_themebackground.h" | 12 #include "xfa/fwl/core/cfwl_themebackground.h" |
| 12 #include "xfa/fwl/core/cfwl_themepart.h" | 13 #include "xfa/fwl/core/cfwl_themepart.h" |
| 13 #include "xfa/fwl/core/cfwl_themetext.h" | 14 #include "xfa/fwl/core/cfwl_themetext.h" |
| 14 #include "xfa/fwl/core/ifwl_app.h" | 15 #include "xfa/fwl/core/ifwl_app.h" |
| 15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 16 #include "xfa/fwl/core/ifwl_themeprovider.h" |
| 16 | 17 |
| 17 namespace { | 18 namespace { |
| 18 | 19 |
| 19 const int kItemTextMargin = 2; | 20 const int kItemTextMargin = 2; |
| 20 | 21 |
| 21 } // namespace | 22 } // namespace |
| 22 | 23 |
| 23 IFWL_ListBox::IFWL_ListBox(const IFWL_App* app, | 24 IFWL_ListBox::IFWL_ListBox(const IFWL_App* app, |
| 24 const CFWL_WidgetImpProperties& properties, | 25 const CFWL_WidgetImpProperties& properties, |
| 25 IFWL_Widget* pOuter) | 26 IFWL_Widget* pOuter) |
| 26 : IFWL_Widget(app, properties, pOuter), | 27 : IFWL_Widget(app, properties, pOuter), |
| 27 m_dwTTOStyles(0), | 28 m_dwTTOStyles(0), |
| 28 m_iTTOAligns(0), | 29 m_iTTOAligns(0), |
| 29 m_hAnchor(nullptr), | 30 m_hAnchor(nullptr), |
| 30 m_fScorllBarWidth(0), | 31 m_fScorllBarWidth(0), |
| 31 m_bLButtonDown(FALSE), | 32 m_bLButtonDown(FALSE), |
| 32 m_pScrollBarTP(nullptr) { | 33 m_pScrollBarTP(nullptr) { |
| 33 m_rtClient.Reset(); | 34 m_rtClient.Reset(); |
| 34 m_rtConent.Reset(); | 35 m_rtConent.Reset(); |
| 35 m_rtStatic.Reset(); | 36 m_rtStatic.Reset(); |
| 37 |
| 38 SetDelegate(pdfium::MakeUnique<CFWL_ListBoxImpDelegate>(this)); |
| 36 } | 39 } |
| 37 | 40 |
| 38 IFWL_ListBox::~IFWL_ListBox() {} | 41 IFWL_ListBox::~IFWL_ListBox() {} |
| 39 | 42 |
| 40 void IFWL_ListBox::Initialize() { | |
| 41 IFWL_Widget::Initialize(); | |
| 42 m_pDelegate = new CFWL_ListBoxImpDelegate(this); | |
| 43 } | |
| 44 | |
| 45 void IFWL_ListBox::Finalize() { | |
| 46 if (m_pVertScrollBar) | |
| 47 m_pVertScrollBar->Finalize(); | |
| 48 if (m_pHorzScrollBar) | |
| 49 m_pHorzScrollBar->Finalize(); | |
| 50 | |
| 51 delete m_pDelegate; | |
| 52 m_pDelegate = nullptr; | |
| 53 IFWL_Widget::Finalize(); | |
| 54 } | |
| 55 | |
| 56 FWL_Type IFWL_ListBox::GetClassID() const { | 43 FWL_Type IFWL_ListBox::GetClassID() const { |
| 57 return FWL_Type::ListBox; | 44 return FWL_Type::ListBox; |
| 58 } | 45 } |
| 59 | 46 |
| 60 FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 47 FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
| 61 if (bAutoSize) { | 48 if (bAutoSize) { |
| 62 rect.Set(0, 0, 0, 0); | 49 rect.Set(0, 0, 0, 0); |
| 63 if (!m_pProperties->m_pThemeProvider) { | 50 if (!m_pProperties->m_pThemeProvider) { |
| 64 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 51 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
| 65 } | 52 } |
| (...skipping 823 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 | 876 |
| 890 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) { | 877 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) { |
| 891 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 878 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
| 892 return; | 879 return; |
| 893 } | 880 } |
| 894 CFWL_WidgetImpProperties prop; | 881 CFWL_WidgetImpProperties prop; |
| 895 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 882 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
| 896 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 883 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
| 897 prop.m_pParent = this; | 884 prop.m_pParent = this; |
| 898 prop.m_pThemeProvider = m_pScrollBarTP; | 885 prop.m_pThemeProvider = m_pScrollBarTP; |
| 899 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this); | 886 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar) |
| 900 pScrollBar->Initialize(); | 887 ->reset(new IFWL_ScrollBar(m_pOwnerApp, prop, this)); |
| 901 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | |
| 902 } | 888 } |
| 903 | 889 |
| 904 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) { | 890 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) { |
| 905 IFWL_ScrollBar* pScrollbar = | 891 IFWL_ScrollBar* pScrollbar = |
| 906 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 892 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
| 907 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { | 893 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { |
| 908 return FALSE; | 894 return FALSE; |
| 909 } | 895 } |
| 910 return !(m_pProperties->m_dwStyleExes & | 896 return !(m_pProperties->m_dwStyleExes & |
| 911 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || | 897 FWL_STYLEEXT_LTB_ShowScrollBarFocus) || |
| (...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1189 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1175 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
| 1190 } | 1176 } |
| 1191 return TRUE; | 1177 return TRUE; |
| 1192 } | 1178 } |
| 1193 | 1179 |
| 1194 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1180 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
| 1195 CFWL_EvtLtbSelChanged ev; | 1181 CFWL_EvtLtbSelChanged ev; |
| 1196 ev.m_pSrcTarget = m_pOwner; | 1182 ev.m_pSrcTarget = m_pOwner; |
| 1197 m_pOwner->DispatchEvent(&ev); | 1183 m_pOwner->DispatchEvent(&ev); |
| 1198 } | 1184 } |
| OLD | NEW |