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 "xfa/fde/tto/fde_textout.h" | 9 #include "xfa/fde/tto/fde_textout.h" |
10 #include "xfa/fwl/core/cfwl_message.h" | 10 #include "xfa/fwl/core/cfwl_message.h" |
11 #include "xfa/fwl/core/cfwl_themebackground.h" | 11 #include "xfa/fwl/core/cfwl_themebackground.h" |
12 #include "xfa/fwl/core/cfwl_themepart.h" | 12 #include "xfa/fwl/core/cfwl_themepart.h" |
13 #include "xfa/fwl/core/cfwl_themetext.h" | 13 #include "xfa/fwl/core/cfwl_themetext.h" |
14 #include "xfa/fwl/core/ifwl_app.h" | 14 #include "xfa/fwl/core/ifwl_app.h" |
15 #include "xfa/fwl/core/ifwl_themeprovider.h" | 15 #include "xfa/fwl/core/ifwl_themeprovider.h" |
16 | 16 |
17 namespace { | 17 namespace { |
18 | 18 |
19 const int kItemTextMargin = 2; | 19 const int kItemTextMargin = 2; |
20 | 20 |
21 } // namespace | 21 } // namespace |
22 | 22 |
23 IFWL_ListBox::IFWL_ListBox(const CFWL_WidgetImpProperties& properties, | 23 IFWL_ListBox::IFWL_ListBox(const IFWL_App* app, |
| 24 const CFWL_WidgetImpProperties& properties, |
24 IFWL_Widget* pOuter) | 25 IFWL_Widget* pOuter) |
25 : IFWL_Widget(properties, pOuter), | 26 : IFWL_Widget(app, properties, pOuter), |
26 m_dwTTOStyles(0), | 27 m_dwTTOStyles(0), |
27 m_iTTOAligns(0), | 28 m_iTTOAligns(0), |
28 m_hAnchor(nullptr), | 29 m_hAnchor(nullptr), |
29 m_fScorllBarWidth(0), | 30 m_fScorllBarWidth(0), |
30 m_bLButtonDown(FALSE), | 31 m_bLButtonDown(FALSE), |
31 m_pScrollBarTP(nullptr) { | 32 m_pScrollBarTP(nullptr) { |
32 m_rtClient.Reset(); | 33 m_rtClient.Reset(); |
33 m_rtConent.Reset(); | 34 m_rtConent.Reset(); |
34 m_rtStatic.Reset(); | 35 m_rtStatic.Reset(); |
35 } | 36 } |
36 | 37 |
37 IFWL_ListBox::~IFWL_ListBox() {} | 38 IFWL_ListBox::~IFWL_ListBox() {} |
38 | 39 |
39 FWL_Type IFWL_ListBox::GetClassID() const { | 40 void IFWL_ListBox::Initialize() { |
40 return FWL_Type::ListBox; | 41 IFWL_Widget::Initialize(); |
41 } | |
42 | |
43 FWL_Error IFWL_ListBox::Initialize() { | |
44 if (IFWL_Widget::Initialize() != FWL_Error::Succeeded) | |
45 return FWL_Error::Indefinite; | |
46 | |
47 m_pDelegate = new CFWL_ListBoxImpDelegate(this); | 42 m_pDelegate = new CFWL_ListBoxImpDelegate(this); |
48 return FWL_Error::Succeeded; | |
49 } | 43 } |
50 | 44 |
51 void IFWL_ListBox::Finalize() { | 45 void IFWL_ListBox::Finalize() { |
52 if (m_pVertScrollBar) | 46 if (m_pVertScrollBar) |
53 m_pVertScrollBar->Finalize(); | 47 m_pVertScrollBar->Finalize(); |
54 if (m_pHorzScrollBar) | 48 if (m_pHorzScrollBar) |
55 m_pHorzScrollBar->Finalize(); | 49 m_pHorzScrollBar->Finalize(); |
56 | 50 |
57 delete m_pDelegate; | 51 delete m_pDelegate; |
58 m_pDelegate = nullptr; | 52 m_pDelegate = nullptr; |
59 IFWL_Widget::Finalize(); | 53 IFWL_Widget::Finalize(); |
60 } | 54 } |
61 | 55 |
| 56 FWL_Type IFWL_ListBox::GetClassID() const { |
| 57 return FWL_Type::ListBox; |
| 58 } |
| 59 |
62 FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { | 60 FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, FX_BOOL bAutoSize) { |
63 if (bAutoSize) { | 61 if (bAutoSize) { |
64 rect.Set(0, 0, 0, 0); | 62 rect.Set(0, 0, 0, 0); |
65 if (!m_pProperties->m_pThemeProvider) { | 63 if (!m_pProperties->m_pThemeProvider) { |
66 m_pProperties->m_pThemeProvider = GetAvailableTheme(); | 64 m_pProperties->m_pThemeProvider = GetAvailableTheme(); |
67 } | 65 } |
68 CFX_SizeF fs = CalcSize(TRUE); | 66 CFX_SizeF fs = CalcSize(TRUE); |
69 rect.Set(0, 0, fs.x, fs.y); | 67 rect.Set(0, 0, fs.x, fs.y); |
70 IFWL_Widget::GetWidgetRect(rect, TRUE); | 68 IFWL_Widget::GetWidgetRect(rect, TRUE); |
71 } else { | 69 } else { |
(...skipping 819 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
891 | 889 |
892 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) { | 890 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) { |
893 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { | 891 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { |
894 return; | 892 return; |
895 } | 893 } |
896 CFWL_WidgetImpProperties prop; | 894 CFWL_WidgetImpProperties prop; |
897 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; | 895 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; |
898 prop.m_dwStates = FWL_WGTSTATE_Invisible; | 896 prop.m_dwStates = FWL_WGTSTATE_Invisible; |
899 prop.m_pParent = this; | 897 prop.m_pParent = this; |
900 prop.m_pThemeProvider = m_pScrollBarTP; | 898 prop.m_pThemeProvider = m_pScrollBarTP; |
901 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(prop, this); | 899 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this); |
902 pScrollBar->Initialize(); | 900 pScrollBar->Initialize(); |
903 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); | 901 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); |
904 } | 902 } |
905 | 903 |
906 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) { | 904 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) { |
907 IFWL_ScrollBar* pScrollbar = | 905 IFWL_ScrollBar* pScrollbar = |
908 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); | 906 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); |
909 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { | 907 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { |
910 return FALSE; | 908 return FALSE; |
911 } | 909 } |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1195 m_pOwner->Repaint(&m_pOwner->m_rtClient); | 1193 m_pOwner->Repaint(&m_pOwner->m_rtClient); |
1196 } | 1194 } |
1197 return TRUE; | 1195 return TRUE; |
1198 } | 1196 } |
1199 | 1197 |
1200 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { | 1198 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { |
1201 CFWL_EvtLtbSelChanged ev; | 1199 CFWL_EvtLtbSelChanged ev; |
1202 ev.m_pSrcTarget = m_pOwner; | 1200 ev.m_pSrcTarget = m_pOwner; |
1203 m_pOwner->DispatchEvent(&ev); | 1201 m_pOwner->DispatchEvent(&ev); |
1204 } | 1202 } |
OLD | NEW |