1 /* This file is part of -*- C++ -*-
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2001 The LyX Team.
9 * This file is Copyright 1999
10 * Jean-Marc Lasgouttes
12 *======================================================*/
19 #include <boost/shared_ptr.hpp>
23 #include "FuncStatus.h"
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 */
72 /// Create a Command type MenuItem
74 string const & label = string(),
75 string const & command = string(),
76 bool optional = false);
80 bool optional = false);
82 /// This one is just to please boost::shared_ptr<>
84 /// The label of a given menuitem
85 string const label() const;
86 /// The keyboard shortcut (usually underlined in the entry)
87 string const shortcut() const;
88 /// The complete label, with label and shortcut separated by a '|'
89 string const fulllabel() const { return label_;}
91 Kind kind() const { return kind_; }
92 /// the action (if relevant)
93 int action() const { return action_; }
94 /// returns true if the entry should be ommited when disabled
95 bool optional() const { return optional_; }
96 /// returns the status of the lfun associated with this entry
97 FuncStatus const & status() const { return status_; }
98 /// returns the status of the lfun associated with this entry
99 FuncStatus & status() { return status_; }
100 /// returns the status of the lfun associated with this entry
101 void status(FuncStatus const & status) { status_ = status; }
102 /// returns the binding associated to this action
103 string const binding() const;
104 /// the description of the submenu (if relevant)
105 string const & submenuname() const { return submenuname_; }
106 /// set the description of the submenu
107 void submenuname(string const & name) { submenuname_ = name; }
109 Menu * submenu() const { return submenu_.get(); }
111 void submenu(Menu * menu);
114 //friend class MenuBackend;
128 boost::shared_ptr<Menu> submenu_;
136 typedef std::vector<MenuItem> ItemList;
138 typedef ItemList::const_iterator const_iterator;
140 typedef ItemList::size_type size_type;
142 explicit Menu(string const & name = string())
145 Menu & add(MenuItem const &, LyXView const * view = 0);
147 Menu & read(LyXLex &);
149 string const & name() const { return name_; }
151 bool empty() const { return items_.empty(); }
153 ItemList::size_type size() const { return items_.size(); }
155 bool hasSubmenu(string const &) const;
157 const_iterator begin() const {
158 return items_.begin();
161 const_iterator end() const {
165 // Check whether the menu shortcuts are unique
166 void checkShortcuts() const;
169 friend class MenuBackend;
181 typedef std::vector<Menu> MenuList;
183 typedef MenuList::const_iterator const_iterator;
187 void add(Menu const &);
189 bool hasMenu(string const &) const;
191 Menu & getMenu(string const &);
193 Menu const & getMenu(string const &) const;
195 Menu const & getMenubar() const;
197 bool empty() const { return menulist_.empty(); }
198 /// Expands some special entries of the menu
199 /** The entries with the following kind are expanded to a
200 sequence of Command MenuItems: Lastfiles, Documents,
201 ViewFormats, ExportFormats, UpdateFormats, Branches
203 void expand(Menu const & frommenu, Menu & tomenu,
204 LyXView const *) const;
206 const_iterator begin() const {
207 return menulist_.begin();
210 const_iterator end() const {
211 return menulist_.end();
221 extern MenuBackend menubackend;
223 #endif /* MENUBACKEND_H */