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