]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listctrl/listtest.cpp
don't try to remove -g flag from CFLAGS, it is not necessary and doesn't work correct...
[wxWidgets.git] / samples / listctrl / listtest.cpp
index 2de2923e3283253a39a5b09988e14a2c4fecf481..7b196adf035514b9df1732ab6aac2547d65206c3 100644 (file)
@@ -631,7 +631,10 @@ void MyListCtrl::OnColClick(wxListEvent& event)
 void MyListCtrl::OnColRightClick(wxListEvent& event)
 {
     int col = event.GetColumn();
-    SetColumnImage(col, -1);
+    if ( col != -1 )
+    {
+        SetColumnImage(col, -1);
+    }
 
     wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() );
 }
@@ -760,7 +763,8 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
 {
     switch ( event.GetCode() )
     {
-        case 'c':
+        case 'c': // colorize
+        case 'C':
             {
                 wxListItem info;
                 info.m_itemId = event.GetIndex();
@@ -772,10 +776,29 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
                     info.SetTextColour(*wxCYAN);
 
                     SetItem(info);
+
+                    RefreshItem(info.m_itemId);
                 }
             }
             break;
 
+        case 'n': // next
+        case 'N':
+            {
+                long item = GetNextItem(-1,
+                                        wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
+                if ( item++ == GetItemCount() - 1 )
+                {
+                    item = 0;
+                }
+
+                wxLogMessage(_T("Focusing item %ld"), item);
+
+                SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
+                EnsureVisible(item);
+            }
+            break;
+
         case WXK_DELETE:
             {
                 long item = GetNextItem(-1,
@@ -818,7 +841,18 @@ void MyListCtrl::OnChar(wxKeyEvent& event)
 {
     wxLogMessage(_T("Got char event."));
 
-    event.Skip();
+    switch ( event.GetKeyCode() )
+    {
+        case 'n':
+        case 'N':
+        case 'c':
+        case 'C':
+            // these are the keys we process ourselves
+            break;
+
+        default:
+            event.Skip();
+    }
 }
 
 void MyListCtrl::LogEvent(const wxListEvent& event, const wxChar *eventName)