]>
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"
23 //-----------------------------------------------------------------------------
25 //-----------------------------------------------------------------------------
31 //-----------------------------------------------------------------------------
33 //-----------------------------------------------------------------------------
35 #define ID_SEPARATOR (-1)
37 //-----------------------------------------------------------------------------
39 //-----------------------------------------------------------------------------
41 class wxMenuBar
: public wxWindow
43 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
47 void Append( wxMenu
*menu
, const wxString
&title
);
49 int FindMenuItem( const wxString
&menuString
, const wxString
&itemString
) const;
50 wxMenuItem
* FindMenuItemById( int id
) const;
52 void Check( int id
, bool check
);
53 bool Checked( int id
) const;
54 void Enable( int id
, bool enable
);
55 bool Enabled( int id
) const;
56 inline bool IsEnabled(int Id
) const { return Enabled(Id
); };
57 inline bool IsChecked(int Id
) const { return Checked(Id
); };
59 int GetMenuCount() const { return m_menus
.Number(); }
60 wxMenu
*GetMenu(int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
66 //-----------------------------------------------------------------------------
68 //-----------------------------------------------------------------------------
70 class wxMenuItem
: public wxObject
72 DECLARE_DYNAMIC_CLASS(wxMenuItem
)
79 void SetId(int id
) { m_id
= id
; }
80 int GetId() const { return m_id
; }
81 bool IsSeparator() const { return m_id
== ID_SEPARATOR
; }
84 void SetText(const wxString
& str
);
85 const wxString
& GetText() const { return m_text
; }
87 // what kind of menu item we are
88 void SetCheckable(bool checkable
) { m_isCheckMenu
= checkable
; }
89 bool IsCheckable() const { return m_isCheckMenu
; }
90 void SetSubMenu(wxMenu
*menu
) { m_subMenu
= menu
; }
91 wxMenu
*GetSubMenu() const { return m_subMenu
; }
92 bool IsSubMenu() const { return m_subMenu
!= NULL
; }
95 void Enable( bool enable
= TRUE
);
96 bool IsEnabled() const { return m_isEnabled
; }
97 void Check( bool check
= TRUE
);
98 bool IsChecked() const;
100 // help string (displayed in the status bar by default)
101 void SetHelp(const wxString
& str
) { m_helpStr
= str
; }
102 const wxString
& GetHelp() const { return m_helpStr
; }
105 void SetMenuItem(GtkWidget
*menuItem
) { m_menuItem
= menuItem
; }
106 GtkWidget
*GetMenuItem() const { return m_menuItem
; }
117 GtkWidget
*m_menuItem
; // GtkMenuItem
120 class wxMenu
: public wxEvtHandler
122 DECLARE_DYNAMIC_CLASS(wxMenu
)
126 wxMenu( const wxString
& title
= wxEmptyString
, const wxFunction func
= (wxFunction
) NULL
);
130 void SetTitle(const wxString
& label
);
131 const wxString
GetTitle() const;
133 void AppendSeparator();
134 void Append(int id
, const wxString
&item
,
135 const wxString
&helpStr
= "", bool checkable
= FALSE
);
136 void Append(int id
, const wxString
&item
,
137 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
140 // find item by name/id
141 int FindItem( const wxString itemString
) const;
142 wxMenuItem
*FindItem( int id
) const;
143 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
145 // get/set item's state
146 void Enable( int id
, bool enable
);
147 bool IsEnabled( int id
) const;
148 void Check( int id
, bool check
);
149 bool IsChecked( int id
) const;
151 void SetLabel( int id
, const wxString
&label
);
152 wxString
GetLabel(int id
) const;
155 virtual void SetHelpString(int id
, const wxString
& helpString
);
156 virtual wxString
GetHelpString(int id
) const ;
159 wxList
& GetItems() { return m_items
; }
161 inline void Callback(const wxFunction func
) { m_callback
= func
; }
163 inline void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
164 inline wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
167 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
168 void SetInvokingWindow( wxWindow
*win
);
169 wxWindow
*GetInvokingWindow();
173 wxWindow
*m_invokingWindow
;
174 wxFunction m_callback
;
175 wxEvtHandler
*m_eventHandler
;
177 GtkWidget
*m_menu
; // GtkMenu
180 #endif // __GTKMENUH__