]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listctrl/listtest.cpp
after a seek, reset error if error==EOF
[wxWidgets.git] / samples / listctrl / listtest.cpp
index 9b8e279c4ce45286c242fbdcaf1e3ea4c33246a6..f8a8a18f3ac574bd90dd67d09d167a5e25386f39 100644 (file)
@@ -60,6 +60,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_COL_CLICK(LIST_CTRL, MyListCtrl::OnColClick)
 END_EVENT_TABLE()
 
 IMPLEMENT_APP(MyApp)
@@ -146,7 +147,7 @@ bool MyApp::OnInit(void)
 
   // Make a panel with a message
   frame->m_listCtrl = new MyListCtrl(frame, LIST_CTRL, wxPoint(0, 0), wxSize(400, 200),
-          wxLC_LIST|wxSUNKEN_BORDER|wxLC_EDIT_LABELS);
+          wxLC_LIST|wxSUNKEN_BORDER|wxLC_EDIT_LABELS );
 //          wxLC_LIST|wxLC_USER_TEXT|wxSUNKEN_BORDER); // wxLC_USER_TEXT requires app to supply all text on demand
   frame->m_logWindow = new wxTextCtrl(frame, -1, "", wxPoint(0, 0), wxSize(400, 200), wxTE_MULTILINE|wxSUNKEN_BORDER);
 
@@ -353,6 +354,20 @@ void MyFrame::OnDeleteAll(wxCommandEvent& WXUNUSED(event))
 
 // MyListCtrl
 
+void MyListCtrl::OnColClick(wxListEvent& event)
+{
+    if ( !wxGetApp().GetTopWindow() )
+        return;
+
+    wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow;
+    if ( !text )
+        return;
+
+    wxString msg;
+    msg.Printf( "OnColumnClick at %d.\n", event.GetColumn() );
+    text->WriteText(msg);
+}
+
 void MyListCtrl::OnBeginDrag(wxListEvent& event)
 {
     if ( !wxGetApp().GetTopWindow() )
@@ -406,10 +421,7 @@ void MyListCtrl::OnEndLabelEdit(wxListEvent& event)
 
     text->WriteText("OnEndLabelEdit: ");
     text->WriteText(event.m_item.m_text);
-    if (event.m_cancelled)
-        text->WriteText(" cancelled by user\n");
-    else
-        text->WriteText(" accepted by user\n");
+    text->WriteText("\n");
 }
 
 void MyListCtrl::OnDeleteItem(wxListEvent& WXUNUSED(event))
@@ -470,7 +482,7 @@ void MyListCtrl::OnSetInfo(wxListEvent& WXUNUSED(event))
     text->WriteText("OnSetInfo\n");
 }
 
-void MyListCtrl::OnSelected(wxListEvent& WXUNUSED(event))
+void MyListCtrl::OnSelected(wxListEvent& event)
 {
     if ( !wxGetApp().GetTopWindow() )
         return;
@@ -479,6 +491,20 @@ void MyListCtrl::OnSelected(wxListEvent& WXUNUSED(event))
     if ( !text )
         return;
 
+    wxListItem info;
+    info.m_itemId = event.m_itemIndex;
+    info.m_col = 1;
+    info.m_mask = wxLIST_MASK_TEXT;
+    if ( GetItem(info) )
+    {
+        *text << "Value of the 2nd field of the selected item: "
+              << info.m_text << '\n';
+    }
+    else
+    {
+        wxFAIL_MSG("wxListCtrl::GetItem() failed");
+    }
+
     text->WriteText("OnSelected\n");
 }