]>
Commit | Line | Data |
---|---|---|
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 | ||
28 | class wxMenuBar; | |
29 | class wxMenuItem; | |
30 | class wxMenu; | |
31 | ||
e2414cbe RR |
32 | //----------------------------------------------------------------------------- |
33 | // const | |
34 | //----------------------------------------------------------------------------- | |
35 | ||
36 | #define ID_SEPARATOR (-1) | |
37 | ||
c801d85f KB |
38 | //----------------------------------------------------------------------------- |
39 | // wxMenuBar | |
40 | //----------------------------------------------------------------------------- | |
41 | ||
42 | class wxMenuBar: public wxWindow | |
43 | { | |
83885a39 VZ |
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; | |
54ff4a70 RR |
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); }; | |
83885a39 VZ |
59 | |
60 | int GetMenuCount() const { return m_menus.Number(); } | |
61 | wxMenu *GetMenu(int n) const { return (wxMenu *)m_menus.Nth(n)->Data(); } | |
62 | ||
83885a39 VZ |
63 | wxList m_menus; |
64 | GtkWidget *m_menubar; | |
c801d85f KB |
65 | }; |
66 | ||
67 | //----------------------------------------------------------------------------- | |
68 | // wxMenu | |
69 | //----------------------------------------------------------------------------- | |
70 | ||
c801d85f KB |
71 | class wxMenu: public wxEvtHandler |
72 | { | |
83885a39 VZ |
73 | DECLARE_DYNAMIC_CLASS(wxMenu) |
74 | ||
75 | public: | |
76 | // construction | |
c67daf87 | 77 | wxMenu( const wxString& title = wxEmptyString, const wxFunction func = (wxFunction) NULL ); |
83885a39 VZ |
78 | |
79 | // operations | |
c2dd8380 GL |
80 | // title |
81 | void SetTitle(const wxString& label); | |
82 | const wxString GetTitle() const; | |
83885a39 VZ |
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; | |
c33c4050 RR |
93 | wxMenuItem *FindItem( int id ) const; |
94 | wxMenuItem *FindItemForId( int id ) const { return FindItem( id ); } | |
83885a39 VZ |
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 ); | |
c33c4050 | 103 | wxString GetLabel(int id) const; |
83885a39 | 104 | |
c33c4050 RR |
105 | // helpstring |
106 | virtual void SetHelpString(int id, const wxString& helpString); | |
107 | virtual wxString GetHelpString(int id) const ; | |
108 | ||
83885a39 VZ |
109 | // accessors |
110 | wxList& GetItems() { return m_items; } | |
111 | ||
6de97a3b RR |
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 | ||
41dee9d0 RR |
117 | inline void SetClientData( void* clientData ) { m_clientData = clientData; } |
118 | inline void* GetClientData() const { return m_clientData; } | |
119 | ||
120 | // implementation | |
121 | ||
83885a39 VZ |
122 | int FindMenuIdByMenuItem( GtkWidget *menuItem ) const; |
123 | void SetInvokingWindow( wxWindow *win ); | |
124 | wxWindow *GetInvokingWindow(); | |
125 | ||
6de97a3b RR |
126 | wxString m_title; |
127 | wxList m_items; | |
128 | wxWindow *m_invokingWindow; | |
129 | wxFunction m_callback; | |
130 | wxEvtHandler *m_eventHandler; | |
41dee9d0 | 131 | void *m_clientData; |
83885a39 | 132 | |
6de97a3b | 133 | GtkWidget *m_menu; // GtkMenu |
c801d85f KB |
134 | }; |
135 | ||
136 | #endif // __GTKMENUH__ |