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