]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/menu.h
all delete functions now send delete notification event
[wxWidgets.git] / include / wx / gtk / menu.h
CommitLineData
c801d85f
KB
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
3// Purpose:
4// Author: Robert Roebling
58614078
RR
5// Id: $Id$
6// Copyright: (c) 1998 Robert Roebling, Julian Smart
83885a39 7// Licence: wxWindows licence
c801d85f
KB
8/////////////////////////////////////////////////////////////////////////////
9
10
11#ifndef __GTKMENUH__
12#define __GTKMENUH__
13
14#ifdef __GNUG__
15#pragma interface
16#endif
17
18#include "wx/defs.h"
19#include "wx/object.h"
20#include "wx/list.h"
21#include "wx/window.h"
6ca41e57 22#include "wx/menuitem.h"
c801d85f
KB
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;
4f22cf8d
RR
52 inline wxMenuItem* FindMenuItemForId( int id ) const
53 { return FindMenuItemById( id ); }
54ff4a70
RR
54
55 void Check( int id, bool check );
56 bool Checked( int id ) const;
57 void Enable( int id, bool enable );
58 bool Enabled( int id ) const;
59 inline bool IsEnabled(int Id) const { return Enabled(Id); };
60 inline bool IsChecked(int Id) const { return Checked(Id); };
83885a39
VZ
61
62 int GetMenuCount() const { return m_menus.Number(); }
63 wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
64
83885a39
VZ
65 wxList m_menus;
66 GtkWidget *m_menubar;
c801d85f
KB
67};
68
69//-----------------------------------------------------------------------------
70// wxMenu
71//-----------------------------------------------------------------------------
72
c801d85f
KB
73class wxMenu: public wxEvtHandler
74{
83885a39
VZ
75DECLARE_DYNAMIC_CLASS(wxMenu)
76
77public:
78 // construction
c67daf87 79 wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL );
83885a39
VZ
80
81 // operations
c2dd8380
GL
82 // title
83 void SetTitle(const wxString& label);
84 const wxString GetTitle() const;
83885a39
VZ
85 // menu creation
86 void AppendSeparator();
87 void Append(int id, const wxString &item,
88 const wxString &helpStr = "", bool checkable = FALSE);
89 void Append(int id, const wxString &item,
90 wxMenu *subMenu, const wxString &helpStr = "" );
91 void Break() {};
92
93 // find item by name/id
94 int FindItem( const wxString itemString ) const;
c33c4050
RR
95 wxMenuItem *FindItem( int id ) const;
96 wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); }
83885a39
VZ
97
98 // get/set item's state
99 void Enable( int id, bool enable );
100 bool IsEnabled( int id ) const;
101 void Check( int id, bool check );
102 bool IsChecked( int id ) const;
103
104 void SetLabel( int id, const wxString &label );
c33c4050 105 wxString GetLabel(int id) const;
83885a39 106
c33c4050
RR
107 // helpstring
108 virtual void SetHelpString(int id, const wxString& helpString);
109 virtual wxString GetHelpString(int id) const ;
110
83885a39
VZ
111 // accessors
112 wxList& GetItems() { return m_items; }
113
6de97a3b
RR
114 inline void Callback(const wxFunction func) { m_callback = func; }
115
116 inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
117 inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
118
41dee9d0
RR
119 inline void SetClientData( void* clientData ) { m_clientData = clientData; }
120 inline void* GetClientData() const { return m_clientData; }
121
122// implementation
123
83885a39
VZ
124 int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
125 void SetInvokingWindow( wxWindow *win );
126 wxWindow *GetInvokingWindow();
127
6de97a3b
RR
128 wxString m_title;
129 wxList m_items;
130 wxWindow *m_invokingWindow;
131 wxFunction m_callback;
132 wxEvtHandler *m_eventHandler;
41dee9d0 133 void *m_clientData;
83885a39 134
6de97a3b 135 GtkWidget *m_menu; // GtkMenu
c801d85f
KB
136};
137
138#endif // __GTKMENUH__