clrpicker.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: clrpicker.h
  3. // Purpose: interface of wxColourPickerCtrl
  4. // Author: wxWidgets team
  5. // Licence: wxWindows licence
  6. /////////////////////////////////////////////////////////////////////////////
  7. #define wxCLRP_USE_TEXTCTRL (wxPB_USE_TEXTCTRL)
  8. #define wxCLRP_DEFAULT_STYLE 0
  9. #define wxCLRP_SHOW_LABEL 0x0008
  10. wxEventType wxEVT_COLOURPICKER_CHANGED;
  11. /**
  12. @class wxColourPickerCtrl
  13. This control allows the user to select a colour. The generic implementation
  14. is a button which brings up a wxColourDialog when clicked. Native
  15. implementation may differ but this is usually a (small) widget which give
  16. access to the colour-chooser dialog. It is only available if
  17. @c wxUSE_COLOURPICKERCTRL is set to 1 (the default).
  18. @beginStyleTable
  19. @style{wxCLRP_DEFAULT_STYLE}
  20. The default style: 0.
  21. @style{wxCLRP_USE_TEXTCTRL}
  22. Creates a text control to the left of the picker button which is
  23. completely managed by the wxColourPickerCtrl and which can be used
  24. by the user to specify a colour (see SetColour). The text control
  25. is automatically synchronized with button's value. Use functions
  26. defined in wxPickerBase to modify the text control.
  27. @style{wxCLRP_SHOW_LABEL}
  28. Shows the colour in HTML form (AABBCC) as colour button label
  29. (instead of no label at all).
  30. @endStyleTable
  31. @beginEventEmissionTable{wxColourPickerEvent}
  32. @event{EVT_COLOURPICKER_CHANGED(id, func)}
  33. The user changed the colour selected in the control either using the
  34. button or using text control (see @c wxCLRP_USE_TEXTCTRL; note that
  35. in this case the event is fired only if the user’s input is valid,
  36. i.e. recognizable).
  37. @endEventTable
  38. @library{wxcore}
  39. @category{pickers}
  40. @appearance{colourpickerctrl}
  41. @see wxColourDialog, wxColourPickerEvent
  42. */
  43. class wxColourPickerCtrl : public wxPickerBase
  44. {
  45. public:
  46. wxColourPickerCtrl();
  47. /**
  48. Initializes the object and calls Create() with all the parameters.
  49. */
  50. wxColourPickerCtrl(wxWindow* parent, wxWindowID id,
  51. const wxColour& colour = *wxBLACK,
  52. const wxPoint& pos = wxDefaultPosition,
  53. const wxSize& size = wxDefaultSize,
  54. long style = wxCLRP_DEFAULT_STYLE,
  55. const wxValidator& validator = wxDefaultValidator,
  56. const wxString& name = wxColourPickerCtrlNameStr);
  57. /**
  58. Creates a colour picker with the given arguments.
  59. @param parent
  60. Parent window, must not be non-@NULL.
  61. @param id
  62. The identifier for the control.
  63. @param colour
  64. The initial colour shown in the control.
  65. @param pos
  66. Initial position.
  67. @param size
  68. Initial size.
  69. @param style
  70. The window style, see wxCRLP_* flags.
  71. @param validator
  72. Validator which can be used for additional date checks.
  73. @param name
  74. Control name.
  75. @return @true if the control was successfully created or @false if
  76. creation failed.
  77. */
  78. bool Create(wxWindow* parent, wxWindowID id,
  79. const wxColour& colour = *wxBLACK,
  80. const wxPoint& pos = wxDefaultPosition,
  81. const wxSize& size = wxDefaultSize,
  82. long style = wxCLRP_DEFAULT_STYLE,
  83. const wxValidator& validator = wxDefaultValidator,
  84. const wxString& name = wxColourPickerCtrlNameStr);
  85. /**
  86. Returns the currently selected colour.
  87. */
  88. wxColour GetColour() const;
  89. //@{
  90. /**
  91. Sets the currently selected colour. See wxColour::Set().
  92. */
  93. void SetColour(const wxColour& col);
  94. void SetColour(const wxString& colname);
  95. //@}
  96. };
  97. /**
  98. @class wxColourPickerEvent
  99. This event class is used for the events generated by wxColourPickerCtrl.
  100. @beginEventTable{wxColourPickerEvent}
  101. @event{EVT_COLOURPICKER_CHANGED(id, func)}
  102. Generated whenever the selected colour changes.
  103. @endEventTable
  104. @library{wxcore}
  105. @category{events}
  106. @see wxColourPickerCtrl
  107. */
  108. class wxColourPickerEvent : public wxCommandEvent
  109. {
  110. public:
  111. wxColourPickerEvent();
  112. /**
  113. The constructor is not normally used by the user code.
  114. */
  115. wxColourPickerEvent(wxObject* generator, int id,
  116. const wxColour& colour);
  117. /**
  118. Retrieve the colour the user has just selected.
  119. */
  120. wxColour GetColour() const;
  121. /**
  122. Set the colour associated with the event.
  123. */
  124. void SetColour(const wxColour& pos);
  125. };