]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/menu.h
Fixed some .tex problems
[wxWidgets.git] / include / wx / motif / menu.h
CommitLineData
9b6dbb09
JS
1/////////////////////////////////////////////////////////////////////////////
2// Name: menu.h
3// Purpose: wxMenu, wxMenuBar classes
4// Author: Julian Smart
5// Modified by:
6// Created: 17/09/98
7// RCS-ID: $Id$
8// Copyright: (c) Julian Smart
9// Licence: wxWindows licence
10/////////////////////////////////////////////////////////////////////////////
11
12#ifndef _WX_MENU_H_
13#define _WX_MENU_H_
14
15#ifdef __GNUG__
16#pragma interface "menu.h"
17#endif
18
19#include "wx/defs.h"
20#include "wx/event.h"
21
22class WXDLLEXPORT wxMenuItem;
23class WXDLLEXPORT wxMenuBar;
24class WXDLLEXPORT wxMenu;
25
26WXDLLEXPORT_DATA(extern const char*) wxEmptyString;
27
28// ----------------------------------------------------------------------------
29// Menu
30// ----------------------------------------------------------------------------
31class WXDLLEXPORT wxMenu: public wxEvtHandler
32{
33 DECLARE_DYNAMIC_CLASS(wxMenu)
34
35public:
36 // ctor & dtor
37 wxMenu(const wxString& title = wxEmptyString, const wxFunction func = NULL);
38 ~wxMenu();
39
40 // construct menu
41 // append items to the menu
42 // separator line
43 void AppendSeparator();
44 // normal item
45 void Append(int id, const wxString& Label, const wxString& helpString = wxEmptyString,
46 bool checkable = FALSE);
47 // a submenu
48 void Append(int id, const wxString& Label, wxMenu *SubMenu,
49 const wxString& helpString = wxEmptyString);
50 // the most generic form (create wxMenuItem first and use it's functions)
51 void Append(wxMenuItem *pItem);
52 // insert a break in the menu
53 void Break();
54 // delete an item
55 void Delete(int id);
56
57 // menu item control
58 void Enable(int id, bool Flag);
59 bool Enabled(int id) const;
60 inline bool IsEnabled(int id) const { return Enabled(id); };
61 void Check(int id, bool Flag);
62 bool Checked(int id) const;
63 inline bool IsChecked(int id) const { return IsChecked(id); };
64
65 // item properties
66 // title
67 void SetTitle(const wxString& label);
68 const wxString GetTitle() const;
69 // label
70 void SetLabel(int id, const wxString& label);
71 wxString GetLabel(int id) const;
72 // help string
73 virtual void SetHelpString(int id, const wxString& helpString);
74 virtual wxString GetHelpString(int id) const ;
75
76 // find item
77 // Finds the item id matching the given string, -1 if not found.
78 virtual int FindItem(const wxString& itemString) const ;
79 // Find wxMenuItem by ID, and item's menu too if itemMenu is !NULL.
80 wxMenuItem *FindItemForId(int itemId, wxMenu **itemMenu = NULL) const;
81
82 void ProcessCommand(wxCommandEvent& event);
83 inline void Callback(const wxFunction func) { m_callback = func; }
84
85 virtual void SetParent(wxEvtHandler *parent) { m_parent = parent; }
86 inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
87 inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
88
89 inline wxList& GetItems() const { return (wxList&) m_menuItems; }
90
91 //// Motif-specific
92 inline WXWidget GetButtonWidget() const { return m_buttonWidget; }
93 inline WXWidget GetMainWidget() const { return m_menuWidget; }
94public:
95 wxFunction m_callback;
96
97 int m_noItems;
98 wxString m_title;
99 wxMenuBar * m_menuBar;
100 wxList m_menuItems;
101 wxEvtHandler * m_parent;
102 wxEvtHandler * m_eventHandler;
103
104 //// Motif-specific
105 int m_numColumns;
106 WXWidget m_menuWidget;
107 WXWidget m_popupShell; // For holding the popup shell widget
108 WXWidget m_buttonWidget; // The actual string, so we can grey it etc.
109 int m_menuId;
110 wxMenu* m_topMenu ;
111 wxMenu* m_menuParent;
112 bool m_ownedByMenuBar;
113};
114
115// ----------------------------------------------------------------------------
116// Menu Bar (a la Windows)
117// ----------------------------------------------------------------------------
118class WXDLLEXPORT wxFrame;
119class WXDLLEXPORT wxMenuBar: public wxEvtHandler
120{
121 DECLARE_DYNAMIC_CLASS(wxMenuBar)
122
123 wxMenuBar();
124 wxMenuBar(int n, wxMenu *menus[], const wxString titles[]);
125 ~wxMenuBar();
126
127 void Append(wxMenu *menu, const wxString& title);
128 // Must only be used AFTER menu has been attached to frame,
129 // otherwise use individual menus to enable/disable items
130 void Enable(int Id, bool Flag);
131 bool Enabled(int Id) const ;
132 inline bool IsEnabled(int Id) const { return Enabled(Id); };
133 void EnableTop(int pos, bool Flag);
134 void Check(int id, bool Flag);
135 bool Checked(int id) const ;
136 inline bool IsChecked(int Id) const { return Checked(Id); };
137 void SetLabel(int id, const wxString& label) ;
138 wxString GetLabel(int id) const ;
139 void SetLabelTop(int pos, const wxString& label) ;
140 wxString GetLabelTop(int pos) const ;
141 virtual void Delete(wxMenu *menu, int index = 0); /* Menu not destroyed */
142 virtual bool OnAppend(wxMenu *menu, const char *title);
143 virtual bool OnDelete(wxMenu *menu, int index);
144
145 virtual void SetHelpString(int Id, const wxString& helpString);
146 virtual wxString GetHelpString(int Id) const ;
147
148 virtual int FindMenuItem(const wxString& menuString, const wxString& itemString) const ;
149
150 // Find wxMenuItem for item ID, and return item's
151 // menu too if itemMenu is non-NULL.
152 wxMenuItem *FindItemForId(int itemId, wxMenu **menuForItem = NULL) const ;
153
154 inline void SetEventHandler(wxEvtHandler *handler) { m_eventHandler = handler; }
155 inline wxEvtHandler *GetEventHandler() { return m_eventHandler; }
156
157 inline int GetMenuCount() const { return m_menuCount; }
158 inline wxMenu* GetMenu(int i) const { return m_menus[i]; }
159
160 public:
161 wxEvtHandler * m_eventHandler;
162 int m_menuCount;
163 wxMenu ** m_menus;
164 wxString * m_titles;
165 wxFrame * m_menuBarFrame;
166/* TODO: data that represents the actual menubar when created.
167 */
168};
169
170#endif // _WX_MENU_H_