Chromium Code Reviews| Index: xfa/fwl/lightwidget/cfwl_listbox.cpp |
| diff --git a/xfa/fwl/lightwidget/cfwl_listbox.cpp b/xfa/fwl/lightwidget/cfwl_listbox.cpp |
| index e8e26f5b52bea0d3c0a6d223cdb20631b1d66656..615ec6f4e8700169093c8a6914a4091f2add0b8d 100644 |
| --- a/xfa/fwl/lightwidget/cfwl_listbox.cpp |
| +++ b/xfa/fwl/lightwidget/cfwl_listbox.cpp |
| @@ -31,22 +31,22 @@ FWL_Error CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { |
| return FWL_Error::Succeeded; |
| } |
| -FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) { |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_pDIB = pDIB; |
| +FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* hItem) { |
| + static_cast<CFWL_ListItem*>(hItem)->m_pDIB = pDIB; |
| return FWL_Error::Succeeded; |
| } |
| -FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, |
| - FX_BOOL bSelect) { |
| +IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, |
| + FX_BOOL bSelect) { |
| std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); |
| pItem->m_dwStates = 0; |
| pItem->m_wsText = wsAdd; |
| pItem->m_dwStates = bSelect ? FWL_ITEMSTATE_LTB_Selected : 0; |
| m_ListBoxDP.m_ItemArray.push_back(std::move(pItem)); |
| - return (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray.back().get(); |
| + return (IFWL_ListItem*)m_ListBoxDP.m_ItemArray.back().get(); |
|
Lei Zhang
2016/06/02 01:14:16
Still need the cast?
Tom Sepez
2016/06/02 21:02:59
Done.
|
| } |
| -FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { |
| +FX_BOOL CFWL_ListBox::DeleteString(IFWL_ListItem* hItem) { |
| int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem); |
| if (nIndex < 0 || |
| static_cast<size_t>(nIndex) >= m_ListBoxDP.m_ItemArray.size()) { |
| @@ -62,7 +62,7 @@ FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { |
| } |
| if (iSel >= 0) { |
| CFWL_ListItem* pSel = |
| - reinterpret_cast<CFWL_ListItem*>(m_ListBoxDP.GetItem(m_pIface, iSel)); |
| + static_cast<CFWL_ListItem*>(m_ListBoxDP.GetItem(m_pIface, iSel)); |
| pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected; |
| } |
| m_ListBoxDP.m_ItemArray.erase(m_ListBoxDP.m_ItemArray.begin() + nIndex); |
| @@ -79,7 +79,7 @@ int32_t CFWL_ListBox::CountSelItems() { |
| return static_cast<IFWL_ListBox*>(m_pIface)->CountSelItems(); |
| } |
| -FWL_HLISTITEM CFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
| +IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
| if (!m_pIface) |
| return NULL; |
| return static_cast<IFWL_ListBox*>(m_pIface)->GetSelItem(nIndexSel); |
| @@ -91,13 +91,13 @@ int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { |
| return static_cast<IFWL_ListBox*>(m_pIface)->GetSelIndex(nIndex); |
| } |
| -FWL_Error CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
| +FWL_Error CFWL_ListBox::SetSelItem(IFWL_ListItem* hItem, FX_BOOL bSelect) { |
| if (!m_pIface) |
| return FWL_Error::Indefinite; |
| return static_cast<IFWL_ListBox*>(m_pIface)->SetSelItem(hItem, bSelect); |
| } |
| -FWL_Error CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, |
| +FWL_Error CFWL_ListBox::GetItemText(IFWL_ListItem* hItem, |
| CFX_WideString& wsText) { |
| if (!m_pIface) |
| return FWL_Error::Indefinite; |
| @@ -115,15 +115,15 @@ FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { |
| return FWL_Error::Succeeded; |
| } |
| -FWL_HLISTITEM CFWL_ListBox::GetFocusItem() { |
| +IFWL_ListItem* CFWL_ListBox::GetFocusItem() { |
| for (const auto& hItem : m_ListBoxDP.m_ItemArray) { |
| if (hItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) |
| - return (FWL_HLISTITEM)hItem.get(); |
| + return (IFWL_ListItem*)hItem.get(); |
|
Lei Zhang
2016/06/02 01:14:16
Ditto
Tom Sepez
2016/06/02 21:03:00
Done.
|
| } |
| return nullptr; |
| } |
| -FWL_Error CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) { |
| +FWL_Error CFWL_ListBox::SetFocusItem(IFWL_ListItem* hItem) { |
| int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem); |
| m_ListBoxDP.m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused; |
| return FWL_Error::Succeeded; |
| @@ -133,43 +133,43 @@ int32_t CFWL_ListBox::CountItems() { |
| return pdfium::CollectionSize<int32_t>(m_ListBoxDP.m_ItemArray); |
| } |
| -FWL_HLISTITEM CFWL_ListBox::GetItem(int32_t nIndex) { |
| +IFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { |
| if (nIndex < 0 || nIndex >= CountItems()) |
| return nullptr; |
| - return (FWL_HLISTITEM)m_ListBoxDP.m_ItemArray[nIndex].get(); |
| + return (IFWL_ListItem*)m_ListBoxDP.m_ItemArray[nIndex].get(); |
|
Lei Zhang
2016/06/02 01:14:16
Ditto
Tom Sepez
2016/06/02 21:03:00
Done.
|
| } |
| -FWL_Error CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem, |
| +FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* hItem, |
| const CFX_WideStringC& wsText) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = wsText; |
| + static_cast<CFWL_ListItem*>(hItem)->m_wsText = wsText; |
| return FWL_Error::Succeeded; |
| } |
| -FWL_Error CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem, |
| +FWL_Error CFWL_ListBox::GetItemString(IFWL_ListItem* hItem, |
| CFX_WideString& wsText) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText; |
| + wsText = static_cast<CFWL_ListItem*>(hItem)->m_wsText; |
| return FWL_Error::Succeeded; |
| } |
| -FWL_Error CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) { |
| +FWL_Error CFWL_ListBox::SetItemData(IFWL_ListItem* hItem, void* pData) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_pData = pData; |
| + static_cast<CFWL_ListItem*>(hItem)->m_pData = pData; |
| return FWL_Error::Succeeded; |
| } |
| -void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem) { |
| +void* CFWL_ListBox::GetItemData(IFWL_ListItem* hItem) { |
| if (!hItem) |
| return NULL; |
| - return reinterpret_cast<CFWL_ListItem*>(hItem)->m_pData; |
| + return static_cast<CFWL_ListItem*>(hItem)->m_pData; |
| } |
| -FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| +IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| CFX_RectF rtClient; |
| m_pIface->GetClientRect(rtClient); |
| fx -= rtClient.left; |
| @@ -180,7 +180,7 @@ FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fy, FALSE); |
| int32_t nCount = m_ListBoxDP.CountItems(NULL); |
| for (int32_t i = 0; i < nCount; i++) { |
| - FWL_HLISTITEM hItem = m_ListBoxDP.GetItem(NULL, i); |
| + IFWL_ListItem* hItem = m_ListBoxDP.GetItem(NULL, i); |
| if (!hItem) { |
| continue; |
| } |
| @@ -194,10 +194,10 @@ FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| return NULL; |
| } |
| -uint32_t CFWL_ListBox::GetItemStates(FWL_HLISTITEM hItem) { |
| +uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* hItem) { |
| if (!hItem) |
| return 0; |
| - CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem); |
| + CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>(hItem); |
| return pItem->m_dwStates | pItem->m_dwCheckState; |
| } |
| @@ -219,91 +219,91 @@ int32_t CFWL_ListBox::CFWL_ListBoxDP::CountItems(IFWL_Widget* pWidget) { |
| return pdfium::CollectionSize<int32_t>(m_ItemArray); |
| } |
| -FWL_HLISTITEM CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget* pWidget, |
| - int32_t nIndex) { |
| +IFWL_ListItem* CFWL_ListBox::CFWL_ListBoxDP::GetItem(IFWL_Widget* pWidget, |
| + int32_t nIndex) { |
| if (nIndex < 0 || nIndex >= CountItems(pWidget)) |
| return nullptr; |
| - return (FWL_HLISTITEM)m_ItemArray[nIndex].get(); |
| + return (IFWL_ListItem*)m_ItemArray[nIndex].get(); |
|
Lei Zhang
2016/06/02 01:14:16
Ditto
|
| } |
| int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem) { |
| + IFWL_ListItem* hItem) { |
| auto it = std::find_if( |
| m_ItemArray.begin(), m_ItemArray.end(), |
| [hItem](const std::unique_ptr<CFWL_ListItem>& candidate) { |
| - return candidate.get() == reinterpret_cast<CFWL_ListItem*>(hItem); |
| + return candidate.get() == static_cast<CFWL_ListItem*>(hItem); |
| }); |
| return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; |
| } |
| FX_BOOL CFWL_ListBox::CFWL_ListBoxDP::SetItemIndex(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| int32_t nIndex) { |
| if (nIndex < 0 || nIndex >= CountItems(pWidget)) |
| return FALSE; |
| - m_ItemArray[nIndex].reset(reinterpret_cast<CFWL_ListItem*>(hItem)); |
| + m_ItemArray[nIndex].reset(static_cast<CFWL_ListItem*>(hItem)); |
| return TRUE; |
| } |
| uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem) { |
| + IFWL_ListItem* hItem) { |
| if (!hItem) |
| return 0; |
| - return reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates; |
| + return static_cast<CFWL_ListItem*>(hItem)->m_dwStates; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| CFX_WideString& wsText) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText; |
| + wsText = static_cast<CFWL_ListItem*>(hItem)->m_wsText; |
| return FWL_Error::Succeeded; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| CFX_RectF& rtItem) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem); |
| + CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>(hItem); |
| rtItem = pItem->m_rtItem; |
| return FWL_Error::Succeeded; |
| } |
| void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem) { |
| + IFWL_ListItem* hItem) { |
| if (!hItem) |
| return NULL; |
| - CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem); |
| + CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>(hItem); |
| return pItem->m_pData; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| uint32_t dwStyle) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates = dwStyle; |
| + static_cast<CFWL_ListItem*>(hItem)->m_dwStates = dwStyle; |
| return FWL_Error::Succeeded; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| const FX_WCHAR* pszText) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = pszText; |
| + static_cast<CFWL_ListItem*>(hItem)->m_wsText = pszText; |
| return FWL_Error::Succeeded; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| const CFX_RectF& rtItem) { |
| if (!hItem) |
| return FWL_Error::Indefinite; |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtItem = rtItem; |
| + static_cast<CFWL_ListItem*>(hItem)->m_rtItem = rtItem; |
| return FWL_Error::Succeeded; |
| } |
| @@ -312,34 +312,34 @@ FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) { |
| } |
| CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem) { |
| - return reinterpret_cast<CFWL_ListItem*>(hItem)->m_pDIB; |
| + IFWL_ListItem* hItem) { |
| + return static_cast<CFWL_ListItem*>(hItem)->m_pDIB; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| CFX_RectF& rtCheck) { |
| - rtCheck = reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox; |
| + rtCheck = static_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox; |
| return FWL_Error::Succeeded; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect( |
| IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| const CFX_RectF& rtCheck) { |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox = rtCheck; |
| + static_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox = rtCheck; |
| return FWL_Error::Succeeded; |
| } |
| uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckState(IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem) { |
| - return reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwCheckState; |
| + IFWL_ListItem* hItem) { |
| + return static_cast<CFWL_ListItem*>(hItem)->m_dwCheckState; |
| } |
| FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState( |
| IFWL_Widget* pWidget, |
| - FWL_HLISTITEM hItem, |
| + IFWL_ListItem* hItem, |
| uint32_t dwCheckState) { |
| - reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwCheckState = dwCheckState; |
| + static_cast<CFWL_ListItem*>(hItem)->m_dwCheckState = dwCheckState; |
| return FWL_Error::Succeeded; |
| } |