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 "support/std_string.h"
21 #include <boost/shared_ptr.hpp>
32 /// The type of elements that can be in a menu
40 /** This is the list of last opened file,
41 typically for the File menu. */
43 /** This is the list of opened Documents,
44 typically for the Documents menu. */
48 /** This is a list of viewable formats
49 typically for the File->View menu. */
51 /** This is a list of updatable formats
52 typically for the File->Update menu. */
54 /** This is a list of exportable formats
55 typically for the File->Export menu. */
57 /** This is a list of importable formats
58 typically for the File->Export menu. */
60 /** This is the list of floats that we can
63 /** This is the list of floats that we can
66 /** This is the list of selections that can
69 /** Available branches in document */
73 explicit MenuItem(Kind kind);
77 string const & command = string(),
78 bool optional = false);
82 FuncRequest const & func,
83 bool optional = false);
85 /// This one is just to please boost::shared_ptr<>
87 /// The label of a given menuitem
88 string const label() const;
89 /// The keyboard shortcut (usually underlined in the entry)
90 string const shortcut() const;
91 /// The complete label, with label and shortcut separated by a '|'
92 string const fulllabel() const { return label_;}
94 Kind kind() const { return kind_; }
95 /// the action (if relevant)
96 FuncRequest const & func() const { return func_; }
97 /// returns true if the entry should be ommited when disabled
98 bool optional() const { return optional_; }
99 /// returns the status of the lfun associated with this entry
100 FuncStatus const & status() const { return status_; }
101 /// returns the status of the lfun associated with this entry
102 FuncStatus & status() { return status_; }
103 /// returns the status of the lfun associated with this entry
104 void status(FuncStatus const & status) { status_ = status; }
105 /// returns the binding associated to this action
106 string const binding() const;
107 /// the description of the submenu (if relevant)
108 string const & submenuname() const { return submenuname_; }
109 /// set the description of the submenu
110 void submenuname(string const & name) { submenuname_ = name; }
112 Menu * submenu() const { return submenu_.get(); }
114 void submenu(Menu * menu);
117 //friend class MenuBackend;
131 boost::shared_ptr<Menu> submenu_;
139 typedef std::vector<MenuItem> ItemList;
141 typedef ItemList::const_iterator const_iterator;
143 typedef ItemList::size_type size_type;
145 explicit Menu(string const & name = string())
148 Menu & add(MenuItem const &, LyXView const * view = 0);
150 Menu & read(LyXLex &);
152 string const & name() const { return name_; }
154 bool empty() const { return items_.empty(); }
156 ItemList::size_type size() const { return items_.size(); }
158 bool hasSubmenu(string const &) const;
160 const_iterator begin() const {
161 return items_.begin();
164 const_iterator end() const {
168 // Check whether the menu shortcuts are unique
169 void checkShortcuts() const;
172 friend class MenuBackend;
184 typedef std::vector<Menu> MenuList;
186 typedef MenuList::const_iterator const_iterator;
190 void add(Menu const &);
192 bool hasMenu(string const &) const;
194 Menu & getMenu(string const &);
196 Menu const & getMenu(string const &) const;
198 Menu const & getMenubar() const;
200 bool empty() const { return menulist_.empty(); }
201 /// Expands some special entries of the menu
202 /** The entries with the following kind are expanded to a
203 sequence of Command MenuItems: Lastfiles, Documents,
204 ViewFormats, ExportFormats, UpdateFormats, Branches
206 void expand(Menu const & frommenu, Menu & tomenu,
207 LyXView const *) const;
209 const_iterator begin() const {
210 return menulist_.begin();
213 const_iterator end() const {
214 return menulist_.end();
224 extern MenuBackend menubackend;
226 #endif /* MENUBACKEND_H */