]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/menu.h
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
7 // Copyright: (c) 1998 Robert Roebling, Julian Smart and Markus Holzem
8 // Licence: wxWindows licence
9 /////////////////////////////////////////////////////////////////////////////
20 #include "wx/object.h"
22 #include "wx/window.h"
24 //-----------------------------------------------------------------------------
26 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
34 //-----------------------------------------------------------------------------
36 #define ID_SEPARATOR (-1)
38 //-----------------------------------------------------------------------------
40 //-----------------------------------------------------------------------------
42 class wxMenuBar
: public wxWindow
44 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
48 void Append( wxMenu
*menu
, const wxString
&title
);
50 int FindMenuItem( const wxString
&menuString
, const wxString
&itemString
) const;
51 wxMenuItem
* FindMenuItemById( int id
) const;
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
); };
60 int GetMenuCount() const { return m_menus
.Number(); }
61 wxMenu
*GetMenu(int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
67 //-----------------------------------------------------------------------------
69 //-----------------------------------------------------------------------------
71 class wxMenuItem
: public wxObject
73 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
80 void SetId(int id
) { m_id
= id
; }
81 int GetId() const { return m_id
; }
82 bool IsSeparator() const { return m_id
== ID_SEPARATOR
; }
85 void SetText(const wxString
& str
);
86 const wxString
& GetText() const { return m_text
; }
88 // what kind of menu item we are
89 void SetCheckable(bool checkable
) { m_isCheckMenu
= checkable
; }
90 bool IsCheckable() const { return m_isCheckMenu
; }
91 void SetSubMenu(wxMenu
*menu
) { m_subMenu
= menu
; }
92 wxMenu
*GetSubMenu() const { return m_subMenu
; }
93 bool IsSubMenu() const { return m_subMenu
!= NULL
; }
96 void Enable( bool enable
= TRUE
);
97 bool IsEnabled() const { return m_isEnabled
; }
98 void Check( bool check
= TRUE
);
99 bool IsChecked() const;
101 // help string (displayed in the status bar by default)
102 void SetHelp(const wxString
& str
) { m_helpStr
= str
; }
103 const wxString
& GetHelp() const { return m_helpStr
; }
106 void SetMenuItem(GtkWidget
*menuItem
) { m_menuItem
= menuItem
; }
107 GtkWidget
*GetMenuItem() const { return m_menuItem
; }
118 GtkWidget
*m_menuItem
; // GtkMenuItem
121 class wxMenu
: public wxEvtHandler
123 DECLARE_DYNAMIC_CLASS(wxMenu
)
127 wxMenu( const wxString
& title
= wxEmptyString
, const wxFunction func
= NULL
);
131 void AppendSeparator();
132 void Append(int id
, const wxString
&item
,
133 const wxString
&helpStr
= "", bool checkable
= FALSE
);
134 void Append(int id
, const wxString
&item
,
135 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
138 // find item by name/id
139 int FindItem( const wxString itemString
) const;
140 wxMenuItem
*FindItem( int id
) const;
141 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
143 // get/set item's state
144 void Enable( int id
, bool enable
);
145 bool IsEnabled( int id
) const;
146 void Check( int id
, bool check
);
147 bool IsChecked( int id
) const;
149 void SetLabel( int id
, const wxString
&label
);
150 wxString
GetLabel(int id
) const;
153 virtual void SetHelpString(int id
, const wxString
& helpString
);
154 virtual wxString
GetHelpString(int id
) const ;
157 wxList
& GetItems() { return m_items
; }
159 inline void Callback(const wxFunction func
) { m_callback
= func
; }
161 inline void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
162 inline wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
165 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
166 void SetInvokingWindow( wxWindow
*win
);
167 wxWindow
*GetInvokingWindow();
171 wxWindow
*m_invokingWindow
;
172 wxFunction m_callback
;
173 wxEvtHandler
*m_eventHandler
;
175 GtkWidget
*m_menu
; // GtkMenu
178 #endif // __GTKMENUH__