]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/menu.h
Added bitmaps and icons to samples
[wxWidgets.git] / include / wx / gtk1 / menu.h
CommitLineData
c801d85f
KB
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
83885a39 8// Licence: wxWindows licence
c801d85f
KB
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
28class wxMenuBar;
29class wxMenuItem;
30class wxMenu;
31
e2414cbe
RR
32//-----------------------------------------------------------------------------
33// const
34//-----------------------------------------------------------------------------
35
36#define ID_SEPARATOR (-1)
37
c801d85f
KB
38//-----------------------------------------------------------------------------
39// wxMenuBar
40//-----------------------------------------------------------------------------
41
42class wxMenuBar: public wxWindow
43{
83885a39
VZ
44DECLARE_DYNAMIC_CLASS(wxMenuBar)
45
46public:
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 int GetMenuCount() const { return m_menus.Number(); }
54 wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
55
56 bool IsChecked( int id ) const;
57 bool IsEnabled( int id ) const;
58
59 wxList m_menus;
60 GtkWidget *m_menubar;
c801d85f
KB
61};
62
63//-----------------------------------------------------------------------------
64// wxMenu
65//-----------------------------------------------------------------------------
66
67class wxMenuItem: public wxObject
68{
83885a39
VZ
69DECLARE_DYNAMIC_CLASS(wxMenuItem)
70
71public:
72 wxMenuItem();
73
74 // accessors
75 // id
76 void SetId(int id) { m_id = id; }
77 int GetId() const { return m_id; }
78 bool IsSeparator() const { return m_id == ID_SEPARATOR; }
79
80 // the item's text
81 void SetText(const wxString& str);
82 const wxString& GetText() const { return m_text; }
83
84 // what kind of menu item we are
85 void SetCheckable(bool checkable) { m_isCheckMenu = checkable; }
86 bool IsCheckable() const { return m_isCheckMenu; }
87 void SetSubMenu(wxMenu *menu) { m_subMenu = menu; }
88 wxMenu *GetSubMenu() const { return m_subMenu; }
89 bool IsSubMenu() const { return m_subMenu != NULL; }
90
91 // state
92 void Enable(bool enable = TRUE) { m_isEnabled = enable; }
93 bool IsEnabled() const { return m_isEnabled; }
94 void Check(bool check = TRUE);
95 bool IsChecked() const;
96
97 // help string (displayed in the status bar by default)
98 void SetHelpString(const wxString& str) { m_helpStr = str; }
99
100 // implementation
101 void SetMenuItem(GtkWidget *menuItem) { m_menuItem = menuItem; }
102 GtkWidget *GetMenuItem() const { return m_menuItem; }
103
104private:
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 GtkWidget *m_menuItem; // GtkMenuItem
c801d85f
KB
114};
115
116class wxMenu: public wxEvtHandler
117{
83885a39
VZ
118DECLARE_DYNAMIC_CLASS(wxMenu)
119
120public:
121 // construction
122 wxMenu( const wxString &title = "" );
123
124 // operations
125 // menu creation
126 void AppendSeparator();
127 void Append(int id, const wxString &item,
128 const wxString &helpStr = "", bool checkable = FALSE);
129 void Append(int id, const wxString &item,
130 wxMenu *subMenu, const wxString &helpStr = "" );
131 void Break() {};
132
133 // find item by name/id
134 int FindItem( const wxString itemString ) const;
135 wxMenuItem *FindItem(int id) const;
136
137 // get/set item's state
138 void Enable( int id, bool enable );
139 bool IsEnabled( int id ) const;
140 void Check( int id, bool check );
141 bool IsChecked( int id ) const;
142
143 void SetLabel( int id, const wxString &label );
144
145 // accessors
146 wxList& GetItems() { return m_items; }
147
148public:
149 int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
150 void SetInvokingWindow( wxWindow *win );
151 wxWindow *GetInvokingWindow();
152
153 wxString m_title;
154 wxList m_items;
155 wxWindow *m_invokingWindow;
156
157 GtkWidget *m_menu; // GtkMenu
c801d85f
KB
158};
159
160#endif // __GTKMENUH__