]> git.saurik.com Git - wxWidgets.git/commitdiff
mac cleanup, pure cgcolor
authorStefan Csomor <csomor@advancedconcepts.ch>
Fri, 23 Nov 2007 09:58:10 +0000 (09:58 +0000)
committerStefan Csomor <csomor@advancedconcepts.ch>
Fri, 23 Nov 2007 09:58:10 +0000 (09:58 +0000)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50183 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775

src/mac/carbon/brush.cpp
src/mac/carbon/dcclient.cpp
src/mac/carbon/drawer.cpp
src/mac/carbon/graphics.cpp
src/mac/carbon/settings.cpp
src/mac/carbon/statbrma.cpp
src/mac/carbon/toplevel.cpp
src/mac/carbon/utils.cpp
src/mac/carbon/window.cpp

index af04c644bf5c8469aa996bc895f213034038ab98..876415261fd619c204aef2ed365b78d8223638fd 100644 (file)
@@ -23,253 +23,163 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
 
 class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
 {
-    friend class wxBrush;
-
 public:
-    wxBrushRefData();
+    wxBrushRefData(const wxColour& colour = wxNullColour, int style = wxSOLID);
+    wxBrushRefData(const wxBitmap& stipple);
     wxBrushRefData(const wxBrushRefData& data);
     virtual ~wxBrushRefData();
 
-    bool operator == ( const wxBrushRefData& brush ) const
-    {
-        return m_style == brush.m_style &&
-                m_stipple.IsSameAs(brush.m_stipple) &&
-                m_colour == brush.m_colour &&
-                m_macBrushKind == brush.m_macBrushKind &&
-                m_macThemeBrush == brush.m_macThemeBrush &&
-                m_macThemeBackground == brush.m_macThemeBackground &&
-                EqualRect(&m_macThemeBackgroundExtent, &brush.m_macThemeBackgroundExtent);
-    }
-
+    bool operator==(const wxBrushRefData& data) const;
 
+    const wxColour& GetColour() const { return m_colour; }
+    int GetStyle() const { return m_style; }
+    wxBitmap *GetStipple() { return &m_stipple; }
+        
+    void SetColour(const wxColour& colour) { m_colour = colour; }
+    void SetStyle(int style) { m_style = style; }
+    void SetStipple(const wxBitmap& stipple) { DoSetStipple(stipple); }
+    
 protected:
-    wxMacBrushKind m_macBrushKind ;
-    int           m_style;
+    void DoSetStipple(const wxBitmap& stipple);
+
     wxBitmap      m_stipple ;
     wxColour      m_colour;
-
-    ThemeBrush    m_macThemeBrush ;
-
-    ThemeBackgroundKind m_macThemeBackground ;
-    Rect         m_macThemeBackgroundExtent ;
+    int           m_style;
 };
 
 #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
 
-
-wxBrushRefData::wxBrushRefData()
-    : m_style(wxSOLID)
+wxBrushRefData::wxBrushRefData(const wxColour& colour, int style)
+    : m_colour(colour), m_style( style )
 {
-    m_macBrushKind = kwxMacBrushColour ;
 }
 
-wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
-    : wxGDIRefData()
-    , m_style(data.m_style)
+wxBrushRefData::wxBrushRefData(const wxBitmap& stipple)
 {
-  m_stipple = data.m_stipple;
-  m_colour = data.m_colour;
-  m_macBrushKind = data.m_macBrushKind ;
-  m_macThemeBrush = data.m_macThemeBrush ;
-  m_macThemeBackground = data.m_macThemeBackground ;
-  m_macThemeBackgroundExtent = data.m_macThemeBackgroundExtent ;
+    DoSetStipple( stipple );
 }
 
-wxBrushRefData::~wxBrushRefData()
+wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
+    : wxGDIRefData() ,
+        m_stipple(data.m_stipple),
+        m_colour(data.m_colour),
+        m_style(data.m_style)
 {
 }
 
-wxBrush::wxBrush()
+wxBrushRefData::~wxBrushRefData()
 {
 }
 
-wxBrush::~wxBrush()
+bool wxBrushRefData::operator==(const wxBrushRefData& data) const
 {
+    return m_style == data.m_style &&
+        m_colour == data.m_colour &&
+        m_stipple.IsSameAs(data.m_stipple);
 }
 
-wxBrush::wxBrush(const wxColour& col, int Style)
+void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)
 {
-    m_refData = new wxBrushRefData;
-
-    M_BRUSHDATA->m_colour = col;
-    M_BRUSHDATA->m_style = Style;
-
-    RealizeResource();
+    m_stipple = stipple;
+    m_style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE;
 }
+//
+//
+//
 
-wxBrush::wxBrush(const wxBitmap& stipple)
+wxBrush::wxBrush()
 {
-    m_refData = new wxBrushRefData;
-
-    M_BRUSHDATA->m_colour = *wxBLACK;
-    M_BRUSHDATA->m_stipple = stipple;
-
-    if (M_BRUSHDATA->m_stipple.GetMask())
-        M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
-    else
-        M_BRUSHDATA->m_style = wxSTIPPLE;
-
-    RealizeResource();
 }
 
-wxBrush::wxBrush( ThemeBrush macThemeBrush )
+wxBrush::~wxBrush()
 {
-    m_refData = new wxBrushRefData;
-
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
-    M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
-
-    RealizeResource();
 }
 
-void wxBrush::Unshare()
+wxBrush::wxBrush(const wxColour& col, int style)
 {
-    // Don't change shared data
-    if (!m_refData)
-    {
-        m_refData = new wxBrushRefData();
-    }
-    else
-    {
-        wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
-        UnRef();
-        m_refData = ref;
-    }
+    m_refData = new wxBrushRefData( col, style );
 }
 
-void wxBrush::SetColour(const wxColour& col)
+wxBrush::wxBrush(const wxBitmap& stipple)
 {
-    Unshare();
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
-    M_BRUSHDATA->m_colour = col;
-
-    RealizeResource();
+    m_refData = new wxBrushRefData( stipple );
 }
 
-void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
-{
-    Unshare();
-
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
-    M_BRUSHDATA->m_colour.Set(r, g, b);
+// ----------------------------------------------------------------------------
+// wxBrush house keeping stuff
+// ----------------------------------------------------------------------------
 
-    RealizeResource();
-}
-
-void wxBrush::SetStyle(int Style)
+bool wxBrush::operator==(const wxBrush& brush) const
 {
-    Unshare();
-
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
-    M_BRUSHDATA->m_style = Style;
-
-    RealizeResource();
+    const wxBrushRefData *brushData = (wxBrushRefData *)brush.m_refData;
+    
+    // an invalid brush is considered to be only equal to another invalid brush
+    return m_refData ? (brushData && *M_BRUSHDATA == *brushData) : !brushData;
 }
 
-void wxBrush::SetStipple(const wxBitmap& Stipple)
+wxObjectRefData *wxBrush::CreateRefData() const
 {
-    Unshare();
-
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
-    M_BRUSHDATA->m_stipple = Stipple;
-
-    RealizeResource();
+    return new wxBrushRefData;
 }
 
-void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
+wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
 {
-    Unshare();
-
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
-    M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
-
-    RGBColor color = { 0,0,0 } ;
-#ifdef __LP64__
-    CGColorRef colorref = 0;
-    HIThemeBrushCreateCGColor( macThemeBrush, &colorref );
-    size_t noComp = CGColorGetNumberOfComponents( colorref );
-    if ( noComp >=3 && noComp <= 4 )
-    {
-        // TODO verify whether we really are on a RGB color space
-        const CGFloat *components = CGColorGetComponents( colorref );
-        color.red = (int)(components[0]*255+0.5);
-        color.green = (int)(components[1]*255+0.5);
-        color.blue = (int)(components[2]*255+0.5);
-    }
-    CFRelease( colorref );
-#else
-    GetThemeBrushAsColor( macThemeBrush , 32, true, &color );
-#endif
-    M_BRUSHDATA->m_colour = color;
-
-    RealizeResource();
+    return new wxBrushRefData(*(const wxBrushRefData *)data);
 }
 
-/* TODO REMOVE
-void wxBrush::MacSetThemeBackground(unsigned long macThemeBackground, const WXRECTPTR extent)
-{
-    Unshare();
-
-    M_BRUSHDATA->m_macBrushKind = kwxMacBrushThemeBackground;
-    M_BRUSHDATA->m_macThemeBackground = macThemeBackground;
-    M_BRUSHDATA->m_macThemeBackgroundExtent = *(Rect*)extent;
-
-    RealizeResource();
-}
-*/
+// ----------------------------------------------------------------------------
+// wxBrush accessors
+// ----------------------------------------------------------------------------
 
-bool wxBrush::RealizeResource()
+const wxColour& wxBrush::GetColour() const
 {
-    return true;
+    wxCHECK_MSG( Ok(), wxNullColour, _T("invalid brush") );
+    
+    return M_BRUSHDATA->GetColour();
 }
 
-/*
-unsigned long wxBrush::MacGetThemeBackground(WXRECTPTR extent) const
+int wxBrush::GetStyle() const
 {
-    if ( M_BRUSHDATA && M_BRUSHDATA->m_macBrushKind == kwxMacBrushThemeBackground )
-    {
-        if ( extent )
-            *(Rect*)extent = M_BRUSHDATA->m_macThemeBackgroundExtent;
-
-        return M_BRUSHDATA->m_macThemeBackground;
-    }
-    else
-    {
-        return 0;
-    }
+    wxCHECK_MSG( Ok(), 0, _T("invalid brush") );
+    
+    return M_BRUSHDATA->GetStyle();
 }
- */
 
-short wxBrush::MacGetTheme() const
+wxBitmap *wxBrush::GetStipple() const
 {
-    return (M_BRUSHDATA ? ((M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme) ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
+    wxCHECK_MSG( Ok(), NULL, _T("invalid brush") );
+    
+    return M_BRUSHDATA->GetStipple();
 }
 
-wxColour& wxBrush::GetColour() const
-{
-    return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour);
-}
+// ----------------------------------------------------------------------------
+// wxBrush setters
+// ----------------------------------------------------------------------------
 
-int wxBrush::GetStyle() const
+void wxBrush::SetColour(const wxColour& col)
 {
-    return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
+    AllocExclusive();
+    
+    M_BRUSHDATA->SetColour(col);
 }
 
-wxBitmap *wxBrush::GetStipple() const
+void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
 {
-    return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
+    AllocExclusive();
+    
+    M_BRUSHDATA->SetColour(wxColour(r, g, b));
 }
 
-wxMacBrushKind wxBrush::MacGetBrushKind() const
+void wxBrush::SetStyle(int style)
 {
-    return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
+    AllocExclusive();
+    
+    M_BRUSHDATA->SetStyle(style);
 }
 
-bool wxBrush::operator == ( const wxBrush& brush ) const
+void wxBrush::SetStipple(const wxBitmap& stipple)
 {
-    if (m_refData == brush.m_refData) return true;
-
-    if (!m_refData || !brush.m_refData) return false;
-
-    return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
+    AllocExclusive();
+    
+    M_BRUSHDATA->SetStipple(stipple);
 }
index bb06309b127253618ab8abe9d36bf2e6196556d3..63eb7a328e5dfda6f797bc8feee877b39ff97d78 100644 (file)
@@ -48,11 +48,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
 #include "wx/tabctrl.h"
 
 
-static wxBrush MacGetBackgroundBrush( wxWindow* window )
-{
-    wxBrush bkdBrush = window->MacGetBackgroundBrush() ;
-    return bkdBrush ;
-}
 
 wxWindowDC::wxWindowDC()
 {
@@ -89,7 +84,7 @@ wxWindowDC::wxWindowDC(wxWindow *window)
     }
     SetClippingRegion( 0 , 0 , m_width , m_height ) ;
 
-    SetBackground(MacGetBackgroundBrush(window));
+    SetBackground(wxBrush(window->GetBackgroundColour(),wxSOLID));
 
     SetFont( window->GetFont() ) ;
 }
index f12286af3380d27209088aaf9d5fc975411bf136..2c02dd42601c54db84d1f35a3d0e5b11a2d89027 100644 (file)
@@ -79,9 +79,8 @@ bool wxDrawerWindow::Create(wxWindow *parent,
     if (success)
     {
         // Use drawer brush.
-        m_macBackgroundBrush.MacSetTheme(kThemeBrushDrawerBackground);
-        ::SetThemeWindowBackground((WindowRef)m_macWindow,
-         m_macBackgroundBrush.MacGetTheme(), false);
+        SetBackgroundColour( wxColour( wxMacCreateCGColorFromHITheme( kThemeBrushDrawerBackground ) ) );
+        ::SetThemeWindowBackground((WindowRef)m_macWindow, kThemeBrushDrawerBackground, false);
          
         // Leading and trailing offset are gaps from parent window edges
         // to where the drawer starts.
index 78992a2f28eab10f9aa156682de138a21012bfe2..0f7889d7a9e67ea6049fd2917108b9dae42003a9 100644 (file)
@@ -483,6 +483,26 @@ static const char *gs_stripedback_xpm[] = {
 
 wxBitmap gs_stripedback_bmp( wxImage( (const char* const* ) gs_stripedback_xpm  ), -1 ) ;
 
+// make sure we all use one class for all conversions from wx to native colour
+
+class wxMacCoreGraphicsColour
+{
+    public:
+        wxMacCoreGraphicsColour();
+        wxMacCoreGraphicsColour(const wxBrush &brush);
+        ~wxMacCoreGraphicsColour();
+        
+        void Apply( CGContextRef cgContext );
+    protected:
+        void Init();
+        wxMacCFRefHolder<CGColorRef> m_color;
+        wxMacCFRefHolder<CGColorSpaceRef> m_colorSpace;
+        
+        bool m_isPattern;
+        wxMacCFRefHolder<CGPatternRef> m_pattern;
+        CGFloat* m_patternColorComponents;
+} ;
+
 wxMacCoreGraphicsColour::~wxMacCoreGraphicsColour()
 {
     delete[] m_patternColorComponents;
@@ -519,18 +539,7 @@ wxMacCoreGraphicsColour::wxMacCoreGraphicsColour( const wxBrush &brush )
     Init();
     if ( brush.GetStyle() == wxSOLID )
     {
-        if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
-        {
-            CGColorRef color ;
-            HIThemeBrushCreateCGColor( brush.MacGetTheme(), &color );
-            m_color.Set( color ) ;
-        }
-        else
-        {
-            CGFloat components[4] = { brush.GetColour().Red() / 255.0 , brush.GetColour().Green() / 255.0 ,
-                brush.GetColour().Blue() / 255.0 , brush.GetColour().Alpha() / 255.0 } ;
-            m_color.Set( CGColorCreate( wxMacGetGenericRGBColorSpace() , components ) ) ;
-        }
+        m_color.Set( brush.GetColour().CreateCGColor() );
     }
     else if ( brush.IsHatch() )
     {
index 237b8f2aeb558f3112af4bd6aa2c182aa813a2f5..03f1f1dcebfbe28c4fb82298e288ff3ce81091f7 100644 (file)
 
 wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 {
-    int major, minor;
     wxColour resultColor;
     ThemeBrush colorBrushID;
 
-    wxGetOsVersion( &major, &minor );
-
     switch ( index )
     {
         case wxSYS_COLOUR_WINDOW:
@@ -55,17 +52,11 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
             break ;
 
         case wxSYS_COLOUR_LISTBOX :
-            if (major >= 10)
-                resultColor = *wxWHITE ;
-            else
-                resultColor = wxColor( 0xEE, 0xEE, 0xEE );
+            resultColor = *wxWHITE ;
             break ;
 
         case wxSYS_COLOUR_BTNSHADOW:
-            if (major >= 10)
-                resultColor = wxColor( 0xBE, 0xBE, 0xBE );
-            else
-                resultColor = wxColor( 0x44, 0x44, 0x44 );
+            resultColor = wxColor( 0xBE, 0xBE, 0xBE );
             break ;
 
         case wxSYS_COLOUR_BTNTEXT:
@@ -85,9 +76,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 #else
                 colorBrushID = kThemeBrushPrimaryHighlightColor;
 #endif
-                CGColorRef color ;
-                HIThemeBrushCreateCGColor( colorBrushID, &color );
-                resultColor = wxColor( color );
+                resultColor = wxColor( wxMacCreateCGColorFromHITheme(colorBrushID) );
             }
             break ;
 
@@ -110,9 +99,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
             resultColor = *wxWHITE ;
 #else
             {
-                CGColorRef color ;
-                HIThemeBrushCreateCGColor( kThemeBrushPrimaryHighlightColor, &color );
-                wxColour highlightcolor( color );
+                wxColour highlightcolor( wxMacCreateCGColorFromHITheme(kThemeBrushPrimaryHighlightColor) );
                 if ((highlightcolor.Red() + highlightcolor.Green()  + highlightcolor.Blue() ) == 0)
                     resultColor = *wxWHITE ;
                 else
index b302d82ab659502735eb410d0379eb44dde5cb27..926198c3b01fec141afb82dd644817443714ef23 100644 (file)
@@ -59,7 +59,7 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
         return false;
 
     if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
-        MacSetBackgroundBrush( wxNullBrush );
+        SetBackgroundStyle( wxBG_STYLE_TRANSPARENT );
 
     // normal system font is too tall for fitting into the standard height
     SetWindowVariant( wxWINDOW_VARIANT_SMALL );
index 135bf7aa619d2d66e4b0a689996c687e8372c46a..57847ae885f9da81b4cee51a5295e28863095a00 100644 (file)
@@ -961,7 +961,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
 
     DoMacCreateRealWindow( parent, title, pos , size , style , name ) ;
 
-    SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
+    SetBackgroundColour(wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)));
 
     if (GetExtraStyle() & wxFRAME_EX_METAL)
         MacSetMetalAppearance(true);
@@ -1063,15 +1063,18 @@ wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
     return wxPoint(0, 0) ;
 }
 
-void  wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
+bool wxTopLevelWindowMac::SetBackgroundColour(const wxColour& col )
 {
-    wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ;
-
-    if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT && m_macBackgroundBrush.MacGetBrushKind() == kwxMacBrushTheme )
-    {
-        SetThemeWindowBackground( (WindowRef) m_macWindow , m_macBackgroundBrush.MacGetTheme() , false ) ;
-    }
-}
+    if ( !wxTopLevelWindowBase::SetBackgroundColour(col) && m_hasBgCol )
+        return false ;
+    
+    if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) )
+        SetThemeWindowBackground( (WindowRef) m_macWindow,  kThemeBrushDocumentWindowBackground, false ) ;
+    else if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) )
+        SetThemeWindowBackground( (WindowRef) m_macWindow,  kThemeBrushDialogBackgroundActive, false ) ;
+    // TODO BETTER THEME SUPPORT
+    return true;
+}    
 
 void wxTopLevelWindowMacInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
 {
index 3b74155503fa6686b3b483fdd1b4488c22349704..757920cd03763390c8ef2b911a29a6b837b9b777 100644 (file)
@@ -687,7 +687,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
 #endif
 }
 
-void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) )
+void wxMacControl::SetBackgroundColour( const wxColour &WXUNUSED(col) )
 {
     // TODO
     // setting up a color proc is not recommended anymore
@@ -1895,37 +1895,6 @@ OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable )
 // Quartz Support
 //
 
-// snippets from Sketch Sample from Apple :
-
-#define kGenericRGBProfilePathStr "/System/Library/ColorSync/Profiles/Generic RGB Profile.icc"
-
-/*
-    This function locates, opens, and returns the profile reference for the calibrated
-    Generic RGB color space. It is up to the caller to call CMCloseProfile when done
-    with the profile reference this function returns.
-*/
-CMProfileRef wxMacOpenGenericProfile()
-{
-    static CMProfileRef cachedRGBProfileRef = NULL;
-
-    // we only create the profile reference once
-    if (cachedRGBProfileRef == NULL)
-    {
-        CMProfileLocation loc;
-
-        loc.locType = cmPathBasedProfile;
-        strcpy(loc.u.pathLoc.path, kGenericRGBProfilePathStr);
-
-        verify_noerr( CMOpenProfile(&cachedRGBProfileRef, &loc) );
-    }
-
-    // clone the profile reference so that the caller has their own reference, not our cached one
-    if (cachedRGBProfileRef)
-        CMCloneProfileRef(cachedRGBProfileRef);
-
-    return cachedRGBProfileRef;
-}
-
 /*
     Return the generic RGB color space. This is a 'get' function and the caller should
     not release the returned value unless the caller retains it first. Usually callers
@@ -1948,6 +1917,13 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace()
     return genericRGBColorSpace;
 }
 
+CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush ) 
+{
+    CGColorRef color ;
+    HIThemeBrushCreateCGColor( brush, &color );
+    return color;
+}
+
 #ifndef __LP64__
 
 wxMacPortSaver::wxMacPortSaver( GrafPtr port )
index 1784856fdfd29cf15069bd8c7b5c7bbc282d48f4..e4d51d52a0ef8417cb033a6aced078ae37edc250 100644 (file)
@@ -924,8 +924,6 @@ void wxWindowMac::Init()
     m_hScrollBarAlwaysShown = false;
     m_vScrollBarAlwaysShown = false;
 
-    m_macBackgroundBrush = wxNullBrush ;
-
     m_macIsUserPane = true;
     m_clipChildren = false ;
     m_cachedClippedRectValid = false ;
@@ -1200,28 +1198,11 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
     if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol )
         return false ;
 
-    wxBrush brush ;
-    wxColour newCol(GetBackgroundColour());
-
-    if ( newCol == wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) )
-        brush.MacSetTheme( kThemeBrushDocumentWindowBackground ) ;
-    else if ( newCol == wxSystemSettings::GetColour( wxSYS_COLOUR_3DFACE ) )
-        brush.MacSetTheme( kThemeBrushDialogBackgroundActive ) ;
-    else
-        brush.SetColour( newCol ) ;
-
-    MacSetBackgroundBrush( brush ) ;
-    MacUpdateControlFont() ;
+    m_peer->SetBackgroundColour( col ) ;
 
     return true ;
 }
 
-void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
-{
-    m_macBackgroundBrush = brush ;
-    m_peer->SetBackground( brush ) ;
-}
-
 bool wxWindowMac::MacCanFocus() const
 {
     // TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
@@ -2315,8 +2296,7 @@ void wxWindowMac::OnEraseBackground(wxEraseEvent& event)
         return ;
 
 #if TARGET_API_MAC_OSX
-    if ( !m_macBackgroundBrush.Ok() || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT
-         || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
+    if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
     {
         event.Skip() ;
     }
@@ -2441,10 +2421,9 @@ void  wxWindowMac::MacPaintGrowBox()
         CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
         CGContextSaveGState( cgContext );
         
-        if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT )
+        if ( m_backgroundColour.Ok() )
         {
-            wxMacCoreGraphicsColour bkgnd( m_macBackgroundBrush ) ;
-            bkgnd.Apply( cgContext );
+            CGContextSetFillColorWithColor( cgContext, m_backgroundColour.GetCGColor() ); 
         }
         else
         {