From e50184c087ee6f90568ad1166a55f5d25be4d09e Mon Sep 17 00:00:00 2001 From: dsinclair Date: Tue, 22 Nov 2016 09:34:44 -0800 Subject: Rename common methods between ifwl and cfwl. This CL renames some methods in IFWL which have the same name as the CFWL methods but the CFWL methods are not proxy methods. Review-Url: https://codereview.chromium.org/2520413002 --- xfa/fwl/core/cfwl_listbox.cpp | 21 +++++---------------- xfa/fwl/core/cfwl_listbox.h | 2 -- xfa/fwl/core/ifwl_combobox.cpp | 24 ++++++++++++------------ xfa/fwl/core/ifwl_combobox.h | 2 +- xfa/fwl/core/ifwl_combolist.cpp | 2 +- xfa/fwl/core/ifwl_listbox.cpp | 13 ++++++++----- xfa/fwl/core/ifwl_listbox.h | 6 +++--- xfa/fxfa/app/xfa_ffchoicelist.cpp | 20 ++++++++++---------- 8 files changed, 40 insertions(+), 50 deletions(-) diff --git a/xfa/fwl/core/cfwl_listbox.cpp b/xfa/fwl/core/cfwl_listbox.cpp index 4c933bf24e..7da49efbb0 100644 --- a/xfa/fwl/core/cfwl_listbox.cpp +++ b/xfa/fwl/core/cfwl_listbox.cpp @@ -82,15 +82,11 @@ void CFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { ToListBox(GetWidget())->SetSelItem(pItem, bSelect); } -void CFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { - if (GetWidget()) - ToListBox(GetWidget())->GetItemText(pItem, wsText); -} - -CFWL_ListItem* CFWL_ListBox::GetItem(int32_t nIndex) { - if (nIndex < 0 || nIndex >= CountItems(nullptr)) - return nullptr; - return m_ItemArray[nIndex].get(); +void CFWL_ListBox::GetItemText(IFWL_Widget* pWidget, + CFWL_ListItem* pItem, + CFX_WideString& wsText) { + if (pItem) + wsText = static_cast(pItem)->m_wsText; } uint32_t CFWL_ListBox::GetItemStates(CFWL_ListItem* pItem) { @@ -124,13 +120,6 @@ uint32_t CFWL_ListBox::GetItemStyles(IFWL_Widget* pWidget, return pItem ? static_cast(pItem)->m_dwStates : 0; } -void CFWL_ListBox::GetItemText(IFWL_Widget* pWidget, - CFWL_ListItem* pItem, - CFX_WideString& wsText) { - if (pItem) - wsText = static_cast(pItem)->m_wsText; -} - void CFWL_ListBox::GetItemRect(IFWL_Widget* pWidget, CFWL_ListItem* pItem, CFX_RectF& rtItem) { diff --git a/xfa/fwl/core/cfwl_listbox.h b/xfa/fwl/core/cfwl_listbox.h index ec033825bb..80bc23b2d0 100644 --- a/xfa/fwl/core/cfwl_listbox.h +++ b/xfa/fwl/core/cfwl_listbox.h @@ -64,8 +64,6 @@ class CFWL_ListBox : public CFWL_Widget, public IFWL_ListBox::DataProvider { CFWL_ListItem* GetSelItem(int32_t nIndexSel); int32_t GetSelIndex(int32_t nIndex); - CFWL_ListItem* GetItem(int32_t nIndex); - void GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText); uint32_t GetItemStates(CFWL_ListItem* pItem); private: diff --git a/xfa/fwl/core/ifwl_combobox.cpp b/xfa/fwl/core/ifwl_combobox.cpp index e632120417..82d9d3d5e7 100644 --- a/xfa/fwl/core/ifwl_combobox.cpp +++ b/xfa/fwl/core/ifwl_combobox.cpp @@ -207,7 +207,7 @@ void IFWL_ComboBox::DrawWidget(CFX_Graphics* pGraphics, static_cast( m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); - m_pListBox->GetItemText(hItem, wsText); + m_pListBox->GetDataProviderItemText(hItem, wsText); CFWL_ThemeText theme_text; theme_text.m_pWidget = this; @@ -261,7 +261,7 @@ void IFWL_ComboBox::SetCurSel(int32_t iSel) { static_cast( m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, iSel); - m_pListBox->GetItemText(hItem, wsText); + m_pListBox->GetDataProviderItemText(hItem, wsText); m_pEdit->SetText(wsText); } m_pEdit->Update(); @@ -298,7 +298,7 @@ void IFWL_ComboBox::GetEditText(CFX_WideString& wsText, IFWL_ComboBox::DataProvider* pData = static_cast(m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); - m_pListBox->GetItemText(hItem, wsText); + m_pListBox->GetDataProviderItemText(hItem, wsText); } void IFWL_ComboBox::OpenDropDownList(bool bActivate) { @@ -327,7 +327,7 @@ void IFWL_ComboBox::EditModifyStylesEx(uint32_t dwStylesExAdded, m_pEdit->ModifyStylesEx(dwStylesExAdded, dwStylesExRemoved); } -FX_FLOAT IFWL_ComboBox::GetListHeight() { +FX_FLOAT IFWL_ComboBox::GetDataProviderListHeight() { return static_cast( m_pProperties->m_pDataProvider) ->GetListHeight(this); @@ -371,9 +371,9 @@ void IFWL_ComboBox::ShowDropList(bool bActivate) { (FWL_STYLEEXT_CMB_Sort | FWL_STYLEEXT_CMB_OwnerDraw); m_pListBox->ModifyStylesEx(dwStyleAdd, 0); m_pListBox->GetWidgetRect(m_rtList, true); - FX_FLOAT fHeight = GetListHeight(); - if (fHeight > 0 && m_rtList.height > GetListHeight()) { - m_rtList.height = GetListHeight(); + FX_FLOAT fHeight = GetDataProviderListHeight(); + if (fHeight > 0 && m_rtList.height > fHeight) { + m_rtList.height = fHeight; m_pListBox->ModifyStyles(FWL_WGTSTYLE_VScroll, 0); } @@ -435,7 +435,7 @@ void IFWL_ComboBox::SyncEditText(int32_t iListItem) { IFWL_ComboBox::DataProvider* pData = static_cast(m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, iListItem); - m_pListBox->GetItemText(hItem, wsText); + m_pListBox->GetDataProviderItemText(hItem, wsText); m_pEdit->SetText(wsText); m_pEdit->Update(); m_pEdit->SetSelected(); @@ -468,7 +468,7 @@ void IFWL_ComboBox::Layout() { static_cast( m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); - m_pListBox->GetItemText(hItem, wsText); + m_pListBox->GetDataProviderItemText(hItem, wsText); m_pEdit->LockUpdate(); m_pEdit->SetText(wsText); m_pEdit->UnlockUpdate(); @@ -804,7 +804,7 @@ void IFWL_ComboBox::DisForm_Layout() { static_cast( m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, m_iCurSel); - m_pListBox->GetItemText(hItem, wsText); + m_pListBox->GetDataProviderItemText(hItem, wsText); m_pEdit->LockUpdate(); m_pEdit->SetText(wsText); m_pEdit->UnlockUpdate(); @@ -990,7 +990,7 @@ void IFWL_ComboBox::DoSubCtrlKey(CFWL_MsgKey* pMsg) { static_cast( m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, iCurSel); - m_pListBox->GetItemText(hItem, wsTemp); + m_pListBox->GetDataProviderItemText(hItem, wsTemp); bMatchEqual = wsText == wsTemp; } } @@ -1126,7 +1126,7 @@ void IFWL_ComboBox::DisForm_OnKey(CFWL_MsgKey* pMsg) { if (iCurSel >= 0) { CFX_WideString wsTemp; CFWL_ListItem* item = m_pListBox->GetSelItem(iCurSel); - m_pListBox->GetItemText(item, wsTemp); + m_pListBox->GetDataProviderItemText(item, wsTemp); bMatchEqual = wsText == wsTemp; } } diff --git a/xfa/fwl/core/ifwl_combobox.h b/xfa/fwl/core/ifwl_combobox.h index db5b0678ae..ad48ec2391 100644 --- a/xfa/fwl/core/ifwl_combobox.h +++ b/xfa/fwl/core/ifwl_combobox.h @@ -120,7 +120,7 @@ class IFWL_ComboBox : public IFWL_Widget { int32_t GetCurrentSelection() const { return m_iCurSel; } private: - FX_FLOAT GetListHeight(); + FX_FLOAT GetDataProviderListHeight(); bool IsDropDownStyle() const { return !!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_CMB_DropDown); } diff --git a/xfa/fwl/core/ifwl_combolist.cpp b/xfa/fwl/core/ifwl_combolist.cpp index e3ddcd08d9..18612dbc80 100644 --- a/xfa/fwl/core/ifwl_combolist.cpp +++ b/xfa/fwl/core/ifwl_combolist.cpp @@ -260,7 +260,7 @@ void IFWL_ComboList::OnDropListKeyDown(CFWL_MsgKey* pKey) { m_pProperties->m_pDataProvider); CFWL_ListItem* hItem = pData->GetItem(this, pOuter->GetCurrentSelection()); - hItem = GetItem(hItem, dwKeyCode); + hItem = GetListItem(hItem, dwKeyCode); if (!hItem) break; diff --git a/xfa/fwl/core/ifwl_listbox.cpp b/xfa/fwl/core/ifwl_listbox.cpp index aa17355b77..bcc8040427 100644 --- a/xfa/fwl/core/ifwl_listbox.cpp +++ b/xfa/fwl/core/ifwl_listbox.cpp @@ -215,7 +215,8 @@ void IFWL_ListBox::SetSelItem(CFWL_ListItem* pItem, bool bSelect) { SetSelection(pItem, pItem, bSelect); } -void IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { +void IFWL_ListBox::GetDataProviderItemText(CFWL_ListItem* pItem, + CFX_WideString& wsText) { if (!m_pProperties->m_pDataProvider) return; @@ -227,7 +228,8 @@ void IFWL_ListBox::GetItemText(CFWL_ListItem* pItem, CFX_WideString& wsText) { pData->GetItemText(this, pItem, wsText); } -CFWL_ListItem* IFWL_ListBox::GetItem(CFWL_ListItem* pItem, uint32_t dwKeyCode) { +CFWL_ListItem* IFWL_ListBox::GetListItem(CFWL_ListItem* pItem, + uint32_t dwKeyCode) { CFWL_ListItem* hRet = nullptr; switch (dwKeyCode) { case FWL_VKEY_Up: @@ -391,7 +393,8 @@ CFWL_ListItem* IFWL_ListBox::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { return nullptr; } -bool IFWL_ListBox::GetItemCheckRect(CFWL_ListItem* pItem, CFX_RectF& rtCheck) { +bool IFWL_ListBox::GetItemCheckRectInternal(CFWL_ListItem* pItem, + CFX_RectF& rtCheck) { if (!m_pProperties->m_pDataProvider) return false; if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) @@ -935,7 +938,7 @@ void IFWL_ListBox::OnLButtonDown(CFWL_MsgMouse* pMsg) { if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { CFWL_ListItem* hSelectedItem = GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); CFX_RectF rtCheck; - GetItemCheckRect(hSelectedItem, rtCheck); + GetItemCheckRectInternal(hSelectedItem, rtCheck); bool bChecked = GetItemChecked(pItem); if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { SetItemChecked(pItem, !bChecked); @@ -970,7 +973,7 @@ void IFWL_ListBox::OnKeyDown(CFWL_MsgKey* pMsg) { case FWL_VKEY_Home: case FWL_VKEY_End: { CFWL_ListItem* pItem = GetFocusedItem(); - pItem = GetItem(pItem, dwKeyCode); + pItem = GetListItem(pItem, dwKeyCode); bool bShift = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Shift); bool bCtrl = !!(pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl); OnVK(pItem, bShift, bCtrl); diff --git a/xfa/fwl/core/ifwl_listbox.h b/xfa/fwl/core/ifwl_listbox.h index ec6587460b..b6c0b8266b 100644 --- a/xfa/fwl/core/ifwl_listbox.h +++ b/xfa/fwl/core/ifwl_listbox.h @@ -98,13 +98,13 @@ class IFWL_ListBox : public IFWL_Widget { CFWL_ListItem* GetSelItem(int32_t nIndexSel); int32_t GetSelIndex(int32_t nIndex); void SetSelItem(CFWL_ListItem* hItem, bool bSelect = true); - void GetItemText(CFWL_ListItem* hItem, CFX_WideString& wsText); + void GetDataProviderItemText(CFWL_ListItem* hItem, CFX_WideString& wsText); FX_FLOAT GetItemHeight() const { return m_fItemHeight; } FX_FLOAT CalcItemHeight(); protected: - CFWL_ListItem* GetItem(CFWL_ListItem* hItem, uint32_t dwKeyCode); + CFWL_ListItem* GetListItem(CFWL_ListItem* hItem, uint32_t dwKeyCode); void SetSelection(CFWL_ListItem* hStart, CFWL_ListItem* hEnd, bool bSelected); CFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); bool ScrollToVisible(CFWL_ListItem* hItem); @@ -120,7 +120,7 @@ class IFWL_ListBox : public IFWL_Widget { void SelectAll(); CFWL_ListItem* GetFocusedItem(); void SetFocusItem(CFWL_ListItem* hItem); - bool GetItemCheckRect(CFWL_ListItem* hItem, CFX_RectF& rtCheck); + bool GetItemCheckRectInternal(CFWL_ListItem* hItem, CFX_RectF& rtCheck); bool SetItemChecked(CFWL_ListItem* hItem, bool bChecked); bool GetItemChecked(CFWL_ListItem* hItem); void DrawBkground(CFX_Graphics* pGraphics, diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 63ed7c46d3..da433aeeed 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -66,7 +66,7 @@ bool CXFA_FFListBox::LoadWidget() { m_pDataAcc->GetSelectedItems(iSelArray); int32_t iSelCount = iSelArray.GetSize(); for (int32_t j = 0; j < iSelCount; j++) { - CFWL_ListItem* item = pListBox->GetItem(iSelArray[j]); + CFWL_ListItem* item = pListBox->GetItem(nullptr, iSelArray[j]); pListBox->SetSelItem(item, true); } m_pNormalWidget->UnlockUpdate(); @@ -100,7 +100,7 @@ bool CXFA_FFListBox::IsDataChanged() { return true; for (int32_t i = 0; i < iSels; ++i) { - CFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]); + CFWL_ListItem* hlistItem = pListBox->GetItem(nullptr, iSelArray[i]); if (!(pListBox->GetItemStates(hlistItem) & FWL_ITEMSTATE_LTB_Selected)) return true; } @@ -160,7 +160,7 @@ void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, CFWL_ListBox* pListBox = (CFWL_ListBox*)m_pNormalWidget; int32_t iSels = pListBox->CountSelItems(); if (iSels > 0) { - pListBox->GetItemText(pListBox->GetSelItem(0), eParam.m_wsNewText); + pListBox->GetItemText(nullptr, pListBox->GetSelItem(0), eParam.m_wsNewText); } m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); } @@ -178,13 +178,13 @@ void CXFA_FFListBox::InsertItem(const CFX_WideStringC& wsLabel, AddInvalidateRect(); } void CXFA_FFListBox::DeleteItem(int32_t nIndex) { - if (nIndex < 0) { - ((CFWL_ListBox*)m_pNormalWidget)->DeleteAll(); - } else { - ((CFWL_ListBox*)m_pNormalWidget) - ->DeleteString(((CFWL_ListBox*)m_pNormalWidget)->GetItem(nIndex)); - } - m_pNormalWidget->Update(); + CFWL_ListBox* listBox = static_cast(m_pNormalWidget); + if (nIndex < 0) + listBox->DeleteAll(); + else + listBox->DeleteString(listBox->GetItem(nullptr, nIndex)); + + listBox->Update(); AddInvalidateRect(); } -- cgit v1.2.3