]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/menu.h
b51e7e5230e353f4f44829de1b0737fe2e68e81c
1 /////////////////////////////////////////////////////////////////////////////
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Robert Roebling, Julian Smart
7 // Licence: wxWindows licence
8 /////////////////////////////////////////////////////////////////////////////
14 #pragma interface "menu.h"
17 //-----------------------------------------------------------------------------
19 //-----------------------------------------------------------------------------
21 class wxMenuBar
: public wxMenuBarBase
26 wxMenuBar(long style
);
27 wxMenuBar(int n
, wxMenu
*menus
[], const wxString titles
[]);
30 // implement base class (pure) virtuals
31 virtual bool Append( wxMenu
*menu
, const wxString
&title
);
32 virtual bool Insert(size_t pos
, wxMenu
*menu
, const wxString
& title
);
33 virtual wxMenu
*Replace(size_t pos
, wxMenu
*menu
, const wxString
& title
);
34 virtual wxMenu
*Remove(size_t pos
);
36 virtual int FindMenuItem(const wxString
& menuString
,
37 const wxString
& itemString
) const;
38 virtual wxMenuItem
* FindItem( int id
, wxMenu
**menu
= NULL
) const;
40 virtual void EnableTop( size_t pos
, bool flag
);
41 virtual void SetLabelTop( size_t pos
, const wxString
& label
);
42 virtual wxString
GetLabelTop( size_t pos
) const;
44 // implementation only from now on
45 void SetInvokingWindow( wxWindow
*win
);
46 void UnsetInvokingWindow( wxWindow
*win
);
48 GtkAccelGroup
*m_accel
;
49 GtkItemFactory
*m_factory
;
52 wxWindow
*m_invokingWindow
;
54 #if 0 // seems to be unused (VZ)
55 wxMenuList
& GetMenus() { return m_menus
; }
59 DECLARE_DYNAMIC_CLASS(wxMenuBar
)
62 //-----------------------------------------------------------------------------
64 //-----------------------------------------------------------------------------
66 class wxMenu
: public wxEvtHandler
68 DECLARE_DYNAMIC_CLASS(wxMenu
)
71 wxMenu( const wxString
& title
, const wxFunction func
)
77 Init( wxEmptyString
, style
);
79 wxMenu( const wxString
& title
= wxEmptyString
, long style
= 0 )
87 void SetTitle(const wxString
& label
);
88 const wxString
GetTitle() const;
91 void AppendSeparator();
92 void Append(int id
, const wxString
&item
,
93 const wxString
&helpStr
= "", bool checkable
= FALSE
);
94 void Append(int id
, const wxString
&item
,
95 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
96 void Append(wxMenuItem
*pItem
);
99 // delete item. don't delete the wxMenu if it's a submenu
100 void Delete( int id
);
102 // find item by name/id
103 int FindItem( const wxString itemString
) const;
104 wxMenuItem
*FindItem( int id
) const;
106 // get/set item's state
107 void Enable( int id
, bool enable
);
108 bool IsEnabled( int id
) const;
109 void Check( int id
, bool check
);
110 bool IsChecked( int id
) const;
112 void SetLabel( int id
, const wxString
&label
);
113 wxString
GetLabel( int id
) const;
116 virtual void SetHelpString(int id
, const wxString
& helpString
);
117 virtual wxString
GetHelpString(int id
) const ;
120 wxList
& GetItems() { return m_items
; }
122 void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
123 wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
125 void SetClientData( void* clientData
) { m_clientData
= clientData
; }
126 void* GetClientData() const { return m_clientData
; }
128 // Updates the UI for a menu and all submenus recursively.
129 // source is the object that has the update event handlers
130 // defined for it. If NULL, the menu or associated window
132 void UpdateUI(wxEvtHandler
* source
= (wxEvtHandler
*) NULL
);
134 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
136 wxFunction
GetCallback() const { return m_callback
; }
137 void Callback(const wxFunction func
) { m_callback
= func
; }
138 wxFunction m_callback
;
140 #ifdef WXWIN_COMPATIBILITY
142 // compatibility: these functions are deprecated
143 bool Enabled(int id
) const { return IsEnabled(id
); }
144 bool Checked(int id
) const { return IsChecked(id
); }
146 #endif // WXWIN_COMPATIBILITY
149 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
150 void SetInvokingWindow( wxWindow
*win
);
151 wxWindow
*GetInvokingWindow();
153 // implementation GTK only
154 GtkWidget
*m_menu
; // GtkMenu
156 GtkAccelGroup
*m_accel
;
157 GtkItemFactory
*m_factory
;
160 long GetStyle(void) const { return m_style
; }
163 // common code for both constructors:
164 void Init( const wxString
& title
,
166 const wxFunction func
= (wxFunction
) NULL
);
170 wxWindow
*m_invokingWindow
;
171 wxEvtHandler
*m_eventHandler
;
176 #endif // __GTKMENUH__