From 8907a7e2c0fb61ecca0b6434dd69ee42b7ee1db6 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sat, 22 Mar 2008 03:13:18 +0000 Subject: [PATCH] add comparison operators for wxPen/BrushStyle and wxSOLID/... constants to avoid warnings in the existing code using such comparisons git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@52672 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- include/wx/brush.h | 23 +++++++++++++++++++++-- include/wx/defs.h | 3 ++- include/wx/pen.h | 23 +++++++++++++++++++++-- 3 files changed, 44 insertions(+), 5 deletions(-) diff --git a/include/wx/brush.h b/include/wx/brush.h index 08fc16b5ff..12fdaf2fac 100644 --- a/include/wx/brush.h +++ b/include/wx/brush.h @@ -96,5 +96,24 @@ public: extern WXDLLEXPORT_DATA(wxBrushList*) wxTheBrushList; -#endif - // _WX_BRUSH_H_BASE_ +// provide comparison operators to allow code such as +// +// if ( brush.GetStyle() == wxTRANSPARENT ) +// +// to compile without warnings which it would otherwise provoke from some +// compilers as it compares elements of different enums +#if FUTURE_WXWIN_COMPATIBILITY_3_0 + +inline bool operator==(wxBrushStyle s, wxDeprecatedGUIConstants t) +{ + return wx_static_cast(int, s) == wx_static_cast(int, t); +} + +inline bool operator!=(wxBrushStyle s, wxDeprecatedGUIConstants t) +{ + return !(s == t); +} + +#endif // FUTURE_WXWIN_COMPATIBILITY_3_0 + +#endif // _WX_BRUSH_H_BASE_ diff --git a/include/wx/defs.h b/include/wx/defs.h index 521ed775a3..cc8a15291e 100644 --- a/include/wx/defs.h +++ b/include/wx/defs.h @@ -2083,7 +2083,8 @@ enum wxHitTest /* GDI descriptions */ /* ---------------------------------------------------------------------------- */ -enum +/* don't use any elements of this enum in the new code */ +enum wxDeprecatedGUIConstants { /* Text font families */ wxDEFAULT = 70, diff --git a/include/wx/pen.h b/include/wx/pen.h index 49d75c5458..8b85a101ef 100644 --- a/include/wx/pen.h +++ b/include/wx/pen.h @@ -132,5 +132,24 @@ public: extern WXDLLEXPORT_DATA(wxPenList*) wxThePenList; -#endif - // _WX_PEN_H_BASE_ +// provide comparison operators to allow code such as +// +// if ( pen.GetStyle() == wxTRANSPARENT ) +// +// to compile without warnings which it would otherwise provoke from some +// compilers as it compares elements of different enums +#if FUTURE_WXWIN_COMPATIBILITY_3_0 + +inline bool operator==(wxPenStyle s, wxDeprecatedGUIConstants t) +{ + return wx_static_cast(int, s) == wx_static_cast(int, t); +} + +inline bool operator!=(wxPenStyle s, wxDeprecatedGUIConstants t) +{ + return !(s == t); +} + +#endif // FUTURE_WXWIN_COMPATIBILITY_3_0 + +#endif // _WX_PEN_H_BASE_ -- 2.45.2