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/object.h"
 | 
				
			||||||
#include "wx/string.h"
 | 
					#include "wx/string.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					struct RGBColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// Colour
 | 
					// Colour
 | 
				
			||||||
class WXDLLEXPORT wxColour: public wxColourBase
 | 
					class WXDLLEXPORT wxColour: public wxColourBase
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
@@ -51,6 +53,10 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    const WXCOLORREF& GetPixel() const { return m_pixel; };
 | 
					    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 :
 | 
					protected :
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // Helper function
 | 
					    // Helper function
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -185,7 +185,7 @@ void wxBrush::MacSetTheme(ThemeBrush macThemeBrush)
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
    RGBColor color ;
 | 
					    RGBColor color ;
 | 
				
			||||||
    GetThemeBrushAsColor( macThemeBrush , 32, true, &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();
 | 
					    RealizeResource();
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -68,7 +68,7 @@ int wxColourDialog::ShowModal()
 | 
				
			|||||||
        currentColor.red = info.theColor.color.rgb.red ;
 | 
					        currentColor.red = info.theColor.color.rgb.red ;
 | 
				
			||||||
        currentColor.green = info.theColor.color.rgb.green ;
 | 
					        currentColor.green = info.theColor.color.rgb.green ;
 | 
				
			||||||
        currentColor.blue = info.theColor.color.rgb.blue ;
 | 
					        currentColor.blue = info.theColor.color.rgb.blue ;
 | 
				
			||||||
        m_colourData.m_dataColour.FromRGBColor((WXCOLORREF*) ¤tColor);
 | 
					        m_colourData.m_dataColour = currentColor;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        return wxID_OK;
 | 
					        return wxID_OK;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -21,7 +21,11 @@
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
 | 
					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 )
 | 
					static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    RGBColor* col = (RGBColor*) color;
 | 
					    RGBColor* col = (RGBColor*) color;
 | 
				
			||||||
@@ -64,6 +68,11 @@ void wxColour::FromRGBColor( WXCOLORREF* color )
 | 
				
			|||||||
    m_green = col->green >> 8;
 | 
					    m_green = col->green >> 8;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					wxColour& wxColour::operator=(const RGBColor& col)
 | 
				
			||||||
 | 
					{
 | 
				
			||||||
 | 
					    FromRGBColor((WXCOLORREF *)&col);
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
bool wxColour::IsOk() const 
 | 
					bool wxColour::IsOk() const 
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    return m_isInit; 
 | 
					    return m_isInit; 
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -746,7 +746,7 @@ bool wxDC::DoGetPixel( wxCoord x, wxCoord y, wxColour *col ) const
 | 
				
			|||||||
    GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
 | 
					    GetCPixel( XLOG2DEVMAC(x), YLOG2DEVMAC(y), &colour );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    // convert from Mac colour to wx
 | 
					    // convert from Mac colour to wx
 | 
				
			||||||
    col->Set( colour.red >> 8, colour.green >> 8, colour.blue >> 8);
 | 
					    *col = colour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return true ;
 | 
					    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 );
 | 
					        YLOG2DEVMAC(y) + m_macLocalOriginInPort.y - m_macLocalOrigin.y, &colour );
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
    // convert from Mac colour to wx
 | 
					    // convert from Mac colour to wx
 | 
				
			||||||
    col->Set( colour.red >> 8, colour.green >> 8, colour.blue >> 8 );
 | 
					    *col = colour;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    return true ;
 | 
					    return true ;
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -125,7 +125,9 @@ pascal OSStatus wxMacCarbonFontPanelHandler(EventHandlerCallRef nextHandler, Eve
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
            RGBColor fontColor ;
 | 
					            RGBColor fontColor ;
 | 
				
			||||||
            if ( cEvent.GetParameter<RGBColor>(kEventParamFontColor, &fontColor) == noErr )
 | 
					            if ( cEvent.GetParameter<RGBColor>(kEventParamFontColor, &fontColor) == noErr )
 | 
				
			||||||
                fontdata.m_fontColour.FromRGBColor((WXCOLORREF*) &fontColor);
 | 
					            {
 | 
				
			||||||
 | 
					                fontdata.m_fontColour = fontColor;
 | 
				
			||||||
 | 
					            }
 | 
				
			||||||
            else
 | 
					            else
 | 
				
			||||||
            {
 | 
					            {
 | 
				
			||||||
                CFDictionaryRef dict ;
 | 
					                CFDictionaryRef dict ;
 | 
				
			||||||
@@ -150,7 +152,7 @@ pascal OSStatus wxMacCarbonFontPanelHandler(EventHandlerCallRef nextHandler, Eve
 | 
				
			|||||||
                            {
 | 
					                            {
 | 
				
			||||||
                                if ( tagPtr[i] == kATSUColorTag && sizePtr[i] == sizeof(RGBColor))
 | 
					                                if ( tagPtr[i] == kATSUColorTag && sizePtr[i] == sizeof(RGBColor))
 | 
				
			||||||
                                {
 | 
					                                {
 | 
				
			||||||
                                    fontdata.m_fontColour.FromRGBColor((WXCOLORREF*) valuesPtr);
 | 
					                                    fontdata.m_fontColour.FromRGBColor(*(RGBColor *)valuesPtr);
 | 
				
			||||||
                                    break ;
 | 
					                                    break ;
 | 
				
			||||||
                                }
 | 
					                                }
 | 
				
			||||||
                                bytePtr = (UInt32*)( (UInt8*)bytePtr + sizePtr[i]);
 | 
					                                bytePtr = (UInt32*)( (UInt8*)bytePtr + sizePtr[i]);
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -370,16 +370,16 @@ wxRendererMac::DrawItemSelectionRect(wxWindow *win,
 | 
				
			|||||||
                                     const wxRect& rect,
 | 
					                                     const wxRect& rect,
 | 
				
			||||||
                                     int flags )
 | 
					                                     int flags )
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
    RGBColor selColor;
 | 
					    if ( !(flags & wxCONTROL_SELECTED) )
 | 
				
			||||||
    if (flags & wxCONTROL_SELECTED)
 | 
					        return;
 | 
				
			||||||
    {
 | 
					 | 
				
			||||||
        if (flags & wxCONTROL_FOCUSED)
 | 
					 | 
				
			||||||
            GetThemeBrushAsColor(kThemeBrushAlternatePrimaryHighlightColor, 32, true, &selColor);
 | 
					 | 
				
			||||||
        else
 | 
					 | 
				
			||||||
            GetThemeBrushAsColor(kThemeBrushSecondaryHighlightColor, 32, true, &selColor);
 | 
					 | 
				
			||||||
    }
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
    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.SetPen( *wxTRANSPARENT_PEN );
 | 
				
			||||||
    dc.SetBrush( selBrush );
 | 
					    dc.SetBrush( selBrush );
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -88,7 +88,7 @@ wxColour wxSystemSettingsNative::GetColour(wxSystemColour index)
 | 
				
			|||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
 | 
					            GetThemeBrushAsColor( colorBrushID, 32, true, &macRGB );
 | 
				
			||||||
            resultColor = wxColor( macRGB.red >> 8, macRGB.green >> 8, macRGB.blue >> 8 );
 | 
					            resultColor = wxColor( macRGB );
 | 
				
			||||||
            break ;
 | 
					            break ;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        case wxSYS_COLOUR_BTNHIGHLIGHT:
 | 
					        case wxSYS_COLOUR_BTNHIGHLIGHT:
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user