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(), bool mb = false)
114 : menubar_(mb), name_(name) {}
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;
126 bool menubar() const { return menubar_; }
128 string const & name() const { return name_; }
130 bool empty() const { return items_.empty(); }
132 ItemList::size_type size() const { return items_.size(); }
134 bool hasSubmenu(string const &) const;
136 const_iterator begin() const {
137 return items_.begin();
140 const_iterator end() const {
144 // Check whether the menu shortcuts are unique
145 void checkShortcuts() const;
161 typedef std::vector<Menu> MenuList;
163 typedef MenuList::const_iterator const_iterator;
166 /// Set default values for menu structure.
169 void add(Menu const &);
171 bool hasMenu(string const &) const;
173 Menu & getMenu (string const &);
175 Menu const & getMenu (string const &) const;
177 bool empty() const { return menulist_.empty(); }
179 const_iterator begin() const {
180 return menulist_.begin();
183 const_iterator end() const {
184 return menulist_.end();
192 extern MenuBackend menubackend;
194 #endif /* MENUBACKEND_H */