]> git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/menu.h
Changed wxRectangle to wxRect. Sorry for the bandwidth...
[wxWidgets.git] / include / wx / gtk1 / menu.h
1 /////////////////////////////////////////////////////////////////////////////
2 // Name: menu.h
3 // Purpose:
4 // Author: Robert Roebling
5 // Id: $Id$
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
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"
22 #include "wx/menuitem.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 GtkWidget *m_menubar;
65 };
66
67 //-----------------------------------------------------------------------------
68 // wxMenu
69 //-----------------------------------------------------------------------------
70
71 class wxMenu: public wxEvtHandler
72 {
73 DECLARE_DYNAMIC_CLASS(wxMenu)
74
75 public:
76 // construction
77 wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL );
78
79 // operations
80 // title
81 void SetTitle(const wxString& label);
82 const wxString GetTitle() const;
83 // menu creation
84 void AppendSeparator();
85 void Append(int id, const wxString &item,
86 const wxString &helpStr = "", bool checkable = FALSE);
87 void Append(int id, const wxString &item,
88 wxMenu *subMenu, const wxString &helpStr = "" );
89 void Break() {};
90
91 // find item by name/id
92 int FindItem( const wxString itemString ) const;
93 wxMenuItem *FindItem( int id ) const;
94 wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); }
95
96 // get/set item's state
97 void Enable( int id, bool enable );
98 bool IsEnabled( int id ) const;
99 void Check( int id, bool check );
100 bool IsChecked( int id ) const;
101
102 void SetLabel( int id, const wxString &label );
103 wxString GetLabel(int id) const;
104
105 // helpstring
106 virtual void SetHelpString(int id, const wxString& helpString);
107 virtual wxString GetHelpString(int id) const ;
108
109 // accessors
110 wxList& GetItems() { return m_items; }
111
112 inline void Callback(const wxFunction func) { m_callback = func; }
113
114 inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
115 inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
116
117 inline void SetClientData( void* clientData ) { m_clientData = clientData; }
118 inline void* GetClientData() const { return m_clientData; }
119
120 // implementation
121
122 int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
123 void SetInvokingWindow( wxWindow *win );
124 wxWindow *GetInvokingWindow();
125
126 wxString m_title;
127 wxList m_items;
128 wxWindow *m_invokingWindow;
129 wxFunction m_callback;
130 wxEvtHandler *m_eventHandler;
131 void *m_clientData;
132
133 GtkWidget *m_menu; // GtkMenu
134 };
135
136 #endif // __GTKMENUH__