From: Mattia Barbon Date: Thu, 23 Oct 2003 21:49:44 +0000 (+0000) Subject: Suboptimal wxColour::CreateByName implementation for wxMotif. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/c0a83c519b566f9a306990cfc8275e512352628f?ds=inline Suboptimal wxColour::CreateByName implementation for wxMotif. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24279 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/include/wx/motif/colour.h b/include/wx/motif/colour.h index b478f37b19..1d60215d65 100644 --- a/include/wx/motif/colour.h +++ b/include/wx/motif/colour.h @@ -66,7 +66,10 @@ public: inline bool operator == (const wxColour& colour) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); } inline bool operator != (const wxColour& colour) const { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); } - + + // Get colour from name or wxNullColour + static wxColour CreateByName(const wxString& name); + // Allocate a colour, or nearest colour, using the given display. // If realloc is TRUE, ignore the existing pixel, otherwise just return // the existing one. diff --git a/src/motif/colour.cpp b/src/motif/colour.cpp index ee95c0a045..b77ec7a38b 100644 --- a/src/motif/colour.cpp +++ b/src/motif/colour.cpp @@ -63,6 +63,26 @@ void wxColour::InitFromName(const wxString& name) *this = wxTheColourDatabase->Find(name); } +/* static */ +wxColour wxColour::CreateByName(const wxString& name) +{ + wxColour col; + + Display *dpy = wxGlobalDisplay(); + WXColormap colormap = wxTheApp->GetMainColormap( dpy ); + XColor xcol; + if ( XParseColor( dpy, (Colormap)colormap, name.mb_str(), &xcol ) ) + { + col.m_red = xcol.red & 0xff; + col.m_green = xcol.green & 0xff; + col.m_blue = xcol.blue & 0xff; + col.m_isInit = TRUE; + col.m_pixel = -1; + } + + return col; +} + wxColour::~wxColour () { }