added GetItemRect() test

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@34803 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2005-07-02 22:14:52 +00:00
parent e6d5afb5b9
commit 100f649f94

View File

@@ -884,6 +884,8 @@ void MyListCtrl::OnFocused(wxListEvent& event)
void MyListCtrl::OnListKeyDown(wxListEvent& event) void MyListCtrl::OnListKeyDown(wxListEvent& event)
{ {
long item;
switch ( event.GetKeyCode() ) switch ( event.GetKeyCode() )
{ {
case 'c': // colorize case 'c': // colorize
@@ -907,35 +909,45 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
case 'n': // next case 'n': // next
case 'N': case 'N':
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
if ( item++ == GetItemCount() - 1 )
{ {
long item = GetNextItem(-1, item = 0;
wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED); }
if ( item++ == GetItemCount() - 1 )
wxLogMessage(_T("Focusing item %ld"), item);
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
EnsureVisible(item);
break;
case 'r': // show bounding Rect
case 'R':
{
item = event.GetIndex();
wxRect r;
if ( !GetItemRect(item, r) )
{ {
item = 0; wxLogError(_T("Failed to retrieve rect of item %ld"), item);
break;
} }
wxLogMessage(_T("Focusing item %ld"), item); wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
item, r.x, r.y, r.x + r.width, r.y + r.height);
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
EnsureVisible(item);
} }
break; break;
case WXK_DELETE: case WXK_DELETE:
item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while ( item != -1 )
{ {
long item = GetNextItem(-1, DeleteItem(item);
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while ( item != -1 )
{
DeleteItem(item);
wxLogMessage(_T("Item %ld deleted"), item); wxLogMessage(_T("Item %ld deleted"), item);
// -1 because the indices were shifted by DeleteItem() // -1 because the indices were shifted by DeleteItem()
item = GetNextItem(item - 1, item = GetNextItem(item - 1,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
}
} }
break; break;