]>
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
)
47 wxMenuBar( long style
);
49 void Append( wxMenu
*menu
, const wxString
&title
);
51 int FindMenuItem( const wxString
&menuString
, const wxString
&itemString
) const;
52 wxMenuItem
* FindMenuItemById( int id
) const;
53 inline wxMenuItem
* FindItemForId( int id
) const { 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 wxString
GetLabel( int id
) const;
63 void SetLabel( int id
, const wxString
&label
);
65 void EnableTop( int pos
, bool flag
);
66 void SetLabelTop( int pos
, const wxString
& label
);
67 wxString
GetLabelTop( int pos
) const;
69 virtual void SetHelpString( int id
, const wxString
& helpString
);
70 virtual wxString
GetHelpString( int id
) const;
72 inline int GetMenuCount() const { return m_menus
.Number(); }
73 inline wxMenu
*GetMenu( int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
79 //-----------------------------------------------------------------------------
81 //-----------------------------------------------------------------------------
83 class wxMenu
: public wxEvtHandler
85 DECLARE_DYNAMIC_CLASS(wxMenu
)
89 wxMenu( const wxString
& title
= wxEmptyString
, const wxFunction func
= (wxFunction
) NULL
);
93 void SetTitle(const wxString
& label
);
94 const wxString
GetTitle() const;
96 void AppendSeparator();
97 void Append(int id
, const wxString
&item
,
98 const wxString
&helpStr
= "", bool checkable
= FALSE
);
99 void Append(int id
, const wxString
&item
,
100 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
103 // find item by name/id
104 int FindItem( const wxString itemString
) const;
105 wxMenuItem
*FindItem( int id
) const;
106 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
108 // get/set item's state
109 void Enable( int id
, bool enable
);
110 bool IsEnabled( int id
) const;
111 void Check( int id
, bool check
);
112 bool IsChecked( int id
) const;
114 void SetLabel( int id
, const wxString
&label
);
115 wxString
GetLabel( int id
) const;
118 virtual void SetHelpString(int id
, const wxString
& helpString
);
119 virtual wxString
GetHelpString(int id
) const ;
122 wxList
& GetItems() { return m_items
; }
124 inline void Callback(const wxFunction func
) { m_callback
= func
; }
126 inline void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
127 inline wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
129 inline void SetClientData( void* clientData
) { m_clientData
= clientData
; }
130 inline void* GetClientData() const { return m_clientData
; }
132 // Updates the UI for a menu and all submenus recursively.
133 // source is the object that has the update event handlers
134 // defined for it. If NULL, the menu or associated window
136 void UpdateUI(wxEvtHandler
* source
= (wxEvtHandler
*) NULL
);
140 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
141 void SetInvokingWindow( wxWindow
*win
);
142 wxWindow
*GetInvokingWindow();
146 wxWindow
*m_invokingWindow
;
147 wxFunction m_callback
;
148 wxEvtHandler
*m_eventHandler
;
151 GtkWidget
*m_menu
; // GtkMenu
155 #endif // __GTKMENUH__