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; }
119 ///returns the binding associated to this action.
120 docstring const binding() const;
121 /// the description of the submenu (if relevant)
122 docstring const & submenuname() const { return submenuname_; }
123 /// set the description of the submenu
124 void submenuname(docstring const & name) { submenuname_ = name; }
126 Menu * submenu() const { return submenu_.get(); }
128 void submenu(Menu * menu);
131 //friend class MenuBackend;
139 docstring submenuname_;
145 boost::shared_ptr<Menu> submenu_;
153 typedef std::vector<MenuItem> ItemList;
155 typedef ItemList::const_iterator const_iterator;
157 typedef ItemList::size_type size_type;
159 explicit Menu(docstring const & name = docstring()) : name_(name) {}
160 /// Add the menu item unconditionally
161 Menu & add(MenuItem const &);
162 /// Checks the associated FuncRequest status before adding the
164 Menu & addWithStatusCheck(MenuItem const &);
166 Menu & read(Lexer &);
168 docstring const & name() const { return name_; }
170 bool empty() const { return items_.empty(); }
171 /// Clear the menu content.
172 void clear() { items_.clear(); }
174 ItemList::size_type size() const { return items_.size(); }
176 MenuItem const & operator[](size_type) const;
178 bool hasFunc(FuncRequest const &) const;
180 const_iterator begin() const { return items_.begin(); }
182 const_iterator end() const { return items_.end(); }
184 // Check whether the menu shortcuts are unique
185 void checkShortcuts() const;
187 // search for func in this menu iteratively, and put menu
189 bool searchMenu(FuncRequest const & func, std::vector<docstring> & names)
193 friend class MenuBackend;
205 typedef std::vector<Menu> MenuList;
207 typedef MenuList::const_iterator const_iterator;
209 typedef MenuList::iterator iterator;
215 void add(Menu const &);
217 bool hasMenu(docstring const &) const;
219 Menu & getMenu(docstring const &);
221 Menu const & getMenu(docstring const &) const;
223 Menu const & getMenubar() const;
225 bool empty() const { return menulist_.empty(); }
226 /** This defines a menu whose entries list the FuncRequests
227 that will be removed by expand() in other menus. This is
228 used by the Qt/Mac code
230 void specialMenu(Menu const &);
232 Menu const & specialMenu() { return specialmenu_; }
234 /// Expands some special entries of the menu
235 /** The entries with the following kind are expanded to a
236 sequence of Command MenuItems: Lastfiles, Documents,
237 ViewFormats, ExportFormats, UpdateFormats, Branches
239 void expand(Menu const & frommenu, Menu & tomenu,
240 Buffer const *) const;
242 const_iterator begin() const { return menulist_.begin(); }
244 iterator begin() { return menulist_.begin(); }
246 const_iterator end() const { return menulist_.end(); }
248 iterator end() { return menulist_.end(); }
261 #endif // MENUBACKEND_H