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. */
49 /** This is a list of viewable formats
50 typically for the File->View menu. */
52 /** This is a list of updatable formats
53 typically for the File->Update menu. */
55 /** This is a list of exportable formats
56 typically for the File->Export menu. */
58 /** This is a list of importable formats
59 typically for the File->Export menu. */
61 /** This is the list of elements available
62 * for insertion into document. */
64 /** This is the list of floats that we can
67 /** This is the list of floats that we can
70 /** This is the list of selections that can
73 /** Available branches in document */
77 explicit MenuItem(Kind kind);
80 docstring const & label,
81 docstring const & submenu = docstring(),
82 bool optional = false);
85 docstring const & label,
86 FuncRequest const & func,
87 bool optional = false);
89 /// This one is just to please boost::shared_ptr<>
91 /// The label of a given menuitem
92 docstring const label() const;
93 /// The keyboard shortcut (usually underlined in the entry)
94 docstring const shortcut() const;
95 /// The complete label, with label and shortcut separated by a '|'
96 docstring const fulllabel() const { return label_;}
98 Kind kind() const { return kind_; }
99 /// the action (if relevant)
100 FuncRequest const & func() const { return func_; }
101 /// returns true if the entry should be ommited when disabled
102 bool optional() const { return optional_; }
103 /// returns the status of the lfun associated with this entry
104 FuncStatus const & status() const { return status_; }
105 /// returns the status of the lfun associated with this entry
106 FuncStatus & status() { return status_; }
107 /// returns the status of the lfun associated with this entry
108 void status(FuncStatus const & status) { status_ = status; }
109 /// returns the binding associated to this action
110 docstring const binding() const;
111 /// the description of the submenu (if relevant)
112 docstring const & submenuname() const { return submenuname_; }
113 /// set the description of the submenu
114 void submenuname(docstring const & name) { submenuname_ = name; }
116 Menu * submenu() const { return submenu_.get(); }
118 void submenu(Menu * menu);
121 //friend class MenuBackend;
129 docstring submenuname_;
135 boost::shared_ptr<Menu> submenu_;
143 typedef std::vector<MenuItem> ItemList;
145 typedef ItemList::const_iterator const_iterator;
147 typedef ItemList::size_type size_type;
149 explicit Menu(docstring const & name = docstring())
151 /// Add the menu item unconditionally
152 Menu & add(MenuItem const &);
153 /// Checks the associated FuncRequest status before adding the
155 Menu & addWithStatusCheck(MenuItem const &);
157 Menu & read(LyXLex &);
159 docstring const & name() const { return name_; }
161 bool empty() const { return items_.empty(); }
162 /// Clear the menu content.
163 void clear() { items_.clear(); }
165 ItemList::size_type size() const { return items_.size(); }
167 MenuItem const & operator[](size_type) const;
169 bool hasFunc(FuncRequest const &) const;
171 const_iterator begin() const {
172 return items_.begin();
175 const_iterator end() const {
179 // Check whether the menu shortcuts are unique
180 void checkShortcuts() const;
183 friend class MenuBackend;
195 typedef std::vector<Menu> MenuList;
197 typedef MenuList::const_iterator const_iterator;
199 typedef MenuList::iterator iterator;
201 MenuBackend() : specialmenu_(0) {}
205 void add(Menu const &);
207 bool hasMenu(docstring const &) const;
209 Menu & getMenu(docstring const &);
211 Menu const & getMenu(docstring const &) const;
213 Menu const & getMenubar() const;
215 bool empty() const { return menulist_.empty(); }
216 /** This defines a menu whose entries list the FuncRequests
217 will be removed by expand() in other menus. This is used by
220 void specialMenu(docstring const &);
221 /// Expands some special entries of the menu
222 /** The entries with the following kind are expanded to a
223 sequence of Command MenuItems: Lastfiles, Documents,
224 ViewFormats, ExportFormats, UpdateFormats, Branches
226 void expand(Menu const & frommenu, Menu & tomenu,
227 Buffer const *) const;
229 const_iterator begin() const {
230 return menulist_.begin();
234 return menulist_.begin();
237 const_iterator end() const {
238 return menulist_.end();
242 return menulist_.end();
254 extern MenuBackend menubackend;
259 #endif /* MENUBACKEND_H */