ChannelType alpha = wxALPHA_OPAQUE )
{ Init(); Set(red, green, blue, alpha); }
wxColour(unsigned long colRGB) { Init(); Set(colRGB); }
- wxColour(const wxString &colourName) { Init(); Set(colourName); }
- wxColour(const wxChar *colourName) { Init(); Set(colourName); }
+ wxColour(const wxString& colourName) { Init(); Set(colourName); }
// initialization using existing NSColor
wxColour( WX_NSColor aColor );
unsigned char alpha = wxALPHA_OPAQUE)
{ wxColourBase::Set(red, green, blue, alpha); }
- bool Set(const wxChar *str)
- { return wxColourBase::Set(str); }
-
bool Set(const wxString &str)
{ return wxColourBase::Set(str); }
ChannelType alpha = wxALPHA_OPAQUE ) \
{ Set(red, green, blue, alpha); } \
wxColour( unsigned long colRGB ) { Set(colRGB); } \
- wxColour(const wxString &colourName) { Set(colourName); } \
- wxColour(const wxChar *colourName) { Set(colourName); }
+ wxColour(const wxString& colourName) { Set(colourName); }
// flags for wxColour -> wxString conversion (see wxColour::GetAsString)
{ InitRGBA(red,green,blue, alpha); }
// implemented in colourcmn.cpp
- bool Set(const wxChar *str)
- { return FromString(str); }
-
bool Set(const wxString &str)
{ return FromString(str); }
virtual void
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
- virtual bool FromString(const wxChar *s);
+ virtual bool FromString(const wxString& s);
};
virtual void
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
- virtual bool FromString(const wxChar *str);
+ virtual bool FromString(const wxString& str);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
virtual ~wxColour();
- virtual bool FromString(const wxChar *str);
+ virtual bool FromString(const wxString& str);
bool Ok() const { return IsOk(); }
bool IsOk() const { return m_refData != NULL; }
virtual void
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
- virtual bool FromString(const wxChar *str);
+ virtual bool FromString(const wxString& str);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
// wxString <-> wxColour conversions
// ============================================================================
-bool wxColourBase::FromString(const wxChar *str)
+bool wxColourBase::FromString(const wxString& str)
{
- if ( str == NULL || str[0] == wxT('\0'))
+ if ( str.empty() )
return false; // invalid or empty string
if ( wxStrncmp(str, wxT("RGB"), 3) == 0 ||
// according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units
// values outside 0-255 range are allowed but should be clipped
int red, green, blue;
- if (wxSscanf(&str[3], wxT("(%d, %d, %d)"), &red, &green, &blue) != 3)
+ if (wxSscanf(str.substr(3), wxT("(%d, %d, %d)"), &red, &green, &blue) != 3)
return false;
Set((unsigned char)wxClip(red,0,255),
{
// hexadecimal prefixed with # (HTML syntax)
unsigned long tmp;
- if (wxSscanf(&str[1], wxT("%lx"), &tmp) != 1)
+ if (wxSscanf(str.substr(1), wxT("%lx"), &tmp) != 1)
return false;
Set((unsigned char)(tmp >> 16),
return &M_COLDATA->m_color;
}
-bool wxColour::FromString(const wxChar *str)
+bool wxColour::FromString(const wxString& str)
{
GdkColor colGDK;
if ( gdk_color_parse( wxGTK_CONV_SYS( str ), &colGDK ) )
return &M_COLDATA->m_color;
}
-bool wxColour::FromString(const wxChar *str)
+bool wxColour::FromString(const wxString& str)
{
GdkColor colGDK;
- if ( gdk_color_parse( str, &colGDK ) )
+ if ( gdk_color_parse( wxGTK_CONV(str), &colGDK ) )
{
UnRef();
return (WXColor*) &M_COLDATA->m_color;
}
-bool wxColour::FromString(const wxChar *name)
+bool wxColour::FromString(const wxString& name)
{
Display *dpy = wxGlobalDisplay();
WXColormap colormap = wxTheApp->GetMainColormap( dpy );
XColor xcol;
- if ( XParseColor( dpy, (Colormap)colormap, wxConvertWX2MB(name), &xcol ) )
+ if ( XParseColor( dpy, (Colormap)colormap, name.mbc_str(), &xcol ) )
{
UnRef();