added wxColour(RGBColor) ctor and use it insteaf of constructing wxColour from RGBColor manually in several places (replaces patch 1662064)
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44710 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
		@@ -15,6 +15,8 @@
 | 
			
		||||
#include "wx/object.h"
 | 
			
		||||
#include "wx/string.h"
 | 
			
		||||
 | 
			
		||||
struct RGBColor;
 | 
			
		||||
 | 
			
		||||
// Colour
 | 
			
		||||
class WXDLLEXPORT wxColour: public wxColourBase
 | 
			
		||||
{
 | 
			
		||||
@@ -51,6 +53,10 @@ public:
 | 
			
		||||
 | 
			
		||||
    const WXCOLORREF& GetPixel() const { return m_pixel; };
 | 
			
		||||
 | 
			
		||||
    // Mac-specific ctor and assignment operator from the native colour
 | 
			
		||||
    wxColour(const RGBColor& col);
 | 
			
		||||
    wxColour& operator=(const RGBColor& col);
 | 
			
		||||
 | 
			
		||||
protected :
 | 
			
		||||
 | 
			
		||||
    // Helper function
 | 
			
		||||
 
 | 
			
		||||
@@ -185,7 +185,7 @@ void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
 | 
			
		||||
 | 
			
		||||
    RGBColor color ;
 | 
			
		||||
    GetThemeBrushAsColor( macThemeBrush , 32, true, &color );
 | 
			
		||||
    M_BRUSHDATA->m_colour.Set( color.red >> 8 , color.green >> 8 , color.blue >> 8 );
 | 
			
		||||
    M_BRUSHDATA->m_colour = color;
 | 
			
		||||
 | 
			
		||||
    RealizeResource();
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -68,7 +68,7 @@ int wxColourDialog::ShowModal()
 | 
			
		||||
        currentColor.red = info.theColor.color.rgb.red ;
 | 
			
		||||
        currentColor.green = info.theColor.color.rgb.green ;
 | 
			
		||||
        currentColor.blue = info.theColor.color.rgb.blue ;
 | 
			
		||||
        m_colourData.m_dataColour.FromRGBColor((WXCOLORREF*) ¤tColor);
 | 
			
		||||
        m_colourData.m_dataColour = currentColor;
 | 
			
		||||
 | 
			
		||||
        return wxID_OK;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -21,7 +21,11 @@
 | 
			
		||||
 | 
			
		||||
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
 | 
			
		||||
 | 
			
		||||
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green );
 | 
			
		||||
wxColour::wxColour(const RGBColor& col)
 | 
			
		||||
{
 | 
			
		||||
    FromRGBColor((WXCOLORREF *)&col);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
 | 
			
		||||
{
 | 
			
		||||
    RGBColor* col = (RGBColor*) color;
 | 
			
		||||
@@ -64,6 +68,11 @@ void wxColour::FromRGBColor( WXCOLORREF* color )
 | 
			
		||||
    m_green = col->green >> 8;
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
wxColour& wxColour::operator=(const RGBColor& col)
 | 
			
		||||
{
 | 
			
		||||
    FromRGBColor((WXCOLORREF *)&col);
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
bool wxColour::IsOk() const 
 | 
			
		||||
{
 | 
			
		||||
    return m_isInit; 
 | 
			
		||||
 
 | 
			
		||||
@@ -746,7 +746,7 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
 | 
			
		||||
    GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
 | 
			
		||||
 | 
			
		||||
    // convert from Mac colour to wx
 | 
			
		||||
    col->Set( colour.red >> 8, colour.green >> 8, colour.blue >> 8);
 | 
			
		||||
    *col = colour;
 | 
			
		||||
 | 
			
		||||
    return true ;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1593,7 +1593,7 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
 | 
			
		||||
        YLOG2DEVMAC(y) + m_macLocalOriginInPort.y - m_macLocalOrigin.y, &colour );
 | 
			
		||||
#endif
 | 
			
		||||
    // convert from Mac colour to wx
 | 
			
		||||
    col->Set( colour.red >> 8, colour.green >> 8, colour.blue >> 8 );
 | 
			
		||||
    *col = colour;
 | 
			
		||||
 | 
			
		||||
    return true ;
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -125,7 +125,9 @@ pascal OSStatus wxMacCarbonFontPanelHandler(EventHandlerCallRef nextHandler, Eve
 | 
			
		||||
 | 
			
		||||
            RGBColor fontColor ;
 | 
			
		||||
            if ( cEvent.GetParameter<RGBColor>(kEventParamFontColor, &fontColor) == noErr )
 | 
			
		||||
                fontdata.m_fontColour.FromRGBColor((WXCOLORREF*) &fontColor);
 | 
			
		||||
            {
 | 
			
		||||
                fontdata.m_fontColour = fontColor;
 | 
			
		||||
            }
 | 
			
		||||
            else
 | 
			
		||||
            {
 | 
			
		||||
                CFDictionaryRef dict ;
 | 
			
		||||
@@ -150,7 +152,7 @@ pascal OSStatus wxMacCarbonFontPanelHandler(EventHandlerCallRef nextHandler, Eve
 | 
			
		||||
                            {
 | 
			
		||||
                                if ( tagPtr[i] == kATSUColorTag && sizePtr[i] == sizeof(RGBColor))
 | 
			
		||||
                                {
 | 
			
		||||
                                    fontdata.m_fontColour.FromRGBColor((WXCOLORREF*) valuesPtr);
 | 
			
		||||
                                    fontdata.m_fontColour.FromRGBColor(*(RGBColor *)valuesPtr);
 | 
			
		||||
                                    break ;
 | 
			
		||||
                                }
 | 
			
		||||
                                bytePtr = (UInt32*)( (UInt8*)bytePtr + sizePtr[i]);
 | 
			
		||||
 
 | 
			
		||||
@@ -370,16 +370,16 @@ wxRendererMac::DrawItemSelectionRect(wxWindow *win,
 | 
			
		||||
                                     const wxRect& rect,
 | 
			
		||||
                                     int flags )
 | 
			
		||||
{
 | 
			
		||||
    RGBColor selColor;
 | 
			
		||||
    if (flags & wxCONTROL_SELECTED)
 | 
			
		||||
    {
 | 
			
		||||
        if (flags & wxCONTROL_FOCUSED)
 | 
			
		||||
            GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &selColor);
 | 
			
		||||
        else
 | 
			
		||||
            GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &selColor);
 | 
			
		||||
    }
 | 
			
		||||
    if ( !(flags & wxCONTROL_SELECTED) )
 | 
			
		||||
        return;
 | 
			
		||||
 | 
			
		||||
    wxBrush selBrush = wxBrush( wxColour( selColor.red, selColor.green, selColor.blue ), wxSOLID );
 | 
			
		||||
    RGBColor selColor;
 | 
			
		||||
    GetThemeBrushAsColor(flags & wxCONTROL_FOCUSED
 | 
			
		||||
                            ? kThemeBrushAlternatePrimaryHighlightColor
 | 
			
		||||
                            : kThemeBrushSecondaryHighlightColor,
 | 
			
		||||
                         32, true, &selColor);
 | 
			
		||||
 | 
			
		||||
    wxBrush selBrush(selColor);
 | 
			
		||||
 | 
			
		||||
    dc.SetPen( *wxTRANSPARENT_PEN );
 | 
			
		||||
    dc.SetBrush( selBrush );
 | 
			
		||||
 
 | 
			
		||||
@@ -88,7 +88,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 | 
			
		||||
#endif
 | 
			
		||||
 | 
			
		||||
            GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
 | 
			
		||||
            resultColor = wxColor( macRGB.red >> 8, macRGB.green >> 8, macRGB.blue >> 8 );
 | 
			
		||||
            resultColor = wxColor( macRGB );
 | 
			
		||||
            break ;
 | 
			
		||||
 | 
			
		||||
        case wxSYS_COLOUR_BTNHIGHLIGHT:
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user