1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/univ/menuitem.h
3 // Purpose: wxMenuItem class for wxUniversal
4 // Author: Vadim Zeitlin
8 // Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
9 // Licence: wxWindows licence
10 ///////////////////////////////////////////////////////////////////////////////
12 #ifndef _WX_UNIV_MENUITEM_H_
13 #define _WX_UNIV_MENUITEM_H_
15 // ----------------------------------------------------------------------------
16 // wxMenuItem implements wxMenuItemBase
17 // ----------------------------------------------------------------------------
19 class WXDLLIMPEXP_CORE wxMenuItem
: public wxMenuItemBase
23 wxMenuItem(wxMenu
*parentMenu
= NULL
,
24 int id
= wxID_SEPARATOR
,
25 const wxString
& name
= wxEmptyString
,
26 const wxString
& help
= wxEmptyString
,
27 wxItemKind kind
= wxITEM_NORMAL
,
28 wxMenu
*subMenu
= NULL
);
29 virtual ~wxMenuItem();
31 // override base class virtuals to update the item appearance on screen
32 virtual void SetItemLabel(const wxString
& text
);
33 virtual void SetCheckable(bool checkable
);
35 virtual void Enable(bool enable
= true);
36 virtual void Check(bool check
= true);
38 // we add some extra functions which are also available under MSW from
39 // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
41 void SetBitmaps(const wxBitmap
& bmpChecked
,
42 const wxBitmap
& bmpUnchecked
= wxNullBitmap
);
43 void SetBitmap(const wxBitmap
& bmp
) { SetBitmaps(bmp
); }
44 const wxBitmap
& GetBitmap(bool checked
= true) const
45 { return checked
? m_bmpChecked
: m_bmpUnchecked
; }
47 void SetDisabledBitmap( const wxBitmap
& bmpDisabled
)
48 { m_bmpDisabled
= bmpDisabled
; }
49 const wxBitmap
& GetDisabledBitmap() const
50 { return m_bmpDisabled
; }
52 // mark item as belonging to the given radio group
53 void SetAsRadioGroupStart();
54 void SetRadioGroupStart(int start
);
55 void SetRadioGroupEnd(int end
);
57 // wxUniv-specific methods for implementation only starting from here
59 // get the accel index of our label or -1 if none
60 int GetAccelIndex() const { return m_indexAccel
; }
62 // get the accel string (displayed to the right of the label)
63 const wxString
& GetAccelString() const { return m_strAccel
; }
65 // set/get the y coord and the height of this item: note that it must be
66 // set first and retrieved later, the item doesn't calculate it itself
67 void SetGeometry(wxCoord y
, wxCoord height
)
73 wxCoord
GetPosition() const
75 wxASSERT_MSG( m_posY
!= wxDefaultCoord
, _T("must call SetHeight first!") );
80 wxCoord
GetHeight() const
82 wxASSERT_MSG( m_height
!= wxDefaultCoord
, _T("must call SetHeight first!") );
88 // notify the menu about the change in this item
89 inline void NotifyMenu();
91 // set the accel index and string from text
92 void UpdateAccelInfo();
94 // the bitmaps (may be invalid, then they're not used)
95 wxBitmap m_bmpChecked
,
99 // the positions of the first and last items of the radio group this item
100 // belongs to or -1: start is the radio group start and is valid for all
101 // but first radio group items (m_isRadioGroupStart == false), end is valid
102 // only for the first one
109 // does this item start a radio group?
110 bool m_isRadioGroupStart
;
112 // the position of the accelerator in our label, -1 if none
115 // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
118 // the position and height of the displayed item
123 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
126 #endif // _WX_UNIV_MENUITEM_H_