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