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,9 +909,7 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
case 'n': // next case 'n': // next
case 'N': case 'N':
{ item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
long item = GetNextItem(-1,
wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
if ( item++ == GetItemCount() - 1 ) if ( item++ == GetItemCount() - 1 )
{ {
item = 0; item = 0;
@@ -919,13 +919,26 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED); SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
EnsureVisible(item); EnsureVisible(item);
break;
case 'r': // show bounding Rect
case 'R':
{
item = event.GetIndex();
wxRect r;
if ( !GetItemRect(item, r) )
{
wxLogError(_T("Failed to retrieve rect of item %ld"), item);
break;
}
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);
} }
break; break;
case WXK_DELETE: case WXK_DELETE:
{ item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
long item = GetNextItem(-1,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
while ( item != -1 ) while ( item != -1 )
{ {
DeleteItem(item); DeleteItem(item);
@@ -936,7 +949,6 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
item = GetNextItem(item - 1, item = GetNextItem(item - 1,
wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED); wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
} }
}
break; break;
case WXK_INSERT: case WXK_INSERT: