]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Toolbars.h
Compil fix.
[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
21
22 namespace lyx {
23
24 class Lexer;
25
26 namespace frontend {
27
28 class ToolbarItem {
29 public:
30         enum Type {
31                 /// command/action
32                 COMMAND,
33                 /// the command buffer
34                 MINIBUFFER,
35                 /// adds space between buttons in the toolbar
36                 SEPARATOR,
37                 /// a special combox insead of a button
38                 LAYOUTS,
39                 /// a special widget to insert tabulars
40                 TABLEINSERT,
41                 ///
42                 POPUPMENU,
43                 ///
44                 ICONPALETTE
45         };
46
47         ToolbarItem(Type type,
48                  FuncRequest const & func,
49                  docstring const & label = docstring());
50
51         ToolbarItem(Type type,
52                  std::string const & name = std::string(),
53                  docstring const & label = docstring());
54
55         /// item type
56         Type type_;
57         /// action
58         FuncRequest func_;
59         /// label/tooltip
60         docstring label_;
61         /// name
62         std::string name_;
63 };
64
65
66 ///
67 class ToolbarInfo {
68 public:
69         /// the toolbar items
70         typedef std::vector<ToolbarItem> Items;
71
72         typedef Items::const_iterator item_iterator;
73
74         explicit ToolbarInfo(std::string const & name = std::string())
75                 : name(name) {}
76
77         /// toolbar name
78         std::string name;
79         /// toolbar GUI name
80         std::string gui_name;
81         /// toolbar contents
82         Items items;
83
84         /// read a toolbar from the file
85         ToolbarInfo & read(Lexer &);
86
87 private:
88         /// add toolbar item
89         void add(ToolbarItem const &);
90 };
91
92
93 ///
94 class Toolbars {
95 public:
96         /// toolbar visibility flags
97         enum Visibility {
98                 ON = 1, //< show
99                 OFF = 2, //< do not show
100                 TOP = 4, //< show at top
101                 BOTTOM = 8, //< show at bottom
102                 LEFT = 16, //< show at left
103                 RIGHT = 32, //< show at right
104                 AUTO = 64,  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
105                 MATH = 128, //< show when in math
106                 TABLE = 256, //< show when in table
107                 REVIEW = 512, //< show when change tracking is enabled
108                 MATHMACROTEMPLATE = 1024 //< show in math macro template
109         };
110
111         typedef std::vector<ToolbarInfo> Infos;
112
113         Toolbars() {}
114
115         /// iterator for all toolbars
116         Infos::const_iterator begin() const { return toolbar_info_.begin(); }
117
118         Infos::const_iterator end() const { return toolbar_info_.end(); }
119
120         Infos::iterator begin() { return toolbar_info_.begin(); }
121
122         Infos::iterator end() { return toolbar_info_.end(); }
123
124         /// read toolbars from the file
125         void readToolbars(Lexer &);
126
127         /// read ui toolbar settings
128         void readToolbarSettings(Lexer &);
129
130         ///
131         ToolbarInfo const * info(std::string const & name) const;
132         ///
133         int defaultVisibility(std::string const & name) const;
134
135 private:
136         /// all the defined toolbars
137         Infos toolbar_info_;
138         ///
139         std::map<std::string, int> toolbar_visibility_;
140 };
141
142 } // namespace frontend
143 } // namespace lyx
144
145 #endif // TOOLBAR_BACKEND_H