X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/0b5c0e1ac19ac7520dea4477c581dd538e1815b6..e777924b358ae352f30881249f681ebb7a3ce089:/src/x11/colour.cpp diff --git a/src/x11/colour.cpp b/src/x11/colour.cpp index dfe438e1c4..e10c2f486b 100644 --- a/src/x11/colour.cpp +++ b/src/x11/colour.cpp @@ -35,6 +35,13 @@ public: m_colormap = (WXColormap *) NULL; m_hasPixel = FALSE; } + wxColourRefData(const wxColourRefData& data): + wxObjectRefData() + { + m_color = data.m_color; + m_colormap = data.m_colormap; + m_hasPixel = data.m_hasPixel; + } ~wxColourRefData() { @@ -83,20 +90,19 @@ unsigned short wxColourRefData::colMapAllocCounter[ 256 ] = void wxColourRefData::FreeColour() { -#if 0 - if (m_colormap) + if (!m_colormap) + return; +#if !wxUSE_NANOX + if ((wxTheApp->m_visualType == GrayScale) || + (wxTheApp->m_visualType == PseudoColor)) { - Colormap cm = (Colormap)m_colormap; - - GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) m_colormap; - if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) - { - int idx = m_color.pixel; - colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1; + int idx = m_color.pixel; + colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1; - if (colMapAllocCounter[ idx ] == 0) - gdk_colormap_free_colors( m_colormap, &m_color, 1 ); + if (colMapAllocCounter[ idx ] == 0) + { + unsigned long pixel = m_color.pixel; + XFreeColors( wxGlobalDisplay(), (Colormap) m_colormap, &pixel, 1, 0 ); } } #endif @@ -109,12 +115,11 @@ void wxColourRefData::AllocColour( WXColormap cmap ) FreeColour(); -#if 0 - GdkColormapPrivate *private_colormap = (GdkColormapPrivate*) cmap; - if ((private_colormap->visual->type == GDK_VISUAL_GRAYSCALE) || - (private_colormap->visual->type == GDK_VISUAL_PSEUDO_COLOR)) +#if !wxUSE_NANOX + if ((wxTheApp->m_visualType == GrayScale) || + (wxTheApp->m_visualType == PseudoColor)) { - m_hasPixel = gdk_colormap_alloc_color( cmap, &m_color, FALSE, TRUE ); + m_hasPixel = XAllocColor( wxGlobalDisplay(), (Colormap) cmap, &m_color ); int idx = m_color.pixel; colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] + 1; } @@ -123,6 +128,7 @@ void wxColourRefData::AllocColour( WXColormap cmap ) { m_hasPixel = XAllocColor( wxGlobalDisplay(), (Colormap) cmap, &m_color ); } + m_colormap = cmap; }