]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Toolbars.h
Some improvements to the graphics dialog
[lyx.git] / src / frontends / qt4 / 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
50         ToolbarItem(Type type,
51                  FuncRequest const & func,
52                  docstring const & label = docstring());
53
54         ToolbarItem(Type type,
55                  std::string const & name = std::string(),
56                  docstring const & label = docstring());
57
58         /// item type
59         Type type_;
60         /// action
61         std::shared_ptr<FuncRequest> func_; // non-null
62         /// label/tooltip
63         docstring label_;
64         /// name
65         std::string name_;
66 };
67
68
69 ///
70 class ToolbarInfo {
71 public:
72         /// the toolbar items
73         typedef std::vector<ToolbarItem> Items;
74
75         typedef Items::const_iterator item_iterator;
76
77         explicit ToolbarInfo(std::string const & name = std::string())
78                 : name(name) {}
79
80         /// toolbar name
81         std::string name;
82         /// toolbar GUI name
83         docstring gui_name;
84         /// toolbar contents
85         Items items;
86
87         /// read a toolbar from the file
88         ToolbarInfo & read(Lexer &);
89
90 private:
91         /// add toolbar item
92         void add(ToolbarItem const &);
93 };
94
95
96 ///
97 class Toolbars {
98 public:
99         /// toolbar visibility flags
100         enum Visibility {
101                 ON = 1, //< show
102                 OFF = 2, //< do not show
103                 TOP = 4, //< show at top
104                 BOTTOM = 8, //< show at bottom
105                 LEFT = 16, //< show at left
106                 RIGHT = 32, //< show at right
107                 AUTO = 64,  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
108                 MATH = 128, //< show when in math
109                 TABLE = 256, //< show when in table
110                 REVIEW = 512, //< show when change tracking is enabled
111                 MATHMACROTEMPLATE = 1024, //< show in math macro template
112                 SAMEROW = 2048, //< place to the current row, no new line
113                 IPA = 4096, //< show when in IPA inset
114                 MINIBUFFER = 8192, //< show when command-execute has been invoked
115                 MINIBUFFER_FOCUS = 16384, //< set focus to minibuffer
116                 ALLOWAUTO = MATH | TABLE | REVIEW | MATHMACROTEMPLATE | IPA | MINIBUFFER
117         };
118
119         typedef std::vector<ToolbarInfo> Infos;
120
121         Toolbars() {}
122
123         ///
124         void reset();
125
126         /// iterator for all toolbars
127         Infos::const_iterator begin() const { return toolbar_info_.begin(); }
128
129         Infos::const_iterator end() const { return toolbar_info_.end(); }
130
131         Infos::iterator begin() { return toolbar_info_.begin(); }
132
133         Infos::iterator end() { return toolbar_info_.end(); }
134
135         /// read toolbars from the file
136         void readToolbars(Lexer &);
137
138         /// read ui toolbar settings
139         void readToolbarSettings(Lexer &);
140
141         ///
142         ToolbarInfo const * info(std::string const & name) const;
143         ///
144         int defaultVisibility(std::string const & name) const;
145         ///
146         bool isMainToolbar(std::string const & name) const;
147
148 private:
149         /// all the defined toolbars
150         Infos toolbar_info_;
151         ///
152         std::map<std::string, int> toolbar_visibility_;
153 };
154
155 } // namespace frontend
156 } // namespace lyx
157
158 #endif // TOOLBAR_BACKEND_H