]>
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 { return FindMenuItemById( id
); }
54 void Check( int id
, bool check
);
55 bool Checked( int id
) const;
56 void Enable( int id
, bool enable
);
57 bool Enabled( int id
) const;
58 inline bool IsEnabled( int id
) const { return Enabled(id
); }
59 inline bool IsChecked( int id
) const { return Checked(id
); }
61 wxString
GetLabel( int id
) const;
62 void SetLabel( int id
, const wxString
&label
);
64 void EnableTop( int pos
, bool flag
);
65 void SetLabelTop( int pos
, const wxString
& label
);
66 wxString
GetLabelTop( int pos
) const;
68 virtual void SetHelpString( int id
, const wxString
& helpString
);
69 virtual wxString
GetHelpString( int id
) const;
71 inline int GetMenuCount() const { return m_menus
.Number(); }
72 inline wxMenu
*GetMenu( int n
) const { return (wxMenu
*)m_menus
.Nth(n
)->Data(); }
78 //-----------------------------------------------------------------------------
80 //-----------------------------------------------------------------------------
82 class wxMenu
: public wxEvtHandler
84 DECLARE_DYNAMIC_CLASS(wxMenu
)
88 wxMenu( const wxString
& title
= wxEmptyString
, const wxFunction func
= (wxFunction
) NULL
);
92 void SetTitle(const wxString
& label
);
93 const wxString
GetTitle() const;
95 void AppendSeparator();
96 void Append(int id
, const wxString
&item
,
97 const wxString
&helpStr
= "", bool checkable
= FALSE
);
98 void Append(int id
, const wxString
&item
,
99 wxMenu
*subMenu
, const wxString
&helpStr
= "" );
102 // find item by name/id
103 int FindItem( const wxString itemString
) const;
104 wxMenuItem
*FindItem( int id
) const;
105 wxMenuItem
*FindItemForId( int id
) const { return FindItem( id
); }
107 // get/set item's state
108 void Enable( int id
, bool enable
);
109 bool IsEnabled( int id
) const;
110 void Check( int id
, bool check
);
111 bool IsChecked( int id
) const;
113 void SetLabel( int id
, const wxString
&label
);
114 wxString
GetLabel( int id
) const;
117 virtual void SetHelpString(int id
, const wxString
& helpString
);
118 virtual wxString
GetHelpString(int id
) const ;
121 wxList
& GetItems() { return m_items
; }
123 inline void Callback(const wxFunction func
) { m_callback
= func
; }
125 inline void SetEventHandler(wxEvtHandler
*handler
) { m_eventHandler
= handler
; }
126 inline wxEvtHandler
*GetEventHandler() { return m_eventHandler
; }
128 inline void SetClientData( void* clientData
) { m_clientData
= clientData
; }
129 inline void* GetClientData() const { return m_clientData
; }
133 int FindMenuIdByMenuItem( GtkWidget
*menuItem
) const;
134 void SetInvokingWindow( wxWindow
*win
);
135 wxWindow
*GetInvokingWindow();
139 wxWindow
*m_invokingWindow
;
140 wxFunction m_callback
;
141 wxEvtHandler
*m_eventHandler
;
144 GtkWidget
*m_menu
; // GtkMenu
148 #endif // __GTKMENUH__