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
67 /// Create a Command type MenuItem
69 string const & label = string(),
70 string const & command = string(),
71 bool optional = false);
75 bool optional = false);
77 /// This one is just to please boost::shared_ptr<>
79 /// The label of a given menuitem
80 string const label() const;
81 /// The keyboard shortcut (usually underlined in the entry)
82 string const shortcut() const;
83 /// The complete label, with label and shortcut separated by a '|'
84 string const fulllabel() const { return label_;}
86 Kind kind() const { return kind_; }
87 /// the action (if relevant)
88 int action() const { return action_; }
89 /// returns true if the entry should be ommited when disabled
90 bool optional() const { return optional_; }
91 /// returns the status of the lfun associated with this entry
92 FuncStatus const & status() const { return status_; }
93 /// returns the status of the lfun associated with this entry
94 FuncStatus & status() { return status_; }
95 /// returns the status of the lfun associated with this entry
96 void status(FuncStatus const & status) { status_ = status; }
97 /// returns the binding associated to this action
98 string const binding() const;
99 /// the description of the submenu (if relevant)
100 string const & submenuname() const { return submenuname_; }
101 /// set the description of the submenu
102 void submenuname(string const & name) { submenuname_ = name; }
104 Menu * submenu() const { return submenu_.get(); }
106 void submenu(Menu * menu);
109 //friend class MenuBackend;
123 boost::shared_ptr<Menu> submenu_;
131 typedef std::vector<MenuItem> ItemList;
133 typedef ItemList::const_iterator const_iterator;
135 typedef ItemList::size_type size_type;
137 explicit Menu(string const & name = string())
140 Menu & add(MenuItem const &, LyXView const * view = 0);
142 Menu & read(LyXLex &);
144 string const & name() const { return name_; }
146 bool empty() const { return items_.empty(); }
148 ItemList::size_type size() const { return items_.size(); }
150 bool hasSubmenu(string const &) const;
152 const_iterator begin() const {
153 return items_.begin();
156 const_iterator end() const {
160 // Check whether the menu shortcuts are unique
161 void checkShortcuts() const;
164 friend class MenuBackend;
176 typedef std::vector<Menu> MenuList;
178 typedef MenuList::const_iterator const_iterator;
182 void add(Menu const &);
184 bool hasMenu(string const &) const;
186 Menu & getMenu (string const &);
188 Menu const & getMenu (string const &) const;
190 Menu const & getMenubar() const;
192 bool empty() const { return menulist_.empty(); }
193 /// Expands some special entries of the menu
194 /** The entries with the following kind are expanded to a
195 sequence of Command MenuItems: Lastfiles, Documents,
196 ViewFormats, ExportFormats, UpdateFormats
198 void expand(Menu const & frommenu, Menu & tomenu,
199 LyXView const *) const;
201 const_iterator begin() const {
202 return menulist_.begin();
205 const_iterator end() const {
206 return menulist_.end();
216 extern MenuBackend menubackend;
218 #endif /* MENUBACKEND_H */