]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/menu.h
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
19 #include "wx/object.h"
21 #include "wx/window.h"
22 #include "wx/menuitem.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 #define ID_SEPARATOR (-1)
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 class wxMenuBar
: public wxWindow
44 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
49 wxMenuBar(long style
);
50 wxMenuBar(int n
, wxMenu
*menus
[], const wxString titles
[]);
52 // menubar construction
53 void Append( wxMenu
*menu
, const wxString
&title
);
56 // by menu and item names, returns wxNOT_FOUND if not found
57 virtual int FindMenuItem(const wxString
& menuString
,
58 const wxString
& itemString
) const;
59 // returns NULL if not found
60 wxMenuItem
* FindItem( int id
) const;
61 // returns NULL if not found, fills menuForItem if !NULL
62 wxMenuItem
*FindItemForId(int itemId
, wxMenu
**menuForItem
= NULL
) const;
65 void Check( int id
, bool check
);
66 bool IsChecked( int id
) const;
67 void Enable( int id
, bool enable
);
68 bool IsEnabled( int id
) const;
70 wxString
GetLabel( int id
) const;
71 void SetLabel( int id
, const wxString
&label
);
73 void EnableTop( int pos
, bool flag
);
74 void SetLabelTop( int pos
, const wxString
& label
);
75 wxString
GetLabelTop( int pos
) const;
77 virtual void SetHelpString( int id
, const wxString
& helpString
);
78 virtual wxString
GetHelpString( int id
) const;
80 int GetMenuCount() const { return m_menus
.Number(); }
81 wxMenu
*GetMenu( int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
83 #ifdef WXWIN_COMPATIBILITY
84 // compatibility: these functions are deprecated
85 bool Enabled(int id
) const { return IsEnabled(id
); }
86 bool Checked(int id
) const { return IsChecked(id
); }
88 wxMenuItem
* FindMenuItemById( int id
) const { return FindItem(id
); }
89 #endif // WXWIN_COMPATIBILITY
92 wxList
& GetMenus() { return m_menus
; }
99 //-----------------------------------------------------------------------------
101 //-----------------------------------------------------------------------------
103 class wxMenu
: public wxEvtHandler
105 DECLARE_DYNAMIC_CLASS(wxMenu
)
108 wxMenu( const wxString
& title
= wxEmptyString
,
109 const wxFunction func
= (wxFunction
) NULL
);
114 void SetTitle(const wxString
& label
);
115 const wxString
GetTitle() const;
117 void AppendSeparator();
118 void Append(int id
, const wxString
&item
,
119 const wxString
&helpStr
= "", bool checkable
= FALSE
);
120 void Append(int id
, const wxString
&item
,
121 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
122 void Append(wxMenuItem
*pItem
);
125 // find item by name/id
126 int FindItem( const wxString itemString
) const;
127 wxMenuItem
*FindItem( int id
) const;
129 // get/set item's state
130 void Enable( int id
, bool enable
);
131 bool IsEnabled( int id
) const;
132 void Check( int id
, bool check
);
133 bool IsChecked( int id
) const;
135 void SetLabel( int id
, const wxString
&label
);
136 wxString
GetLabel( int id
) const;
139 virtual void SetHelpString(int id
, const wxString
& helpString
);
140 virtual wxString
GetHelpString(int id
) const ;
143 wxList
& GetItems() { return m_items
; }
145 void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
146 wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
148 void SetClientData( void* clientData
) { m_clientData
= clientData
; }
149 void* GetClientData() const { return m_clientData
; }
151 // Updates the UI for a menu and all submenus recursively.
152 // source is the object that has the update event handlers
153 // defined for it. If NULL, the menu or associated window
155 void UpdateUI(wxEvtHandler
* source
= (wxEvtHandler
*) NULL
);
157 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
159 #ifdef WXWIN_COMPATIBILITY
160 wxFunction
GetCallback() const { return m_callback
; }
161 void Callback(const wxFunction func
) { m_callback
= func
; }
163 // compatibility: these functions are deprecated
164 bool Enabled(int id
) const { return IsEnabled(id
); }
165 bool Checked(int id
) const { return IsChecked(id
); }
166 #endif // WXWIN_COMPATIBILITY
169 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
170 void SetInvokingWindow( wxWindow
*win
);
171 wxWindow
*GetInvokingWindow();
173 // implementation only
174 GtkWidget
*m_menu
; // GtkMenu
177 GtkAccelGroup
*m_accel
;
178 GtkItemFactory
*m_factory
;
183 wxWindow
*m_invokingWindow
;
184 wxFunction m_callback
;
185 wxEvtHandler
*m_eventHandler
;
189 #endif // __GTKMENUH__