From 3ff4deea307c38462393e4f83dabe32949338168 Mon Sep 17 00:00:00 2001 From: dsinclair Date: Wed, 9 Nov 2016 10:09:03 -0800 Subject: Rename IFWL_ListItem to CFWL_ListItem This CL removes the empty IFWL_ListItem class and uses CFWL_ListItem in its place. As well, the CFWL_ComboListItem is removed and replaced with CFWL_ListItem. These were almost duplicate classes and the one missing field added to CFWL_ListItem. Review-Url: https://codereview.chromium.org/2487943003 --- BUILD.gn | 2 + xfa/fwl/core/cfwl_combobox.cpp | 80 +++++++++++++++++++-------------------- xfa/fwl/core/cfwl_combobox.h | 46 ++++++++-------------- xfa/fwl/core/cfwl_listbox.cpp | 74 +++++++++++++++--------------------- xfa/fwl/core/cfwl_listbox.h | 74 +++++++++++++++--------------------- xfa/fwl/core/cfwl_listitem.cpp | 19 ++++++++++ xfa/fwl/core/cfwl_listitem.h | 30 +++++++++++++++ xfa/fwl/core/ifwl_combobox.cpp | 18 ++++----- xfa/fwl/core/ifwl_combolist.cpp | 16 ++++---- xfa/fwl/core/ifwl_listbox.cpp | 76 ++++++++++++++++++------------------- xfa/fwl/core/ifwl_listbox.h | 71 +++++++++++++++++----------------- xfa/fxfa/app/xfa_ffchoicelist.cpp | 10 ++--- 12 files changed, 261 insertions(+), 255 deletions(-) create mode 100644 xfa/fwl/core/cfwl_listitem.cpp create mode 100644 xfa/fwl/core/cfwl_listitem.h diff --git a/BUILD.gn b/BUILD.gn index 945b5a9a5b..cf25d5a639 100644 --- a/BUILD.gn +++ b/BUILD.gn @@ -1178,6 +1178,8 @@ if (pdf_enable_xfa) { "xfa/fwl/core/cfwl_event.h", "xfa/fwl/core/cfwl_listbox.cpp", "xfa/fwl/core/cfwl_listbox.h", + "xfa/fwl/core/cfwl_listitem.cpp", + "xfa/fwl/core/cfwl_listitem.h", "xfa/fwl/core/cfwl_message.h", "xfa/fwl/core/cfwl_picturebox.cpp", "xfa/fwl/core/cfwl_picturebox.h", diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp index fa2698be6e..9b2cf7fe41 100644 --- a/xfa/fwl/core/cfwl_combobox.cpp +++ b/xfa/fwl/core/cfwl_combobox.cpp @@ -39,7 +39,7 @@ void CFWL_ComboBox::Initialize() { } int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { - std::unique_ptr pItem(new CFWL_ComboBoxItem); + std::unique_ptr pItem(new CFWL_ListItem); pItem->m_wsText = wsText; pItem->m_dwStyles = 0; m_ItemArray.push_back(std::move(pItem)); @@ -48,7 +48,7 @@ int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText, CFX_DIBitmap* pIcon) { - std::unique_ptr pItem(new CFWL_ComboBoxItem); + std::unique_ptr pItem(new CFWL_ListItem); pItem->m_wsText = wsText; pItem->m_dwStyles = 0; pItem->m_pDIB = pIcon; @@ -74,8 +74,8 @@ int32_t CFWL_ComboBox::CountItems() { FWL_Error CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) { - CFWL_ComboBoxItem* pItem = - static_cast(GetItem(m_pIface.get(), iIndex)); + CFWL_ListItem* pItem = + static_cast(GetItem(m_pIface.get(), iIndex)); if (!pItem) return FWL_Error::Indefinite; wsText = pItem->m_wsText; @@ -146,8 +146,8 @@ FWL_Error CFWL_ComboBox::SetMaxListHeight(FX_FLOAT fMaxHeight) { } FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { - CFWL_ComboBoxItem* pItem = - static_cast(GetItem(m_pIface.get(), iIndex)); + CFWL_ListItem* pItem = + static_cast(GetItem(m_pIface.get(), iIndex)); if (!pItem) return FWL_Error::Indefinite; pItem->m_pData = pData; @@ -155,8 +155,8 @@ FWL_Error CFWL_ComboBox::SetItemData(int32_t iIndex, void* pData) { } void* CFWL_ComboBox::GetItemData(int32_t iIndex) { - CFWL_ComboBoxItem* pItem = - static_cast(GetItem(m_pIface.get(), iIndex)); + CFWL_ListItem* pItem = + static_cast(GetItem(m_pIface.get(), iIndex)); return pItem ? pItem->m_pData : nullptr; } @@ -246,7 +246,7 @@ int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) { return m_ItemArray.size(); } -IFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, +CFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, int32_t nIndex) { if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) return nullptr; @@ -255,80 +255,80 @@ IFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, } int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { + CFWL_ListItem* pItem) { auto it = std::find_if( m_ItemArray.begin(), m_ItemArray.end(), - [pItem](const std::unique_ptr& candidate) { - return candidate.get() == static_cast(pItem); + [pItem](const std::unique_ptr& candidate) { + return candidate.get() == static_cast(pItem); }); return it != m_ItemArray.end() ? it - m_ItemArray.begin() : -1; } bool CFWL_ComboBox::SetItemIndex(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, int32_t nIndex) { if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) return false; - m_ItemArray[nIndex].reset(static_cast(pItem)); + m_ItemArray[nIndex].reset(static_cast(pItem)); return true; } uint32_t CFWL_ComboBox::GetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { + CFWL_ListItem* pItem) { if (!pItem) return 0; - return static_cast(pItem)->m_dwStyles; + return static_cast(pItem)->m_dwStyles; } FWL_Error CFWL_ComboBox::GetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_WideString& wsText) { if (!pItem) return FWL_Error::Indefinite; - wsText = static_cast(pItem)->m_wsText; + wsText = static_cast(pItem)->m_wsText; return FWL_Error::Succeeded; } FWL_Error CFWL_ComboBox::GetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtItem) { if (!pItem) return FWL_Error::Indefinite; - CFWL_ComboBoxItem* pComboItem = static_cast(pItem); + CFWL_ListItem* pComboItem = static_cast(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::GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) { - return pItem ? static_cast(pItem)->m_pData : nullptr; +void* CFWL_ComboBox::GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { + return pItem ? static_cast(pItem)->m_pData : nullptr; } FWL_Error CFWL_ComboBox::SetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwStyle) { if (!pItem) return FWL_Error::Indefinite; - static_cast(pItem)->m_dwStyles = dwStyle; + static_cast(pItem)->m_dwStyles = dwStyle; return FWL_Error::Succeeded; } FWL_Error CFWL_ComboBox::SetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const FX_WCHAR* pszText) { if (!pItem) return FWL_Error::Indefinite; - static_cast(pItem)->m_wsText = pszText; + static_cast(pItem)->m_wsText = pszText; return FWL_Error::Succeeded; } FWL_Error CFWL_ComboBox::SetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtItem) { if (!pItem) return FWL_Error::Indefinite; - static_cast(pItem)->m_rtItem = rtItem; + static_cast(pItem)->m_rtItem = rtItem; return FWL_Error::Succeeded; } @@ -337,40 +337,36 @@ FX_FLOAT CFWL_ComboBox::GetItemHeight(IFWL_Widget* pWidget) { } CFX_DIBitmap* CFWL_ComboBox::GetItemIcon(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { - return pItem ? static_cast(pItem)->m_pDIB : nullptr; + CFWL_ListItem* pItem) { + return pItem ? static_cast(pItem)->m_pDIB : nullptr; } FWL_Error CFWL_ComboBox::GetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtCheck) { - rtCheck = static_cast(pItem)->m_rtCheckBox; + rtCheck = static_cast(pItem)->m_rtCheckBox; return FWL_Error::Succeeded; } FWL_Error CFWL_ComboBox::SetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtCheck) { - static_cast(pItem)->m_rtCheckBox = rtCheck; + static_cast(pItem)->m_rtCheckBox = rtCheck; return FWL_Error::Succeeded; } uint32_t CFWL_ComboBox::GetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { - return static_cast(pItem)->m_dwCheckState; + CFWL_ListItem* pItem) { + return static_cast(pItem)->m_dwCheckState; } FWL_Error CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwCheckState) { - static_cast(pItem)->m_dwCheckState = dwCheckState; + static_cast(pItem)->m_dwCheckState = dwCheckState; return FWL_Error::Succeeded; } FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { return m_fMaxListHeight; } - -CFWL_ComboBoxItem::CFWL_ComboBoxItem() : m_pDIB(nullptr), m_pData(nullptr) {} - -CFWL_ComboBoxItem::~CFWL_ComboBoxItem() {} diff --git a/xfa/fwl/core/cfwl_combobox.h b/xfa/fwl/core/cfwl_combobox.h index cd409ffbc1..4b544b4530 100644 --- a/xfa/fwl/core/cfwl_combobox.h +++ b/xfa/fwl/core/cfwl_combobox.h @@ -13,20 +13,6 @@ #include "xfa/fwl/core/cfwl_widget.h" #include "xfa/fwl/core/ifwl_combobox.h" -class CFWL_ComboBoxItem : public IFWL_ListItem { - public: - CFWL_ComboBoxItem(); - ~CFWL_ComboBoxItem(); - - CFX_RectF m_rtItem; - uint32_t m_dwStyles; - CFX_WideString m_wsText; - CFX_DIBitmap* m_pDIB; - uint32_t m_dwCheckState; - CFX_RectF m_rtCheckBox; - void* m_pData; -}; - class CFWL_ComboBox : public CFWL_Widget, public IFWL_ComboBoxDP { public: CFWL_ComboBox(const IFWL_App*); @@ -84,49 +70,49 @@ class CFWL_ComboBox : public CFWL_Widget, public IFWL_ComboBoxDP { // IFWL_ListBoxDP int32_t CountItems(const IFWL_Widget* pWidget) override; - IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) override; - int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override; + CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) override; + int32_t GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) override; bool SetItemIndex(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, int32_t nIndex) override; - uint32_t GetItemStyles(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override; + uint32_t GetItemStyles(IFWL_Widget* pWidget, CFWL_ListItem* pItem) override; FWL_Error GetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_WideString& wsText) override; FWL_Error GetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtItem) override; - void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override; + void* GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) override; FWL_Error SetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwStyle) override; FWL_Error SetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const FX_WCHAR* pszText) override; FWL_Error SetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtItem) override; FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override; CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) override; + CFWL_ListItem* pItem) override; FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtCheck) override; FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtCheck) override; uint32_t GetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) override; + CFWL_ListItem* pItem) override; FWL_Error SetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwCheckState) override; // IFWL_ComboBoxDP FX_FLOAT GetListHeight(IFWL_Widget* pWidget) override; private: - std::vector> m_ItemArray; + std::vector> m_ItemArray; FX_FLOAT m_fMaxListHeight; FX_FLOAT m_fItemHeight; }; diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp index 458a0eb647..a569ad056e 100644 --- a/xfa/fwl/core/cfwl_listbox.cpp +++ b/xfa/fwl/core/cfwl_listbox.cpp @@ -32,12 +32,12 @@ void CFWL_ListBox::Initialize() { CFWL_Widget::Initialize(); } -FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem) { +FWL_Error CFWL_ListBox::AddDIBitmap(CFX_DIBitmap* pDIB, CFWL_ListItem* pItem) { static_cast(pItem)->m_pDIB = pDIB; return FWL_Error::Succeeded; } -IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, +CFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, bool bSelect) { std::unique_ptr pItem(new CFWL_ListItem); pItem->m_dwStates = 0; @@ -47,7 +47,7 @@ IFWL_ListItem* CFWL_ListBox::AddString(const CFX_WideStringC& wsAdd, return m_ItemArray.back().get(); } -bool CFWL_ListBox::DeleteString(IFWL_ListItem* pItem) { +bool CFWL_ListBox::DeleteString(CFWL_ListItem* pItem) { int32_t nIndex = GetItemIndex(GetWidget(), pItem); if (nIndex < 0 || static_cast(nIndex) >= m_ItemArray.size()) { return false; @@ -79,7 +79,7 @@ int32_t CFWL_ListBox::CountSelItems() { return ToListBox(GetWidget())->CountSelItems(); } -IFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { +CFWL_ListItem* CFWL_ListBox::GetSelItem(int32_t nIndexSel) { if (!GetWidget()) return nullptr; return ToListBox(GetWidget())->GetSelItem(nIndexSel); @@ -91,13 +91,13 @@ int32_t CFWL_ListBox::GetSelIndex(int32_t nIndex) { return ToListBox(GetWidget())->GetSelIndex(nIndex); } -FWL_Error CFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, bool bSelect) { +FWL_Error CFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { if (!GetWidget()) return FWL_Error::Indefinite; return ToListBox(GetWidget())->SetSelItem(pItem, bSelect); } -FWL_Error CFWL_ListBox::GetItemText(IFWL_ListItem* pItem, +FWL_Error CFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { if (!GetWidget()) return FWL_Error::Indefinite; @@ -115,7 +115,7 @@ FWL_Error CFWL_ListBox::SetItemHeight(FX_FLOAT fItemHeight) { return FWL_Error::Succeeded; } -IFWL_ListItem* CFWL_ListBox::GetFocusItem() { +CFWL_ListItem* CFWL_ListBox::GetFocusItem() { for (const auto& pItem : m_ItemArray) { if (pItem->m_dwStates & FWL_ITEMSTATE_LTB_Focused) return pItem.get(); @@ -123,7 +123,7 @@ IFWL_ListItem* CFWL_ListBox::GetFocusItem() { return nullptr; } -FWL_Error CFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) { +FWL_Error CFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) { int32_t nIndex = GetItemIndex(GetWidget(), pItem); m_ItemArray[nIndex]->m_dwStates |= FWL_ITEMSTATE_LTB_Focused; return FWL_Error::Succeeded; @@ -133,14 +133,14 @@ int32_t CFWL_ListBox::CountItems() { return pdfium::CollectionSize(m_ItemArray); } -IFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { +CFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { if (nIndex < 0 || nIndex >= CountItems()) return nullptr; return m_ItemArray[nIndex].get(); } -FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* pItem, +FWL_Error CFWL_ListBox::SetItemString(CFWL_ListItem* pItem, const CFX_WideStringC& wsText) { if (!pItem) return FWL_Error::Indefinite; @@ -148,7 +148,7 @@ FWL_Error CFWL_ListBox::SetItemString(IFWL_ListItem* pItem, return FWL_Error::Succeeded; } -FWL_Error CFWL_ListBox::GetItemString(IFWL_ListItem* pItem, +FWL_Error CFWL_ListBox::GetItemString(CFWL_ListItem* pItem, CFX_WideString& wsText) { if (!pItem) return FWL_Error::Indefinite; @@ -156,18 +156,18 @@ FWL_Error CFWL_ListBox::GetItemString(IFWL_ListItem* pItem, return FWL_Error::Succeeded; } -FWL_Error CFWL_ListBox::SetItemData(IFWL_ListItem* pItem, void* pData) { +FWL_Error CFWL_ListBox::SetItemData(CFWL_ListItem* pItem, void* pData) { if (!pItem) return FWL_Error::Indefinite; static_cast(pItem)->m_pData = pData; return FWL_Error::Succeeded; } -void* CFWL_ListBox::GetItemData(IFWL_ListItem* pItem) { +void* CFWL_ListBox::GetItemData(CFWL_ListItem* pItem) { return pItem ? static_cast(pItem)->m_pData : nullptr; } -IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { +CFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { CFX_RectF rtClient; GetWidget()->GetClientRect(rtClient); fx -= rtClient.left; @@ -178,7 +178,7 @@ IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { ToListBox(GetWidget())->GetScrollPos(fy, false); int32_t nCount = CountItems(nullptr); for (int32_t i = 0; i < nCount; i++) { - IFWL_ListItem* pItem = GetItem(nullptr, i); + CFWL_ListItem* pItem = GetItem(nullptr, i); if (!pItem) { continue; } @@ -192,7 +192,7 @@ IFWL_ListItem* CFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { return nullptr; } -uint32_t CFWL_ListBox::GetItemStates(IFWL_ListItem* pItem) { +uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { if (!pItem) return 0; CFWL_ListItem* pListItem = static_cast(pItem); @@ -209,7 +209,7 @@ int32_t CFWL_ListBox::CountItems(const IFWL_Widget* pWidget) { return pdfium::CollectionSize(m_ItemArray); } -IFWL_ListItem* CFWL_ListBox::GetItem(const IFWL_Widget* pWidget, +CFWL_ListItem* CFWL_ListBox::GetItem(const IFWL_Widget* pWidget, int32_t nIndex) { if (nIndex < 0 || nIndex >= CountItems(pWidget)) return nullptr; @@ -217,7 +217,7 @@ IFWL_ListItem* CFWL_ListBox::GetItem(const IFWL_Widget* pWidget, return m_ItemArray[nIndex].get(); } -int32_t CFWL_ListBox::GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) { +int32_t CFWL_ListBox::GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { auto it = std::find_if( m_ItemArray.begin(), m_ItemArray.end(), [pItem](const std::unique_ptr& candidate) { @@ -227,7 +227,7 @@ int32_t CFWL_ListBox::GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) { } bool CFWL_ListBox::SetItemIndex(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, int32_t nIndex) { if (nIndex < 0 || nIndex >= CountItems(pWidget)) return false; @@ -236,14 +236,14 @@ bool CFWL_ListBox::SetItemIndex(IFWL_Widget* pWidget, } uint32_t CFWL_ListBox::GetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { + CFWL_ListItem* pItem) { if (!pItem) return 0; return static_cast(pItem)->m_dwStates; } FWL_Error CFWL_ListBox::GetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_WideString& wsText) { if (!pItem) return FWL_Error::Indefinite; @@ -252,7 +252,7 @@ FWL_Error CFWL_ListBox::GetItemText(IFWL_Widget* pWidget, } FWL_Error CFWL_ListBox::GetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtItem) { if (!pItem) return FWL_Error::Indefinite; @@ -260,12 +260,12 @@ FWL_Error CFWL_ListBox::GetItemRect(IFWL_Widget* pWidget, return FWL_Error::Succeeded; } -void* CFWL_ListBox::GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) { +void* CFWL_ListBox::GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { return pItem ? static_cast(pItem)->m_pData : nullptr; } FWL_Error CFWL_ListBox::SetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwStyle) { if (!pItem) return FWL_Error::Indefinite; @@ -274,7 +274,7 @@ FWL_Error CFWL_ListBox::SetItemStyles(IFWL_Widget* pWidget, } FWL_Error CFWL_ListBox::SetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const FX_WCHAR* pszText) { if (!pItem) return FWL_Error::Indefinite; @@ -283,7 +283,7 @@ FWL_Error CFWL_ListBox::SetItemText(IFWL_Widget* pWidget, } FWL_Error CFWL_ListBox::SetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtItem) { if (!pItem) return FWL_Error::Indefinite; @@ -296,44 +296,32 @@ FX_FLOAT CFWL_ListBox::GetItemHeight(IFWL_Widget* pWidget) { } CFX_DIBitmap* CFWL_ListBox::GetItemIcon(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { + CFWL_ListItem* pItem) { return static_cast(pItem)->m_pDIB; } FWL_Error CFWL_ListBox::GetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtCheck) { rtCheck = static_cast(pItem)->m_rtCheckBox; return FWL_Error::Succeeded; } FWL_Error CFWL_ListBox::SetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtCheck) { static_cast(pItem)->m_rtCheckBox = rtCheck; return FWL_Error::Succeeded; } uint32_t CFWL_ListBox::GetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) { + CFWL_ListItem* pItem) { return static_cast(pItem)->m_dwCheckState; } FWL_Error CFWL_ListBox::SetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwCheckState) { static_cast(pItem)->m_dwCheckState = dwCheckState; return FWL_Error::Succeeded; } - -CFWL_ListItem::CFWL_ListItem() { - m_rtItem.Reset(); - m_dwStates = 0; - m_wsText = L""; - m_pDIB = nullptr; - m_pData = nullptr; - m_dwCheckState = 0; - m_rtCheckBox.Reset(); -} - -CFWL_ListItem::~CFWL_ListItem() {} diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h index d91ddff328..e28f8df7bb 100644 --- a/xfa/fwl/core/cfwl_listbox.h +++ b/xfa/fwl/core/cfwl_listbox.h @@ -15,20 +15,6 @@ #include "xfa/fwl/core/ifwl_listbox.h" #include "xfa/fwl/core/ifwl_widget.h" -class CFWL_ListItem : public IFWL_ListItem { - public: - CFWL_ListItem(); - ~CFWL_ListItem(); - - CFX_RectF m_rtItem; - uint32_t m_dwStates; - CFX_WideString m_wsText; - CFX_DIBitmap* m_pDIB; - void* m_pData; - uint32_t m_dwCheckState; - CFX_RectF m_rtCheckBox; -}; - class CFWL_ListBox : public CFWL_Widget, public IFWL_ListBoxDP { public: CFWL_ListBox(const IFWL_App*); @@ -36,27 +22,27 @@ class CFWL_ListBox : public CFWL_Widget, public IFWL_ListBoxDP { void Initialize(); - FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, IFWL_ListItem* pItem); - IFWL_ListItem* AddString(const CFX_WideStringC& wsAdd, bool bSelect = false); - bool DeleteString(IFWL_ListItem* pItem); + FWL_Error AddDIBitmap(CFX_DIBitmap* pDIB, CFWL_ListItem* pItem); + CFWL_ListItem* AddString(const CFX_WideStringC& wsAdd, bool bSelect = false); + bool DeleteString(CFWL_ListItem* pItem); void DeleteAll(); int32_t CountSelItems(); - IFWL_ListItem* GetSelItem(int32_t nIndexSel); + CFWL_ListItem* GetSelItem(int32_t nIndexSel); int32_t GetSelIndex(int32_t nIndex); - FWL_Error SetSelItem(IFWL_ListItem* pItem, bool bSelect = true); - FWL_Error GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText); + FWL_Error SetSelItem(CFWL_ListItem* pItem, bool bSelect = true); + FWL_Error GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText); FWL_Error GetScrollPos(FX_FLOAT& fPos, bool bVert = true); FWL_Error SetItemHeight(FX_FLOAT fItemHeight); - IFWL_ListItem* GetFocusItem(); - FWL_Error SetFocusItem(IFWL_ListItem* pItem); + CFWL_ListItem* GetFocusItem(); + FWL_Error SetFocusItem(CFWL_ListItem* pItem); int32_t CountItems(); - 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_ListItem* GetItem(int32_t nIndex); + FWL_Error SetItemString(CFWL_ListItem* pItem, const CFX_WideStringC& wsText); + FWL_Error GetItemString(CFWL_ListItem* pItem, CFX_WideString& wsText); + FWL_Error SetItemData(CFWL_ListItem* pItem, void* pData); + void* GetItemData(CFWL_ListItem* pItem); + CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); + uint32_t GetItemStates(CFWL_ListItem* pItem); // IFWL_DataProvider: FWL_Error GetCaption(IFWL_Widget* pWidget, @@ -64,41 +50,41 @@ class CFWL_ListBox : public CFWL_Widget, public IFWL_ListBoxDP { // IFWL_ListBoxDP: int32_t CountItems(const IFWL_Widget* pWidget) override; - IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) override; - int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override; + CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) override; + int32_t GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) override; bool SetItemIndex(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, int32_t nIndex) override; - uint32_t GetItemStyles(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override; + uint32_t GetItemStyles(IFWL_Widget* pWidget, CFWL_ListItem* pItem) override; FWL_Error GetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_WideString& wsText) override; FWL_Error GetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtItem) override; - void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) override; + void* GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) override; FWL_Error SetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwStyle) override; FWL_Error SetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const FX_WCHAR* pszText) override; FWL_Error SetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtItem) override; FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) override; CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) override; + CFWL_ListItem* pItem) override; FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtCheck) override; FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtCheck) override; uint32_t GetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) override; + CFWL_ListItem* pItem) override; FWL_Error SetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwCheckState) override; private: diff --git a/xfa/fwl/core/cfwl_listitem.cpp b/xfa/fwl/core/cfwl_listitem.cpp new file mode 100644 index 0000000000..4419839024 --- /dev/null +++ b/xfa/fwl/core/cfwl_listitem.cpp @@ -0,0 +1,19 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#include "xfa/fwl/core/cfwl_listitem.h" + +CFWL_ListItem::CFWL_ListItem() + : m_dwStates(0), + m_wsText(L""), + m_pDIB(nullptr), + m_pData(nullptr), + m_dwCheckState(0) { + m_rtCheckBox.Reset(); + m_rtItem.Reset(); +} + +CFWL_ListItem::~CFWL_ListItem() {} diff --git a/xfa/fwl/core/cfwl_listitem.h b/xfa/fwl/core/cfwl_listitem.h new file mode 100644 index 0000000000..0a5f0a3088 --- /dev/null +++ b/xfa/fwl/core/cfwl_listitem.h @@ -0,0 +1,30 @@ +// Copyright 2016 PDFium Authors. All rights reserved. +// Use of this source code is governed by a BSD-style license that can be +// found in the LICENSE file. + +// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com + +#ifndef XFA_FWL_CORE_CFWL_LISTITEM_H_ +#define XFA_FWL_CORE_CFWL_LISTITEM_H_ + +#include "core/fxcrt/fx_coordinates.h" +#include "core/fxcrt/fx_string.h" + +class CFX_DIBitmap; + +class CFWL_ListItem { + public: + CFWL_ListItem(); + ~CFWL_ListItem(); + + CFX_RectF m_rtItem; + uint32_t m_dwStates; + uint32_t m_dwStyles; + CFX_WideString m_wsText; + CFX_DIBitmap* m_pDIB; + void* m_pData; + uint32_t m_dwCheckState; + CFX_RectF m_rtCheckBox; +}; + +#endif // XFA_FWL_CORE_CFWL_LISTITEM_H_ diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp index 6d0a814157..ad42ce23eb 100644 --- a/xfa/fwl/core/ifwl_combobox.cpp +++ b/xfa/fwl/core/ifwl_combobox.cpp @@ -192,7 +192,7 @@ FWL_Error IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics, CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); + CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); m_pListBox->GetItemText(hItem, wsText); CFWL_ThemeText theme_text; theme_text.m_pWidget = this; @@ -251,7 +251,7 @@ FWL_Error IFWL_ComboBox::SetCurSel(int32_t iSel) { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, iSel); + CFWL_ListItem* hItem = pData->GetItem(this, iSel); m_pListBox->GetItemText(hItem, wsText); m_pEdit->SetText(wsText); } @@ -291,7 +291,7 @@ FWL_Error IFWL_ComboBox::GetEditText(CFX_WideString& wsText, } else if (m_pListBox) { IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); + CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); return m_pListBox->GetItemText(hItem, wsText); } return FWL_Error::Indefinite; @@ -553,7 +553,7 @@ void IFWL_ComboBox::SynchrEditText(int32_t iListItem) { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, iListItem); + CFWL_ListItem* hItem = pData->GetItem(this, iListItem); m_pListBox->GetItemText(hItem, wsText); m_pEdit->SetText(wsText); m_pEdit->Update(); @@ -582,7 +582,7 @@ void IFWL_ComboBox::Layout() { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); + CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); m_pListBox->GetItemText(hItem, wsText); m_pEdit->LockUpdate(); m_pEdit->SetText(wsText); @@ -667,7 +667,7 @@ void IFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) { if (bDropDown) { IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); + CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); if (hItem) { CFX_WideString wsText; pData->GetItemText(this, hItem, wsText); @@ -902,7 +902,7 @@ void IFWL_ComboBox::DisForm_Layout() { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); + CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); m_pListBox->GetItemText(hItem, wsText); m_pEdit->LockUpdate(); m_pEdit->SetText(wsText); @@ -1103,7 +1103,7 @@ void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) { CFX_WideString wsTemp; IFWL_ComboBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, iCurSel); + CFWL_ListItem* hItem = pData->GetItem(this, iCurSel); m_pListBox->GetItemText(hItem, wsTemp); bMatchEqual = wsText == wsTemp; } @@ -1240,7 +1240,7 @@ void IFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) { iCurSel = pComboList->MatchItem(wsText); if (iCurSel >= 0) { CFX_WideString wsTemp; - IFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel); + CFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel); m_pListBox->GetItemText(item, wsTemp); bMatchEqual = wsText == wsTemp; } diff --git a/xfa/fwl/core/ifwl_combolist.cpp b/xfa/fwl/core/ifwl_combolist.cpp index 04fefc628a..535ed68d62 100644 --- a/xfa/fwl/core/ifwl_combolist.cpp +++ b/xfa/fwl/core/ifwl_combolist.cpp @@ -28,7 +28,7 @@ int32_t IFWL_ComboList::MatchItem(const CFX_WideString& wsMatch) { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* hItem = pData->GetItem(this, i); + CFWL_ListItem* hItem = pData->GetItem(this, i); CFX_WideString wsText; pData->GetItemText(this, hItem, wsText); FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); @@ -44,10 +44,10 @@ void IFWL_ComboList::ChangeSelected(int32_t iSel) { return; IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, iSel); + CFWL_ListItem* hItem = pData->GetItem(this, iSel); CFX_RectF rtInvalidate; rtInvalidate.Reset(); - IFWL_ListItem* hOld = GetSelItem(0); + CFWL_ListItem* hOld = GetSelItem(0); int32_t iOld = pData->GetItemIndex(this, hOld); if (iOld == iSel) { return; @@ -59,7 +59,7 @@ void IFWL_ComboList::ChangeSelected(int32_t iSel) { CFX_RectF rect; GetItemRect(iSel, rect); rtInvalidate.Union(rect); - IFWL_ListItem* hSel = pData->GetItem(this, iSel); + CFWL_ListItem* hSel = pData->GetItem(this, iSel); SetSelItem(hSel, true); } if (!rtInvalidate.IsEmpty()) { @@ -76,7 +76,7 @@ int32_t IFWL_ComboList::CountItems() { void IFWL_ComboList::GetItemRect(int32_t nIndex, CFX_RectF& rtItem) { IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = pData->GetItem(this, nIndex); + CFWL_ListItem* hItem = pData->GetItem(this, nIndex); pData->GetItemRect(this, hItem, rtItem); } @@ -163,7 +163,7 @@ int32_t IFWL_ComboList::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { return 1; } } - IFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); if (hItem) { if (!m_pProperties->m_pDataProvider) return 0; @@ -207,7 +207,7 @@ int32_t IFWL_ComboList::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { } } pOuter->ShowDropList(false); - IFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* hItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); if (hItem) pOuter->ProcessSelChanged(true); } @@ -254,7 +254,7 @@ void IFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) { IFWL_ComboBox* pOuter = static_cast(m_pOuter); IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hItem = + CFWL_ListItem* hItem = pData->GetItem(this, pOuter->GetCurrentSelection()); hItem = GetItem(hItem, dwKeyCode); if (!hItem) { diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp index f0d2f019d3..f54c089a9a 100644 --- a/xfa/fwl/core/ifwl_listbox.cpp +++ b/xfa/fwl/core/ifwl_listbox.cpp @@ -151,7 +151,7 @@ int32_t IFWL_ListBox::CountSelItems() { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) { continue; } @@ -163,7 +163,7 @@ int32_t IFWL_ListBox::CountSelItems() { return iRet; } -IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { +CFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { if (!m_pProperties->m_pDataProvider) return nullptr; int32_t index = 0; @@ -171,7 +171,7 @@ IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) { return nullptr; } @@ -195,7 +195,7 @@ int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) { return -1; } @@ -211,7 +211,7 @@ int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { return -1; } -FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, bool bSelect) { +FWL_Error IFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { if (!m_pProperties->m_pDataProvider) return FWL_Error::Indefinite; if (!pItem) { @@ -231,7 +231,7 @@ FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, bool bSelect) { return FWL_Error::Succeeded; } -FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem, +FWL_Error IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { if (!m_pProperties->m_pDataProvider) return FWL_Error::Indefinite; @@ -253,8 +253,8 @@ FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, bool bVert) { return FWL_Error::Indefinite; } -IFWL_ListItem* IFWL_ListBox::GetItem(IFWL_ListItem* pItem, uint32_t dwKeyCode) { - IFWL_ListItem* hRet = nullptr; +CFWL_ListItem* IFWL_ListBox::GetItem(CFWL_ListItem* pItem, uint32_t dwKeyCode) { + CFWL_ListItem* hRet = nullptr; switch (dwKeyCode) { case FWL_VKEY_Up: case FWL_VKEY_Down: @@ -283,8 +283,8 @@ IFWL_ListItem* IFWL_ListBox::GetItem(IFWL_ListItem* pItem, uint32_t dwKeyCode) { return hRet; } -void IFWL_ListBox::SetSelection(IFWL_ListItem* hStart, - IFWL_ListItem* hEnd, +void IFWL_ListBox::SetSelection(CFWL_ListItem* hStart, + CFWL_ListItem* hEnd, bool bSelected) { IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); @@ -298,17 +298,17 @@ void IFWL_ListBox::SetSelection(IFWL_ListItem* hStart, if (bSelected) { int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); SetSelectionDirect(pItem, false); } } for (; iStart <= iEnd; iStart++) { - IFWL_ListItem* pItem = pData->GetItem(this, iStart); + CFWL_ListItem* pItem = pData->GetItem(this, iStart); SetSelectionDirect(pItem, bSelected); } } -void IFWL_ListBox::SetSelectionDirect(IFWL_ListItem* pItem, bool bSelect) { +void IFWL_ListBox::SetSelectionDirect(CFWL_ListItem* pItem, bool bSelect) { IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); uint32_t dwOldStyle = pData->GetItemStyles(this, pItem); @@ -317,7 +317,7 @@ void IFWL_ListBox::SetSelectionDirect(IFWL_ListItem* pItem, bool bSelect) { pData->SetItemStyles(this, pItem, dwOldStyle); } -bool IFWL_ListBox::IsItemSelected(IFWL_ListItem* pItem) { +bool IFWL_ListBox::IsItemSelected(CFWL_ListItem* pItem) { IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); uint32_t dwState = pData->GetItemStyles(this, pItem); @@ -330,7 +330,7 @@ void IFWL_ListBox::ClearSelection() { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); uint32_t dwState = pData->GetItemStyles(this, pItem); if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) continue; @@ -349,18 +349,18 @@ void IFWL_ListBox::SelectAll() { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); if (iCount > 0) { - IFWL_ListItem* pItemStart = pData->GetItem(this, 0); - IFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); + CFWL_ListItem* pItemStart = pData->GetItem(this, 0); + CFWL_ListItem* pItemEnd = pData->GetItem(this, iCount - 1); SetSelection(pItemStart, pItemEnd, false); } } -IFWL_ListItem* IFWL_ListBox::GetFocusedItem() { +CFWL_ListItem* IFWL_ListBox::GetFocusedItem() { IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) return nullptr; if (pData->GetItemStyles(this, pItem) & FWL_ITEMSTATE_LTB_Focused) { @@ -370,10 +370,10 @@ IFWL_ListItem* IFWL_ListBox::GetFocusedItem() { return nullptr; } -void IFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) { +void IFWL_ListBox::SetFocusItem(CFWL_ListItem* pItem) { IFWL_ListBoxDP* pData = static_cast(m_pProperties->m_pDataProvider); - IFWL_ListItem* hFocus = GetFocusedItem(); + CFWL_ListItem* hFocus = GetFocusedItem(); if (pItem != hFocus) { if (hFocus) { uint32_t dwStyle = pData->GetItemStyles(this, hFocus); @@ -388,7 +388,7 @@ void IFWL_ListBox::SetFocusItem(IFWL_ListItem* pItem) { } } -IFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { +CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { fx -= m_rtConent.left, fy -= m_rtConent.top; FX_FLOAT fPosX = 0.0f; if (m_pHorzScrollBar) { @@ -402,7 +402,7 @@ IFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { static_cast(m_pProperties->m_pDataProvider); int32_t nCount = pData->CountItems(this); for (int32_t i = 0; i < nCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) { continue; } @@ -416,7 +416,7 @@ IFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { return nullptr; } -bool IFWL_ListBox::GetItemCheckRect(IFWL_ListItem* pItem, CFX_RectF& rtCheck) { +bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) { if (!m_pProperties->m_pDataProvider) return false; if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { @@ -428,7 +428,7 @@ bool IFWL_ListBox::GetItemCheckRect(IFWL_ListItem* pItem, CFX_RectF& rtCheck) { return true; } -bool IFWL_ListBox::GetItemChecked(IFWL_ListItem* pItem) { +bool IFWL_ListBox::GetItemChecked(CFWL_ListItem* pItem) { if (!m_pProperties->m_pDataProvider) return false; if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { @@ -439,7 +439,7 @@ bool IFWL_ListBox::GetItemChecked(IFWL_ListItem* pItem) { return !!(pData->GetItemCheckState(this, pItem) & FWL_ITEMSTATE_LTB_Checked); } -bool IFWL_ListBox::SetItemChecked(IFWL_ListItem* pItem, bool bChecked) { +bool IFWL_ListBox::SetItemChecked(CFWL_ListItem* pItem, bool bChecked) { if (!m_pProperties->m_pDataProvider) return false; if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { @@ -452,7 +452,7 @@ bool IFWL_ListBox::SetItemChecked(IFWL_ListItem* pItem, bool bChecked) { return true; } -bool IFWL_ListBox::ScrollToVisible(IFWL_ListItem* pItem) { +bool IFWL_ListBox::ScrollToVisible(CFWL_ListItem* pItem) { if (!m_pVertScrollBar) return false; CFX_RectF rtItem; @@ -525,7 +525,7 @@ void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics, static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) { continue; } @@ -557,7 +557,7 @@ void IFWL_ListBox::DrawItems(CFX_Graphics* pGraphics, void IFWL_ListBox::DrawItem(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, int32_t Index, const CFX_RectF& rtItem, const CFX_Matrix* pMatrix) { @@ -679,7 +679,7 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!bAutoSize) { CFX_RectF rtItem; rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, 0, 0); @@ -710,7 +710,7 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* htem = pData->GetItem(this, i); + CFWL_ListItem* htem = pData->GetItem(this, i); GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); } } @@ -815,7 +815,7 @@ CFX_SizeF IFWL_ListBox::CalcSize(bool bAutoSize) { } void IFWL_ListBox::GetItemSize(CFX_SizeF& size, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, FX_FLOAT fWidth, FX_FLOAT fItemHeight, bool bAutoSize) { @@ -839,7 +839,7 @@ FX_FLOAT IFWL_ListBox::GetMaxTextWidth() { static_cast(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(this); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* pItem = pData->GetItem(this, i); + CFWL_ListItem* pItem = pData->GetItem(this, i); if (!pItem) { continue; } @@ -899,7 +899,7 @@ void IFWL_ListBox::ProcessSelChanged() { CFX_Int32Array arrSels; int32_t iCount = CountSelItems(); for (int32_t i = 0; i < iCount; i++) { - IFWL_ListItem* item = GetSelItem(i); + CFWL_ListItem* item = GetSelItem(i); if (!item) { continue; } @@ -991,7 +991,7 @@ void IFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { if ((m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) SetFocus(true); - IFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* pItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); if (!pItem) return; @@ -1013,7 +1013,7 @@ void IFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { SetSelection(pItem, pItem, true); } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { - IFWL_ListItem* hSelectedItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + CFWL_ListItem* hSelectedItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); CFX_RectF rtCheck; GetItemCheckRect(hSelectedItem, rtCheck); bool bChecked = GetItemChecked(pItem); @@ -1051,7 +1051,7 @@ void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { case FWL_VKEY_Down: case FWL_VKEY_Home: case FWL_VKEY_End: { - IFWL_ListItem* pItem = GetFocusedItem(); + CFWL_ListItem* pItem = GetFocusedItem(); pItem = GetItem(pItem, dwKeyCode); bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); @@ -1065,7 +1065,7 @@ void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { } } -void IFWL_ListBox::OnVK(IFWL_ListItem* pItem, bool bShift, bool bCtrl) { +void IFWL_ListBox::OnVK(CFWL_ListItem* pItem, bool bShift, bool bCtrl) { if (!pItem) return; diff --git a/xfa/fwl/core/ifwl_listbox.h b/xfa/fwl/core/ifwl_listbox.h index 99006caa18..943c064afe 100644 --- a/xfa/fwl/core/ifwl_listbox.h +++ b/xfa/fwl/core/ifwl_listbox.h @@ -10,6 +10,7 @@ #include #include "xfa/fwl/core/cfwl_event.h" +#include "xfa/fwl/core/cfwl_listitem.h" #include "xfa/fwl/core/cfwl_widgetproperties.h" #include "xfa/fwl/core/ifwl_dataprovider.h" #include "xfa/fwl/core/ifwl_edit.h" @@ -48,55 +49,53 @@ FWL_EVENT_DEF(CFWL_EvtLtbDrawItem, int32_t m_index; CFX_RectF m_rect;) -class IFWL_ListItem {}; - class IFWL_ListBoxDP : public IFWL_DataProvider { public: virtual int32_t CountItems(const IFWL_Widget* pWidget) = 0; - virtual IFWL_ListItem* GetItem(const IFWL_Widget* pWidget, + virtual CFWL_ListItem* GetItem(const IFWL_Widget* pWidget, int32_t nIndex) = 0; - virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; + virtual int32_t GetItemIndex(IFWL_Widget* pWidget, CFWL_ListItem* pItem) = 0; virtual bool SetItemIndex(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, int32_t nIndex) = 0; virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) = 0; + CFWL_ListItem* pItem) = 0; virtual FWL_Error GetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_WideString& wsText) = 0; virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtItem) = 0; - virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; + virtual void* GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) = 0; virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwStyle) = 0; virtual FWL_Error SetItemText(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const FX_WCHAR* pszText) = 0; virtual FWL_Error SetItemRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtItem) = 0; virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0; virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) = 0; + CFWL_ListItem* pItem) = 0; virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, CFX_RectF& rtCheck) = 0; virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, const CFX_RectF& rtCheck) = 0; virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem) = 0; + CFWL_ListItem* pItem) = 0; virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget, - IFWL_ListItem* pItem, + CFWL_ListItem* pItem, uint32_t dwCheckState) = 0; }; class IFWL_ListBoxCompare { public: virtual ~IFWL_ListBoxCompare() {} - virtual int32_t Compare(IFWL_ListItem* hLeft, IFWL_ListItem* hRight) = 0; + virtual int32_t Compare(CFWL_ListItem* hLeft, CFWL_ListItem* hRight) = 0; }; class IFWL_ListBox : public IFWL_Widget { @@ -120,29 +119,29 @@ class IFWL_ListBox : public IFWL_Widget { const CFX_Matrix* pMatrix) override; int32_t CountSelItems(); - IFWL_ListItem* GetSelItem(int32_t nIndexSel); + CFWL_ListItem* GetSelItem(int32_t nIndexSel); int32_t GetSelIndex(int32_t nIndex); - FWL_Error SetSelItem(IFWL_ListItem* hItem, bool bSelect = true); - FWL_Error GetItemText(IFWL_ListItem* hItem, CFX_WideString& wsText); + FWL_Error SetSelItem(CFWL_ListItem* hItem, bool bSelect = true); + FWL_Error GetItemText(CFWL_ListItem* hItem, CFX_WideString& wsText); FWL_Error GetScrollPos(FX_FLOAT& fPos, bool bVert = true); FWL_Error* Sort(IFWL_ListBoxCompare* pCom); protected: friend class CFWL_ListBoxImpDelegate; - IFWL_ListItem* GetItem(IFWL_ListItem* hItem, uint32_t dwKeyCode); - void SetSelection(IFWL_ListItem* hStart, IFWL_ListItem* hEnd, bool bSelected); - void SetSelectionDirect(IFWL_ListItem* hItem, bool bSelect); - bool IsItemSelected(IFWL_ListItem* hItem); + CFWL_ListItem* GetItem(CFWL_ListItem* hItem, uint32_t dwKeyCode); + void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected); + void SetSelectionDirect(CFWL_ListItem* hItem, bool bSelect); + bool IsItemSelected(CFWL_ListItem* hItem); void ClearSelection(); void SelectAll(); - IFWL_ListItem* GetFocusedItem(); - void SetFocusItem(IFWL_ListItem* hItem); - IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); - bool GetItemCheckRect(IFWL_ListItem* hItem, CFX_RectF& rtCheck); - bool SetItemChecked(IFWL_ListItem* hItem, bool bChecked); - bool GetItemChecked(IFWL_ListItem* hItem); - bool ScrollToVisible(IFWL_ListItem* hItem); + CFWL_ListItem* GetFocusedItem(); + void SetFocusItem(CFWL_ListItem* hItem); + CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); + bool GetItemCheckRect(CFWL_ListItem* hItem, CFX_RectF& rtCheck); + bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked); + bool GetItemChecked(CFWL_ListItem* hItem); + bool ScrollToVisible(CFWL_ListItem* hItem); void DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix = nullptr); @@ -151,14 +150,14 @@ class IFWL_ListBox : public IFWL_Widget { const CFX_Matrix* pMatrix = nullptr); void DrawItem(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - IFWL_ListItem* hItem, + CFWL_ListItem* hItem, int32_t Index, const CFX_RectF& rtItem, const CFX_Matrix* pMatrix = nullptr); void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); CFX_SizeF CalcSize(bool bAutoSize = false); void GetItemSize(CFX_SizeF& size, - IFWL_ListItem* hItem, + CFWL_ListItem* hItem, FX_FLOAT fWidth, FX_FLOAT fHeight, bool bAutoSize = false); @@ -176,7 +175,7 @@ class IFWL_ListBox : public IFWL_Widget { std::unique_ptr m_pVertScrollBar; uint32_t m_dwTTOStyles; int32_t m_iTTOAligns; - IFWL_ListItem* m_hAnchor; + CFWL_ListItem* m_hAnchor; FX_FLOAT m_fItemHeight; FX_FLOAT m_fScorllBarWidth; bool m_bLButtonDown; @@ -188,7 +187,7 @@ class IFWL_ListBox : public IFWL_Widget { void OnLButtonUp(CFWL_MsgMouse* pMsg); void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); void OnKeyDown(CFWL_MsgKey* pMsg); - void OnVK(IFWL_ListItem* hItem, bool bShift, bool bCtrl); + void OnVK(CFWL_ListItem* hItem, bool bShift, bool bCtrl); bool OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); void DispatchSelChangedEv(); }; diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 7a20730410..93e270da3e 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -63,7 +63,7 @@ bool CXFA_FFListBox::LoadWidget() { m_pDataAcc->GetSelectedItems(iSelArray); int32_t iSelCount = iSelArray.GetSize(); for (int32_t j = 0; j < iSelCount; j++) { - IFWL_ListItem* item = pListBox->GetItem(iSelArray[j]); + CFWL_ListItem* item = pListBox->GetItem(iSelArray[j]); pListBox->SetSelItem(item, true); } m_pNormalWidget->UnlockUpdate(); @@ -97,7 +97,7 @@ bool CXFA_FFListBox::IsDataChanged() { return true; for (int32_t i = 0; i < iSels; ++i) { - IFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]); + CFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]); if (!(pListBox->GetItemStates(hlistItem) & FWL_ITEMSTATE_LTB_Selected)) return true; } @@ -133,12 +133,12 @@ bool CXFA_FFListBox::UpdateFWLData() { return false; } CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); - CFX_ArrayTemplate selItemArray; + CFX_ArrayTemplate selItemArray; CFX_Int32Array iSelArray; m_pDataAcc->GetSelectedItems(iSelArray); int32_t iSelCount = iSelArray.GetSize(); for (int32_t j = 0; j < iSelCount; j++) { - IFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); + CFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); selItemArray.Add(lpItemSel); } pListBox->SetSelItem(pListBox->GetSelItem(-1), false); @@ -162,7 +162,7 @@ void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); } void CXFA_FFListBox::SetItemState(int32_t nIndex, bool bSelected) { - IFWL_ListItem* item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); + CFWL_ListItem* item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected); m_pNormalWidget->Update(); AddInvalidateRect(); -- cgit v1.2.3