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 *======================================================*/
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)
74 : kind_(kind), label_(label),
75 action_(action), submenu_(), optional_(optional) {}
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 /// the description of the submenu (if relevant)
88 string const & submenu() const { return submenu_; }
89 /// returns true if the entry should be ommited when disabled
90 bool optional() const { return optional_; }
109 typedef std::vector<MenuItem> ItemList;
111 typedef ItemList::const_iterator const_iterator;
113 explicit Menu(string const & name = string())
116 Menu & add(MenuItem const &);
118 Menu & read(LyXLex &);
119 /// Expands some special entries of the menu
120 /** The entries with the following kind are expanded to a
121 sequence of Command MenuItems: Lastfiles, Documents,
122 ViewFormats, ExportFormats, UpdateFormats
124 void expand(Menu & tomenu, Buffer const *) const;
126 string const & name() const { return name_; }
128 bool empty() const { return items_.empty(); }
130 ItemList::size_type size() const { return items_.size(); }
132 bool hasSubmenu(string const &) const;
134 const_iterator begin() const {
135 return items_.begin();
138 const_iterator end() const {
142 // Check whether the menu shortcuts are unique
143 void checkShortcuts() const;
157 typedef std::vector<Menu> MenuList;
159 typedef MenuList::const_iterator const_iterator;
162 /// Set default values for menu structure.
165 void add(Menu const &);
167 bool hasMenu(string const &) const;
169 Menu & getMenu (string const &);
171 Menu const & getMenu (string const &) const;
173 Menu const & getMenubar() const;
175 bool empty() const { return menulist_.empty(); }
177 const_iterator begin() const {
178 return menulist_.begin();
181 const_iterator end() const {
182 return menulist_.end();
192 extern MenuBackend menubackend;
194 #endif /* MENUBACKEND_H */