Applied patch [ 828303 ] Slight wxColour cleanup

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24751 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Julian Smart
2003-12-11 10:10:40 +00:00
parent 12ac619f42
commit aad6765cbd
23 changed files with 303 additions and 260 deletions

View File

@@ -100,6 +100,7 @@ All (GUI):
- make it possible to use wxRTTI macros with namespaces (Benjamin I. Williams) - make it possible to use wxRTTI macros with namespaces (Benjamin I. Williams)
- wxColourDatabase API now uses objects instead of pointers - wxColourDatabase API now uses objects instead of pointers
- added resolution option to JPEG image handler (Jeff Burton) - added resolution option to JPEG image handler (Jeff Burton)
- added wxCalendarEvent::SetDate, wxCalendarEvent::SetWeekDay
wxMSW: wxMSW:
@@ -120,6 +121,11 @@ wxGTK:
- fix for crash when using user-dashed lines (Chris Borgolte) - fix for crash when using user-dashed lines (Chris Borgolte)
- fixed wxChoice::Delete() in presence of client data - fixed wxChoice::Delete() in presence of client data
- allow calling wxWindow::SetFont if window not yet created - allow calling wxWindow::SetFont if window not yet created
- use same average character width as other ports when calculating dialog units
wxMac:
- use same average character width as other ports when calculating dialog units
wxHTML: wxHTML:

View File

@@ -33,7 +33,7 @@ public:
wxColour( unsigned long colRGB ) wxColour( unsigned long colRGB )
: m_cocoaNSColor(NULL) : m_cocoaNSColor(NULL)
{ Set(colRGB); } { Set(colRGB); }
// implicit conversion from the colour name // implicit conversion from the colour name
wxColour( const wxString &colourName ) wxColour( const wxString &colourName )
: m_cocoaNSColor(NULL) : m_cocoaNSColor(NULL)
@@ -62,10 +62,10 @@ public:
// comparison // comparison
bool operator == (const wxColour& colour) const bool operator == (const wxColour& colour) const
{ {
return (m_cocoaNSColor == colour.m_cocoaNSColor && return (m_cocoaNSColor == colour.m_cocoaNSColor
m_red == colour.m_red && && m_red == colour.m_red
m_green == colour.m_green && && m_green == colour.m_green
m_blue == colour.m_blue); && m_blue == colour.m_blue);
} }
bool operator != (const wxColour& colour) const bool operator != (const wxColour& colour) const
{ return !(*this == colour); } { return !(*this == colour); }
@@ -83,7 +83,6 @@ public:
(unsigned char)(colRGB >> 16)); (unsigned char)(colRGB >> 16));
} }
protected:
void InitFromName(const wxString& col); void InitFromName(const wxString& col);
private: private:

View File

@@ -40,7 +40,7 @@ class wxColour: public wxGDIObject
{ {
public: public:
wxColour() { } wxColour() { }
// Construct from RGB // Construct from RGB
wxColour( unsigned char red, unsigned char green, unsigned char blue ); wxColour( unsigned char red, unsigned char green, unsigned char blue );
wxColour( unsigned long colRGB ) { Set(colRGB); } wxColour( unsigned long colRGB ) { Set(colRGB); }
@@ -61,7 +61,7 @@ public:
~wxColour(); ~wxColour();
bool Ok() const { return m_refData != NULL; } bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxColour& col ) const; bool operator == ( const wxColour& col ) const;
bool operator != ( const wxColour& col ) const { return !(*this == col); } bool operator != ( const wxColour& col ) const { return !(*this == col); }
@@ -88,13 +88,13 @@ public:
int GetPixel() const; int GetPixel() const;
GdkColor *GetColor() const; GdkColor *GetColor() const;
void InitFromName(const wxString& colourName);
protected: protected:
// ref counting code // ref counting code
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// Helper functions
void InitFromName(const wxString& colourName);
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -40,7 +40,7 @@ class wxColour: public wxGDIObject
{ {
public: public:
wxColour() { } wxColour() { }
// Construct from RGB // Construct from RGB
wxColour( unsigned char red, unsigned char green, unsigned char blue ); wxColour( unsigned char red, unsigned char green, unsigned char blue );
wxColour( unsigned long colRGB ) { Set(colRGB); } wxColour( unsigned long colRGB ) { Set(colRGB); }
@@ -61,7 +61,7 @@ public:
~wxColour(); ~wxColour();
bool Ok() const { return m_refData != NULL; } bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxColour& col ) const; bool operator == ( const wxColour& col ) const;
bool operator != ( const wxColour& col ) const { return !(*this == col); } bool operator != ( const wxColour& col ) const { return !(*this == col); }
@@ -88,13 +88,13 @@ public:
int GetPixel() const; int GetPixel() const;
GdkColor *GetColor() const; GdkColor *GetColor() const;
void InitFromName(const wxString& colourName);
protected: protected:
// ref counting code // ref counting code
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// Helper functions
void InitFromName(const wxString& colourName);
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -31,7 +31,7 @@ public:
{ Set(red, green, blue); } { Set(red, green, blue); }
wxColour( unsigned long colRGB ) wxColour( unsigned long colRGB )
{ Set(colRGB); } { Set(colRGB); }
// implicit conversion from the colour name // implicit conversion from the colour name
wxColour( const wxString &colourName ) wxColour( const wxString &colourName )
{ InitFromName(colourName); } { InitFromName(colourName); }
@@ -67,25 +67,28 @@ public:
// comparison // comparison
bool operator == (const wxColour& colour) const bool operator == (const wxColour& colour) const
{ {
return (m_isInit == colour.m_isInit && return (m_isInit == colour.m_isInit
m_red == colour.m_red && && m_red == colour.m_red
m_green == colour.m_green && && m_green == colour.m_green
m_blue == colour.m_blue); && m_blue == colour.m_blue);
} }
bool operator != (const wxColour& colour) const { return !(*this == colour); } bool operator != (const wxColour& colour) const { return !(*this == colour); }
void InitFromName(const wxString& col);
const WXCOLORREF& GetPixel() const { return m_pixel; }; const WXCOLORREF& GetPixel() const { return m_pixel; };
void InitFromName(const wxString& col);
protected :
// Helper function
void Init();
private: private:
bool m_isInit; bool m_isInit;
unsigned char m_red; unsigned char m_red;
unsigned char m_blue; unsigned char m_blue;
unsigned char m_green; unsigned char m_green;
void Init();
public: public:
WXCOLORREF m_pixel ; WXCOLORREF m_pixel ;
void Set( const WXCOLORREF* color ) ; void Set( const WXCOLORREF* color ) ;

View File

@@ -69,16 +69,19 @@ public:
} }
bool operator != (const wxColour& colour) const { return !(*this == colour); } bool operator != (const wxColour& colour) const { return !(*this == colour); }
void InitFromName(const wxString& colourName);
protected:
// Helper function
void Init();
private: private:
bool m_isInit; bool m_isInit;
unsigned char m_red; unsigned char m_red;
unsigned char m_blue; unsigned char m_blue;
unsigned char m_green; unsigned char m_green;
// ctors helpers
void Init();
void InitFromName(const wxString& colourName);
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)
}; };

View File

@@ -31,18 +31,18 @@ public:
wxColour( unsigned char red, unsigned char green, unsigned char blue ) wxColour( unsigned char red, unsigned char green, unsigned char blue )
{ Set(red, green, blue); } { Set(red, green, blue); }
wxColour( unsigned long colRGB ) { Set(colRGB); } wxColour( unsigned long colRGB ) { Set(colRGB); }
// implicit conversion from the colour name // implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); } wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); } wxColour( const char *colourName ) { InitFromName(colourName); }
// copy ctors and assignment operators // copy ctors and assignment operators
wxColour( const wxColour& col ); wxColour( const wxColour& col );
wxColour& operator = ( const wxColour& col ); wxColour& operator = ( const wxColour& col );
// dtor // dtor
~wxColour(); ~wxColour();
// Set() functions // Set() functions
void Set( unsigned char red, unsigned char green, unsigned char blue ); void Set( unsigned char red, unsigned char green, unsigned char blue );
void Set( unsigned long colRGB ) void Set( unsigned long colRGB )
@@ -53,41 +53,45 @@ public:
(unsigned char)(colRGB >> 8), (unsigned char)(colRGB >> 8),
(unsigned char)(colRGB >> 16)); (unsigned char)(colRGB >> 16));
} }
// accessors // accessors
bool Ok() const {return m_isInit; } bool Ok() const {return m_isInit; }
unsigned char Red() const { return m_red; } unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; } unsigned char Green() const { return m_green; }
unsigned char Blue() const { return m_blue; } unsigned char Blue() const { return m_blue; }
int GetPixel() const { return m_pixel; }; int GetPixel() const { return m_pixel; };
void SetPixel(int pixel) { m_pixel = pixel; m_isInit = TRUE; }; void SetPixel(int pixel) { m_pixel = pixel; m_isInit = true; };
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); }
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 // Get colour from name or wxNullColour
static wxColour CreateByName(const wxString& name); static wxColour CreateByName(const wxString& name);
// Allocate a colour, or nearest colour, using the given display. // Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return // If realloc is true, ignore the existing pixel, otherwise just return
// the existing one. // the existing one.
// Returns the allocated pixel. // Returns the allocated pixel.
// TODO: can this handle mono displays? If not, we should have an extra // 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. // flag to specify whether this should be black or white by default.
int AllocColour(WXDisplay* display, bool realloc = FALSE); int AllocColour(WXDisplay* display, bool realloc = false);
void InitFromName(const wxString& col); void InitFromName(const wxString& col);
protected:
// Helper function
void Init();
private: private:
bool m_isInit; bool m_isInit;
unsigned char m_red; unsigned char m_red;
unsigned char m_blue; unsigned char m_blue;
unsigned char m_green; unsigned char m_green;
public: public:
int m_pixel; int m_pixel;
}; };

View File

@@ -54,9 +54,9 @@ public:
// other methods // other methods
// ------------- // -------------
// to have the matching Create also for this class // to have the matching Create also for this class
void Create( unsigned char red, unsigned char green, unsigned char blue ) void Create( unsigned char red, unsigned char green, unsigned char blue )
{ Set(red, green, blue); } { Set(red, green, blue); }
// Set() functions // Set() functions
void Set(unsigned char red, unsigned char green, unsigned char blue); void Set(unsigned char red, unsigned char green, unsigned char blue);
@@ -65,14 +65,14 @@ public:
// we don't need to know sizeof(long) here because we assume that the three // 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 // 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 >> 8),
(unsigned char)(colRGB >> 16)); (unsigned char)(colRGB >> 16));
} }
// accessors // accessors
// --------- // ---------
bool Ok() const {return m_isInit; } bool Ok() const { return m_isInit; }
unsigned char Red() const { return m_red; } unsigned char Red() const { return m_red; }
unsigned char Green() const { return m_green; } unsigned char Green() const { return m_green; }
@@ -81,29 +81,31 @@ public:
// comparison // comparison
bool operator==(const wxColour& colour) const bool operator==(const wxColour& colour) const
{ {
return m_isInit == colour.m_isInit && return m_isInit == colour.m_isInit
m_red == colour.m_red && && m_red == colour.m_red
m_green == colour.m_green && && m_green == colour.m_green
m_blue == colour.m_blue; && m_blue == colour.m_blue;
} }
bool operator != (const wxColour& colour) const { return !(*this == colour); } bool operator != (const wxColour& colour) const { return !(*this == colour); }
WXCOLORREF GetPixel() const { return m_pixel; }; WXCOLORREF GetPixel() const { return m_pixel; };
void InitFromName(const wxString& colourName);
public: public:
WXCOLORREF m_pixel; WXCOLORREF m_pixel;
protected:
// Helper function
void Init();
private: private:
bool m_isInit; bool m_isInit;
unsigned char m_red; unsigned char m_red;
unsigned char m_blue; unsigned char m_blue;
unsigned char m_green; unsigned char m_green;
// ctors helpers
void Init();
void InitFromName(const wxString& colourName);
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)
}; };

View File

@@ -41,7 +41,7 @@ public:
// Implicit conversion from the colour name // Implicit conversion from the colour name
// //
wxColour(const wxString& rColourName) { InitFromName(rColourName); } wxColour(const wxString& rColourName) { InitFromName(rColourName); }
wxColour(const char* zColourName) { InitFromName(zColourName); } wxColour(const wxChar *zColourName) { InitFromName(zColourName); }
// //
// Copy ctors and assignment operators // Copy ctors and assignment operators
@@ -92,17 +92,24 @@ public:
// //
bool operator == (const wxColour& rColour) const bool operator == (const wxColour& rColour) const
{ {
return (m_cRed == rColour.m_cRed && return (m_isInit == rColour.m_isInit
m_cGreen == rColour.m_cGreen && && m_cRed == rColour.m_cRed
m_cBlue == rColour.m_cBlue && m_cGreen == rColour.m_cGreen
&& m_cBlue == rColour.m_cBlue
); );
} }
bool operator != (const wxColour& rColour) const { return !(*this == rColour); } bool operator != (const wxColour& rColour) const { return !(*this == rColour); }
void InitFromName(const wxString& rCol);
WXCOLORREF GetPixel(void) const { return m_vPixel; }; WXCOLORREF GetPixel(void) const { return m_vPixel; };
void InitFromName(const wxString& rCol);
private: private:
// Helper function
void Init();
bool m_bIsInit; bool m_bIsInit;
unsigned char m_cRed; unsigned char m_cRed;
unsigned char m_cBlue; unsigned char m_cBlue;

View File

@@ -37,11 +37,11 @@ class wxColour;
// wxColour // wxColour
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
class wxColour: public wxGDIObject class WXDLLEXPORT wxColour: public wxGDIObject
{ {
public: public:
wxColour() { } wxColour() { }
// Construct from RGB // Construct from RGB
wxColour( unsigned char red, unsigned char green, unsigned char blue ); wxColour( unsigned char red, unsigned char green, unsigned char blue );
wxColour( unsigned long colRGB ) { Set(colRGB); } wxColour( unsigned long colRGB ) { Set(colRGB); }
@@ -62,7 +62,7 @@ public:
~wxColour(); ~wxColour();
bool Ok() const { return m_refData != NULL; } bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxColour& col ) const; bool operator == ( const wxColour& col ) const;
bool operator != ( const wxColour& col ) const { return !(*this == col); } bool operator != ( const wxColour& col ) const { return !(*this == col); }
@@ -81,18 +81,18 @@ public:
unsigned char Blue() const; unsigned char Blue() const;
// Implementation part // Implementation part
void CalcPixel( WXColormap cmap ); void CalcPixel( WXColormap cmap );
unsigned long GetPixel() const; unsigned long GetPixel() const;
WXColor *GetColor() const; WXColor *GetColor() const;
void InitFromName(const wxString& colourName);
protected: protected:
// ref counting code // ref counting code
virtual wxObjectRefData *CreateRefData() const; virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const; virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// Helper functions
void InitFromName(const wxString& colourName);
private: private:
DECLARE_DYNAMIC_CLASS(wxColour) DECLARE_DYNAMIC_CLASS(wxColour)

View File

@@ -331,7 +331,7 @@ void wxColourDatabase::Initialize()
{wxT("WHEAT"), 216, 216, 191}, {wxT("WHEAT"), 216, 216, 191},
{wxT("WHITE"), 255, 255, 255}, {wxT("WHITE"), 255, 255, 255},
{wxT("YELLOW"), 255, 255, 0}, {wxT("YELLOW"), 255, 255, 0},
{wxT("YELLOW GREEN"), 153, 204, 50}, {wxT("YELLOW GREEN"), 153, 204, 50}
}; };
size_t n; size_t n;

View File

@@ -37,7 +37,7 @@ public:
m_color.blue = 0; m_color.blue = 0;
m_color.pixel = 0; m_color.pixel = 0;
m_colormap = (GdkColormap *) NULL; m_colormap = (GdkColormap *) NULL;
m_hasPixel = FALSE; m_hasPixel = false;
} }
wxColourRefData(const wxColourRefData& data) wxColourRefData(const wxColourRefData& data)
@@ -207,10 +207,10 @@ wxColour::~wxColour()
bool wxColour::operator == ( const wxColour& col ) const bool wxColour::operator == ( const wxColour& col ) const
{ {
if (m_refData == col.m_refData) if (m_refData == col.m_refData)
return TRUE; return true;
if (!m_refData || !col.m_refData) if (!m_refData || !col.m_refData)
return FALSE; return false;
GdkColor *own = &(((wxColourRefData*)m_refData)->m_color); GdkColor *own = &(((wxColourRefData*)m_refData)->m_color);
GdkColor *other = &(((wxColourRefData*)col.m_refData)->m_color); GdkColor *other = &(((wxColourRefData*)col.m_refData)->m_color);
@@ -239,7 +239,7 @@ void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
M_COLDATA->m_color.pixel = 0; M_COLDATA->m_color.pixel = 0;
M_COLDATA->m_colormap = (GdkColormap*) NULL; M_COLDATA->m_colormap = (GdkColormap*) NULL;
M_COLDATA->m_hasPixel = FALSE; M_COLDATA->m_hasPixel = false;
} }
unsigned char wxColour::Red() const unsigned char wxColour::Red() const

View File

@@ -37,7 +37,7 @@ public:
m_color.blue = 0; m_color.blue = 0;
m_color.pixel = 0; m_color.pixel = 0;
m_colormap = (GdkColormap *) NULL; m_colormap = (GdkColormap *) NULL;
m_hasPixel = FALSE; m_hasPixel = false;
} }
wxColourRefData(const wxColourRefData& data) wxColourRefData(const wxColourRefData& data)
@@ -207,10 +207,10 @@ wxColour::~wxColour()
bool wxColour::operator == ( const wxColour& col ) const bool wxColour::operator == ( const wxColour& col ) const
{ {
if (m_refData == col.m_refData) if (m_refData == col.m_refData)
return TRUE; return true;
if (!m_refData || !col.m_refData) if (!m_refData || !col.m_refData)
return FALSE; return false;
GdkColor *own = &(((wxColourRefData*)m_refData)->m_color); GdkColor *own = &(((wxColourRefData*)m_refData)->m_color);
GdkColor *other = &(((wxColourRefData*)col.m_refData)->m_color); GdkColor *other = &(((wxColourRefData*)col.m_refData)->m_color);
@@ -239,7 +239,7 @@ void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
M_COLDATA->m_color.pixel = 0; M_COLDATA->m_color.pixel = 0;
M_COLDATA->m_colormap = (GdkColormap*) NULL; M_COLDATA->m_colormap = (GdkColormap*) NULL;
M_COLDATA->m_hasPixel = FALSE; M_COLDATA->m_hasPixel = false;
} }
unsigned char wxColour::Red() const unsigned char wxColour::Red() const

View File

@@ -25,7 +25,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
#include "wx/mac/private.h" #include "wx/mac/private.h"
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ; static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
{ {
RGBColor* col = (RGBColor*) color ; RGBColor* col = (RGBColor*) color ;
col->red = (red << 8) + red; col->red = (red << 8) + red;
@@ -35,11 +35,11 @@ static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green
void wxColour::Init() void wxColour::Init()
{ {
m_isInit = FALSE; m_isInit = false;
m_red = m_red =
m_blue = m_blue =
m_green = 0; m_green = 0;
wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
} }
@@ -70,23 +70,26 @@ wxColour& wxColour::operator =(const wxColour& col)
m_green = col.m_green; m_green = col.m_green;
m_blue = col.m_blue; m_blue = col.m_blue;
m_isInit = col.m_isInit; m_isInit = col.m_isInit;
memcpy( &m_pixel , &col.m_pixel , 6 ) ; memcpy( &m_pixel , &col.m_pixel , 6 ) ;
return *this; return *this;
} }
void wxColour::InitFromName(const wxString& name) void wxColour::InitFromName(const wxString& name)
{ {
wxColour col = wxTheColourDatabase->Find(name); if ( wxTheColourDatabase )
if ( col.Ok() )
{ {
*this = col; wxColour col = wxTheColourDatabase->Find(name);
} if ( col.Ok() )
else {
{ *this = col;
Init(); return;
}
} }
// leave invalid
Init();
} }
wxColour::~wxColour () wxColour::~wxColour ()
@@ -98,13 +101,13 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
m_red = r; m_red = r;
m_green = g; m_green = g;
m_blue = b; m_blue = b;
m_isInit = TRUE; m_isInit = true;
wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
} }
void wxColour::Set( const WXCOLORREF* color ) void wxColour::Set( const WXCOLORREF* color )
{ {
RGBColor* col = (RGBColor*) color ; RGBColor* col = (RGBColor*) color ;
memcpy( &m_pixel , color , 6 ) ; memcpy( &m_pixel , color , 6 ) ;
m_red = col->red>>8 ; m_red = col->red>>8 ;

View File

@@ -25,7 +25,7 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
#include "wx/mac/private.h" #include "wx/mac/private.h"
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ; static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) ;
static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green ) static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green )
{ {
RGBColor* col = (RGBColor*) color ; RGBColor* col = (RGBColor*) color ;
col->red = (red << 8) + red; col->red = (red << 8) + red;
@@ -35,11 +35,11 @@ static void wxComposeRGBColor( WXCOLORREF* color , int red, int blue, int green
void wxColour::Init() void wxColour::Init()
{ {
m_isInit = FALSE; m_isInit = false;
m_red = m_red =
m_blue = m_blue =
m_green = 0; m_green = 0;
wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
} }
@@ -70,23 +70,26 @@ wxColour& wxColour::operator =(const wxColour& col)
m_green = col.m_green; m_green = col.m_green;
m_blue = col.m_blue; m_blue = col.m_blue;
m_isInit = col.m_isInit; m_isInit = col.m_isInit;
memcpy( &m_pixel , &col.m_pixel , 6 ) ; memcpy( &m_pixel , &col.m_pixel , 6 ) ;
return *this; return *this;
} }
void wxColour::InitFromName(const wxString& name) void wxColour::InitFromName(const wxString& name)
{ {
wxColour col = wxTheColourDatabase->Find(name); if ( wxTheColourDatabase )
if ( col.Ok() )
{ {
*this = col; wxColour col = wxTheColourDatabase->Find(name);
} if ( col.Ok() )
else {
{ *this = col;
Init(); return;
}
} }
// leave invalid
Init();
} }
wxColour::~wxColour () wxColour::~wxColour ()
@@ -98,13 +101,13 @@ void wxColour::Set (unsigned char r, unsigned char g, unsigned char b)
m_red = r; m_red = r;
m_green = g; m_green = g;
m_blue = b; m_blue = b;
m_isInit = TRUE; m_isInit = true;
wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ; wxComposeRGBColor( &m_pixel , m_red , m_blue , m_green ) ;
} }
void wxColour::Set( const WXCOLORREF* color ) void wxColour::Set( const WXCOLORREF* color )
{ {
RGBColor* col = (RGBColor*) color ; RGBColor* col = (RGBColor*) color ;
memcpy( &m_pixel , color , 6 ) ; memcpy( &m_pixel , color , 6 ) ;
m_red = col->red>>8 ; m_red = col->red>>8 ;

View File

@@ -32,7 +32,7 @@ void wxColour::Init()
m_red = m_red =
m_blue = m_blue =
m_green = 0; m_green = 0;
m_isInit = FALSE; m_isInit = false;
} }
wxColour::wxColour(const wxColour& col) wxColour::wxColour(const wxColour& col)
@@ -51,15 +51,18 @@ wxColour& wxColour::operator =(const wxColour& col)
void wxColour::InitFromName(const wxString& name) void wxColour::InitFromName(const wxString& name)
{ {
wxColour *col = wxTheColourDatabase->Find(name); if ( wxTheColourDatabase )
if ( col.Ok() )
{ {
*this = col; wxColour col = wxTheColourDatabase->Find(name);
} if ( col.Ok() )
else {
{ *this = col;
Init(); return;
}
} }
// leave invalid
Init();
} }
wxColour::~wxColour() wxColour::~wxColour()
@@ -71,5 +74,5 @@ void wxColour::Set(unsigned char r, unsigned char g, unsigned char b)
m_red = r; m_red = r;
m_green = g; m_green = g;
m_blue = b; m_blue = b;
m_isInit = TRUE; m_isInit = true;
} }

View File

@@ -34,16 +34,21 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
// Colour // Colour
wxColour::wxColour () void wxColour::Init()
{ {
m_isInit = FALSE; m_isInit = false;
m_red = m_red =
m_blue = m_blue =
m_green = 0; m_green = 0;
m_pixel = -1; m_pixel = -1;
} }
wxColour::wxColour (const wxColour& col) wxColour::wxColour()
{
Init();
}
wxColour::wxColour(const wxColour& col)
{ {
*this = col; *this = col;
} }
@@ -60,7 +65,18 @@ wxColour& wxColour::operator =(const wxColour& col)
void wxColour::InitFromName(const wxString& name) void wxColour::InitFromName(const wxString& name)
{ {
*this = wxTheColourDatabase->Find(name); if ( wxTheColourDatabase )
{
wxColour col = wxTheColourDatabase->Find(name);
if ( col.Ok() )
{
*this = col;
return;
}
}
// leave invalid
Init();
} }
/* static */ /* static */
@@ -83,21 +99,21 @@ wxColour wxColour::CreateByName(const wxString& name)
return col; return col;
} }
wxColour::~wxColour () wxColour::~wxColour()
{ {
} }
void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) void wxColour::Set(unsigned char r, unsigned char g, unsigned char b)
{ {
m_red = r; m_red = r;
m_green = g; m_green = g;
m_blue = b; m_blue = b;
m_isInit = TRUE; m_isInit = true;
m_pixel = -1; m_pixel = -1;
} }
// Allocate a colour, or nearest colour, using the given display. // Allocate a colour, or nearest colour, using the given display.
// If realloc is TRUE, ignore the existing pixel, otherwise just return // If realloc is true, ignore the existing pixel, otherwise just return
// the existing one. // the existing one.
// Returns the old or allocated pixel. // Returns the old or allocated pixel.
@@ -108,7 +124,7 @@ int wxColour::AllocColour(WXDisplay* display, bool realloc)
{ {
if ((m_pixel != -1) && !realloc) if ((m_pixel != -1) && !realloc)
return m_pixel; return m_pixel;
XColor color; XColor color;
color.red = (unsigned short) Red (); color.red = (unsigned short) Red ();
color.red |= color.red << 8; color.red |= color.red << 8;
@@ -116,11 +132,11 @@ int wxColour::AllocColour(WXDisplay* display, bool realloc)
color.green |= color.green << 8; color.green |= color.green << 8;
color.blue = (unsigned short) Blue (); color.blue = (unsigned short) Blue ();
color.blue |= color.blue << 8; color.blue |= color.blue << 8;
color.flags = DoRed | DoGreen | DoBlue; color.flags = DoRed | DoGreen | DoBlue;
WXColormap cmap = wxTheApp->GetMainColormap(display); WXColormap cmap = wxTheApp->GetMainColormap(display);
if (!XAllocColor ((Display*) display, (Colormap) cmap, &color)) if (!XAllocColor ((Display*) display, (Colormap) cmap, &color))
{ {
m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap); m_pixel = wxGetBestMatchingPixel((Display*) display, &color,(Colormap) cmap);
@@ -167,7 +183,7 @@ int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap
{ {
if (cmap == (Colormap) NULL) if (cmap == (Colormap) NULL)
cmap = (Colormap) wxTheApp->GetMainColormap(display); cmap = (Colormap) wxTheApp->GetMainColormap(display);
int numPixVals = XDisplayCells(display, DefaultScreen (display)); int numPixVals = XDisplayCells(display, DefaultScreen (display));
int mindist = 256 * 256 * 3; int mindist = 256 * 256 * 3;
int bestpixel = (int) BlackPixel (display, DefaultScreen (display)); int bestpixel = (int) BlackPixel (display, DefaultScreen (display));
@@ -175,21 +191,21 @@ int wxGetBestMatchingPixel(Display *display, XColor *desiredColor, Colormap cmap
int green = desiredColor->green >> 8; int green = desiredColor->green >> 8;
int blue = desiredColor->blue >> 8; int blue = desiredColor->blue >> 8;
const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B const int threshold = 2 * 2 * 3; // allow an error of up to 2 in R,G & B
for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++) for (int pixelcount = 0; pixelcount < numPixVals; pixelcount++)
{ {
XColor matching_color; XColor matching_color;
matching_color.pixel = pixelcount; matching_color.pixel = pixelcount;
XQueryColor(display,cmap,&matching_color); XQueryColor(display,cmap,&matching_color);
int delta_red = red - (matching_color.red >> 8); int delta_red = red - (matching_color.red >> 8);
int delta_green = green - (matching_color.green >> 8); int delta_green = green - (matching_color.green >> 8);
int delta_blue = blue - (matching_color.blue >> 8); int delta_blue = blue - (matching_color.blue >> 8);
int dist = delta_red * delta_red + int dist = delta_red * delta_red +
delta_green * delta_green + delta_green * delta_green +
delta_blue * delta_blue; delta_blue * delta_blue;
if (dist <= threshold) if (dist <= threshold)
{ {
// try to allocate a read-only colour... // try to allocate a read-only colour...

View File

@@ -6,7 +6,7 @@
// Created: 01/02/97 // Created: 01/02/97
// RCS-ID: $Id$ // RCS-ID: $Id$
// Copyright: (c) Julian Smart // Copyright: (c) Julian Smart
// Licence: wxWindows licence // Licence: wxWindows licence
///////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////
#if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA)
@@ -29,38 +29,39 @@
template<> void wxStringReadValue(const wxString &s , wxColour &data ) template<> void wxStringReadValue(const wxString &s , wxColour &data )
{ {
// copied from VS xrc // copied from VS xrc
unsigned long tmp = 0; unsigned long tmp = 0;
if (s.Length() != 7 || s[0u] != wxT('#') || if (s.Length() != 7 || s[0u] != wxT('#')
wxSscanf(s.c_str(), wxT("#%lX"), &tmp) != 1) || wxSscanf(s.c_str(), wxT("#%lX"), &tmp) != 1)
{ {
wxLogError(_("String To Colour : Incorrect colour specification : %s"), wxLogError(_("String To Colour : Incorrect colour specification : %s"),
s.c_str() ); s.c_str() );
data = wxNullColour; data = wxNullColour;
} }
else else
{ {
data = wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) , data = wxColour((unsigned char) ((tmp & 0xFF0000) >> 16) ,
(unsigned char) ((tmp & 0x00FF00) >> 8), (unsigned char) ((tmp & 0x00FF00) >> 8),
(unsigned char) ((tmp & 0x0000FF))); (unsigned char) ((tmp & 0x0000FF)));
} }
} }
template<> void wxStringWriteValue(wxString &s , const wxColour &data ) template<> void wxStringWriteValue(wxString &s , const wxColour &data )
{ {
s = wxString::Format(wxT("#%02X%02X%02X"), data.Red() , data.Green() , data.Blue() ) ; s = wxString::Format(wxT("#%02X%02X%02X"),
data.Red(), data.Green(), data.Blue() );
} }
IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour , wxObject , "wx/colour.h" , &wxToStringConverter<wxColour> , &wxFromStringConverter<wxColour>) IMPLEMENT_DYNAMIC_CLASS_WITH_COPY_AND_STREAMERS_XTI( wxColour , wxObject , "wx/colour.h" , &wxToStringConverter<wxColour> , &wxFromStringConverter<wxColour>)
wxBEGIN_PROPERTIES_TABLE(wxColour) wxBEGIN_PROPERTIES_TABLE(wxColour)
wxREADONLY_PROPERTY( Red, unsigned char , Red , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxREADONLY_PROPERTY( Red, unsigned char, Red, , 0 /*flags*/, wxT("Helpstring"), wxT("group"))
wxREADONLY_PROPERTY( Green, unsigned char , Green , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxREADONLY_PROPERTY( Green, unsigned char, Green, , 0 /*flags*/, wxT("Helpstring"), wxT("group"))
wxREADONLY_PROPERTY( Blue, unsigned char , Blue , , 0 /*flags*/ , wxT("Helpstring") , wxT("group")) wxREADONLY_PROPERTY( Blue, unsigned char, Blue, , 0 /*flags*/, wxT("Helpstring"), wxT("group"))
wxEND_PROPERTIES_TABLE() wxEND_PROPERTIES_TABLE()
wxCONSTRUCTOR_3( wxColour , unsigned char , Red , unsigned char , Green , unsigned char , Blue ) wxCONSTRUCTOR_3( wxColour, unsigned char, Red, unsigned char, Green, unsigned char, Blue )
wxBEGIN_HANDLERS_TABLE(wxColour) wxBEGIN_HANDLERS_TABLE(wxColour)
wxEND_HANDLERS_TABLE() wxEND_HANDLERS_TABLE()
@@ -72,14 +73,14 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
void wxColour::Init() void wxColour::Init()
{ {
m_isInit = FALSE; m_isInit = false;
m_pixel = 0; m_pixel = 0;
m_red = m_red =
m_blue = m_blue =
m_green = 0; m_green = 0;
} }
wxColour::wxColour (const wxColour& col) wxColour::wxColour(const wxColour& col)
{ {
*this = col; *this = col;
} }
@@ -114,12 +115,12 @@ wxColour::~wxColour()
{ {
} }
void wxColour::Set (unsigned char r, unsigned char g, unsigned char b) void wxColour::Set(unsigned char r, unsigned char g, unsigned char b)
{ {
m_red = r; m_red = r;
m_green = g; m_green = g;
m_blue = b; m_blue = b;
m_isInit = TRUE; m_isInit = true;
m_pixel = PALETTERGB (m_red, m_green, m_blue); m_pixel = PALETTERGB(m_red, m_green, m_blue);
} }

View File

@@ -25,11 +25,16 @@ IMPLEMENT_DYNAMIC_CLASS(wxColour, wxObject)
// Colour // Colour
wxColour::wxColour () void wxColour::Init()
{ {
m_bIsInit = FALSE; m_bIsInit = false;
m_vPixel = 0; m_vPixel = 0;
m_cRed = m_cBlue = m_cGreen = 0; m_cRed = m_cBlue = m_cGreen = 0;
} // end of wxColour::Init
wxColour::wxColour ()
{
Init();
} // end of wxColour::wxColour } // end of wxColour::wxColour
wxColour::wxColour ( wxColour::wxColour (
@@ -38,22 +43,14 @@ wxColour::wxColour (
, unsigned char cBlue , unsigned char cBlue
) )
{ {
m_cRed = cRed; Set(cRed, cGreen, cBlue);
m_cGreen = cGreen;
m_cBlue = cBlue;
m_bIsInit = TRUE;
m_vPixel = OS2RGB (m_cRed, m_cGreen, m_cBlue);
} // end of wxColour::wxColour } // end of wxColour::wxColour
wxColour::wxColour ( wxColour::wxColour(
const wxColour& rCol const wxColour& rCol
) )
{ {
m_cRed = rCol.m_cRed; *this = col;
m_cGreen = rCol.m_cGreen;
m_cBlue = rCol.m_cBlue;
m_bIsInit = rCol.m_bIsInit;
m_vPixel = rCol.m_vPixel;
} // end of wxColour::wxColour } // end of wxColour::wxColour
wxColour& wxColour::operator =( wxColour& wxColour::operator =(
@@ -72,30 +69,26 @@ void wxColour::InitFromName(
const wxString& sCol const wxString& sCol
) )
{ {
wxColour* pTheColour = wxTheColourDatabase->FindColour(sCol); if ( wxTheColourDatabase )
{
wxColour col = wxTheColourDatabase->Find(sCol);
if ( col.Ok() )
{
*this = col;
return;
}
}
// leave invalid
Init();
if (pTheColour)
{
m_cRed = pTheColour->Red();
m_cGreen = pTheColour->Green();
m_cBlue = pTheColour->Blue();
m_bIsInit = TRUE;
}
else
{
m_cRed = 0;
m_cGreen = 0;
m_cBlue = 0;
m_bIsInit = FALSE;
}
m_vPixel = OS2RGB (m_cRed, m_cGreen, m_cBlue);
} // end of wxColour::InitFromName } // end of wxColour::InitFromName
wxColour::~wxColour () wxColour::~wxColour()
{ {
} // end of wxColour::~wxColour } // end of wxColour::~wxColour
void wxColour::Set ( void wxColour::Set(
unsigned char cRed unsigned char cRed
, unsigned char cGreen , unsigned char cGreen
, unsigned char cBlue , unsigned char cBlue
@@ -104,6 +97,6 @@ void wxColour::Set (
m_cRed = cRed; m_cRed = cRed;
m_cGreen = cGreen; m_cGreen = cGreen;
m_cBlue = cBlue; m_cBlue = cBlue;
m_bIsInit = TRUE; m_bIsInit = true;
m_vPixel = OS2RGB (m_cRed, m_cGreen, m_cBlue); m_vPixel = OS2RGB (m_cRed, m_cGreen, m_cBlue);
} // end of wxColour::Set } // end of wxColour::Set

View File

@@ -316,19 +316,19 @@ void wxDC::AddToDCCache(
void wxDC::ClearCache() void wxDC::ClearCache()
{ {
m_svBitmapCache.DeleteContents(TRUE); m_svBitmapCache.DeleteContents(true);
m_svBitmapCache.Clear(); m_svBitmapCache.Clear();
m_svBitmapCache.DeleteContents(FALSE); m_svBitmapCache.DeleteContents(false);
m_svDCCache.DeleteContents(TRUE); m_svDCCache.DeleteContents(true);
m_svDCCache.Clear(); m_svDCCache.Clear();
m_svDCCache.DeleteContents(FALSE); m_svDCCache.DeleteContents(false);
} // end of wxDC::ClearCache } // end of wxDC::ClearCache
// Clean up cache at app exit // Clean up cache at app exit
class wxDCModule : public wxModule class wxDCModule : public wxModule
{ {
public: public:
virtual bool OnInit() { return TRUE; } virtual bool OnInit() { return true; }
virtual void OnExit() { wxDC::ClearCache(); } virtual void OnExit() { wxDC::ClearCache(); }
private: private:
@@ -345,8 +345,6 @@ IMPLEMENT_DYNAMIC_CLASS(wxDCModule, wxModule)
wxDC::wxDC(void) wxDC::wxDC(void)
{ {
wxColour vColor;
m_pCanvas = NULL; m_pCanvas = NULL;
m_hOldBitmap = 0; m_hOldBitmap = 0;
@@ -355,16 +353,18 @@ wxDC::wxDC(void)
m_hOldFont = 0; m_hOldFont = 0;
m_hOldPalette = 0; m_hOldPalette = 0;
m_bOwnsDC = FALSE; m_bOwnsDC = false;
m_hDC = 0; m_hDC = 0;
m_hOldPS = NULL; m_hOldPS = NULL;
m_hPS = NULL; m_hPS = NULL;
m_bIsPaintTime = FALSE; // True at Paint Time m_bIsPaintTime = false; // True at Paint Time
vColor.InitFromName("BLACK"); wxColour vColor( wxT("BLACK") );
m_pen.SetColour(vColor); m_pen.SetColour(vColor);
vColor.Set("WHITE");
vColor.Set( wxT("WHITE") );
m_brush.SetColour(vColor); m_brush.SetColour(vColor);
} // end of wxDC::wxDC } // end of wxDC::wxDC
wxDC::~wxDC(void) wxDC::~wxDC(void)
@@ -459,7 +459,7 @@ void wxDC::DoSetClippingRegion(
RECTL vRect; RECTL vRect;
vY = OS2Y(vY,vHeight); vY = OS2Y(vY,vHeight);
m_clipping = TRUE; m_clipping = true;
vRect.xLeft = vX; vRect.xLeft = vX;
vRect.yTop = vY + vHeight; vRect.yTop = vY + vHeight;
vRect.xRight = vX + vWidth; vRect.xRight = vX + vWidth;
@@ -475,7 +475,7 @@ void wxDC::DoSetClippingRegionAsRegion(
wxCHECK_RET(rRegion.GetHRGN(), wxT("invalid clipping region")); wxCHECK_RET(rRegion.GetHRGN(), wxT("invalid clipping region"));
HRGN hRgnOld; HRGN hRgnOld;
m_clipping = TRUE; m_clipping = true;
::GpiSetClipRegion( m_hPS ::GpiSetClipRegion( m_hPS
,(HRGN)rRegion.GetHRGN() ,(HRGN)rRegion.GetHRGN()
,&hRgnOld ,&hRgnOld
@@ -503,7 +503,7 @@ void wxDC::DestroyClippingRegion(void)
::GpiSetClipRegion(m_hPS, hRgn, &hRgnOld); ::GpiSetClipRegion(m_hPS, hRgn, &hRgnOld);
} }
m_clipping = FALSE; m_clipping = false;
} // end of wxDC::DestroyClippingRegion } // end of wxDC::DestroyClippingRegion
// --------------------------------------------------------------------------- // ---------------------------------------------------------------------------
@@ -512,7 +512,7 @@ void wxDC::DestroyClippingRegion(void)
bool wxDC::CanDrawBitmap() const bool wxDC::CanDrawBitmap() const
{ {
return TRUE; return true;
} }
bool wxDC::CanGetTextExtent() const bool wxDC::CanGetTextExtent() const
@@ -571,7 +571,7 @@ bool wxDC::DoFloodFill(
LONG lColor; LONG lColor;
LONG lOptions; LONG lOptions;
LONG lHits; LONG lHits;
bool bSuccess = FALSE; bool bSuccess = false;
vPtlPos.x = vX; // Loads x-coordinate vPtlPos.x = vX; // Loads x-coordinate
vPtlPos.y = OS2Y(vY,0); // Loads y-coordinate vPtlPos.y = OS2Y(vY,0); // Loads y-coordinate
@@ -582,8 +582,9 @@ bool wxDC::DoFloodFill(
lOptions = FF_SURFACE; lOptions = FF_SURFACE;
if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR) if ((lHits = ::GpiFloodFill(m_hPS, lOptions, lColor)) != GPI_ERROR)
bSuccess = TRUE; bSuccess = true;
return TRUE;
return true;
} // end of wxDC::DoFloodFill } // end of wxDC::DoFloodFill
bool wxDC::DoGetPixel( bool wxDC::DoGetPixel(
@@ -1290,13 +1291,13 @@ void wxDC::DoDrawIcon(
// //
if (rIcon.IsXpm()) if (rIcon.IsXpm())
{ {
DoDrawBitmap(rIcon.GetXpmSrc(), vX, vY, TRUE); DoDrawBitmap(rIcon.GetXpmSrc(), vX, vY, true);
} }
else else
{ {
wxBitmap vBitmap(rIcon); wxBitmap vBitmap(rIcon);
DoDrawBitmap(vBitmap, vX, vY, FALSE); DoDrawBitmap(vBitmap, vX, vY, false);
} }
CalcBoundingBox(vX, vY); CalcBoundingBox(vX, vY);
CalcBoundingBox(vX + rIcon.GetWidth(), vY + rIcon.GetHeight()); CalcBoundingBox(vX + rIcon.GetWidth(), vY + rIcon.GetHeight());
@@ -2074,7 +2075,7 @@ void wxDC::SetBackground(
return; return;
if (m_pCanvas) if (m_pCanvas)
{ {
bool bCustomColours = TRUE; bool bCustomColours = true;
// //
// If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to // If we haven't specified wxUSER_COLOURS, don't allow the panel/dialog box to
@@ -2082,12 +2083,12 @@ void wxDC::SetBackground(
// //
if (m_pCanvas->IsKindOf(CLASSINFO(wxWindow)) && if (m_pCanvas->IsKindOf(CLASSINFO(wxWindow)) &&
((m_pCanvas->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS)) ((m_pCanvas->GetWindowStyleFlag() & wxUSER_COLOURS) != wxUSER_COLOURS))
bCustomColours = FALSE; bCustomColours = false;
if (bCustomColours) if (bCustomColours)
{ {
if (m_backgroundBrush.GetStyle()==wxTRANSPARENT) if (m_backgroundBrush.GetStyle()==wxTRANSPARENT)
{ {
m_pCanvas->SetTransparent(TRUE); m_pCanvas->SetTransparent(true);
} }
else else
{ {
@@ -2101,7 +2102,7 @@ void wxDC::SetBackground(
// parent? // parent?
// m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour()); // m_canvas->SetBackgroundColour(m_backgroundBrush.GetColour());
// //
m_pCanvas->SetTransparent(FALSE); m_pCanvas->SetTransparent(false);
} }
} }
} }
@@ -2192,8 +2193,8 @@ bool wxDC::StartDoc(
const wxString& rsMessage const wxString& rsMessage
) )
{ {
// We might be previewing, so return TRUE to let it continue. // We might be previewing, so return true to let it continue.
return TRUE; return true;
} // end of wxDC::StartDoc } // end of wxDC::StartDoc
void wxDC::EndDoc() void wxDC::EndDoc()
@@ -2471,7 +2472,7 @@ wxCoord wxDCBase::DeviceToLogicalX(wxCoord x) const
wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const wxCoord wxDCBase::DeviceToLogicalXRel(wxCoord x) const
{ {
// axis orientation is not taken into account for conversion of a distance // axis orientation is not taken into account for conversion of a distance
return (wxCoord) ((x)/(m_logicalScaleX*m_userScaleX*m_scaleX)); return (wxCoord) ((x)/(m_logicalScaleX*m_userScaleX*m_scaleX));
} }
@@ -2482,7 +2483,7 @@ wxCoord wxDCBase::DeviceToLogicalY(wxCoord y) const
wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const wxCoord wxDCBase::DeviceToLogicalYRel(wxCoord y) const
{ {
// axis orientation is not taken into account for conversion of a distance // axis orientation is not taken into account for conversion of a distance
return (wxCoord) ((y)/(m_logicalScaleY*m_userScaleY*m_scaleY)); return (wxCoord) ((y)/(m_logicalScaleY*m_userScaleY*m_scaleY));
} }
@@ -2493,7 +2494,7 @@ wxCoord wxDCBase::LogicalToDeviceX(wxCoord x) const
wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const wxCoord wxDCBase::LogicalToDeviceXRel(wxCoord x) const
{ {
// axis orientation is not taken into account for conversion of a distance // axis orientation is not taken into account for conversion of a distance
return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_scaleX); return (wxCoord) (x*m_logicalScaleX*m_userScaleX*m_scaleX);
} }
@@ -2504,7 +2505,7 @@ wxCoord wxDCBase::LogicalToDeviceY(wxCoord y) const
wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const wxCoord wxDCBase::LogicalToDeviceYRel(wxCoord y) const
{ {
// axis orientation is not taken into account for conversion of a distance // axis orientation is not taken into account for conversion of a distance
return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_scaleY); return (wxCoord) (y*m_logicalScaleY*m_userScaleY*m_scaleY);
} }
@@ -2538,7 +2539,7 @@ bool wxDC::DoBlit(
pMask = rBmp.GetMask(); pMask = rBmp.GetMask();
if (!(rBmp.Ok() && pMask && pMask->GetMaskBitmap())) if (!(rBmp.Ok() && pMask && pMask->GetMaskBitmap()))
{ {
bUseMask = FALSE; bUseMask = false;
} }
} }
@@ -2586,7 +2587,7 @@ bool wxDC::DoBlit(
case wxNOR: lRop = ROP_NOTSRCCOPY; break; case wxNOR: lRop = ROP_NOTSRCCOPY; break;
default: default:
wxFAIL_MSG( wxT("unsupported logical function") ); wxFAIL_MSG( wxT("unsupported logical function") );
return FALSE; return false;
} }
bool bSuccess; bool bSuccess;
@@ -2618,7 +2619,7 @@ bool wxDC::DoBlit(
vBmpHdr.cBitCount = 24; vBmpHdr.cBitCount = 24;
#if wxUSE_DC_CACHEING #if wxUSE_DC_CACHEING
if (TRUE) if (true)
{ {
// //
// create a temp buffer bitmap and DCs to access it and the mask // create a temp buffer bitmap and DCs to access it and the mask
@@ -2649,24 +2650,24 @@ bool wxDC::DoBlit(
} }
POINTL aPoint1[4] = { {0, 0} POINTL aPoint1[4] = { {0, 0}
,{vWidth, vHeight} ,{vWidth, vHeight}
,{vXdest, vYdest} ,{vXdest, vYdest}
,{vXdest + vWidth, vYdest + vHeight} ,{vXdest + vWidth, vYdest + vHeight}
}; };
POINTL aPoint2[4] = { {0, 0} POINTL aPoint2[4] = { {0, 0}
,{vWidth, vHeight} ,{vWidth, vHeight}
,{vXsrc, vYsrc} ,{vXsrc, vYsrc}
,{vXsrc + vWidth, vYsrc + vHeight} ,{vXsrc + vWidth, vYsrc + vHeight}
}; };
POINTL aPoint3[4] = { {vXdest, vYdest} POINTL aPoint3[4] = { {vXdest, vYdest}
,{vXdest + vWidth, vYdest + vHeight} ,{vXdest + vWidth, vYdest + vHeight}
,{vXsrc, vYsrc} ,{vXsrc, vYsrc}
,{vXsrc + vWidth, vYsrc + vHeight} ,{vXsrc + vWidth, vYsrc + vHeight}
}; };
POINTL aPoint4[4] = { {vXdest, vYdest} POINTL aPoint4[4] = { {vXdest, vYdest}
,{vXdest + vWidth, vYdest + vHeight} ,{vXdest + vWidth, vYdest + vHeight}
,{0, 0} ,{0, 0}
,{vWidth, vHeight} ,{vWidth, vHeight}
}; };
::GpiSetBitmap(hPSMask, (HBITMAP) pMask->GetMaskBitmap()); ::GpiSetBitmap(hPSMask, (HBITMAP) pMask->GetMaskBitmap());
::GpiSetBitmap(hPSBuffer, (HBITMAP) hBufBitmap); ::GpiSetBitmap(hPSBuffer, (HBITMAP) hBufBitmap);
@@ -2757,7 +2758,7 @@ bool wxDC::DoBlit(
); );
if (rc == GPI_ERROR) if (rc == GPI_ERROR)
{ {
bSuccess = FALSE; bSuccess = false;
wxLogLastError(wxT("BitBlt")); wxLogLastError(wxT("BitBlt"));
} }
@@ -2773,14 +2774,14 @@ bool wxDC::DoBlit(
::DevCloseDC(hDCBuffer); ::DevCloseDC(hDCBuffer);
::GpiDeleteBitmap(hBufBitmap); ::GpiDeleteBitmap(hBufBitmap);
#endif #endif
bSuccess = TRUE; bSuccess = true;
} }
else // no mask, just BitBlt() it else // no mask, just BitBlt() it
{ {
POINTL aPoint[4] = { {vXdest, vYdest} POINTL aPoint[4] = { {vXdest, vYdest}
,{vXdest + vWidth, vYdest + vHeight} ,{vXdest + vWidth, vYdest + vHeight}
,{vXsrc, vYsrc} ,{vXsrc, vYsrc}
,{vXsrc + vWidth, vYsrc + vHeight} ,{vXsrc + vWidth, vYsrc + vHeight}
}; };
bSuccess = (::GpiBitBlt( m_hPS bSuccess = (::GpiBitBlt( m_hPS

View File

@@ -142,7 +142,6 @@ wxWindowDC::wxWindowDC(
void wxWindowDC::InitDC() void wxWindowDC::InitDC()
{ {
wxColour vColor;
// //
// The background mode is only used for text background and is set in // The background mode is only used for text background and is set in
@@ -155,9 +154,10 @@ void wxWindowDC::InitDC()
// //
SetBackground(wxBrush(m_pCanvas->GetBackgroundColour(), wxSOLID)); SetBackground(wxBrush(m_pCanvas->GetBackgroundColour(), wxSOLID));
vColor.InitFromName("BLACK"); wxColour vColor( wxT("BLACK") );
m_pen.SetColour(vColor); m_pen.SetColour(vColor);
vColor.Set("WHITE");
vColor.Set( wxT("WHITE") );
m_brush.SetColour(vColor); m_brush.SetColour(vColor);
InitializePalette(); InitializePalette();
wxFont* pFont = new wxFont( 12 wxFont* pFont = new wxFont( 12

View File

@@ -56,7 +56,6 @@ void wxToolTip::Create(
) )
{ {
ULONG lStyle = ES_READONLY | ES_MARGIN | ES_CENTER; ULONG lStyle = ES_READONLY | ES_MARGIN | ES_CENTER;
wxColour vColor;
LONG lColor; LONG lColor;
char zFont[128]; char zFont[128];
@@ -74,7 +73,7 @@ void wxToolTip::Create(
if (!m_hWnd) if (!m_hWnd)
wxLogError("Unable to create tooltip window"); wxLogError("Unable to create tooltip window");
vColor.InitFromName("YELLOW"); wxColour vColor( wxT("YELLOW") );
lColor = (LONG)vColor.GetPixel(); lColor = (LONG)vColor.GetPixel();
::WinSetPresParam( m_hWnd ::WinSetPresParam( m_hWnd
,PP_BACKGROUNDCOLOR ,PP_BACKGROUNDCOLOR

View File

@@ -33,7 +33,7 @@ public:
m_color.blue = 0; m_color.blue = 0;
m_color.pixel = 0; m_color.pixel = 0;
m_colormap = (WXColormap *) NULL; m_colormap = (WXColormap *) NULL;
m_hasPixel = FALSE; m_hasPixel = false;
} }
wxColourRefData(const wxColourRefData& data): wxColourRefData(const wxColourRefData& data):
wxObjectRefData() wxObjectRefData()
@@ -42,7 +42,7 @@ public:
m_colormap = data.m_colormap; m_colormap = data.m_colormap;
m_hasPixel = data.m_hasPixel; m_hasPixel = data.m_hasPixel;
} }
~wxColourRefData() ~wxColourRefData()
{ {
FreeColour(); FreeColour();
@@ -57,7 +57,7 @@ public:
m_color.blue == data.m_color.blue && m_color.blue == data.m_color.blue &&
m_color.pixel == data.m_color.pixel); m_color.pixel == data.m_color.pixel);
} }
void FreeColour(); void FreeColour();
void AllocColour( WXColormap cmap ); void AllocColour( WXColormap cmap );
@@ -71,8 +71,8 @@ public:
static unsigned short colMapAllocCounter[ 256 ]; static unsigned short colMapAllocCounter[ 256 ];
}; };
unsigned short wxColourRefData::colMapAllocCounter[ 256 ] = unsigned short wxColourRefData::colMapAllocCounter[ 256 ] =
{ {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
@@ -92,13 +92,13 @@ void wxColourRefData::FreeColour()
{ {
if (!m_colormap) if (!m_colormap)
return; return;
#if !wxUSE_NANOX #if !wxUSE_NANOX
if ((wxTheApp->m_visualInfo->m_visualType == GrayScale) || if ((wxTheApp->m_visualInfo->m_visualType == GrayScale) ||
(wxTheApp->m_visualInfo->m_visualType == PseudoColor)) (wxTheApp->m_visualInfo->m_visualType == PseudoColor))
{ {
int idx = m_color.pixel; int idx = m_color.pixel;
colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1; colMapAllocCounter[ idx ] = colMapAllocCounter[ idx ] - 1;
if (colMapAllocCounter[ idx ] == 0) if (colMapAllocCounter[ idx ] == 0)
{ {
unsigned long pixel = m_color.pixel; unsigned long pixel = m_color.pixel;
@@ -128,7 +128,7 @@ void wxColourRefData::AllocColour( WXColormap cmap )
{ {
m_hasPixel = XAllocColor( wxGlobalDisplay(), (Colormap) cmap, &m_color ); m_hasPixel = XAllocColor( wxGlobalDisplay(), (Colormap) cmap, &m_color );
} }
m_colormap = cmap; m_colormap = cmap;
} }
@@ -147,7 +147,7 @@ wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
M_COLDATA->m_color.red = ((unsigned short)red) ; M_COLDATA->m_color.red = ((unsigned short)red) ;
M_COLDATA->m_color.green = ((unsigned short)green) ; M_COLDATA->m_color.green = ((unsigned short)green) ;
M_COLDATA->m_color.blue = ((unsigned short)blue) ; M_COLDATA->m_color.blue = ((unsigned short)blue) ;
#else #else
M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT; M_COLDATA->m_color.red = ((unsigned short)red) << SHIFT;
M_COLDATA->m_color.green = ((unsigned short)green) << SHIFT; M_COLDATA->m_color.green = ((unsigned short)green) << SHIFT;
M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT; M_COLDATA->m_color.blue = ((unsigned short)blue) << SHIFT;
@@ -204,17 +204,17 @@ wxColour::~wxColour()
bool wxColour::operator == ( const wxColour& col ) const bool wxColour::operator == ( const wxColour& col ) const
{ {
if (m_refData == col.m_refData) return TRUE; if (m_refData == col.m_refData) return true;
if (!m_refData || !col.m_refData) return FALSE; if (!m_refData || !col.m_refData) return false;
XColor *own = &(((wxColourRefData*)m_refData)->m_color); XColor *own = &(((wxColourRefData*)m_refData)->m_color);
XColor *other = &(((wxColourRefData*)col.m_refData)->m_color); XColor *other = &(((wxColourRefData*)col.m_refData)->m_color);
if (own->red != other->red) return FALSE;
if (own->blue != other->blue) return FALSE;
if (own->green != other->green) return FALSE;
return TRUE; return (own->red == other->red)
&& (own->green == other->green)
&& (own->blue == other->blue)
} }
wxObjectRefData *wxColour::CreateRefData() const wxObjectRefData *wxColour::CreateRefData() const
@@ -230,7 +230,7 @@ wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const
void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
{ {
AllocExclusive(); AllocExclusive();
m_refData = new wxColourRefData(); m_refData = new wxColourRefData();
#if wxUSE_NANOX #if wxUSE_NANOX
M_COLDATA->m_color.red = ((unsigned short)red) ; M_COLDATA->m_color.red = ((unsigned short)red) ;