Chromium Code Reviews| Index: xfa/src/fwl/src/lightwidget/listbox.cpp |
| diff --git a/xfa/src/fwl/src/lightwidget/listbox.cpp b/xfa/src/fwl/src/lightwidget/listbox.cpp |
| index 1507d50ea2b01adbff1724f85a2cc73a3231197c..900de2319064dc2354df608210610eb3072649d7 100644 |
| --- a/xfa/src/fwl/src/lightwidget/listbox.cpp |
| +++ b/xfa/src/fwl/src/lightwidget/listbox.cpp |
| @@ -14,18 +14,17 @@ FWL_ERR CFWL_ListBox::Initialize(const CFWL_WidgetProperties* pProperties) { |
| if (pProperties) { |
| *m_pProperties = *pProperties; |
| } |
| - m_pIface = IFWL_ListBox::Create(); |
| - FWL_ERR ret = |
| - ((IFWL_ListBox*)m_pIface) |
| - ->Initialize(m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), |
| - nullptr); |
| + IFWL_ListBox* pListBox = IFWL_ListBox::Create(); |
| + m_pIface = pListBox; |
| + FWL_ERR ret = pListBox->Initialize( |
| + m_pProperties->MakeWidgetImpProperties(&m_ListBoxDP), nullptr); |
| if (ret == FWL_ERR_Succeeded) { |
| CFWL_Widget::Initialize(); |
| } |
| return ret; |
| } |
| FWL_ERR CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem) { |
| - ((CFWL_ListItem*)hItem)->m_pDIB = pDIB; |
| + reinterpret_cast<CFWL_ListItem*>(hItem)->m_pDIB = pDIB; |
| return FWL_ERR_Succeeded; |
| } |
| FWL_HLISTITEM CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, |
| @@ -43,8 +42,8 @@ FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { |
| return FALSE; |
| } |
| CFWL_ListItem* pDelItem = |
| - (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, nIndex); |
| - int32_t iCount = m_ListBoxDP.CountItems((IFWL_ListBox*)this); |
| + reinterpret_cast<CFWL_ListItem*>(m_ListBoxDP.GetItem(m_pIface, nIndex)); |
|
Tom Sepez
2015/12/08 00:47:06
yow.
|
| + int32_t iCount = m_ListBoxDP.CountItems(m_pIface); |
| int32_t iSel = nIndex + 1; |
| if (iSel >= iCount) { |
| iSel = nIndex - 1; |
| @@ -53,8 +52,7 @@ FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { |
| } |
| } |
| if (iSel >= 0) { |
| - CFWL_ListItem* pSel = |
| - (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, iSel); |
| + CFWL_ListItem* pSel = (CFWL_ListItem*)m_ListBoxDP.GetItem(m_pIface, iSel); |
| pSel->m_dwStates |= FWL_ITEMSTATE_LTB_Selected; |
| } |
| m_ListBoxDP.m_arrItem.RemoveAt(nIndex); |
| @@ -62,10 +60,9 @@ FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) { |
| return TRUE; |
| } |
| FX_BOOL CFWL_ListBox::DeleteAll() { |
| - int32_t iCount = m_ListBoxDP.CountItems((IFWL_ListBox*)this); |
| + int32_t iCount = m_ListBoxDP.CountItems(m_pIface); |
| for (int32_t i = 0; i < iCount; i++) { |
| - CFWL_ListItem* pItem = |
| - (CFWL_ListItem*)m_ListBoxDP.GetItem((IFWL_ListBox*)this, i); |
| + CFWL_ListItem* pItem = (CFWL_ListItem*)m_ListBoxDP.GetItem(m_pIface, i); |
| delete pItem; |
| } |
| m_ListBoxDP.m_arrItem.RemoveAll(); |
| @@ -74,32 +71,32 @@ FX_BOOL CFWL_ListBox::DeleteAll() { |
| int32_t CFWL_ListBox::CountSelItems() { |
| if (!m_pIface) |
| return 0; |
| - return ((IFWL_ListBox*)m_pIface)->CountSelItems(); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->CountSelItems(); |
| } |
| FWL_HLISTITEM CFWL_ListBox::GetSelItem(int32_t nIndexSel) { |
| if (!m_pIface) |
| return NULL; |
| - return ((IFWL_ListBox*)m_pIface)->GetSelItem(nIndexSel); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->GetSelItem(nIndexSel); |
| } |
| int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { |
| if (!m_pIface) |
| return 0; |
| - return ((IFWL_ListBox*)m_pIface)->GetSelIndex(nIndex); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->GetSelIndex(nIndex); |
| } |
| FWL_ERR CFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { |
| if (!m_pIface) |
| return FWL_ERR_Indefinite; |
| - return ((IFWL_ListBox*)m_pIface)->SetSelItem(hItem, bSelect); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->SetSelItem(hItem, bSelect); |
| } |
| FWL_ERR CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText) { |
| if (!m_pIface) |
| return FWL_ERR_Indefinite; |
| - return ((IFWL_ListBox*)m_pIface)->GetItemText(hItem, wsText); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->GetItemText(hItem, wsText); |
| } |
| FWL_ERR CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { |
| if (!m_pIface) |
| return FWL_ERR_Indefinite; |
| - return ((IFWL_ListBox*)m_pIface)->GetScrollPos(fPos, bVert); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fPos, bVert); |
| } |
| FWL_ERR CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { |
| m_ListBoxDP.m_fItemHeight = fItemHeight; |
| @@ -121,7 +118,7 @@ FWL_ERR CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) { |
| return FWL_ERR_Succeeded; |
| } |
| FWL_ERR* CFWL_ListBox::Sort(IFWL_ListBoxCompare* pCom) { |
| - return ((IFWL_ListBox*)m_pIface)->Sort(pCom); |
| + return static_cast<IFWL_ListBox*>(m_pIface)->Sort(pCom); |
| } |
| int32_t CFWL_ListBox::CountItems() { |
| return m_ListBoxDP.m_arrItem.GetSize(); |
| @@ -169,8 +166,8 @@ FWL_HLISTITEM CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { |
| fy -= rtClient.top; |
| FX_FLOAT fPosX = 0; |
| FX_FLOAT fPosY = 0; |
| - ((IFWL_ListBox*)m_pIface)->GetScrollPos(fx); |
| - ((IFWL_ListBox*)m_pIface)->GetScrollPos(fy, FALSE); |
| + static_cast<IFWL_ListBox*>(m_pIface)->GetScrollPos(fx); |
| + 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); |
| @@ -234,14 +231,14 @@ FX_DWORD CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget, |
| FWL_HLISTITEM hItem) { |
| if (!hItem) |
| return -1; |
| - return ((CFWL_ListItem*)hItem)->m_dwStates; |
| + return reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates; |
| } |
| FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget, |
| FWL_HLISTITEM hItem, |
| CFX_WideString& wsText) { |
| if (!hItem) |
| return FWL_ERR_Indefinite; |
| - wsText = ((CFWL_ListItem*)hItem)->m_wsText; |
| + wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText; |
| return FWL_ERR_Succeeded; |
| } |
| FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget, |
| @@ -249,7 +246,7 @@ FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget, |
| CFX_RectF& rtItem) { |
| if (!hItem) |
| return FWL_ERR_Indefinite; |
| - CFWL_ListItem* pItem = (CFWL_ListItem*)hItem; |
| + CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem); |
| rtItem = pItem->m_rtItem; |
| return FWL_ERR_Succeeded; |
| } |
| @@ -257,7 +254,7 @@ void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget, |
| FWL_HLISTITEM hItem) { |
| if (!hItem) |
| return NULL; |
| - CFWL_ListItem* pItem = (CFWL_ListItem*)hItem; |
| + CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem); |
| return pItem->m_pData; |
| } |
| FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
| @@ -265,7 +262,7 @@ FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget, |
| FX_DWORD dwStyle) { |
| if (!hItem) |
| return FWL_ERR_Indefinite; |
| - ((CFWL_ListItem*)hItem)->m_dwStates = dwStyle; |
| + reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates = dwStyle; |
| return FWL_ERR_Succeeded; |
| } |
| FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget, |
| @@ -273,7 +270,7 @@ FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget, |
| const FX_WCHAR* pszText) { |
| if (!hItem) |
| return FWL_ERR_Indefinite; |
| - ((CFWL_ListItem*)hItem)->m_wsText = pszText; |
| + reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = pszText; |
| return FWL_ERR_Succeeded; |
| } |
| FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget, |
| @@ -281,7 +278,7 @@ FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget, |
| const CFX_RectF& rtItem) { |
| if (!hItem) |
| return FWL_ERR_Indefinite; |
| - ((CFWL_ListItem*)hItem)->m_rtItem = rtItem; |
| + reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtItem = rtItem; |
| return FWL_ERR_Succeeded; |
| } |
| FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) { |
| @@ -289,7 +286,7 @@ FX_FLOAT CFWL_ListBox::CFWL_ListBoxDP::GetItemHeight(IFWL_Widget* pWidget) { |
| } |
| CFX_DIBitmap* CFWL_ListBox::CFWL_ListBoxDP::GetItemIcon(IFWL_Widget* pWidget, |
| FWL_HLISTITEM hItem) { |
| - return ((CFWL_ListItem*)hItem)->m_pDIB; |
| + return reinterpret_cast<CFWL_ListItem*>(hItem)->m_pDIB; |
| } |
| FWL_ERR CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget, |
| FWL_HLISTITEM hItem, |