]> git.saurik.com Git - wxWidgets.git/blob - include/wx/menu.h
1. added encoding param to wxFontEncoding::EnumFamilies() which allows to get
[wxWidgets.git] / include / wx / menu.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: wx/menu.h
3 // Purpose: wxMenu and wxMenuBar classes
4 // Author: Vadim Zeitlin
5 // Modified by:
6 // Created: 26.10.99
7 // RCS-ID: $Id$
8 // Copyright: (c) wxWindows team
9 // Licence: wxWindows license
10 ///////////////////////////////////////////////////////////////////////////////
11
12 #ifndef _WX_MENU_H_BASE_
13 #define _WX_MENU_H_BASE_
14
15 #ifdef __GNUG__
16 #pragma interface "menubase.h"
17 #endif
18
19 // ----------------------------------------------------------------------------
20 // headers
21 // ----------------------------------------------------------------------------
22
23 #include "wx/list.h" // for wxMenuList
24 #include "wx/window.h" // base class for wxMenuBar
25
26 class WXDLLEXPORT wxMenu;
27 class WXDLLEXPORT wxMenuBar;
28 class WXDLLEXPORT wxMenuItem;
29
30 // ----------------------------------------------------------------------------
31 // wxMenu
32 // ----------------------------------------------------------------------------
33
34 // for now, it's in platform-specific file
35
36 WX_DECLARE_LIST(wxMenu, wxMenuList);
37
38 // ----------------------------------------------------------------------------
39 // wxMenuBar
40 // ----------------------------------------------------------------------------
41
42 class WXDLLEXPORT wxMenuBarBase : public wxWindow
43 {
44 public:
45 // default ctor
46 wxMenuBarBase();
47
48 // dtor will delete all menus we own
49 virtual ~wxMenuBarBase();
50
51 // menu bar construction
52 // ---------------------
53
54 // append a menu to the end of menubar, return TRUE if ok
55 virtual bool Append(wxMenu *menu, const wxString& title);
56
57 // insert a menu before the given position into the menubar, return TRUE
58 // if inserted ok
59 virtual bool Insert(size_t pos, wxMenu *menu, const wxString& title);
60
61 // menu bar items access
62 // ---------------------
63
64 // get the number of menus in the menu bar
65 size_t GetMenuCount() const { return m_menus.GetCount(); }
66
67 // get the menu at given position
68 wxMenu *GetMenu(size_t pos) const;
69
70 // replace the menu at given position with another one, returns the
71 // previous menu (which should be deleted by the caller)
72 virtual wxMenu *Replace(size_t pos, wxMenu *menu, const wxString& title);
73
74 // delete the menu at given position from the menu bar, return the pointer
75 // to the menu (which should be deleted by the caller)
76 virtual wxMenu *Remove(size_t pos);
77
78 // enable or disable a submenu
79 virtual void EnableTop(size_t pos, bool enable) = 0;
80
81 // get or change the label of the menu at given position
82 virtual void SetLabelTop(size_t pos, const wxString& label) = 0;
83 virtual wxString GetLabelTop(size_t pos) const = 0;
84
85 // item search
86 // -----------
87
88 // by menu and item names, returns wxNOT_FOUND if not found or id of the
89 // found item
90 virtual int FindMenuItem(const wxString& menuString,
91 const wxString& itemString) const = 0;
92
93 // find item by id (in any menu), returns NULL if not found
94 //
95 // if menu is !NULL, it will be filled with wxMenu this item belongs to
96 virtual wxMenuItem* FindItem(int id, wxMenu **menu = NULL) const = 0;
97
98 // item access
99 // -----------
100
101 // all these functions just use FindItem() and then call an appropriate
102 // method on it
103 //
104 // NB: under MSW, these methods can only be used after the menubar had
105 // been attached to the frame
106
107 void Enable(int id, bool enable);
108 void Check(int id, bool check);
109 bool IsChecked(int id) const;
110 bool IsEnabled(int id) const;
111
112 void SetLabel(int id, const wxString &label);
113 wxString GetLabel(int id) const;
114
115 void SetHelpString(int id, const wxString& helpString);
116 wxString GetHelpString(int id) const;
117
118 // need to override these ones to avoid virtual function hiding
119 virtual bool Enable(bool enable = TRUE) { return wxWindow::Enable(enable); }
120 virtual void SetLabel(const wxString& s) { wxWindow::SetLabel(s); }
121 virtual wxString GetLabel() const { return wxWindow::GetLabel(); }
122
123 // compatibility only: these functions are deprecated, use the new ones
124 // instead
125 #ifdef WXWIN_COMPATIBILITY
126 bool Enabled(int id) const { return IsEnabled(id); }
127 bool Checked(int id) const { return IsChecked(id); }
128
129 wxMenuItem* FindMenuItemById(int id) const
130 { return FindItem(id); }
131 wxMenuItem* FindItemForId(int id, wxMenu **menu = NULL) const
132 { return FindItem(id, menu); }
133 #endif // WXWIN_COMPATIBILITY
134
135 protected:
136 // the list of all our menus
137 wxMenuList m_menus;
138 };
139
140 // ----------------------------------------------------------------------------
141 // include the real class declaration
142 // ----------------------------------------------------------------------------
143
144 #ifdef wxUSE_BASE_CLASSES_ONLY
145 #define wxMenuItem wxMenuItemBase
146 #else // !wxUSE_BASE_CLASSES_ONLY
147 #if defined(__WXMSW__)
148 #include "wx/msw/menu.h"
149 #elif defined(__WXMOTIF__)
150 #include "wx/motif/menu.h"
151 #elif defined(__WXGTK__)
152 #include "wx/gtk/menu.h"
153 #elif defined(__WXQT__)
154 #include "wx/qt/menu.h"
155 #elif defined(__WXMAC__)
156 #include "wx/mac/menu.h"
157 #elif defined(__WXPM__)
158 #include "wx/os2/menu.h"
159 #elif defined(__WXSTUBS__)
160 #include "wx/stubs/menu.h"
161 #endif
162 #endif // wxUSE_BASE_CLASSES_ONLY/!wxUSE_BASE_CLASSES_ONLY
163
164 // also include this one to ensure compatibility with old code which only
165 // included wx/menu.h
166 #include "wx/menuitem.h"
167
168 #endif
169 // _WX_MENU_H_BASE_