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

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

Issue 2494743002: IFWL cleanup in the Combo classes (Closed)
Patch Set: Review feedback 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/cfwl_combobox.h ('k') | xfa/fwl/core/cfwl_listbox.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/cfwl_combobox.h" 7 #include "xfa/fwl/core/cfwl_combobox.h"
8 8
9 #include <utility> 9 #include <utility>
10 10
(...skipping 28 matching lines...) Expand all
39 } 39 }
40 40
41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { 41 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); 42 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem);
43 pItem->m_wsText = wsText; 43 pItem->m_wsText = wsText;
44 pItem->m_dwStyles = 0; 44 pItem->m_dwStyles = 0;
45 m_ItemArray.push_back(std::move(pItem)); 45 m_ItemArray.push_back(std::move(pItem));
46 return m_ItemArray.size() - 1; 46 return m_ItemArray.size() - 1;
47 } 47 }
48 48
49 int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText,
50 CFX_DIBitmap* pIcon) {
51 std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem);
52 pItem->m_wsText = wsText;
53 pItem->m_dwStyles = 0;
54 pItem->m_pDIB = pIcon;
55 m_ItemArray.push_back(std::move(pItem));
56 return m_ItemArray.size() - 1;
57 }
58
59 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { 49 bool CFWL_ComboBox::RemoveAt(int32_t iIndex) {
60 if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) { 50 if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) {
61 return false; 51 return false;
62 } 52 }
63 m_ItemArray.erase(m_ItemArray.begin() + iIndex); 53 m_ItemArray.erase(m_ItemArray.begin() + iIndex);
64 return true; 54 return true;
65 } 55 }
66 56
67 void CFWL_ComboBox::RemoveAll() { 57 void CFWL_ComboBox::RemoveAll() {
68 m_ItemArray.clear(); 58 m_ItemArray.clear();
69 } 59 }
70 60
71 int32_t CFWL_ComboBox::CountItems() { 61 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex,
72 return CountItems(GetWidget()); 62 CFX_WideString& wsText) const {
63 CFWL_ListItem* pItem =
64 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex));
65 if (pItem)
66 wsText = pItem->m_wsText;
73 } 67 }
74 68
75 FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex, 69 int32_t CFWL_ComboBox::GetCurSel() const {
76 CFX_WideString& wsText) {
77 CFWL_ListItem* pItem =
78 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex));
79 if (!pItem)
80 return FWL_Error::Indefinite;
81 wsText = pItem->m_wsText;
82 return FWL_Error::Succeeded;
83 }
84
85 int32_t CFWL_ComboBox::GetCurSel() {
86 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1; 70 return GetWidget() ? ToComboBox(GetWidget())->GetCurSel() : -1;
87 } 71 }
88 72
89 FWL_Error CFWL_ComboBox::SetCurSel(int32_t iSel) { 73 void CFWL_ComboBox::SetCurSel(int32_t iSel) {
90 return GetWidget() ? ToComboBox(GetWidget())->SetCurSel(iSel) 74 if (GetWidget())
91 : FWL_Error::Indefinite; 75 ToComboBox(GetWidget())->SetCurSel(iSel);
92 } 76 }
93 77
94 void CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) { 78 void CFWL_ComboBox::SetEditText(const CFX_WideString& wsText) {
95 if (GetWidget()) 79 if (GetWidget())
96 ToComboBox(GetWidget())->SetEditText(wsText); 80 ToComboBox(GetWidget())->SetEditText(wsText);
97 } 81 }
98 82
99 int32_t CFWL_ComboBox::GetEditTextLength() const { 83 void CFWL_ComboBox::GetEditText(CFX_WideString& wsText,
100 return GetWidget() ? ToComboBox(GetWidget())->GetEditTextLength() : 0; 84 int32_t nStart,
85 int32_t nCount) const {
86 if (GetWidget())
87 ToComboBox(GetWidget())->GetEditText(wsText, nStart, nCount);
101 } 88 }
102 89
103 FWL_Error CFWL_ComboBox::GetEditText(CFX_WideString& wsText, 90 void CFWL_ComboBox::OpenDropDownList(bool bActivate) {
104 int32_t nStart, 91 ToComboBox(GetWidget())->OpenDropDownList(bActivate);
105 int32_t nCount) const {
106 return GetWidget()
107 ? ToComboBox(GetWidget())->GetEditText(wsText, nStart, nCount)
108 : FWL_Error::Indefinite;
109 }
110
111 FWL_Error CFWL_ComboBox::SetEditSelRange(int32_t nStart, int32_t nCount) {
112 return GetWidget() ? ToComboBox(GetWidget())->SetEditSelRange(nStart, nCount)
113 : FWL_Error::Indefinite;
114 }
115
116 int32_t CFWL_ComboBox::GetEditSelRange(int32_t nIndex, int32_t& nStart) {
117 return GetWidget() ? ToComboBox(GetWidget())->GetEditSelRange(nIndex, nStart)
118 : 0;
119 }
120
121 int32_t CFWL_ComboBox::GetEditLimit() {
122 return GetWidget() ? ToComboBox(GetWidget())->GetEditLimit() : 0;
123 }
124
125 FWL_Error CFWL_ComboBox::SetEditLimit(int32_t nLimit) {
126 return GetWidget() ? ToComboBox(GetWidget())->SetEditLimit(nLimit)
127 : FWL_Error::Indefinite;
128 }
129
130 bool CFWL_ComboBox::EditRedo(const IFDE_TxtEdtDoRecord* pRecord) {
131 return GetWidget() ? ToComboBox(GetWidget())->EditRedo(pRecord) : false;
132 }
133
134 bool CFWL_ComboBox::EditUndo(const IFDE_TxtEdtDoRecord* pRecord) {
135 return GetWidget() ? ToComboBox(GetWidget())->EditUndo(pRecord) : false;
136 }
137
138 FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
139 m_fMaxListHeight = fMaxHeight;
140 return FWL_Error::Succeeded;
141 }
142
143 FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
144 CFWL_ListItem* pItem =
145 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex));
146 if (!pItem)
147 return FWL_Error::Indefinite;
148 pItem->m_pData = pData;
149 return FWL_Error::Succeeded;
150 }
151
152 void* CFWL_ComboBox::GetItemData(int32_t iIndex) {
153 CFWL_ListItem* pItem =
154 static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex));
155 return pItem ? pItem->m_pData : nullptr;
156 }
157
158 void CFWL_ComboBox::SetListTheme(IFWL_ThemeProvider* pTheme) {
159 ToComboBox(GetWidget())->GetListBoxt()->SetThemeProvider(pTheme);
160 }
161
162 bool CFWL_ComboBox::AfterFocusShowDropList() {
163 return ToComboBox(GetWidget())->AfterFocusShowDropList();
164 }
165
166 FWL_Error CFWL_ComboBox::OpenDropDownList(bool bActivate) {
167 return ToComboBox(GetWidget())->OpenDropDownList(bActivate);
168 } 92 }
169 93
170 bool CFWL_ComboBox::EditCanUndo() { 94 bool CFWL_ComboBox::EditCanUndo() {
171 return GetWidget() ? ToComboBox(GetWidget())->EditCanUndo() : false; 95 return GetWidget() ? ToComboBox(GetWidget())->EditCanUndo() : false;
172 } 96 }
173 97
174 bool CFWL_ComboBox::EditCanRedo() { 98 bool CFWL_ComboBox::EditCanRedo() {
175 return GetWidget() ? ToComboBox(GetWidget())->EditCanRedo() : false; 99 return GetWidget() ? ToComboBox(GetWidget())->EditCanRedo() : false;
176 } 100 }
177 101
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
212 } 136 }
213 137
214 bool CFWL_ComboBox::EditDelete() { 138 bool CFWL_ComboBox::EditDelete() {
215 return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : false; 139 return GetWidget() ? ToComboBox(GetWidget())->EditDelete() : false;
216 } 140 }
217 141
218 bool CFWL_ComboBox::EditDeSelect() { 142 bool CFWL_ComboBox::EditDeSelect() {
219 return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : false; 143 return GetWidget() ? ToComboBox(GetWidget())->EditDeSelect() : false;
220 } 144 }
221 145
222 FWL_Error CFWL_ComboBox::GetBBox(CFX_RectF& rect) { 146 void CFWL_ComboBox::GetBBox(CFX_RectF& rect) {
223 return GetWidget() ? ToComboBox(GetWidget())->GetBBox(rect) 147 if (GetWidget())
224 : FWL_Error::Indefinite; 148 ToComboBox(GetWidget())->GetBBox(rect);
225 } 149 }
226 150
227 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, 151 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
228 uint32_t dwStylesExRemoved) { 152 uint32_t dwStylesExRemoved) {
229 if (GetWidget()) { 153 if (GetWidget()) {
230 ToComboBox(GetWidget()) 154 ToComboBox(GetWidget())
231 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 155 ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
232 } 156 }
233 } 157 }
234 158
235 void CFWL_ComboBox::GetCaption(IFWL_Widget* pWidget, 159 void CFWL_ComboBox::GetCaption(IFWL_Widget* pWidget,
236 CFX_WideString& wsCaption) {} 160 CFX_WideString& wsCaption) {}
237 161
238 int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) { 162 int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) const {
239 return m_ItemArray.size(); 163 return m_ItemArray.size();
240 } 164 }
241 165
242 CFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, 166 CFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget,
243 int32_t nIndex) { 167 int32_t nIndex) const {
244 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) 168 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size())
245 return nullptr; 169 return nullptr;
246 170
247 return m_ItemArray[nIndex].get(); 171 return m_ItemArray[nIndex].get();
248 } 172 }
249 173
250 int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget, 174 int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget,
251 CFWL_ListItem* pItem) { 175 CFWL_ListItem* pItem) {
252 auto it = std::find_if( 176 auto it = std::find_if(
253 m_ItemArray.begin(), m_ItemArray.end(), 177 m_ItemArray.begin(), m_ItemArray.end(),
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 268
345 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, 269 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget,
346 CFWL_ListItem* pItem, 270 CFWL_ListItem* pItem,
347 uint32_t dwCheckState) { 271 uint32_t dwCheckState) {
348 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; 272 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState;
349 } 273 }
350 274
351 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { 275 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) {
352 return m_fMaxListHeight; 276 return m_fMaxListHeight;
353 } 277 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_combobox.h ('k') | xfa/fwl/core/cfwl_listbox.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698