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

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

Issue 2555103005: Cleanup return values in CFWL_ComboBox (Closed)
Patch Set: Rebase to master Created 4 years 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/fxfa/app/xfa_ffchoicelist.cpp » ('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 <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after
245 if (!pThemeProvider) 245 if (!pThemeProvider)
246 return; 246 return;
247 247
248 m_pProperties->m_pThemeProvider = pThemeProvider; 248 m_pProperties->m_pThemeProvider = pThemeProvider;
249 if (m_pListBox) 249 if (m_pListBox)
250 m_pListBox->SetThemeProvider(pThemeProvider); 250 m_pListBox->SetThemeProvider(pThemeProvider);
251 if (m_pEdit) 251 if (m_pEdit)
252 m_pEdit->SetThemeProvider(pThemeProvider); 252 m_pEdit->SetThemeProvider(pThemeProvider);
253 } 253 }
254 254
255 void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, 255 CFX_WideString CFWL_ComboBox::GetTextByIndex(int32_t iIndex) const {
256 CFX_WideString& wsText) const {
257 CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>( 256 CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>(
258 m_pListBox->GetItem(m_pListBox.get(), iIndex)); 257 m_pListBox->GetItem(m_pListBox.get(), iIndex));
259 if (pItem) 258 return pItem ? pItem->m_wsText : L"";
260 wsText = pItem->m_wsText;
261 } 259 }
262 260
263 void CFWL_ComboBox::SetCurSel(int32_t iSel) { 261 void CFWL_ComboBox::SetCurSel(int32_t iSel) {
264 int32_t iCount = m_pListBox->CountItems(nullptr); 262 int32_t iCount = m_pListBox->CountItems(nullptr);
265 bool bClearSel = iSel < 0 || iSel >= iCount; 263 bool bClearSel = iSel < 0 || iSel >= iCount;
266 if (IsDropDownStyle() && m_pEdit) { 264 if (IsDropDownStyle() && m_pEdit) {
267 if (bClearSel) { 265 if (bClearSel) {
268 m_pEdit->SetText(CFX_WideString()); 266 m_pEdit->SetText(CFX_WideString());
269 } else { 267 } else {
270 CFWL_ListItem* hItem = m_pListBox->GetItem(this, iSel); 268 CFWL_ListItem* hItem = m_pListBox->GetItem(this, iSel);
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after
307 return L""; 305 return L"";
308 306
309 CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel); 307 CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
310 return m_pListBox->GetDataProviderItemText(hItem); 308 return m_pListBox->GetDataProviderItemText(hItem);
311 } 309 }
312 310
313 void CFWL_ComboBox::OpenDropDownList(bool bActivate) { 311 void CFWL_ComboBox::OpenDropDownList(bool bActivate) {
314 ShowDropList(bActivate); 312 ShowDropList(bActivate);
315 } 313 }
316 314
317 void CFWL_ComboBox::GetBBox(CFX_RectF& rect) const { 315 CFX_RectF CFWL_ComboBox::GetBBox() const {
318 if (m_pWidgetMgr->IsFormDisabled()) { 316 if (m_pWidgetMgr->IsFormDisabled())
319 DisForm_GetBBox(rect); 317 return DisForm_GetBBox();
320 return;
321 }
322 318
323 rect = m_pProperties->m_rtWidget; 319 CFX_RectF rect = m_pProperties->m_rtWidget;
324 if (!m_pListBox || !IsDropListVisible()) 320 if (!m_pListBox || !IsDropListVisible())
325 return; 321 return rect;
326 322
327 CFX_RectF rtList; 323 CFX_RectF rtList;
328 m_pListBox->GetWidgetRect(rtList, false); 324 m_pListBox->GetWidgetRect(rtList, false);
329 rtList.Offset(rect.left, rect.top); 325 rtList.Offset(rect.left, rect.top);
330 rect.Union(rtList); 326 rect.Union(rtList);
327 return rect;
331 } 328 }
332 329
333 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, 330 void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded,
334 uint32_t dwStylesExRemoved) { 331 uint32_t dwStylesExRemoved) {
335 if (m_pEdit) 332 if (m_pEdit)
336 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); 333 m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved);
337 } 334 }
338 335
339 void CFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics, 336 void CFWL_ComboBox::DrawStretchHandler(CFX_Graphics* pGraphics,
340 const CFX_Matrix* pMatrix) { 337 const CFX_Matrix* pMatrix) {
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
730 if (m_pListBox && DisForm_IsDropListVisible()) { 727 if (m_pListBox && DisForm_IsDropListVisible()) {
731 CFX_RectF rtList; 728 CFX_RectF rtList;
732 m_pListBox->GetWidgetRect(rtList, false); 729 m_pListBox->GetWidgetRect(rtList, false);
733 CFX_Matrix mt; 730 CFX_Matrix mt;
734 mt.Set(1, 0, 0, 1, rtList.left, rtList.top); 731 mt.Set(1, 0, 0, 1, rtList.left, rtList.top);
735 mt.Concat(mtOrg); 732 mt.Concat(mtOrg);
736 m_pListBox->DrawWidget(pGraphics, &mt); 733 m_pListBox->DrawWidget(pGraphics, &mt);
737 } 734 }
738 } 735 }
739 736
740 void CFWL_ComboBox::DisForm_GetBBox(CFX_RectF& rect) const { 737 CFX_RectF CFWL_ComboBox::DisForm_GetBBox() const {
741 rect = m_pProperties->m_rtWidget; 738 CFX_RectF rect = m_pProperties->m_rtWidget;
742 if (!m_pListBox || !DisForm_IsDropListVisible()) 739 if (!m_pListBox || !DisForm_IsDropListVisible())
743 return; 740 return rect;
744 741
745 CFX_RectF rtList; 742 CFX_RectF rtList;
746 m_pListBox->GetWidgetRect(rtList, false); 743 m_pListBox->GetWidgetRect(rtList, false);
747 rtList.Offset(rect.left, rect.top); 744 rtList.Offset(rect.left, rect.top);
748 rect.Union(rtList); 745 rect.Union(rtList);
746 return rect;
749 } 747 }
750 748
751 void CFWL_ComboBox::DisForm_Layout() { 749 void CFWL_ComboBox::DisForm_Layout() {
752 GetClientRect(m_rtClient); 750 GetClientRect(m_rtClient);
753 m_rtContent = m_rtClient; 751 m_rtContent = m_rtClient;
754 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>( 752 FX_FLOAT* pFWidth = static_cast<FX_FLOAT*>(
755 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth)); 753 GetThemeCapacity(CFWL_WidgetCapacity::ScrollBarWidth));
756 if (!pFWidth) 754 if (!pFWidth)
757 return; 755 return;
758 756
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after
1101 else 1099 else
1102 iCurSel++; 1100 iCurSel++;
1103 } 1101 }
1104 m_iCurSel = iCurSel; 1102 m_iCurSel = iCurSel;
1105 SyncEditText(m_iCurSel); 1103 SyncEditText(m_iCurSel);
1106 return; 1104 return;
1107 } 1105 }
1108 if (m_pEdit) 1106 if (m_pEdit)
1109 m_pEdit->GetDelegate()->OnProcessMessage(pMsg); 1107 m_pEdit->GetDelegate()->OnProcessMessage(pMsg);
1110 } 1108 }
OLDNEW
« no previous file with comments | « xfa/fwl/core/cfwl_combobox.h ('k') | xfa/fxfa/app/xfa_ffchoicelist.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698