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

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

Issue 2488953003: Cleanup IFWL_Widget visibility and virtual parameters (Closed)
Patch Set: fixes Created 4 years, 1 month 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/ifwl_listbox.h ('k') | xfa/fwl/core/ifwl_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/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"
(...skipping 24 matching lines...) Expand all
35 m_rtConent.Reset(); 35 m_rtConent.Reset();
36 m_rtStatic.Reset(); 36 m_rtStatic.Reset();
37 } 37 }
38 38
39 IFWL_ListBox::~IFWL_ListBox() {} 39 IFWL_ListBox::~IFWL_ListBox() {}
40 40
41 FWL_Type IFWL_ListBox::GetClassID() const { 41 FWL_Type IFWL_ListBox::GetClassID() const {
42 return FWL_Type::ListBox; 42 return FWL_Type::ListBox;
43 } 43 }
44 44
45 FWL_Error IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) { 45 void IFWL_ListBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
46 if (bAutoSize) { 46 if (bAutoSize) {
47 rect.Set(0, 0, 0, 0); 47 rect.Set(0, 0, 0, 0);
48 if (!m_pProperties->m_pThemeProvider) { 48 if (!m_pProperties->m_pThemeProvider) {
49 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 49 m_pProperties->m_pThemeProvider = GetAvailableTheme();
50 } 50 }
51 CFX_SizeF fs = CalcSize(true); 51 CFX_SizeF fs = CalcSize(true);
52 rect.Set(0, 0, fs.x, fs.y); 52 rect.Set(0, 0, fs.x, fs.y);
53 IFWL_Widget::GetWidgetRect(rect, true); 53 IFWL_Widget::GetWidgetRect(rect, true);
54 } else { 54 } else {
55 rect = m_pProperties->m_rtWidget; 55 rect = m_pProperties->m_rtWidget;
56 } 56 }
57 return FWL_Error::Succeeded;
58 } 57 }
59 58
60 FWL_Error IFWL_ListBox::Update() { 59 void IFWL_ListBox::Update() {
61 if (IsLocked()) { 60 if (IsLocked()) {
62 return FWL_Error::Indefinite; 61 return;
63 } 62 }
64 if (!m_pProperties->m_pThemeProvider) { 63 if (!m_pProperties->m_pThemeProvider) {
65 m_pProperties->m_pThemeProvider = GetAvailableTheme(); 64 m_pProperties->m_pThemeProvider = GetAvailableTheme();
66 } 65 }
67 m_iTTOAligns = FDE_TTOALIGNMENT_Center; 66 m_iTTOAligns = FDE_TTOALIGNMENT_Center;
68 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) { 67 switch (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_AlignMask) {
69 case FWL_STYLEEXT_LTB_LeftAlign: { 68 case FWL_STYLEEXT_LTB_LeftAlign: {
70 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft; 69 m_iTTOAligns = FDE_TTOALIGNMENT_CenterLeft;
71 break; 70 break;
72 } 71 }
73 case FWL_STYLEEXT_LTB_RightAlign: { 72 case FWL_STYLEEXT_LTB_RightAlign: {
74 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight; 73 m_iTTOAligns = FDE_TTOALIGNMENT_CenterRight;
75 break; 74 break;
76 } 75 }
77 case FWL_STYLEEXT_LTB_CenterAlign: 76 case FWL_STYLEEXT_LTB_CenterAlign:
78 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; } 77 default: { m_iTTOAligns = FDE_TTOALIGNMENT_Center; }
79 } 78 }
80 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) { 79 if (m_pProperties->m_dwStyleExes & FWL_WGTSTYLE_RTLReading) {
81 m_dwTTOStyles |= FDE_TTOSTYLE_RTL; 80 m_dwTTOStyles |= FDE_TTOSTYLE_RTL;
82 } 81 }
83 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine; 82 m_dwTTOStyles |= FDE_TTOSTYLE_SingleLine;
84 m_fScorllBarWidth = GetScrollWidth(); 83 m_fScorllBarWidth = GetScrollWidth();
85 CalcSize(); 84 CalcSize();
86 return FWL_Error::Succeeded;
87 } 85 }
88 86
89 FWL_WidgetHit IFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) { 87 FWL_WidgetHit IFWL_ListBox::HitTest(FX_FLOAT fx, FX_FLOAT fy) {
90 if (IsShowScrollBar(false)) { 88 if (IsShowScrollBar(false)) {
91 CFX_RectF rect; 89 CFX_RectF rect;
92 m_pHorzScrollBar->GetWidgetRect(rect); 90 m_pHorzScrollBar->GetWidgetRect(rect);
93 if (rect.Contains(fx, fy)) 91 if (rect.Contains(fx, fy))
94 return FWL_WidgetHit::HScrollBar; 92 return FWL_WidgetHit::HScrollBar;
95 } 93 }
96 if (IsShowScrollBar(true)) { 94 if (IsShowScrollBar(true)) {
97 CFX_RectF rect; 95 CFX_RectF rect;
98 m_pVertScrollBar->GetWidgetRect(rect); 96 m_pVertScrollBar->GetWidgetRect(rect);
99 if (rect.Contains(fx, fy)) 97 if (rect.Contains(fx, fy))
100 return FWL_WidgetHit::VScrollBar; 98 return FWL_WidgetHit::VScrollBar;
101 } 99 }
102 if (m_rtClient.Contains(fx, fy)) 100 if (m_rtClient.Contains(fx, fy))
103 return FWL_WidgetHit::Client; 101 return FWL_WidgetHit::Client;
104 return FWL_WidgetHit::Unknown; 102 return FWL_WidgetHit::Unknown;
105 } 103 }
106 104
107 FWL_Error IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics, 105 void IFWL_ListBox::DrawWidget(CFX_Graphics* pGraphics,
108 const CFX_Matrix* pMatrix) { 106 const CFX_Matrix* pMatrix) {
109 if (!pGraphics) 107 if (!pGraphics)
110 return FWL_Error::Indefinite; 108 return;
111 if (!m_pProperties->m_pThemeProvider) 109 if (!m_pProperties->m_pThemeProvider)
112 return FWL_Error::Indefinite; 110 return;
113 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider; 111 IFWL_ThemeProvider* pTheme = m_pProperties->m_pThemeProvider;
114 pGraphics->SaveGraphState(); 112 pGraphics->SaveGraphState();
115 if (HasBorder()) { 113 if (HasBorder()) {
116 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix); 114 DrawBorder(pGraphics, CFWL_Part::Border, pTheme, pMatrix);
117 } 115 }
118 if (HasEdge()) { 116 if (HasEdge()) {
119 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix); 117 DrawEdge(pGraphics, CFWL_Part::Edge, pTheme, pMatrix);
120 } 118 }
121 CFX_RectF rtClip(m_rtConent); 119 CFX_RectF rtClip(m_rtConent);
122 if (IsShowScrollBar(false)) { 120 if (IsShowScrollBar(false)) {
123 rtClip.height -= m_fScorllBarWidth; 121 rtClip.height -= m_fScorllBarWidth;
124 } 122 }
125 if (IsShowScrollBar(true)) { 123 if (IsShowScrollBar(true)) {
126 rtClip.width -= m_fScorllBarWidth; 124 rtClip.width -= m_fScorllBarWidth;
127 } 125 }
128 if (pMatrix) { 126 if (pMatrix) {
129 pMatrix->TransformRect(rtClip); 127 pMatrix->TransformRect(rtClip);
130 } 128 }
131 pGraphics->SetClipRect(rtClip); 129 pGraphics->SetClipRect(rtClip);
132 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) { 130 if ((m_pProperties->m_dwStyles & FWL_WGTSTYLE_NoBackground) == 0) {
133 DrawBkground(pGraphics, pTheme, pMatrix); 131 DrawBkground(pGraphics, pTheme, pMatrix);
134 } 132 }
135 DrawItems(pGraphics, pTheme, pMatrix); 133 DrawItems(pGraphics, pTheme, pMatrix);
136 pGraphics->RestoreGraphState(); 134 pGraphics->RestoreGraphState();
137 return FWL_Error::Succeeded;
138 } 135 }
139 136
140 FWL_Error IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) { 137 void IFWL_ListBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
141 if (!pThemeProvider) 138 if (pThemeProvider)
142 return FWL_Error::Indefinite; 139 m_pProperties->m_pThemeProvider = pThemeProvider;
143 m_pProperties->m_pThemeProvider = pThemeProvider;
144 return FWL_Error::Succeeded;
145 } 140 }
146 int32_t IFWL_ListBox::CountSelItems() { 141 int32_t IFWL_ListBox::CountSelItems() {
147 if (!m_pProperties->m_pDataProvider) 142 if (!m_pProperties->m_pDataProvider)
148 return 0; 143 return 0;
149 int32_t iRet = 0; 144 int32_t iRet = 0;
150 IFWL_ListBoxDP* pData = 145 IFWL_ListBoxDP* pData =
151 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); 146 static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider);
152 int32_t iCount = pData->CountItems(this); 147 int32_t iCount = pData->CountItems(this);
153 for (int32_t i = 0; i < iCount; i++) { 148 for (int32_t i = 0; i < iCount; i++) {
154 CFWL_ListItem* pItem = pData->GetItem(this, i); 149 CFWL_ListItem* pItem = pData->GetItem(this, i);
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1145 Repaint(&m_rtClient); 1140 Repaint(&m_rtClient);
1146 } 1141 }
1147 return true; 1142 return true;
1148 } 1143 }
1149 1144
1150 void IFWL_ListBox::DispatchSelChangedEv() { 1145 void IFWL_ListBox::DispatchSelChangedEv() {
1151 CFWL_EvtLtbSelChanged ev; 1146 CFWL_EvtLtbSelChanged ev;
1152 ev.m_pSrcTarget = this; 1147 ev.m_pSrcTarget = this;
1153 DispatchEvent(&ev); 1148 DispatchEvent(&ev);
1154 } 1149 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/ifwl_listbox.h ('k') | xfa/fwl/core/ifwl_monthcalendar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698