wxGenericListCtrl::SetItemState(-1) now changes the state of all items (patch 1101650)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@32195 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -72,6 +72,8 @@ All (GUI):
|
|||||||
- wxProgressDialog accepts smooth gauge again (wxPD_SMOOTH style)
|
- wxProgressDialog accepts smooth gauge again (wxPD_SMOOTH style)
|
||||||
- wxProgressDialog new style: wxPD_CAN_SKIP which provides skipping some parts
|
- wxProgressDialog new style: wxPD_CAN_SKIP which provides skipping some parts
|
||||||
of the progress (with new "Skip" button in dialog)
|
of the progress (with new "Skip" button in dialog)
|
||||||
|
- wxGenericListCtrl::SetItemState(-1) now changes the state of all items as
|
||||||
|
in wxMSW version (Gunnar Roth)
|
||||||
|
|
||||||
Unix:
|
Unix:
|
||||||
|
|
||||||
|
@@ -644,6 +644,7 @@ public:
|
|||||||
void SetItem( wxListItem &item );
|
void SetItem( wxListItem &item );
|
||||||
void GetItem( wxListItem &item ) const;
|
void GetItem( wxListItem &item ) const;
|
||||||
void SetItemState( long item, long state, long stateMask );
|
void SetItemState( long item, long state, long stateMask );
|
||||||
|
void SetItemStateAll( long state, long stateMask );
|
||||||
int GetItemState( long item, long stateMask ) const;
|
int GetItemState( long item, long stateMask ) const;
|
||||||
void GetItemRect( long index, wxRect &rect ) const;
|
void GetItemRect( long index, wxRect &rect ) const;
|
||||||
wxRect GetViewRect() const;
|
wxRect GetViewRect() const;
|
||||||
@@ -3635,8 +3636,58 @@ void wxListMainWindow::SetItem( wxListItem &item )
|
|||||||
RefreshRect(rectItem);
|
RefreshRect(rectItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void wxListMainWindow::SetItemStateAll(long state, long stateMask)
|
||||||
|
{
|
||||||
|
if ( IsEmpty() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
// first deal with selection
|
||||||
|
if ( stateMask & wxLIST_STATE_SELECTED )
|
||||||
|
{
|
||||||
|
// set/clear select state
|
||||||
|
if ( IsVirtual() )
|
||||||
|
{
|
||||||
|
// optimized version for virtual listctrl.
|
||||||
|
m_selStore.SelectRange(0, GetItemCount() - 1, state == wxLIST_STATE_SELECTED);
|
||||||
|
Refresh();
|
||||||
|
}
|
||||||
|
else if ( state & wxLIST_STATE_SELECTED )
|
||||||
|
{
|
||||||
|
const long count = GetItemCount();
|
||||||
|
for( long i = 0; i < count; i++ )
|
||||||
|
{
|
||||||
|
SetItemState( i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED );
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// clear for non virtual (somewhat optimized by using GetNextItem())
|
||||||
|
long i = -1;
|
||||||
|
while ( (i = GetNextItem(i, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED)) != -1 )
|
||||||
|
{
|
||||||
|
SetItemState( i, 0, wxLIST_STATE_SELECTED );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( HasCurrent() && (state == 0) && (stateMask & wxLIST_STATE_FOCUSED) )
|
||||||
|
{
|
||||||
|
// unfocus all: only one item can be focussed, so clearing focus for
|
||||||
|
// all items is simply clearing focus of the focussed item.
|
||||||
|
SetItemState(m_current, state, stateMask);
|
||||||
|
}
|
||||||
|
//(setting focus to all items makes no sense, so it is not handled here.)
|
||||||
|
}
|
||||||
|
|
||||||
void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
|
void wxListMainWindow::SetItemState( long litem, long state, long stateMask )
|
||||||
{
|
{
|
||||||
|
if ( litem == -1 )
|
||||||
|
{
|
||||||
|
SetItemStateAll(state, stateMask);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(),
|
wxCHECK_RET( litem >= 0 && (size_t)litem < GetItemCount(),
|
||||||
_T("invalid list ctrl item index in SetItem") );
|
_T("invalid list ctrl item index in SetItem") );
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user