]>
Commit | Line | Data |
---|---|---|
1 | /////////////////////////////////////////////////////////////////////////////// | |
2 | // Name: menuitem.h | |
3 | // Purpose: wxMenuItem class | |
4 | // Author: Vadim Zeitlin | |
5 | // Modified by: | |
6 | // Created: 11.11.97 | |
7 | // RCS-ID: $Id$ | |
8 | // Copyright: (c) 1998 Vadim Zeitlin <zeitlin@dptmaths.ens-cachan.fr> | |
9 | // Licence: wxWindows licence | |
10 | /////////////////////////////////////////////////////////////////////////////// | |
11 | ||
12 | #ifndef _MENUITEM_H | |
13 | #define _MENUITEM_H | |
14 | ||
15 | // ---------------------------------------------------------------------------- | |
16 | // headers | |
17 | // ---------------------------------------------------------------------------- | |
18 | ||
19 | #if wxUSE_OWNER_DRAWN | |
20 | #include "wx/ownerdrw.h" // base class | |
21 | #endif | |
22 | ||
23 | // ---------------------------------------------------------------------------- | |
24 | // wxMenuItem: an item in the menu, optionally implements owner-drawn behaviour | |
25 | // ---------------------------------------------------------------------------- | |
26 | ||
27 | class WXDLLEXPORT wxMenuItem : public wxMenuItemBase | |
28 | #if wxUSE_OWNER_DRAWN | |
29 | , public wxOwnerDrawn | |
30 | #endif | |
31 | { | |
32 | public: | |
33 | // ctor & dtor | |
34 | wxMenuItem(wxMenu *parentMenu = (wxMenu *)NULL, | |
35 | int id = wxID_SEPARATOR, | |
36 | const wxString& name = wxEmptyString, | |
37 | const wxString& help = wxEmptyString, | |
38 | wxItemKind kind = wxITEM_NORMAL, | |
39 | wxMenu *subMenu = (wxMenu *)NULL); | |
40 | virtual ~wxMenuItem(); | |
41 | ||
42 | // override base class virtuals | |
43 | virtual void SetItemLabel(const wxString& strName); | |
44 | virtual void SetCheckable(bool checkable); | |
45 | ||
46 | virtual void Enable(bool bDoEnable = true); | |
47 | virtual void Check(bool bDoCheck = true); | |
48 | virtual bool IsChecked() const; | |
49 | ||
50 | // unfortunately needed to resolve ambiguity between | |
51 | // wxMenuItemBase::IsCheckable() and wxOwnerDrawn::IsCheckable() | |
52 | bool IsCheckable() const { return wxMenuItemBase::IsCheckable(); } | |
53 | ||
54 | // the id for a popup menu is really its menu handle (as required by | |
55 | // ::AppendMenu() API), so this function will return either the id or the | |
56 | // menu handle depending on what we are | |
57 | // | |
58 | // notice that it also returns the id as an unsigned int, as required by | |
59 | // Win32 API | |
60 | WXWPARAM GetMSWId() const; | |
61 | ||
62 | // mark item as belonging to the given radio group | |
63 | void SetAsRadioGroupStart(); | |
64 | void SetRadioGroupStart(int start); | |
65 | void SetRadioGroupEnd(int end); | |
66 | ||
67 | // compatibility only, don't use in new code | |
68 | wxMenuItem(wxMenu *parentMenu, | |
69 | int id, | |
70 | const wxString& text, | |
71 | const wxString& help, | |
72 | bool isCheckable, | |
73 | wxMenu *subMenu = (wxMenu *)NULL); | |
74 | ||
75 | private: | |
76 | // common part of all ctors | |
77 | void Init(); | |
78 | ||
79 | // the positions of the first and last items of the radio group this item | |
80 | // belongs to or -1: start is the radio group start and is valid for all | |
81 | // but first radio group items (m_isRadioGroupStart == false), end is valid | |
82 | // only for the first one | |
83 | union | |
84 | { | |
85 | int start; | |
86 | int end; | |
87 | } m_radioGroup; | |
88 | ||
89 | // does this item start a radio group? | |
90 | bool m_isRadioGroupStart; | |
91 | ||
92 | DECLARE_DYNAMIC_CLASS_NO_COPY(wxMenuItem) | |
93 | }; | |
94 | ||
95 | #endif //_MENUITEM_H |