]> git.saurik.com Git - wxWidgets.git/blame_incremental - include/wx/gtk/menu.h
Second try at doing Set/GetClient right
[wxWidgets.git] / include / wx / gtk / menu.h
... / ...
CommitLineData
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
28class wxMenuBar;
29class wxMenuItem;
30class wxMenu;
31
32//-----------------------------------------------------------------------------
33// const
34//-----------------------------------------------------------------------------
35
36#define ID_SEPARATOR (-1)
37
38//-----------------------------------------------------------------------------
39// wxMenuBar
40//-----------------------------------------------------------------------------
41
42class wxMenuBar: public wxWindow
43{
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 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
71class wxMenu: public wxEvtHandler
72{
73DECLARE_DYNAMIC_CLASS(wxMenu)
74
75public:
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
117public:
118 int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
119 void SetInvokingWindow( wxWindow *win );
120 wxWindow *GetInvokingWindow();
121
122 wxString m_title;
123 wxList m_items;
124 wxWindow *m_invokingWindow;
125 wxFunction m_callback;
126 wxEvtHandler *m_eventHandler;
127
128 GtkWidget *m_menu; // GtkMenu
129};
130
131#endif // __GTKMENUH__