clrpickerg.h 2.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/generic/clrpickerg.h
  3. // Purpose: wxGenericColourButton header
  4. // Author: Francesco Montorsi (based on Vadim Zeitlin's code)
  5. // Modified by:
  6. // Created: 14/4/2006
  7. // Copyright: (c) Vadim Zeitlin, Francesco Montorsi
  8. // Licence: wxWindows Licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CLRPICKER_H_
  11. #define _WX_CLRPICKER_H_
  12. #include "wx/button.h"
  13. #include "wx/bmpbuttn.h"
  14. #include "wx/colourdata.h"
  15. //-----------------------------------------------------------------------------
  16. // wxGenericColourButton: a button which brings up a wxColourDialog
  17. //-----------------------------------------------------------------------------
  18. class WXDLLIMPEXP_CORE wxGenericColourButton : public wxBitmapButton,
  19. public wxColourPickerWidgetBase
  20. {
  21. public:
  22. wxGenericColourButton() {}
  23. wxGenericColourButton(wxWindow *parent,
  24. wxWindowID id,
  25. const wxColour& col = *wxBLACK,
  26. const wxPoint& pos = wxDefaultPosition,
  27. const wxSize& size = wxDefaultSize,
  28. long style = wxCLRBTN_DEFAULT_STYLE,
  29. const wxValidator& validator = wxDefaultValidator,
  30. const wxString& name = wxColourPickerWidgetNameStr)
  31. {
  32. Create(parent, id, col, pos, size, style, validator, name);
  33. }
  34. virtual ~wxGenericColourButton() {}
  35. public: // API extensions specific for wxGenericColourButton
  36. // user can override this to init colour data in a different way
  37. virtual void InitColourData();
  38. // returns the colour data shown in wxColourDialog
  39. wxColourData *GetColourData() { return &ms_data; }
  40. public:
  41. bool Create(wxWindow *parent,
  42. wxWindowID id,
  43. const wxColour& col = *wxBLACK,
  44. const wxPoint& pos = wxDefaultPosition,
  45. const wxSize& size = wxDefaultSize,
  46. long style = wxCLRBTN_DEFAULT_STYLE,
  47. const wxValidator& validator = wxDefaultValidator,
  48. const wxString& name = wxColourPickerWidgetNameStr);
  49. void OnButtonClick(wxCommandEvent &);
  50. protected:
  51. wxBitmap m_bitmap;
  52. wxSize DoGetBestSize() const;
  53. void UpdateColour();
  54. // the colour data shown in wxColourPickerCtrlGeneric
  55. // controls. This member is static so that all colour pickers
  56. // in the program share the same set of custom colours.
  57. static wxColourData ms_data;
  58. private:
  59. DECLARE_DYNAMIC_CLASS(wxGenericColourButton)
  60. };
  61. #endif // _WX_CLRPICKER_H_