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>
30 /// The type of elements that can be in a menu
38 /** This is the list of last opened file,
39 typically for the File menu. */
41 /** This is the list of opened Documents,
42 typically for the Documents menu. */
46 /** This is a list of viewable formats
47 typically for the File->View menu. */
49 /** This is a list of updatable formats
50 typically for the File->Update menu. */
52 /** This is a list of exportable formats
53 typically for the File->Export menu. */
55 /** This is a list of importable formats
56 typically for the File->Export menu. */
58 /** This is the list of floats that we can
61 /** This is the list of floats that we can
64 /** This is the list of selections that can
67 /** Available branches in document */
71 explicit MenuItem(Kind kind);
74 std::string const & label,
75 std::string const & command = std::string(),
76 bool optional = false);
79 std::string const & label,
80 FuncRequest const & func,
81 bool optional = false);
83 /// This one is just to please boost::shared_ptr<>
85 /// The label of a given menuitem
86 std::string const label() const;
87 /// The keyboard shortcut (usually underlined in the entry)
88 std::string const shortcut() const;
89 /// The complete label, with label and shortcut separated by a '|'
90 std::string const fulllabel() const { return label_;}
92 Kind kind() const { return kind_; }
93 /// the action (if relevant)
94 FuncRequest const & func() const { return func_; }
95 /// returns true if the entry should be ommited when disabled
96 bool optional() const { return optional_; }
97 /// returns the status of the lfun associated with this entry
98 FuncStatus const & status() const { return status_; }
99 /// returns the status of the lfun associated with this entry
100 FuncStatus & status() { return status_; }
101 /// returns the status of the lfun associated with this entry
102 void status(FuncStatus const & status) { status_ = status; }
103 /// returns the binding associated to this action
104 std::string const binding() const;
105 /// the description of the submenu (if relevant)
106 std::string const & submenuname() const { return submenuname_; }
107 /// set the description of the submenu
108 void submenuname(std::string const & name) { submenuname_ = name; }
110 Menu * submenu() const { return submenu_.get(); }
112 void submenu(Menu * menu);
115 //friend class MenuBackend;
123 std::string submenuname_;
129 boost::shared_ptr<Menu> submenu_;
137 typedef std::vector<MenuItem> ItemList;
139 typedef ItemList::const_iterator const_iterator;
141 typedef ItemList::size_type size_type;
143 explicit Menu(std::string const & name = std::string())
146 Menu & add(MenuItem const &, LyXView const * view = 0);
148 Menu & read(LyXLex &);
150 std::string const & name() const { return name_; }
152 bool empty() const { return items_.empty(); }
154 ItemList::size_type size() const { return items_.size(); }
156 bool hasSubmenu(std::string const &) const;
158 const_iterator begin() const {
159 return items_.begin();
162 const_iterator end() const {
166 // Check whether the menu shortcuts are unique
167 void checkShortcuts() const;
170 friend class MenuBackend;
182 typedef std::vector<Menu> MenuList;
184 typedef MenuList::const_iterator const_iterator;
188 void add(Menu const &);
190 bool hasMenu(std::string const &) const;
192 Menu & getMenu(std::string const &);
194 Menu const & getMenu(std::string const &) const;
196 Menu const & getMenubar() const;
198 bool empty() const { return menulist_.empty(); }
199 /// Expands some special entries of the menu
200 /** The entries with the following kind are expanded to a
201 sequence of Command MenuItems: Lastfiles, Documents,
202 ViewFormats, ExportFormats, UpdateFormats, Branches
204 void expand(Menu const & frommenu, Menu & tomenu,
205 LyXView const *) const;
207 const_iterator begin() const {
208 return menulist_.begin();
211 const_iterator end() const {
212 return menulist_.end();
222 extern MenuBackend menubackend;
224 #endif /* MENUBACKEND_H */