mac cleanup, pure cgcolor
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@50183 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
850df2d788
commit
a01d9a255c
@ -23,62 +23,70 @@ IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
|||||||
|
|
||||||
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
|
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
|
||||||
{
|
{
|
||||||
friend class wxBrush;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
wxBrushRefData();
|
wxBrushRefData(const wxColour& colour = wxNullColour, int style = wxSOLID);
|
||||||
|
wxBrushRefData(const wxBitmap& stipple);
|
||||||
wxBrushRefData(const wxBrushRefData& data);
|
wxBrushRefData(const wxBrushRefData& data);
|
||||||
virtual ~wxBrushRefData();
|
virtual ~wxBrushRefData();
|
||||||
|
|
||||||
bool operator == ( const wxBrushRefData& brush ) const
|
bool operator==(const wxBrushRefData& data) 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);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
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:
|
protected:
|
||||||
wxMacBrushKind m_macBrushKind ;
|
void DoSetStipple(const wxBitmap& stipple);
|
||||||
int m_style;
|
|
||||||
wxBitmap m_stipple ;
|
wxBitmap m_stipple ;
|
||||||
wxColour m_colour;
|
wxColour m_colour;
|
||||||
|
int m_style;
|
||||||
ThemeBrush m_macThemeBrush ;
|
|
||||||
|
|
||||||
ThemeBackgroundKind m_macThemeBackground ;
|
|
||||||
Rect m_macThemeBackgroundExtent ;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
||||||
|
|
||||||
|
wxBrushRefData::wxBrushRefData(const wxColour& colour, int style)
|
||||||
wxBrushRefData::wxBrushRefData()
|
: m_colour(colour), m_style( style )
|
||||||
: m_style(wxSOLID)
|
|
||||||
{
|
{
|
||||||
m_macBrushKind = kwxMacBrushColour ;
|
}
|
||||||
|
|
||||||
|
wxBrushRefData::wxBrushRefData(const wxBitmap& stipple)
|
||||||
|
{
|
||||||
|
DoSetStipple( stipple );
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
|
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
|
||||||
: wxGDIRefData()
|
: wxGDIRefData() ,
|
||||||
, m_style(data.m_style)
|
m_stipple(data.m_stipple),
|
||||||
|
m_colour(data.m_colour),
|
||||||
|
m_style(data.m_style)
|
||||||
{
|
{
|
||||||
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 ;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrushRefData::~wxBrushRefData()
|
wxBrushRefData::~wxBrushRefData()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxBrushRefData::operator==(const wxBrushRefData& data) const
|
||||||
|
{
|
||||||
|
return m_style == data.m_style &&
|
||||||
|
m_colour == data.m_colour &&
|
||||||
|
m_stipple.IsSameAs(data.m_stipple);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBrushRefData::DoSetStipple(const wxBitmap& stipple)
|
||||||
|
{
|
||||||
|
m_stipple = stipple;
|
||||||
|
m_style = stipple.GetMask() ? wxSTIPPLE_MASK_OPAQUE : wxSTIPPLE;
|
||||||
|
}
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//
|
||||||
|
|
||||||
wxBrush::wxBrush()
|
wxBrush::wxBrush()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@ -87,189 +95,91 @@ wxBrush::~wxBrush()
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxColour& col, int Style)
|
wxBrush::wxBrush(const wxColour& col, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
m_refData = new wxBrushRefData( col, style );
|
||||||
|
|
||||||
M_BRUSHDATA->m_colour = col;
|
|
||||||
M_BRUSHDATA->m_style = Style;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxBitmap& stipple)
|
wxBrush::wxBrush(const wxBitmap& stipple)
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
m_refData = new wxBrushRefData( stipple );
|
||||||
|
|
||||||
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 house keeping stuff
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
bool wxBrush::operator==(const wxBrush& brush) const
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
const wxBrushRefData *brushData = (wxBrushRefData *)brush.m_refData;
|
||||||
|
|
||||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushTheme;
|
// an invalid brush is considered to be only equal to another invalid brush
|
||||||
M_BRUSHDATA->m_macThemeBrush = macThemeBrush;
|
return m_refData ? (brushData && *M_BRUSHDATA == *brushData) : !brushData;
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBrush::Unshare()
|
wxObjectRefData *wxBrush::CreateRefData() const
|
||||||
{
|
{
|
||||||
// Don't change shared data
|
return new wxBrushRefData;
|
||||||
if (!m_refData)
|
|
||||||
{
|
|
||||||
m_refData = new wxBrushRefData();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
|
|
||||||
UnRef();
|
|
||||||
m_refData = ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBrush::SetColour(const wxColour& col)
|
wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
|
||||||
{
|
{
|
||||||
Unshare();
|
return new wxBrushRefData(*(const wxBrushRefData *)data);
|
||||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
|
||||||
M_BRUSHDATA->m_colour = col;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrush accessors
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
const wxColour& wxBrush::GetColour() const
|
||||||
{
|
{
|
||||||
Unshare();
|
wxCHECK_MSG( Ok(), wxNullColour, _T("invalid brush") );
|
||||||
|
|
||||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
return M_BRUSHDATA->GetColour();
|
||||||
M_BRUSHDATA->m_colour.Set(r, g, b);
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::SetStyle(int Style)
|
|
||||||
{
|
|
||||||
Unshare();
|
|
||||||
|
|
||||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
|
||||||
M_BRUSHDATA->m_style = Style;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::SetStipple(const wxBitmap& Stipple)
|
|
||||||
{
|
|
||||||
Unshare();
|
|
||||||
|
|
||||||
M_BRUSHDATA->m_macBrushKind = kwxMacBrushColour;
|
|
||||||
M_BRUSHDATA->m_stipple = Stipple;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
|
|
||||||
{
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* 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();
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
bool wxBrush::RealizeResource()
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
unsigned long wxBrush::MacGetThemeBackground(WXRECTPTR extent) 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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
|
|
||||||
short wxBrush::MacGetTheme() const
|
|
||||||
{
|
|
||||||
return (M_BRUSHDATA ? ((M_BRUSHDATA->m_macBrushKind == kwxMacBrushTheme) ? M_BRUSHDATA->m_macThemeBrush : kThemeBrushBlack) : kThemeBrushBlack);
|
|
||||||
}
|
|
||||||
|
|
||||||
wxColour& wxBrush::GetColour() const
|
|
||||||
{
|
|
||||||
return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int wxBrush::GetStyle() const
|
int wxBrush::GetStyle() const
|
||||||
{
|
{
|
||||||
return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0);
|
wxCHECK_MSG( Ok(), 0, _T("invalid brush") );
|
||||||
|
|
||||||
|
return M_BRUSHDATA->GetStyle();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBitmap *wxBrush::GetStipple() const
|
wxBitmap *wxBrush::GetStipple() const
|
||||||
{
|
{
|
||||||
return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0);
|
wxCHECK_MSG( Ok(), NULL, _T("invalid brush") );
|
||||||
|
|
||||||
|
return M_BRUSHDATA->GetStipple();
|
||||||
}
|
}
|
||||||
|
|
||||||
wxMacBrushKind wxBrush::MacGetBrushKind() const
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrush setters
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
void wxBrush::SetColour(const wxColour& col)
|
||||||
{
|
{
|
||||||
return (M_BRUSHDATA ? M_BRUSHDATA->m_macBrushKind : kwxMacBrushColour);
|
AllocExclusive();
|
||||||
|
|
||||||
|
M_BRUSHDATA->SetColour(col);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxBrush::operator == ( const wxBrush& brush ) const
|
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
||||||
{
|
{
|
||||||
if (m_refData == brush.m_refData) return true;
|
AllocExclusive();
|
||||||
|
|
||||||
if (!m_refData || !brush.m_refData) return false;
|
M_BRUSHDATA->SetColour(wxColour(r, g, b));
|
||||||
|
}
|
||||||
return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
|
|
||||||
|
void wxBrush::SetStyle(int style)
|
||||||
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
|
M_BRUSHDATA->SetStyle(style);
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBrush::SetStipple(const wxBitmap& stipple)
|
||||||
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
|
M_BRUSHDATA->SetStipple(stipple);
|
||||||
}
|
}
|
||||||
|
@ -48,11 +48,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxPaintDC, wxWindowDC)
|
|||||||
#include "wx/tabctrl.h"
|
#include "wx/tabctrl.h"
|
||||||
|
|
||||||
|
|
||||||
static wxBrush MacGetBackgroundBrush( wxWindow* window )
|
|
||||||
{
|
|
||||||
wxBrush bkdBrush = window->MacGetBackgroundBrush() ;
|
|
||||||
return bkdBrush ;
|
|
||||||
}
|
|
||||||
|
|
||||||
wxWindowDC::wxWindowDC()
|
wxWindowDC::wxWindowDC()
|
||||||
{
|
{
|
||||||
@ -89,7 +84,7 @@ wxWindowDC::wxWindowDC(wxWindow *window)
|
|||||||
}
|
}
|
||||||
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
SetClippingRegion( 0 , 0 , m_width , m_height ) ;
|
||||||
|
|
||||||
SetBackground(MacGetBackgroundBrush(window));
|
SetBackground(wxBrush(window->GetBackgroundColour(),wxSOLID));
|
||||||
|
|
||||||
SetFont( window->GetFont() ) ;
|
SetFont( window->GetFont() ) ;
|
||||||
}
|
}
|
||||||
|
@ -79,9 +79,8 @@ bool wxDrawerWindow::Create(wxWindow *parent,
|
|||||||
if (success)
|
if (success)
|
||||||
{
|
{
|
||||||
// Use drawer brush.
|
// Use drawer brush.
|
||||||
m_macBackgroundBrush.MacSetTheme(kThemeBrushDrawerBackground);
|
SetBackgroundColour( wxColour( wxMacCreateCGColorFromHITheme( kThemeBrushDrawerBackground ) ) );
|
||||||
::SetThemeWindowBackground((WindowRef)m_macWindow,
|
::SetThemeWindowBackground((WindowRef)m_macWindow, kThemeBrushDrawerBackground, false);
|
||||||
m_macBackgroundBrush.MacGetTheme(), false);
|
|
||||||
|
|
||||||
// Leading and trailing offset are gaps from parent window edges
|
// Leading and trailing offset are gaps from parent window edges
|
||||||
// to where the drawer starts.
|
// to where the drawer starts.
|
||||||
|
@ -483,6 +483,26 @@ static const char *gs_stripedback_xpm[] = {
|
|||||||
|
|
||||||
wxBitmap gs_stripedback_bmp( wxImage( (const char* const* ) gs_stripedback_xpm ), -1 ) ;
|
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()
|
wxMacCoreGraphicsColour::~wxMacCoreGraphicsColour()
|
||||||
{
|
{
|
||||||
delete[] m_patternColorComponents;
|
delete[] m_patternColorComponents;
|
||||||
@ -519,18 +539,7 @@ wxMacCoreGraphicsColour::wxMacCoreGraphicsColour( const wxBrush &brush )
|
|||||||
Init();
|
Init();
|
||||||
if ( brush.GetStyle() == wxSOLID )
|
if ( brush.GetStyle() == wxSOLID )
|
||||||
{
|
{
|
||||||
if ( brush.MacGetBrushKind() == kwxMacBrushTheme )
|
m_color.Set( brush.GetColour().CreateCGColor() );
|
||||||
{
|
|
||||||
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 ) ) ;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else if ( brush.IsHatch() )
|
else if ( brush.IsHatch() )
|
||||||
{
|
{
|
||||||
|
@ -30,12 +30,9 @@
|
|||||||
|
|
||||||
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
||||||
{
|
{
|
||||||
int major, minor;
|
|
||||||
wxColour resultColor;
|
wxColour resultColor;
|
||||||
ThemeBrush colorBrushID;
|
ThemeBrush colorBrushID;
|
||||||
|
|
||||||
wxGetOsVersion( &major, &minor );
|
|
||||||
|
|
||||||
switch ( index )
|
switch ( index )
|
||||||
{
|
{
|
||||||
case wxSYS_COLOUR_WINDOW:
|
case wxSYS_COLOUR_WINDOW:
|
||||||
@ -55,17 +52,11 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxSYS_COLOUR_LISTBOX :
|
case wxSYS_COLOUR_LISTBOX :
|
||||||
if (major >= 10)
|
resultColor = *wxWHITE ;
|
||||||
resultColor = *wxWHITE ;
|
|
||||||
else
|
|
||||||
resultColor = wxColor( 0xEE, 0xEE, 0xEE );
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxSYS_COLOUR_BTNSHADOW:
|
case wxSYS_COLOUR_BTNSHADOW:
|
||||||
if (major >= 10)
|
resultColor = wxColor( 0xBE, 0xBE, 0xBE );
|
||||||
resultColor = wxColor( 0xBE, 0xBE, 0xBE );
|
|
||||||
else
|
|
||||||
resultColor = wxColor( 0x44, 0x44, 0x44 );
|
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
case wxSYS_COLOUR_BTNTEXT:
|
case wxSYS_COLOUR_BTNTEXT:
|
||||||
@ -85,9 +76,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
#else
|
#else
|
||||||
colorBrushID = kThemeBrushPrimaryHighlightColor;
|
colorBrushID = kThemeBrushPrimaryHighlightColor;
|
||||||
#endif
|
#endif
|
||||||
CGColorRef color ;
|
resultColor = wxColor( wxMacCreateCGColorFromHITheme(colorBrushID) );
|
||||||
HIThemeBrushCreateCGColor( colorBrushID, &color );
|
|
||||||
resultColor = wxColor( color );
|
|
||||||
}
|
}
|
||||||
break ;
|
break ;
|
||||||
|
|
||||||
@ -110,9 +99,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
|
|||||||
resultColor = *wxWHITE ;
|
resultColor = *wxWHITE ;
|
||||||
#else
|
#else
|
||||||
{
|
{
|
||||||
CGColorRef color ;
|
wxColour highlightcolor( wxMacCreateCGColorFromHITheme(kThemeBrushPrimaryHighlightColor) );
|
||||||
HIThemeBrushCreateCGColor( kThemeBrushPrimaryHighlightColor, &color );
|
|
||||||
wxColour highlightcolor( color );
|
|
||||||
if ((highlightcolor.Red() + highlightcolor.Green() + highlightcolor.Blue() ) == 0)
|
if ((highlightcolor.Red() + highlightcolor.Green() + highlightcolor.Blue() ) == 0)
|
||||||
resultColor = *wxWHITE ;
|
resultColor = *wxWHITE ;
|
||||||
else
|
else
|
||||||
|
@ -59,7 +59,7 @@ bool wxStatusBarMac::Create(wxWindow *parent, wxWindowID id,
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
|
if ( parent->MacGetTopLevelWindow()->MacGetMetalAppearance() )
|
||||||
MacSetBackgroundBrush( wxNullBrush );
|
SetBackgroundStyle( wxBG_STYLE_TRANSPARENT );
|
||||||
|
|
||||||
// normal system font is too tall for fitting into the standard height
|
// normal system font is too tall for fitting into the standard height
|
||||||
SetWindowVariant( wxWINDOW_VARIANT_SMALL );
|
SetWindowVariant( wxWINDOW_VARIANT_SMALL );
|
||||||
|
@ -961,7 +961,7 @@ bool wxTopLevelWindowMac::Create(wxWindow *parent,
|
|||||||
|
|
||||||
DoMacCreateRealWindow( parent, title, pos , size , style , name ) ;
|
DoMacCreateRealWindow( parent, title, pos , size , style , name ) ;
|
||||||
|
|
||||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
SetBackgroundColour(wxColour(wxMacCreateCGColorFromHITheme(kThemeBrushDialogBackgroundActive)));
|
||||||
|
|
||||||
if (GetExtraStyle() & wxFRAME_EX_METAL)
|
if (GetExtraStyle() & wxFRAME_EX_METAL)
|
||||||
MacSetMetalAppearance(true);
|
MacSetMetalAppearance(true);
|
||||||
@ -1063,15 +1063,18 @@ wxPoint wxTopLevelWindowMac::GetClientAreaOrigin() const
|
|||||||
return wxPoint(0, 0) ;
|
return wxPoint(0, 0) ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxTopLevelWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
bool wxTopLevelWindowMac::SetBackgroundColour(const wxColour& col )
|
||||||
{
|
{
|
||||||
wxTopLevelWindowBase::MacSetBackgroundBrush( brush ) ;
|
if ( !wxTopLevelWindowBase::SetBackgroundColour(col) && m_hasBgCol )
|
||||||
|
return false ;
|
||||||
if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT && m_macBackgroundBrush.MacGetBrushKind() == kwxMacBrushTheme )
|
|
||||||
{
|
if ( col == wxSystemSettings::GetColour( wxSYS_COLOUR_WINDOW ) )
|
||||||
SetThemeWindowBackground( (WindowRef) m_macWindow , m_macBackgroundBrush.MacGetTheme() , false ) ;
|
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)
|
void wxTopLevelWindowMacInstallTopLevelWindowEventHandler(WindowRef window, EventHandlerRef* handler, void *ref)
|
||||||
{
|
{
|
||||||
|
@ -687,7 +687,7 @@ void wxMacControl::SetFont( const wxFont & font , const wxColour& foreground , l
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxMacControl::SetBackground( const wxBrush &WXUNUSED(brush) )
|
void wxMacControl::SetBackgroundColour( const wxColour &WXUNUSED(col) )
|
||||||
{
|
{
|
||||||
// TODO
|
// TODO
|
||||||
// setting up a color proc is not recommended anymore
|
// setting up a color proc is not recommended anymore
|
||||||
@ -1895,37 +1895,6 @@ OSStatus wxMacControl::SetTabEnabled( SInt16 tabNo , bool enable )
|
|||||||
// Quartz Support
|
// 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
|
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
|
not release the returned value unless the caller retains it first. Usually callers
|
||||||
@ -1948,6 +1917,13 @@ CGColorSpaceRef wxMacGetGenericRGBColorSpace()
|
|||||||
return genericRGBColorSpace;
|
return genericRGBColorSpace;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
CGColorRef wxMacCreateCGColorFromHITheme( ThemeBrush brush )
|
||||||
|
{
|
||||||
|
CGColorRef color ;
|
||||||
|
HIThemeBrushCreateCGColor( brush, &color );
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
#ifndef __LP64__
|
#ifndef __LP64__
|
||||||
|
|
||||||
wxMacPortSaver::wxMacPortSaver( GrafPtr port )
|
wxMacPortSaver::wxMacPortSaver( GrafPtr port )
|
||||||
|
@ -924,8 +924,6 @@ void wxWindowMac::Init()
|
|||||||
m_hScrollBarAlwaysShown = false;
|
m_hScrollBarAlwaysShown = false;
|
||||||
m_vScrollBarAlwaysShown = false;
|
m_vScrollBarAlwaysShown = false;
|
||||||
|
|
||||||
m_macBackgroundBrush = wxNullBrush ;
|
|
||||||
|
|
||||||
m_macIsUserPane = true;
|
m_macIsUserPane = true;
|
||||||
m_clipChildren = false ;
|
m_clipChildren = false ;
|
||||||
m_cachedClippedRectValid = false ;
|
m_cachedClippedRectValid = false ;
|
||||||
@ -1200,28 +1198,11 @@ bool wxWindowMac::SetBackgroundColour(const wxColour& col )
|
|||||||
if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol )
|
if ( !wxWindowBase::SetBackgroundColour(col) && m_hasBgCol )
|
||||||
return false ;
|
return false ;
|
||||||
|
|
||||||
wxBrush brush ;
|
m_peer->SetBackgroundColour( col ) ;
|
||||||
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() ;
|
|
||||||
|
|
||||||
return true ;
|
return true ;
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxWindowMac::MacSetBackgroundBrush( const wxBrush &brush )
|
|
||||||
{
|
|
||||||
m_macBackgroundBrush = brush ;
|
|
||||||
m_peer->SetBackground( brush ) ;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxWindowMac::MacCanFocus() const
|
bool wxWindowMac::MacCanFocus() const
|
||||||
{
|
{
|
||||||
// TODO : evaluate performance hits by looking up this value, eventually cache the results for a 1 sec or so
|
// 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 ;
|
return ;
|
||||||
|
|
||||||
#if TARGET_API_MAC_OSX
|
#if TARGET_API_MAC_OSX
|
||||||
if ( !m_macBackgroundBrush.Ok() || m_macBackgroundBrush.GetStyle() == wxTRANSPARENT
|
if ( !m_backgroundColour.Ok() || GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
|
||||||
|| GetBackgroundStyle() == wxBG_STYLE_TRANSPARENT )
|
|
||||||
{
|
{
|
||||||
event.Skip() ;
|
event.Skip() ;
|
||||||
}
|
}
|
||||||
@ -2441,10 +2421,9 @@ void wxWindowMac::MacPaintGrowBox()
|
|||||||
CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
|
CGPoint cgpoint = CGPointMake( rect.right - size , rect.bottom - size ) ;
|
||||||
CGContextSaveGState( cgContext );
|
CGContextSaveGState( cgContext );
|
||||||
|
|
||||||
if ( m_macBackgroundBrush.Ok() && m_macBackgroundBrush.GetStyle() != wxTRANSPARENT )
|
if ( m_backgroundColour.Ok() )
|
||||||
{
|
{
|
||||||
wxMacCoreGraphicsColour bkgnd( m_macBackgroundBrush ) ;
|
CGContextSetFillColorWithColor( cgContext, m_backgroundColour.GetCGColor() );
|
||||||
bkgnd.Apply( cgContext );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user