]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk/menu.h
fixed somebody's typo in a preprocessor directive (&6 --> &&)
[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;
342b6a2f 52 inline wxMenuItem* FindItemForId( int id ) const { return FindMenuItemById( id ); }
54ff4a70
RR
53
54 void Check( int id, bool check );
55 bool Checked( int id ) const;
56 void Enable( int id, bool enable );
57 bool Enabled( int id ) const;
342b6a2f
RR
58 inline bool IsEnabled( int id ) const { return Enabled(id); }
59 inline bool IsChecked( int id ) const { return Checked(id); }
bbe0af5b
RR
60
61 wxString GetLabel( int id ) const;
62 void SetLabel( int id, const wxString &label );
63
64 void EnableTop( int pos, bool flag );
65 void SetLabelTop( int pos, const wxString& label );
66 wxString GetLabelTop( int pos ) const;
83885a39 67
342b6a2f
RR
68 virtual void SetHelpString( int id, const wxString& helpString );
69 virtual wxString GetHelpString( int id ) const;
70
71 inline int GetMenuCount() const { return m_menus.Number(); }
72 inline wxMenu *GetMenu( int n ) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
83885a39 73
83885a39
VZ
74 wxList m_menus;
75 GtkWidget *m_menubar;
c801d85f
KB
76};
77
78//-----------------------------------------------------------------------------
79// wxMenu
80//-----------------------------------------------------------------------------
81
c801d85f
KB
82class wxMenu: public wxEvtHandler
83{
83885a39
VZ
84DECLARE_DYNAMIC_CLASS(wxMenu)
85
86public:
87 // construction
c67daf87 88 wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL );
83885a39
VZ
89
90 // operations
c2dd8380
GL
91 // title
92 void SetTitle(const wxString& label);
93 const wxString GetTitle() const;
83885a39
VZ
94 // menu creation
95 void AppendSeparator();
96 void Append(int id, const wxString &item,
97 const wxString &helpStr = "", bool checkable = FALSE);
98 void Append(int id, const wxString &item,
99 wxMenu *subMenu, const wxString &helpStr = "" );
100 void Break() {};
101
102 // find item by name/id
103 int FindItem( const wxString itemString ) const;
c33c4050
RR
104 wxMenuItem *FindItem( int id ) const;
105 wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); }
83885a39
VZ
106
107 // get/set item's state
108 void Enable( int id, bool enable );
109 bool IsEnabled( int id ) const;
110 void Check( int id, bool check );
111 bool IsChecked( int id ) const;
112
113 void SetLabel( int id, const wxString &label );
bbe0af5b 114 wxString GetLabel( int id ) const;
83885a39 115
c33c4050
RR
116 // helpstring
117 virtual void SetHelpString(int id, const wxString& helpString);
118 virtual wxString GetHelpString(int id) const ;
119
83885a39
VZ
120 // accessors
121 wxList& GetItems() { return m_items; }
122
6de97a3b
RR
123 inline void Callback(const wxFunction func) { m_callback = func; }
124
125 inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
126 inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
127
41dee9d0
RR
128 inline void SetClientData( void* clientData ) { m_clientData = clientData; }
129 inline void* GetClientData() const { return m_clientData; }
130
631f1bfe
JS
131 // Updates the UI for a menu and all submenus recursively.
132 // source is the object that has the update event handlers
133 // defined for it. If NULL, the menu or associated window
134 // will be used.
135 void UpdateUI(wxEvtHandler* source = (wxEvtHandler*) NULL);
136
41dee9d0
RR
137// implementation
138
83885a39
VZ
139 int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
140 void SetInvokingWindow( wxWindow *win );
141 wxWindow *GetInvokingWindow();
142
6de97a3b
RR
143 wxString m_title;
144 wxList m_items;
145 wxWindow *m_invokingWindow;
146 wxFunction m_callback;
147 wxEvtHandler *m_eventHandler;
41dee9d0 148 void *m_clientData;
83885a39 149
6de97a3b 150 GtkWidget *m_menu; // GtkMenu
2b1c162e 151 GtkWidget *m_owner;
c801d85f
KB
152};
153
154#endif // __GTKMENUH__