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