wxX11:
Updated wxPen and wxBrush. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@14106 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
parent
1934d291cd
commit
74dc5eb60e
@ -1,11 +1,11 @@
|
|||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
// Name: brush.h
|
// Name: brush.h
|
||||||
// Purpose: wxBrush class
|
// Purpose: wxBrush class
|
||||||
// Author: Julian Smart
|
// Author: Julian Smart, Robert Roebling
|
||||||
// Modified by:
|
// Modified by:
|
||||||
// Created: 17/09/98
|
// Created: 17/09/98
|
||||||
// RCS-ID: $Id$
|
// RCS-ID: $Id$
|
||||||
// Copyright: (c) Julian Smart
|
// Copyright: (c) Julian Smart, Robert Roebling
|
||||||
// Licence: wxWindows licence
|
// Licence: wxWindows licence
|
||||||
/////////////////////////////////////////////////////////////////////////////
|
/////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
@ -20,59 +20,48 @@
|
|||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
class WXDLLEXPORT wxBrush;
|
//-----------------------------------------------------------------------------
|
||||||
|
// classes
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
|
class wxBrush;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxBrush
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxBrush: public wxGDIObject
|
||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxBrush;
|
|
||||||
public:
|
public:
|
||||||
wxBrushRefData();
|
wxBrush() { }
|
||||||
wxBrushRefData(const wxBrushRefData& data);
|
|
||||||
~wxBrushRefData();
|
|
||||||
|
|
||||||
protected:
|
wxBrush( const wxColour &colour, int style );
|
||||||
int m_style;
|
wxBrush( const wxBitmap &stippleBitmap );
|
||||||
wxBitmap m_stipple ;
|
|
||||||
wxColour m_colour;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
|
||||||
|
|
||||||
// Brush
|
|
||||||
class WXDLLEXPORT wxBrush: public wxGDIObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxBrush)
|
|
||||||
|
|
||||||
public:
|
|
||||||
wxBrush();
|
|
||||||
wxBrush(const wxColour& col, int style);
|
|
||||||
wxBrush(const wxBitmap& stipple);
|
|
||||||
inline wxBrush(const wxBrush& brush) { Ref(brush); }
|
|
||||||
~wxBrush();
|
~wxBrush();
|
||||||
|
|
||||||
virtual void SetColour(const wxColour& col) ;
|
wxBrush( const wxBrush &brush ) { Ref(brush); }
|
||||||
virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
|
wxBrush& operator = ( const wxBrush& brush ) { Ref(brush); return *this; }
|
||||||
virtual void SetStyle(int style) ;
|
|
||||||
virtual void SetStipple(const wxBitmap& stipple) ;
|
|
||||||
|
|
||||||
inline wxBrush& operator = (const wxBrush& brush) { if (*this == brush) return (*this); Ref(brush); return *this; }
|
bool Ok() const { return m_refData != NULL; }
|
||||||
inline bool operator == (const wxBrush& brush) const { return m_refData == brush.m_refData; }
|
|
||||||
inline bool operator != (const wxBrush& brush) const { return m_refData != brush.m_refData; }
|
|
||||||
|
|
||||||
inline wxColour& GetColour() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_colour : wxNullColour); };
|
bool operator == ( const wxBrush& brush ) const;
|
||||||
inline int GetStyle() const { return (M_BRUSHDATA ? M_BRUSHDATA->m_style : 0); };
|
bool operator != (const wxBrush& brush) const { return !(*this == brush); }
|
||||||
inline wxBitmap *GetStipple() const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_stipple : 0); };
|
|
||||||
|
|
||||||
virtual bool Ok() const { return (m_refData != NULL) ; }
|
int GetStyle() const;
|
||||||
|
wxColour &GetColour() const;
|
||||||
|
wxBitmap *GetStipple() const;
|
||||||
|
|
||||||
// Implementation
|
void SetColour( const wxColour& col );
|
||||||
|
void SetColour( unsigned char r, unsigned char g, unsigned char b );
|
||||||
|
void SetStyle( int style );
|
||||||
|
void SetStipple( const wxBitmap& stipple );
|
||||||
|
|
||||||
// Useful helper: create the brush resource
|
private:
|
||||||
bool RealizeResource();
|
// ref counting code
|
||||||
|
virtual wxObjectRefData *CreateRefData() const;
|
||||||
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||||
|
|
||||||
// When setting properties, we must make sure we're not changing
|
DECLARE_DYNAMIC_CLASS(wxBrush)
|
||||||
// another object
|
|
||||||
void Unshare();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -145,7 +145,7 @@ protected:
|
|||||||
int m_currentPenJoin ;
|
int m_currentPenJoin ;
|
||||||
int m_currentPenCap ;
|
int m_currentPenCap ;
|
||||||
int m_currentPenDashCount ;
|
int m_currentPenDashCount ;
|
||||||
wxMOTIFDash* m_currentPenDash ;
|
wxX11Dash* m_currentPenDash ;
|
||||||
wxBitmap m_currentStipple ;
|
wxBitmap m_currentStipple ;
|
||||||
int m_currentStyle ;
|
int m_currentStyle ;
|
||||||
int m_currentFill ;
|
int m_currentFill ;
|
||||||
|
@ -20,82 +20,57 @@
|
|||||||
#include "wx/colour.h"
|
#include "wx/colour.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/bitmap.h"
|
||||||
|
|
||||||
typedef char wxMOTIFDash;
|
//-----------------------------------------------------------------------------
|
||||||
|
// classes
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxPen;
|
class wxPen;
|
||||||
|
|
||||||
class WXDLLEXPORT wxPenRefData: public wxGDIRefData
|
typedef char wxX11Dash;
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxPen
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class wxPen: public wxGDIObject
|
||||||
{
|
{
|
||||||
friend class WXDLLEXPORT wxPen;
|
|
||||||
public:
|
public:
|
||||||
wxPenRefData();
|
wxPen() { }
|
||||||
wxPenRefData(const wxPenRefData& data);
|
|
||||||
~wxPenRefData();
|
|
||||||
|
|
||||||
protected:
|
wxPen( const wxColour &colour, int width, int style );
|
||||||
int m_width;
|
|
||||||
int m_style;
|
|
||||||
int m_join ;
|
|
||||||
int m_cap ;
|
|
||||||
wxBitmap m_stipple ;
|
|
||||||
int m_nbDash ;
|
|
||||||
wxMOTIFDash *m_dash ;
|
|
||||||
wxColour m_colour;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_PENDATA ((wxPenRefData *)m_refData)
|
|
||||||
|
|
||||||
// Pen
|
|
||||||
class WXDLLEXPORT wxPen: public wxGDIObject
|
|
||||||
{
|
|
||||||
DECLARE_DYNAMIC_CLASS(wxPen)
|
|
||||||
public:
|
|
||||||
wxPen();
|
|
||||||
wxPen(const wxColour& col, int width, int style);
|
|
||||||
wxPen(const wxBitmap& stipple, int width);
|
|
||||||
inline wxPen(const wxPen& pen) { Ref(pen); }
|
|
||||||
~wxPen();
|
~wxPen();
|
||||||
|
|
||||||
inline wxPen& operator = (const wxPen& pen) { if (*this == pen) return (*this); Ref(pen); return *this; }
|
wxPen( const wxPen& pen ) { Ref(pen); }
|
||||||
inline bool operator == (const wxPen& pen) const { return m_refData == pen.m_refData; }
|
wxPen& operator = ( const wxPen& pen ) { Ref(pen); return *this; }
|
||||||
inline bool operator != (const wxPen& pen) const { return m_refData != pen.m_refData; }
|
|
||||||
|
|
||||||
virtual bool Ok() const { return (m_refData != NULL) ; }
|
bool Ok() const { return m_refData != NULL; }
|
||||||
|
|
||||||
// Override in order to recreate the pen
|
bool operator == ( const wxPen& pen ) const;
|
||||||
void SetColour(const wxColour& col) ;
|
bool operator != (const wxPen& pen) const { return !(*this == pen); }
|
||||||
void SetColour(unsigned char r, unsigned char g, unsigned char b) ;
|
|
||||||
|
|
||||||
void SetWidth(int width) ;
|
void SetColour( const wxColour &colour );
|
||||||
void SetStyle(int style) ;
|
void SetColour( int red, int green, int blue );
|
||||||
void SetStipple(const wxBitmap& stipple) ;
|
void SetCap( int capStyle );
|
||||||
void SetDashes(int nb_dashes, const wxDash *dash) ;
|
void SetJoin( int joinStyle );
|
||||||
void SetJoin(int join) ;
|
void SetStyle( int style );
|
||||||
void SetCap(int cap) ;
|
void SetWidth( int width );
|
||||||
|
void SetDashes( int number_of_dashes, const wxDash *dash );
|
||||||
|
|
||||||
inline wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
|
wxColour &GetColour() const;
|
||||||
inline int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
|
int GetCap() const;
|
||||||
inline int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
|
int GetJoin() const;
|
||||||
inline int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
|
int GetStyle() const;
|
||||||
inline int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
|
int GetWidth() const;
|
||||||
inline int GetDashes(wxDash **ptr) const
|
int GetDashes(wxDash **ptr) const;
|
||||||
{
|
int GetDashCount() const;
|
||||||
*ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
|
wxDash* GetDash() const;
|
||||||
return (M_PENDATA ? M_PENDATA->m_nbDash : 0);
|
|
||||||
}
|
|
||||||
inline int GetDashCount() const { return (M_PENDATA->m_nbDash); }
|
|
||||||
inline wxDash* GetDash() const { return (wxDash*)M_PENDATA->m_dash; }
|
|
||||||
|
|
||||||
inline wxBitmap *GetStipple() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
|
private:
|
||||||
|
// ref counting code
|
||||||
|
virtual wxObjectRefData *CreateRefData() const;
|
||||||
|
virtual wxObjectRefData *CloneRefData(const wxObjectRefData *data) const;
|
||||||
|
|
||||||
// Implementation
|
DECLARE_DYNAMIC_CLASS(wxPen)
|
||||||
|
|
||||||
// Useful helper: create the brush resource
|
|
||||||
bool RealizeResource();
|
|
||||||
|
|
||||||
// When setting properties, we must make sure we're not changing
|
|
||||||
// another object
|
|
||||||
void Unshare();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -17,107 +17,152 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/brush.h"
|
#include "wx/brush.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxBrush
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxBrushRefData::wxBrushRefData()
|
class wxBrushRefData: public wxObjectRefData
|
||||||
{
|
{
|
||||||
m_style = wxSOLID;
|
public:
|
||||||
}
|
wxBrushRefData()
|
||||||
|
{
|
||||||
|
m_style = 0;
|
||||||
|
}
|
||||||
|
|
||||||
wxBrushRefData::wxBrushRefData(const wxBrushRefData& data)
|
wxBrushRefData( const wxBrushRefData& data )
|
||||||
{
|
{
|
||||||
m_style = data.m_style;
|
m_style = data.m_style;
|
||||||
m_stipple = data.m_stipple;
|
m_stipple = data.m_stipple;
|
||||||
m_colour = data.m_colour;
|
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( const wxColour &colour, int style )
|
||||||
|
{
|
||||||
|
m_refData = new wxBrushRefData();
|
||||||
|
M_BRUSHDATA->m_style = style;
|
||||||
|
M_BRUSHDATA->m_colour = colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrushRefData::~wxBrushRefData()
|
wxBrush::wxBrush( const wxBitmap &stippleBitmap )
|
||||||
{
|
{
|
||||||
}
|
m_refData = new wxBrushRefData();
|
||||||
|
M_BRUSHDATA->m_colour = *wxBLACK;
|
||||||
|
|
||||||
// Brushes
|
M_BRUSHDATA->m_stipple = stippleBitmap;
|
||||||
wxBrush::wxBrush()
|
|
||||||
{
|
if (M_BRUSHDATA->m_stipple.GetMask())
|
||||||
|
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
|
||||||
|
else
|
||||||
|
M_BRUSHDATA->m_style = wxSTIPPLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::~wxBrush()
|
wxBrush::~wxBrush()
|
||||||
{
|
{
|
||||||
|
// m_refData unrefed in ~wxObject
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxColour& col, int Style)
|
wxObjectRefData *wxBrush::CreateRefData() const
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
return new wxBrushRefData;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxObjectRefData *wxBrush::CloneRefData(const wxObjectRefData *data) const
|
||||||
|
{
|
||||||
|
return new wxBrushRefData(*(wxBrushRefData *)data);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool wxBrush::operator == ( const wxBrush& brush ) const
|
||||||
|
{
|
||||||
|
if (m_refData == brush.m_refData) return TRUE;
|
||||||
|
|
||||||
|
if (!m_refData || !brush.m_refData) return FALSE;
|
||||||
|
|
||||||
|
return ( *(wxBrushRefData*)m_refData == *(wxBrushRefData*)brush.m_refData );
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxBrush::GetStyle() const
|
||||||
|
{
|
||||||
|
if (m_refData == NULL)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("invalid brush") );
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return M_BRUSHDATA->m_style;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxColour &wxBrush::GetColour() const
|
||||||
|
{
|
||||||
|
if (m_refData == NULL)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("invalid brush") );
|
||||||
|
return wxNullColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
return M_BRUSHDATA->m_colour;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap *wxBrush::GetStipple() const
|
||||||
|
{
|
||||||
|
if (m_refData == NULL)
|
||||||
|
{
|
||||||
|
wxFAIL_MSG( wxT("invalid brush") );
|
||||||
|
return &wxNullBitmap;
|
||||||
|
}
|
||||||
|
|
||||||
|
return &M_BRUSHDATA->m_stipple;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBrush::SetColour( const wxColour& col )
|
||||||
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
M_BRUSHDATA->m_colour = col;
|
M_BRUSHDATA->m_colour = col;
|
||||||
M_BRUSHDATA->m_style = Style;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxBrush::wxBrush(const wxBitmap& stipple)
|
void wxBrush::SetColour( unsigned char r, unsigned char g, unsigned char b )
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
AllocExclusive();
|
||||||
|
|
||||||
|
M_BRUSHDATA->m_colour.Set( r, g, b );
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBrush::SetStyle( int style )
|
||||||
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
|
M_BRUSHDATA->m_style = style;
|
||||||
|
}
|
||||||
|
|
||||||
|
void wxBrush::SetStipple( const wxBitmap& stipple )
|
||||||
|
{
|
||||||
|
AllocExclusive();
|
||||||
|
|
||||||
M_BRUSHDATA->m_style = wxSTIPPLE;
|
|
||||||
M_BRUSHDATA->m_stipple = stipple;
|
M_BRUSHDATA->m_stipple = stipple;
|
||||||
|
if (M_BRUSHDATA->m_stipple.GetMask())
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::Unshare()
|
|
||||||
{
|
|
||||||
// Don't change shared data
|
|
||||||
if (!m_refData)
|
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData();
|
M_BRUSHDATA->m_style = wxSTIPPLE_MASK_OPAQUE;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
wxBrushRefData* ref = new wxBrushRefData(*(wxBrushRefData*)m_refData);
|
M_BRUSHDATA->m_style = wxSTIPPLE;
|
||||||
UnRef();
|
|
||||||
m_refData = ref;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxBrush::SetColour(const wxColour& col)
|
|
||||||
{
|
|
||||||
Unshare();
|
|
||||||
|
|
||||||
M_BRUSHDATA->m_colour = col;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
|
||||||
{
|
|
||||||
Unshare();
|
|
||||||
|
|
||||||
M_BRUSHDATA->m_colour.Set(r, g, b);
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::SetStyle(int Style)
|
|
||||||
{
|
|
||||||
Unshare();
|
|
||||||
|
|
||||||
M_BRUSHDATA->m_style = Style;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
void wxBrush::SetStipple(const wxBitmap& Stipple)
|
|
||||||
{
|
|
||||||
Unshare();
|
|
||||||
|
|
||||||
M_BRUSHDATA->m_stipple = Stipple;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
|
||||||
|
|
||||||
bool wxBrush::RealizeResource()
|
|
||||||
{
|
|
||||||
// Nothing more to do
|
|
||||||
return TRUE;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@ -135,7 +135,7 @@ wxWindowDC::wxWindowDC()
|
|||||||
m_currentPenWidth = 1;
|
m_currentPenWidth = 1;
|
||||||
m_currentPenJoin = -1;
|
m_currentPenJoin = -1;
|
||||||
m_currentPenDashCount = -1;
|
m_currentPenDashCount = -1;
|
||||||
m_currentPenDash = (wxMOTIFDash*) NULL;
|
m_currentPenDash = (wxX11Dash*) NULL;
|
||||||
m_currentStyle = -1;
|
m_currentStyle = -1;
|
||||||
m_currentFill = -1;
|
m_currentFill = -1;
|
||||||
// m_currentBkMode = wxTRANSPARENT;
|
// m_currentBkMode = wxTRANSPARENT;
|
||||||
@ -160,7 +160,7 @@ wxWindowDC::wxWindowDC( wxWindow *window )
|
|||||||
m_currentPenWidth = 1;
|
m_currentPenWidth = 1;
|
||||||
m_currentPenJoin = -1;
|
m_currentPenJoin = -1;
|
||||||
m_currentPenDashCount = -1;
|
m_currentPenDashCount = -1;
|
||||||
m_currentPenDash = (wxMOTIFDash*) NULL;
|
m_currentPenDash = (wxX11Dash*) NULL;
|
||||||
m_currentStyle = -1;
|
m_currentStyle = -1;
|
||||||
m_currentFill = -1;
|
m_currentFill = -1;
|
||||||
// m_currentBkMode = wxTRANSPARENT;
|
// m_currentBkMode = wxTRANSPARENT;
|
||||||
@ -1309,7 +1309,7 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
|||||||
int old_pen_join = m_currentPenJoin;
|
int old_pen_join = m_currentPenJoin;
|
||||||
int old_pen_cap = m_currentPenCap;
|
int old_pen_cap = m_currentPenCap;
|
||||||
int old_pen_nb_dash = m_currentPenDashCount;
|
int old_pen_nb_dash = m_currentPenDashCount;
|
||||||
wxMOTIFDash *old_pen_dash = m_currentPenDash;
|
wxX11Dash *old_pen_dash = m_currentPenDash;
|
||||||
|
|
||||||
wxColour oldPenColour = m_currentColour;
|
wxColour oldPenColour = m_currentColour;
|
||||||
m_currentColour = m_pen.GetColour ();
|
m_currentColour = m_pen.GetColour ();
|
||||||
@ -1319,10 +1319,13 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
|||||||
m_currentPenJoin = m_pen.GetJoin ();
|
m_currentPenJoin = m_pen.GetJoin ();
|
||||||
m_currentPenCap = m_pen.GetCap ();
|
m_currentPenCap = m_pen.GetCap ();
|
||||||
m_currentPenDashCount = m_pen.GetDashCount();
|
m_currentPenDashCount = m_pen.GetDashCount();
|
||||||
m_currentPenDash = (wxMOTIFDash*)m_pen.GetDash();
|
m_currentPenDash = (wxX11Dash*)m_pen.GetDash();
|
||||||
|
|
||||||
|
#if 0
|
||||||
|
// TODO
|
||||||
if (m_currentStyle == wxSTIPPLE)
|
if (m_currentStyle == wxSTIPPLE)
|
||||||
m_currentStipple = * m_pen.GetStipple ();
|
m_currentStipple = * m_pen.GetStipple ();
|
||||||
|
#endif
|
||||||
|
|
||||||
bool sameStyle = (oldStyle == m_currentStyle &&
|
bool sameStyle = (oldStyle == m_currentStyle &&
|
||||||
oldFill == m_currentFill &&
|
oldFill == m_currentFill &&
|
||||||
@ -1347,15 +1350,15 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
|||||||
int style;
|
int style;
|
||||||
int join;
|
int join;
|
||||||
int cap;
|
int cap;
|
||||||
static const wxMOTIFDash dotted[] = {2, 5};
|
static const wxX11Dash dotted[] = {2, 5};
|
||||||
static const wxMOTIFDash short_dashed[] = {4, 4};
|
static const wxX11Dash short_dashed[] = {4, 4};
|
||||||
static const wxMOTIFDash long_dashed[] = {4, 8};
|
static const wxX11Dash long_dashed[] = {4, 8};
|
||||||
static const wxMOTIFDash dotted_dashed[] = {6, 6, 2, 6};
|
static const wxX11Dash dotted_dashed[] = {6, 6, 2, 6};
|
||||||
|
|
||||||
// We express dash pattern in pen width unit, so we are
|
// We express dash pattern in pen width unit, so we are
|
||||||
// independent of zoom factor and so on...
|
// independent of zoom factor and so on...
|
||||||
int req_nb_dash;
|
int req_nb_dash;
|
||||||
const wxMOTIFDash *req_dash;
|
const wxX11Dash *req_dash;
|
||||||
|
|
||||||
switch (m_pen.GetStyle ())
|
switch (m_pen.GetStyle ())
|
||||||
{
|
{
|
||||||
@ -1389,13 +1392,13 @@ void wxWindowDC::SetPen( const wxPen &pen )
|
|||||||
case wxTRANSPARENT:
|
case wxTRANSPARENT:
|
||||||
default:
|
default:
|
||||||
style = LineSolid;
|
style = LineSolid;
|
||||||
req_dash = (wxMOTIFDash*)NULL;
|
req_dash = (wxX11Dash*)NULL;
|
||||||
req_nb_dash = 0;
|
req_nb_dash = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (req_dash && req_nb_dash)
|
if (req_dash && req_nb_dash)
|
||||||
{
|
{
|
||||||
wxMOTIFDash *real_req_dash = new wxMOTIFDash[req_nb_dash];
|
wxX11Dash *real_req_dash = new wxX11Dash[req_nb_dash];
|
||||||
if (real_req_dash)
|
if (real_req_dash)
|
||||||
{
|
{
|
||||||
int factor = scaled_width == 0 ? 1 : scaled_width;
|
int factor = scaled_width == 0 ? 1 : scaled_width;
|
||||||
|
235
src/x11/pen.cpp
235
src/x11/pen.cpp
@ -17,166 +17,191 @@
|
|||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/pen.h"
|
#include "wx/pen.h"
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
//-----------------------------------------------------------------------------
|
||||||
|
// wxPen
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxPenRefData::wxPenRefData()
|
class wxPenRefData: public wxObjectRefData
|
||||||
{
|
{
|
||||||
m_style = wxSOLID;
|
public:
|
||||||
|
wxPenRefData()
|
||||||
|
{
|
||||||
m_width = 1;
|
m_width = 1;
|
||||||
m_join = wxJOIN_ROUND ;
|
m_style = wxSOLID;
|
||||||
m_cap = wxCAP_ROUND ;
|
m_joinStyle = wxJOIN_ROUND;
|
||||||
m_nbDash = 0 ;
|
m_capStyle = wxCAP_ROUND;
|
||||||
m_dash = (wxMOTIFDash*)NULL;
|
m_dash = (wxX11Dash*) NULL;
|
||||||
}
|
m_countDashes = 0;
|
||||||
|
}
|
||||||
|
|
||||||
wxPenRefData::wxPenRefData(const wxPenRefData& data)
|
wxPenRefData( const wxPenRefData& data )
|
||||||
{
|
{
|
||||||
m_style = data.m_style;
|
m_style = data.m_style;
|
||||||
m_width = data.m_width;
|
m_width = data.m_width;
|
||||||
m_join = data.m_join;
|
m_joinStyle = data.m_joinStyle;
|
||||||
m_cap = data.m_cap;
|
m_capStyle = data.m_capStyle;
|
||||||
m_nbDash = data.m_nbDash;
|
|
||||||
m_dash = data.m_dash;
|
|
||||||
m_colour = data.m_colour;
|
m_colour = data.m_colour;
|
||||||
}
|
m_countDashes = data.m_countDashes;
|
||||||
|
/*
|
||||||
|
if (data.m_dash) TODO
|
||||||
|
m_dash = new
|
||||||
|
*/
|
||||||
|
m_dash = data.m_dash;
|
||||||
|
}
|
||||||
|
|
||||||
wxPenRefData::~wxPenRefData()
|
bool operator == (const wxPenRefData& data) const
|
||||||
{
|
{
|
||||||
}
|
return (m_style == data.m_style &&
|
||||||
|
m_width == data.m_width &&
|
||||||
// Pens
|
m_joinStyle == data.m_joinStyle &&
|
||||||
|
m_capStyle == data.m_capStyle &&
|
||||||
wxPen::wxPen()
|
m_colour == data.m_colour);
|
||||||
|
}
|
||||||
|
|
||||||
|
int m_width;
|
||||||
|
int m_style;
|
||||||
|
int m_joinStyle;
|
||||||
|
int m_capStyle;
|
||||||
|
wxColour m_colour;
|
||||||
|
int m_countDashes;
|
||||||
|
wxX11Dash *m_dash;
|
||||||
|
};
|
||||||
|
|
||||||
|
//-----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
#define M_PENDATA ((wxPenRefData *)m_refData)
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxPen,wxGDIObject)
|
||||||
|
|
||||||
|
wxPen::wxPen( const wxColour &colour, int width, int style )
|
||||||
{
|
{
|
||||||
|
m_refData = new wxPenRefData();
|
||||||
|
M_PENDATA->m_width = width;
|
||||||
|
M_PENDATA->m_style = style;
|
||||||
|
M_PENDATA->m_colour = colour;
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::~wxPen()
|
wxPen::~wxPen()
|
||||||
{
|
{
|
||||||
|
// m_refData unrefed in ~wxObject
|
||||||
}
|
}
|
||||||
|
|
||||||
// Should implement Create
|
wxObjectRefData *wxPen::CreateRefData() const
|
||||||
wxPen::wxPen(const wxColour& col, int Width, int Style)
|
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
return new wxPenRefData;
|
||||||
|
|
||||||
M_PENDATA->m_colour = col;
|
|
||||||
M_PENDATA->m_width = Width;
|
|
||||||
M_PENDATA->m_style = Style;
|
|
||||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_nbDash = 0 ;
|
|
||||||
M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
wxPen::wxPen(const wxBitmap& stipple, int Width)
|
wxObjectRefData *wxPen::CloneRefData(const wxObjectRefData *data) const
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
return new wxPenRefData(*(wxPenRefData *)data);
|
||||||
|
|
||||||
M_PENDATA->m_stipple = stipple;
|
|
||||||
M_PENDATA->m_width = Width;
|
|
||||||
M_PENDATA->m_style = wxSTIPPLE;
|
|
||||||
M_PENDATA->m_join = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_cap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_nbDash = 0 ;
|
|
||||||
M_PENDATA->m_dash = (wxMOTIFDash*)NULL;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::Unshare()
|
bool wxPen::operator == ( const wxPen& pen ) const
|
||||||
{
|
{
|
||||||
// Don't change shared data
|
if (m_refData == pen.m_refData) return TRUE;
|
||||||
if (!m_refData)
|
|
||||||
{
|
if (!m_refData || !pen.m_refData) return FALSE;
|
||||||
m_refData = new wxPenRefData();
|
|
||||||
}
|
return ( *(wxPenRefData*)m_refData == *(wxPenRefData*)pen.m_refData );
|
||||||
else
|
|
||||||
{
|
|
||||||
wxPenRefData* ref = new wxPenRefData(*(wxPenRefData*)m_refData);
|
|
||||||
UnRef();
|
|
||||||
m_refData = ref;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetColour(const wxColour& col)
|
void wxPen::SetColour( const wxColour &colour )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_colour = col;
|
M_PENDATA->m_colour = colour;
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetColour(unsigned char r, unsigned char g, unsigned char b)
|
void wxPen::SetDashes( int number_of_dashes, const wxDash *dash )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_colour.Set(r, g, b);
|
M_PENDATA->m_countDashes = number_of_dashes;
|
||||||
|
M_PENDATA->m_dash = (wxX11Dash *)dash; // TODO
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetWidth(int Width)
|
void wxPen::SetColour( int red, int green, int blue )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_width = Width;
|
M_PENDATA->m_colour.Set( red, green, blue );
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetStyle(int Style)
|
void wxPen::SetCap( int capStyle )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_style = Style;
|
M_PENDATA->m_capStyle = capStyle;
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetStipple(const wxBitmap& Stipple)
|
void wxPen::SetJoin( int joinStyle )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_stipple = Stipple;
|
M_PENDATA->m_joinStyle = joinStyle;
|
||||||
M_PENDATA->m_style = wxSTIPPLE;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetDashes(int nb_dashes, const wxDash *Dash)
|
void wxPen::SetStyle( int style )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_nbDash = nb_dashes;
|
M_PENDATA->m_style = style;
|
||||||
M_PENDATA->m_dash = (wxMOTIFDash *)Dash;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetJoin(int Join)
|
void wxPen::SetWidth( int width )
|
||||||
{
|
{
|
||||||
Unshare();
|
AllocExclusive();
|
||||||
|
|
||||||
M_PENDATA->m_join = Join;
|
M_PENDATA->m_width = width;
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void wxPen::SetCap(int Cap)
|
int wxPen::GetDashes( wxDash **ptr ) const
|
||||||
{
|
{
|
||||||
Unshare();
|
*ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
|
||||||
|
return (M_PENDATA ? M_PENDATA->m_countDashes : 0);
|
||||||
M_PENDATA->m_cap = Cap;
|
|
||||||
|
|
||||||
RealizeResource();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool wxPen::RealizeResource()
|
int wxPen::GetDashCount() const
|
||||||
{
|
{
|
||||||
// Nothing more to do
|
return (M_PENDATA->m_countDashes);
|
||||||
return TRUE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxDash* wxPen::GetDash() const
|
||||||
|
{
|
||||||
|
return (wxDash*)M_PENDATA->m_dash;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetCap() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_capStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetJoin() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_joinStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetStyle() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_style;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetWidth() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_width;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxColour &wxPen::GetColour() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_colour;
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user