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