]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listctrl/listtest.cpp
fixed mouse input handling in wxUniv: the static boxes ust be transparent
[wxWidgets.git] / samples / listctrl / listtest.cpp
index 9796a033b7de101a4fd2cbf20831cb684b71dd74..c1fd9dc512a859a5ef59b6ad80fc71a6bd775144 100644 (file)
@@ -92,6 +92,7 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
     EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
     EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
     EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
     EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
     EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
     EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
+    EVT_LIST_ITEM_FOCUSED(LIST_CTRL, MyListCtrl::OnFocused)
 
     EVT_LIST_COL_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
     EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL, MyListCtrl::OnColRightClick)
 
     EVT_LIST_COL_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
     EVT_LIST_COL_RIGHT_CLICK(LIST_CTRL, MyListCtrl::OnColRightClick)
@@ -750,11 +751,17 @@ void MyListCtrl::OnActivated(wxListEvent& event)
     LogEvent(event, _T("OnActivated"));
 }
 
     LogEvent(event, _T("OnActivated"));
 }
 
+void MyListCtrl::OnFocused(wxListEvent& event)
+{
+    LogEvent(event, _T("OnFocused"));
+}
+
 void MyListCtrl::OnListKeyDown(wxListEvent& event)
 {
     switch ( event.GetCode() )
     {
 void MyListCtrl::OnListKeyDown(wxListEvent& event)
 {
     switch ( event.GetCode() )
     {
-        case 'c':
+        case 'c': // colorize
+        case 'C':
             {
                 wxListItem info;
                 info.m_itemId = event.GetIndex();
             {
                 wxListItem info;
                 info.m_itemId = event.GetIndex();
@@ -766,7 +773,26 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
                     info.SetTextColour(*wxCYAN);
 
                     SetItem(info);
                     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;
 
             }
             break;
 
@@ -812,7 +838,18 @@ void MyListCtrl::OnChar(wxKeyEvent& event)
 {
     wxLogMessage(_T("Got char 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)
 }
 
 void MyListCtrl::LogEvent(const wxListEvent& event, const wxChar *eventName)