1 /* This file is part of -*- C++ -*-
2 * ======================================================
4 * LyX, The Document Processor
6 * Copyright 1995 Matthias Ettrich
7 * Copyright 1995-2000 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. */
49 /** This is a list of viewable formats
50 typically for the File->View menu. */
52 /** This is a list of updatable formats
53 typically for the File->Update menu. */
55 /** This is a list of exportable formats
56 typically for the File->Export menu. */
59 /// Create a Command type MenuItem
61 string const & label = string(),
62 string const & command = string(),
63 bool optional = false);
67 bool optional = false)
68 : kind_(kind), label_(label),
69 action_(action), submenu_(), optional_(optional) {}
71 /// The label of a given menuitem
72 string const label() const { return token(label_, '|', 0); }
73 /// The keyboard shortcut (usually underlined in the entry)
74 string const shortcut() const { return token(label_, '|', 1); }
75 /// The complete label, with label and shortcut separated by a '|'
76 string const fulllabel() const { return label_;}
78 Kind kind() const { return kind_; }
79 /// the action (if relevant)
80 int action() const { return action_; }
81 /// the description of the submenu (if relevant)
82 string const & submenu() const { return submenu_; }
83 /// returns true if the entry should be ommited when disabled
84 bool optional() const { return optional_; }
103 typedef std::vector<MenuItem> ItemList;
105 typedef ItemList::const_iterator const_iterator;
107 explicit Menu(string const & name = string(), bool mb = false)
108 : menubar_(mb), name_(name) {}
110 Menu & add(MenuItem const &);
112 Menu & read(LyXLex &);
113 /// Expands some special entries of the menu
114 /** The entries with the following kind are expanded to a
115 sequence of Command MenuItems: Lastfiles, Documents,
116 ViewFormats, ExportFormats, UpdateFormats
118 void expand(Menu & tomenu, Buffer *) const;
120 bool menubar() const { return menubar_; }
122 string const & name() const { return name_; }
124 bool empty() const { return items_.empty(); }
126 ItemList::size_type size() const { return items_.size(); }
128 const_iterator begin() const {
129 return items_.begin();
132 const_iterator end() const {
136 // Check whether the menu shortcuts are unique
137 void checkShortcuts() const;
153 typedef std::vector<Menu> MenuList;
155 typedef MenuList::const_iterator const_iterator;
158 /// Set default values for menu structure.
161 void add(Menu const &);
163 bool hasMenu (string const &) const;
165 Menu & getMenu (string const &);
167 Menu const & getMenu (string const &) const;
169 bool empty() const { return menulist_.empty(); }
171 const_iterator begin() const {
172 return menulist_.begin();
175 const_iterator end() const {
176 return menulist_.end();
184 extern MenuBackend menubackend;
186 #endif /* MENUBACKEND_H */