]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
floating pane size now restores after perspective restore
[wxWidgets.git] / src / generic / listctrl.cpp
index 08e3146d1e4df0e36fe769513d4b6601ddcc0bb0..3bda4a220f1c71f0d6adf35f144f68318c8c221f 100644 (file)
     #include "wx/mac/private.h"
 #endif
 
-#ifdef __WXGTK20__
-    #include "wx/gtk/private.h"
-    #include "wx/gtk/win_gtk.h"
-#endif
-
-
 
 // NOTE: If using the wxListBox visual attributes works everywhere then this can
 // be removed, as well as the #else case below.
@@ -209,6 +203,7 @@ public:
     void SetItem( const wxListItem &item );
     void SetPosition( int x, int y );
     void SetWidth( int w );
+    void SetState( int state );
     void SetFormat( int format );
     void SetHeight( int h );
     bool HasImage() const;
@@ -223,6 +218,7 @@ public:
     int GetImage() const;
     int GetWidth() const;
     int GetFormat() const;
+    int GetState() const;
 
 protected:
     long      m_mask;
@@ -233,6 +229,7 @@ protected:
     int       m_xpos,
               m_ypos;
     int       m_height;
+    int       m_state;
 
 private:
     void Init();
@@ -1008,6 +1005,7 @@ void wxListHeaderData::Init()
     m_xpos = 0;
     m_ypos = 0;
     m_height = 0;
+    m_state = 0;
 }
 
 wxListHeaderData::wxListHeaderData()
@@ -1037,6 +1035,9 @@ void wxListHeaderData::SetItem( const wxListItem &item )
 
     if ( m_mask & wxLIST_MASK_WIDTH )
         SetWidth(item.m_width);
+        
+    if ( m_mask & wxLIST_MASK_STATE )
+        SetState(item.m_state);
 }
 
 void wxListHeaderData::SetPosition( int x, int y )
@@ -1055,6 +1056,11 @@ void wxListHeaderData::SetWidth( int w )
     m_width = w < 0 ? WIDTH_COL_DEFAULT : w;
 }
 
+void wxListHeaderData::SetState( int flag )
+{
+    m_state = flag;
+}
+
 void wxListHeaderData::SetFormat( int format )
 {
     m_format = format;
@@ -1077,6 +1083,7 @@ void wxListHeaderData::GetItem( wxListItem& item )
     item.m_image = m_image;
     item.m_format = m_format;
     item.m_width = m_width;
+    item.m_state = m_state;
 }
 
 int wxListHeaderData::GetImage() const
@@ -1094,6 +1101,11 @@ int wxListHeaderData::GetFormat() const
     return m_format;
 }
 
+int wxListHeaderData::GetState() const
+{
+    return m_state;
+}
+
 //-----------------------------------------------------------------------------
 //  wxListLineData
 //-----------------------------------------------------------------------------
@@ -1448,7 +1460,7 @@ void wxListLineData::Draw( wxDC *dc )
     wxListItemAttr *attr = GetAttr();
 
     if ( SetAttributes(dc, attr, highlighted) )
-#ifndef __WXGTK20__
+#if ( !defined(__WXGTK20__) && !defined(__WXMAC__) )
     {
         dc->DrawRectangle( m_gi->m_rectHighlight );
     }
@@ -1456,17 +1468,11 @@ void wxListLineData::Draw( wxDC *dc )
     {
         if (highlighted)
         {
-            wxRect rect2( m_gi->m_rectHighlight );
-            m_owner->CalcScrolledPosition( rect2.x, rect2.y, &rect2.x, &rect2.y );
-        
-            gtk_paint_flat_box( m_owner->m_widget->style, 
-                            GTK_PIZZA(m_owner->m_wxwindow)->bin_window,
-                                       GTK_STATE_SELECTED,
-                            GTK_SHADOW_NONE,
-                            NULL,
-                            m_owner->m_wxwindow,
-                            "cell_even",
-                            rect2.x, rect2.y, rect2.width, rect2.height );
+            int flags = wxCONTROL_SELECTED;
+            if (m_owner->HasFocus())
+                flags |= wxCONTROL_FOCUSED;
+            wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, m_gi->m_rectHighlight, flags );
+            
         }
         else
         {
@@ -1513,7 +1519,7 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
     //       GetAttr() and move these lines into the loop below
     wxListItemAttr *attr = GetAttr();
     if ( SetAttributes(dc, attr, highlighted) )
-#ifndef __WXGTK20__
+#if ( !defined(__WXGTK20__) && !defined(__WXMAC__) )
     {
         dc->DrawRectangle( rectHL );
     }
@@ -1521,17 +1527,10 @@ void wxListLineData::DrawInReportMode( wxDC *dc,
     {
         if (highlighted)
         {
-            wxRect rect2( rectHL );
-            m_owner->CalcScrolledPosition( rect2.x, rect2.y, &rect2.x, &rect2.y );
-        
-            gtk_paint_flat_box( m_owner->m_widget->style, 
-                            GTK_PIZZA(m_owner->m_wxwindow)->bin_window,
-                                       GTK_STATE_SELECTED,
-                            GTK_SHADOW_NONE,
-                            NULL,
-                            m_owner->m_wxwindow,
-                            "cell_even",
-                            rect2.x, rect2.y, rect2.width, rect2.height );
+            int flags = wxCONTROL_SELECTED;
+            if (m_owner->HasFocus())
+                flags |= wxCONTROL_FOCUSED;
+            wxRendererNative::Get().DrawItemSelectionRect( m_owner, *dc, rectHL, flags );
         }
         else
         {
@@ -1798,13 +1797,26 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
         int ch = h - 2;
 #endif
 
+        int flags = 0;
+        if (!m_parent->IsEnabled())
+            flags |= wxCONTROL_DISABLED;
+
+// NB: The code below is not really Mac-specific, but since we are close 
+// to 2.8 release and I don't have time to test on other platforms, I
+// defined this only for wxMac. If this behavior is desired on
+// other platforms, please go ahead and revise or remove the #ifdef.
+#ifdef __WXMAC__
+        if ( !m_owner->IsVirtual() && (item.m_mask & wxLIST_MASK_STATE) && 
+                (item.m_state & wxLIST_STATE_SELECTED) )
+            flags |= wxCONTROL_SELECTED;
+#endif
+
         wxRendererNative::Get().DrawHeaderButton
                                 (
                                     this,
                                     dc,
                                     wxRect(x, HEADER_OFFSET_Y, cw, ch),
-                                    m_parent->IsEnabled() ? 0
-                                                          : (int)wxCONTROL_DISABLED
+                                    flags
                                 );
 
         // see if we have enough space for the column label
@@ -2000,6 +2012,22 @@ void wxListHeaderWindow::OnMouse( wxMouseEvent &event )
             }
             else // click on a column
             {
+                // record the selected state of the columns
+                if (event.LeftDown())
+                {
+                    for (int i=0; i < m_owner->GetColumnCount(); i++)
+                    {
+                        wxListItem colItem;
+                        m_owner->GetColumn(i, colItem);
+                        long state = colItem.GetState(); 
+                        if (i == m_column)
+                            colItem.SetState(state | wxLIST_STATE_SELECTED);
+                        else
+                            colItem.SetState(state & ~wxLIST_STATE_SELECTED);
+                        m_owner->SetColumn(i, colItem);
+                    }
+                }
+                
                 SendListEvent( event.LeftDown()
                                     ? wxEVT_COMMAND_LIST_COL_CLICK
                                     : wxEVT_COMMAND_LIST_COL_RIGHT_CLICK,
@@ -2262,14 +2290,6 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
 {
     Init();
 
-
-#ifdef __WXMAC__
-    // OS X sel item highlight color differs from text highlight color, which is
-    // what wxSYS_COLOUR_HIGHLIGHT returns. 
-    RGBColor hilight;
-    GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &hilight);
-    m_highlightBrush = new wxBrush( wxColour(hilight.red, hilight.green, hilight.blue ), wxSOLID );
-#else
     m_highlightBrush = new wxBrush
                          (
                             wxSystemSettings::GetColour
@@ -2278,14 +2298,7 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
                             ),
                             wxSOLID
                          );
-#endif
-
-#ifdef __WXMAC__
-    // on Mac, this color also differs from the wxSYS_COLOUR_BTNSHADOW, enough to be noticable.
-    // I don't know if BTNSHADOW is appropriate in other contexts, so I'm just changing it here.
-    GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &hilight);
-    m_highlightUnfocusedBrush = new wxBrush( wxColour(hilight.red, hilight.green, hilight.blue ), wxSOLID );
-#else
+                         
     m_highlightUnfocusedBrush = new wxBrush
                               (
                                  wxSystemSettings::GetColour
@@ -2294,7 +2307,6 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
                                  ),
                                  wxSOLID
                               );
-#endif
 
     SetScrollbars( 0, 0, 0, 0, 0, 0 );
 
@@ -2801,15 +2813,7 @@ void wxListMainWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
             dc.SetBrush( *wxTRANSPARENT_BRUSH );
             dc.DrawRectangle( rect );
 #else
-            CalcScrolledPosition( rect.x, rect.y, &rect.x, &rect.y );
-        
-            gtk_paint_focus( m_widget->style, 
-                             GTK_PIZZA(m_wxwindow)->bin_window,
-                             GTK_STATE_SELECTED,
-                             NULL,
-                             m_wxwindow,
-                             "treeview",
-                             rect.x, rect.y, rect.width, rect.height );
+            wxRendererNative::Get().DrawItemSelectionRect( this, dc, rect, wxCONTROL_CURRENT|wxCONTROL_FOCUSED );
             
 #endif
         }