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

@@ -1,11 +1,29 @@
*** wxWindows 2.3.3 *** *** wxWindows 2.3.3 ***
Implemented new ref-counting for GDI classes.
New implemenation of wxCondition.
Implemented actual comparisons between GDI classes instead of
comparing just the ref-count.
Fixed wxMiniFrame again.
Added wxCursor creation from wxImage.
Added inlined wxHashMap class.
Redone thread wake-up code for immediate wake-up instead
of 50 ms pause. This gives apps 100% CPU time for background
tasks.
New behaviour for wxWindow::Refresh() as it now produces a New behaviour for wxWindow::Refresh() as it now produces a
delayed refresh. Call the new wxWindow::Update() to force delayed refresh. Call the new wxWindow::Update() to force
an immediate update. an immediate update.
Support for more SGI hardware (12-bit mode among others). Support for more SGI hardware (12-bit mode among others) and
corrections to wxImage code for special SGI visuals.
Changed wxDC::Blit() to honour source DC's logical coordinates. Changed wxDC::Blit() to honour source DC's logical coordinates.
@@ -14,16 +32,14 @@ tasks (unlike thread work).
Various updates to wxHTML. Various updates to wxHTML.
Some wxFont changes for better mixing of native fonts Some wxFont changes for better mixing of native fonts and
and wxFont's accessors. wxFont's accessors.
Corrections to wxImage code for special SGI visuals.
Added IFF image handler. Added IFF image handler.
Added ICO, CUR and ANI image handler. Added ICO, CUR and ANI image handler.
wxFrame::SetMenuBar() works again. wxFrame::SetMenuBar() corrected.
wxButton honours wxBU_EXACTFIT. wxButton honours wxBU_EXACTFIT.

View File

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

View File

@@ -39,55 +39,56 @@ class wxColour;
class wxColour: public wxGDIObject class wxColour: public wxGDIObject
{ {
public: public:
// ctors wxColour() { }
// default
wxColour(); // Construct from RGB
// 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); }
// 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 wxColour( const wxColour& col ) { Ref(col); }
wxColour( const wxColour& col ); wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
wxColour& operator = ( const wxColour& col );
// dtor ~wxColour();
~wxColour();
// comparison 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;
bool operator != ( const wxColour& col ) const { return !(*this == col); }
// accessors 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 ) {
{ // 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)); }
}
unsigned char Red() const; unsigned char Red() const;
unsigned char Green() const; unsigned char Green() const;
unsigned char Blue() const; unsigned char Blue() const;
bool Ok() const;
// implementation
void CalcPixel( GdkColormap *cmap ); // Implementation part
int GetPixel() const; void CalcPixel( GdkColormap *cmap );
GdkColor *GetColor() const; int GetPixel() const;
GdkColor *GetColor() const;
protected: protected:
// helper functions // ref counting code
void InitFromName(const wxString& colourName); virtual wxObjectRefData *CreateRefData() 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)
}; };
#endif // __GTKCOLOURH__ #endif // __GTKCOLOURH__

View File

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

View File

@@ -71,13 +71,15 @@ public:
} }
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
virtual ~wxRegion(); ~wxRegion();
wxRegion( const wxRegion& r ) { Ref(r); } wxRegion( const wxRegion& region ) { Ref(region); }
wxRegion& operator = ( const wxRegion& r ) { Ref(r); return *this; } 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 ); bool operator != ( const wxRegion& region ) { return !(*this == region); }
void Clear(); void Clear();

View File

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

View File

@@ -39,55 +39,56 @@ class wxColour;
class wxColour: public wxGDIObject class wxColour: public wxGDIObject
{ {
public: public:
// ctors wxColour() { }
// default
wxColour(); // Construct from RGB
// 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); }
// 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 wxColour( const wxColour& col ) { Ref(col); }
wxColour( const wxColour& col ); wxColour& operator = ( const wxColour& col ) { Ref(col); return *this; }
wxColour& operator = ( const wxColour& col );
// dtor ~wxColour();
~wxColour();
// comparison 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;
bool operator != ( const wxColour& col ) const { return !(*this == col); }
// accessors 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 ) {
{ // 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)); }
}
unsigned char Red() const; unsigned char Red() const;
unsigned char Green() const; unsigned char Green() const;
unsigned char Blue() const; unsigned char Blue() const;
bool Ok() const;
// implementation
void CalcPixel( GdkColormap *cmap ); // Implementation part
int GetPixel() const; void CalcPixel( GdkColormap *cmap );
GdkColor *GetColor() const; int GetPixel() const;
GdkColor *GetColor() const;
protected: protected:
// helper functions // ref counting code
void InitFromName(const wxString& colourName); virtual wxObjectRefData *CreateRefData() 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)
}; };
#endif // __GTKCOLOURH__ #endif // __GTKCOLOURH__

View File

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

View File

@@ -71,13 +71,15 @@ public:
} }
wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE ); wxRegion( size_t n, const wxPoint *points, int fillStyle = wxODDEVEN_RULE );
virtual ~wxRegion(); ~wxRegion();
wxRegion( const wxRegion& r ) { Ref(r); } wxRegion( const wxRegion& region ) { Ref(region); }
wxRegion& operator = ( const wxRegion& r ) { Ref(r); return *this; } 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 ); bool operator != ( const wxRegion& region ) { return !(*this == region); }
void Clear(); void Clear();

View File

@@ -230,6 +230,10 @@ void wxObject::Ref(const wxObject& clone)
DEBUG_PRINTF(wxObject::Ref) DEBUG_PRINTF(wxObject::Ref)
#endif #endif
// nothing to be done
if (m_refData == clone.m_refData)
return;
// delete reference to old data // delete reference to old data
UnRef(); UnRef();

View File

@@ -22,36 +22,36 @@
class wxBrushRefData: public wxObjectRefData class wxBrushRefData: public wxObjectRefData
{ {
public: public:
wxBrushRefData(); wxBrushRefData()
wxBrushRefData( const wxBrushRefData& data ); {
m_style = 0;
int m_style; }
wxBitmap m_stipple;
wxColour m_colour; wxBrushRefData( const wxBrushRefData& data )
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
}
bool operator == (const wxBrushRefData& data) const
{
return (m_style == data.m_style &&
m_stipple == data.m_stipple &&
m_colour == data.m_colour);
}
int m_style;
wxColour m_colour;
wxBitmap m_stipple;
}; };
wxBrushRefData::wxBrushRefData()
{
m_style = 0;
}
wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define M_BRUSHDATA ((wxBrushRefData *)m_refData) #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
wxBrush::wxBrush()
{
}
wxBrush::wxBrush( const wxColour &colour, int style ) wxBrush::wxBrush( const wxColour &colour, int style )
{ {
m_refData = new wxBrushRefData(); m_refData = new wxBrushRefData();
@@ -72,36 +72,28 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap )
M_BRUSHDATA->m_style = wxSTIPPLE; M_BRUSHDATA->m_style = wxSTIPPLE;
} }
wxBrush::wxBrush( const wxBrush &brush )
{
Ref( brush );
}
wxBrush::~wxBrush() wxBrush::~wxBrush()
{ {
// m_refData unrefed in ~wxObject
} }
wxBrush& wxBrush::operator = ( const wxBrush& brush ) wxObjectRefData *wxBrush::CreateRefData() const
{ {
if ( m_refData != brush.m_refData ) return new wxBrushRefData;
Ref( brush ); }
return *this; wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
{
return new wxBrushRefData(*(wxBrushRefData *)data);
} }
bool wxBrush::operator == ( const wxBrush& brush ) const bool wxBrush::operator == ( const wxBrush& brush ) const
{ {
return m_refData == brush.m_refData; if (m_refData == brush.m_refData) return TRUE;
}
if (!m_refData || !brush.m_refData) return FALSE;
bool wxBrush::operator != ( const wxBrush& brush ) const
{ return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
return m_refData != brush.m_refData;
}
bool wxBrush::Ok() const
{
return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
} }
int wxBrush::GetStyle() const int wxBrush::GetStyle() const
@@ -139,25 +131,29 @@ wxBitmap *wxBrush::GetStipple() const
void wxBrush::SetColour( const wxColour& col ) void wxBrush::SetColour( const wxColour& col )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_colour = col; M_BRUSHDATA->m_colour = col;
} }
void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b ) void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_colour.Set( r, g, b ); M_BRUSHDATA->m_colour.Set( r, g, b );
} }
void wxBrush::SetStyle( int style ) void wxBrush::SetStyle( int style )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_style = style; M_BRUSHDATA->m_style = style;
} }
void wxBrush::SetStipple( const wxBitmap& stipple ) void wxBrush::SetStipple( const wxBitmap& stipple )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_stipple = stipple; M_BRUSHDATA->m_stipple = stipple;
if (M_BRUSHDATA->m_stipple.GetMask()) if (M_BRUSHDATA->m_stipple.GetMask())
{ {
@@ -169,17 +165,3 @@ void wxBrush::SetStipple( const wxBitmap& stipple )
} }
} }
void wxBrush::Unshare()
{
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
wxBrushRefData* ref = new wxBrushRefData( *(wxBrushRefData*)m_refData );
UnRef();
m_refData = ref;
}
}

View File

@@ -25,13 +25,34 @@
class wxColourRefData: public wxObjectRefData class wxColourRefData: public wxObjectRefData
{ {
public: public:
wxColourRefData(); wxColourRefData()
~wxColourRefData(); {
m_color.red = 0;
m_color.green = 0;
m_color.blue = 0;
m_color.pixel = 0;
m_colormap = (GdkColormap *) NULL;
m_hasPixel = FALSE;
}
~wxColourRefData()
{
FreeColour();
}
bool operator == (const wxColourRefData& data) const
{
return (m_colormap == data.m_colormap &&
m_hasPixel == data.m_hasPixel &&
m_color.red == data.m_color.red &&
m_color.green == data.m_color.green &&
m_color.blue == data.m_color.blue &&
m_color.pixel == data.m_color.pixel);
}
void FreeColour(); void FreeColour();
void AllocColour( GdkColormap* cmap ); void AllocColour( GdkColormap* cmap );
public:
GdkColor m_color; GdkColor m_color;
GdkColormap *m_colormap; GdkColormap *m_colormap;
bool m_hasPixel; bool m_hasPixel;
@@ -59,21 +80,6 @@ gushort 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
}; };
wxColourRefData::wxColourRefData()
{
m_color.red = 0;
m_color.green = 0;
m_color.blue = 0;
m_color.pixel = 0;
m_colormap = (GdkColormap *) NULL;
m_hasPixel = FALSE;
}
wxColourRefData::~wxColourRefData()
{
FreeColour();
}
void wxColourRefData::FreeColour() void wxColourRefData::FreeColour()
{ {
if (m_colormap) if (m_colormap)
@@ -131,10 +137,6 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject)
wxColour::wxColour()
{
}
wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
{ {
m_refData = new wxColourRefData(); m_refData = new wxColourRefData();
@@ -173,28 +175,15 @@ void wxColour::InitFromName( const wxString &colourName )
} }
} }
wxColour::wxColour( const wxColour& col )
{
Ref( col );
}
wxColour::~wxColour() wxColour::~wxColour()
{ {
} }
wxColour& wxColour::operator = ( const wxColour& col )
{
if (*this == col) return (*this);
Ref( col );
return *this;
}
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) return FALSE; if (!m_refData || !col.m_refData) return FALSE;
if (!col.m_refData) 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);
@@ -205,14 +194,20 @@ bool wxColour::operator == ( const wxColour& col ) const
return TRUE; return TRUE;
} }
bool wxColour::operator != ( const wxColour& col) const wxObjectRefData *wxColour::CreateRefData() const
{ {
return !(*this == col); return new wxColourRefData;
}
wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const
{
return new wxColourRefData(*(wxColourRefData *)data);
} }
void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
{ {
UnRef(); AllocExclusive();
m_refData = new wxColourRefData(); m_refData = new wxColourRefData();
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;
@@ -241,11 +236,6 @@ unsigned char wxColour::Blue() const
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
} }
bool wxColour::Ok() const
{
return (m_refData != NULL);
}
void wxColour::CalcPixel( GdkColormap *cmap ) void wxColour::CalcPixel( GdkColormap *cmap )
{ {
if (!Ok()) return; if (!Ok()) return;

View File

@@ -23,43 +23,48 @@
class wxPenRefData: public wxObjectRefData class wxPenRefData: public wxObjectRefData
{ {
public: public:
wxPenRefData()
wxPenRefData(); {
wxPenRefData( const wxPenRefData& data ); m_width = 1;
m_style = wxSOLID;
int m_width; m_joinStyle = wxJOIN_ROUND;
int m_style; m_capStyle = wxCAP_ROUND;
int m_joinStyle; m_dash = (wxGTKDash*) NULL;
int m_capStyle; m_countDashes = 0;
wxColour m_colour; }
int m_countDashes;
wxGTKDash *m_dash; wxPenRefData( const wxPenRefData& data )
}; {
m_style = data.m_style;
wxPenRefData::wxPenRefData() m_width = data.m_width;
{ m_joinStyle = data.m_joinStyle;
m_width = 1; m_capStyle = data.m_capStyle;
m_style = wxSOLID; m_colour = data.m_colour;
m_joinStyle = wxJOIN_ROUND; m_countDashes = data.m_countDashes;
m_capStyle = wxCAP_ROUND;
m_dash = (wxGTKDash*) NULL;
m_countDashes = 0;
}
wxPenRefData::wxPenRefData( const wxPenRefData& data )
{
m_style = data.m_style;
m_width = data.m_width;
m_joinStyle = data.m_joinStyle;
m_capStyle = data.m_capStyle;
m_colour = data.m_colour;
m_countDashes = data.m_countDashes;
/* /*
if (data.m_dash) TODO if (data.m_dash) TODO
m_dash = new m_dash = new
*/ */
m_dash = data.m_dash; m_dash = data.m_dash;
} }
bool operator == (const wxPenRefData& data) const
{
return (m_style == data.m_style &&
m_width == data.m_width &&
m_joinStyle == data.m_joinStyle &&
m_capStyle == data.m_capStyle &&
m_colour == data.m_colour);
}
int m_width;
int m_style;
int m_joinStyle;
int m_capStyle;
wxColour m_colour;
int m_countDashes;
wxGTKDash *m_dash;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -67,10 +72,6 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data )
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
wxPen::wxPen()
{
}
wxPen::wxPen( const wxColour &colour, int width, int style ) wxPen::wxPen( const wxColour &colour, int width, int style )
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
@@ -79,73 +80,77 @@ wxPen::wxPen( const wxColour &colour, int width, int style )
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
} }
wxPen::wxPen( const wxPen& pen )
{
Ref( pen );
}
wxPen::~wxPen() wxPen::~wxPen()
{ {
// m_refData unrefed in ~wxObject
} }
wxPen& wxPen::operator = ( const wxPen& pen ) wxObjectRefData *wxPen::CreateRefData() const
{ {
if ( m_refData != pen.m_refData ) return new wxPenRefData;
Ref( pen ); }
return *this; wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
{
return new wxPenRefData(*(wxPenRefData *)data);
} }
bool wxPen::operator == ( const wxPen& pen ) const bool wxPen::operator == ( const wxPen& pen ) const
{ {
return m_refData == pen.m_refData; if (m_refData == pen.m_refData) return TRUE;
}
if (!m_refData || !pen.m_refData) return FALSE;
bool wxPen::operator != ( const wxPen& pen ) const
{ return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
return m_refData != pen.m_refData;
} }
void wxPen::SetColour( const wxColour &colour ) void wxPen::SetColour( const wxColour &colour )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
} }
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash ) void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_countDashes = number_of_dashes; M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */ M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
} }
void wxPen::SetColour( int red, int green, int blue ) void wxPen::SetColour( int red, int green, int blue )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_colour.Set( red, green, blue ); M_PENDATA->m_colour.Set( red, green, blue );
} }
void wxPen::SetCap( int capStyle ) void wxPen::SetCap( int capStyle )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_capStyle = capStyle; M_PENDATA->m_capStyle = capStyle;
} }
void wxPen::SetJoin( int joinStyle ) void wxPen::SetJoin( int joinStyle )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_joinStyle = joinStyle; M_PENDATA->m_joinStyle = joinStyle;
} }
void wxPen::SetStyle( int style ) void wxPen::SetStyle( int style )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_style = style; M_PENDATA->m_style = style;
} }
void wxPen::SetWidth( int width ) void wxPen::SetWidth( int width )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_width = width; M_PENDATA->m_width = width;
} }
@@ -200,22 +205,3 @@ wxColour &wxPen::GetColour() const
return M_PENDATA->m_colour; return M_PENDATA->m_colour;
} }
bool wxPen::Ok() const
{
return (m_refData != NULL);
}
void wxPen::Unshare()
{
if (!m_refData)
{
m_refData = new wxPenRefData();
}
else
{
wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData );
UnRef();
m_refData = ref;
}
}

View File

@@ -133,22 +133,22 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
{ {
return new wxRegionRefData(*(wxRegionRefData *)data); return new wxRegionRefData(*(wxRegionRefData *)data);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion comparison // wxRegion comparison
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegion::operator==( const wxRegion& region ) bool wxRegion::operator==( const wxRegion& region )
{ {
if (m_refData == region.m_refData) return TRUE;
if (!m_refData || !region.m_refData) return FALSE;
// compare the regions themselves, not the pointers to ref data! // compare the regions themselves, not the pointers to ref data!
return gdk_region_equal(M_REGIONDATA->m_region, return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region); M_REGIONDATA_OF(region)->m_region);
} }
bool wxRegion::operator != ( const wxRegion& region )
{
return !(*this == region);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion operations // wxRegion operations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -805,30 +805,6 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (gdk_event->count == 0) if (gdk_event->count == 0)
win->GtkSendPaintEvents(); win->GtkSendPaintEvents();
// The following code will result in all window-less widgets
// being redrawn if the wxWindows class is given a chance to
// paint *anything* because it will then be allowed to paint
// over the window-less widgets.
GList *children = pizza->children;
while (children)
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
GdkEventExpose child_event = *gdk_event;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget) /* &&
gtk_widget_intersect (child->widget, &gdk_event->area, &child_event.area)*/ )
{
child_event.area.x = child->widget->allocation.x;
child_event.area.y = child->widget->allocation.y;
child_event.area.width = child->widget->allocation.width;
child_event.area.height = child->widget->allocation.height;
gtk_widget_event (child->widget, (GdkEvent*) &child_event);
}
}
return TRUE; return TRUE;
} }
@@ -3439,9 +3415,38 @@ void wxWindowGTK::GtkSendPaintEvents()
paint_event.SetEventObject( this ); paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( paint_event ); GetEventHandler()->ProcessEvent( paint_event );
m_updateRegion.Clear();
m_clipPaintRegion = FALSE; m_clipPaintRegion = FALSE;
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
if (g_list_length(pizza->children) > 0)
{
// The following code will result in all window-less widgets
// being redrawn because the wxWindows class is allowed to
// paint over the window-less widgets.
GList *children = pizza->children;
while (children)
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget))
{
// Get intersection of widget area and update region
wxRegion region( m_updateRegion );
region.Intersect( child->widget->allocation.x,
child->widget->allocation.y,
child->widget->allocation.width,
child->widget->allocation.height );
// Redraw the whole widget anyway
if (!region.IsEmpty())
gtk_widget_draw( child->widget, NULL );
}
}
}
m_updateRegion.Clear();
} }
void wxWindowGTK::Clear() void wxWindowGTK::Clear()

View File

@@ -22,36 +22,36 @@
class wxBrushRefData: public wxObjectRefData class wxBrushRefData: public wxObjectRefData
{ {
public: public:
wxBrushRefData(); wxBrushRefData()
wxBrushRefData( const wxBrushRefData& data ); {
m_style = 0;
int m_style; }
wxBitmap m_stipple;
wxColour m_colour; wxBrushRefData( const wxBrushRefData& data )
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
}
bool operator == (const wxBrushRefData& data) const
{
return (m_style == data.m_style &&
m_stipple == data.m_stipple &&
m_colour == data.m_colour);
}
int m_style;
wxColour m_colour;
wxBitmap m_stipple;
}; };
wxBrushRefData::wxBrushRefData()
{
m_style = 0;
}
wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
{
m_style = data.m_style;
m_stipple = data.m_stipple;
m_colour = data.m_colour;
}
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
#define M_BRUSHDATA ((wxBrushRefData *)m_refData) #define M_BRUSHDATA ((wxBrushRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
wxBrush::wxBrush()
{
}
wxBrush::wxBrush( const wxColour &colour, int style ) wxBrush::wxBrush( const wxColour &colour, int style )
{ {
m_refData = new wxBrushRefData(); m_refData = new wxBrushRefData();
@@ -72,36 +72,28 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap )
M_BRUSHDATA->m_style = wxSTIPPLE; M_BRUSHDATA->m_style = wxSTIPPLE;
} }
wxBrush::wxBrush( const wxBrush &brush )
{
Ref( brush );
}
wxBrush::~wxBrush() wxBrush::~wxBrush()
{ {
// m_refData unrefed in ~wxObject
} }
wxBrush& wxBrush::operator = ( const wxBrush& brush ) wxObjectRefData *wxBrush::CreateRefData() const
{ {
if ( m_refData != brush.m_refData ) return new wxBrushRefData;
Ref( brush ); }
return *this; wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
{
return new wxBrushRefData(*(wxBrushRefData *)data);
} }
bool wxBrush::operator == ( const wxBrush& brush ) const bool wxBrush::operator == ( const wxBrush& brush ) const
{ {
return m_refData == brush.m_refData; if (m_refData == brush.m_refData) return TRUE;
}
if (!m_refData || !brush.m_refData) return FALSE;
bool wxBrush::operator != ( const wxBrush& brush ) const
{ return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
return m_refData != brush.m_refData;
}
bool wxBrush::Ok() const
{
return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
} }
int wxBrush::GetStyle() const int wxBrush::GetStyle() const
@@ -139,25 +131,29 @@ wxBitmap *wxBrush::GetStipple() const
void wxBrush::SetColour( const wxColour& col ) void wxBrush::SetColour( const wxColour& col )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_colour = col; M_BRUSHDATA->m_colour = col;
} }
void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b ) void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_colour.Set( r, g, b ); M_BRUSHDATA->m_colour.Set( r, g, b );
} }
void wxBrush::SetStyle( int style ) void wxBrush::SetStyle( int style )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_style = style; M_BRUSHDATA->m_style = style;
} }
void wxBrush::SetStipple( const wxBitmap& stipple ) void wxBrush::SetStipple( const wxBitmap& stipple )
{ {
Unshare(); AllocExclusive();
M_BRUSHDATA->m_stipple = stipple; M_BRUSHDATA->m_stipple = stipple;
if (M_BRUSHDATA->m_stipple.GetMask()) if (M_BRUSHDATA->m_stipple.GetMask())
{ {
@@ -169,17 +165,3 @@ void wxBrush::SetStipple( const wxBitmap& stipple )
} }
} }
void wxBrush::Unshare()
{
if (!m_refData)
{
m_refData = new wxBrushRefData();
}
else
{
wxBrushRefData* ref = new wxBrushRefData( *(wxBrushRefData*)m_refData );
UnRef();
m_refData = ref;
}
}

View File

@@ -25,13 +25,34 @@
class wxColourRefData: public wxObjectRefData class wxColourRefData: public wxObjectRefData
{ {
public: public:
wxColourRefData(); wxColourRefData()
~wxColourRefData(); {
m_color.red = 0;
m_color.green = 0;
m_color.blue = 0;
m_color.pixel = 0;
m_colormap = (GdkColormap *) NULL;
m_hasPixel = FALSE;
}
~wxColourRefData()
{
FreeColour();
}
bool operator == (const wxColourRefData& data) const
{
return (m_colormap == data.m_colormap &&
m_hasPixel == data.m_hasPixel &&
m_color.red == data.m_color.red &&
m_color.green == data.m_color.green &&
m_color.blue == data.m_color.blue &&
m_color.pixel == data.m_color.pixel);
}
void FreeColour(); void FreeColour();
void AllocColour( GdkColormap* cmap ); void AllocColour( GdkColormap* cmap );
public:
GdkColor m_color; GdkColor m_color;
GdkColormap *m_colormap; GdkColormap *m_colormap;
bool m_hasPixel; bool m_hasPixel;
@@ -59,21 +80,6 @@ gushort 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
}; };
wxColourRefData::wxColourRefData()
{
m_color.red = 0;
m_color.green = 0;
m_color.blue = 0;
m_color.pixel = 0;
m_colormap = (GdkColormap *) NULL;
m_hasPixel = FALSE;
}
wxColourRefData::~wxColourRefData()
{
FreeColour();
}
void wxColourRefData::FreeColour() void wxColourRefData::FreeColour()
{ {
if (m_colormap) if (m_colormap)
@@ -131,10 +137,6 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject)
wxColour::wxColour()
{
}
wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue ) wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
{ {
m_refData = new wxColourRefData(); m_refData = new wxColourRefData();
@@ -173,28 +175,15 @@ void wxColour::InitFromName( const wxString &colourName )
} }
} }
wxColour::wxColour( const wxColour& col )
{
Ref( col );
}
wxColour::~wxColour() wxColour::~wxColour()
{ {
} }
wxColour& wxColour::operator = ( const wxColour& col )
{
if (*this == col) return (*this);
Ref( col );
return *this;
}
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) return FALSE; if (!m_refData || !col.m_refData) return FALSE;
if (!col.m_refData) 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);
@@ -205,14 +194,20 @@ bool wxColour::operator == ( const wxColour& col ) const
return TRUE; return TRUE;
} }
bool wxColour::operator != ( const wxColour& col) const wxObjectRefData *wxColour::CreateRefData() const
{ {
return !(*this == col); return new wxColourRefData;
}
wxObjectRefData *wxColour::CloneRefData(const wxObjectRefData *data) const
{
return new wxColourRefData(*(wxColourRefData *)data);
} }
void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue ) void wxColour::Set( unsigned char red, unsigned char green, unsigned char blue )
{ {
UnRef(); AllocExclusive();
m_refData = new wxColourRefData(); m_refData = new wxColourRefData();
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;
@@ -241,11 +236,6 @@ unsigned char wxColour::Blue() const
return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT); return (unsigned char)(M_COLDATA->m_color.blue >> SHIFT);
} }
bool wxColour::Ok() const
{
return (m_refData != NULL);
}
void wxColour::CalcPixel( GdkColormap *cmap ) void wxColour::CalcPixel( GdkColormap *cmap )
{ {
if (!Ok()) return; if (!Ok()) return;

View File

@@ -23,43 +23,48 @@
class wxPenRefData: public wxObjectRefData class wxPenRefData: public wxObjectRefData
{ {
public: public:
wxPenRefData()
wxPenRefData(); {
wxPenRefData( const wxPenRefData& data ); m_width = 1;
m_style = wxSOLID;
int m_width; m_joinStyle = wxJOIN_ROUND;
int m_style; m_capStyle = wxCAP_ROUND;
int m_joinStyle; m_dash = (wxGTKDash*) NULL;
int m_capStyle; m_countDashes = 0;
wxColour m_colour; }
int m_countDashes;
wxGTKDash *m_dash; wxPenRefData( const wxPenRefData& data )
}; {
m_style = data.m_style;
wxPenRefData::wxPenRefData() m_width = data.m_width;
{ m_joinStyle = data.m_joinStyle;
m_width = 1; m_capStyle = data.m_capStyle;
m_style = wxSOLID; m_colour = data.m_colour;
m_joinStyle = wxJOIN_ROUND; m_countDashes = data.m_countDashes;
m_capStyle = wxCAP_ROUND;
m_dash = (wxGTKDash*) NULL;
m_countDashes = 0;
}
wxPenRefData::wxPenRefData( const wxPenRefData& data )
{
m_style = data.m_style;
m_width = data.m_width;
m_joinStyle = data.m_joinStyle;
m_capStyle = data.m_capStyle;
m_colour = data.m_colour;
m_countDashes = data.m_countDashes;
/* /*
if (data.m_dash) TODO if (data.m_dash) TODO
m_dash = new m_dash = new
*/ */
m_dash = data.m_dash; m_dash = data.m_dash;
} }
bool operator == (const wxPenRefData& data) const
{
return (m_style == data.m_style &&
m_width == data.m_width &&
m_joinStyle == data.m_joinStyle &&
m_capStyle == data.m_capStyle &&
m_colour == data.m_colour);
}
int m_width;
int m_style;
int m_joinStyle;
int m_capStyle;
wxColour m_colour;
int m_countDashes;
wxGTKDash *m_dash;
};
//----------------------------------------------------------------------------- //-----------------------------------------------------------------------------
@@ -67,10 +72,6 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data )
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject) IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
wxPen::wxPen()
{
}
wxPen::wxPen( const wxColour &colour, int width, int style ) wxPen::wxPen( const wxColour &colour, int width, int style )
{ {
m_refData = new wxPenRefData(); m_refData = new wxPenRefData();
@@ -79,73 +80,77 @@ wxPen::wxPen( const wxColour &colour, int width, int style )
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
} }
wxPen::wxPen( const wxPen& pen )
{
Ref( pen );
}
wxPen::~wxPen() wxPen::~wxPen()
{ {
// m_refData unrefed in ~wxObject
} }
wxPen& wxPen::operator = ( const wxPen& pen ) wxObjectRefData *wxPen::CreateRefData() const
{ {
if ( m_refData != pen.m_refData ) return new wxPenRefData;
Ref( pen ); }
return *this; wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
{
return new wxPenRefData(*(wxPenRefData *)data);
} }
bool wxPen::operator == ( const wxPen& pen ) const bool wxPen::operator == ( const wxPen& pen ) const
{ {
return m_refData == pen.m_refData; if (m_refData == pen.m_refData) return TRUE;
}
if (!m_refData || !pen.m_refData) return FALSE;
bool wxPen::operator != ( const wxPen& pen ) const
{ return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
return m_refData != pen.m_refData;
} }
void wxPen::SetColour( const wxColour &colour ) void wxPen::SetColour( const wxColour &colour )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_colour = colour; M_PENDATA->m_colour = colour;
} }
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash ) void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_countDashes = number_of_dashes; M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */ M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
} }
void wxPen::SetColour( int red, int green, int blue ) void wxPen::SetColour( int red, int green, int blue )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_colour.Set( red, green, blue ); M_PENDATA->m_colour.Set( red, green, blue );
} }
void wxPen::SetCap( int capStyle ) void wxPen::SetCap( int capStyle )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_capStyle = capStyle; M_PENDATA->m_capStyle = capStyle;
} }
void wxPen::SetJoin( int joinStyle ) void wxPen::SetJoin( int joinStyle )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_joinStyle = joinStyle; M_PENDATA->m_joinStyle = joinStyle;
} }
void wxPen::SetStyle( int style ) void wxPen::SetStyle( int style )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_style = style; M_PENDATA->m_style = style;
} }
void wxPen::SetWidth( int width ) void wxPen::SetWidth( int width )
{ {
Unshare(); AllocExclusive();
M_PENDATA->m_width = width; M_PENDATA->m_width = width;
} }
@@ -200,22 +205,3 @@ wxColour &wxPen::GetColour() const
return M_PENDATA->m_colour; return M_PENDATA->m_colour;
} }
bool wxPen::Ok() const
{
return (m_refData != NULL);
}
void wxPen::Unshare()
{
if (!m_refData)
{
m_refData = new wxPenRefData();
}
else
{
wxPenRefData* ref = new wxPenRefData( *(wxPenRefData*)m_refData );
UnRef();
m_refData = ref;
}
}

View File

@@ -133,22 +133,22 @@ wxObjectRefData *wxRegion::CloneRefData(const wxObjectRefData *data) const
{ {
return new wxRegionRefData(*(wxRegionRefData *)data); return new wxRegionRefData(*(wxRegionRefData *)data);
} }
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion comparison // wxRegion comparison
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
bool wxRegion::operator==( const wxRegion& region ) bool wxRegion::operator==( const wxRegion& region )
{ {
if (m_refData == region.m_refData) return TRUE;
if (!m_refData || !region.m_refData) return FALSE;
// compare the regions themselves, not the pointers to ref data! // compare the regions themselves, not the pointers to ref data!
return gdk_region_equal(M_REGIONDATA->m_region, return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region); M_REGIONDATA_OF(region)->m_region);
} }
bool wxRegion::operator != ( const wxRegion& region )
{
return !(*this == region);
}
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------
// wxRegion operations // wxRegion operations
// ---------------------------------------------------------------------------- // ----------------------------------------------------------------------------

View File

@@ -805,30 +805,6 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (gdk_event->count == 0) if (gdk_event->count == 0)
win->GtkSendPaintEvents(); win->GtkSendPaintEvents();
// The following code will result in all window-less widgets
// being redrawn if the wxWindows class is given a chance to
// paint *anything* because it will then be allowed to paint
// over the window-less widgets.
GList *children = pizza->children;
while (children)
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
GdkEventExpose child_event = *gdk_event;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget) /* &&
gtk_widget_intersect (child->widget, &gdk_event->area, &child_event.area)*/ )
{
child_event.area.x = child->widget->allocation.x;
child_event.area.y = child->widget->allocation.y;
child_event.area.width = child->widget->allocation.width;
child_event.area.height = child->widget->allocation.height;
gtk_widget_event (child->widget, (GdkEvent*) &child_event);
}
}
return TRUE; return TRUE;
} }
@@ -3439,9 +3415,38 @@ void wxWindowGTK::GtkSendPaintEvents()
paint_event.SetEventObject( this ); paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( paint_event ); GetEventHandler()->ProcessEvent( paint_event );
m_updateRegion.Clear();
m_clipPaintRegion = FALSE; m_clipPaintRegion = FALSE;
GtkPizza *pizza = GTK_PIZZA(m_wxwindow);
if (g_list_length(pizza->children) > 0)
{
// The following code will result in all window-less widgets
// being redrawn because the wxWindows class is allowed to
// paint over the window-less widgets.
GList *children = pizza->children;
while (children)
{
GtkPizzaChild *child = (GtkPizzaChild*) children->data;
children = children->next;
if (GTK_WIDGET_NO_WINDOW (child->widget) &&
GTK_WIDGET_DRAWABLE (child->widget))
{
// Get intersection of widget area and update region
wxRegion region( m_updateRegion );
region.Intersect( child->widget->allocation.x,
child->widget->allocation.y,
child->widget->allocation.width,
child->widget->allocation.height );
// Redraw the whole widget anyway
if (!region.IsEmpty())
gtk_widget_draw( child->widget, NULL );
}
}
}
m_updateRegion.Clear();
} }
void wxWindowGTK::Clear() void wxWindowGTK::Clear()