colour.h 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/cocoa/colour.h
  3. // Purpose: wxColour class
  4. // Author: David Elliott
  5. // Modified by:
  6. // Created: 2003/06/17
  7. // Copyright: (c) 2003 David Elliott
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef __WX_COCOA_COLOUR_H__
  11. #define __WX_COCOA_COLOUR_H__
  12. #include "wx/object.h"
  13. #include "wx/string.h"
  14. // ========================================================================
  15. // wxColour
  16. // ========================================================================
  17. class WXDLLIMPEXP_CORE wxColour : public wxColourBase
  18. {
  19. public:
  20. // constructors
  21. // ------------
  22. DEFINE_STD_WXCOLOUR_CONSTRUCTORS
  23. // initialization using existing NSColor
  24. wxColour( WX_NSColor aColor );
  25. // copy ctors and assignment operators
  26. wxColour( const wxColour& col );
  27. wxColour& operator = ( const wxColour& col );
  28. virtual ~wxColour();
  29. // accessors
  30. virtual bool IsOk() const { return m_cocoaNSColor; }
  31. WX_NSColor GetNSColor() { return m_cocoaNSColor; }
  32. WX_NSColor GetNSColor() const { return m_cocoaNSColor; }
  33. unsigned char Red() const { return m_red; }
  34. unsigned char Green() const { return m_green; }
  35. unsigned char Blue() const { return m_blue; }
  36. unsigned char Alpha() const { return m_alpha; }
  37. // comparison
  38. bool operator == (const wxColour& colour) const
  39. {
  40. return m_cocoaNSColor == colour.m_cocoaNSColor ||
  41. (m_red == colour.m_red &&
  42. m_green == colour.m_green &&
  43. m_blue == colour.m_blue &&
  44. m_alpha == colour.m_alpha);
  45. }
  46. bool operator != (const wxColour& colour) const
  47. { return !(*this == colour); }
  48. // Set() functions
  49. void Set( WX_NSColor aColor );
  50. // reroute the inherited ones
  51. void Set(unsigned char red,
  52. unsigned char green,
  53. unsigned char blue,
  54. unsigned char alpha = wxALPHA_OPAQUE)
  55. { wxColourBase::Set(red, green, blue, alpha); }
  56. bool Set(const wxString &str)
  57. { return wxColourBase::Set(str); }
  58. void Set(unsigned long colRGB)
  59. { wxColourBase::Set(colRGB); }
  60. protected:
  61. // puts the object in an invalid, uninitialized state
  62. void Init();
  63. virtual void
  64. InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
  65. private:
  66. WX_NSColor m_cocoaNSColor;
  67. unsigned char m_red;
  68. unsigned char m_green;
  69. unsigned char m_blue;
  70. unsigned char m_alpha;
  71. DECLARE_DYNAMIC_CLASS(wxColour)
  72. };
  73. #endif // __WX_COCOA_COLOUR_H__