diff options
author | Dan Sinclair <dsinclair@chromium.org> | 2016-11-23 12:20:47 -0500 |
---|---|---|
committer | Chromium commit bot <commit-bot@chromium.org> | 2016-11-23 17:38:32 +0000 |
commit | 0ced827f257344a1f5804aa96df538f3e783bd10 (patch) | |
tree | 5387c8a2d18be8b86d9b2a72a8f829118f0e42bb /xfa/fwl/core/cfwl_combobox.cpp | |
parent | 209821f79d0bbeeaeadf4e82ff643ee20d676222 (diff) | |
download | pdfium-0ced827f257344a1f5804aa96df538f3e783bd10.tar.xz |
Remove listbox providers and build into listbox
This CL removes the IFWL_ListBox::DataProvider and builds the data storage
for the list directly into IFWL_ListBox. This removes the need for the provider
in CFWL_ComboBox and CFWL_ListBox.
Change-Id: I74c2286757a0b73083908f1cc630a88e7d730fd9
Reviewed-on: https://pdfium-review.googlesource.com/2050
Commit-Queue: dan sinclair <dsinclair@chromium.org>
Reviewed-by: Tom Sepez <tsepez@chromium.org>
Diffstat (limited to 'xfa/fwl/core/cfwl_combobox.cpp')
-rw-r--r-- | xfa/fwl/core/cfwl_combobox.cpp | 123 |
1 files changed, 13 insertions, 110 deletions
diff --git a/xfa/fwl/core/cfwl_combobox.cpp b/xfa/fwl/core/cfwl_combobox.cpp index 602e09d4b0..9af4b8da7d 100644 --- a/xfa/fwl/core/cfwl_combobox.cpp +++ b/xfa/fwl/core/cfwl_combobox.cpp @@ -35,32 +35,29 @@ void CFWL_ComboBox::Initialize() { CFWL_Widget::Initialize(); } -int32_t CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { - std::unique_ptr<CFWL_ListItem> pItem(new CFWL_ListItem); - pItem->m_wsText = wsText; - pItem->m_dwStyles = 0; - m_ItemArray.push_back(std::move(pItem)); - return m_ItemArray.size() - 1; +void CFWL_ComboBox::AddString(const CFX_WideStringC& wsText) { + if (GetWidget()) + ToComboBox(GetWidget())->AddString(wsText); } bool CFWL_ComboBox::RemoveAt(int32_t iIndex) { - if (iIndex < 0 || static_cast<size_t>(iIndex) >= m_ItemArray.size()) - return false; - - m_ItemArray.erase(m_ItemArray.begin() + iIndex); - return true; + return GetWidget() && ToComboBox(GetWidget())->RemoveAt(iIndex); } void CFWL_ComboBox::RemoveAll() { - m_ItemArray.clear(); + if (GetWidget()) + ToComboBox(GetWidget())->RemoveAll(); +} + +FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { + return m_fMaxListHeight; } void CFWL_ComboBox::GetTextByIndex(int32_t iIndex, CFX_WideString& wsText) const { - CFWL_ListItem* pItem = - static_cast<CFWL_ListItem*>(GetItem(m_pIface.get(), iIndex)); - if (pItem) - wsText = pItem->m_wsText; + if (!GetWidget()) + return; + ToComboBox(GetWidget())->GetTextByIndex(iIndex, wsText); } int32_t CFWL_ComboBox::GetCurSel() const { @@ -155,97 +152,3 @@ void CFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, ->EditModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); } } - -int32_t CFWL_ComboBox::CountItems(const IFWL_Widget* pWidget) const { - return m_ItemArray.size(); -} - -CFWL_ListItem* CFWL_ComboBox::GetItem(const IFWL_Widget* pWidget, - int32_t nIndex) const { - if (nIndex < 0 || static_cast<size_t>(nIndex) >= m_ItemArray.size()) - return nullptr; - return m_ItemArray[nIndex].get(); -} - -int32_t CFWL_ComboBox::GetItemIndex(IFWL_Widget* pWidget, - CFWL_ListItem* pItem) { - auto it = std::find_if( - m_ItemArray.begin(), m_ItemArray.end(), - [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; -} - -uint32_t CFWL_ComboBox::GetItemStyles(IFWL_Widget* pWidget, - CFWL_ListItem* pItem) { - return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_dwStyles : 0; -} - -void CFWL_ComboBox::GetItemText(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - CFX_WideString& wsText) { - if (pItem) - wsText = static_cast<CFWL_ListItem*>(pItem)->m_wsText; -} - -void CFWL_ComboBox::GetItemRect(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - CFX_RectF& rtItem) { - if (!pItem) - return; - - CFWL_ListItem* pComboItem = static_cast<CFWL_ListItem*>(pItem); - rtItem.Set(pComboItem->m_rtItem.left, pComboItem->m_rtItem.top, - pComboItem->m_rtItem.width, pComboItem->m_rtItem.height); -} - -void* CFWL_ComboBox::GetItemData(IFWL_Widget* pWidget, CFWL_ListItem* pItem) { - return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pData : nullptr; -} - -void CFWL_ComboBox::SetItemStyles(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - uint32_t dwStyle) { - if (pItem) - static_cast<CFWL_ListItem*>(pItem)->m_dwStyles = dwStyle; -} - -void CFWL_ComboBox::SetItemRect(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - const CFX_RectF& rtItem) { - if (pItem) - static_cast<CFWL_ListItem*>(pItem)->m_rtItem = rtItem; -} - -CFX_DIBitmap* CFWL_ComboBox::GetItemIcon(IFWL_Widget* pWidget, - CFWL_ListItem* pItem) { - return pItem ? static_cast<CFWL_ListItem*>(pItem)->m_pDIB : nullptr; -} - -void CFWL_ComboBox::GetItemCheckRect(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - CFX_RectF& rtCheck) { - rtCheck = static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox; -} - -void CFWL_ComboBox::SetItemCheckRect(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - const CFX_RectF& rtCheck) { - static_cast<CFWL_ListItem*>(pItem)->m_rtCheckBox = rtCheck; -} - -uint32_t CFWL_ComboBox::GetItemCheckState(IFWL_Widget* pWidget, - CFWL_ListItem* pItem) { - return static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState; -} - -void CFWL_ComboBox::SetItemCheckState(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - uint32_t dwCheckState) { - static_cast<CFWL_ListItem*>(pItem)->m_dwCheckState = dwCheckState; -} - -FX_FLOAT CFWL_ComboBox::GetListHeight(IFWL_Widget* pWidget) { - return m_fMaxListHeight; -} |