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

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

Issue 2436103002: Remove FWL globals. (Closed)
Patch Set: fix mac Created 4 years, 2 months 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
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/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 821 matching lines...) Expand 10 before | Expand all | Expand 10 after
893 891
894 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) { 892 void IFWL_ListBox::InitScrollBar(FX_BOOL bVert) {
895 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) { 893 if ((bVert && m_pVertScrollBar) || (!bVert && m_pHorzScrollBar)) {
896 return; 894 return;
897 } 895 }
898 CFWL_WidgetImpProperties prop; 896 CFWL_WidgetImpProperties prop;
899 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz; 897 prop.m_dwStyleExes = bVert ? FWL_STYLEEXT_SCB_Vert : FWL_STYLEEXT_SCB_Horz;
900 prop.m_dwStates = FWL_WGTSTATE_Invisible; 898 prop.m_dwStates = FWL_WGTSTATE_Invisible;
901 prop.m_pParent = this; 899 prop.m_pParent = this;
902 prop.m_pThemeProvider = m_pScrollBarTP; 900 prop.m_pThemeProvider = m_pScrollBarTP;
903 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(prop, this); 901 IFWL_ScrollBar* pScrollBar = new IFWL_ScrollBar(m_pOwnerApp, prop, this);
904 pScrollBar->Initialize(); 902 pScrollBar->Initialize();
905 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar); 903 (bVert ? &m_pVertScrollBar : &m_pHorzScrollBar)->reset(pScrollBar);
906 } 904 }
907 905
908 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) { 906 FX_BOOL IFWL_ListBox::IsShowScrollBar(FX_BOOL bVert) {
909 IFWL_ScrollBar* pScrollbar = 907 IFWL_ScrollBar* pScrollbar =
910 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get(); 908 bVert ? m_pVertScrollBar.get() : m_pHorzScrollBar.get();
911 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) { 909 if (!pScrollbar || (pScrollbar->GetStates() & FWL_WGTSTATE_Invisible)) {
912 return FALSE; 910 return FALSE;
913 } 911 }
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after
1197 m_pOwner->Repaint(&m_pOwner->m_rtClient); 1195 m_pOwner->Repaint(&m_pOwner->m_rtClient);
1198 } 1196 }
1199 return TRUE; 1197 return TRUE;
1200 } 1198 }
1201 1199
1202 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() { 1200 void CFWL_ListBoxImpDelegate::DispatchSelChangedEv() {
1203 CFWL_EvtLtbSelChanged ev; 1201 CFWL_EvtLtbSelChanged ev;
1204 ev.m_pSrcTarget = m_pOwner; 1202 ev.m_pSrcTarget = m_pOwner;
1205 m_pOwner->DispatchEvent(&ev); 1203 m_pOwner->DispatchEvent(&ev);
1206 } 1204 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698