use wxString instead of wxChar* in wxColour::Set/FromString
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@46239 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -35,8 +35,7 @@ public:
|
|||||||
ChannelType alpha = wxALPHA_OPAQUE )
|
ChannelType alpha = wxALPHA_OPAQUE )
|
||||||
{ Init(); Set(red, green, blue, alpha); }
|
{ Init(); Set(red, green, blue, alpha); }
|
||||||
wxColour(unsigned long colRGB) { Init(); Set(colRGB); }
|
wxColour(unsigned long colRGB) { Init(); Set(colRGB); }
|
||||||
wxColour(const wxString &colourName) { Init(); Set(colourName); }
|
wxColour(const wxString& colourName) { Init(); Set(colourName); }
|
||||||
wxColour(const wxChar *colourName) { Init(); Set(colourName); }
|
|
||||||
|
|
||||||
// initialization using existing NSColor
|
// initialization using existing NSColor
|
||||||
wxColour( WX_NSColor aColor );
|
wxColour( WX_NSColor aColor );
|
||||||
@@ -80,9 +79,6 @@ public:
|
|||||||
unsigned char alpha = wxALPHA_OPAQUE)
|
unsigned char alpha = wxALPHA_OPAQUE)
|
||||||
{ wxColourBase::Set(red, green, blue, alpha); }
|
{ wxColourBase::Set(red, green, blue, alpha); }
|
||||||
|
|
||||||
bool Set(const wxChar *str)
|
|
||||||
{ return wxColourBase::Set(str); }
|
|
||||||
|
|
||||||
bool Set(const wxString &str)
|
bool Set(const wxString &str)
|
||||||
{ return wxColourBase::Set(str); }
|
{ return wxColourBase::Set(str); }
|
||||||
|
|
||||||
|
@@ -27,8 +27,7 @@ class WXDLLEXPORT wxColour;
|
|||||||
ChannelType alpha = wxALPHA_OPAQUE ) \
|
ChannelType alpha = wxALPHA_OPAQUE ) \
|
||||||
{ Set(red, green, blue, alpha); } \
|
{ Set(red, green, blue, alpha); } \
|
||||||
wxColour( unsigned long colRGB ) { Set(colRGB); } \
|
wxColour( unsigned long colRGB ) { Set(colRGB); } \
|
||||||
wxColour(const wxString &colourName) { Set(colourName); } \
|
wxColour(const wxString& colourName) { Set(colourName); }
|
||||||
wxColour(const wxChar *colourName) { Set(colourName); }
|
|
||||||
|
|
||||||
|
|
||||||
// flags for wxColour -> wxString conversion (see wxColour::GetAsString)
|
// flags for wxColour -> wxString conversion (see wxColour::GetAsString)
|
||||||
@@ -74,9 +73,6 @@ public:
|
|||||||
{ InitRGBA(red,green,blue, alpha); }
|
{ InitRGBA(red,green,blue, alpha); }
|
||||||
|
|
||||||
// implemented in colourcmn.cpp
|
// implemented in colourcmn.cpp
|
||||||
bool Set(const wxChar *str)
|
|
||||||
{ return FromString(str); }
|
|
||||||
|
|
||||||
bool Set(const wxString &str)
|
bool Set(const wxString &str)
|
||||||
{ return FromString(str); }
|
{ return FromString(str); }
|
||||||
|
|
||||||
@@ -120,7 +116,7 @@ protected:
|
|||||||
virtual void
|
virtual void
|
||||||
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
|
InitRGBA(ChannelType r, ChannelType g, ChannelType b, ChannelType a) = 0;
|
||||||
|
|
||||||
virtual bool FromString(const wxChar *s);
|
virtual bool FromString(const wxString& s);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
@@ -53,7 +53,7 @@ protected:
|
|||||||
virtual void
|
virtual void
|
||||||
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
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:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxColour)
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
||||||
|
@@ -43,7 +43,7 @@ public:
|
|||||||
|
|
||||||
virtual ~wxColour();
|
virtual ~wxColour();
|
||||||
|
|
||||||
virtual bool FromString(const wxChar *str);
|
virtual bool FromString(const wxString& str);
|
||||||
|
|
||||||
bool Ok() const { return IsOk(); }
|
bool Ok() const { return IsOk(); }
|
||||||
bool IsOk() const { return m_refData != NULL; }
|
bool IsOk() const { return m_refData != NULL; }
|
||||||
|
@@ -68,7 +68,7 @@ protected:
|
|||||||
virtual void
|
virtual void
|
||||||
InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
|
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:
|
private:
|
||||||
DECLARE_DYNAMIC_CLASS(wxColour)
|
DECLARE_DYNAMIC_CLASS(wxColour)
|
||||||
|
@@ -34,9 +34,9 @@ IMPLEMENT_VARIANT_OBJECT_EXPORTED(wxColour,WXDLLEXPORT)
|
|||||||
// wxString <-> wxColour conversions
|
// 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
|
return false; // invalid or empty string
|
||||||
|
|
||||||
if ( wxStrncmp(str, wxT("RGB"), 3) == 0 ||
|
if ( wxStrncmp(str, wxT("RGB"), 3) == 0 ||
|
||||||
@@ -46,7 +46,7 @@ bool wxColourBase::FromString(const wxChar *str)
|
|||||||
// according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units
|
// according to http://www.w3.org/TR/REC-CSS2/syndata.html#color-units
|
||||||
// values outside 0-255 range are allowed but should be clipped
|
// values outside 0-255 range are allowed but should be clipped
|
||||||
int red, green, blue;
|
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;
|
return false;
|
||||||
|
|
||||||
Set((unsigned char)wxClip(red,0,255),
|
Set((unsigned char)wxClip(red,0,255),
|
||||||
@@ -57,7 +57,7 @@ bool wxColourBase::FromString(const wxChar *str)
|
|||||||
{
|
{
|
||||||
// hexadecimal prefixed with # (HTML syntax)
|
// hexadecimal prefixed with # (HTML syntax)
|
||||||
unsigned long tmp;
|
unsigned long tmp;
|
||||||
if (wxSscanf(&str[1], wxT("%lx"), &tmp) != 1)
|
if (wxSscanf(str.substr(1), wxT("%lx"), &tmp) != 1)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
Set((unsigned char)(tmp >> 16),
|
Set((unsigned char)(tmp >> 16),
|
||||||
|
@@ -180,7 +180,7 @@ const GdkColor *wxColour::GetColor() const
|
|||||||
return &M_COLDATA->m_color;
|
return &M_COLDATA->m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxColour::FromString(const wxChar *str)
|
bool wxColour::FromString(const wxString& str)
|
||||||
{
|
{
|
||||||
GdkColor colGDK;
|
GdkColor colGDK;
|
||||||
if ( gdk_color_parse( wxGTK_CONV_SYS( str ), &colGDK ) )
|
if ( gdk_color_parse( wxGTK_CONV_SYS( str ), &colGDK ) )
|
||||||
|
@@ -225,10 +225,10 @@ GdkColor *wxColour::GetColor() const
|
|||||||
return &M_COLDATA->m_color;
|
return &M_COLDATA->m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxColour::FromString(const wxChar *str)
|
bool wxColour::FromString(const wxString& str)
|
||||||
{
|
{
|
||||||
GdkColor colGDK;
|
GdkColor colGDK;
|
||||||
if ( gdk_color_parse( str, &colGDK ) )
|
if ( gdk_color_parse( wxGTK_CONV(str), &colGDK ) )
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
|
@@ -245,12 +245,12 @@ WXColor *wxColour::GetColor() const
|
|||||||
return (WXColor*) &M_COLDATA->m_color;
|
return (WXColor*) &M_COLDATA->m_color;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxColour::FromString(const wxChar *name)
|
bool wxColour::FromString(const wxString& name)
|
||||||
{
|
{
|
||||||
Display *dpy = wxGlobalDisplay();
|
Display *dpy = wxGlobalDisplay();
|
||||||
WXColormap colormap = wxTheApp->GetMainColormap( dpy );
|
WXColormap colormap = wxTheApp->GetMainColormap( dpy );
|
||||||
XColor xcol;
|
XColor xcol;
|
||||||
if ( XParseColor( dpy, (Colormap)colormap, wxConvertWX2MB(name), &xcol ) )
|
if ( XParseColor( dpy, (Colormap)colormap, name.mbc_str(), &xcol ) )
|
||||||
{
|
{
|
||||||
UnRef();
|
UnRef();
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user