Use wxVisualAttributes (partially #if'd out until tested further.)
authorRobin Dunn <robin@alldunn.com>
Thu, 6 May 2004 21:01:24 +0000 (21:01 +0000)
committerRobin Dunn <robin@alldunn.com>
Thu, 6 May 2004 21:01:24 +0000 (21:01 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@27122 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

include/wx/generic/listctrl.h
include/wx/generic/treectlg.h
src/generic/listctrl.cpp
src/generic/treectlg.cpp

index 47ba79defec6eb191340fd6026f73823fe0c540e..961bd9901d62d486658cc4dc08e07b4710ab8a2b 100644 (file)
@@ -173,6 +173,14 @@ public:
     wxDEPRECATED( int GetItemSpacing( bool isSmall ) const );
 
 
+    virtual wxVisualAttributes GetDefaultAttributes() const
+    {
+        return GetClassDefaultAttributes(GetWindowVariant());
+    }
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+
     // implementation only from now on
     // -------------------------------
 
index 7ab1cd0d31870017309c06c64306d2f9a2839b7b..68fb89b8b2b96d39e9f49ebdb6a0af5a84825d5e 100644 (file)
@@ -391,6 +391,14 @@ public:
     void OnGetToolTip( wxTreeEvent &event );
     void OnInternalIdle( );
 
+    virtual wxVisualAttributes GetDefaultAttributes() const
+    {
+        return GetClassDefaultAttributes(GetWindowVariant());
+    }
+
+    static wxVisualAttributes
+    GetClassDefaultAttributes(wxWindowVariant variant = wxWINDOW_VARIANT_NORMAL);
+    
     // implementation helpers
 protected:
     friend class wxGenericTreeItem;
index 5fd80d4198f478d403a6e68e8e7231f62c2e604f..8c81811aaadc4a9ef8d4d4201781a87a3c6c740d 100644 (file)
@@ -1658,7 +1658,16 @@ wxListHeaderWindow::wxListHeaderWindow( wxWindow *win,
     m_owner = owner;
     m_resizeCursor = new wxCursor( wxCURSOR_SIZEWE );
 
-    SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_BTNFACE ) );
+#if _USE_VISATTR
+    wxVisualAttributes attr = wxPanel::GetClassDefaultAttributes();    
+    SetDefaultForegroundColour( attr.colFg );
+    SetDefaultBackgroundColour( attr.colBg );
+    SetDefaultFont( attr.font );
+#else
+    SetDefaultForegroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT));
+    SetDefaultBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_BTNFACE));
+    SetDefaultFont( wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT ));
+#endif
 }
 
 wxListHeaderWindow::~wxListHeaderWindow()
@@ -1703,12 +1712,8 @@ void wxListHeaderWindow::OnPaint( wxPaintEvent &WXUNUSED(event) )
 
     dc.SetBackgroundMode(wxTRANSPARENT);
 
-    // do *not* use the listctrl colour for headers - one day we will have a
-    // function to set it separately
-    //dc.SetTextForeground( *wxBLACK );
-    dc.SetTextForeground(wxSystemSettings::
-                            GetSystemColour( wxSYS_COLOUR_WINDOWTEXT ));
-
+    dc.SetTextForeground(GetForegroundColour());
+    
     int x = HEADER_OFFSET_X;
 
     int numColumns = m_owner->GetColumnCount();
@@ -2200,7 +2205,10 @@ wxListMainWindow::wxListMainWindow( wxWindow *parent,
 
     SetScrollbars( 0, 0, 0, 0, 0, 0 );
 
-    SetBackgroundColour( wxSystemSettings::GetColour( wxSYS_COLOUR_LISTBOX ) );
+    wxVisualAttributes attr = wxGenericListCtrl::GetClassDefaultAttributes();    
+    SetDefaultForegroundColour( attr.colFg );
+    SetDefaultBackgroundColour( attr.colBg );
+    SetDefaultFont( attr.font );
 }
 
 wxListMainWindow::~wxListMainWindow()
@@ -4630,6 +4638,8 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
         }
     }
 
+    SetBestSize(size);
+    
     return TRUE;
 }
 
@@ -5232,6 +5242,29 @@ bool wxGenericListCtrl::SetFont( const wxFont &font )
     return TRUE;
 }
 
+
+// NOTE: If using the wxListBox visual attributes works everywhere then this can
+// be removed, as well as the #else case below.
+#define _USE_VISATTR 0
+
+#include "wx/listbox.h"
+
+//static
+wxVisualAttributes
+wxGenericListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+{
+#if _USE_VISATTR
+    // Use the same color scheme as wxListBox
+    return wxListBox::GetClassDefaultAttributes(variant);
+#else
+    wxVisualAttributes attr;
+    attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+    attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
+    attr.font  = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+    return attr;
+#endif
+}
+
 // ----------------------------------------------------------------------------
 // methods forwarded to m_mainWin
 // ----------------------------------------------------------------------------
index 24dec8e4cb1a8cab5be216fb546231b1f6c2ba57..c7cfd6b8549f16fa1fbc7296eae79248ccf3a9ed 100644 (file)
@@ -788,12 +788,16 @@ bool wxGenericTreeCtrl::Create(wxWindow *parent,
     SetValidator( validator );
 #endif
 
-    SetForegroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT) );
-    SetBackgroundColour( wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX) );
+    wxVisualAttributes attr = GetDefaultAttributes();    
+    SetDefaultForegroundColour( attr.colFg );
+    SetDefaultBackgroundColour( attr.colBg );
+    SetDefaultFont(attr.font);
 
 //  m_dottedPen = wxPen( "grey", 0, wxDOT );  too slow under XFree86
     m_dottedPen = wxPen( wxT("grey"), 0, 0 );
 
+    SetBestSize(size);
+    
     return TRUE;
 }
 
@@ -3437,4 +3441,27 @@ void wxGenericTreeCtrl::OnGetToolTip( wxTreeEvent &event )
     event.Veto();
 }
 
+
+// NOTE: If using the wxListBox visual attributes works everywhere then this can
+// be removed, as well as the #else case below.
+#define _USE_VISATTR 0
+
+#include "wx/listbox.h"
+
+//static
+wxVisualAttributes
+wxGenericTreeCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+{
+#if _USE_VISATTR
+    // Use the same color scheme as wxListBox
+    return wxListBox::GetClassDefaultAttributes(variant);
+#else
+    wxVisualAttributes attr;
+    attr.colFg = wxSystemSettings::GetColour(wxSYS_COLOUR_WINDOWTEXT);
+    attr.colBg = wxSystemSettings::GetColour(wxSYS_COLOUR_LISTBOX);
+    attr.font  = wxSystemSettings::GetFont(wxSYS_DEFAULT_GUI_FONT);
+    return attr;
+#endif
+}
+
 #endif // wxUSE_TREECTRL