Updated brush/pen implementation for OS/2 to current implementation style.
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52739 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -12,36 +12,8 @@
|
|||||||
#ifndef _WX_BRUSH_H_
|
#ifndef _WX_BRUSH_H_
|
||||||
#define _WX_BRUSH_H_
|
#define _WX_BRUSH_H_
|
||||||
|
|
||||||
#include "wx/gdicmn.h"
|
class WXDLLIMPEXP_FWD_CORE wxColour;
|
||||||
#include "wx/gdiobj.h"
|
class WXDLLIMPEXP_FWD_CORE wxBitmap;
|
||||||
#include "wx/bitmap.h"
|
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxBrush;
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
|
|
||||||
{
|
|
||||||
friend class WXDLLIMPEXP_FWD_CORE wxBrush;
|
|
||||||
public:
|
|
||||||
wxBrushRefData();
|
|
||||||
wxBrushRefData(const wxBrushRefData& rData);
|
|
||||||
virtual ~wxBrushRefData();
|
|
||||||
|
|
||||||
bool operator == (const wxBrushRefData& data) const
|
|
||||||
{
|
|
||||||
return (m_nStyle == data.m_nStyle &&
|
|
||||||
m_vStipple.IsSameAs(data.m_vStipple) &&
|
|
||||||
m_vColour == data.m_vColour);
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
wxBrushStyle m_nStyle;
|
|
||||||
wxBitmap m_vStipple;
|
|
||||||
wxColour m_vColour;
|
|
||||||
WXHBRUSH m_hBrush; // in OS/2 GPI this will be the PS the pen is associated with
|
|
||||||
AREABUNDLE m_vBundle;
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
|
||||||
|
|
||||||
// Brush
|
// Brush
|
||||||
class WXDLLEXPORT wxBrush: public wxBrushBase
|
class WXDLLEXPORT wxBrush: public wxBrushBase
|
||||||
@@ -64,10 +36,10 @@ public:
|
|||||||
virtual void SetStyle(wxBrushStyle nStyle);
|
virtual void SetStyle(wxBrushStyle nStyle);
|
||||||
virtual void SetStipple(const wxBitmap& rStipple);
|
virtual void SetStipple(const wxBitmap& rStipple);
|
||||||
|
|
||||||
inline wxColour& GetColour(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_vColour : wxNullColour); };
|
wxColour GetColour(void) const;
|
||||||
virtual wxBrushStyle GetStyle(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_nStyle : wxBRUSHSTYLE_INVALID); };
|
virtual wxBrushStyle GetStyle(void) const;
|
||||||
inline wxBitmap* GetStipple(void) const { return (M_BRUSHDATA ? & M_BRUSHDATA->m_vStipple : NULL); };
|
wxBitmap* GetStipple(void) const;
|
||||||
inline int GetPS(void) const { return (M_BRUSHDATA ? M_BRUSHDATA->m_hBrush : 0); };
|
int GetPS(void) const;
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implementation
|
// Implementation
|
||||||
|
@@ -17,49 +17,14 @@
|
|||||||
|
|
||||||
typedef long wxPMDash;
|
typedef long wxPMDash;
|
||||||
|
|
||||||
class WXDLLIMPEXP_FWD_CORE wxPen;
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxPenRefData: public wxGDIRefData
|
|
||||||
{
|
|
||||||
friend class WXDLLIMPEXP_FWD_CORE wxPen;
|
|
||||||
public:
|
|
||||||
wxPenRefData();
|
|
||||||
wxPenRefData(const wxPenRefData& rData);
|
|
||||||
virtual ~wxPenRefData();
|
|
||||||
|
|
||||||
bool operator==(const wxPenRefData& data) const
|
|
||||||
{
|
|
||||||
// we intentionally don't compare m_hPen fields here
|
|
||||||
return m_nStyle == data.m_nStyle &&
|
|
||||||
m_nWidth == data.m_nWidth &&
|
|
||||||
m_nJoin == data.m_nJoin &&
|
|
||||||
m_nCap == data.m_nCap &&
|
|
||||||
m_vColour == data.m_vColour &&
|
|
||||||
(m_nStyle != wxPENSTYLE_STIPPLE || m_vStipple.IsSameAs(data.m_vStipple)) &&
|
|
||||||
(m_nStyle != wxPENSTYLE_USER_DASH ||
|
|
||||||
(m_dash == data.m_dash &&
|
|
||||||
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int m_nWidth;
|
|
||||||
wxPenStyle m_nStyle;
|
|
||||||
wxPenJoin m_nJoin;
|
|
||||||
wxPenCap m_nCap;
|
|
||||||
wxBitmap m_vStipple;
|
|
||||||
int m_nbDash;
|
|
||||||
wxDash * m_dash;
|
|
||||||
wxColour m_vColour;
|
|
||||||
WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_PENDATA ((wxPenRefData *)m_refData)
|
|
||||||
|
|
||||||
// Pen
|
// Pen
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
class WXDLLEXPORT wxPen : public wxPenBase
|
class WXDLLEXPORT wxPen : public wxPenBase
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
wxPen();
|
wxPen() { }
|
||||||
wxPen( const wxColour& rColour
|
wxPen( const wxColour& rColour
|
||||||
,int nWidth = 1
|
,int nWidth = 1
|
||||||
,wxPenStyle nStyle = wxPENSTYLE_SOLID
|
,wxPenStyle nStyle = wxPENSTYLE_SOLID
|
||||||
@@ -71,16 +36,9 @@ public:
|
|||||||
wxPen( const wxBitmap& rStipple
|
wxPen( const wxBitmap& rStipple
|
||||||
,int nWidth
|
,int nWidth
|
||||||
);
|
);
|
||||||
virtual ~wxPen();
|
virtual ~wxPen() { }
|
||||||
|
|
||||||
inline bool operator == (const wxPen& rPen) const
|
|
||||||
{
|
|
||||||
const wxPenRefData *penData = (wxPenRefData *)rPen.m_refData;
|
|
||||||
|
|
||||||
// an invalid pen is only equal to another invalid pen
|
|
||||||
return m_refData ? penData && *M_PENDATA == *penData : !penData;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
bool operator == (const wxPen& rPen) const;
|
||||||
inline bool operator != (const wxPen& rPen) const
|
inline bool operator != (const wxPen& rPen) const
|
||||||
{ return !(*this == rPen); }
|
{ return !(*this == rPen); }
|
||||||
|
|
||||||
@@ -100,21 +58,16 @@ public:
|
|||||||
void SetCap(wxPenCap nCap);
|
void SetCap(wxPenCap nCap);
|
||||||
void SetPS(HPS hPS);
|
void SetPS(HPS hPS);
|
||||||
|
|
||||||
inline wxColour& GetColour(void) const { return (M_PENDATA ? M_PENDATA->m_vColour : wxNullColour); };
|
wxColour& GetColour(void) const;
|
||||||
inline int GetWidth(void) const { return (M_PENDATA ? M_PENDATA->m_nWidth : -1); };
|
int GetWidth(void) const;
|
||||||
inline wxPenStyle GetStyle(void) const { return (M_PENDATA ? M_PENDATA->m_nStyle : wxPENSTYLE_INVALID); };
|
wxPenStyle GetStyle(void) const;
|
||||||
inline wxPenJoin GetJoin(void) const { return (M_PENDATA ? M_PENDATA->m_nJoin : wxJOIN_INVALID); };
|
wxPenJoin GetJoin(void) const;
|
||||||
inline wxPenCap GetCap(void) const { return (M_PENDATA ? M_PENDATA->m_nCap : wxCAP_INVALID); };
|
wxPenCap GetCap(void) const;
|
||||||
inline int GetPS(void) const { return (M_PENDATA ? M_PENDATA->m_hPen : 0); };
|
int GetPS(void) const;
|
||||||
inline int GetDashes(wxDash **ptr) const
|
int GetDashes(wxDash **ptr) const;
|
||||||
{
|
wxDash* GetDash() const;
|
||||||
*ptr = (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*) NULL);
|
int GetDashCount() const;
|
||||||
return (M_PENDATA ? M_PENDATA->m_nbDash : -1);
|
wxBitmap* GetStipple(void) const;
|
||||||
}
|
|
||||||
inline wxDash* GetDash() const { return (M_PENDATA ? (wxDash*)M_PENDATA->m_dash : (wxDash*)NULL); };
|
|
||||||
inline int GetDashCount() const { return (M_PENDATA ? M_PENDATA->m_nbDash : 0); };
|
|
||||||
|
|
||||||
inline wxBitmap* GetStipple(void) const { return (M_PENDATA ? (& M_PENDATA->m_vStipple) : (wxBitmap*) NULL); };
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Implementation
|
// Implementation
|
||||||
|
@@ -23,22 +23,66 @@
|
|||||||
|
|
||||||
#include "wx/os2/private.h"
|
#include "wx/os2/private.h"
|
||||||
|
|
||||||
#include "assert.h"
|
class WXDLLEXPORT wxBrushRefData: public wxGDIRefData
|
||||||
|
{
|
||||||
|
friend class WXDLLIMPEXP_FWD_CORE wxBrush;
|
||||||
|
public:
|
||||||
|
wxBrushRefData(const wxColour& colour = wxNullColour, wxBrushStyle style = wxBRUSHSTYLE_SOLID);
|
||||||
|
wxBrushRefData(const wxBitmap& stipple);
|
||||||
|
wxBrushRefData(const wxBrushRefData& rData);
|
||||||
|
virtual ~wxBrushRefData();
|
||||||
|
|
||||||
|
bool operator == (const wxBrushRefData& data) const
|
||||||
|
{
|
||||||
|
return (m_nStyle == data.m_nStyle &&
|
||||||
|
m_vStipple.IsSameAs(data.m_vStipple) &&
|
||||||
|
m_vColour == data.m_vColour);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected:
|
||||||
|
wxBrushStyle m_nStyle;
|
||||||
|
wxBitmap m_vStipple;
|
||||||
|
wxColour m_vColour;
|
||||||
|
WXHBRUSH m_hBrush; // in OS/2 GPI this will be the PS the pen is associated with
|
||||||
|
AREABUNDLE m_vBundle;
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M_BRUSHDATA ((wxBrushRefData *)m_refData)
|
||||||
|
|
||||||
|
// ============================================================================
|
||||||
|
// wxBrushRefData implementation
|
||||||
|
// ============================================================================
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
IMPLEMENT_DYNAMIC_CLASS(wxBrush, wxGDIObject)
|
||||||
|
|
||||||
wxBrushRefData::wxBrushRefData()
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrushRefData ctors/dtor
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxBrushRefData::wxBrushRefData(const wxColour& colour, wxBrushStyle style)
|
||||||
|
: m_vColour(colour)
|
||||||
{
|
{
|
||||||
m_nStyle = wxSOLID;
|
m_nStyle = style;
|
||||||
m_hBrush = 0;
|
m_hBrush = 0;
|
||||||
memset(&m_vBundle, '\0', sizeof(AREABUNDLE));
|
memset(&m_vBundle, '\0', sizeof(AREABUNDLE));
|
||||||
} // end of wxBrushRefData::wxBrushRefData
|
} // end of wxBrushRefData::wxBrushRefData
|
||||||
|
|
||||||
|
wxBrushRefData::wxBrushRefData(const wxBitmap& stipple)
|
||||||
|
{
|
||||||
|
m_vStipple = stipple;
|
||||||
|
m_nStyle = stipple.GetMask() ? wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE
|
||||||
|
: wxBRUSHSTYLE_STIPPLE;
|
||||||
|
|
||||||
|
m_hBrush = NULL;
|
||||||
|
memset(&m_vBundle, '\0', sizeof(AREABUNDLE));
|
||||||
|
}
|
||||||
|
|
||||||
wxBrushRefData::wxBrushRefData(const wxBrushRefData& rData)
|
wxBrushRefData::wxBrushRefData(const wxBrushRefData& rData)
|
||||||
|
: wxGDIRefData(),
|
||||||
|
m_vStipple(rData.m_vStipple),
|
||||||
|
m_vColour(rData.m_vColour)
|
||||||
{
|
{
|
||||||
m_nStyle = rData.m_nStyle;
|
m_nStyle = rData.m_nStyle;
|
||||||
m_vStipple = rData.m_vStipple;
|
|
||||||
m_vColour = rData.m_vColour;
|
|
||||||
m_hBrush = 0;
|
m_hBrush = 0;
|
||||||
memcpy(&m_vBundle, &rData.m_vBundle, sizeof(AREABUNDLE));
|
memcpy(&m_vBundle, &rData.m_vBundle, sizeof(AREABUNDLE));
|
||||||
} // end of wxBrushRefData::wxBrushRefData
|
} // end of wxBrushRefData::wxBrushRefData
|
||||||
@@ -47,9 +91,14 @@ wxBrushRefData::~wxBrushRefData()
|
|||||||
{
|
{
|
||||||
} // end of wxBrushRefData::~wxBrushRefData
|
} // end of wxBrushRefData::~wxBrushRefData
|
||||||
|
|
||||||
//
|
// ============================================================================
|
||||||
// Brushes
|
// wxBrush implementation
|
||||||
//
|
// ============================================================================
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrush ctors/dtor
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
wxBrush::wxBrush()
|
wxBrush::wxBrush()
|
||||||
{
|
{
|
||||||
} // end of wxBrush::wxBrush
|
} // end of wxBrush::wxBrush
|
||||||
@@ -63,12 +112,7 @@ wxBrush::wxBrush(
|
|||||||
, wxBrushStyle nStyle
|
, wxBrushStyle nStyle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
m_refData = new wxBrushRefData(rColour, nStyle);
|
||||||
|
|
||||||
M_BRUSHDATA->m_vColour = rColour;
|
|
||||||
M_BRUSHDATA->m_nStyle = nStyle;
|
|
||||||
M_BRUSHDATA->m_hBrush = 0;
|
|
||||||
memset(&M_BRUSHDATA->m_vBundle, '\0', sizeof(AREABUNDLE));
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of wxBrush::wxBrush
|
} // end of wxBrush::wxBrush
|
||||||
@@ -76,12 +120,7 @@ wxBrush::wxBrush(
|
|||||||
#if FUTURE_WXWIN_COMPATIBILITY_3_0
|
#if FUTURE_WXWIN_COMPATIBILITY_3_0
|
||||||
wxBrush::wxBrush(const wxColour& col, int style)
|
wxBrush::wxBrush(const wxColour& col, int style)
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
m_refData = new wxBrushRefData(col, (wxBrushStyle)style);
|
||||||
|
|
||||||
M_BRUSHDATA->m_vColour = col;
|
|
||||||
M_BRUSHDATA->m_nStyle = (wxBrushStyle)style;
|
|
||||||
M_BRUSHDATA->m_hBrush = 0;
|
|
||||||
memset(&M_BRUSHDATA->m_vBundle, '\0', sizeof(AREABUNDLE));
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
@@ -89,12 +128,7 @@ wxBrush::wxBrush(const wxColour& col, int style)
|
|||||||
|
|
||||||
wxBrush::wxBrush(const wxBitmap& rStipple)
|
wxBrush::wxBrush(const wxBitmap& rStipple)
|
||||||
{
|
{
|
||||||
m_refData = new wxBrushRefData;
|
m_refData = new wxBrushRefData(rStipple);
|
||||||
|
|
||||||
M_BRUSHDATA->m_nStyle = wxSTIPPLE;
|
|
||||||
M_BRUSHDATA->m_vStipple = rStipple;
|
|
||||||
M_BRUSHDATA->m_hBrush = 0;
|
|
||||||
memset(&M_BRUSHDATA->m_vBundle, '\0', sizeof(AREABUNDLE));
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of wxBrush::wxBrush
|
} // end of wxBrush::wxBrush
|
||||||
@@ -226,10 +260,42 @@ bool wxBrush::RealizeResource()
|
|||||||
return false;
|
return false;
|
||||||
} // end of wxBrush::RealizeResource
|
} // end of wxBrush::RealizeResource
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrush accessors
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxColour wxBrush::GetColour() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxNullColour, _T("invalid brush") );
|
||||||
|
|
||||||
|
return M_BRUSHDATA->m_vColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBrushStyle wxBrush::GetStyle() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxBRUSHSTYLE_INVALID, _T("invalid brush") );
|
||||||
|
|
||||||
|
return M_BRUSHDATA->m_nStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap *wxBrush::GetStipple() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), NULL, _T("invalid brush") );
|
||||||
|
|
||||||
|
return &(M_BRUSHDATA->m_vStipple);
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxBrush::GetPS() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, _T("invalid brush") );
|
||||||
|
|
||||||
|
return M_BRUSHDATA->m_hBrush;
|
||||||
|
}
|
||||||
|
|
||||||
WXHANDLE wxBrush::GetResourceHandle() const
|
WXHANDLE wxBrush::GetResourceHandle() const
|
||||||
{
|
{
|
||||||
if (!M_BRUSHDATA)
|
wxCHECK_MSG( Ok(), 0, _T("invalid brush") );
|
||||||
return 0;
|
|
||||||
return (WXHANDLE)M_BRUSHDATA->m_hBrush;
|
return (WXHANDLE)M_BRUSHDATA->m_hBrush;
|
||||||
} // end of wxBrush::GetResourceHandle
|
} // end of wxBrush::GetResourceHandle
|
||||||
|
|
||||||
@@ -248,6 +314,10 @@ bool wxBrush::IsFree() const
|
|||||||
return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
|
return (M_BRUSHDATA && (M_BRUSHDATA->m_hBrush == 0));
|
||||||
} // end of wxBrush::IsFree
|
} // end of wxBrush::IsFree
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrush setters
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
void wxBrush::SetColour( const wxColour& rColour )
|
void wxBrush::SetColour( const wxColour& rColour )
|
||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
@@ -289,6 +359,9 @@ void wxBrush::SetPS(
|
|||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of WxWinGdi_CPen::SetPS
|
} // end of WxWinGdi_CPen::SetPS
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxBrush house keeping stuff
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
bool wxBrush::operator == (
|
bool wxBrush::operator == (
|
||||||
const wxBrush& brush
|
const wxBrush& brush
|
||||||
|
204
src/os2/pen.cpp
204
src/os2/pen.cpp
@@ -23,19 +23,75 @@
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/os2/private.h"
|
#include "wx/os2/private.h"
|
||||||
#include "assert.h"
|
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
class WXDLLIMPEXP_FWD_CORE wxPen;
|
||||||
|
|
||||||
wxPenRefData::wxPenRefData()
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxPenRefData: contains information about an HPEN and its handle
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxPenRefData: public wxGDIRefData
|
||||||
|
{
|
||||||
|
friend class WXDLLIMPEXP_FWD_CORE wxPen;
|
||||||
|
public:
|
||||||
|
wxPenRefData();
|
||||||
|
wxPenRefData(const wxPenRefData& rData);
|
||||||
|
wxPenRefData(const wxColour& col, int width, wxPenStyle style);
|
||||||
|
wxPenRefData(const wxBitmap& stipple, int width);
|
||||||
|
virtual ~wxPenRefData();
|
||||||
|
|
||||||
|
bool operator==(const wxPenRefData& data) const
|
||||||
|
{
|
||||||
|
// we intentionally don't compare m_hPen fields here
|
||||||
|
return m_nStyle == data.m_nStyle &&
|
||||||
|
m_nWidth == data.m_nWidth &&
|
||||||
|
m_nJoin == data.m_nJoin &&
|
||||||
|
m_nCap == data.m_nCap &&
|
||||||
|
m_vColour == data.m_vColour &&
|
||||||
|
(m_nStyle != wxPENSTYLE_STIPPLE || m_vStipple.IsSameAs(data.m_vStipple)) &&
|
||||||
|
(m_nStyle != wxPENSTYLE_USER_DASH ||
|
||||||
|
(m_dash == data.m_dash &&
|
||||||
|
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
// initialize the fields which have reasonable default values
|
||||||
|
//
|
||||||
|
// doesn't initialize m_width and m_style which must be initialize in ctor
|
||||||
|
void Init()
|
||||||
{
|
{
|
||||||
m_nStyle = wxPENSTYLE_SOLID;
|
|
||||||
m_nWidth = 1;
|
|
||||||
m_nJoin = wxJOIN_ROUND;
|
m_nJoin = wxJOIN_ROUND;
|
||||||
m_nCap = wxCAP_ROUND;
|
m_nCap = wxCAP_ROUND;
|
||||||
m_nbDash = 0;
|
m_nbDash = 0;
|
||||||
m_dash = (wxDash*)NULL;
|
m_dash = NULL;
|
||||||
m_hPen = 0L;
|
m_hPen = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int m_nWidth;
|
||||||
|
wxPenStyle m_nStyle;
|
||||||
|
wxPenJoin m_nJoin;
|
||||||
|
wxPenCap m_nCap;
|
||||||
|
wxBitmap m_vStipple;
|
||||||
|
int m_nbDash;
|
||||||
|
wxDash * m_dash;
|
||||||
|
wxColour m_vColour;
|
||||||
|
WXHPEN m_hPen;// in OS/2 GPI this will be the PS the pen is associated with
|
||||||
|
|
||||||
|
DECLARE_NO_ASSIGN_CLASS(wxPenRefData)
|
||||||
|
};
|
||||||
|
|
||||||
|
#define M_PENDATA ((wxPenRefData *)m_refData)
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
// wxPenRefData ctors/dtor
|
||||||
|
// ----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
wxPenRefData::wxPenRefData()
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
|
m_nStyle = wxPENSTYLE_SOLID;
|
||||||
|
m_nWidth = 1;
|
||||||
} // end of wxPenRefData::wxPenRefData
|
} // end of wxPenRefData::wxPenRefData
|
||||||
|
|
||||||
wxPenRefData::wxPenRefData(
|
wxPenRefData::wxPenRefData(
|
||||||
@@ -52,36 +108,43 @@ wxPenRefData::wxPenRefData(
|
|||||||
m_hPen = 0L;
|
m_hPen = 0L;
|
||||||
} // end of wxPenRefData::wxPenRefData
|
} // end of wxPenRefData::wxPenRefData
|
||||||
|
|
||||||
|
wxPenRefData::wxPenRefData(const wxColour& col, int width, wxPenStyle style)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
|
m_nStyle = style;
|
||||||
|
m_nWidth = width;
|
||||||
|
|
||||||
|
m_vColour = col;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPenRefData::wxPenRefData(const wxBitmap& stipple, int width)
|
||||||
|
{
|
||||||
|
Init();
|
||||||
|
|
||||||
|
m_nStyle = wxPENSTYLE_STIPPLE;
|
||||||
|
m_nWidth = width;
|
||||||
|
|
||||||
|
m_vStipple = stipple;
|
||||||
|
}
|
||||||
|
|
||||||
wxPenRefData::~wxPenRefData()
|
wxPenRefData::~wxPenRefData()
|
||||||
{
|
{
|
||||||
} // end of wxPenRefData::~wxPenRefData
|
} // end of wxPenRefData::~wxPenRefData
|
||||||
|
|
||||||
//
|
// ----------------------------------------------------------------------------
|
||||||
// Pens
|
// wxPen
|
||||||
//
|
// ----------------------------------------------------------------------------
|
||||||
wxPen::wxPen()
|
|
||||||
{
|
|
||||||
} // end of wxPen::wxPen
|
|
||||||
|
|
||||||
wxPen::~wxPen()
|
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
||||||
{
|
|
||||||
} // end of wxPen::wxPen
|
|
||||||
|
|
||||||
// Should implement Create
|
|
||||||
wxPen::wxPen(
|
wxPen::wxPen(
|
||||||
const wxColour& rColour
|
const wxColour& rColour
|
||||||
, int nWidth
|
, int nWidth
|
||||||
, wxPenStyle nStyle
|
, wxPenStyle nStyle
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
m_refData = new wxPenRefData(rColour, nWidth, nStyle);
|
||||||
|
|
||||||
M_PENDATA->m_vColour = rColour;
|
|
||||||
M_PENDATA->m_nWidth = nWidth;
|
|
||||||
M_PENDATA->m_nStyle = nStyle;
|
|
||||||
M_PENDATA->m_nJoin = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_nCap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_hPen = 0L;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of wxPen::wxPen
|
} // end of wxPen::wxPen
|
||||||
@@ -89,14 +152,7 @@ wxPen::wxPen(
|
|||||||
#if FUTURE_WXWIN_COMPATIBILITY_3_0
|
#if FUTURE_WXWIN_COMPATIBILITY_3_0
|
||||||
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(colour, width, (wxPenStyle)style);
|
||||||
|
|
||||||
M_PENDATA->m_vColour = colour;
|
|
||||||
M_PENDATA->m_nWidth = width;
|
|
||||||
M_PENDATA->m_nStyle = (wxPenStyle)nStyle;
|
|
||||||
M_PENDATA->m_nJoin = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_nCap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_hPen = 0L;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
@@ -107,14 +163,7 @@ wxPen::wxPen(
|
|||||||
, int nWidth
|
, int nWidth
|
||||||
)
|
)
|
||||||
{
|
{
|
||||||
m_refData = new wxPenRefData;
|
m_refData = new wxPenRefData (rStipple, nWidth);
|
||||||
|
|
||||||
M_PENDATA->m_vStipple = rStipple;
|
|
||||||
M_PENDATA->m_nWidth = nWidth;
|
|
||||||
M_PENDATA->m_nStyle = wxSTIPPLE;
|
|
||||||
M_PENDATA->m_nJoin = wxJOIN_ROUND ;
|
|
||||||
M_PENDATA->m_nCap = wxCAP_ROUND ;
|
|
||||||
M_PENDATA->m_hPen = 0;
|
|
||||||
|
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of wxPen::wxPen
|
} // end of wxPen::wxPen
|
||||||
@@ -400,7 +449,7 @@ void wxPen::SetStipple(
|
|||||||
{
|
{
|
||||||
AllocExclusive();
|
AllocExclusive();
|
||||||
M_PENDATA->m_vStipple = rStipple;
|
M_PENDATA->m_vStipple = rStipple;
|
||||||
M_PENDATA->m_nStyle = wxSTIPPLE;
|
M_PENDATA->m_nStyle = wxPENSTYLE_STIPPLE;
|
||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of wxPen::SetStipple
|
} // end of wxPen::SetStipple
|
||||||
|
|
||||||
@@ -430,6 +479,77 @@ void wxPen::SetCap(
|
|||||||
RealizeResource();
|
RealizeResource();
|
||||||
} // end of wxPen::SetCap
|
} // end of wxPen::SetCap
|
||||||
|
|
||||||
|
wxColour& wxPen::GetColour() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_vColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetWidth() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_nWidth;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPenStyle wxPen::GetStyle() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxPENSTYLE_INVALID, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_nStyle;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPenJoin wxPen::GetJoin() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxJOIN_INVALID, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_nJoin;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxPenCap wxPen::GetCap() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), wxCAP_INVALID, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_nCap;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetPS() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), 0, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_hPen;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetDashes(wxDash** ptr) const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
*ptr = M_PENDATA->m_dash;
|
||||||
|
return M_PENDATA->m_nbDash;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDash* wxPen::GetDash() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_dash;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetDashCount() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), -1, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return M_PENDATA->m_nbDash;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap* wxPen::GetStipple() const
|
||||||
|
{
|
||||||
|
wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") );
|
||||||
|
|
||||||
|
return &(M_PENDATA->m_vStipple);
|
||||||
|
}
|
||||||
|
|
||||||
int wx2os2PenStyle(
|
int wx2os2PenStyle(
|
||||||
wxPenStyle nWxStyle
|
wxPenStyle nWxStyle
|
||||||
)
|
)
|
||||||
|
Reference in New Issue
Block a user