summaryrefslogtreecommitdiff
path: root/xfa/fwl/core/ifwl_combobox.cpp
diff options
context:
space:
mode:
authorDan Sinclair <dsinclair@chromium.org>2016-11-23 12:20:47 -0500
committerChromium commit bot <commit-bot@chromium.org>2016-11-23 17:38:32 +0000
commit0ced827f257344a1f5804aa96df538f3e783bd10 (patch)
tree5387c8a2d18be8b86d9b2a72a8f829118f0e42bb /xfa/fwl/core/ifwl_combobox.cpp
parent209821f79d0bbeeaeadf4e82ff643ee20d676222 (diff)
downloadpdfium-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/ifwl_combobox.cpp')
-rw-r--r--xfa/fwl/core/ifwl_combobox.cpp81
1 files changed, 38 insertions, 43 deletions
diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp
index f2a85e68bc..906fe1d6ef 100644
--- a/xfa/fwl/core/ifwl_combobox.cpp
+++ b/xfa/fwl/core/ifwl_combobox.cpp
@@ -100,6 +100,18 @@ void IFWL_ComboBox::GetWidgetRect(CFX_RectF& rect, bool bAutoSize) {
IFWL_Widget::GetWidgetRect(rect, true);
}
+void IFWL_ComboBox::AddString(const CFX_WideStringC& wsText) {
+ m_pListBox->AddString(wsText);
+}
+
+bool IFWL_ComboBox::RemoveAt(int32_t iIndex) {
+ return m_pListBox->RemoveAt(iIndex);
+}
+
+void IFWL_ComboBox::RemoveAll() {
+ m_pListBox->DeleteAll();
+}
+
void IFWL_ComboBox::ModifyStylesEx(uint32_t dwStylesExAdded,
uint32_t dwStylesExRemoved) {
if (m_pWidgetMgr->IsFormDisabled()) {
@@ -179,13 +191,11 @@ void IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics,
param.m_rtPart = rtTextBk;
if (m_iCurSel >= 0) {
- IFWL_ListBox::DataProvider* pData =
- static_cast<IFWL_ListBox::DataProvider*>(
- m_pListBox->GetDataProvider());
- void* p = pData->GetItemData(m_pListBox.get(),
- pData->GetItem(m_pListBox.get(), m_iCurSel));
- if (p)
+ if (void* p = m_pListBox->GetItemData(
+ m_pListBox.get(),
+ m_pListBox->GetItem(m_pListBox.get(), m_iCurSel))) {
param.m_pData = p;
+ }
}
if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) {
@@ -203,10 +213,7 @@ void IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics,
return;
CFX_WideString wsText;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(
- m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
m_pListBox->GetDataProviderItemText(hItem, wsText);
CFWL_ThemeText theme_text;
@@ -249,18 +256,23 @@ void IFWL_ComboBox::SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) {
m_pEdit->SetThemeProvider(pThemeProvider);
}
+void IFWL_ComboBox::GetTextByIndex(int32_t iIndex,
+ CFX_WideString& wsText) const {
+ CFWL_ListItem* pItem = static_cast<CFWL_ListItem*>(
+ m_pListBox->GetItem(m_pListBox.get(), iIndex));
+ if (pItem)
+ wsText = pItem->m_wsText;
+}
+
void IFWL_ComboBox::SetCurSel(int32_t iSel) {
- int32_t iCount = m_pListBox->CountItems();
+ int32_t iCount = m_pListBox->CountItems(nullptr);
bool bClearSel = iSel < 0 || iSel >= iCount;
if (IsDropDownStyle() && m_pEdit) {
if (bClearSel) {
m_pEdit->SetText(CFX_WideString());
} else {
CFX_WideString wsText;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(
- m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, iSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, iSel);
m_pListBox->GetDataProviderItemText(hItem, wsText);
m_pEdit->SetText(wsText);
}
@@ -295,9 +307,7 @@ void IFWL_ComboBox::GetEditText(CFX_WideString& wsText,
if (!m_pListBox)
return;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
m_pListBox->GetDataProviderItemText(hItem, wsText);
}
@@ -432,9 +442,7 @@ void IFWL_ComboBox::MatchEditText() {
void IFWL_ComboBox::SyncEditText(int32_t iListItem) {
CFX_WideString wsText;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, iListItem);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, iListItem);
m_pListBox->GetDataProviderItemText(hItem, wsText);
m_pEdit->SetText(wsText);
m_pEdit->Update();
@@ -464,10 +472,7 @@ void IFWL_ComboBox::Layout() {
if (m_iCurSel >= 0) {
CFX_WideString wsText;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(
- m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
m_pListBox->GetDataProviderItemText(hItem, wsText);
m_pEdit->LockUpdate();
m_pEdit->SetText(wsText);
@@ -551,22 +556,18 @@ void IFWL_ComboBox::ResetListItemAlignment() {
}
void IFWL_ComboBox::ProcessSelChanged(bool bLButtonUp) {
- IFWL_ComboBox::DataProvider* pDatas =
- static_cast<IFWL_ComboBox::DataProvider*>(m_pProperties->m_pDataProvider);
- m_iCurSel = pDatas->GetItemIndex(this, m_pListBox->GetSelItem(0));
+ m_iCurSel = m_pListBox->GetItemIndex(this, m_pListBox->GetSelItem(0));
if (!IsDropDownStyle()) {
Repaint(&m_rtClient);
return;
}
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
if (!hItem)
return;
CFX_WideString wsText;
- pData->GetItemText(this, hItem, wsText);
+ m_pListBox->GetItemText(this, hItem, wsText);
if (m_pEdit) {
m_pEdit->SetText(wsText);
m_pEdit->Update();
@@ -635,7 +636,7 @@ void IFWL_ComboBox::DisForm_ShowDropList(bool bActivate) {
DispatchEvent(&preEvent);
IFWL_ComboList* pComboList = m_pListBox.get();
- int32_t iItems = pComboList->CountItems();
+ int32_t iItems = pComboList->CountItems(nullptr);
if (iItems < 1)
return;
@@ -800,10 +801,7 @@ void IFWL_ComboBox::DisForm_Layout() {
if (m_iCurSel >= 0) {
CFX_WideString wsText;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(
- m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, m_iCurSel);
m_pListBox->GetDataProviderItemText(hItem, wsText);
m_pEdit->LockUpdate();
m_pEdit->SetText(wsText);
@@ -973,7 +971,7 @@ void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
const bool bUp = dwKeyCode == FWL_VKEY_Up;
const bool bDown = dwKeyCode == FWL_VKEY_Down;
if (bUp || bDown) {
- int32_t iCount = m_pListBox->CountItems();
+ int32_t iCount = m_pListBox->CountItems(nullptr);
if (iCount < 1)
return;
@@ -986,10 +984,7 @@ void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) {
iCurSel = m_pListBox->MatchItem(wsText);
if (iCurSel >= 0) {
CFX_WideString wsTemp;
- IFWL_ComboBox::DataProvider* pData =
- static_cast<IFWL_ComboBox::DataProvider*>(
- m_pProperties->m_pDataProvider);
- CFWL_ListItem* hItem = pData->GetItem(this, iCurSel);
+ CFWL_ListItem* hItem = m_pListBox->GetItem(this, iCurSel);
m_pListBox->GetDataProviderItemText(hItem, wsTemp);
bMatchEqual = wsText == wsTemp;
}
@@ -1113,7 +1108,7 @@ void IFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) {
const bool bDown = dwKeyCode == FWL_VKEY_Down;
if (bUp || bDown) {
IFWL_ComboList* pComboList = m_pListBox.get();
- int32_t iCount = pComboList->CountItems();
+ int32_t iCount = pComboList->CountItems(nullptr);
if (iCount < 1)
return;