m_red = the_colour->Red ();
m_green = the_colour->Green ();
m_blue = the_colour->Blue ();
+ m_pixel = the_colour->m_pixel;
m_isInit = TRUE;
}
else
m_blue = 0;
m_isInit = FALSE;
}
-/* TODO
- m_pixel = PALETTERGB (m_red, m_green, m_blue);
-*/
}
wxColour::~wxColour ()
m_red = the_colour->Red ();
m_green = the_colour->Green ();
m_blue = the_colour->Blue ();
+ m_pixel = the_colour->m_pixel;
m_isInit = TRUE;
}
else
m_blue = 0;
m_isInit = FALSE;
}
-/* TODO
- m_pixel = PALETTERGB (m_red, m_green, m_blue);
-*/
+
return (*this);
}
m_green = g;
m_blue = b;
m_isInit = TRUE;
-/* TODO
- m_pixel = PALETTERGB (m_red, m_green, m_blue);
-*/
+ m_pixel = -1;
}
// Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return
// the existing one.
-// Returns FALSE if an exact match was not found, TRUE otherwise.
+// Returns the old or allocated pixel.
// TODO: can this handle mono displays? If not, we should have an extra
// flag to specify whether this should be black or white by default.
-bool wxColour::AllocColour(WXDisplay* display, bool realloc)
+int wxColour::AllocColour(WXDisplay* display, bool realloc)
{
if ((m_pixel != -1) && !realloc)
- return TRUE;
+ return m_pixel;
XColor color;
color.red = (unsigned short) Red ();
if (!XAllocColor ((Display*) display, (Colormap) cmap, &color))
{
m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
- return FALSE;
+ return m_pixel;
}
else
{
m_pixel = (int) color.pixel;
- return TRUE;
+ return m_pixel;
}
}