pen.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/pen.h
  3. // Purpose: Base header for wxPen
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created:
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows Licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_PEN_H_BASE_
  11. #define _WX_PEN_H_BASE_
  12. #include "wx/gdiobj.h"
  13. #include "wx/gdicmn.h"
  14. enum wxPenStyle
  15. {
  16. wxPENSTYLE_INVALID = -1,
  17. wxPENSTYLE_SOLID = wxSOLID,
  18. wxPENSTYLE_DOT = wxDOT,
  19. wxPENSTYLE_LONG_DASH = wxLONG_DASH,
  20. wxPENSTYLE_SHORT_DASH = wxSHORT_DASH,
  21. wxPENSTYLE_DOT_DASH = wxDOT_DASH,
  22. wxPENSTYLE_USER_DASH = wxUSER_DASH,
  23. wxPENSTYLE_TRANSPARENT = wxTRANSPARENT,
  24. wxPENSTYLE_STIPPLE_MASK_OPAQUE = wxSTIPPLE_MASK_OPAQUE,
  25. wxPENSTYLE_STIPPLE_MASK = wxSTIPPLE_MASK,
  26. wxPENSTYLE_STIPPLE = wxSTIPPLE,
  27. wxPENSTYLE_BDIAGONAL_HATCH = wxHATCHSTYLE_BDIAGONAL,
  28. wxPENSTYLE_CROSSDIAG_HATCH = wxHATCHSTYLE_CROSSDIAG,
  29. wxPENSTYLE_FDIAGONAL_HATCH = wxHATCHSTYLE_FDIAGONAL,
  30. wxPENSTYLE_CROSS_HATCH = wxHATCHSTYLE_CROSS,
  31. wxPENSTYLE_HORIZONTAL_HATCH = wxHATCHSTYLE_HORIZONTAL,
  32. wxPENSTYLE_VERTICAL_HATCH = wxHATCHSTYLE_VERTICAL,
  33. wxPENSTYLE_FIRST_HATCH = wxHATCHSTYLE_FIRST,
  34. wxPENSTYLE_LAST_HATCH = wxHATCHSTYLE_LAST
  35. };
  36. enum wxPenJoin
  37. {
  38. wxJOIN_INVALID = -1,
  39. wxJOIN_BEVEL = 120,
  40. wxJOIN_MITER,
  41. wxJOIN_ROUND
  42. };
  43. enum wxPenCap
  44. {
  45. wxCAP_INVALID = -1,
  46. wxCAP_ROUND = 130,
  47. wxCAP_PROJECTING,
  48. wxCAP_BUTT
  49. };
  50. class WXDLLIMPEXP_CORE wxPenBase : public wxGDIObject
  51. {
  52. public:
  53. virtual ~wxPenBase() { }
  54. virtual void SetColour(const wxColour& col) = 0;
  55. virtual void SetColour(unsigned char r, unsigned char g, unsigned char b) = 0;
  56. virtual void SetWidth(int width) = 0;
  57. virtual void SetStyle(wxPenStyle style) = 0;
  58. virtual void SetStipple(const wxBitmap& stipple) = 0;
  59. virtual void SetDashes(int nb_dashes, const wxDash *dash) = 0;
  60. virtual void SetJoin(wxPenJoin join) = 0;
  61. virtual void SetCap(wxPenCap cap) = 0;
  62. virtual wxColour GetColour() const = 0;
  63. virtual wxBitmap *GetStipple() const = 0;
  64. virtual wxPenStyle GetStyle() const = 0;
  65. virtual wxPenJoin GetJoin() const = 0;
  66. virtual wxPenCap GetCap() const = 0;
  67. virtual int GetWidth() const = 0;
  68. virtual int GetDashes(wxDash **ptr) const = 0;
  69. // Convenient helpers for testing whether the pen is a transparent one:
  70. // unlike GetStyle() == wxPENSTYLE_TRANSPARENT, they work correctly even if
  71. // the pen is invalid (they both return false in this case).
  72. bool IsTransparent() const
  73. {
  74. return IsOk() && GetStyle() == wxPENSTYLE_TRANSPARENT;
  75. }
  76. bool IsNonTransparent() const
  77. {
  78. return IsOk() && GetStyle() != wxPENSTYLE_TRANSPARENT;
  79. }
  80. };
  81. #if defined(__WXMSW__)
  82. #include "wx/msw/pen.h"
  83. #elif defined(__WXMOTIF__) || defined(__WXX11__)
  84. #include "wx/x11/pen.h"
  85. #elif defined(__WXGTK20__)
  86. #include "wx/gtk/pen.h"
  87. #elif defined(__WXGTK__)
  88. #include "wx/gtk1/pen.h"
  89. #elif defined(__WXDFB__)
  90. #include "wx/dfb/pen.h"
  91. #elif defined(__WXMAC__)
  92. #include "wx/osx/pen.h"
  93. #elif defined(__WXCOCOA__)
  94. #include "wx/cocoa/pen.h"
  95. #elif defined(__WXPM__)
  96. #include "wx/os2/pen.h"
  97. #endif
  98. class WXDLLIMPEXP_CORE wxPenList: public wxGDIObjListBase
  99. {
  100. public:
  101. wxPen *FindOrCreatePen(const wxColour& colour,
  102. int width = 1,
  103. wxPenStyle style = wxPENSTYLE_SOLID);
  104. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  105. wxPen *FindOrCreatePen(const wxColour& colour, int width, int style)
  106. { return FindOrCreatePen(colour, width, (wxPenStyle)style); }
  107. #endif
  108. #if WXWIN_COMPATIBILITY_2_6
  109. wxDEPRECATED( void AddPen(wxPen*) );
  110. wxDEPRECATED( void RemovePen(wxPen*) );
  111. #endif
  112. };
  113. extern WXDLLIMPEXP_DATA_CORE(wxPenList*) wxThePenList;
  114. // provide comparison operators to allow code such as
  115. //
  116. // if ( pen.GetStyle() == wxTRANSPARENT )
  117. //
  118. // to compile without warnings which it would otherwise provoke from some
  119. // compilers as it compares elements of different enums
  120. #if FUTURE_WXWIN_COMPATIBILITY_3_0
  121. // Unfortunately some compilers have ambiguity issues when enum comparisons are
  122. // overloaded so we have to disable the overloads in this case, see
  123. // wxCOMPILER_NO_OVERLOAD_ON_ENUM definition in wx/platform.h for more details.
  124. #ifndef wxCOMPILER_NO_OVERLOAD_ON_ENUM
  125. inline bool operator==(wxPenStyle s, wxDeprecatedGUIConstants t)
  126. {
  127. return static_cast<int>(s) == static_cast<int>(t);
  128. }
  129. inline bool operator!=(wxPenStyle s, wxDeprecatedGUIConstants t)
  130. {
  131. return !(s == t);
  132. }
  133. #endif // wxCOMPILER_NO_OVERLOAD_ON_ENUM
  134. #endif // FUTURE_WXWIN_COMPATIBILITY_3_0
  135. #endif // _WX_PEN_H_BASE_