Review feedback
This commit is contained in:
committed by
Vadim Zeitlin
parent
2305604565
commit
999c750ca7
@@ -11,6 +11,7 @@
|
||||
#ifndef _WX_PEN_H_BASE_
|
||||
#define _WX_PEN_H_BASE_
|
||||
|
||||
#include "wx/bitmap.h"
|
||||
#include "wx/gdiobj.h"
|
||||
#include "wx/gdicmn.h"
|
||||
|
||||
@@ -63,73 +64,56 @@ enum wxPenCap
|
||||
// wxPenInfo describes a wxPen
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
class wxPenInfo
|
||||
template <class T>
|
||||
class wxPenInfoBase
|
||||
{
|
||||
public:
|
||||
wxPenInfo() :
|
||||
m_colour(wxNullColour)
|
||||
wxPenInfoBase(const wxColour& colour, wxPenStyle style)
|
||||
{
|
||||
Init();
|
||||
m_nb_dashes = 0;
|
||||
m_dash = NULL;
|
||||
m_join = wxJOIN_ROUND;
|
||||
m_cap = wxCAP_ROUND;
|
||||
|
||||
m_width = 1;
|
||||
m_style = wxPENSTYLE_SOLID;
|
||||
}
|
||||
|
||||
explicit wxPenInfo(const wxColour& colour, int width = 1, wxPenStyle style = wxPENSTYLE_SOLID) :
|
||||
m_colour((wxColour&) colour)
|
||||
{
|
||||
Init();
|
||||
|
||||
m_width = width;
|
||||
m_colour = colour;
|
||||
m_style = style;
|
||||
}
|
||||
|
||||
// Setters for the various attributes. All of them return the object itself
|
||||
// so that the calls to them could be chained.
|
||||
|
||||
wxPenInfo& Colour(const wxColour& colour)
|
||||
{ m_colour = colour; return *this; }
|
||||
T &Colour(const wxColour& colour)
|
||||
{ m_colour = colour; return static_cast<T&>(*this); }
|
||||
|
||||
wxPenInfo& Width(int width)
|
||||
{ m_width = width; return *this; }
|
||||
|
||||
wxPenInfo& Style(wxPenStyle style)
|
||||
{ m_style = style; return *this; }
|
||||
wxPenInfo& Stipple(const wxBitmap& stipple)
|
||||
{ m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return *this; }
|
||||
wxPenInfo& Dashes(int nb_dashes, const wxDash *dash)
|
||||
{ m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return *this; }
|
||||
wxPenInfo& Join(wxPenJoin join)
|
||||
{ m_join = join; return *this; }
|
||||
wxPenInfo& Cap(wxPenCap cap)
|
||||
{ m_cap = cap; return *this; }
|
||||
T &Style(wxPenStyle style)
|
||||
{ m_style = style; return static_cast<T&>(*this); }
|
||||
T &Stipple(const wxBitmap& stipple)
|
||||
{ m_stipple = stipple; m_style = wxPENSTYLE_STIPPLE; return static_cast<T&>(*this); }
|
||||
T &Dashes(int nb_dashes, const wxDash *dash)
|
||||
{ m_nb_dashes = nb_dashes; m_dash = (wxDash *)dash; return static_cast<T&>(*this); }
|
||||
T &Join(wxPenJoin join)
|
||||
{ m_join = join; return static_cast<T&>(*this); }
|
||||
T &Cap(wxPenCap cap)
|
||||
{ m_cap = cap; return static_cast<T&>(*this); }
|
||||
|
||||
// Accessors are mostly meant to be used by wxPen itself.
|
||||
|
||||
wxColour GetColour() const { return m_colour; }
|
||||
wxBitmap* GetStipple() { return &m_stipple; }
|
||||
wxBitmap GetStipple() const { return m_stipple; }
|
||||
wxPenStyle GetStyle() const { return m_style; }
|
||||
wxPenJoin GetJoin() const { return m_join; }
|
||||
wxPenCap GetCap() const { return m_cap; }
|
||||
int GetWidth() const { return m_width; }
|
||||
int GetDashes(wxDash **ptr) const { *ptr = m_dash; return m_nb_dashes; }
|
||||
|
||||
int GetDashCount() const { return m_nb_dashes; }
|
||||
wxDash* GetDash() const { return m_dash; }
|
||||
|
||||
// Convenience
|
||||
|
||||
bool IsTransparent() const { return m_style == wxPENSTYLE_TRANSPARENT; }
|
||||
|
||||
private:
|
||||
void Init()
|
||||
{
|
||||
m_stipple = wxNullBitmap;
|
||||
m_nb_dashes = 0;
|
||||
m_dash = NULL;
|
||||
m_join = wxJOIN_ROUND;
|
||||
m_cap = wxCAP_ROUND;
|
||||
}
|
||||
|
||||
wxColour& m_colour;
|
||||
int m_width;
|
||||
wxColour m_colour;
|
||||
wxBitmap m_stipple;
|
||||
wxPenStyle m_style;
|
||||
wxPenJoin m_join;
|
||||
@@ -139,6 +123,28 @@ private:
|
||||
wxDash* m_dash;
|
||||
};
|
||||
|
||||
class wxPenInfo : public wxPenInfoBase<wxPenInfo>
|
||||
{
|
||||
public:
|
||||
explicit wxPenInfo(const wxColour& colour = wxColour(), int width = 1, wxPenStyle style = wxPENSTYLE_SOLID)
|
||||
: wxPenInfoBase(colour, style)
|
||||
{
|
||||
m_width = width;
|
||||
}
|
||||
|
||||
// Setters
|
||||
|
||||
wxPenInfo& Width(int width)
|
||||
{ m_width = width; return *this; }
|
||||
|
||||
// Accessors
|
||||
|
||||
int GetWidth() const { return m_width; }
|
||||
|
||||
private:
|
||||
int m_width;
|
||||
};
|
||||
|
||||
|
||||
class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject
|
||||
{
|
||||
|
Reference in New Issue
Block a user