make wxPenRefData private
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@44744 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -13,59 +13,7 @@
|
|||||||
#define _WX_PEN_H_
|
#define _WX_PEN_H_
|
||||||
|
|
||||||
#include "wx/gdiobj.h"
|
#include "wx/gdiobj.h"
|
||||||
#include "wx/bitmap.h"
|
#include "wx/gdicmn.h"
|
||||||
#include "wx/colour.h"
|
|
||||||
|
|
||||||
typedef WXDWORD wxMSWDash;
|
|
||||||
|
|
||||||
class WXDLLEXPORT wxPen;
|
|
||||||
|
|
||||||
// VZ: this class should be made private
|
|
||||||
class WXDLLEXPORT wxPenRefData : public wxGDIRefData
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
wxPenRefData();
|
|
||||||
wxPenRefData(const wxPenRefData& data);
|
|
||||||
virtual ~wxPenRefData();
|
|
||||||
|
|
||||||
bool operator==(const wxPenRefData& data) const
|
|
||||||
{
|
|
||||||
// we intentionally don't compare m_hPen fields here
|
|
||||||
return m_style == data.m_style &&
|
|
||||||
m_width == data.m_width &&
|
|
||||||
m_join == data.m_join &&
|
|
||||||
m_cap == data.m_cap &&
|
|
||||||
m_colour == data.m_colour &&
|
|
||||||
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
|
||||||
(m_style != wxUSER_DASH ||
|
|
||||||
(m_nbDash == data.m_nbDash &&
|
|
||||||
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
|
||||||
}
|
|
||||||
|
|
||||||
protected:
|
|
||||||
int m_width;
|
|
||||||
int m_style;
|
|
||||||
int m_join;
|
|
||||||
int m_cap;
|
|
||||||
wxBitmap m_stipple;
|
|
||||||
int m_nbDash;
|
|
||||||
wxDash * m_dash;
|
|
||||||
wxColour m_colour;
|
|
||||||
WXHPEN m_hPen;
|
|
||||||
|
|
||||||
private:
|
|
||||||
friend class WXDLLEXPORT wxPen;
|
|
||||||
|
|
||||||
// Cannot use
|
|
||||||
// DECLARE_NO_COPY_CLASS(wxPenRefData)
|
|
||||||
// because copy constructor is explicitly declared above;
|
|
||||||
// but no copy assignment operator is defined, so declare
|
|
||||||
// it private to prevent the compiler from defining it:
|
|
||||||
wxPenRefData& operator=(const wxPenRefData&);
|
|
||||||
};
|
|
||||||
|
|
||||||
#define M_PENDATA ((wxPenRefData *)m_refData)
|
|
||||||
#define wxPENDATA(x) ((wxPenRefData *)(x).m_refData)
|
|
||||||
|
|
||||||
// ----------------------------------------------------------------------------
|
// ----------------------------------------------------------------------------
|
||||||
// Pen
|
// Pen
|
||||||
@@ -79,14 +27,7 @@ public:
|
|||||||
wxPen(const wxBitmap& stipple, int width);
|
wxPen(const wxBitmap& stipple, int width);
|
||||||
virtual ~wxPen();
|
virtual ~wxPen();
|
||||||
|
|
||||||
bool operator==(const wxPen& pen) const
|
bool operator==(const wxPen& pen) const;
|
||||||
{
|
|
||||||
const wxPenRefData *penData = (wxPenRefData *)pen.m_refData;
|
|
||||||
|
|
||||||
// an invalid pen is only equal to another invalid pen
|
|
||||||
return m_refData ? penData && *M_PENDATA == *penData : !penData;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
bool operator!=(const wxPen& pen) const { return !(*this == pen); }
|
||||||
|
|
||||||
virtual bool Ok() const { return IsOk(); }
|
virtual bool Ok() const { return IsOk(); }
|
||||||
@@ -103,20 +44,15 @@ public:
|
|||||||
void SetJoin(int join);
|
void SetJoin(int join);
|
||||||
void SetCap(int cap);
|
void SetCap(int cap);
|
||||||
|
|
||||||
wxColour& GetColour() const { return (M_PENDATA ? M_PENDATA->m_colour : wxNullColour); };
|
wxColour& GetColour() const;
|
||||||
int GetWidth() const { return (M_PENDATA ? M_PENDATA->m_width : 0); };
|
int GetWidth() const;
|
||||||
int GetStyle() const { return (M_PENDATA ? M_PENDATA->m_style : 0); };
|
int GetStyle() const;
|
||||||
int GetJoin() const { return (M_PENDATA ? M_PENDATA->m_join : 0); };
|
int GetJoin() const;
|
||||||
int GetCap() const { return (M_PENDATA ? M_PENDATA->m_cap : 0); };
|
int GetCap() const;
|
||||||
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 : 0);
|
wxBitmap* GetStipple() const;
|
||||||
}
|
|
||||||
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() const { return (M_PENDATA ? (& M_PENDATA->m_stipple) : (wxBitmap*) NULL); };
|
|
||||||
|
|
||||||
// Internal
|
// Internal
|
||||||
bool RealizeResource();
|
bool RealizeResource();
|
||||||
|
110
src/msw/pen.cpp
110
src/msw/pen.cpp
@@ -19,17 +19,51 @@
|
|||||||
#include "wx/pen.h"
|
#include "wx/pen.h"
|
||||||
|
|
||||||
#ifndef WX_PRECOMP
|
#ifndef WX_PRECOMP
|
||||||
#include <stdio.h>
|
#include "wx/bitmap.h"
|
||||||
#include "wx/list.h"
|
|
||||||
#include "wx/utils.h"
|
#include "wx/utils.h"
|
||||||
#include "wx/app.h"
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#include "wx/msw/private.h"
|
#include "wx/msw/private.h"
|
||||||
|
|
||||||
|
typedef WXDWORD wxMSWDash;
|
||||||
|
|
||||||
static int wx2msPenStyle(int wx_style);
|
static int wx2msPenStyle(int wx_style);
|
||||||
|
|
||||||
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
#define M_PENDATA ((wxPenRefData*)m_refData)
|
||||||
|
|
||||||
|
class WXDLLEXPORT wxPenRefData : public wxGDIRefData
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
wxPenRefData();
|
||||||
|
wxPenRefData(const wxPenRefData& data);
|
||||||
|
virtual ~wxPenRefData();
|
||||||
|
|
||||||
|
bool operator==(const wxPenRefData& data) const
|
||||||
|
{
|
||||||
|
// we intentionally don't compare m_hPen fields here
|
||||||
|
return m_style == data.m_style &&
|
||||||
|
m_width == data.m_width &&
|
||||||
|
m_join == data.m_join &&
|
||||||
|
m_cap == data.m_cap &&
|
||||||
|
m_colour == data.m_colour &&
|
||||||
|
(m_style != wxSTIPPLE || m_stipple.IsSameAs(data.m_stipple)) &&
|
||||||
|
(m_style != wxUSER_DASH ||
|
||||||
|
(m_nbDash == data.m_nbDash &&
|
||||||
|
memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
int m_width;
|
||||||
|
int m_style;
|
||||||
|
int m_join;
|
||||||
|
int m_cap;
|
||||||
|
wxBitmap m_stipple;
|
||||||
|
int m_nbDash;
|
||||||
|
wxDash * m_dash;
|
||||||
|
wxColour m_colour;
|
||||||
|
WXHPEN m_hPen;
|
||||||
|
|
||||||
|
DECLARE_NO_ASSIGN_CLASS(wxPenRefData)
|
||||||
|
};
|
||||||
|
|
||||||
wxPenRefData::wxPenRefData()
|
wxPenRefData::wxPenRefData()
|
||||||
{
|
{
|
||||||
@@ -63,6 +97,8 @@ wxPenRefData::~wxPenRefData()
|
|||||||
|
|
||||||
// Pens
|
// Pens
|
||||||
|
|
||||||
|
IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject)
|
||||||
|
|
||||||
wxPen::wxPen()
|
wxPen::wxPen()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
@@ -106,6 +142,14 @@ wxPen::wxPen(const wxBitmap& stipple, int Width)
|
|||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool wxPen::operator==(const wxPen& pen) const
|
||||||
|
{
|
||||||
|
const wxPenRefData *penData = wx_static_cast(const wxPenRefData*, pen.m_refData);
|
||||||
|
|
||||||
|
// an invalid pen is only equal to another invalid pen
|
||||||
|
return m_refData ? penData && *M_PENDATA == *penData : !penData;
|
||||||
|
}
|
||||||
|
|
||||||
bool wxPen::RealizeResource()
|
bool wxPen::RealizeResource()
|
||||||
{
|
{
|
||||||
if ( !M_PENDATA || M_PENDATA->m_hPen )
|
if ( !M_PENDATA || M_PENDATA->m_hPen )
|
||||||
@@ -354,6 +398,64 @@ void wxPen::SetCap(int Cap)
|
|||||||
RealizeResource();
|
RealizeResource();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
wxColour& wxPen::GetColour() const
|
||||||
|
{
|
||||||
|
return m_refData ? M_PENDATA->m_colour : wxNullColour;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetWidth() const
|
||||||
|
{
|
||||||
|
return m_refData ? M_PENDATA->m_width : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetStyle() const
|
||||||
|
{
|
||||||
|
return m_refData ? M_PENDATA->m_style : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetJoin() const
|
||||||
|
{
|
||||||
|
return m_refData ? M_PENDATA->m_join : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetCap() const
|
||||||
|
{
|
||||||
|
return m_refData ? M_PENDATA->m_cap : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetDashes(wxDash** ptr) const
|
||||||
|
{
|
||||||
|
*ptr = NULL;
|
||||||
|
int count = 0;
|
||||||
|
if (m_refData)
|
||||||
|
{
|
||||||
|
*ptr = M_PENDATA->m_dash;
|
||||||
|
count = M_PENDATA->m_nbDash;
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxDash* wxPen::GetDash() const
|
||||||
|
{
|
||||||
|
wxDash* dash = NULL;
|
||||||
|
if (m_refData)
|
||||||
|
dash = M_PENDATA->m_dash;
|
||||||
|
return dash;
|
||||||
|
}
|
||||||
|
|
||||||
|
int wxPen::GetDashCount() const
|
||||||
|
{
|
||||||
|
return m_refData ? M_PENDATA->m_nbDash : 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
wxBitmap* wxPen::GetStipple() const
|
||||||
|
{
|
||||||
|
wxBitmap* bitmap = NULL;
|
||||||
|
if (m_refData)
|
||||||
|
bitmap = &M_PENDATA->m_stipple;
|
||||||
|
return bitmap;
|
||||||
|
}
|
||||||
|
|
||||||
int wx2msPenStyle(int wx_style)
|
int wx2msPenStyle(int wx_style)
|
||||||
{
|
{
|
||||||
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
|
#if !defined(__WXMICROWIN__) && !defined(__WXWINCE__)
|
||||||
|
Reference in New Issue
Block a user