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 *======================================================*/
22 #include "support/lstrings.h"
31 /// The type of elements that can be in a menu
39 /** This is the list of last opened file,
40 typically for the File menu. */
42 /** This is the list of opened Documents,
43 typically for the Documents menu. */
47 /** This is a list of viewable formats
48 typically for the File->View menu. */
50 /** This is a list of updatable formats
51 typically for the File->Update menu. */
53 /** This is a list of exportable formats
54 typically for the File->Export menu. */
56 /** This is a list of importable formats
57 typically for the File->Export menu. */
59 /** This is the list of floats that we can
62 /** This is the list of floats that we can
66 /// Create a Command type MenuItem
68 string const & label = string(),
69 string const & command = string(),
70 bool optional = false);
74 bool optional = false)
75 : kind_(kind), label_(label),
76 action_(action), submenu_(), optional_(optional) {}
78 /// The label of a given menuitem
79 string const label() const { return token(label_, '|', 0); }
80 /// The keyboard shortcut (usually underlined in the entry)
81 string const shortcut() const { return token(label_, '|', 1); }
82 /// The complete label, with label and shortcut separated by a '|'
83 string const fulllabel() const { return label_;}
85 Kind kind() const { return kind_; }
86 /// the action (if relevant)
87 int action() const { return action_; }
88 /// the description of the submenu (if relevant)
89 string const & submenu() const { return submenu_; }
90 /// returns true if the entry should be ommited when disabled
91 bool optional() const { return optional_; }
110 typedef std::vector<MenuItem> ItemList;
112 typedef ItemList::const_iterator const_iterator;
114 explicit Menu(string const & name = string(), bool mb = false)
115 : menubar_(mb), name_(name) {}
117 Menu & add(MenuItem const &);
119 Menu & read(LyXLex &);
120 /// Expands some special entries of the menu
121 /** The entries with the following kind are expanded to a
122 sequence of Command MenuItems: Lastfiles, Documents,
123 ViewFormats, ExportFormats, UpdateFormats
125 void expand(Menu & tomenu, Buffer *) const;
127 bool menubar() const { return menubar_; }
129 string const & name() const { return name_; }
131 bool empty() const { return items_.empty(); }
133 ItemList::size_type size() const { return items_.size(); }
135 bool hasSubmenu(string const &) const;
137 const_iterator begin() const {
138 return items_.begin();
141 const_iterator end() const {
145 // Check whether the menu shortcuts are unique
146 void checkShortcuts() const;
162 typedef std::vector<Menu> MenuList;
164 typedef MenuList::const_iterator const_iterator;
167 /// Set default values for menu structure.
170 void add(Menu const &);
172 bool hasMenu(string const &) const;
174 Menu & getMenu (string const &);
176 Menu const & getMenu (string const &) const;
178 bool empty() const { return menulist_.empty(); }
180 const_iterator begin() const {
181 return menulist_.begin();
184 const_iterator end() const {
185 return menulist_.end();
193 extern MenuBackend menubackend;
195 #endif /* MENUBACKEND_H */