colour.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/motif/colour.h
  3. // Purpose: wxColour class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 17/09/98
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_COLOUR_H_
  11. #define _WX_COLOUR_H_
  12. #include "wx/object.h"
  13. #include "wx/string.h"
  14. // Colour
  15. class WXDLLIMPEXP_CORE wxColour : public wxColourBase
  16. {
  17. DECLARE_DYNAMIC_CLASS(wxColour)
  18. public:
  19. // constructors
  20. // ------------
  21. DEFINE_STD_WXCOLOUR_CONSTRUCTORS
  22. // copy ctors and assignment operators
  23. wxColour( const wxColour& col );
  24. wxColour& operator = ( const wxColour& col );
  25. // dtor
  26. virtual ~wxColour();
  27. // accessors
  28. virtual bool IsOk() const {return m_isInit; }
  29. unsigned char Red() const { return m_red; }
  30. unsigned char Green() const { return m_green; }
  31. unsigned char Blue() const { return m_blue; }
  32. WXPixel GetPixel() const { return m_pixel; }
  33. void SetPixel(WXPixel pixel) { m_pixel = pixel; m_isInit = true; }
  34. inline bool operator == (const wxColour& colour) const { return (m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue); }
  35. inline bool operator != (const wxColour& colour) const { return (!(m_red == colour.m_red && m_green == colour.m_green && m_blue == colour.m_blue)); }
  36. // Allocate a colour, or nearest colour, using the given display.
  37. // If realloc is true, ignore the existing pixel, otherwise just return
  38. // the existing one.
  39. // Returns the allocated pixel.
  40. // TODO: can this handle mono displays? If not, we should have an extra
  41. // flag to specify whether this should be black or white by default.
  42. WXPixel AllocColour(WXDisplay* display, bool realloc = false);
  43. protected:
  44. // Helper function
  45. void Init();
  46. virtual void
  47. InitRGBA(unsigned char r, unsigned char g, unsigned char b, unsigned char a);
  48. private:
  49. bool m_isInit;
  50. unsigned char m_red;
  51. unsigned char m_blue;
  52. unsigned char m_green;
  53. public:
  54. WXPixel m_pixel;
  55. };
  56. #endif
  57. // _WX_COLOUR_H_