]> git.saurik.com Git - wxWidgets.git/blame - include/wx/gtk1/menu.h
New DnD and Clipboard code
[wxWidgets.git] / include / wx / gtk1 / 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;
aeeb6a44 52 inline wxMenuItem* FindItemForId( int id ) const
4f22cf8d 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;
2b1c162e
RR
59 inline bool IsEnabled(int Id) const { return Enabled(Id); }
60 inline bool IsChecked(int Id) const { return Checked(Id); }
bbe0af5b
RR
61
62 wxString GetLabel( int id ) const;
63 void SetLabel( int id, const wxString &label );
64
65 void EnableTop( int pos, bool flag );
66 void SetLabelTop( int pos, const wxString& label );
67 wxString GetLabelTop( int pos ) const;
83885a39
VZ
68
69 int GetMenuCount() const { return m_menus.Number(); }
70 wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); }
71
83885a39
VZ
72 wxList m_menus;
73 GtkWidget *m_menubar;
c801d85f
KB
74};
75
76//-----------------------------------------------------------------------------
77// wxMenu
78//-----------------------------------------------------------------------------
79
c801d85f
KB
80class wxMenu: public wxEvtHandler
81{
83885a39
VZ
82DECLARE_DYNAMIC_CLASS(wxMenu)
83
84public:
85 // construction
c67daf87 86 wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL );
83885a39
VZ
87
88 // operations
c2dd8380
GL
89 // title
90 void SetTitle(const wxString& label);
91 const wxString GetTitle() const;
83885a39
VZ
92 // menu creation
93 void AppendSeparator();
94 void Append(int id, const wxString &item,
95 const wxString &helpStr = "", bool checkable = FALSE);
96 void Append(int id, const wxString &item,
97 wxMenu *subMenu, const wxString &helpStr = "" );
98 void Break() {};
99
100 // find item by name/id
101 int FindItem( const wxString itemString ) const;
c33c4050
RR
102 wxMenuItem *FindItem( int id ) const;
103 wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); }
83885a39
VZ
104
105 // get/set item's state
106 void Enable( int id, bool enable );
107 bool IsEnabled( int id ) const;
108 void Check( int id, bool check );
109 bool IsChecked( int id ) const;
110
111 void SetLabel( int id, const wxString &label );
bbe0af5b 112 wxString GetLabel( int id ) const;
83885a39 113
c33c4050
RR
114 // helpstring
115 virtual void SetHelpString(int id, const wxString& helpString);
116 virtual wxString GetHelpString(int id) const ;
117
83885a39
VZ
118 // accessors
119 wxList& GetItems() { return m_items; }
120
6de97a3b
RR
121 inline void Callback(const wxFunction func) { m_callback = func; }
122
123 inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
124 inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
125
41dee9d0
RR
126 inline void SetClientData( void* clientData ) { m_clientData = clientData; }
127 inline void* GetClientData() const { return m_clientData; }
128
129// implementation
130
83885a39
VZ
131 int FindMenuIdByMenuItem( GtkWidget *menuItem ) const;
132 void SetInvokingWindow( wxWindow *win );
133 wxWindow *GetInvokingWindow();
134
6de97a3b
RR
135 wxString m_title;
136 wxList m_items;
137 wxWindow *m_invokingWindow;
138 wxFunction m_callback;
139 wxEvtHandler *m_eventHandler;
41dee9d0 140 void *m_clientData;
83885a39 141
6de97a3b 142 GtkWidget *m_menu; // GtkMenu
2b1c162e 143 GtkWidget *m_owner;
c801d85f
KB
144};
145
146#endif // __GTKMENUH__