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 "support/std_string.h"
18 #include <boost/shared_ptr.hpp>
22 #include "FuncStatus.h"
31 /// The type of elements that can be in a menu
39 /** This is the list of last opened file,
40 typically for the File menu. */
42 /** This is the list of opened Documents,
43 typically for the Documents menu. */
47 /** This is a list of viewable formats
48 typically for the File->View menu. */
50 /** This is a list of updatable formats
51 typically for the File->Update menu. */
53 /** This is a list of exportable formats
54 typically for the File->Export menu. */
56 /** This is a list of importable formats
57 typically for the File->Export menu. */
59 /** This is the list of floats that we can
62 /** This is the list of floats that we can
65 /** This is the list of selections that can
68 /** Available branches in document */
71 /// Create a Command type MenuItem
73 string const & label = string(),
74 string const & command = string(),
75 bool optional = false);
79 bool optional = false);
81 /// This one is just to please boost::shared_ptr<>
83 /// The label of a given menuitem
84 string const label() const;
85 /// The keyboard shortcut (usually underlined in the entry)
86 string const shortcut() const;
87 /// The complete label, with label and shortcut separated by a '|'
88 string const fulllabel() const { return label_;}
90 Kind kind() const { return kind_; }
91 /// the action (if relevant)
92 int action() const { return action_; }
93 /// returns true if the entry should be ommited when disabled
94 bool optional() const { return optional_; }
95 /// returns the status of the lfun associated with this entry
96 FuncStatus const & status() const { return status_; }
97 /// returns the status of the lfun associated with this entry
98 FuncStatus & status() { return status_; }
99 /// returns the status of the lfun associated with this entry
100 void status(FuncStatus const & status) { status_ = status; }
101 /// returns the binding associated to this action
102 string const binding() const;
103 /// the description of the submenu (if relevant)
104 string const & submenuname() const { return submenuname_; }
105 /// set the description of the submenu
106 void submenuname(string const & name) { submenuname_ = name; }
108 Menu * submenu() const { return submenu_.get(); }
110 void submenu(Menu * menu);
113 //friend class MenuBackend;
127 boost::shared_ptr<Menu> submenu_;
135 typedef std::vector<MenuItem> ItemList;
137 typedef ItemList::const_iterator const_iterator;
139 typedef ItemList::size_type size_type;
141 explicit Menu(string const & name = string())
144 Menu & add(MenuItem const &, LyXView const * view = 0);
146 Menu & read(LyXLex &);
148 string const & name() const { return name_; }
150 bool empty() const { return items_.empty(); }
152 ItemList::size_type size() const { return items_.size(); }
154 bool hasSubmenu(string const &) const;
156 const_iterator begin() const {
157 return items_.begin();
160 const_iterator end() const {
164 // Check whether the menu shortcuts are unique
165 void checkShortcuts() const;
168 friend class MenuBackend;
180 typedef std::vector<Menu> MenuList;
182 typedef MenuList::const_iterator const_iterator;
186 void add(Menu const &);
188 bool hasMenu(string const &) const;
190 Menu & getMenu(string const &);
192 Menu const & getMenu(string const &) const;
194 Menu const & getMenubar() const;
196 bool empty() const { return menulist_.empty(); }
197 /// Expands some special entries of the menu
198 /** The entries with the following kind are expanded to a
199 sequence of Command MenuItems: Lastfiles, Documents,
200 ViewFormats, ExportFormats, UpdateFormats, Branches
202 void expand(Menu const & frommenu, Menu & tomenu,
203 LyXView const *) const;
205 const_iterator begin() const {
206 return menulist_.begin();
209 const_iterator end() const {
210 return menulist_.end();
220 extern MenuBackend menubackend;
222 #endif /* MENUBACKEND_H */