switch ( event.GetKeyCode() )
{
- case 'c': // colorize
- case 'C':
+ case 'C': // colorize
{
wxListItem info;
info.m_itemId = event.GetIndex();
}
break;
- case 'n': // next
- case 'N':
+ case 'N': // next
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
if ( item++ == GetItemCount() - 1 )
{
EnsureVisible(item);
break;
- case 'r': // show bounding Rect
- case 'R':
+ case 'R': // show bounding rectangle
{
item = event.GetIndex();
wxRect r;
}
break;
+ case 'U': // update
+ if ( !IsVirtual() )
+ break;
+
+ if ( m_updated != -1 )
+ RefreshItem(m_updated);
+
+ m_updated = event.GetIndex();
+ if ( m_updated != -1 )
+ {
+ // we won't see changes to this item as it's selected, update
+ // the next one (or the first one if we're on the last item)
+ if ( ++m_updated == GetItemCount() )
+ m_updated = 0;
+
+ wxLogMessage("Updating colour of the item %ld", m_updated);
+ RefreshItem(m_updated);
+ }
+ break;
+
case WXK_DELETE:
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while ( item != -1 )
case 'N':
case 'c':
case 'C':
+ case 'r':
+ case 'R':
+ case 'u':
+ case 'U':
+ case WXK_DELETE:
+ case WXK_INSERT:
// these are the keys we process ourselves
break;
{
return SMALL_VIRTUAL_VIEW_ITEMS[item][column];
}
- else
+ else // "big" virtual control
{
return wxString::Format(_T("Column %ld of item %ld"), column, item);
}
if (!column)
return 0;
- if (!(item %3) && column == 1)
+ if (!(item % 3) && column == 1)
return 0;
return -1;
wxListItemAttr *MyListCtrl::OnGetItemAttr(long item) const
{
+ // test to check that RefreshItem() works correctly: when m_updated is
+ // set to some item and it is refreshed, we highlight the item
+ if ( item == m_updated )
+ {
+ static wxListItemAttr s_attrHighlight(*wxRED, wxNullColour, wxNullFont);
+ return &s_attrHighlight;
+ }
+
return item % 2 ? NULL : (wxListItemAttr *)&m_attr;
}
: wxListCtrl(parent, id, pos, size, style),
m_attr(*wxBLUE, *wxLIGHT_GREY, wxNullFont)
{
+ m_updated = -1;
+
#ifdef __POCKETPC__
EnableContextMenu();
#endif
wxListItemAttr m_attr;
+ long m_updated;
+
+
DECLARE_NO_COPY_CLASS(MyListCtrl)
DECLARE_EVENT_TABLE()
};
void wxListCtrl::RefreshItem(long item)
{
- // strangely enough, ListView_Update() results in much more flicker here
- // than a dumb Refresh() -- why?
-#if 0
- if ( !ListView_Update(GetHwnd(), item) )
- {
- wxLogLastError(_T("ListView_Update"));
- }
-#else // 1
- wxRect rect;
- GetItemRect(item, rect);
- RefreshRect(rect);
-#endif // 0/1
+ RefreshItems(item, item);
}
void wxListCtrl::RefreshItems(long itemFrom, long itemTo)
{
- wxRect rect1, rect2;
- GetItemRect(itemFrom, rect1);
- GetItemRect(itemTo, rect2);
-
- wxRect rect = rect1;
- rect.height = rect2.GetBottom() - rect1.GetTop();
-
- RefreshRect(rect);
+ ListView_RedrawItems(GetHwnd(), itemFrom, itemTo);
}
// ----------------------------------------------------------------------------