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); }
74 string const shortcut() const { return token(label_, '|', 1); }
76 Kind kind() const { return kind_; }
77 /// the action (if relevant)
78 int action() const { return action_; }
79 /// the description of the submenu (if relevant)
80 string const & submenu() const { return submenu_; }
81 /// returns true if the entry should be ommited when disabled
82 bool optional() const { return optional_; }
101 typedef std::vector<MenuItem> ItemList;
103 typedef ItemList::const_iterator const_iterator;
105 explicit Menu(string const & name = string(), bool mb = false)
106 : menubar_(mb), name_(name) {}
108 Menu & add(MenuItem const &);
110 Menu & read(LyXLex &);
111 /// Expands some special entries of the menu
112 /** The entries with the following kind are exanded to a
113 sequence of Command MenuItems: Lastfiles, Documents,
114 ViewFormats, ExportFormats, UpdateFormats
116 void expand(Menu & tomenu, Buffer *) const;
118 bool menubar() const { return menubar_; }
120 string const & name() const { return name_; }
122 bool empty() const { return items_.empty(); }
124 ItemList::size_type size() const { return items_.size(); }
126 const_iterator begin() const {
127 return items_.begin();
130 const_iterator end() const {
147 typedef std::vector<Menu> MenuList;
149 typedef MenuList::const_iterator const_iterator;
152 /// Set default values for menu structure.
155 void add(Menu const &);
157 bool hasMenu (string const &) const;
159 Menu & getMenu (string const &);
161 Menu const & getMenu (string const &) const;
163 bool empty() const { return menulist_.empty(); }
165 const_iterator begin() const {
166 return menulist_.begin();
169 const_iterator end() const {
170 return menulist_.end();
178 extern MenuBackend menubackend;
180 #endif /* MENUBACKEND_H */