Respect wxListItem::m_mask in general list control Set/GetItem() and allow
them to be used to change/query the item selection and focus status (second part of patch 1264533 from Ryan, modified to be backwards compatible) git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@35462 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -674,6 +674,7 @@ public:
|
|||||||
wxString GetItemText(long item) const
|
wxString GetItemText(long item) const
|
||||||
{
|
{
|
||||||
wxListItem info;
|
wxListItem info;
|
||||||
|
info.m_mask = wxLIST_MASK_TEXT;
|
||||||
info.m_itemId = item;
|
info.m_itemId = item;
|
||||||
GetItem( info );
|
GetItem( info );
|
||||||
return info.m_text;
|
return info.m_text;
|
||||||
@@ -997,8 +998,18 @@ int wxListItemData::GetHeight() const
|
|||||||
|
|
||||||
void wxListItemData::GetItem( wxListItem &info ) const
|
void wxListItemData::GetItem( wxListItem &info ) const
|
||||||
{
|
{
|
||||||
|
long mask = info.m_mask;
|
||||||
|
if ( !mask )
|
||||||
|
{
|
||||||
|
// by default, get everything for backwards compatibility
|
||||||
|
mask = -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( mask & wxLIST_MASK_TEXT )
|
||||||
info.m_text = m_text;
|
info.m_text = m_text;
|
||||||
|
if ( mask & wxLIST_MASK_IMAGE )
|
||||||
info.m_image = m_image;
|
info.m_image = m_image;
|
||||||
|
if ( mask & wxLIST_MASK_DATA )
|
||||||
info.m_data = m_data;
|
info.m_data = m_data;
|
||||||
|
|
||||||
if ( m_attr )
|
if ( m_attr )
|
||||||
@@ -3648,6 +3659,10 @@ void wxListMainWindow::SetItem( wxListItem &item )
|
|||||||
wxListLineData *line = GetLine((size_t)id);
|
wxListLineData *line = GetLine((size_t)id);
|
||||||
line->SetItem( item.m_col, item );
|
line->SetItem( item.m_col, item );
|
||||||
|
|
||||||
|
// Set item state if user wants
|
||||||
|
if ( item.m_mask & wxLIST_MASK_STATE )
|
||||||
|
SetItemState( item.m_itemId, item.m_state, item.m_state );
|
||||||
|
|
||||||
if (InReportView())
|
if (InReportView())
|
||||||
{
|
{
|
||||||
// update the Max Width Cache if needed
|
// update the Max Width Cache if needed
|
||||||
@@ -3831,6 +3846,11 @@ void wxListMainWindow::GetItem( wxListItem &item ) const
|
|||||||
|
|
||||||
wxListLineData *line = GetLine((size_t)item.m_itemId);
|
wxListLineData *line = GetLine((size_t)item.m_itemId);
|
||||||
line->GetItem( item.m_col, item );
|
line->GetItem( item.m_col, item );
|
||||||
|
|
||||||
|
// Get item state if user wants it
|
||||||
|
if ( item.m_mask & wxLIST_MASK_STATE )
|
||||||
|
item.m_state = GetItemState( item.m_itemId, wxLIST_STATE_SELECTED |
|
||||||
|
wxLIST_STATE_FOCUSED );
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
@@ -4996,6 +5016,7 @@ void wxGenericListCtrl::SetItemText( long item, const wxString& str )
|
|||||||
wxUIntPtr wxGenericListCtrl::GetItemData( long item ) const
|
wxUIntPtr wxGenericListCtrl::GetItemData( long item ) const
|
||||||
{
|
{
|
||||||
wxListItem info;
|
wxListItem info;
|
||||||
|
info.m_mask = wxLIST_MASK_DATA;
|
||||||
info.m_itemId = item;
|
info.m_itemId = item;
|
||||||
m_mainWin->GetItem( info );
|
m_mainWin->GetItem( info );
|
||||||
return info.m_data;
|
return info.m_data;
|
||||||
|
Reference in New Issue
Block a user