summaryrefslogtreecommitdiff
path: root/xfa/fwl/lightwidget
diff options
context:
space:
mode:
authortsepez <tsepez@chromium.org>2016-06-02 14:17:40 -0700
committerCommit bot <commit-bot@chromium.org>2016-06-02 14:17:40 -0700
commitad700c2c1fc3c3843dae71e5982f462e42efc987 (patch)
tree9d996c8101e0d467a278d51a90f0cf4889ef358e /xfa/fwl/lightwidget
parentec409315f876bbac0e73abacfe73ef9bd1dd3db9 (diff)
downloadpdfium-ad700c2c1fc3c3843dae71e5982f462e42efc987.tar.xz
Replace FWL_HLISTITEM with class IFWL_ListItem {}
Make CFWL_ classes inherit from IFWL_ListItem. Replace reinterpret_casts with static_casts. Review-Url: https://codereview.chromium.org/2029923002
Diffstat (limited to 'xfa/fwl/lightwidget')
-rw-r--r--xfa/fwl/lightwidget/cfwl_combobox.cpp104
-rw-r--r--xfa/fwl/lightwidget/cfwl_combobox.h38
-rw-r--r--xfa/fwl/lightwidget/cfwl_listbox.cpp164
-rw-r--r--xfa/fwl/lightwidget/cfwl_listbox.h64
4 files changed, 181 insertions, 189 deletions
diff --git a/xfa/fwl/lightwidget/cfwl_combobox.cpp b/xfa/fwl/lightwidget/cfwl_combobox.cpp
index d70113b18a..934b0d856e 100644
--- a/xfa/fwl/lightwidget/cfwl_combobox.cpp
+++ b/xfa/fwl/lightwidget/cfwl_combobox.cpp
@@ -69,8 +69,8 @@ int32_t CFWL_ComboBox::CountItems() {
FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex,
CFX_WideString& wsText) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(
- m_comboBoxData.GetItem(m_pIface, iIndex));
+ CFWL_ComboBoxItem* pItem =
+ static_cast<CFWL_ComboBoxItem*>(m_comboBoxData.GetItem(m_pIface, iIndex));
if (!pItem)
return FWL_Error::Indefinite;
wsText = pItem->m_wsText;
@@ -158,8 +158,8 @@ FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) {
}
FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(
- m_comboBoxData.GetItem(m_pIface, iIndex));
+ CFWL_ComboBoxItem* pItem =
+ static_cast<CFWL_ComboBoxItem*>(m_comboBoxData.GetItem(m_pIface, iIndex));
if (!pItem)
return FWL_Error::Indefinite;
pItem->m_pData = pData;
@@ -167,8 +167,8 @@ FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) {
}
void* CFWL_ComboBox::GetItemData(int32_t iIndex) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(
- m_comboBoxData.GetItem(m_pIface, iIndex));
+ CFWL_ComboBoxItem* pItem =
+ static_cast<CFWL_ComboBoxItem*>(m_comboBoxData.GetItem(m_pIface, iIndex));
if (!pItem)
return NULL;
return pItem->m_pData;
@@ -294,93 +294,92 @@ int32_t CFWL_ComboBox::CFWL_ComboBoxDP::CountItems(IFWL_Widget* pWidget) {
return m_ItemArray.size();
}
-FWL_HLISTITEM CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget,
- int32_t nIndex) {
+IFWL_ListItem* CFWL_ComboBox::CFWL_ComboBoxDP::GetItem(IFWL_Widget* pWidget,
+ int32_t nIndex) {
if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size())
return nullptr;
- return reinterpret_cast<FWL_HLISTITEM>(m_ItemArray[nIndex].get());
+ return m_ItemArray[nIndex].get();
}
int32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIndex(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
+ IFWL_ListItem* pItem) {
auto it = std::find_if(
m_ItemArray.begin(), m_ItemArray.end(),
- [hItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) {
- return candidate.get() == reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
+ [pItem](const std::unique_ptr<CFWL_ComboBoxItem>& candidate) {
+ return candidate.get() == static_cast<CFWL_ComboBoxItem*>(pItem);
});
return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1;
}
FX_BOOL CFWL_ComboBox::CFWL_ComboBoxDP::SetItemIndex(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
int32_t nIndex) {
if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size())
return FALSE;
- m_ItemArray[nIndex].reset(reinterpret_cast<CFWL_ComboBoxItem*>(hItem));
+ m_ItemArray[nIndex].reset(static_cast<CFWL_ComboBoxItem*>(pItem));
return TRUE;
}
uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
- if (!hItem)
+ IFWL_ListItem* pItem) {
+ if (!pItem)
return 0;
- return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles;
+ return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_WideString& wsText) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- wsText = reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText;
+ wsText = static_cast<CFWL_ComboBoxItem*>(pItem)->m_wsText;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtItem) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
- rtItem.Set(pItem->m_rtItem.left, pItem->m_rtItem.top, pItem->m_rtItem.width,
- pItem->m_rtItem.height);
+ CFWL_ComboBoxItem* pComboItem = static_cast<CFWL_ComboBoxItem*>(pItem);
+ rtItem.Set(pComboItem->m_rtItem.left, pComboItem->m_rtItem.top,
+ pComboItem->m_rtItem.width, pComboItem->m_rtItem.height);
return FWL_Error::Succeeded;
}
void* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemData(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
- if (!hItem)
+ IFWL_ListItem* pItem) {
+ if (!pItem)
return NULL;
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
- return pItem->m_pData;
+ return static_cast<CFWL_ComboBoxItem*>(pItem)->m_pData;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwStyle) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_dwStyles = dwStyle;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwStyles = dwStyle;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const FX_WCHAR* pszText) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_wsText = pszText;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_wsText = pszText;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtItem) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_rtItem = rtItem;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtItem = rtItem;
return FWL_Error::Succeeded;
}
@@ -388,43 +387,40 @@ FX_FLOAT CFWL_ComboBox::CFWL_ComboBoxDP::GetItemHeight(IFWL_Widget* pWidget) {
return m_fItemHeight;
}
-CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
- if (!hItem)
+CFX_DIBitmap* CFWL_ComboBox::CFWL_ComboBoxDP::GetItemIcon(
+ IFWL_Widget* pWidget,
+ IFWL_ListItem* pItem) {
+ if (!pItem)
return NULL;
- return reinterpret_cast<CFWL_ComboBoxItem*>(hItem)->m_pDIB;
+ return static_cast<CFWL_ComboBoxItem*>(pItem)->m_pDIB;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtCheck) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
- rtCheck = pItem->m_rtCheckBox;
+ rtCheck = static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtCheckBox;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckRect(
IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtCheck) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
- pItem->m_rtCheckBox = rtCheck;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_rtCheckBox = rtCheck;
return FWL_Error::Succeeded;
}
uint32_t CFWL_ComboBox::CFWL_ComboBoxDP::GetItemCheckState(
IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
- return pItem->m_dwCheckState;
+ IFWL_ListItem* pItem) {
+ return static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwCheckState;
}
FWL_Error CFWL_ComboBox::CFWL_ComboBoxDP::SetItemCheckState(
IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwCheckState) {
- CFWL_ComboBoxItem* pItem = reinterpret_cast<CFWL_ComboBoxItem*>(hItem);
- pItem->m_dwCheckState = dwCheckState;
+ static_cast<CFWL_ComboBoxItem*>(pItem)->m_dwCheckState = dwCheckState;
return FWL_Error::Succeeded;
}
diff --git a/xfa/fwl/lightwidget/cfwl_combobox.h b/xfa/fwl/lightwidget/cfwl_combobox.h
index b5d0327ba9..a708589d4f 100644
--- a/xfa/fwl/lightwidget/cfwl_combobox.h
+++ b/xfa/fwl/lightwidget/cfwl_combobox.h
@@ -79,42 +79,42 @@ class CFWL_ComboBox : public CFWL_Widget {
}
virtual int32_t CountItems(IFWL_Widget* pWidget);
- virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex);
- virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem);
+ virtual IFWL_ListItem* GetItem(IFWL_Widget* pWidget, int32_t nIndex);
+ virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem);
virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
int32_t nIndex);
- virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem);
+ virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, IFWL_ListItem* pItem);
virtual FWL_Error GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_WideString& wsText);
virtual FWL_Error GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtItem);
- virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem);
+ virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem);
virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwStyle);
virtual FWL_Error SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const FX_WCHAR* pszText);
virtual FWL_Error SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtItem);
virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget);
virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem);
+ IFWL_ListItem* pItem);
virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtCheck);
virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtCheck);
virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem);
+ IFWL_ListItem* pItem);
virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwCheckState);
virtual FX_FLOAT GetListHeight(IFWL_Widget* pWidget);
@@ -125,12 +125,10 @@ class CFWL_ComboBox : public CFWL_Widget {
CFWL_ComboBoxDP m_comboBoxData;
};
-class CFWL_ComboBoxItem {
+class CFWL_ComboBoxItem : public IFWL_ListItem {
public:
- CFWL_ComboBoxItem() {
- m_pDIB = NULL;
- m_pData = NULL;
- }
+ CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {}
+
CFX_RectF m_rtItem;
uint32_t m_dwStyles;
CFX_WideString m_wsText;
diff --git a/xfa/fwl/lightwidget/cfwl_listbox.cpp b/xfa/fwl/lightwidget/cfwl_listbox.cpp
index e8e26f5b52..d51db44f3b 100644
--- a/xfa/fwl/lightwidget/cfwl_listbox.cpp
+++ b/xfa/fwl/lightwidget/cfwl_listbox.cpp
@@ -31,23 +31,23 @@ 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* pItem) {
+ static_cast<CFWL_ListItem*>(pItem)->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 m_ListBoxDP.m_ItemArray.back().get();
}
-FX_BOOL CFWL_ListBox::DeleteString(FWL_HLISTITEM hItem) {
- int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
+FX_BOOL CFWL_ListBox::DeleteString(IFWL_ListItem* pItem) {
+ int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), pItem);
if (nIndex < 0 ||
static_cast<size_t>(nIndex) >= m_ListBoxDP.m_ItemArray.size()) {
return FALSE;
@@ -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,17 +91,17 @@ 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* pItem, FX_BOOL bSelect) {
if (!m_pIface)
return FWL_Error::Indefinite;
- return static_cast<IFWL_ListBox*>(m_pIface)->SetSelItem(hItem, bSelect);
+ return static_cast<IFWL_ListBox*>(m_pIface)->SetSelItem(pItem, bSelect);
}
-FWL_Error CFWL_ListBox::GetItemText(FWL_HLISTITEM hItem,
+FWL_Error CFWL_ListBox::GetItemText(IFWL_ListItem* pItem,
CFX_WideString& wsText) {
if (!m_pIface)
return FWL_Error::Indefinite;
- return static_cast<IFWL_ListBox*>(m_pIface)->GetItemText(hItem, wsText);
+ return static_cast<IFWL_ListBox*>(m_pIface)->GetItemText(pItem, wsText);
}
FWL_Error CFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) {
@@ -115,16 +115,16 @@ FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) {
return FWL_Error::Succeeded;
}
-FWL_HLISTITEM CFWL_ListBox::GetFocusItem() {
- for (const auto& hItem : m_ListBoxDP.m_ItemArray) {
- if (hItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused)
- return (FWL_HLISTITEM)hItem.get();
+IFWL_ListItem* CFWL_ListBox::GetFocusItem() {
+ for (const auto& pItem : m_ListBoxDP.m_ItemArray) {
+ if (pItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused)
+ return pItem.get();
}
return nullptr;
}
-FWL_Error CFWL_ListBox::SetFocusItem(FWL_HLISTITEM hItem) {
- int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), hItem);
+FWL_Error CFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) {
+ int32_t nIndex = m_ListBoxDP.GetItemIndex(GetWidget(), pItem);
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 m_ListBoxDP.m_ItemArray[nIndex].get();
}
-FWL_Error CFWL_ListBox::SetItemString(FWL_HLISTITEM hItem,
+FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* pItem,
const CFX_WideStringC& wsText) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = wsText;
+ static_cast<CFWL_ListItem*>(pItem)->m_wsText = wsText;
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBox::GetItemString(FWL_HLISTITEM hItem,
+FWL_Error CFWL_ListBox::GetItemString(IFWL_ListItem* pItem,
CFX_WideString& wsText) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText;
+ wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText;
return FWL_Error::Succeeded;
}
-FWL_Error CFWL_ListBox::SetItemData(FWL_HLISTITEM hItem, void* pData) {
- if (!hItem)
+FWL_Error CFWL_ListBox::SetItemData(IFWL_ListItem* pItem, void* pData) {
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_pData = pData;
+ static_cast<CFWL_ListItem*>(pItem)->m_pData = pData;
return FWL_Error::Succeeded;
}
-void* CFWL_ListBox::GetItemData(FWL_HLISTITEM hItem) {
- if (!hItem)
+void* CFWL_ListBox::GetItemData(IFWL_ListItem* pItem) {
+ if (!pItem)
return NULL;
- return reinterpret_cast<CFWL_ListItem*>(hItem)->m_pData;
+ return static_cast<CFWL_ListItem*>(pItem)->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,25 +180,25 @@ 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);
- if (!hItem) {
+ IFWL_ListItem* pItem = m_ListBoxDP.GetItem(NULL, i);
+ if (!pItem) {
continue;
}
CFX_RectF rtItem;
- m_ListBoxDP.GetItemRect(NULL, hItem, rtItem);
+ m_ListBoxDP.GetItemRect(NULL, pItem, rtItem);
rtItem.Offset(-fPosX, -fPosY);
if (rtItem.Contains(fx, fy)) {
- return hItem;
+ return pItem;
}
}
return NULL;
}
-uint32_t CFWL_ListBox::GetItemStates(FWL_HLISTITEM hItem) {
- if (!hItem)
+uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) {
+ if (!pItem)
return 0;
- CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem);
- return pItem->m_dwStates | pItem->m_dwCheckState;
+ CFWL_ListItem* pListItem = static_cast<CFWL_ListItem*>(pItem);
+ return pListItem->m_dwStates | pListItem->m_dwCheckState;
}
CFWL_ListBox::CFWL_ListBox() {}
@@ -219,91 +219,89 @@ 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 m_ItemArray[nIndex].get();
}
int32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemIndex(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
+ IFWL_ListItem* pItem) {
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);
+ [pItem](const std::unique_ptr<CFWL_ListItem>& candidate) {
+ return candidate.get() == static_cast<CFWL_ListItem*>(pItem);
});
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* pItem,
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*>(pItem));
return TRUE;
}
uint32_t CFWL_ListBox::CFWL_ListBoxDP::GetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
- if (!hItem)
+ IFWL_ListItem* pItem) {
+ if (!pItem)
return 0;
- return reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates;
+ return static_cast<CFWL_ListItem*>(pItem)->m_dwStates;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_WideString& wsText) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- wsText = reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText;
+ wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtItem) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem);
- rtItem = pItem->m_rtItem;
+ rtItem = static_cast<CFWL_ListItem*>(pItem)->m_rtItem;
return FWL_Error::Succeeded;
}
void* CFWL_ListBox::CFWL_ListBoxDP::GetItemData(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) {
- if (!hItem)
+ IFWL_ListItem* pItem) {
+ if (!pItem)
return NULL;
- CFWL_ListItem* pItem = reinterpret_cast<CFWL_ListItem*>(hItem);
- return pItem->m_pData;
+ return static_cast<CFWL_ListItem*>(pItem)->m_pData;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwStyle) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwStates = dwStyle;
+ static_cast<CFWL_ListItem*>(pItem)->m_dwStates = dwStyle;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const FX_WCHAR* pszText) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_wsText = pszText;
+ static_cast<CFWL_ListItem*>(pItem)->m_wsText = pszText;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtItem) {
- if (!hItem)
+ if (!pItem)
return FWL_Error::Indefinite;
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtItem = rtItem;
+ static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem;
return FWL_Error::Succeeded;
}
@@ -312,34 +310,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* pItem) {
+ return static_cast<CFWL_ListItem*>(pItem)->m_pDIB;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtCheck) {
- rtCheck = reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox;
+ rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox;
return FWL_Error::Succeeded;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckRect(
IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtCheck) {
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_rtCheckBox = rtCheck;
+ static_cast<CFWL_ListItem*>(pItem)->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* pItem) {
+ return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState;
}
FWL_Error CFWL_ListBox::CFWL_ListBoxDP::SetItemCheckState(
IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwCheckState) {
- reinterpret_cast<CFWL_ListItem*>(hItem)->m_dwCheckState = dwCheckState;
+ static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState;
return FWL_Error::Succeeded;
}
diff --git a/xfa/fwl/lightwidget/cfwl_listbox.h b/xfa/fwl/lightwidget/cfwl_listbox.h
index a40d0f975c..7d79893fa6 100644
--- a/xfa/fwl/lightwidget/cfwl_listbox.h
+++ b/xfa/fwl/lightwidget/cfwl_listbox.h
@@ -21,28 +21,28 @@ class CFWL_ListBox : public CFWL_Widget {
public:
static CFWL_ListBox* Create();
FWL_Error Initialize(const CFWL_WidgetProperties* pProperties = NULL);
- FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, FWL_HLISTITEM hItem);
- FWL_HLISTITEM AddString(const CFX_WideStringC& wsAdd,
- FX_BOOL bSelect = FALSE);
- FX_BOOL DeleteString(FWL_HLISTITEM hItem);
+ FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem);
+ IFWL_ListItem* AddString(const CFX_WideStringC& wsAdd,
+ FX_BOOL bSelect = FALSE);
+ FX_BOOL DeleteString(IFWL_ListItem* pItem);
void DeleteAll();
int32_t CountSelItems();
- FWL_HLISTITEM GetSelItem(int32_t nIndexSel);
+ IFWL_ListItem* GetSelItem(int32_t nIndexSel);
int32_t GetSelIndex(int32_t nIndex);
- FWL_Error SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect = TRUE);
- FWL_Error GetItemText(FWL_HLISTITEM hItem, CFX_WideString& wsText);
+ FWL_Error SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect = TRUE);
+ FWL_Error GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText);
FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE);
FWL_Error SetItemHeight(FX_FLOAT fItemHeight);
- FWL_HLISTITEM GetFocusItem();
- FWL_Error SetFocusItem(FWL_HLISTITEM hItem);
+ IFWL_ListItem* GetFocusItem();
+ FWL_Error SetFocusItem(IFWL_ListItem* pItem);
int32_t CountItems();
- FWL_HLISTITEM GetItem(int32_t nIndex);
- FWL_Error SetItemString(FWL_HLISTITEM hItem, const CFX_WideStringC& wsText);
- FWL_Error GetItemString(FWL_HLISTITEM hItem, CFX_WideString& wsText);
- FWL_Error SetItemData(FWL_HLISTITEM hItem, void* pData);
- void* GetItemData(FWL_HLISTITEM hItem);
- FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
- uint32_t GetItemStates(FWL_HLISTITEM hItem);
+ IFWL_ListItem* GetItem(int32_t nIndex);
+ FWL_Error SetItemString(IFWL_ListItem* pItem, const CFX_WideStringC& wsText);
+ FWL_Error GetItemString(IFWL_ListItem* pItem, CFX_WideString& wsText);
+ FWL_Error SetItemData(IFWL_ListItem* pItem, void* pData);
+ void* GetItemData(IFWL_ListItem* pItem);
+ IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy);
+ uint32_t GetItemStates(IFWL_ListItem* pItem);
CFWL_ListBox();
virtual ~CFWL_ListBox();
@@ -58,41 +58,41 @@ class CFWL_ListBox : public CFWL_Widget {
// IFWL_ListBoxDP:
int32_t CountItems(IFWL_Widget* pWidget) override;
- FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex) override;
- int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override;
+ IFWL_ListItem* GetItem(IFWL_Widget* pWidget, int32_t nIndex) override;
+ int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
FX_BOOL SetItemIndex(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
int32_t nIndex) override;
- uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override;
+ uint32_t GetItemStyles(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
FWL_Error GetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_WideString& wsText) override;
FWL_Error GetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtItem) override;
- void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) override;
+ void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override;
FWL_Error SetItemStyles(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwStyle) override;
FWL_Error SetItemText(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const FX_WCHAR* pszText) override;
FWL_Error SetItemRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtItem) override;
FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override;
CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) override;
+ IFWL_ListItem* pItem) override;
FWL_Error GetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
CFX_RectF& rtCheck) override;
FWL_Error SetItemCheckRect(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
const CFX_RectF& rtCheck) override;
uint32_t GetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem) override;
+ IFWL_ListItem* pItem) override;
FWL_Error SetItemCheckState(IFWL_Widget* pWidget,
- FWL_HLISTITEM hItem,
+ IFWL_ListItem* pItem,
uint32_t dwCheckState) override;
std::vector<std::unique_ptr<CFWL_ListItem>> m_ItemArray;
@@ -103,7 +103,7 @@ class CFWL_ListBox : public CFWL_Widget {
CFWL_ListBoxDP m_ListBoxDP;
};
-class CFWL_ListItem {
+class CFWL_ListItem : public IFWL_ListItem {
public:
CFWL_ListItem() {
m_rtItem.Reset();