wxColour(const char *) ctor related modifications

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@886 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
1998-10-20 14:35:22 +00:00
parent 9c1f7241c0
commit e4a81a2e96
35 changed files with 222 additions and 533 deletions

View File

@@ -15,5 +15,7 @@
#include "wx/stubs/colour.h"
#endif
#define wxColor wxColour
#endif
// _WX_COLOUR_H_BASE_

View File

@@ -199,7 +199,6 @@ class WXDLLEXPORT wxPenList: public wxList
void AddPen(wxPen *pen);
void RemovePen(wxPen *pen);
wxPen *FindOrCreatePen(const wxColour& colour, int width, int style);
wxPen *FindOrCreatePen(const wxString& colour, int width, int style);
};
class WXDLLEXPORT wxBrushList: public wxList
@@ -212,7 +211,6 @@ class WXDLLEXPORT wxBrushList: public wxList
void AddBrush(wxBrush *brush);
void RemoveBrush(wxBrush *brush);
wxBrush *FindOrCreateBrush(const wxColour& colour, int style);
wxBrush *FindOrCreateBrush(const wxString& colour, int style);
};
WXDLLEXPORT_DATA(extern const char*) wxEmptyString;

View File

@@ -40,7 +40,6 @@ class wxBrush: public wxGDIObject
wxBrush(void);
wxBrush( const wxColour &colour, int style );
wxBrush( const wxString &colourName, int style );
wxBrush( const wxBitmap &stippleBitmap );
wxBrush( const wxBrush &brush );
wxBrush( const wxBrush *brush );
@@ -56,7 +55,6 @@ class wxBrush: public wxGDIObject
void SetColour( const wxColour& col );
void SetColour( const wxString& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
void SetStipple( const wxBitmap& stipple );

View File

@@ -39,43 +39,46 @@ class wxColour;
class wxColour: public wxGDIObject
{
public:
public:
// ctors
// default
wxColour();
// from RGB
wxColour( char red, char green, char blue );
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
wxColour();
wxColour( char red, char green, char blue );
wxColour( const wxString &colourName ) { InitFromName(colourName); }
// wxColour( const char *colourName ) { InitFromName(colourName); }
wxColour( const wxColour& col );
wxColour( const wxColour* col );
~wxColour();
wxColour& operator = ( const wxColour& col );
wxColour& operator = ( const wxString& colourName );
bool operator == ( const wxColour& col );
bool operator != ( const wxColour& col );
void Set( const unsigned char red, const unsigned char green, const unsigned char blue );
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
private:
public:
// dtor
~wxColour();
friend wxDC;
friend wxPaintDC;
friend wxBitmap;
friend wxWindow;
// comparison
bool operator == ( const wxColour& col );
bool operator != ( const wxColour& col );
// accessors
void Set( unsigned char red, unsigned char green, unsigned char blue );
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
// implementation
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
protected:
// helper functions
void InitFromName(const wxString& colourName);
// helper functions
void InitFromName(const wxString& colourName);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
DECLARE_DYNAMIC_CLASS(wxColour)
};
#endif // __GTKCOLOURH__

View File

@@ -40,7 +40,6 @@ class wxPen: public wxGDIObject
wxPen(void);
wxPen( const wxColour &colour, int width, int style );
wxPen( const wxString &colourName, int width, int style );
wxPen( const wxPen& pen );
wxPen( const wxPen* pen );
~wxPen(void);
@@ -49,7 +48,6 @@ class wxPen: public wxGDIObject
bool operator != ( const wxPen& pen );
void SetColour( const wxColour &colour );
void SetColour( const wxString &colourName );
void SetColour( int red, int green, int blue );
void SetCap( int capStyle );
void SetJoin( int joinStyle );

View File

@@ -40,7 +40,6 @@ class wxBrush: public wxGDIObject
wxBrush(void);
wxBrush( const wxColour &colour, int style );
wxBrush( const wxString &colourName, int style );
wxBrush( const wxBitmap &stippleBitmap );
wxBrush( const wxBrush &brush );
wxBrush( const wxBrush *brush );
@@ -56,7 +55,6 @@ class wxBrush: public wxGDIObject
void SetColour( const wxColour& col );
void SetColour( const wxString& col );
void SetColour( unsigned char r, unsigned char g, unsigned char b );
void SetStyle( int style );
void SetStipple( const wxBitmap& stipple );

View File

@@ -39,43 +39,46 @@ class wxColour;
class wxColour: public wxGDIObject
{
public:
public:
// ctors
// default
wxColour();
// from RGB
wxColour( char red, char green, char blue );
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
wxColour();
wxColour( char red, char green, char blue );
wxColour( const wxString &colourName ) { InitFromName(colourName); }
// wxColour( const char *colourName ) { InitFromName(colourName); }
wxColour( const wxColour& col );
wxColour( const wxColour* col );
~wxColour();
wxColour& operator = ( const wxColour& col );
wxColour& operator = ( const wxString& colourName );
bool operator == ( const wxColour& col );
bool operator != ( const wxColour& col );
void Set( const unsigned char red, const unsigned char green, const unsigned char blue );
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
private:
public:
// dtor
~wxColour();
friend wxDC;
friend wxPaintDC;
friend wxBitmap;
friend wxWindow;
// comparison
bool operator == ( const wxColour& col );
bool operator != ( const wxColour& col );
// accessors
void Set( unsigned char red, unsigned char green, unsigned char blue );
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
// implementation
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
protected:
// helper functions
void InitFromName(const wxString& colourName);
// helper functions
void InitFromName(const wxString& colourName);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
DECLARE_DYNAMIC_CLASS(wxColour)
};
#endif // __GTKCOLOURH__

View File

@@ -40,7 +40,6 @@ class wxPen: public wxGDIObject
wxPen(void);
wxPen( const wxColour &colour, int width, int style );
wxPen( const wxString &colourName, int width, int style );
wxPen( const wxPen& pen );
wxPen( const wxPen* pen );
~wxPen(void);
@@ -49,7 +48,6 @@ class wxPen: public wxGDIObject
bool operator != ( const wxPen& pen );
void SetColour( const wxColour &colour );
void SetColour( const wxString &colourName );
void SetColour( int red, int green, int blue );
void SetCap( int capStyle );
void SetJoin( int joinStyle );

View File

@@ -46,14 +46,12 @@ class WXDLLEXPORT wxBrush: public wxGDIObject
public:
wxBrush();
wxBrush(const wxColour& col, int style);
wxBrush(const wxString& col, int style);
wxBrush(const wxBitmap& stipple);
inline wxBrush(const wxBrush& brush) { Ref(brush); }
inline wxBrush(const wxBrush* brush) { if (brush) Ref(*brush); }
~wxBrush();
virtual void SetColour(const wxColour& col) ;
virtual void SetColour(const wxString& col) ;
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
virtual void SetStyle(int style) ;
virtual void SetStipple(const wxBitmap& stipple) ;

View File

@@ -20,40 +20,42 @@
#include "wx/string.h"
// Colour
class WXDLLEXPORT wxColour: public wxObject
class WXDLLEXPORT wxColour : public wxObject
{
DECLARE_DYNAMIC_CLASS(wxColour)
public:
// ctors
// default
wxColour();
wxColour(unsigned char r, unsigned char g, unsigned char b);
wxColour(unsigned long colRGB) { Set(colRGB); }
wxColour(const wxColour& col);
wxColour(const wxString& col);
~wxColour() ;
wxColour& operator =(const wxColour& src) ;
wxColour& operator =(const wxString& src) ;
inline int Ok() const { return (m_isInit) ; }
// from RGB
wxColour( char red, char green, char blue );
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
void Set(unsigned char r, unsigned char g, unsigned char b);
void Set(unsigned long colRGB)
{
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
// dtor
~wxColour();
// Set() functions
void Set( unsigned char red, unsigned char green, unsigned char blue );
void Set( unsigned long colRGB )
{
// we don't need to know sizeof(long) here because we assume that the three
// least significant bytes contain the R, G and B values
Set((unsigned char)colRGB,
Set((unsigned char)colRGB,
(unsigned char)(colRGB >> 8),
(unsigned char)(colRGB >> 16));
(unsigned char)(colRGB >> 16));
}
inline unsigned char Red() const { return m_red; }
inline unsigned char Green() const { return m_green; }
inline unsigned char Blue() const { return m_blue; }
// accessors
bool Ok() const {return m_isInit; }
inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
inline int GetPixel() const { return m_pixel; };
inline void SetPixel(int pixel) { m_pixel = pixel; m_isInit = TRUE; };
int GetPixel() const { return m_pixel; };
void SetPixel(int pixel) { m_pixel = pixel; m_isInit = TRUE; };
// Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return
@@ -65,17 +67,15 @@ public:
int AllocColour(WXDisplay* display, bool realloc = FALSE);
private:
private:
bool m_isInit;
unsigned char m_red;
unsigned char m_blue;
unsigned char m_green;
public:
public:
int m_pixel;
};
#define wxColor wxColour
#endif
// _WX_COLOUR_H_

View File

@@ -52,7 +52,6 @@ class WXDLLEXPORT wxPen: public wxGDIObject
public:
wxPen();
wxPen(const wxColour& col, int width, int style);
wxPen(const wxString& col, int width, int style);
wxPen(const wxBitmap& stipple, int width);
inline wxPen(const wxPen& pen) { Ref(pen); }
inline wxPen(const wxPen* pen) { if (pen) Ref(*pen); }
@@ -66,8 +65,7 @@ public:
// Override in order to recreate the pen
void SetColour(const wxColour& col) ;
void SetColour(const wxString& col) ;
void SetColour(const unsigned char r, const unsigned char g, const unsigned char b) ;
void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
void SetWidth(int width) ;
void SetStyle(int style) ;

View File

@@ -20,19 +20,25 @@
class WXDLLEXPORT wxColour: public wxObject
{
public:
// ctors
// default
wxColour();
wxColour(const unsigned char r, const unsigned char g, const unsigned char b);
wxColour(unsigned long colRGB) { Set(colRGB); }
wxColour(const wxColour& col);
wxColour(const wxString& col) { InitFromName(col); }
// wxColour(const char *col) { InitFromName(col); }
// from RGB
wxColour( char red, char green, char blue );
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
// dtor
~wxColour();
wxColour& operator =(const wxColour& src) ;
wxColour& operator =(const wxString& src) ;
inline int Ok() const { return (m_isInit) ; }
void Set(unsigned char r, unsigned char g, unsigned char b);
// Set() functions
void Set( unsigned char red, unsigned char green, unsigned char blue );
void Set(unsigned long colRGB)
{
// we don't need to know sizeof(long) here because we assume that the three
@@ -42,23 +48,31 @@ public:
(unsigned char)(colRGB >> 16));
}
// accessors
bool Ok() const {return m_isInit; }
// Let's remove this inelegant function
#if WXWIN_COMPATIBILITY
void Get(unsigned char *r, unsigned char *g, unsigned char *b) const;
#endif
inline unsigned char Red() const { return m_red; }
inline unsigned char Green() const { return m_green; }
inline unsigned char Blue() const { return m_blue; }
unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; }
unsigned char Blue() const { return m_blue; }
inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
// comparison
bool operator == (const wxColour& colour)
{
return (m_red == colour.m_red &&
m_green == colour.m_green &&
m_blue == colour.m_blue);
}
bool operator != (const wxColour& colour) { return !(*this == colour); }
WXCOLORREF GetPixel() const { return m_pixel; };
private:
bool m_isInit;
bool m_isInit;
unsigned char m_red;
unsigned char m_blue;
unsigned char m_green;
@@ -73,7 +87,5 @@ private:
DECLARE_DYNAMIC_CLASS(wxColour)
};
#define wxColor wxColour
#endif
// _WX_COLOUR_H_

View File

@@ -26,9 +26,9 @@ class WXDLLEXPORT wxPenRefData: public wxGDIRefData
{
friend class WXDLLEXPORT wxPen;
public:
wxPenRefData(void);
wxPenRefData();
wxPenRefData(const wxPenRefData& data);
~wxPenRefData(void);
~wxPenRefData();
protected:
int m_width;
@@ -49,19 +49,19 @@ class WXDLLEXPORT wxPen: public wxGDIObject
{
DECLARE_DYNAMIC_CLASS(wxPen)
public:
wxPen(void);
wxPen();
wxPen(const wxColour& col, int width, int style);
wxPen(const wxString& col, int width, int style);
wxPen(const wxBitmap& stipple, int width);
inline wxPen(const wxPen& pen) { Ref(pen); }
inline wxPen(const wxPen* pen) { if (pen) Ref(*pen); }
~wxPen(void);
~wxPen();
inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
inline bool operator == (const wxPen& pen) { return m_refData == pen.m_refData; }
inline bool operator != (const wxPen& pen) { return m_refData != pen.m_refData; }
virtual bool Ok(void) const { return (m_refData != NULL) ; }
virtual bool Ok() const { return (m_refData != NULL) ; }
// Override in order to recreate the pen
void SetColour(const wxColour& col) ;
@@ -75,22 +75,22 @@ public:
void SetJoin(int join) ;
void SetCap(int cap) ;
inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
inline int GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
inline int GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
inline int GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
inline int GetDashes(wxDash **ptr) const {
*ptr = (M_PENDATA ? M_PENDATA->m_dash : NULL); return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
}
inline wxBitmap *GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : NULL); };
inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : NULL); };
// Internal
bool RealizeResource(void);
bool RealizeResource();
bool FreeResource(bool force = FALSE);
WXHANDLE GetResourceHandle(void) ;
bool IsFree(void);
WXHANDLE GetResourceHandle() ;
bool IsFree() const;
void Unshare();
};

View File

@@ -50,14 +50,12 @@ class WXDLLEXPORT wxBrush: public wxGDIObject
public:
wxBrush();
wxBrush(const wxColour& col, int style);
wxBrush(const wxString& col, int style);
wxBrush(const wxBitmap& stipple);
inline wxBrush(const wxBrush& brush) { Ref(brush); }
inline wxBrush(const wxBrush* brush) { if (brush) Ref(*brush); }
~wxBrush();
virtual void SetColour(const wxColour& col) ;
virtual void SetColour(const wxString& col) ;
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
virtual void SetStyle(int style) ;
virtual void SetStipple(const wxBitmap& stipple) ;

View File

@@ -22,52 +22,74 @@
// Colour
class WXDLLEXPORT wxColour: public wxObject
{
DECLARE_DYNAMIC_CLASS(wxColour)
public:
// ctors
// default
wxColour();
wxColour(unsigned char r, unsigned char g, unsigned char b);
wxColour(unsigned long colRGB) { Set(colRGB); }
wxColour(const wxColour& col);
wxColour(const wxString& col);
~wxColour() ;
wxColour& operator =(const wxColour& src) ;
wxColour& operator =(const wxString& src) ;
inline int Ok() const { return (m_isInit) ; }
// from RGB
wxColour( char red, char green, char blue );
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
void Set(unsigned char r, unsigned char g, unsigned char b);
void Set(unsigned long colRGB)
{
// copy ctors and assignment operators
wxColour( const wxColour& col );
wxColour( const wxColour* col );
wxColour& operator = ( const wxColour& col );
// dtor
~wxColour();
// Set() functions
void Set( unsigned char red, unsigned char green, unsigned char blue );
void Set( unsigned long colRGB )
{
// we don't need to know sizeof(long) here because we assume that the three
// least significant bytes contain the R, G and B values
Set((unsigned char)colRGB,
Set((unsigned char)colRGB,
(unsigned char)(colRGB >> 8),
(unsigned char)(colRGB >> 16));
(unsigned char)(colRGB >> 16));
}
inline unsigned char Red() const { return m_red; }
inline unsigned char Green() const { return m_green; }
inline unsigned char Blue() const { return m_blue; }
// accessors
bool Ok() const {return m_isInit; }
inline bool operator == (const wxColour& colour) { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
// Let's remove this inelegant function
#if WXWIN_COMPATIBILITY
void Get(unsigned char *r, unsigned char *g, unsigned char *b) const;
#endif
inline bool operator != (const wxColour& colour) { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; }
unsigned char Blue() const { return m_blue; }
// comparison
bool operator == (const wxColour& colour)
{
return (m_red == colour.m_red &&
m_green == colour.m_green &&
m_blue == colour.m_blue);
}
bool operator != (const wxColour& colour) { return !(*this == colour); }
/* TODO
WXCOLORREF GetPixel() const { return m_pixel; };
*/
private:
bool m_isInit;
private:
bool m_isInit;
unsigned char m_red;
unsigned char m_blue;
unsigned char m_green;
public:
/* TODO: implementation
WXCOLORREF m_pixel ;
*/
};
#define wxColor wxColour
public:
/* TODO: implementation
WXCOLORREF m_pixel ;
*/
private:
DECLARE_DYNAMIC_CLASS(wxColour)
};
#endif
// _WX_COLOUR_H_

View File

@@ -55,7 +55,6 @@ class WXDLLEXPORT wxPen: public wxGDIObject
public:
wxPen();
wxPen(const wxColour& col, int width, int style);
wxPen(const wxString& col, int width, int style);
wxPen(const wxBitmap& stipple, int width);
inline wxPen(const wxPen& pen) { Ref(pen); }
inline wxPen(const wxPen* pen) { if (pen) Ref(*pen); }
@@ -69,8 +68,7 @@ public:
// Override in order to recreate the pen
void SetColour(const wxColour& col) ;
void SetColour(const wxString& col) ;
void SetColour(const unsigned char r, const unsigned char g, const unsigned char b) ;
void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
void SetWidth(int width) ;
void SetStyle(int style) ;