diff options
Diffstat (limited to 'xfa')
-rw-r--r-- | xfa/fwl/basewidget/fwl_comboboximp.cpp | 34 | ||||
-rw-r--r-- | xfa/fwl/basewidget/fwl_listboximp.cpp | 234 | ||||
-rw-r--r-- | xfa/fwl/basewidget/fwl_listboximp.h | 38 | ||||
-rw-r--r-- | xfa/fwl/basewidget/ifwl_listbox.h | 43 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_combobox.cpp | 104 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_combobox.h | 38 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_listbox.cpp | 164 | ||||
-rw-r--r-- | xfa/fwl/lightwidget/cfwl_listbox.h | 64 | ||||
-rw-r--r-- | xfa/fxfa/app/xfa_ffchoicelist.cpp | 10 |
9 files changed, 361 insertions, 368 deletions
diff --git a/xfa/fwl/basewidget/fwl_comboboximp.cpp b/xfa/fwl/basewidget/fwl_comboboximp.cpp index 3e70cffffd..34e98fa38a 100644 --- a/xfa/fwl/basewidget/fwl_comboboximp.cpp +++ b/xfa/fwl/basewidget/fwl_comboboximp.cpp @@ -223,7 +223,7 @@ int32_t CFWL_ComboListImp::MatchItem(const CFX_WideString& wsMatch) { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, i); CFX_WideString wsText; pData->GetItemText(m_pInterface, hItem, wsText); FX_STRSIZE pos = wsText.Find(wsMatch.c_str()); @@ -238,10 +238,10 @@ void CFWL_ComboListImp::ChangeSelected(int32_t iSel) { return; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iSel); CFX_RectF rtInvalidate; rtInvalidate.Reset(); - FWL_HLISTITEM hOld = GetSelItem(0); + IFWL_ListItem* hOld = GetSelItem(0); int32_t iOld = pData->GetItemIndex(m_pInterface, hOld); if (iOld == iSel) { return; @@ -253,7 +253,7 @@ void CFWL_ComboListImp::ChangeSelected(int32_t iSel) { CFX_RectF rect; GetItemRect(iSel, rect); rtInvalidate.Union(rect); - FWL_HLISTITEM hSel = pData->GetItem(m_pInterface, iSel); + IFWL_ListItem* hSel = pData->GetItem(m_pInterface, iSel); SetSelItem(hSel, TRUE); } if (!rtInvalidate.IsEmpty()) { @@ -268,7 +268,7 @@ int32_t CFWL_ComboListImp::CountItems() { void CFWL_ComboListImp::GetItemRect(int32_t nIndex, CFX_RectF& rtItem) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, nIndex); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, nIndex); pData->GetItemRect(m_pInterface, hItem, rtItem); } void CFWL_ComboListImp::ClientToOuter(FX_FLOAT& fx, FX_FLOAT& fy) { @@ -358,7 +358,7 @@ int32_t CFWL_ComboListImpDelegate::OnDropListMouseMove(CFWL_MsgMouse* pMsg) { return 1; } } - FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); if (hItem) { if (!m_pOwner->m_pProperties->m_pDataProvider) return 0; @@ -403,7 +403,7 @@ int32_t CFWL_ComboListImpDelegate::OnDropListLButtonUp(CFWL_MsgMouse* pMsg) { } } pOuter->ShowDropList(FALSE); - FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + IFWL_ListItem* hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); if (hItem) { pOuter->ProcessSelChanged(TRUE); } @@ -452,7 +452,7 @@ void CFWL_ComboListImpDelegate::OnDropListKeyDown(CFWL_MsgKey* pKey) { static_cast<CFWL_ComboBoxImp*>(m_pOwner->m_pOuter->GetImpl()); IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>( m_pOwner->m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = + IFWL_ListItem* hItem = pData->GetItem(m_pOwner->m_pInterface, pOuter->m_iCurSel); hItem = m_pOwner->GetItem(hItem, dwKeyCode); if (!hItem) { @@ -657,7 +657,7 @@ FWL_Error CFWL_ComboBoxImp::DrawWidget(CFX_Graphics* pGraphics, CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) ->GetItemText(hItem, wsText); CFWL_ThemeText param; @@ -718,7 +718,7 @@ FWL_Error CFWL_ComboBoxImp::SetCurSel(int32_t iSel) { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iSel); static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) ->GetItemText(hItem, wsText); m_pEdit->SetText(wsText); @@ -757,7 +757,7 @@ FWL_Error CFWL_ComboBoxImp::GetEditText(CFX_WideString& wsText, } else if (m_pListBox) { IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); return m_pListBox->GetItemText(hItem, wsText); } return FWL_Error::Indefinite; @@ -997,7 +997,7 @@ void CFWL_ComboBoxImp::SynchrEditText(int32_t iListItem) { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iListItem); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, iListItem); static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) ->GetItemText(hItem, wsText); m_pEdit->SetText(wsText); @@ -1026,7 +1026,7 @@ void CFWL_ComboBoxImp::Layout() { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) ->GetItemText(hItem, wsText); m_pEdit->LockUpdate(); @@ -1115,7 +1115,7 @@ void CFWL_ComboBoxImp::ProcessSelChanged(FX_BOOL bLButtonUp) { if (bDropDown) { IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); if (hItem) { CFX_WideString wsText; pData->GetItemText(m_pInterface, hItem, wsText); @@ -1357,7 +1357,7 @@ void CFWL_ComboBoxImp::DisForm_Layout() { CFX_WideString wsText; IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, m_iCurSel); + IFWL_ListItem* hItem = pData->GetItem(m_pInterface, m_iCurSel); static_cast<CFWL_ComboListImp*>(m_pListBox->GetImpl()) ->GetItemText(hItem, wsText); m_pEdit->LockUpdate(); @@ -1570,7 +1570,7 @@ void CFWL_ComboBoxImpDelegate::DoSubCtrlKey(CFWL_MsgKey* pMsg) { CFX_WideString wsTemp; IFWL_ComboBoxDP* pData = static_cast<IFWL_ComboBoxDP*>( m_pOwner->m_pProperties->m_pDataProvider); - FWL_HLISTITEM hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel); + IFWL_ListItem* hItem = pData->GetItem(m_pOwner->m_pInterface, iCurSel); static_cast<CFWL_ComboListImp*>(m_pOwner->m_pListBox->GetImpl()) ->GetItemText(hItem, wsTemp); bMatchEqual = wsText == wsTemp; @@ -1721,7 +1721,7 @@ void CFWL_ComboBoxImpDelegate::DisForm_OnKey(CFWL_MsgKey* pMsg) { iCurSel = pComboList->MatchItem(wsText); if (iCurSel >= 0) { CFX_WideString wsTemp; - FWL_HLISTITEM item = m_pOwner->m_pListBox->GetSelItem(iCurSel); + IFWL_ListItem* item = m_pOwner->m_pListBox->GetSelItem(iCurSel); m_pOwner->m_pListBox->GetItemText(item, wsTemp); bMatchEqual = wsText == wsTemp; } diff --git a/xfa/fwl/basewidget/fwl_listboximp.cpp b/xfa/fwl/basewidget/fwl_listboximp.cpp index 9b05a7fee4..639a46c87b 100644 --- a/xfa/fwl/basewidget/fwl_listboximp.cpp +++ b/xfa/fwl/basewidget/fwl_listboximp.cpp @@ -46,18 +46,18 @@ IFWL_ListBox::IFWL_ListBox() {} int32_t IFWL_ListBox::CountSelItems() { return static_cast<CFWL_ListBoxImp*>(GetImpl())->CountSelItems(); } -FWL_HLISTITEM IFWL_ListBox::GetSelItem(int32_t nIndexSel) { +IFWL_ListItem* IFWL_ListBox::GetSelItem(int32_t nIndexSel) { return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelItem(nIndexSel); } int32_t IFWL_ListBox::GetSelIndex(int32_t nIndex) { return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetSelIndex(nIndex); } -FWL_Error IFWL_ListBox::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { - return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(hItem, bSelect); +FWL_Error IFWL_ListBox::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) { + return static_cast<CFWL_ListBoxImp*>(GetImpl())->SetSelItem(pItem, bSelect); } -FWL_Error IFWL_ListBox::GetItemText(FWL_HLISTITEM hItem, +FWL_Error IFWL_ListBox::GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText) { - return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(hItem, wsText); + return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetItemText(pItem, wsText); } FWL_Error IFWL_ListBox::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { return static_cast<CFWL_ListBoxImp*>(GetImpl())->GetScrollPos(fPos, bVert); @@ -217,18 +217,18 @@ int32_t CFWL_ListBoxImp::CountSelItems() { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) { continue; } - uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); + uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { iRet++; } } return iRet; } -FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { +IFWL_ListItem* CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { if (!m_pProperties->m_pDataProvider) return NULL; int32_t index = 0; @@ -236,14 +236,14 @@ FWL_HLISTITEM CFWL_ListBoxImp::GetSelItem(int32_t nIndexSel) { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) { return NULL; } - uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); + uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { if (index == nIndexSel) { - return hItem; + return pItem; } else { index++; } @@ -259,11 +259,11 @@ int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) { return -1; } - uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); + uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); if (dwStyle & FWL_ITEMSTATE_LTB_Selected) { if (index == nIndex) { return i; @@ -274,10 +274,10 @@ int32_t CFWL_ListBoxImp::GetSelIndex(int32_t nIndex) { } return -1; } -FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { +FWL_Error CFWL_ListBoxImp::SetSelItem(IFWL_ListItem* pItem, FX_BOOL bSelect) { if (!m_pProperties->m_pDataProvider) return FWL_Error::Indefinite; - if (!hItem) { + if (!pItem) { if (bSelect) { SelectAll(); } else { @@ -287,21 +287,21 @@ FWL_Error CFWL_ListBoxImp::SetSelItem(FWL_HLISTITEM hItem, FX_BOOL bSelect) { return FWL_Error::Indefinite; } if (m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { - SetSelectionDirect(hItem, bSelect); + SetSelectionDirect(pItem, bSelect); } else { - SetSelection(hItem, hItem, bSelect); + SetSelection(pItem, pItem, bSelect); } return FWL_Error::Succeeded; } -FWL_Error CFWL_ListBoxImp::GetItemText(FWL_HLISTITEM hItem, +FWL_Error CFWL_ListBoxImp::GetItemText(IFWL_ListItem* pItem, CFX_WideString& wsText) { if (!m_pProperties->m_pDataProvider) return FWL_Error::Indefinite; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - if (!hItem) + if (!pItem) return FWL_Error::Indefinite; - pData->GetItemText(m_pInterface, hItem, wsText); + pData->GetItemText(m_pInterface, pItem, wsText); return FWL_Error::Succeeded; } @@ -315,9 +315,9 @@ FWL_Error CFWL_ListBoxImp::GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert) { return FWL_Error::Indefinite; } -FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, - uint32_t dwKeyCode) { - FWL_HLISTITEM hRet = NULL; +IFWL_ListItem* CFWL_ListBoxImp::GetItem(IFWL_ListItem* pItem, + uint32_t dwKeyCode) { + IFWL_ListItem* hRet = NULL; switch (dwKeyCode) { case FWL_VKEY_Up: case FWL_VKEY_Down: @@ -330,7 +330,7 @@ FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iDstItem = -1; if (bUp || bDown) { - int32_t index = pData->GetItemIndex(m_pInterface, hItem); + int32_t index = pData->GetItemIndex(m_pInterface, pItem); iDstItem = dwKeyCode == FWL_VKEY_Up ? index - 1 : index + 1; } else if (bHome) { iDstItem = 0; @@ -345,8 +345,8 @@ FWL_HLISTITEM CFWL_ListBoxImp::GetItem(FWL_HLISTITEM hItem, } return hRet; } -void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart, - FWL_HLISTITEM hEnd, +void CFWL_ListBoxImp::SetSelection(IFWL_ListItem* hStart, + IFWL_ListItem* hEnd, FX_BOOL bSelected) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); @@ -360,27 +360,28 @@ void CFWL_ListBoxImp::SetSelection(FWL_HLISTITEM hStart, if (bSelected) { int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - SetSelectionDirect(hItem, FALSE); + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + SetSelectionDirect(pItem, FALSE); } } for (; iStart <= iEnd; iStart++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, iStart); - SetSelectionDirect(hItem, bSelected); + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, iStart); + SetSelectionDirect(pItem, bSelected); } } -void CFWL_ListBoxImp::SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect) { +void CFWL_ListBoxImp::SetSelectionDirect(IFWL_ListItem* pItem, + FX_BOOL bSelect) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - uint32_t dwOldStyle = pData->GetItemStyles(m_pInterface, hItem); + uint32_t dwOldStyle = pData->GetItemStyles(m_pInterface, pItem); bSelect ? dwOldStyle |= FWL_ITEMSTATE_LTB_Selected : dwOldStyle &= ~FWL_ITEMSTATE_LTB_Selected; - pData->SetItemStyles(m_pInterface, hItem, dwOldStyle); + pData->SetItemStyles(m_pInterface, pItem, dwOldStyle); } -FX_BOOL CFWL_ListBoxImp::IsItemSelected(FWL_HLISTITEM hItem) { +FX_BOOL CFWL_ListBoxImp::IsItemSelected(IFWL_ListItem* pItem) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem); + uint32_t dwState = pData->GetItemStyles(m_pInterface, pItem); return (dwState & FWL_ITEMSTATE_LTB_Selected) != 0; } void CFWL_ListBoxImp::ClearSelection() { @@ -390,11 +391,11 @@ void CFWL_ListBoxImp::ClearSelection() { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - uint32_t dwState = pData->GetItemStyles(m_pInterface, hItem); + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + uint32_t dwState = pData->GetItemStyles(m_pInterface, pItem); if (!(dwState & FWL_ITEMSTATE_LTB_Selected)) continue; - SetSelectionDirect(hItem, FALSE); + SetSelectionDirect(pItem, FALSE); if (!bMulti) return; } @@ -409,43 +410,43 @@ void CFWL_ListBoxImp::SelectAll() { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); if (iCount > 0) { - FWL_HLISTITEM hItemStart = pData->GetItem(m_pInterface, 0); - FWL_HLISTITEM hItemEnd = pData->GetItem(m_pInterface, iCount - 1); - SetSelection(hItemStart, hItemEnd, FALSE); + IFWL_ListItem* pItemStart = pData->GetItem(m_pInterface, 0); + IFWL_ListItem* pItemEnd = pData->GetItem(m_pInterface, iCount - 1); + SetSelection(pItemStart, pItemEnd, FALSE); } } -FWL_HLISTITEM CFWL_ListBoxImp::GetFocusedItem() { +IFWL_ListItem* CFWL_ListBoxImp::GetFocusedItem() { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) return NULL; - if (pData->GetItemStyles(m_pInterface, hItem) & FWL_ITEMSTATE_LTB_Focused) { - return hItem; + if (pData->GetItemStyles(m_pInterface, pItem) & FWL_ITEMSTATE_LTB_Focused) { + return pItem; } } return NULL; } -void CFWL_ListBoxImp::SetFocusItem(FWL_HLISTITEM hItem) { +void CFWL_ListBoxImp::SetFocusItem(IFWL_ListItem* pItem) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - FWL_HLISTITEM hFocus = GetFocusedItem(); - if (hItem != hFocus) { + IFWL_ListItem* hFocus = GetFocusedItem(); + if (pItem != hFocus) { if (hFocus) { uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hFocus); dwStyle &= ~FWL_ITEMSTATE_LTB_Focused; pData->SetItemStyles(m_pInterface, hFocus, dwStyle); } - if (hItem) { - uint32_t dwStyle = pData->GetItemStyles(m_pInterface, hItem); + if (pItem) { + uint32_t dwStyle = pData->GetItemStyles(m_pInterface, pItem); dwStyle |= FWL_ITEMSTATE_LTB_Focused; - pData->SetItemStyles(m_pInterface, hItem, dwStyle); + pData->SetItemStyles(m_pInterface, pItem, dwStyle); } } } -FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { +IFWL_ListItem* CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { fx -= m_rtConent.left, fy -= m_rtConent.top; FX_FLOAT fPosX = 0.0f; if (m_pHorzScrollBar) { @@ -459,20 +460,20 @@ FWL_HLISTITEM CFWL_ListBoxImp::GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy) { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t nCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < nCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) { continue; } CFX_RectF rtItem; - pData->GetItemRect(m_pInterface, hItem, rtItem); + pData->GetItemRect(m_pInterface, pItem, rtItem); rtItem.Offset(-fPosX, -fPosY); if (rtItem.Contains(fx, fy)) { - return hItem; + return pItem; } } return NULL; } -FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem, +FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(IFWL_ListItem* pItem, CFX_RectF& rtCheck) { if (!m_pProperties->m_pDataProvider) return FALSE; @@ -481,10 +482,10 @@ FX_BOOL CFWL_ListBoxImp::GetItemCheckRect(FWL_HLISTITEM hItem, } IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->GetItemCheckRect(m_pInterface, hItem, rtCheck); + pData->GetItemCheckRect(m_pInterface, pItem, rtCheck); return TRUE; } -FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem) { +FX_BOOL CFWL_ListBoxImp::GetItemChecked(IFWL_ListItem* pItem) { if (!m_pProperties->m_pDataProvider) return FALSE; if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { @@ -492,10 +493,11 @@ FX_BOOL CFWL_ListBoxImp::GetItemChecked(FWL_HLISTITEM hItem) { } IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - return (pData->GetItemCheckState(m_pInterface, hItem) & + return (pData->GetItemCheckState(m_pInterface, pItem) & FWL_ITEMSTATE_LTB_Checked); } -FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked) { +FX_BOOL CFWL_ListBoxImp::SetItemChecked(IFWL_ListItem* pItem, + FX_BOOL bChecked) { if (!m_pProperties->m_pDataProvider) return FALSE; if (!(m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check)) { @@ -503,17 +505,17 @@ FX_BOOL CFWL_ListBoxImp::SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked) { } IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemCheckState(m_pInterface, hItem, + pData->SetItemCheckState(m_pInterface, pItem, bChecked ? FWL_ITEMSTATE_LTB_Checked : 0); return TRUE; } -FX_BOOL CFWL_ListBoxImp::ScrollToVisible(FWL_HLISTITEM hItem) { +FX_BOOL CFWL_ListBoxImp::ScrollToVisible(IFWL_ListItem* pItem) { if (!m_pVertScrollBar) return FALSE; CFX_RectF rtItem; IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->GetItemRect(m_pInterface, hItem, rtItem); + pData->GetItemRect(m_pInterface, pItem, rtItem); FX_BOOL bScroll = FALSE; FX_FLOAT fPosY = m_pVertScrollBar->GetPos(); rtItem.Offset(0, -fPosY + m_rtConent.top); @@ -578,12 +580,12 @@ void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics, static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) { continue; } CFX_RectF rtItem; - pData->GetItemRect(m_pInterface, hItem, rtItem); + pData->GetItemRect(m_pInterface, pItem, rtItem); rtItem.Offset(m_rtConent.left - fPosX, m_rtConent.top - fPosY); if (rtItem.bottom() < m_rtConent.top) { continue; @@ -603,19 +605,19 @@ void CFWL_ListBoxImp::DrawItems(CFX_Graphics* pGraphics, ev.m_rect = rtItem; DispatchEvent(&ev); } else { - DrawItem(pGraphics, pTheme, hItem, i, rtItem, pMatrix); + DrawItem(pGraphics, pTheme, pItem, i, rtItem, pMatrix); } } } void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, int32_t Index, const CFX_RectF& rtItem, const CFX_Matrix* pMatrix) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, hItem); + uint32_t dwItemStyles = pData->GetItemStyles(m_pInterface, pItem); uint32_t dwPartStates = CFWL_PartState_Normal; if (m_pProperties->m_dwStates & FWL_WGTSTATE_Disabled) { dwPartStates = CFWL_PartState_Disabled; @@ -649,7 +651,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, FX_BOOL bHasIcon = GetStylesEx() & FWL_STYLEEXT_LTB_Icon; if (bHasIcon) { CFX_RectF rtDIB; - CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, hItem); + CFX_DIBitmap* pDib = pData->GetItemIcon(m_pInterface, pItem); rtDIB.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); if (pDib) { CFWL_ThemeBackground param; @@ -668,12 +670,12 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, CFX_RectF rtCheck; rtCheck.Set(rtItem.left, rtItem.top, rtItem.height, rtItem.height); rtCheck.Deflate(2, 2, 2, 2); - pData->SetItemCheckRect(m_pInterface, hItem, rtCheck); + pData->SetItemCheckRect(m_pInterface, pItem, rtCheck); CFWL_ThemeBackground param; param.m_pWidget = m_pInterface; param.m_iPart = CFWL_Part::Check; param.m_pGraphics = pGraphics; - if (GetItemChecked(hItem)) { + if (GetItemChecked(pItem)) { param.m_dwStates = CFWL_PartState_Checked; } else { param.m_dwStates = CFWL_PartState_Normal; @@ -684,7 +686,7 @@ void CFWL_ListBoxImp::DrawItem(CFX_Graphics* pGraphics, pTheme->DrawBackground(¶m); } CFX_WideString wsText; - pData->GetItemText(m_pInterface, hItem, wsText); + pData->GetItemText(m_pInterface, pItem, wsText); if (wsText.GetLength() <= 0) { return; } @@ -728,11 +730,9 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { if (m_pProperties->m_pThemeProvider->IsCustomizedLayout(m_pInterface)) { IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - if (!bAutoSize) { - } int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); CFWL_ThemePart itemPart; itemPart.m_pWidget = m_pInterface; itemPart.m_iPart = CFWL_Part::ListItem; @@ -745,7 +745,7 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { rtItem.Set(m_rtClient.left, m_rtClient.top + fs.y, r.width, r.height); IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemRect(m_pInterface, hItem, rtItem); + pData->SetItemRect(m_pInterface, pItem, rtItem); } fs.y += r.height; if (fs.x < r.width) { @@ -773,7 +773,7 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { } int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM htem = pData->GetItem(m_pInterface, i); + IFWL_ListItem* htem = pData->GetItem(m_pInterface, i); GetItemSize(fs, htem, fWidth, m_fItemHeight, bAutoSize); } } @@ -877,7 +877,7 @@ CFX_SizeF CFWL_ListBoxImp::CalcSize(FX_BOOL bAutoSize) { return fs; } void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, FX_FLOAT fWidth, FX_FLOAT m_fItemHeight, FX_BOOL bAutoSize) { @@ -888,7 +888,7 @@ void CFWL_ListBoxImp::GetItemSize(CFX_SizeF& size, rtItem.Set(0, size.y, fWidth, m_fItemHeight); IFWL_ListBoxDP* pData = static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); - pData->SetItemRect(m_pInterface, hItem, rtItem); + pData->SetItemRect(m_pInterface, pItem, rtItem); } size.x = fWidth; size.y += m_fItemHeight; @@ -900,12 +900,12 @@ FX_FLOAT CFWL_ListBoxImp::GetMaxTextWidth() { static_cast<IFWL_ListBoxDP*>(m_pProperties->m_pDataProvider); int32_t iCount = pData->CountItems(m_pInterface); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM hItem = pData->GetItem(m_pInterface, i); - if (!hItem) { + IFWL_ListItem* pItem = pData->GetItem(m_pInterface, i); + if (!pItem) { continue; } CFX_WideString wsText; - pData->GetItemText(m_pInterface, hItem, wsText); + pData->GetItemText(m_pInterface, pItem, wsText); CFX_SizeF sz = CalcTextSize(wsText, m_pProperties->m_pThemeProvider); if (sz.x > fRet) { fRet = sz.x; @@ -957,7 +957,7 @@ void CFWL_ListBoxImp::ProcessSelChanged() { CFX_Int32Array arrSels; int32_t iCount = CountSelItems(); for (int32_t i = 0; i < iCount; i++) { - FWL_HLISTITEM item = GetSelItem(i); + IFWL_ListItem* item = GetSelItem(i); if (item == NULL) { continue; } @@ -1061,46 +1061,46 @@ void CFWL_ListBoxImpDelegate::OnLButtonDown(CFWL_MsgMouse* pMsg) { if ((m_pOwner->m_pProperties->m_dwStates & FWL_WGTSTATE_Focused) == 0) { m_pOwner->SetFocus(TRUE); } - FWL_HLISTITEM hItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); - if (!hItem) { + IFWL_ListItem* pItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); + if (!pItem) { return; } if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_MultiSelection) { if (pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl) { - FX_BOOL bSelected = m_pOwner->IsItemSelected(hItem); - m_pOwner->SetSelectionDirect(hItem, !bSelected); - m_pOwner->m_hAnchor = hItem; + FX_BOOL bSelected = m_pOwner->IsItemSelected(pItem); + m_pOwner->SetSelectionDirect(pItem, !bSelected); + m_pOwner->m_hAnchor = pItem; } else if (pMsg->m_dwFlags & FWL_KEYFLAG_Shift) { if (m_pOwner->m_hAnchor) { - m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); + m_pOwner->SetSelection(m_pOwner->m_hAnchor, pItem, TRUE); } else { - m_pOwner->SetSelectionDirect(hItem, TRUE); + m_pOwner->SetSelectionDirect(pItem, TRUE); } } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); - m_pOwner->m_hAnchor = hItem; + m_pOwner->SetSelection(pItem, pItem, TRUE); + m_pOwner->m_hAnchor = pItem; } } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); + m_pOwner->SetSelection(pItem, pItem, TRUE); } if (m_pOwner->m_pProperties->m_dwStyleExes & FWL_STYLEEXT_LTB_Check) { - FWL_HLISTITEM hSelectedItem = + IFWL_ListItem* hSelectedItem = m_pOwner->GetItemAtPoint(pMsg->m_fx, pMsg->m_fy); CFX_RectF rtCheck; m_pOwner->GetItemCheckRect(hSelectedItem, rtCheck); - FX_BOOL bChecked = m_pOwner->GetItemChecked(hItem); + FX_BOOL bChecked = m_pOwner->GetItemChecked(pItem); if (rtCheck.Contains(pMsg->m_fx, pMsg->m_fy)) { if (bChecked) { - m_pOwner->SetItemChecked(hItem, FALSE); + m_pOwner->SetItemChecked(pItem, FALSE); } else { - m_pOwner->SetItemChecked(hItem, TRUE); + m_pOwner->SetItemChecked(pItem, TRUE); } m_pOwner->Update(); } } - m_pOwner->SetFocusItem(hItem); - m_pOwner->ScrollToVisible(hItem); + m_pOwner->SetFocusItem(pItem); + m_pOwner->ScrollToVisible(pItem); m_pOwner->SetGrab(TRUE); m_pOwner->ProcessSelChanged(); m_pOwner->Repaint(&m_pOwner->m_rtClient); @@ -1128,11 +1128,11 @@ void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { case FWL_VKEY_Down: case FWL_VKEY_Home: case FWL_VKEY_End: { - FWL_HLISTITEM hItem = m_pOwner->GetFocusedItem(); - hItem = m_pOwner->GetItem(hItem, dwKeyCode); + IFWL_ListItem* pItem = m_pOwner->GetFocusedItem(); + pItem = m_pOwner->GetItem(pItem, dwKeyCode); FX_BOOL bShift = pMsg->m_dwFlags & FWL_KEYFLAG_Shift; FX_BOOL bCtrl = pMsg->m_dwFlags & FWL_KEYFLAG_Ctrl; - OnVK(hItem, bShift, bCtrl); + OnVK(pItem, bShift, bCtrl); DispatchSelChangedEv(); m_pOwner->ProcessSelChanged(); break; @@ -1140,10 +1140,10 @@ void CFWL_ListBoxImpDelegate::OnKeyDown(CFWL_MsgKey* pMsg) { default: {} } } -void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem, +void CFWL_ListBoxImpDelegate::OnVK(IFWL_ListItem* pItem, FX_BOOL bShift, FX_BOOL bCtrl) { - if (!hItem) { + if (!pItem) { return; } if (m_pOwner->m_pProperties->m_dwStyleExes & @@ -1151,19 +1151,19 @@ void CFWL_ListBoxImpDelegate::OnVK(FWL_HLISTITEM hItem, if (bCtrl) { } else if (bShift) { if (m_pOwner->m_hAnchor) { - m_pOwner->SetSelection(m_pOwner->m_hAnchor, hItem, TRUE); + m_pOwner->SetSelection(m_pOwner->m_hAnchor, pItem, TRUE); } else { - m_pOwner->SetSelectionDirect(hItem, TRUE); + m_pOwner->SetSelectionDirect(pItem, TRUE); } } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); - m_pOwner->m_hAnchor = hItem; + m_pOwner->SetSelection(pItem, pItem, TRUE); + m_pOwner->m_hAnchor = pItem; } } else { - m_pOwner->SetSelection(hItem, hItem, TRUE); + m_pOwner->SetSelection(pItem, pItem, TRUE); } - m_pOwner->SetFocusItem(hItem); - m_pOwner->ScrollToVisible(hItem); + m_pOwner->SetFocusItem(pItem); + m_pOwner->ScrollToVisible(pItem); { CFX_RectF rtInvalidate; rtInvalidate.Set(0, 0, m_pOwner->m_pProperties->m_rtWidget.width, diff --git a/xfa/fwl/basewidget/fwl_listboximp.h b/xfa/fwl/basewidget/fwl_listboximp.h index f32dece8dc..1a7a9419e5 100644 --- a/xfa/fwl/basewidget/fwl_listboximp.h +++ b/xfa/fwl/basewidget/fwl_listboximp.h @@ -39,31 +39,31 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp { FWL_Error SetThemeProvider(IFWL_ThemeProvider* pThemeProvider) override; 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* hItem, FX_BOOL bSelect = TRUE); + FWL_Error GetItemText(IFWL_ListItem* hItem, CFX_WideString& wsText); FWL_Error GetScrollPos(FX_FLOAT& fPos, FX_BOOL bVert = TRUE); FWL_Error* Sort(IFWL_ListBoxCompare* pCom); protected: friend class CFWL_ListBoxImpDelegate; - FWL_HLISTITEM GetItem(FWL_HLISTITEM hItem, uint32_t dwKeyCode); - void SetSelection(FWL_HLISTITEM hStart, - FWL_HLISTITEM hEnd, + IFWL_ListItem* GetItem(IFWL_ListItem* hItem, uint32_t dwKeyCode); + void SetSelection(IFWL_ListItem* hStart, + IFWL_ListItem* hEnd, FX_BOOL bSelected); - void SetSelectionDirect(FWL_HLISTITEM hItem, FX_BOOL bSelect); - FX_BOOL IsItemSelected(FWL_HLISTITEM hItem); + void SetSelectionDirect(IFWL_ListItem* hItem, FX_BOOL bSelect); + FX_BOOL IsItemSelected(IFWL_ListItem* hItem); void ClearSelection(); void SelectAll(); - FWL_HLISTITEM GetFocusedItem(); - void SetFocusItem(FWL_HLISTITEM hItem); - FWL_HLISTITEM GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); - FX_BOOL GetItemCheckRect(FWL_HLISTITEM hItem, CFX_RectF& rtCheck); - FX_BOOL SetItemChecked(FWL_HLISTITEM hItem, FX_BOOL bChecked); - FX_BOOL GetItemChecked(FWL_HLISTITEM hItem); - FX_BOOL ScrollToVisible(FWL_HLISTITEM hItem); + IFWL_ListItem* GetFocusedItem(); + void SetFocusItem(IFWL_ListItem* hItem); + IFWL_ListItem* GetItemAtPoint(FX_FLOAT fx, FX_FLOAT fy); + FX_BOOL GetItemCheckRect(IFWL_ListItem* hItem, CFX_RectF& rtCheck); + FX_BOOL SetItemChecked(IFWL_ListItem* hItem, FX_BOOL bChecked); + FX_BOOL GetItemChecked(IFWL_ListItem* hItem); + FX_BOOL ScrollToVisible(IFWL_ListItem* hItem); void DrawBkground(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, const CFX_Matrix* pMatrix = NULL); @@ -72,14 +72,14 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp { const CFX_Matrix* pMatrix = NULL); void DrawItem(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme, - FWL_HLISTITEM hItem, + IFWL_ListItem* hItem, int32_t Index, const CFX_RectF& rtItem, const CFX_Matrix* pMatrix = NULL); void DrawStatic(CFX_Graphics* pGraphics, IFWL_ThemeProvider* pTheme); CFX_SizeF CalcSize(FX_BOOL bAutoSize = FALSE); void GetItemSize(CFX_SizeF& size, - FWL_HLISTITEM hItem, + IFWL_ListItem* hItem, FX_FLOAT fWidth, FX_FLOAT fHeight, FX_BOOL bAutoSize = FALSE); @@ -97,7 +97,7 @@ class CFWL_ListBoxImp : public CFWL_WidgetImp { std::unique_ptr<IFWL_ScrollBar> m_pVertScrollBar; uint32_t m_dwTTOStyles; int32_t m_iTTOAligns; - FWL_HLISTITEM m_hAnchor; + IFWL_ListItem* m_hAnchor; FX_FLOAT m_fItemHeight; FX_FLOAT m_fScorllBarWidth; FX_BOOL m_bLButtonDown; @@ -117,7 +117,7 @@ class CFWL_ListBoxImpDelegate : public CFWL_WidgetImpDelegate { void OnLButtonUp(CFWL_MsgMouse* pMsg); void OnMouseWheel(CFWL_MsgMouseWheel* pMsg); void OnKeyDown(CFWL_MsgKey* pMsg); - void OnVK(FWL_HLISTITEM hItem, FX_BOOL bShift, FX_BOOL bCtrl); + void OnVK(IFWL_ListItem* hItem, FX_BOOL bShift, FX_BOOL bCtrl); FX_BOOL OnScroll(IFWL_ScrollBar* pScrollBar, uint32_t dwCode, FX_FLOAT fPos); void DispatchSelChangedEv(); CFWL_ListBoxImp* m_pOwner; diff --git a/xfa/fwl/basewidget/ifwl_listbox.h b/xfa/fwl/basewidget/ifwl_listbox.h index 9782cbbc29..c531cea9f3 100644 --- a/xfa/fwl/basewidget/ifwl_listbox.h +++ b/xfa/fwl/basewidget/ifwl_listbox.h @@ -29,8 +29,6 @@ #define FWL_ITEMSTATE_LTB_Focused (1L << 1) #define FWL_ITEMSTATE_LTB_Checked (1L << 2) -typedef struct FWL_HLISTITEM_ { void* pData; } * FWL_HLISTITEM; - class CFX_DIBitmap; BEGIN_FWL_EVENT_DEF(CFWL_EvtLtbSelChanged, CFWL_EventType::SelectChanged) @@ -44,51 +42,54 @@ int32_t m_index; CFX_RectF m_rect; END_FWL_EVENT_DEF +class IFWL_ListItem {}; + class IFWL_ListBoxDP : public IFWL_DataProvider { public: virtual int32_t CountItems(IFWL_Widget* pWidget) = 0; - virtual FWL_HLISTITEM GetItem(IFWL_Widget* pWidget, int32_t nIndex) = 0; - virtual int32_t GetItemIndex(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0; + virtual IFWL_ListItem* GetItem(IFWL_Widget* pWidget, int32_t nIndex) = 0; + virtual int32_t GetItemIndex(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; virtual FX_BOOL SetItemIndex(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, int32_t nIndex) = 0; - virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0; + virtual uint32_t GetItemStyles(IFWL_Widget* pWidget, + IFWL_ListItem* pItem) = 0; virtual FWL_Error GetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, CFX_WideString& wsText) = 0; virtual FWL_Error GetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, CFX_RectF& rtItem) = 0; - virtual void* GetItemData(IFWL_Widget* pWidget, FWL_HLISTITEM hItem) = 0; + virtual void* GetItemData(IFWL_Widget* pWidget, IFWL_ListItem* pItem) = 0; virtual FWL_Error SetItemStyles(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, uint32_t dwStyle) = 0; virtual FWL_Error SetItemText(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, const FX_WCHAR* pszText) = 0; virtual FWL_Error SetItemRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, const CFX_RectF& rtItem) = 0; virtual FX_FLOAT GetItemHeight(IFWL_Widget* pWidget) = 0; virtual CFX_DIBitmap* GetItemIcon(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) = 0; + IFWL_ListItem* pItem) = 0; virtual FWL_Error GetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, CFX_RectF& rtCheck) = 0; virtual FWL_Error SetItemCheckRect(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, const CFX_RectF& rtCheck) = 0; virtual uint32_t GetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem) = 0; + IFWL_ListItem* pItem) = 0; virtual FWL_Error SetItemCheckState(IFWL_Widget* pWidget, - FWL_HLISTITEM hItem, + IFWL_ListItem* pItem, uint32_t dwCheckState) = 0; }; class IFWL_ListBoxCompare { public: virtual ~IFWL_ListBoxCompare() {} - virtual int32_t Compare(FWL_HLISTITEM hLeft, FWL_HLISTITEM hRight) = 0; + virtual int32_t Compare(IFWL_ListItem* hLeft, IFWL_ListItem* hRight) = 0; }; class IFWL_ListBox : public IFWL_Widget { @@ -100,10 +101,10 @@ class IFWL_ListBox : public IFWL_Widget { IFWL_Widget* pOuter); 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); protected: 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(); diff --git a/xfa/fxfa/app/xfa_ffchoicelist.cpp b/xfa/fxfa/app/xfa_ffchoicelist.cpp index 21f96eeb79..51d693fa35 100644 --- a/xfa/fxfa/app/xfa_ffchoicelist.cpp +++ b/xfa/fxfa/app/xfa_ffchoicelist.cpp @@ -56,7 +56,7 @@ FX_BOOL CXFA_FFListBox::LoadWidget() { m_pDataAcc->GetSelectedItems(iSelArray); int32_t iSelCount = iSelArray.GetSize(); for (int32_t j = 0; j < iSelCount; j++) { - FWL_HLISTITEM item = pListBox->GetItem(iSelArray[j]); + IFWL_ListItem* item = pListBox->GetItem(iSelArray[j]); pListBox->SetSelItem(item, TRUE); } m_pNormalWidget->UnlockUpdate(); @@ -90,7 +90,7 @@ FX_BOOL CXFA_FFListBox::IsDataChanged() { return TRUE; for (int32_t i = 0; i < iSels; ++i) { - FWL_HLISTITEM hlistItem = pListBox->GetItem(iSelArray[i]); + IFWL_ListItem* hlistItem = pListBox->GetItem(iSelArray[i]); if (!(pListBox->GetItemStates(hlistItem) && FWL_ITEMSTATE_LTB_Selected)) return TRUE; } @@ -126,12 +126,12 @@ FX_BOOL CXFA_FFListBox::UpdateFWLData() { return FALSE; } CFWL_ListBox* pListBox = ((CFWL_ListBox*)m_pNormalWidget); - CFX_ArrayTemplate<FWL_HLISTITEM> selItemArray; + CFX_ArrayTemplate<IFWL_ListItem*> selItemArray; CFX_Int32Array iSelArray; m_pDataAcc->GetSelectedItems(iSelArray); int32_t iSelCount = iSelArray.GetSize(); for (int32_t j = 0; j < iSelCount; j++) { - FWL_HLISTITEM lpItemSel = pListBox->GetSelItem(iSelArray[j]); + IFWL_ListItem* lpItemSel = pListBox->GetSelItem(iSelArray[j]); selItemArray.Add(lpItemSel); } pListBox->SetSelItem(pListBox->GetSelItem(-1), FALSE); @@ -155,7 +155,7 @@ void CXFA_FFListBox::OnSelectChanged(IFWL_Widget* pWidget, m_pDataAcc->ProcessEvent(XFA_ATTRIBUTEENUM_Change, &eParam); } void CXFA_FFListBox::SetItemState(int32_t nIndex, FX_BOOL bSelected) { - FWL_HLISTITEM item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); + IFWL_ListItem* item = ((CFWL_ListBox*)m_pNormalWidget)->GetSelItem(nIndex); ((CFWL_ListBox*)m_pNormalWidget)->SetSelItem(item, bSelected); m_pNormalWidget->Update(); AddInvalidateRect(); |