Added missing test in wxObject::Ref() for already

equal objects (same m_refData).
  Implemented new ref counting for wxBrush, wxPen
    and wxColour (in addition to wxRegion). Also
    inlined some more functions and implemented
    real comparisons.
  Corrected refresh code to update GTK's window-less
    widgets if overdrawn after a wxWindow::Refresh().


git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@13999 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Robert Roebling
2002-02-04 18:01:21 +00:00
parent a407ff6ae8
commit c89f5c02b1
20 changed files with 524 additions and 550 deletions

View File

@@ -34,15 +34,19 @@ class wxBrush;
class wxBrush: public wxGDIObject
{
public:
wxBrush();
wxBrush() { }
wxBrush( const wxColour &colour, int style );
wxBrush( const wxBitmap &stippleBitmap );
wxBrush( const wxBrush &brush );
~wxBrush();
wxBrush& operator = ( const wxBrush& brush );
wxBrush( const wxBrush &brush ) { Ref(brush); }
wxBrush& operator = ( const wxBrush& brush ) { Ref(brush); return *this; }
bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxBrush& brush ) const;
bool operator != ( const wxBrush& brush ) const;
bool Ok() const;
bool operator != (const wxBrush& brush) const { return !(*this == brush); }
int GetStyle() const;
wxColour &GetColour() const;
@@ -53,9 +57,11 @@ public:
void SetStyle( int style );
void SetStipple( const wxBitmap& stipple );
void Unshare();
private:
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
DECLARE_DYNAMIC_CLASS(wxBrush)
};

View File

@@ -39,55 +39,56 @@ class wxColour;
class wxColour: public wxGDIObject
{
public:
// ctors
// default
wxColour();
// from RGB
wxColour( unsigned char red, unsigned char green, unsigned char blue );
wxColour( unsigned long colRGB ) { Set(colRGB); }
wxColour() { }
// Construct from RGB
wxColour( unsigned char red, unsigned char green, unsigned char blue );
wxColour( unsigned long colRGB ) { Set(colRGB); }
// implicit conversion from the colour name
wxColour( const wxString &colourName ) { InitFromName(colourName); }
wxColour( const char *colourName ) { InitFromName(colourName); }
// 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& operator = ( const wxColour& col );
wxColour( const wxColour& col ) { Ref(col); }
wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
// dtor
~wxColour();
~wxColour();
// comparison
bool operator == ( const wxColour& col ) const;
bool operator != ( const wxColour& col ) const;
bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxColour& col ) const;
bool operator != ( const wxColour& col ) const { return !(*this == col); }
// accessors
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,
(unsigned char)(colRGB >> 8),
(unsigned char)(colRGB >> 16));
}
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,
(unsigned char)(colRGB >> 8),
(unsigned char)(colRGB >> 16));
}
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
// implementation
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
// Implementation part
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
protected:
// helper functions
void InitFromName(const wxString& colourName);
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// Helper functions
void InitFromName(const wxString& colourName);
private:
DECLARE_DYNAMIC_CLASS(wxColour)
DECLARE_DYNAMIC_CLASS(wxColour)
};
#endif // __GTKCOLOURH__

View File

@@ -40,13 +40,18 @@ typedef gchar wxGTKDash;
class wxPen: public wxGDIObject
{
public:
wxPen();
wxPen() { }
wxPen( const wxColour &colour, int width, int style );
wxPen( const wxPen& pen );
~wxPen();
wxPen& operator = ( const wxPen& pen );
wxPen( const wxPen& pen ) { Ref(pen); }
wxPen& operator = ( const wxPen& pen ) { Ref(pen); return *this; }
bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxPen& pen ) const;
bool operator != ( const wxPen& pen ) const;
bool operator != (const wxPen& pen) const { return !(*this == pen); }
void SetColour( const wxColour &colour );
void SetColour( int red, int green, int blue );
@@ -64,12 +69,12 @@ public:
int GetDashes(wxDash **ptr) const;
int GetDashCount() const;
wxDash* GetDash() const;
bool Ok() const;
void Unshare();
private:
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
DECLARE_DYNAMIC_CLASS(wxPen)
};

View File

@@ -71,13 +71,15 @@ public:
}
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
virtual ~wxRegion();
~wxRegion();
wxRegion( const wxRegion& r ) { Ref(r); }
wxRegion& operator = ( const wxRegion& r ) { Ref(r); return *this; }
wxRegion( const wxRegion& region ) { Ref(region); }
wxRegion& operator = ( const wxRegion& region ) { Ref(region); return *this; }
bool Ok() const { return m_refData != NULL; }
bool operator == ( const wxRegion& region );
bool operator != ( const wxRegion& region );
bool operator != ( const wxRegion& region ) { return !(*this == region); }
void Clear();