]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listctrl/listtest.cpp
some kbd handling fixes (some problems still persist)
[wxWidgets.git] / samples / listctrl / listtest.cpp
index c14a3ad5d5c774969e1dd70217c0658a6a94ee35..8f17b941d904892a25fefc2f521dee38b439155c 100644 (file)
 #include "wx/wx.h"
 #endif
 
 #include "wx/wx.h"
 #endif
 
+#ifndef __WXMSW__
+#include "mondrian.xpm"
+#endif
+
 #include "wx/listctrl.h"
 #include "listtest.h"
 
 #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_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)
 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.
   // 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
 
   // 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);
 
   // Make an image list containing large icons
   m_imageListNormal = new wxImageList(32, 32, TRUE);
@@ -325,12 +325,7 @@ void MyListCtrl::OnBeginDrag(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnBeginDrag\n";
-       str.flush();
-#endif
+        text->WriteText("OnBeginDrag\n");
 }
 
 void MyListCtrl::OnBeginRDrag(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnBeginRDrag(wxListEvent& WXUNUSED(event))
@@ -341,12 +336,7 @@ void MyListCtrl::OnBeginRDrag(wxListEvent& WXUNUSED(event))
        wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow;
        if ( !text )
                return;
        wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow;
        if ( !text )
                return;
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnBeginRDrag\n";
-       str.flush();
-#endif
+        text->WriteText("OnBeginRDrag\n");
 }
 
 void MyListCtrl::OnBeginLabelEdit(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnBeginLabelEdit(wxListEvent& WXUNUSED(event))
@@ -358,12 +348,7 @@ void MyListCtrl::OnBeginLabelEdit(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnBeginLabelEdit\n";
-       str.flush();
-#endif
+        text->WriteText("OnBeginLabelEdit\n");
 }
 
 void MyListCtrl::OnEndLabelEdit(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnEndLabelEdit(wxListEvent& WXUNUSED(event))
@@ -375,12 +360,7 @@ void MyListCtrl::OnEndLabelEdit(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnEndLabelEdit\n";
-       str.flush();
-#endif
+        text->WriteText("OnEndLabelEdit\n");
 }
 
 void MyListCtrl::OnDeleteItem(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnDeleteItem(wxListEvent& WXUNUSED(event))
@@ -392,15 +372,10 @@ void MyListCtrl::OnDeleteItem(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnDeleteItem\n";
-       str.flush();
-#endif
+        text->WriteText("OnDeleteItem\n");
 }
 
 }
 
-void MyListCtrl::OnGetInfo(wxListEvent& event)
+void MyListCtrl::OnGetInfo(wxListEvent& /*event*/)
 {
        if ( !wxGetApp().GetTopWindow() )
                return;
 {
        if ( !wxGetApp().GetTopWindow() )
                return;
@@ -409,7 +384,9 @@ void MyListCtrl::OnGetInfo(wxListEvent& event)
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
+        text->WriteText("OnGetInfo\n");
+
+/*
        ostream str(text);
 
        str << "OnGetInfo (" << event.m_item.m_itemId << ", " << event.m_item.m_col << ")";
        ostream str(text);
 
        str << "OnGetInfo (" << event.m_item.m_itemId << ", " << event.m_item.m_col << ")";
@@ -434,7 +411,7 @@ void MyListCtrl::OnGetInfo(wxListEvent& event)
        }
        str << "\n";
        str.flush();
        }
        str << "\n";
        str.flush();
-#endif
+*/
 }
 
 void MyListCtrl::OnSetInfo(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnSetInfo(wxListEvent& WXUNUSED(event))
@@ -446,12 +423,7 @@ void MyListCtrl::OnSetInfo(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnSetInfo\n";
-       str.flush();
-#endif
+       text->WriteText("OnSetInfo\n");
 }
 
 void MyListCtrl::OnSelected(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnSelected(wxListEvent& WXUNUSED(event))
@@ -463,12 +435,7 @@ void MyListCtrl::OnSelected(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnSelected\n";
-       str.flush();
-#endif
+       text->WriteText("OnSelected\n");
 }
 
 void MyListCtrl::OnDeselected(wxListEvent& WXUNUSED(event))
 }
 
 void MyListCtrl::OnDeselected(wxListEvent& WXUNUSED(event))
@@ -480,15 +447,10 @@ void MyListCtrl::OnDeselected(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
-
-       str << "OnDeselected\n";
-       str.flush();
-#endif
+       text->WriteText("OnDeselected\n");
 }
 
 }
 
-void MyListCtrl::OnKeyDown(wxListEvent& WXUNUSED(event))
+void MyListCtrl::OnActivated(wxListEvent& WXUNUSED(event))
 {
        if ( !wxGetApp().GetTopWindow() )
                return;
 {
        if ( !wxGetApp().GetTopWindow() )
                return;
@@ -497,11 +459,19 @@ void MyListCtrl::OnKeyDown(wxListEvent& WXUNUSED(event))
        if ( !text )
                return;
 
        if ( !text )
                return;
 
-#ifndef __GNUWIN32__
-       ostream str(text);
+       text->WriteText("OnActivated\n");
+}
 
 
-       str << "OnKeyDown\n";
-       str.flush();
-#endif
+void MyListCtrl::OnListKeyDown(wxListEvent& WXUNUSED(event))
+{
+       if ( !wxGetApp().GetTopWindow() )
+               return;
+
+       wxTextCtrl *text = ((MyFrame *)wxGetApp().GetTopWindow())->m_logWindow;
+       if ( !text )
+               return;
+
+       text->WriteText("OnListKeyDown\n");
 }
 
 }
 
+