menuitem.h 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // Name: wx/osx/menuitem.h
  3. // Purpose: wxMenuItem class
  4. // Author: Vadim Zeitlin
  5. // Modified by:
  6. // Created: 11.11.97
  7. // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr>
  8. // Licence: wxWindows licence
  9. ///////////////////////////////////////////////////////////////////////////////
  10. #ifndef _MENUITEM_H
  11. #define _MENUITEM_H
  12. // ----------------------------------------------------------------------------
  13. // headers
  14. // ----------------------------------------------------------------------------
  15. #include "wx/defs.h"
  16. #include "wx/bitmap.h"
  17. // ----------------------------------------------------------------------------
  18. // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour
  19. // ----------------------------------------------------------------------------
  20. class WXDLLIMPEXP_FWD_CORE wxMenuItemImpl ;
  21. class WXDLLIMPEXP_CORE wxMenuItem: public wxMenuItemBase
  22. {
  23. public:
  24. // ctor & dtor
  25. wxMenuItem(wxMenu *parentMenu = NULL,
  26. int id = wxID_SEPARATOR,
  27. const wxString& name = wxEmptyString,
  28. const wxString& help = wxEmptyString,
  29. wxItemKind kind = wxITEM_NORMAL,
  30. wxMenu *subMenu = NULL);
  31. virtual ~wxMenuItem();
  32. // override base class virtuals
  33. virtual void SetItemLabel(const wxString& strName);
  34. virtual void Enable(bool bDoEnable = true);
  35. virtual void Check(bool bDoCheck = true);
  36. virtual void SetBitmap(const wxBitmap& bitmap) ;
  37. virtual const wxBitmap& GetBitmap() const { return m_bitmap; }
  38. // Implementation only from now on.
  39. // update the os specific representation
  40. void UpdateItemBitmap() ;
  41. void UpdateItemText() ;
  42. void UpdateItemStatus() ;
  43. // mark item as belonging to the given radio group
  44. void SetAsRadioGroupStart(bool start = true);
  45. void SetRadioGroupStart(int start);
  46. void SetRadioGroupEnd(int end);
  47. // return true if this is the starting item of a radio group
  48. bool IsRadioGroupStart() const;
  49. // get the start of the radio group this item belongs to: should not be
  50. // called for the starting radio group item itself because it doesn't have
  51. // this information
  52. int GetRadioGroupStart() const;
  53. // get the end of the radio group this item belongs to: should be only
  54. // called for the starting radio group item, i.e. if IsRadioGroupStart() is
  55. // true
  56. int GetRadioGroupEnd() const;
  57. wxMenuItemImpl* GetPeer() { return m_peer; }
  58. private:
  59. void UncheckRadio() ;
  60. // the positions of the first and last items of the radio group this item
  61. // belongs to or -1: start is the radio group start and is valid for all
  62. // but first radio group items (m_isRadioGroupStart == FALSE), end is valid
  63. // only for the first one
  64. union
  65. {
  66. int start;
  67. int end;
  68. } m_radioGroup;
  69. // does this item start a radio group?
  70. bool m_isRadioGroupStart;
  71. wxBitmap m_bitmap; // Bitmap for menuitem, if any
  72. wxMenuItemImpl* m_peer;
  73. DECLARE_DYNAMIC_CLASS(wxMenuItem)
  74. };
  75. #endif //_MENUITEM_H