X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/cb129171c2653ca2202849e609cc41a6ddd0a9cb..96c9640205933ad0673d5af2c96af0816c50160c:/src/msw/pen.cpp diff --git a/src/msw/pen.cpp b/src/msw/pen.cpp index be20ac765d..518e4d91e0 100644 --- a/src/msw/pen.cpp +++ b/src/msw/pen.cpp @@ -74,14 +74,14 @@ public: // accessors and setters // --------------------- - wxColour& GetColour() const { return wx_const_cast(wxColour&, m_colour); } + wxColour& GetColour() const { return const_cast(m_colour); } int GetWidth() const { return m_width; } 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); } + wxBitmap* GetStipple() const { return const_cast(&m_stipple); } void SetColour(const wxColour& col) { Free(); m_colour = col; } void SetWidth(int width) { Free(); m_width = width; } @@ -99,7 +99,7 @@ public: Free(); m_nbDash = nb_dashes; - m_dash = wx_const_cast(wxDash *, dash); + m_dash = const_cast(dash); } void SetJoin(wxPenJoin join) { Free(); m_join = join; } @@ -144,7 +144,7 @@ private: wxColour m_colour; HPEN m_hPen; - DECLARE_NO_ASSIGN_CLASS(wxPenRefData) + wxDECLARE_NO_ASSIGN_CLASS(wxPenRefData); }; // ============================================================================ @@ -218,7 +218,7 @@ static int ConvertPenStyle(wxPenStyle style) return PS_NULL; default: - wxFAIL_MSG( _T("unknown pen style") ); + wxFAIL_MSG( wxT("unknown pen style") ); // fall through #ifdef wxHAVE_EXT_CREATE_PEN @@ -258,7 +258,7 @@ static int ConvertJoinStyle(wxPenJoin join) return PS_JOIN_MITER; default: - wxFAIL_MSG( _T("unknown pen join style") ); + wxFAIL_MSG( wxT("unknown pen join style") ); // fall through case wxJOIN_ROUND: @@ -277,7 +277,7 @@ static int ConvertCapStyle(wxPenCap cap) return PS_ENDCAP_FLAT; default: - wxFAIL_MSG( _T("unknown pen cap style") ); + wxFAIL_MSG( wxT("unknown pen cap style") ); // fall through case wxCAP_ROUND: @@ -373,11 +373,9 @@ bool wxPenRefData::Alloc() default: lb.lbStyle = BS_SOLID; -#ifdef __WXDEBUG__ // this should be unnecessary (it's unused) but suppresses the // Purify messages about uninitialized memory read lb.lbHatch = 0; -#endif break; } @@ -419,7 +417,7 @@ bool wxPenRefData::Free() WXHPEN wxPenRefData::GetHPEN() const { if ( !m_hPen ) - wx_const_cast(wxPenRefData *, this)->Alloc(); + const_cast(this)->Alloc(); return (WXHPEN)m_hPen; } @@ -435,12 +433,12 @@ wxPen::wxPen(const wxColour& col, int width, wxPenStyle style) m_refData = new wxPenRefData(col, width, style); } -/* error: `wxBrushStyle' has not been declared -wxPen::wxPen(const wxColour& colour, int width, wxBrushStyle 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) { @@ -450,7 +448,7 @@ wxPen::wxPen(const wxBitmap& stipple, int width) bool wxPen::operator==(const wxPen& pen) const { const wxPenRefData * - penData = wx_static_cast(const wxPenRefData *, pen.m_refData); + penData = static_cast(pen.m_refData); // an invalid pen is only equal to another invalid pen return m_refData ? penData && *M_PENDATA == *penData : !penData; @@ -483,7 +481,7 @@ wxGDIRefData* wxPen::CreateGDIRefData() const wxGDIRefData* wxPen::CloneGDIRefData(const wxGDIRefData* data) const { - return new wxPenRefData(*wx_static_cast(const wxPenRefData*, data)); + return new wxPenRefData(*static_cast(data)); } void wxPen::SetColour(const wxColour& col) @@ -540,38 +538,44 @@ void wxPen::SetCap(wxPenCap cap) M_PENDATA->SetCap(cap); } -wxColour& wxPen::GetColour() const +wxColour wxPen::GetColour() const { - return m_refData ? M_PENDATA->GetColour() : wxNullColour; + wxCHECK_MSG( IsOk(), wxNullColour, wxT("invalid pen") ); + + return M_PENDATA->GetColour(); } int wxPen::GetWidth() const { - return m_refData ? M_PENDATA->GetWidth() : 0; + wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") ); + + return M_PENDATA->GetWidth(); } wxPenStyle wxPen::GetStyle() const { - return m_refData ? M_PENDATA->GetStyle() : wxPENSTYLE_MAX; + wxCHECK_MSG( IsOk(), wxPENSTYLE_INVALID, wxT("invalid pen") ); + + return M_PENDATA->GetStyle(); } wxPenJoin wxPen::GetJoin() const { - return m_refData ? M_PENDATA->GetJoin() : wxJOIN_INVALID; + wxCHECK_MSG( IsOk(), wxJOIN_INVALID, wxT("invalid pen") ); + + return M_PENDATA->GetJoin(); } wxPenCap wxPen::GetCap() const { - return m_refData ? M_PENDATA->GetCap() : wxCAP_INVALID; + wxCHECK_MSG( IsOk(), wxCAP_INVALID, wxT("invalid pen") ); + + return M_PENDATA->GetCap(); } int wxPen::GetDashes(wxDash** ptr) const { - if ( !m_refData ) - { - *ptr = NULL; - return 0; - } + wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") ); *ptr = M_PENDATA->GetDash(); return M_PENDATA->GetDashCount(); @@ -579,15 +583,21 @@ int wxPen::GetDashes(wxDash** ptr) const wxDash* wxPen::GetDash() const { + wxCHECK_MSG( IsOk(), NULL, wxT("invalid pen") ); + return m_refData ? M_PENDATA->GetDash() : NULL; } int wxPen::GetDashCount() const { + wxCHECK_MSG( IsOk(), -1, wxT("invalid pen") ); + return m_refData ? M_PENDATA->GetDashCount() : 0; } wxBitmap* wxPen::GetStipple() const { + wxCHECK_MSG( IsOk(), NULL, wxT("invalid pen") ); + return m_refData ? M_PENDATA->GetStipple() : NULL; }