]> git.saurik.com Git - wxWidgets.git/blobdiff - samples/listctrl/listtest.cpp
moving libiconv and libz into linker flags, as Xcode resolves the links otherwise...
[wxWidgets.git] / samples / listctrl / listtest.cpp
index 19469c2655691b3e8d6c2ba0f61fcc654cfe9b39..bfef9f62abef47db72fbc67e6b1c6d5c07f77500 100644 (file)
 #include "wx/wx.h"
 #endif
 
-#ifndef __WXMSW__
+#if !defined(__WXMSW__) && !defined(__WXPM__)
     #include "mondrian.xpm"
+#endif
 
+#ifndef __WXMSW__
     #include "bitmaps/toolbrai.xpm"
     #include "bitmaps/toolchar.xpm"
     #include "bitmaps/tooldata.xpm"
@@ -95,7 +97,7 @@ BEGIN_EVENT_TABLE(MyFrame, wxFrame)
     EVT_MENU(LIST_TOGGLE_LINES, MyFrame::OnToggleLines)
 
     EVT_UPDATE_UI(LIST_SHOW_COL_INFO, MyFrame::OnUpdateShowColInfo)
-    EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)    
+    EVT_UPDATE_UI(LIST_TOGGLE_MULTI_SEL, MyFrame::OnUpdateToggleMultiSel)
 END_EVENT_TABLE()
 
 BEGIN_EVENT_TABLE(MyListCtrl, wxListCtrl)
@@ -494,6 +496,9 @@ void MyFrame::InitWithReportItems()
     m_listCtrl->SetColumnWidth( 0, wxLIST_AUTOSIZE );
     m_listCtrl->SetColumnWidth( 1, wxLIST_AUTOSIZE );
     m_listCtrl->SetColumnWidth( 2, wxLIST_AUTOSIZE );
+
+    // test SetItemFont too
+    m_listCtrl->SetItemFont(0, *wxITALIC_FONT);
 }
 
 void MyFrame::InitWithIconItems(bool withText, bool sameIcon)
@@ -717,7 +722,11 @@ void MyListCtrl::SetColumnImage(int col, int image)
 void MyListCtrl::OnColClick(wxListEvent& event)
 {
     int col = event.GetColumn();
-    SetColumnImage(col, 0);
+
+    // set or unset image
+    static bool x = false;
+    x = !x;
+    SetColumnImage(col, x ? 0 : -1);
 
     wxLogMessage( wxT("OnColumnClick at %d."), col );
 }
@@ -733,7 +742,7 @@ void MyListCtrl::OnColRightClick(wxListEvent& event)
     // Show popupmenu at position
     wxMenu menu(wxT("Test"));
     menu.Append(LIST_ABOUT, _T("&About"));
-    PopupMenu(&menu, event.GetPoint()); 
+    PopupMenu(&menu, event.GetPoint());
 
     wxLogMessage( wxT("OnColumnRightClick at %d."), event.GetColumn() );
 }
@@ -884,6 +893,8 @@ void MyListCtrl::OnFocused(wxListEvent& event)
 
 void MyListCtrl::OnListKeyDown(wxListEvent& event)
 {
+    long item;
+
     switch ( event.GetKeyCode() )
     {
         case 'c': // colorize
@@ -907,35 +918,45 @@ void MyListCtrl::OnListKeyDown(wxListEvent& event)
 
         case 'n': // next
         case 'N':
+            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 'r': // show bounding Rect
+        case 'R':
             {
-                long item = GetNextItem(-1,
-                                        wxLIST_NEXT_ALL, wxLIST_STATE_FOCUSED);
-                if ( item++ == GetItemCount() - 1 )
+                item = event.GetIndex();
+                wxRect r;
+                if ( !GetItemRect(item, r) )
                 {
-                    item = 0;
+                    wxLogError(_T("Failed to retrieve rect of item %ld"), item);
+                    break;
                 }
 
-                wxLogMessage(_T("Focusing item %ld"), item);
-
-                SetItemState(item, wxLIST_STATE_FOCUSED, wxLIST_STATE_FOCUSED);
-                EnsureVisible(item);
+                wxLogMessage(_T("Bounding rect of item %ld is (%d, %d)-(%d, %d)"),
+                             item, r.x, r.y, r.x + r.width, r.y + r.height);
             }
             break;
 
         case WXK_DELETE:
+            item = GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
+            while ( item != -1 )
             {
-                long item = GetNextItem(-1,
-                                        wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
-                while ( item != -1 )
-                {
-                    DeleteItem(item);
+                DeleteItem(item);
 
-                    wxLogMessage(_T("Item %ld deleted"), item);
+                wxLogMessage(_T("Item %ld deleted"), item);
 
-                    // -1 because the indices were shifted by DeleteItem()
-                    item = GetNextItem(item - 1,
-                                       wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
-                }
+                // -1 because the indices were shifted by DeleteItem()
+                item = GetNextItem(item - 1,
+                                   wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
             }
             break;
 
@@ -1020,4 +1041,3 @@ void MyListCtrl::InsertItemInReportView(int i)
     buf.Printf(_T("Item %d in column 2"), i);
     SetItem(i, 2, buf);
 }
-