4 * This file is part of LyX, the document processor.
5 * Licence details can be found in the file COPYING.
7 * \author Lars Gullik Bjønnes
8 * \author Jean-Marc Lasgouttes
10 * Full author contact details are available in file CREDITS.
16 #include "FuncStatus.h"
17 #include "FuncRequest.h"
19 #include <boost/shared_ptr.hpp>
33 /// The type of elements that can be in a menu
41 /** This is the list of last opened file,
42 typically for the File menu. */
44 /** This is the list of opened Documents,
45 typically for the Documents menu. */
47 /** This is the bookmarks */
51 /** This is a list of viewable formats
52 typically for the File->View menu. */
54 /** This is a list of updatable formats
55 typically for the File->Update menu. */
57 /** This is a list of exportable formats
58 typically for the File->Export menu. */
60 /** This is a list of importable formats
61 typically for the File->Export menu. */
63 /** This is the list of elements available
64 * for insertion into document. */
66 /** This is the list of user-configurable
67 insets to insert into document */
69 /** This is the list of XML elements to
70 insert into the document */
72 /** This is the list of floats that we can
75 /** This is the list of floats that we can
78 /** This is the list of selections that can
83 /** Available branches in document */
87 explicit MenuItem(Kind kind);
90 docstring const & label,
91 docstring const & submenu = docstring(),
92 bool optional = false);
95 docstring const & label,
96 FuncRequest const & func,
97 bool optional = false);
99 /// This one is just to please boost::shared_ptr<>
101 /// The label of a given menuitem
102 docstring const label() const;
103 /// The keyboard shortcut (usually underlined in the entry)
104 docstring const shortcut() const;
105 /// The complete label, with label and shortcut separated by a '|'
106 docstring const fulllabel() const { return label_;}
107 /// The kind of entry
108 Kind kind() const { return kind_; }
109 /// the action (if relevant)
110 FuncRequest const & func() const { return func_; }
111 /// returns true if the entry should be ommited when disabled
112 bool optional() const { return optional_; }
113 /// returns the status of the lfun associated with this entry
114 FuncStatus const & status() const { return status_; }
115 /// returns the status of the lfun associated with this entry
116 FuncStatus & status() { return status_; }
117 /// returns the status of the lfun associated with this entry
118 void status(FuncStatus const & status) { status_ = status; }
120 * returns the binding associated to this action.
121 * Use the native UI format when \c forgui is true.
123 docstring const binding(bool forgui) const;
124 /// the description of the submenu (if relevant)
125 docstring const & submenuname() const { return submenuname_; }
126 /// set the description of the submenu
127 void submenuname(docstring const & name) { submenuname_ = name; }
129 Menu * submenu() const { return submenu_.get(); }
131 void submenu(Menu * menu);
134 //friend class MenuBackend;
142 docstring submenuname_;
148 boost::shared_ptr<Menu> submenu_;
156 typedef std::vector<MenuItem> ItemList;
158 typedef ItemList::const_iterator const_iterator;
160 typedef ItemList::size_type size_type;
162 explicit Menu(docstring const & name = docstring())
164 /// Add the menu item unconditionally
165 Menu & add(MenuItem const &);
166 /// Checks the associated FuncRequest status before adding the
168 Menu & addWithStatusCheck(MenuItem const &);
170 Menu & read(Lexer &);
172 docstring const & name() const { return name_; }
174 bool empty() const { return items_.empty(); }
175 /// Clear the menu content.
176 void clear() { items_.clear(); }
178 ItemList::size_type size() const { return items_.size(); }
180 MenuItem const & operator[](size_type) const;
182 bool hasFunc(FuncRequest const &) const;
184 const_iterator begin() const {
185 return items_.begin();
188 const_iterator end() const {
192 // Check whether the menu shortcuts are unique
193 void checkShortcuts() const;
196 friend class MenuBackend;
208 typedef std::vector<Menu> MenuList;
210 typedef MenuList::const_iterator const_iterator;
212 typedef MenuList::iterator iterator;
218 void add(Menu const &);
220 bool hasMenu(docstring const &) const;
222 Menu & getMenu(docstring const &);
224 Menu const & getMenu(docstring const &) const;
226 Menu const & getMenubar() const;
228 bool empty() const { return menulist_.empty(); }
229 /** This defines a menu whose entries list the FuncRequests
230 that will be removed by expand() in other menus. This is
231 used by the Qt/Mac code
233 void specialMenu(Menu const &);
235 Menu const & specialMenu() { return specialmenu_; }
237 /// Expands some special entries of the menu
238 /** The entries with the following kind are expanded to a
239 sequence of Command MenuItems: Lastfiles, Documents,
240 ViewFormats, ExportFormats, UpdateFormats, Branches
242 void expand(Menu const & frommenu, Menu & tomenu,
243 Buffer const *) const;
245 const_iterator begin() const {
246 return menulist_.begin();
250 return menulist_.begin();
253 const_iterator end() const {
254 return menulist_.end();
258 return menulist_.end();
270 extern MenuBackend menubackend;
275 #endif /* MENUBACKEND_H */