]> git.saurik.com Git - wxWidgets.git/blob - include/wx/qt/menu.h
DP: native wxTreeCtrl for GTK.
[wxWidgets.git] / include / wx / qt / menu.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: menu.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Created: 01/02/97
6 // Id:
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
10
11
12 #ifndef __GTKMENUH__
13 #define __GTKMENUH__
14
15 #ifdef __GNUG__
16 #pragma interface
17 #endif
18
19 #include "wx/defs.h"
20 #include "wx/object.h"
21 #include "wx/list.h"
22 #include "wx/window.h"
23
24 //-----------------------------------------------------------------------------
25 // classes
26 //-----------------------------------------------------------------------------
27
28 class wxMenuBar;
29 class wxMenuItem;
30 class wxMenu;
31
32 //-----------------------------------------------------------------------------
33 // const
34 //-----------------------------------------------------------------------------
35
36 #define ID_SEPARATOR (-1)
37
38 //-----------------------------------------------------------------------------
39 // wxMenuBar
40 //-----------------------------------------------------------------------------
41
42 class wxMenuBar: public wxWindow
43 {
44 DECLARE_DYNAMIC_CLASS(wxMenuBar)
45
46 public:
47 wxMenuBar();
48 void Append( wxMenu *menu, const wxString &title );
49
50 int FindMenuItem( const wxString &menuString, const wxString &itemString ) const;
51 wxMenuItem* FindMenuItemById( int id ) const;
52
53 void Check( int id, bool check );
54 bool Checked( int id ) const;
55 void Enable( int id, bool enable );
56 bool Enabled( int id ) const;
57 inline bool IsEnabled(int Id) const { return Enabled(Id); };
58 inline bool IsChecked(int Id) const { return Checked(Id); };
59
60 int GetMenuCount() const { return m_menus.Number(); }
61 wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
62
63 wxList m_menus;
64 };
65
66 //-----------------------------------------------------------------------------
67 // wxMenu
68 //-----------------------------------------------------------------------------
69
70 class wxMenuItem: public wxObject
71 {
72 DECLARE_DYNAMIC_CLASS(wxMenuItem)
73
74 public:
75 wxMenuItem();
76
77 // accessors
78 // id
79 void SetId(int id) { m_id = id; }
80 int GetId() const { return m_id; }
81 bool IsSeparator() const { return m_id == ID_SEPARATOR; }
82
83 // the item's text
84 void SetText(const wxString& str);
85 const wxString& GetText() const { return m_text; }
86
87 // what kind of menu item we are
88 void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
89 bool IsCheckable() const { return m_isCheckMenu; }
90 void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
91 wxMenu *GetSubMenu() const { return m_subMenu; }
92 bool IsSubMenu() const { return m_subMenu != NULL; }
93
94 // state
95 void Enable(bool enable = TRUE) { m_isEnabled = enable; }
96 bool IsEnabled() const { return m_isEnabled; }
97 void Check(bool check = TRUE);
98 bool IsChecked() const;
99
100 // help string (displayed in the status bar by default)
101 void SetHelpString(const wxString& str) { m_helpStr = str; }
102
103
104 private:
105 int m_id;
106 wxString m_text;
107 bool m_isCheckMenu;
108 bool m_isChecked;
109 bool m_isEnabled;
110 wxMenu *m_subMenu;
111 wxString m_helpStr;
112 };
113
114 class wxMenu: public wxEvtHandler
115 {
116 DECLARE_DYNAMIC_CLASS(wxMenu)
117
118 public:
119 // construction
120 wxMenu( const wxString &title = "" );
121
122 // operations
123 // menu creation
124 void AppendSeparator();
125 void Append(int id, const wxString &item,
126 const wxString &helpStr = "", bool checkable = FALSE);
127 void Append(int id, const wxString &item,
128 wxMenu *subMenu, const wxString &helpStr = "" );
129 void Break() {};
130
131 // find item by name/id
132 int FindItem( const wxString itemString ) const;
133 wxMenuItem *FindItem(int id) const;
134
135 // get/set item's state
136 void Enable( int id, bool enable );
137 bool IsEnabled( int id ) const;
138 void Check( int id, bool check );
139 bool IsChecked( int id ) const;
140
141 void SetLabel( int id, const wxString &label );
142
143 // accessors
144 wxList& GetItems() { return m_items; }
145
146 public:
147 void SetInvokingWindow( wxWindow *win );
148 wxWindow *GetInvokingWindow();
149
150 wxString m_title;
151 wxList m_items;
152 wxWindow *m_invokingWindow;
153 };
154
155 #endif // __GTKMENUH__