]> git.lyx.org Git - lyx.git/blob - src/frontends/qt/Toolbars.h
Remove obsolete (and false) comment.
[lyx.git] / src / frontends / qt / Toolbars.h
1 // -*- C++ -*-
2 /**
3  * \file Toolbars.h
4  * This file is part of LyX, the document processor.
5  * Licence details can be found in the file COPYING.
6  *
7  * \author Jean-Marc Lasgouttes
8  * \author John Levon
9  *
10  * Full author contact details are available in file CREDITS.
11  */
12
13 #ifndef TOOLBAR_BACKEND_H
14 #define TOOLBAR_BACKEND_H
15
16 #include "FuncRequest.h"
17
18 #include <vector>
19 #include <map>
20 #include <memory>
21
22
23 namespace lyx {
24
25 class Lexer;
26
27 namespace frontend {
28
29 class ToolbarItem {
30 public:
31         enum Type {
32                 /// command/action
33                 COMMAND,
34                 /// the command buffer
35                 MINIBUFFER,
36                 /// adds space between buttons in the toolbar
37                 SEPARATOR,
38                 /// a special combox insead of a button
39                 LAYOUTS,
40                 /// a special widget to insert tabulars
41                 TABLEINSERT,
42                 /// a button that expands a menu
43                 POPUPMENU,
44                 /// a button that expands a menu but remembers the last choice
45                 STICKYPOPUPMENU,
46                 ///
47                 ICONPALETTE,
48                 ///
49                 DYNAMICMENU
50         };
51
52         ToolbarItem(Type type,
53                  FuncRequest const & func,
54                  docstring const & label = docstring());
55
56         ToolbarItem(Type type,
57                  std::string const & name = std::string(),
58                  docstring const & label = docstring());
59
60         /// item type
61         Type type_;
62         /// action
63         std::shared_ptr<FuncRequest> func_; // non-null
64         /// label/tooltip
65         docstring label_;
66         /// name
67         std::string name_;
68 };
69
70
71 ///
72 class ToolbarInfo {
73 public:
74         /// the toolbar items
75         typedef std::vector<ToolbarItem> Items;
76
77         typedef Items::const_iterator item_iterator;
78
79         explicit ToolbarInfo(std::string const & name = std::string())
80                 : name(name) {}
81
82         /// toolbar name
83         std::string name;
84         /// toolbar GUI name
85         docstring gui_name;
86         /// toolbar contents
87         Items items;
88
89         /// read a toolbar from the file
90         ToolbarInfo & read(Lexer &);
91
92 private:
93         /// add toolbar item
94         void add(ToolbarItem const &);
95 };
96
97
98 ///
99 class Toolbars {
100 public:
101         /// toolbar visibility flags
102         enum Visibility {
103                 ON = 1, //< show
104                 OFF = 2, //< do not show
105                 TOP = 4, //< show at top
106                 BOTTOM = 8, //< show at bottom
107                 LEFT = 16, //< show at left
108                 RIGHT = 32, //< show at right
109                 AUTO = 64,  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
110                 MATH = 128, //< show when in math
111                 TABLE = 256, //< show when in table
112                 REVIEW = 512, //< show when change tracking is enabled
113                 MATHMACROTEMPLATE = 1024, //< show in math macro template
114                 SAMEROW = 2048, //< place to the current row, no new line
115                 IPA = 4096, //< show when in IPA inset
116                 MINIBUFFER = 8192, //< show when command-execute has been invoked
117                 MINIBUFFER_FOCUS = 16384, //< set focus to minibuffer
118                 ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA | MINIBUFFER
119         };
120
121         typedef std::vector<ToolbarInfo> Infos;
122
123         Toolbars() {}
124
125         ///
126         void reset();
127
128         /// iterator for all toolbars
129         Infos::const_iterator begin() const { return toolbar_info_.begin(); }
130
131         Infos::const_iterator end() const { return toolbar_info_.end(); }
132
133         Infos::iterator begin() { return toolbar_info_.begin(); }
134
135         Infos::iterator end() { return toolbar_info_.end(); }
136
137         /// read toolbars from the file
138         void readToolbars(Lexer &);
139
140         /// read ui toolbar settings
141         void readToolbarSettings(Lexer &);
142
143         ///
144         ToolbarInfo const * info(std::string const & name) const;
145         ///
146         int defaultVisibility(std::string const & name) const;
147         ///
148         bool isMainToolbar(std::string const & name) const;
149
150 private:
151         /// all the defined toolbars
152         Infos toolbar_info_;
153         ///
154         std::map<std::string, int> toolbar_visibility_;
155 };
156
157 } // namespace frontend
158 } // namespace lyx
159
160 #endif // TOOLBAR_BACKEND_H