X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/8f884a0dccd6b642f35c441ac9bfc87a6d5b4d35..4081eb6fe2de5eed5716459d09c8f4bed8eda92d:/src/msw/pen.cpp diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index 9df28c6731..ae66559cec 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -52,7 +52,7 @@ public: wxPenRefData(); wxPenRefData(const wxPenRefData& data); - wxPenRefData(const wxColour& col, int width, int style); + wxPenRefData(const wxColour& col, int width, wxPenStyle style); wxPenRefData(const wxBitmap& stipple, int width); virtual ~wxPenRefData(); @@ -64,8 +64,8 @@ public: 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_style != wxPENSTYLE_STIPPLE || m_stipple.IsSameAs(data.m_stipple)) && + (m_style != wxPENSTYLE_USER_DASH || (m_nbDash == data.m_nbDash && memcmp(m_dash, data.m_dash, m_nbDash*sizeof(wxDash)) == 0)); } @@ -76,21 +76,21 @@ public: wxColour& GetColour() const { return wx_const_cast(wxColour&, m_colour); } int GetWidth() const { return m_width; } - int GetStyle() const { return m_style; } - int GetJoin() const { return m_join; } - int GetCap() const { return m_cap; } + wxPenStyle GetStyle() const { return m_style; } + wxPenJoin GetJoin() const { return m_join; } + wxPenCap GetCap() const { return m_cap; } wxDash* GetDash() const { return m_dash; } int GetDashCount() const { return m_nbDash; } wxBitmap* GetStipple() const { return wx_const_cast(wxBitmap *, &m_stipple); } void SetColour(const wxColour& col) { Free(); m_colour = col; } void SetWidth(int width) { Free(); m_width = width; } - void SetStyle(int style) { Free(); m_style = style; } + void SetStyle(wxPenStyle style) { Free(); m_style = style; } void SetStipple(const wxBitmap& stipple) { Free(); - m_style = wxSTIPPLE; + m_style = wxPENSTYLE_STIPPLE; m_stipple = stipple; } @@ -102,8 +102,8 @@ public: m_dash = wx_const_cast(wxDash *, dash); } - void SetJoin(int join) { Free(); m_join = join; } - void SetCap(int cap) { Free(); m_cap = cap; } + void SetJoin(wxPenJoin join) { Free(); m_join = join; } + void SetCap(wxPenCap cap) { Free(); m_cap = cap; } // HPEN management @@ -135,9 +135,9 @@ private: } int m_width; - int m_style; - int m_join; - int m_cap; + wxPenStyle m_style; + wxPenJoin m_join; + wxPenCap m_cap; wxBitmap m_stipple; int m_nbDash; wxDash * m_dash; @@ -159,7 +159,7 @@ wxPenRefData::wxPenRefData() { Init(); - m_style = wxSOLID; + m_style = wxPENSTYLE_SOLID; m_width = 1; } @@ -176,7 +176,7 @@ wxPenRefData::wxPenRefData(const wxPenRefData& data) m_hPen = 0; } -wxPenRefData::wxPenRefData(const wxColour& col, int width, int style) +wxPenRefData::wxPenRefData(const wxColour& col, int width, wxPenStyle style) { Init(); @@ -190,7 +190,7 @@ wxPenRefData::wxPenRefData(const wxBitmap& stipple, int width) { Init(); - m_style = wxSTIPPLE; + m_style = wxPENSTYLE_STIPPLE; m_width = width; m_stipple = stipple; @@ -206,15 +206,15 @@ wxPenRefData::~wxPenRefData() // wxPenRefData HPEN management // ---------------------------------------------------------------------------- -static int ConvertPenStyle(int style) +static int ConvertPenStyle(wxPenStyle style) { switch ( style ) { - case wxSHORT_DASH: - case wxLONG_DASH: + case wxPENSTYLE_SHORT_DASH: + case wxPENSTYLE_LONG_DASH: return PS_DASH; - case wxTRANSPARENT: + case wxPENSTYLE_TRANSPARENT: return PS_NULL; default: @@ -222,23 +222,23 @@ static int ConvertPenStyle(int style) // fall through #ifdef wxHAVE_EXT_CREATE_PEN - case wxDOT: + case wxPENSTYLE_DOT: return PS_DOT; - case wxDOT_DASH: + case wxPENSTYLE_DOT_DASH: return PS_DASHDOT; - case wxUSER_DASH: + case wxPENSTYLE_USER_DASH: return PS_USERSTYLE; - case wxSTIPPLE: - case wxBDIAGONAL_HATCH: - case wxCROSSDIAG_HATCH: - case wxFDIAGONAL_HATCH: - case wxCROSS_HATCH: - case wxHORIZONTAL_HATCH: - case wxVERTICAL_HATCH: - case wxSOLID: + case wxPENSTYLE_STIPPLE: + case wxPENSTYLE_BDIAGONAL_HATCH: + case wxPENSTYLE_CROSSDIAG_HATCH: + case wxPENSTYLE_FDIAGONAL_HATCH: + case wxPENSTYLE_CROSS_HATCH: + case wxPENSTYLE_HORIZONTAL_HATCH: + case wxPENSTYLE_VERTICAL_HATCH: + case wxPENSTYLE_SOLID: #endif // wxHAVE_EXT_CREATE_PEN return PS_SOLID; @@ -247,7 +247,7 @@ static int ConvertPenStyle(int style) #ifdef wxHAVE_EXT_CREATE_PEN -static int ConvertJoinStyle(int join) +static int ConvertJoinStyle(wxPenJoin join) { switch( join ) { @@ -266,7 +266,7 @@ static int ConvertJoinStyle(int join) } } -static int ConvertCapStyle(int cap) +static int ConvertCapStyle(wxPenCap cap) { switch ( cap ) { @@ -292,7 +292,7 @@ bool wxPenRefData::Alloc() if ( m_hPen ) return false; - if ( m_style == wxTRANSPARENT ) + if ( m_style == wxPENSTYLE_TRANSPARENT ) { m_hPen = (HPEN)::GetStockObject(NULL_PEN); return true; @@ -304,11 +304,11 @@ bool wxPenRefData::Alloc() // Only NT can display dashed or dotted lines with width > 1 static const int os = wxGetOsVersion(); if ( os != wxOS_WINDOWS_NT && - (m_style == wxDOT || - m_style == wxLONG_DASH || - m_style == wxSHORT_DASH || - m_style == wxDOT_DASH || - m_style == wxUSER_DASH) && + (m_style == wxPENSTYLE_DOT || + m_style == wxPENSTYLE_LONG_DASH || + m_style == wxPENSTYLE_SHORT_DASH || + m_style == wxPENSTYLE_DOT_DASH || + m_style == wxPENSTYLE_USER_DASH) && m_width > 1 ) { m_width = 1; @@ -318,9 +318,9 @@ bool wxPenRefData::Alloc() // CreatePen() if ( m_join == wxJOIN_ROUND && m_cap == wxCAP_ROUND && - m_style != wxUSER_DASH && - m_style != wxSTIPPLE && - (m_width <= 1 || m_style == wxSOLID) ) + m_style != wxPENSTYLE_USER_DASH && + m_style != wxPENSTYLE_STIPPLE && + (m_width <= 1 || m_style == wxPENSTYLE_SOLID) ) #endif // !wxHAVE_EXT_CREATE_PEN { m_hPen = ::CreatePen(ConvertPenStyle(m_style), m_width, col); @@ -336,37 +336,37 @@ bool wxPenRefData::Alloc() LOGBRUSH lb; switch( m_style ) { - case wxSTIPPLE: + case wxPENSTYLE_STIPPLE: lb.lbStyle = BS_PATTERN; - lb.lbHatch = (LONG)m_stipple.GetHBITMAP(); + lb.lbHatch = wxPtrToUInt(m_stipple.GetHBITMAP()); break; - case wxBDIAGONAL_HATCH: + case wxPENSTYLE_BDIAGONAL_HATCH: lb.lbStyle = BS_HATCHED; lb.lbHatch = HS_BDIAGONAL; break; - case wxCROSSDIAG_HATCH: + case wxPENSTYLE_CROSSDIAG_HATCH: lb.lbStyle = BS_HATCHED; lb.lbHatch = HS_DIAGCROSS; break; - case wxFDIAGONAL_HATCH: + case wxPENSTYLE_FDIAGONAL_HATCH: lb.lbStyle = BS_HATCHED; lb.lbHatch = HS_FDIAGONAL; break; - case wxCROSS_HATCH: + case wxPENSTYLE_CROSS_HATCH: lb.lbStyle = BS_HATCHED; lb.lbHatch = HS_CROSS; break; - case wxHORIZONTAL_HATCH: + case wxPENSTYLE_HORIZONTAL_HATCH: lb.lbStyle = BS_HATCHED; lb.lbHatch = HS_HORIZONTAL; break; - case wxVERTICAL_HATCH: + case wxPENSTYLE_VERTICAL_HATCH: lb.lbStyle = BS_HATCHED; lb.lbHatch = HS_VERTICAL; break; @@ -384,7 +384,7 @@ bool wxPenRefData::Alloc() lb.lbColor = col; DWORD *dash; - if ( m_style == wxUSER_DASH && m_nbDash && m_dash ) + if ( m_style == wxPENSTYLE_USER_DASH && m_nbDash && m_dash ) { dash = new DWORD[m_nbDash]; int rw = m_width > 1 ? m_width : 1; @@ -430,11 +430,18 @@ WXHPEN wxPenRefData::GetHPEN() const IMPLEMENT_DYNAMIC_CLASS(wxPen, wxGDIObject) -wxPen::wxPen(const wxColour& col, int width, int style) +wxPen::wxPen(const wxColour& col, int width, wxPenStyle style) { m_refData = new wxPenRefData(col, width, style); } +#if FUTURE_WXWIN_COMPATIBILITY_3_0 +wxPen::wxPen(const wxColour& colour, int width, int style) +{ + m_refData = new wxPenRefData(colour, width, (wxPenStyle)style); +} +#endif + wxPen::wxPen(const wxBitmap& stipple, int width) { m_refData = new wxPenRefData(stipple, width); @@ -498,7 +505,7 @@ void wxPen::SetWidth(int width) M_PENDATA->SetWidth(width); } -void wxPen::SetStyle(int style) +void wxPen::SetStyle(wxPenStyle style) { AllocExclusive(); @@ -519,52 +526,58 @@ void wxPen::SetDashes(int nb_dashes, const wxDash *dash) M_PENDATA->SetDashes(nb_dashes, dash); } -void wxPen::SetJoin(int join) +void wxPen::SetJoin(wxPenJoin join) { AllocExclusive(); M_PENDATA->SetJoin(join); } -void wxPen::SetCap(int cap) +void wxPen::SetCap(wxPenCap cap) { AllocExclusive(); M_PENDATA->SetCap(cap); } -wxColour& wxPen::GetColour() const +wxColour wxPen::GetColour() const { - return m_refData ? M_PENDATA->GetColour() : wxNullColour; + wxCHECK_MSG( Ok(), wxNullColour, wxT("invalid pen") ); + + return M_PENDATA->GetColour(); } int wxPen::GetWidth() const { - return m_refData ? M_PENDATA->GetWidth() : 0; + wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); + + return M_PENDATA->GetWidth(); } -int wxPen::GetStyle() const +wxPenStyle wxPen::GetStyle() const { - return m_refData ? M_PENDATA->GetStyle() : 0; + wxCHECK_MSG( Ok(), wxPENSTYLE_INVALID, wxT("invalid pen") ); + + return M_PENDATA->GetStyle(); } -int wxPen::GetJoin() const +wxPenJoin wxPen::GetJoin() const { - return m_refData ? M_PENDATA->GetJoin() : 0; + wxCHECK_MSG( Ok(), wxJOIN_INVALID, wxT("invalid pen") ); + + return M_PENDATA->GetJoin(); } -int wxPen::GetCap() const +wxPenCap wxPen::GetCap() const { - return m_refData ? M_PENDATA->GetCap() : 0; + wxCHECK_MSG( Ok(), wxCAP_INVALID, wxT("invalid pen") ); + + return M_PENDATA->GetCap(); } int wxPen::GetDashes(wxDash** ptr) const { - if ( !m_refData ) - { - *ptr = NULL; - return 0; - } + wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); *ptr = M_PENDATA->GetDash(); return M_PENDATA->GetDashCount(); @@ -572,15 +585,21 @@ int wxPen::GetDashes(wxDash** ptr) const wxDash* wxPen::GetDash() const { + wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") ); + return m_refData ? M_PENDATA->GetDash() : NULL; } int wxPen::GetDashCount() const { + wxCHECK_MSG( Ok(), -1, wxT("invalid pen") ); + return m_refData ? M_PENDATA->GetDashCount() : 0; } wxBitmap* wxPen::GetStipple() const { + wxCHECK_MSG( Ok(), NULL, wxT("invalid pen") ); + return m_refData ? M_PENDATA->GetStipple() : NULL; }