brush.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/brush.h
  3. // Purpose: Includes platform-specific wxBrush file
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created:
  7. // Copyright: Julian Smart
  8. // Licence: wxWindows Licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_BRUSH_H_BASE_
  11. #define _WX_BRUSH_H_BASE_
  12. #include "wx/defs.h"
  13. #include "wx/object.h"
  14. #include "wx/gdiobj.h"
  15. #include "wx/gdicmn.h" // for wxGDIObjListBase
  16. // NOTE: these values cannot be combined together!
  17. enum wxBrushStyle
  18. {
  19. wxBRUSHSTYLE_INVALID = -1,
  20. wxBRUSHSTYLE_SOLID = wxSOLID,
  21. wxBRUSHSTYLE_TRANSPARENT = wxTRANSPARENT,
  22. wxBRUSHSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
  23. wxBRUSHSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
  24. wxBRUSHSTYLE_STIPPLE = wxSTIPPLE,
  25. wxBRUSHSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL,
  26. wxBRUSHSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG,
  27. wxBRUSHSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL,
  28. wxBRUSHSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS,
  29. wxBRUSHSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL,
  30. wxBRUSHSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL,
  31. wxBRUSHSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST,
  32. wxBRUSHSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST
  33. };
  34. // wxBrushBase
  35. class WXDLLIMPEXP_CORE wxBrushBase: public wxGDIObject
  36. {
  37. public:
  38. virtual ~wxBrushBase() { }
  39. virtual void SetColour(const wxColour& col) = 0;
  40. virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0;
  41. virtual void SetStyle(wxBrushStyle style) = 0;
  42. virtual void SetStipple(const wxBitmap& stipple) = 0;
  43. virtual wxColour GetColour() const = 0;
  44. virtual wxBrushStyle GetStyle() const = 0;
  45. virtual wxBitmap *GetStipple() const = 0;
  46. virtual bool IsHatch() const
  47. { return (GetStyle()>=wxBRUSHSTYLE_FIRST_HATCH) && (GetStyle()<=wxBRUSHSTYLE_LAST_HATCH); }
  48. // Convenient helpers for testing whether the brush is a transparent one:
  49. // unlike GetStyle() == wxBRUSHSTYLE_TRANSPARENT, they work correctly even
  50. // if the brush is invalid (they both return false in this case).
  51. bool IsTransparent() const
  52. {
  53. return IsOk() && GetStyle() == wxBRUSHSTYLE_TRANSPARENT;
  54. }
  55. bool IsNonTransparent() const
  56. {
  57. return IsOk() && GetStyle() != wxBRUSHSTYLE_TRANSPARENT;
  58. }
  59. };
  60. #if defined(__WXMSW__)
  61. #include "wx/msw/brush.h"
  62. #elif defined(__WXMOTIF__) || defined(__WXX11__)
  63. #include "wx/x11/brush.h"
  64. #elif defined(__WXGTK20__)
  65. #include "wx/gtk/brush.h"
  66. #elif defined(__WXGTK__)
  67. #include "wx/gtk1/brush.h"
  68. #elif defined(__WXDFB__)
  69. #include "wx/dfb/brush.h"
  70. #elif defined(__WXMAC__)
  71. #include "wx/osx/brush.h"
  72. #elif defined(__WXCOCOA__)
  73. #include "wx/cocoa/brush.h"
  74. #elif defined(__WXPM__)
  75. #include "wx/os2/brush.h"
  76. #endif
  77. class WXDLLIMPEXP_CORE wxBrushList: public wxGDIObjListBase
  78. {
  79. public:
  80. wxBrush *FindOrCreateBrush(const wxColour& colour,
  81. wxBrushStyle style = wxBRUSHSTYLE_SOLID);
  82. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  83. wxBrush *FindOrCreateBrush(const wxColour& colour, int style)
  84. { return FindOrCreateBrush(colour, (wxBrushStyle)style); }
  85. #endif
  86. #if WXWIN_COMPATIBILITY_2_6
  87. wxDEPRECATED( void AddBrush(wxBrush*) );
  88. wxDEPRECATED( void RemoveBrush(wxBrush*) );
  89. #endif
  90. };
  91. extern WXDLLIMPEXP_DATA_CORE(wxBrushList*) wxTheBrushList;
  92. // provide comparison operators to allow code such as
  93. //
  94. // if ( brush.GetStyle() == wxTRANSPARENT )
  95. //
  96. // to compile without warnings which it would otherwise provoke from some
  97. // compilers as it compares elements of different enums
  98. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  99. // Unfortunately some compilers have ambiguity issues when enum comparisons are
  100. // overloaded so we have to disable the overloads in this case, see
  101. // wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
  102. #ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
  103. inline bool operator==(wxBrushStyle s, wxDeprecatedGUIConstants t)
  104. {
  105. return static_cast<int>(s) == static_cast<int>(t);
  106. }
  107. inline bool operator!=(wxBrushStyle s, wxDeprecatedGUIConstants t)
  108. {
  109. return !(s == t);
  110. }
  111. #endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
  112. #endif // FUTURE_WXWIN_COMPATIBILITY_3_0
  113. #endif // _WX_BRUSH_H_BASE_