X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/887dd52f06a985ec0455e91f4b3d2b091a1b1c7b..1978421a6d8b81c1f8a961da4b8ddf544fec7b1b:/src/gtk/colour.cpp diff --git a/src/gtk/colour.cpp b/src/gtk/colour.cpp index d4b9194145..3b148e7bd3 100644 --- a/src/gtk/colour.cpp +++ b/src/gtk/colour.cpp @@ -8,11 +8,16 @@ ///////////////////////////////////////////////////////////////////////////// -#ifdef __GNUG__ +#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "colour.h" #endif +// For compilers that support precompilation, includes "wx.h". +#include "wx/wxprec.h" + #include "wx/gdicmn.h" +#include "wx/colour.h" +#include "wx/gtk/private.h" #include #include @@ -35,6 +40,14 @@ public: m_hasPixel = FALSE; } + wxColourRefData(const wxColourRefData& data) + : wxObjectRefData() + { + m_color = data.m_color; + m_colormap = data.m_colormap; + m_hasPixel = data.m_hasPixel; + } + ~wxColourRefData() { FreeColour(); @@ -110,8 +123,8 @@ void wxColourRefData::AllocColour( GdkColormap *cmap ) FreeColour(); #ifdef __WXGTK20__ - if ((m_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (m_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) + if ( (cmap->visual->type == GDK_VISUAL_GRAYSCALE) || + (cmap->visual->type == GDK_VISUAL_PSEUDO_COLOR) ) #else GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap; if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || @@ -146,12 +159,13 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) M_COLDATA->m_color.pixel = 0; } + + void wxColour::InitFromName( const wxString &colourName ) { - wxNode *node = (wxNode *) NULL; - if ( (wxTheColourDatabase) && (node = wxTheColourDatabase->Find(colourName)) ) + wxColour* col = NULL; + if ( (wxTheColourDatabase) && (col = wxTheColourDatabase->FindColourNoAdd(colourName)) ) { - wxColour *col = (wxColour*)node->Data(); UnRef(); if (col) Ref( *col ); } @@ -159,7 +173,7 @@ void wxColour::InitFromName( const wxString &colourName ) { m_refData = new wxColourRefData(); - if (!gdk_color_parse( colourName.mb_str(), &M_COLDATA->m_color )) + if (!gdk_color_parse( wxGTK_CONV( colourName ), &M_COLDATA->m_color )) { // VZ: asserts are good in general but this one is triggered by // calling wxColourDatabase::FindColour() with an @@ -209,11 +223,13 @@ void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) { AllocExclusive(); - m_refData = new wxColourRefData(); M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT; M_COLDATA->m_color.green = ((unsigned short)green) << SHIFT; M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT; M_COLDATA->m_color.pixel = 0; + + M_COLDATA->m_colormap = (GdkColormap*) NULL; + M_COLDATA->m_hasPixel = FALSE; } unsigned char wxColour::Red() const