checkbox.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. /////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/msw/checkbox.h
  3. // Purpose: wxCheckBox class
  4. // Author: Julian Smart
  5. // Modified by:
  6. // Created: 01/02/97
  7. // Copyright: (c) Julian Smart
  8. // Licence: wxWindows licence
  9. /////////////////////////////////////////////////////////////////////////////
  10. #ifndef _WX_CHECKBOX_H_
  11. #define _WX_CHECKBOX_H_
  12. // Checkbox item (single checkbox)
  13. class WXDLLIMPEXP_CORE wxCheckBox : public wxCheckBoxBase
  14. {
  15. public:
  16. wxCheckBox() { }
  17. wxCheckBox(wxWindow *parent,
  18. wxWindowID id,
  19. const wxString& label,
  20. const wxPoint& pos = wxDefaultPosition,
  21. const wxSize& size = wxDefaultSize,
  22. long style = 0,
  23. const wxValidator& validator = wxDefaultValidator,
  24. const wxString& name = wxCheckBoxNameStr)
  25. {
  26. Create(parent, id, label, pos, size, style, validator, name);
  27. }
  28. bool Create(wxWindow *parent,
  29. wxWindowID id,
  30. const wxString& label,
  31. const wxPoint& pos = wxDefaultPosition,
  32. const wxSize& size = wxDefaultSize,
  33. long style = 0,
  34. const wxValidator& validator = wxDefaultValidator,
  35. const wxString& name = wxCheckBoxNameStr);
  36. virtual void SetValue(bool value);
  37. virtual bool GetValue() const;
  38. // override some base class virtuals
  39. virtual void SetLabel(const wxString& label);
  40. virtual bool MSWCommand(WXUINT param, WXWORD id);
  41. virtual void Command(wxCommandEvent& event);
  42. virtual bool SetForegroundColour(const wxColour& colour);
  43. virtual bool MSWOnDraw(WXDRAWITEMSTRUCT *item);
  44. // returns true if the platform should explicitly apply a theme border
  45. virtual bool CanApplyThemeBorder() const { return false; }
  46. // make the checkbox owner drawn or reset it to normal style
  47. void MSWMakeOwnerDrawn(bool ownerDrawn);
  48. // implementation only from now on
  49. virtual WXDWORD MSWGetStyle(long flags, WXDWORD *exstyle = NULL) const;
  50. protected:
  51. virtual wxSize DoGetBestClientSize() const;
  52. virtual void DoSet3StateValue(wxCheckBoxState value);
  53. virtual wxCheckBoxState DoGet3StateValue() const;
  54. // return true if this checkbox is owner drawn
  55. bool IsOwnerDrawn() const;
  56. private:
  57. // common part of all ctors
  58. void Init();
  59. // event handlers used by owner-drawn checkbox
  60. void OnMouseEnterOrLeave(wxMouseEvent& event);
  61. void OnMouseLeft(wxMouseEvent& event);
  62. void OnFocus(wxFocusEvent& event);
  63. // current state of the checkbox
  64. wxCheckBoxState m_state;
  65. // true if the checkbox is currently pressed
  66. bool m_isPressed;
  67. // true if mouse is currently over the control
  68. bool m_isHot;
  69. DECLARE_DYNAMIC_CLASS_NO_COPY(wxCheckBox)
  70. };
  71. #endif
  72. // _WX_CHECKBOX_H_