]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/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
)
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 wxMenu
: public wxEvtHandler
73 DECLARE_DYNAMIC_CLASS(wxMenu
)
77 wxMenu( const wxString
& title
= wxEmptyString
, const wxFunction func
= (wxFunction
) NULL
);
81 void SetTitle(const wxString
& label
);
82 const wxString
GetTitle() const;
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
= "" );
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
); }
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;
102 void SetLabel( int id
, const wxString
&label
);
103 wxString
GetLabel(int id
) const;
106 virtual void SetHelpString(int id
, const wxString
& helpString
);
107 virtual wxString
GetHelpString(int id
) const ;
110 wxList
& GetItems() { return m_items
; }
112 inline void Callback(const wxFunction func
) { m_callback
= func
; }
114 inline void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
115 inline wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
117 inline void SetClientData( void* clientData
) { m_clientData
= clientData
; }
118 inline void* GetClientData() const { return m_clientData
; }
122 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
123 void SetInvokingWindow( wxWindow
*win
);
124 wxWindow
*GetInvokingWindow();
128 wxWindow
*m_invokingWindow
;
129 wxFunction m_callback
;
130 wxEvtHandler
*m_eventHandler
;
133 GtkWidget
*m_menu
; // GtkMenu
136 #endif // __GTKMENUH__