From 42cb64572198bf8a72de9b18eae9f9dd9a07beb7 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Mon, 31 Oct 2016 12:50:04 -0700 Subject: Remove GetWidget() overrides This Cl removes the various CFWL_*::GetWidget overrides and adds anonymous To* methods as needed. Review-Url: https://codereview.chromium.org/2467503003 --- xfa/fwl/core/cfwl_listbox.cpp | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'xfa/fwl/core/cfwl_listbox.cpp') diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp index 5820a27926..139c488830 100644 --- a/xfa/fwl/core/cfwl_listbox.cpp +++ b/xfa/fwl/core/cfwl_listbox.cpp @@ -10,6 +10,14 @@ #include "third_party/base/stl_util.h" +namespace { + +IFWL_ListBox* ToListBox(IFWL_Widget* widget) { + return static_cast(widget); +} + +} // namespace + CFWL_ListBox::CFWL_ListBox(const IFWL_App* app) : CFWL_Widget(app) {} CFWL_ListBox::~CFWL_ListBox() {} @@ -25,14 +33,6 @@ void CFWL_ListBox::Initialize() { CFWL_Widget::Initialize(); } -IFWL_ListBox* CFWL_ListBox::GetWidget() { - return static_cast(m_pIface.get()); -} - -const IFWL_ListBox* CFWL_ListBox::GetWidget() const { - return static_cast(m_pIface.get()); -} - FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) { static_cast(pItem)->m_pDIB = pDIB; return FWL_Error::Succeeded; @@ -78,38 +78,38 @@ void CFWL_ListBox::DeleteAll() { int32_t CFWL_ListBox::CountSelItems() { if (!GetWidget()) return 0; - return GetWidget()->CountSelItems(); + return ToListBox(GetWidget())->CountSelItems(); } IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { if (!GetWidget()) return nullptr; - return GetWidget()->GetSelItem(nIndexSel); + return ToListBox(GetWidget())->GetSelItem(nIndexSel); } int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { if (!GetWidget()) return 0; - return GetWidget()->GetSelIndex(nIndex); + return ToListBox(GetWidget())->GetSelIndex(nIndex); } FWL_Error CFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) { if (!GetWidget()) return FWL_Error::Indefinite; - return GetWidget()->SetSelItem(pItem, bSelect); + return ToListBox(GetWidget())->SetSelItem(pItem, bSelect); } FWL_Error CFWL_ListBox::GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText) { if (!GetWidget()) return FWL_Error::Indefinite; - return GetWidget()->GetItemText(pItem, wsText); + return ToListBox(GetWidget())->GetItemText(pItem, wsText); } FWL_Error CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { if (!GetWidget()) return FWL_Error::Indefinite; - return GetWidget()->GetScrollPos(fPos, bVert); + return ToListBox(GetWidget())->GetScrollPos(fPos, bVert); } FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { @@ -176,8 +176,8 @@ IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { fy -= rtClient.top; FX_FLOAT fPosX = 0; FX_FLOAT fPosY = 0; - GetWidget()->GetScrollPos(fx); - GetWidget()->GetScrollPos(fy, FALSE); + ToListBox(GetWidget())->GetScrollPos(fx); + ToListBox(GetWidget())->GetScrollPos(fy, FALSE); int32_t nCount = m_ListBoxDP.CountItems(nullptr); for (int32_t i = 0; i < nCount; i++) { IFWL_ListItem* pItem = m_ListBoxDP.GetItem(nullptr, i); -- cgit v1.2.3