]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listctrl/listtest.cpp
a bit of debug code
[wxWidgets.git] / samples / listctrl / listtest.cpp
index 47b336f58af65fa8b0d135268f9bfc9ecfe1e5f5..d5578d2bee412875f946d14636accc8f7da80375 100644 (file)
 #include "wx/wx.h"
 #endif
 
+#ifndef __WXMSW__
+#include "mondrian.xpm"
+#endif
+
 #include "wx/listctrl.h"
 #include "listtest.h"
 
@@ -51,7 +55,8 @@ BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
        EVT_LIST_SET_INFO(LIST_CTRL, MyListCtrl::OnSetInfo)
        EVT_LIST_ITEM_SELECTED(LIST_CTRL, MyListCtrl::OnSelected)
        EVT_LIST_ITEM_DESELECTED(LIST_CTRL, MyListCtrl::OnDeselected)
-       EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnKeyDown)
+       EVT_LIST_KEY_DOWN(LIST_CTRL, MyListCtrl::OnListKeyDown)
+       EVT_LIST_ITEM_ACTIVATED(LIST_CTRL, MyListCtrl::OnActivated)
 END_EVENT_TABLE()
 
 IMPLEMENT_APP(MyApp)
@@ -65,15 +70,10 @@ bool MyApp::OnInit(void)
   // This reduces flicker effects - even better would be to define OnEraseBackground
   // to do nothing. When the list control's scrollbars are show or hidden, the
   // frame is sent a background erase event.
-  frame->SetBackgroundColour(wxColour(255, 255, 255));
+  frame->SetBackgroundColour( *wxWHITE );
 
   // Give it an icon
-#ifdef __WXMSW__
-  frame->SetIcon(wxIcon("mondrian"));
-#else
-#include "mondrian.xpm"
-  frame->SetIcon(wxIcon(mondrian_xpm));
-#endif
+  frame->SetIcon( wxICON(mondrian) );
 
   // Make an image list containing large icons
   m_imageListNormal = new wxImageList(32, 32, TRUE);
@@ -220,8 +220,8 @@ void MyFrame::OnSelectAll(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event))
 {
-       m_logWindow->Clear();
        m_listCtrl->DeleteAllItems();
+       m_logWindow->Clear();
        m_listCtrl->SetSingleStyle(wxLC_LIST);
     m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_NORMAL);
     m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_SMALL);
@@ -236,8 +236,8 @@ void MyFrame::OnListView(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
 {
-       m_logWindow->Clear();
        m_listCtrl->DeleteAllItems();
+       m_logWindow->Clear();
        m_listCtrl->SetSingleStyle(wxLC_REPORT);
     m_listCtrl->SetImageList((wxImageList *) NULL, wxIMAGE_LIST_NORMAL);
     m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL);
@@ -258,8 +258,8 @@ void MyFrame::OnReportView(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnIconView(wxCommandEvent& WXUNUSED(event))
 {
-       m_logWindow->Clear();
        m_listCtrl->DeleteAllItems();
+       m_logWindow->Clear();
        m_listCtrl->SetSingleStyle(wxLC_ICON);
     m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL);
     m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL);
@@ -272,8 +272,8 @@ void MyFrame::OnIconView(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnIconTextView(wxCommandEvent& WXUNUSED(event))
 {
-       m_logWindow->Clear();
        m_listCtrl->DeleteAllItems();
+       m_logWindow->Clear();
        m_listCtrl->SetSingleStyle(wxLC_ICON);
     m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL);
     m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL);
@@ -288,8 +288,8 @@ void MyFrame::OnIconTextView(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnSmallIconView(wxCommandEvent& WXUNUSED(event))
 {
-       m_logWindow->Clear();
        m_listCtrl->DeleteAllItems();
+       m_logWindow->Clear();
        m_listCtrl->SetSingleStyle(wxLC_SMALL_ICON);
     m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL);
     m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL);
@@ -302,8 +302,8 @@ void MyFrame::OnSmallIconView(wxCommandEvent& WXUNUSED(event))
 
 void MyFrame::OnSmallIconTextView(wxCommandEvent& WXUNUSED(event))
 {
-       m_logWindow->Clear();
        m_listCtrl->DeleteAllItems();
+       m_logWindow->Clear();
        m_listCtrl->SetSingleStyle(wxLC_SMALL_ICON);
     m_listCtrl->SetImageList(wxGetApp().m_imageListNormal, wxIMAGE_LIST_NORMAL);
     m_listCtrl->SetImageList(wxGetApp().m_imageListSmall, wxIMAGE_LIST_SMALL);
@@ -375,7 +375,7 @@ void MyListCtrl::OnDeleteItem(wxListEvent& WXUNUSED(event))
         text->WriteText("OnDeleteItem\n");
 }
 
-void MyListCtrl::OnGetInfo(wxListEvent& event)
+void MyListCtrl::OnGetInfo(wxListEvent& /*event*/)
 {
        if ( !wxGetApp().GetTopWindow() )
                return;
@@ -450,7 +450,7 @@ void MyListCtrl::OnDeselected(wxListEvent& WXUNUSED(event))
        text->WriteText("OnDeselected\n");
 }
 
-void MyListCtrl::OnKeyDown(wxListEvent& WXUNUSED(event))
+void MyListCtrl::OnActivated(wxListEvent& WXUNUSED(event))
 {
        if ( !wxGetApp().GetTopWindow() )
                return;
@@ -459,6 +459,19 @@ void MyListCtrl::OnKeyDown(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
-       text->WriteText("OnKeyDown\n");
+       text->WriteText("OnActivated\n");
 }
 
+void MyListCtrl::OnListKeyDown(wxListEvent& WXUNUSED(event))
+{
+       if ( !wxGetApp().GetTopWindow() )
+               return;
+
+       wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow;
+       if ( !text )
+               return;
+
+       text->WriteText("OnListKeyDown\n");
+}
+
+