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 ***
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
delayed refresh. Call the new wxWindow::Update() to force
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.
@@ -14,16 +32,14 @@ tasks (unlike thread work).
Various updates to wxHTML.
Some wxFont changes for better mixing of native fonts
and wxFont's accessors.
Corrections to wxImage code for special SGI visuals.
Some wxFont changes for better mixing of native fonts and
wxFont's accessors.
Added IFF image handler.
Added ICO, CUR and ANI image handler.
wxFrame::SetMenuBar() works again.
wxFrame::SetMenuBar() corrected.
wxButton honours wxBU_EXACTFIT.

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,33 +39,30 @@ class wxColour;
class wxColour: public wxGDIObject
{
public:
// ctors
// default
wxColour();
// from RGB
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
// 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();
// 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
// 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),
@@ -75,15 +72,19 @@ public:
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
// implementation
// Implementation part
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
protected:
// helper functions
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// Helper functions
void InitFromName(const wxString& colourName);
private:

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 );
@@ -65,11 +70,11 @@ public:
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();

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,33 +39,30 @@ class wxColour;
class wxColour: public wxGDIObject
{
public:
// ctors
// default
wxColour();
// from RGB
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
// 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();
// 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
// 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),
@@ -75,15 +72,19 @@ public:
unsigned char Red() const;
unsigned char Green() const;
unsigned char Blue() const;
bool Ok() const;
// implementation
// Implementation part
void CalcPixel( GdkColormap *cmap );
int GetPixel() const;
GdkColor *GetColor() const;
protected:
// helper functions
// ref counting code
virtual wxObjectRefData *CreateRefData() const;
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
// Helper functions
void InitFromName(const wxString& colourName);
private:

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 );
@@ -65,11 +70,11 @@ public:
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();

View File

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

View File

@@ -22,36 +22,36 @@
class wxBrushRefData: public wxObjectRefData
{
public:
wxBrushRefData();
wxBrushRefData( const wxBrushRefData& data );
int m_style;
wxBitmap m_stipple;
wxColour m_colour;
};
wxBrushRefData::wxBrushRefData()
wxBrushRefData()
{
m_style = 0;
}
wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
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;
};
//-----------------------------------------------------------------------------
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
wxBrush::wxBrush()
{
}
wxBrush::wxBrush( const wxColour &colour, int style )
{
m_refData = new wxBrushRefData();
@@ -72,36 +72,28 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap )
M_BRUSHDATA->m_style = wxSTIPPLE;
}
wxBrush::wxBrush( const wxBrush &brush )
{
Ref( brush );
}
wxBrush::~wxBrush()
{
// m_refData unrefed in ~wxObject
}
wxBrush& wxBrush::operator = ( const wxBrush& brush )
wxObjectRefData *wxBrush::CreateRefData() const
{
if ( m_refData != brush.m_refData )
Ref( brush );
return new wxBrushRefData;
}
return *this;
wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
{
return new wxBrushRefData(*(wxBrushRefData *)data);
}
bool wxBrush::operator == ( const wxBrush& brush ) const
{
return m_refData == brush.m_refData;
}
if (m_refData == brush.m_refData) return TRUE;
bool wxBrush::operator != ( const wxBrush& brush ) const
{
return m_refData != brush.m_refData;
}
if (!m_refData || !brush.m_refData) return FALSE;
bool wxBrush::Ok() const
{
return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
}
int wxBrush::GetStyle() const
@@ -139,25 +131,29 @@ wxBitmap *wxBrush::GetStipple() const
void wxBrush::SetColour( const wxColour& col )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_colour = col;
}
void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_colour.Set( r, g, b );
}
void wxBrush::SetStyle( int style )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_style = style;
}
void wxBrush::SetStipple( const wxBitmap& stipple )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_stipple = stipple;
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
{
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 AllocColour( GdkColormap* cmap );
public:
GdkColor m_color;
GdkColormap *m_colormap;
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
};
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()
{
if (m_colormap)
@@ -131,10 +137,6 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject)
wxColour::wxColour()
{
}
wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
{
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::operator = ( const wxColour& col )
{
if (*this == col) return (*this);
Ref( col );
return *this;
}
bool wxColour::operator == ( const wxColour& col ) const
{
if (m_refData == col.m_refData) return TRUE;
if (!m_refData) return FALSE;
if (!col.m_refData) return FALSE;
if (!m_refData || !col.m_refData) return FALSE;
GdkColor *own = &(((wxColourRefData*)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;
}
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 )
{
UnRef();
AllocExclusive();
m_refData = new wxColourRefData();
M_COLDATA->m_color.red = ((unsigned short)red) << 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);
}
bool wxColour::Ok() const
{
return (m_refData != NULL);
}
void wxColour::CalcPixel( GdkColormap *cmap )
{
if (!Ok()) return;

View File

@@ -23,20 +23,7 @@
class wxPenRefData: public wxObjectRefData
{
public:
wxPenRefData();
wxPenRefData( const wxPenRefData& data );
int m_width;
int m_style;
int m_joinStyle;
int m_capStyle;
wxColour m_colour;
int m_countDashes;
wxGTKDash *m_dash;
};
wxPenRefData::wxPenRefData()
wxPenRefData()
{
m_width = 1;
m_style = wxSOLID;
@@ -46,7 +33,7 @@ wxPenRefData::wxPenRefData()
m_countDashes = 0;
}
wxPenRefData::wxPenRefData( const wxPenRefData& data )
wxPenRefData( const wxPenRefData& data )
{
m_style = data.m_style;
m_width = data.m_width;
@@ -61,16 +48,30 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data )
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;
};
//-----------------------------------------------------------------------------
#define M_PENDATA ((wxPenRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
wxPen::wxPen()
{
}
wxPen::wxPen( const wxColour &colour, int width, int style )
{
m_refData = new wxPenRefData();
@@ -79,73 +80,77 @@ wxPen::wxPen( const wxColour &colour, int width, int style )
M_PENDATA->m_colour = colour;
}
wxPen::wxPen( const wxPen& pen )
{
Ref( pen );
}
wxPen::~wxPen()
{
// m_refData unrefed in ~wxObject
}
wxPen& wxPen::operator = ( const wxPen& pen )
wxObjectRefData *wxPen::CreateRefData() const
{
if ( m_refData != pen.m_refData )
Ref( pen );
return new wxPenRefData;
}
return *this;
wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
{
return new wxPenRefData(*(wxPenRefData *)data);
}
bool wxPen::operator == ( const wxPen& pen ) const
{
return m_refData == pen.m_refData;
}
if (m_refData == pen.m_refData) return TRUE;
bool wxPen::operator != ( const wxPen& pen ) const
{
return m_refData != pen.m_refData;
if (!m_refData || !pen.m_refData) return FALSE;
return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
}
void wxPen::SetColour( const wxColour &colour )
{
Unshare();
AllocExclusive();
M_PENDATA->m_colour = colour;
}
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
{
Unshare();
AllocExclusive();
M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
}
void wxPen::SetColour( int red, int green, int blue )
{
Unshare();
AllocExclusive();
M_PENDATA->m_colour.Set( red, green, blue );
}
void wxPen::SetCap( int capStyle )
{
Unshare();
AllocExclusive();
M_PENDATA->m_capStyle = capStyle;
}
void wxPen::SetJoin( int joinStyle )
{
Unshare();
AllocExclusive();
M_PENDATA->m_joinStyle = joinStyle;
}
void wxPen::SetStyle( int style )
{
Unshare();
AllocExclusive();
M_PENDATA->m_style = style;
}
void wxPen::SetWidth( int width )
{
Unshare();
AllocExclusive();
M_PENDATA->m_width = width;
}
@@ -200,22 +205,3 @@ wxColour &wxPen::GetColour() const
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);
}
// ----------------------------------------------------------------------------
// wxRegion comparison
// ----------------------------------------------------------------------------
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!
return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region);
}
bool wxRegion::operator != ( const wxRegion& region )
{
return !(*this == region);
}
// ----------------------------------------------------------------------------
// wxRegion operations
// ----------------------------------------------------------------------------

View File

@@ -805,30 +805,6 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (gdk_event->count == 0)
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;
}
@@ -3439,9 +3415,38 @@ void wxWindowGTK::GtkSendPaintEvents()
paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( paint_event );
m_updateRegion.Clear();
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()

View File

@@ -22,36 +22,36 @@
class wxBrushRefData: public wxObjectRefData
{
public:
wxBrushRefData();
wxBrushRefData( const wxBrushRefData& data );
int m_style;
wxBitmap m_stipple;
wxColour m_colour;
};
wxBrushRefData::wxBrushRefData()
wxBrushRefData()
{
m_style = 0;
}
wxBrushRefData::wxBrushRefData( const wxBrushRefData& data )
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;
};
//-----------------------------------------------------------------------------
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxBrush,wxGDIObject)
wxBrush::wxBrush()
{
}
wxBrush::wxBrush( const wxColour &colour, int style )
{
m_refData = new wxBrushRefData();
@@ -72,36 +72,28 @@ wxBrush::wxBrush( const wxBitmap &stippleBitmap )
M_BRUSHDATA->m_style = wxSTIPPLE;
}
wxBrush::wxBrush( const wxBrush &brush )
{
Ref( brush );
}
wxBrush::~wxBrush()
{
// m_refData unrefed in ~wxObject
}
wxBrush& wxBrush::operator = ( const wxBrush& brush )
wxObjectRefData *wxBrush::CreateRefData() const
{
if ( m_refData != brush.m_refData )
Ref( brush );
return new wxBrushRefData;
}
return *this;
wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
{
return new wxBrushRefData(*(wxBrushRefData *)data);
}
bool wxBrush::operator == ( const wxBrush& brush ) const
{
return m_refData == brush.m_refData;
}
if (m_refData == brush.m_refData) return TRUE;
bool wxBrush::operator != ( const wxBrush& brush ) const
{
return m_refData != brush.m_refData;
}
if (!m_refData || !brush.m_refData) return FALSE;
bool wxBrush::Ok() const
{
return ((m_refData) && M_BRUSHDATA->m_colour.Ok());
return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
}
int wxBrush::GetStyle() const
@@ -139,25 +131,29 @@ wxBitmap *wxBrush::GetStipple() const
void wxBrush::SetColour( const wxColour& col )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_colour = col;
}
void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_colour.Set( r, g, b );
}
void wxBrush::SetStyle( int style )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_style = style;
}
void wxBrush::SetStipple( const wxBitmap& stipple )
{
Unshare();
AllocExclusive();
M_BRUSHDATA->m_stipple = stipple;
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
{
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 AllocColour( GdkColormap* cmap );
public:
GdkColor m_color;
GdkColormap *m_colormap;
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
};
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()
{
if (m_colormap)
@@ -131,10 +137,6 @@ void wxColourRefData::AllocColour( GdkColormap *cmap )
IMPLEMENT_DYNAMIC_CLASS(wxColour,wxGDIObject)
wxColour::wxColour()
{
}
wxColour::wxColour( unsigned char red, unsigned char green, unsigned char blue )
{
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::operator = ( const wxColour& col )
{
if (*this == col) return (*this);
Ref( col );
return *this;
}
bool wxColour::operator == ( const wxColour& col ) const
{
if (m_refData == col.m_refData) return TRUE;
if (!m_refData) return FALSE;
if (!col.m_refData) return FALSE;
if (!m_refData || !col.m_refData) return FALSE;
GdkColor *own = &(((wxColourRefData*)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;
}
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 )
{
UnRef();
AllocExclusive();
m_refData = new wxColourRefData();
M_COLDATA->m_color.red = ((unsigned short)red) << 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);
}
bool wxColour::Ok() const
{
return (m_refData != NULL);
}
void wxColour::CalcPixel( GdkColormap *cmap )
{
if (!Ok()) return;

View File

@@ -23,20 +23,7 @@
class wxPenRefData: public wxObjectRefData
{
public:
wxPenRefData();
wxPenRefData( const wxPenRefData& data );
int m_width;
int m_style;
int m_joinStyle;
int m_capStyle;
wxColour m_colour;
int m_countDashes;
wxGTKDash *m_dash;
};
wxPenRefData::wxPenRefData()
wxPenRefData()
{
m_width = 1;
m_style = wxSOLID;
@@ -46,7 +33,7 @@ wxPenRefData::wxPenRefData()
m_countDashes = 0;
}
wxPenRefData::wxPenRefData( const wxPenRefData& data )
wxPenRefData( const wxPenRefData& data )
{
m_style = data.m_style;
m_width = data.m_width;
@@ -61,16 +48,30 @@ wxPenRefData::wxPenRefData( const wxPenRefData& data )
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;
};
//-----------------------------------------------------------------------------
#define M_PENDATA ((wxPenRefData *)m_refData)
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
wxPen::wxPen()
{
}
wxPen::wxPen( const wxColour &colour, int width, int style )
{
m_refData = new wxPenRefData();
@@ -79,73 +80,77 @@ wxPen::wxPen( const wxColour &colour, int width, int style )
M_PENDATA->m_colour = colour;
}
wxPen::wxPen( const wxPen& pen )
{
Ref( pen );
}
wxPen::~wxPen()
{
// m_refData unrefed in ~wxObject
}
wxPen& wxPen::operator = ( const wxPen& pen )
wxObjectRefData *wxPen::CreateRefData() const
{
if ( m_refData != pen.m_refData )
Ref( pen );
return new wxPenRefData;
}
return *this;
wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
{
return new wxPenRefData(*(wxPenRefData *)data);
}
bool wxPen::operator == ( const wxPen& pen ) const
{
return m_refData == pen.m_refData;
}
if (m_refData == pen.m_refData) return TRUE;
bool wxPen::operator != ( const wxPen& pen ) const
{
return m_refData != pen.m_refData;
if (!m_refData || !pen.m_refData) return FALSE;
return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
}
void wxPen::SetColour( const wxColour &colour )
{
Unshare();
AllocExclusive();
M_PENDATA->m_colour = colour;
}
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
{
Unshare();
AllocExclusive();
M_PENDATA->m_countDashes = number_of_dashes;
M_PENDATA->m_dash = (wxGTKDash *)dash; /* TODO */
}
void wxPen::SetColour( int red, int green, int blue )
{
Unshare();
AllocExclusive();
M_PENDATA->m_colour.Set( red, green, blue );
}
void wxPen::SetCap( int capStyle )
{
Unshare();
AllocExclusive();
M_PENDATA->m_capStyle = capStyle;
}
void wxPen::SetJoin( int joinStyle )
{
Unshare();
AllocExclusive();
M_PENDATA->m_joinStyle = joinStyle;
}
void wxPen::SetStyle( int style )
{
Unshare();
AllocExclusive();
M_PENDATA->m_style = style;
}
void wxPen::SetWidth( int width )
{
Unshare();
AllocExclusive();
M_PENDATA->m_width = width;
}
@@ -200,22 +205,3 @@ wxColour &wxPen::GetColour() const
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);
}
// ----------------------------------------------------------------------------
// wxRegion comparison
// ----------------------------------------------------------------------------
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!
return gdk_region_equal(M_REGIONDATA->m_region,
M_REGIONDATA_OF(region)->m_region);
}
bool wxRegion::operator != ( const wxRegion& region )
{
return !(*this == region);
}
// ----------------------------------------------------------------------------
// wxRegion operations
// ----------------------------------------------------------------------------

View File

@@ -805,30 +805,6 @@ static int gtk_window_expose_callback( GtkWidget *widget,
if (gdk_event->count == 0)
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;
}
@@ -3439,9 +3415,38 @@ void wxWindowGTK::GtkSendPaintEvents()
paint_event.SetEventObject( this );
GetEventHandler()->ProcessEvent( paint_event );
m_updateRegion.Clear();
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()