]> git.saurik.com Git - wxWidgets.git/blobdiff - src/generic/listctrl.cpp
fixed setting of initial font under wxGTK2
[wxWidgets.git] / src / generic / listctrl.cpp
index 2b062881dbca87ca03dd17b3e60ed24d062d1aca..99fec5e45f73874ca4c4eb9d82357262dbed3918 100644 (file)
 
 #include "wx/renderer.h"
 
+#ifdef __WXMAC__
+    #include "wx/mac/private.h"
+#endif
+
+// 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
+
+
 // ----------------------------------------------------------------------------
 // events
 // ----------------------------------------------------------------------------
@@ -112,7 +121,7 @@ static const int SCROLL_UNIT_X = 15;
 static const int LINE_SPACING = 0;
 
 // extra margins around the text label
-static const int EXTRA_WIDTH = 3;
+static const int EXTRA_WIDTH = 4;
 static const int EXTRA_HEIGHT = 4;
 
 // margin between the window and the items
@@ -1655,7 +1664,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()
@@ -1700,12 +1718,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();
@@ -2197,7 +2211,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()
@@ -4611,6 +4628,11 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
 
     m_mainWin = new wxListMainWindow( this, -1, wxPoint(0,0), size, style );
 
+#if defined( __WXMAC__ ) && __WXMAC_CARBON__
+    wxFont font ;
+    font.MacCreateThemeFont( kThemeViewsFont ) ;
+    SetFont( font ) ;
+#endif
     if ( InReportView() )
     {
         CreateHeaderWindow();
@@ -4622,6 +4644,8 @@ bool wxGenericListCtrl::Create(wxWindow *parent,
         }
     }
 
+    SetBestSize(size);
+    
     return TRUE;
 }
 
@@ -5224,6 +5248,29 @@ bool wxGenericListCtrl::SetFont( const wxFont &font )
     return TRUE;
 }
 
+
+
+#if _USE_VISATTR
+#include "wx/listbox.h"
+#endif
+
+//static
+wxVisualAttributes
+wxGenericListCtrl::GetClassDefaultAttributes(wxWindowVariant variant)
+{
+#if _USE_VISATTR
+    // Use the same color scheme as wxListBox
+    return wxListBox::GetClassDefaultAttributes(variant);
+#else
+    wxUnusedVar(variant);
+    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
 // ----------------------------------------------------------------------------