]>
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;
52 inline wxMenuItem
* FindItemForId( int id
) const
53 { return FindMenuItemById( id
); }
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;
59 inline bool IsEnabled(int Id
) const { return Enabled(Id
); };
60 inline bool IsChecked(int Id
) const { return Checked(Id
); };
62 int GetMenuCount() const { return m_menus
.Number(); }
63 wxMenu
*GetMenu(int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
69 //-----------------------------------------------------------------------------
71 //-----------------------------------------------------------------------------
73 class wxMenu
: public wxEvtHandler
75 DECLARE_DYNAMIC_CLASS(wxMenu
)
79 wxMenu( const wxString
& title
= wxEmptyString
, const wxFunction func
= (wxFunction
) NULL
);
83 void SetTitle(const wxString
& label
);
84 const wxString
GetTitle() const;
86 void AppendSeparator();
87 void Append(int id
, const wxString
&item
,
88 const wxString
&helpStr
= "", bool checkable
= FALSE
);
89 void Append(int id
, const wxString
&item
,
90 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
93 // find item by name/id
94 int FindItem( const wxString itemString
) const;
95 wxMenuItem
*FindItem( int id
) const;
96 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
98 // get/set item's state
99 void Enable( int id
, bool enable
);
100 bool IsEnabled( int id
) const;
101 void Check( int id
, bool check
);
102 bool IsChecked( int id
) const;
104 void SetLabel( int id
, const wxString
&label
);
105 wxString
GetLabel(int id
) const;
108 virtual void SetHelpString(int id
, const wxString
& helpString
);
109 virtual wxString
GetHelpString(int id
) const ;
112 wxList
& GetItems() { return m_items
; }
114 inline void Callback(const wxFunction func
) { m_callback
= func
; }
116 inline void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
117 inline wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
119 inline void SetClientData( void* clientData
) { m_clientData
= clientData
; }
120 inline void* GetClientData() const { return m_clientData
; }
124 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
125 void SetInvokingWindow( wxWindow
*win
);
126 wxWindow
*GetInvokingWindow();
130 wxWindow
*m_invokingWindow
;
131 wxFunction m_callback
;
132 wxEvtHandler
*m_eventHandler
;
135 GtkWidget
*m_menu
; // GtkMenu
138 #endif // __GTKMENUH__