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

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

Issue 2498163002: Cleanup cfwl_* files. (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_datetimepicker.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
11 #include "third_party/base/ptr_util.h" 11 #include "third_party/base/ptr_util.h"
12 #include "xfa/fwl/core/fwl_error.h" 12 #include "xfa/fwl/core/fwl_error.h"
13 #include "xfa/fwl/core/ifwl_widget.h" 13 #include "xfa/fwl/core/ifwl_widget.h"
14 14
15 namespace { 15 namespace {
16 16
17 IFWL_ComboBox* ToComboBox(IFWL_Widget* widget) { 17 IFWL_ComboBox* ToComboBox(IFWL_Widget* widget) {
18 return static_cast<IFWL_ComboBox*>(widget); 18 return static_cast<IFWL_ComboBox*>(widget);
19 } 19 }
20 20
21 const IFWL_ComboBox* ToComboBox(const IFWL_Widget* widget) { 21 const IFWL_ComboBox* ToComboBox(const IFWL_Widget* widget) {
22 return static_cast<const IFWL_ComboBox*>(widget); 22 return static_cast<const IFWL_ComboBox*>(widget);
23 } 23 }
24 24
25 } // namespace 25 } // namespace
26 26
27 CFWL_ComboBox::CFWL_ComboBox(const IFWL_App* app) 27 CFWL_ComboBox::CFWL_ComboBox(const IFWL_App* app)
28 : CFWL_Widget(app), m_fMaxListHeight(0), m_fItemHeight(0) {} 28 : CFWL_Widget(app), m_fMaxListHeight(0) {}
29 29
30 CFWL_ComboBox::~CFWL_ComboBox() {} 30 CFWL_ComboBox::~CFWL_ComboBox() {}
31 31
32 void CFWL_ComboBox::Initialize() { 32 void CFWL_ComboBox::Initialize() {
33 ASSERT(!m_pIface); 33 ASSERT(!m_pIface);
34 34
35 m_pIface = pdfium::MakeUnique<IFWL_ComboBox>( 35 m_pIface = pdfium::MakeUnique<IFWL_ComboBox>(
36 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this)); 36 m_pApp, pdfium::MakeUnique<CFWL_WidgetProperties>(this));
37 37
38 CFWL_Widget::Initialize(); 38 CFWL_Widget::Initialize();
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
174 int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget, 174 int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget,
175 CFWL_ListItem* pItem) { 175 CFWL_ListItem* pItem) {
176 auto it = std::find_if( 176 auto it = std::find_if(
177 m_ItemArray.begin(), m_ItemArray.end(), 177 m_ItemArray.begin(), m_ItemArray.end(),
178 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) { 178 [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) {
179 return candidate.get() == static_cast<CFWL_ListItem*>(pItem); 179 return candidate.get() == static_cast<CFWL_ListItem*>(pItem);
180 }); 180 });
181 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; 181 return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1;
182 } 182 }
183 183
184 bool CFWL_ComboBox::SetItemIndex(IFWL_Widget* pWidget,
185 CFWL_ListItem* pItem,
186 int32_t nIndex) {
187 if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size())
188 return false;
189
190 m_ItemArray[nIndex].reset(static_cast<CFWL_ListItem*>(pItem));
191 return true;
192 }
193
194 uint32_t CFWL_ComboBox::GetItemStyles(IFWL_Widget* pWidget, 184 uint32_t CFWL_ComboBox::GetItemStyles(IFWL_Widget* pWidget,
195 CFWL_ListItem* pItem) { 185 CFWL_ListItem* pItem) {
196 if (!pItem) 186 if (!pItem)
197 return 0; 187 return 0;
198 return static_cast<CFWL_ListItem*>(pItem)->m_dwStyles; 188 return static_cast<CFWL_ListItem*>(pItem)->m_dwStyles;
199 } 189 }
200 190
201 void CFWL_ComboBox::GetItemText(IFWL_Widget* pWidget, 191 void CFWL_ComboBox::GetItemText(IFWL_Widget* pWidget,
202 CFWL_ListItem* pItem, 192 CFWL_ListItem* pItem,
203 CFX_WideString& wsText) { 193 CFX_WideString& wsText) {
(...skipping 15 matching lines...) Expand all
219 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; 209 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr;
220 } 210 }
221 211
222 void CFWL_ComboBox::SetItemStyles(IFWL_Widget* pWidget, 212 void CFWL_ComboBox::SetItemStyles(IFWL_Widget* pWidget,
223 CFWL_ListItem* pItem, 213 CFWL_ListItem* pItem,
224 uint32_t dwStyle) { 214 uint32_t dwStyle) {
225 if (pItem) 215 if (pItem)
226 static_cast<CFWL_ListItem*>(pItem)->m_dwStyles = dwStyle; 216 static_cast<CFWL_ListItem*>(pItem)->m_dwStyles = dwStyle;
227 } 217 }
228 218
229 void CFWL_ComboBox::SetItemText(IFWL_Widget* pWidget,
230 CFWL_ListItem* pItem,
231 const FX_WCHAR* pszText) {
232 if (pItem)
233 static_cast<CFWL_ListItem*>(pItem)->m_wsText = pszText;
234 }
235
236 void CFWL_ComboBox::SetItemRect(IFWL_Widget* pWidget, 219 void CFWL_ComboBox::SetItemRect(IFWL_Widget* pWidget,
237 CFWL_ListItem* pItem, 220 CFWL_ListItem* pItem,
238 const CFX_RectF& rtItem) { 221 const CFX_RectF& rtItem) {
239 if (pItem) 222 if (pItem)
240 static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem; 223 static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem;
241 } 224 }
242 225
243 FX_FLOAT CFWL_ComboBox::GetItemHeight(IFWL_Widget* pWidget) {
244 return m_fItemHeight;
245 }
246
247 CFX_DIBitmap* CFWL_ComboBox::GetItemIcon(IFWL_Widget* pWidget, 226 CFX_DIBitmap* CFWL_ComboBox::GetItemIcon(IFWL_Widget* pWidget,
248 CFWL_ListItem* pItem) { 227 CFWL_ListItem* pItem) {
249 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pDIB : nullptr; 228 return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pDIB : nullptr;
250 } 229 }
251 230
252 void CFWL_ComboBox::GetItemCheckRect(IFWL_Widget* pWidget, 231 void CFWL_ComboBox::GetItemCheckRect(IFWL_Widget* pWidget,
253 CFWL_ListItem* pItem, 232 CFWL_ListItem* pItem,
254 CFX_RectF& rtCheck) { 233 CFX_RectF& rtCheck) {
255 rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox; 234 rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox;
256 } 235 }
(...skipping 11 matching lines...) Expand all
268 247
269 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, 248 void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget,
270 CFWL_ListItem* pItem, 249 CFWL_ListItem* pItem,
271 uint32_t dwCheckState) { 250 uint32_t dwCheckState) {
272 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; 251 static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState;
273 } 252 }
274 253
275 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { 254 FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) {
276 return m_fMaxListHeight; 255 return m_fMaxListHeight;
277 } 256 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_combobox.h ('k') | xfa/fwl/core/cfwl_datetimepicker.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698