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