]> git.saurik.com Git - wxWidgets.git/blame - include/wx/univ/menuitem.h
Fix wxPropertyGrid::GetPropertyRect when the last item is collapsed.
[wxWidgets.git] / include / wx / univ / menuitem.h
CommitLineData
1e6feb95
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/univ/menuitem.h
3// Purpose: wxMenuItem class for wxUniversal
4// Author: Vadim Zeitlin
5// Modified by:
6// Created: 05.05.01
442b35b5 7// Copyright: (c) 2001 SciTech Software, Inc. (www.scitechsoft.com)
65571936 8// Licence: wxWindows licence
1e6feb95
VZ
9///////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_UNIV_MENUITEM_H_
12#define _WX_UNIV_MENUITEM_H_
13
1e6feb95
VZ
14// ----------------------------------------------------------------------------
15// wxMenuItem implements wxMenuItemBase
16// ----------------------------------------------------------------------------
17
53a2db12 18class WXDLLIMPEXP_CORE wxMenuItem : public wxMenuItemBase
1e6feb95
VZ
19{
20public:
21 // ctor & dtor
d3b9f782 22 wxMenuItem(wxMenu *parentMenu = NULL,
1e6feb95
VZ
23 int id = wxID_SEPARATOR,
24 const wxString& name = wxEmptyString,
25 const wxString& help = wxEmptyString,
546bfbea 26 wxItemKind kind = wxITEM_NORMAL,
d3b9f782 27 wxMenu *subMenu = NULL);
1e6feb95
VZ
28 virtual ~wxMenuItem();
29
30 // override base class virtuals to update the item appearance on screen
52af3158 31 virtual void SetItemLabel(const wxString& text);
1e6feb95
VZ
32 virtual void SetCheckable(bool checkable);
33
a290fa5a
WS
34 virtual void Enable(bool enable = true);
35 virtual void Check(bool check = true);
1e6feb95
VZ
36
37 // we add some extra functions which are also available under MSW from
38 // wxOwnerDrawn class - they will be moved to wxMenuItemBase later
39 // hopefully
40 void SetBitmaps(const wxBitmap& bmpChecked,
41 const wxBitmap& bmpUnchecked = wxNullBitmap);
42 void SetBitmap(const wxBitmap& bmp) { SetBitmaps(bmp); }
a290fa5a 43 const wxBitmap& GetBitmap(bool checked = true) const
1e6feb95
VZ
44 { return checked ? m_bmpChecked : m_bmpUnchecked; }
45
dba6b4f8
JS
46 void SetDisabledBitmap( const wxBitmap& bmpDisabled )
47 { m_bmpDisabled = bmpDisabled; }
48 const wxBitmap& GetDisabledBitmap() const
49 { return m_bmpDisabled; }
50
6f7c5199
JS
51 // mark item as belonging to the given radio group
52 void SetAsRadioGroupStart();
53 void SetRadioGroupStart(int start);
54 void SetRadioGroupEnd(int end);
55
1e6feb95
VZ
56 // wxUniv-specific methods for implementation only starting from here
57
58 // get the accel index of our label or -1 if none
59 int GetAccelIndex() const { return m_indexAccel; }
60
61 // get the accel string (displayed to the right of the label)
62 const wxString& GetAccelString() const { return m_strAccel; }
63
64 // set/get the y coord and the height of this item: note that it must be
65 // set first and retrieved later, the item doesn't calculate it itself
66 void SetGeometry(wxCoord y, wxCoord height)
67 {
68 m_posY = y;
69 m_height = height;
70 }
71
72 wxCoord GetPosition() const
73 {
9a83f860 74 wxASSERT_MSG( m_posY != wxDefaultCoord, wxT("must call SetHeight first!") );
1e6feb95
VZ
75
76 return m_posY;
77 }
78
79 wxCoord GetHeight() const
80 {
9a83f860 81 wxASSERT_MSG( m_height != wxDefaultCoord, wxT("must call SetHeight first!") );
1e6feb95
VZ
82
83 return m_height;
84 }
85
86protected:
87 // notify the menu about the change in this item
88 inline void NotifyMenu();
89
90 // set the accel index and string from text
91 void UpdateAccelInfo();
92
93 // the bitmaps (may be invalid, then they're not used)
94 wxBitmap m_bmpChecked,
dba6b4f8 95 m_bmpUnchecked,
52af3158 96 m_bmpDisabled;
1e6feb95 97
6f7c5199
JS
98 // the positions of the first and last items of the radio group this item
99 // belongs to or -1: start is the radio group start and is valid for all
a290fa5a 100 // but first radio group items (m_isRadioGroupStart == false), end is valid
6f7c5199
JS
101 // only for the first one
102 union
103 {
104 int start;
105 int end;
106 } m_radioGroup;
107
108 // does this item start a radio group?
109 bool m_isRadioGroupStart;
110
1e6feb95
VZ
111 // the position of the accelerator in our label, -1 if none
112 int m_indexAccel;
113
114 // the accel string (i.e. "Ctrl-Q" or "Alt-F1")
115 wxString m_strAccel;
116
117 // the position and height of the displayed item
118 wxCoord m_posY,
119 m_height;
120
121private:
122 DECLARE_DYNAMIC_CLASS(wxMenuItem)
123};
124
125#endif // _WX_UNIV_MENUITEM_H_
126