]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
removed subprojects for ldef and cdef, changed to in-proc ldef
[wxWidgets.git] / src / generic / listctrl.cpp
index b556a2e8eb27fe50c09d56080533cb22728ca228..b4c6644be48382e2adeea25a5cf481bab209498f 100644 (file)
@@ -1879,7 +1879,7 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
 
     int numColumns = m_owner->GetColumnCount();
     wxListItem item;
-    for (int i = 0; i < numColumns; i++)
+    for ( int i = 0; i < numColumns && x < w; i++ )
     {
         m_owner->GetColumn( i, item );
         int wCol = item.m_width;
@@ -1923,11 +1923,9 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
         dc.DrawText( item.GetText(),
                      x + EXTRA_WIDTH, HEADER_OFFSET_Y + EXTRA_HEIGHT );
 
-        if ( x > w - wCol + 5 )
-            break;
-
         x += wCol;
     }
+
     dc.EndDrawing();
 }
 
@@ -2044,6 +2042,14 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
                                     : wxEVT_COMMAND_LIST_COL_RIGHT_CLICK,
                                 parent->GetId() );
                 le.SetEventObject( parent );
+                le.m_pointDrag = event.GetPosition();
+
+                // the position should be relative to the parent window, not
+                // this one for compatibility with MSW and common sense: the
+                // user code doesn't know anything at all about this header
+                // window, so why should it get positions relative to it?
+                le.m_pointDrag.y -= GetSize().y;
+
                 le.m_col = m_column;
                 parent->GetEventHandler()->ProcessEvent( le );
             }
@@ -2613,6 +2619,14 @@ void wxListMainWindow::RefreshSelected()
         to = GetItemCount() - 1;
     }
 
+    // VZ: this code would work fine if wxGTK wxWindow::Refresh() were
+    //     reasonable, i.e. if it only generated one expose event for
+    //     several calls to it - as it is, each Refresh() results in a
+    //     repaint which provokes flicker too horrible to be seen
+    //
+    //     when/if wxGTK is fixed, this code should be restored as normally it
+    //     should generate _less_ flicker than the version below
+#ifndef __WXGTK__
     if ( HasCurrent() && m_current >= from && m_current <= to )
     {
         RefreshLine(m_current);
@@ -2626,6 +2640,26 @@ void wxListMainWindow::RefreshSelected()
             RefreshLine(line);
         }
     }
+#else // __WXGTK__
+    size_t selMin = (size_t)-1,
+           selMax = 0;
+
+    for ( size_t line = from; line <= to; line++ )
+    {
+        if ( IsHighlighted(line) || (line == m_current) )
+        {
+            if ( line < selMin )
+                selMin = line;
+            if ( line > selMax )
+                selMax = line;
+        }
+    }
+
+    if ( selMin != (size_t)-1 )
+    {
+        RefreshLines(selMin, selMax);
+    }
+#endif // !__WXGTK__/__WXGTK__
 }
 
 void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
@@ -3208,7 +3242,8 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
         nevent.SetDirection( !event.ShiftDown() );
         nevent.SetEventObject( GetParent()->GetParent() );
         nevent.SetCurrentFocus( m_parent );
-        if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent )) return;
+        if (GetParent()->GetParent()->GetEventHandler()->ProcessEvent( nevent ))
+            return;
     }
 
     /* no item -> nothing to do */
@@ -3308,12 +3343,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
         case WXK_SPACE:
             if ( IsSingleSel() )
             {
-                wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
-                                GetParent()->GetId() );
-                le.SetEventObject( GetParent() );
-                le.m_itemIndex = m_current;
-                GetLine(m_current)->GetItem( 0, le.m_item );
-                GetParent()->GetEventHandler()->ProcessEvent( le );
+                SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
 
                 if ( IsHighlighted(m_current) )
                 {
@@ -3328,14 +3358,7 @@ void wxListMainWindow::OnChar( wxKeyEvent &event )
 
         case WXK_RETURN:
         case WXK_EXECUTE:
-            {
-                wxListEvent le( wxEVT_COMMAND_LIST_ITEM_ACTIVATED,
-                                GetParent()->GetId() );
-                le.SetEventObject( GetParent() );
-                le.m_itemIndex = m_current;
-                GetLine(m_current)->GetItem( 0, le.m_item );
-                GetParent()->GetEventHandler()->ProcessEvent( le );
-            }
+            SendNotify( m_current, wxEVT_COMMAND_LIST_ITEM_ACTIVATED );
             break;
 
         default:
@@ -3353,12 +3376,19 @@ extern wxWindow *g_focusWindow;
 
 void wxListMainWindow::OnSetFocus( wxFocusEvent &WXUNUSED(event) )
 {
-    m_hasFocus = TRUE;
+    // wxGTK sends us EVT_SET_FOCUS events even if we had never got
+    // EVT_KILL_FOCUS before which means that we finish by redrawing the items
+    // which are already drawn correctly resulting in horrible flicker - avoid
+    // it
+    if ( !m_hasFocus )
+    {
+        m_hasFocus = TRUE;
 
-    if (!GetParent())
-        return;
+        RefreshSelected();
+    }
 
-    RefreshSelected();
+    if ( !GetParent() )
+        return;
 
 #ifdef __WXGTK__
     g_focusWindow = GetParent();
@@ -4861,7 +4891,7 @@ bool wxListCtrl::DeleteAllColumns()
 {
     size_t count = m_mainWin->m_columns.GetCount();
     for ( size_t n = 0; n < count; n++ )
-        DeleteColumn(n);
+        DeleteColumn(0);
 
     return TRUE;
 }