]>
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
[]);
53 // menubar construction
54 void Append( wxMenu
*menu
, const wxString
&title
);
57 // by menu and item names, returns wxNOT_FOUND if not found
58 virtual int FindMenuItem(const wxString
& menuString
,
59 const wxString
& itemString
) const;
60 // returns NULL if not found
61 wxMenuItem
* FindItem( int id
) const;
62 // returns NULL if not found, fills menuForItem if !NULL
63 wxMenuItem
*FindItemForId(int itemId
, wxMenu
**menuForItem
= NULL
) const;
66 void Check( int id
, bool check
);
67 bool IsChecked( int id
) const;
68 void Enable( int id
, bool enable
);
69 bool IsEnabled( int id
) const;
71 wxString
GetLabel( int id
) const;
72 void SetLabel( int id
, const wxString
&label
);
74 void EnableTop( int pos
, bool flag
);
75 void SetLabelTop( int pos
, const wxString
& label
);
76 wxString
GetLabelTop( int pos
) const;
78 virtual void SetHelpString( int id
, const wxString
& helpString
);
79 virtual wxString
GetHelpString( int id
) const;
81 int GetMenuCount() const { return m_menus
.Number(); }
82 wxMenu
*GetMenu( int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
84 #ifdef WXWIN_COMPATIBILITY
85 // compatibility: these functions are deprecated
86 bool Enabled(int id
) const { return IsEnabled(id
); }
87 bool Checked(int id
) const { return IsChecked(id
); }
89 wxMenuItem
* FindMenuItemById( int id
) const { return FindItem(id
); }
90 #endif // WXWIN_COMPATIBILITY
92 // implementation only
93 wxList
& GetMenus() { return m_menus
; }
95 GtkAccelGroup
*m_accel
;
96 GtkItemFactory
*m_factory
;
100 GtkWidget
*m_menubar
;
103 //-----------------------------------------------------------------------------
105 //-----------------------------------------------------------------------------
107 class wxMenu
: public wxEvtHandler
109 DECLARE_DYNAMIC_CLASS(wxMenu
)
112 wxMenu( const wxString
& title
= wxEmptyString
,
113 const wxFunction func
= (wxFunction
) NULL
);
118 void SetTitle(const wxString
& label
);
119 const wxString
GetTitle() const;
121 void AppendSeparator();
122 void Append(int id
, const wxString
&item
,
123 const wxString
&helpStr
= "", bool checkable
= FALSE
);
124 void Append(int id
, const wxString
&item
,
125 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
126 void Append(wxMenuItem
*pItem
);
129 // find item by name/id
130 int FindItem( const wxString itemString
) const;
131 wxMenuItem
*FindItem( int id
) const;
133 // get/set item's state
134 void Enable( int id
, bool enable
);
135 bool IsEnabled( int id
) const;
136 void Check( int id
, bool check
);
137 bool IsChecked( int id
) const;
139 void SetLabel( int id
, const wxString
&label
);
140 wxString
GetLabel( int id
) const;
143 virtual void SetHelpString(int id
, const wxString
& helpString
);
144 virtual wxString
GetHelpString(int id
) const ;
147 wxList
& GetItems() { return m_items
; }
149 void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
150 wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
152 void SetClientData( void* clientData
) { m_clientData
= clientData
; }
153 void* GetClientData() const { return m_clientData
; }
155 // Updates the UI for a menu and all submenus recursively.
156 // source is the object that has the update event handlers
157 // defined for it. If NULL, the menu or associated window
159 void UpdateUI(wxEvtHandler
* source
= (wxEvtHandler
*) NULL
);
161 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
163 #ifdef WXWIN_COMPATIBILITY
164 wxFunction
GetCallback() const { return m_callback
; }
165 void Callback(const wxFunction func
) { m_callback
= func
; }
167 // compatibility: these functions are deprecated
168 bool Enabled(int id
) const { return IsEnabled(id
); }
169 bool Checked(int id
) const { return IsChecked(id
); }
170 #endif // WXWIN_COMPATIBILITY
173 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
174 void SetInvokingWindow( wxWindow
*win
);
175 wxWindow
*GetInvokingWindow();
177 // implementation GTK only
178 GtkWidget
*m_menu
; // GtkMenu
180 GtkAccelGroup
*m_accel
;
181 GtkItemFactory
*m_factory
;
187 wxWindow
*m_invokingWindow
;
188 wxFunction m_callback
;
189 wxEvtHandler
*m_eventHandler
;
193 #endif // __GTKMENUH__