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>
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
65 /// Create a Command type MenuItem
67 string const & label = string(),
68 string const & command = string(),
69 bool optional = false);
73 bool optional = false);
75 /// This one is just to please boost::shared_ptr<>
77 /// The label of a given menuitem
78 string const label() const;
79 /// The keyboard shortcut (usually underlined in the entry)
80 string const shortcut() const;
81 /// The complete label, with label and shortcut separated by a '|'
82 string const fulllabel() const { return label_;}
84 Kind kind() const { return kind_; }
85 /// the action (if relevant)
86 int action() const { return action_; }
87 /// returns true if the entry should be ommited when disabled
88 bool optional() const { return optional_; }
89 /// the description of the submenu (if relevant)
90 string const & submenuname() const { return submenuname_; }
91 /// the description of the submenu (if relevant)
92 void submenuname(string const & name) { submenuname_ = name; }
94 Menu * submenu() const { return submenu_.get(); }
96 void submenu(Menu * menu);
99 //friend class MenuBackend;
111 boost::shared_ptr<Menu> submenu_;
119 typedef std::vector<MenuItem> ItemList;
121 typedef ItemList::const_iterator const_iterator;
123 typedef ItemList::size_type size_type;
125 explicit Menu(string const & name = string())
128 Menu & add(MenuItem const &);
130 Menu & read(LyXLex &);
132 string const & name() const { return name_; }
134 bool empty() const { return items_.empty(); }
136 ItemList::size_type size() const { return items_.size(); }
138 bool hasSubmenu(string const &) const;
140 const_iterator begin() const {
141 return items_.begin();
144 const_iterator end() const {
148 // Check whether the menu shortcuts are unique
149 void checkShortcuts() const;
163 typedef std::vector<Menu> MenuList;
165 typedef MenuList::const_iterator const_iterator;
168 /// Set default values for menu structure.
171 void add(Menu const &);
173 bool hasMenu(string const &) const;
175 Menu & getMenu (string const &);
177 Menu const & getMenu (string const &) const;
179 Menu const & getMenubar() const;
181 bool empty() const { return menulist_.empty(); }
182 /// Expands some special entries of the menu
183 /** The entries with the following kind are expanded to a
184 sequence of Command MenuItems: Lastfiles, Documents,
185 ViewFormats, ExportFormats, UpdateFormats
187 void expand(Menu const & frommenu, Menu & tomenu,
188 Buffer const *) const;
190 const_iterator begin() const {
191 return menulist_.begin();
194 const_iterator end() const {
195 return menulist_.end();
205 extern MenuBackend menubackend;
207 #endif /* MENUBACKEND_H */