]> git.lyx.org Git - lyx.git/blob - src/frontends/qt4/Toolbars.h
b4a9182e6465ce686812dd53df391324e90106f6
[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         ~ToolbarItem();
55
56         /// item type
57         Type type_;
58         /// action
59         FuncRequest func_;
60         /// label/tooltip
61         docstring label_;
62         /// name
63         std::string name_;
64 };
65
66
67 ///
68 class ToolbarInfo {
69 public:
70         /// toolbar flags
71         enum Flags {
72                 ON = 1, //< show
73                 OFF = 2, //< do not show
74                 MATH = 4, //< show when in math
75                 TABLE = 8, //< show when in table
76                 TOP = 16, //< show at top
77                 BOTTOM = 32, //< show at bottom
78                 LEFT = 64, //< show at left
79                 RIGHT = 128, //< show at right
80                 REVIEW = 256, //< show when change tracking is enabled
81                 AUTO = 512,  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
82                 MATHMACROTEMPLATE = 1024 //< show in math macro template
83         };
84         /// the toolbar items
85         typedef std::vector<ToolbarItem> Items;
86
87         typedef Items::const_iterator item_iterator;
88
89         explicit ToolbarInfo(std::string const & name = std::string())
90                 : name(name) {}
91
92         /// toolbar name
93         std::string name;
94         /// toolbar GUI name
95         std::string gui_name;
96         /// toolbar contents
97         Items items;
98         /// flags
99         Flags flags;
100         /// store flags when coming to fullscreen mode
101         Flags before_fullscreen;
102
103         /// read a toolbar from the file
104         ToolbarInfo & read(Lexer &);
105
106 private:
107         /// add toolbar item
108         void add(ToolbarItem const &);
109 };
110
111
112 ///
113 class Toolbars {
114 public:
115         typedef std::vector<ToolbarInfo> Infos;
116
117         Toolbars();
118
119         /// iterator for all toolbars
120         Infos::const_iterator begin() const { return usedtoolbars.begin(); }
121
122         Infos::const_iterator end() const { return usedtoolbars.end(); }
123
124         Infos::iterator begin() { return usedtoolbars.begin(); }
125
126         Infos::iterator end() { return usedtoolbars.end(); }
127
128         /// read toolbars from the file
129         void readToolbars(Lexer &);
130
131         /// read ui toolbar settings
132         void readToolbarSettings(Lexer &);
133
134         ///
135         ToolbarInfo const * getDefinedToolbarInfo(std::string const & name) const;
136         ///
137         ToolbarInfo * getUsedToolbarInfo(std::string const & name);
138
139         // FIXME should be deleted when every window has its own toolbar config.
140         /// number of toggleFullScreen calls, i.e. number of FullScreen windows.
141         int fullScreenWindows;
142
143 private:
144         /// all the defined toolbars
145         Infos toolbars;
146
147         /// toolbars listed
148         Infos usedtoolbars;
149 };
150
151 } // namespace frontend
152 } // namespace lyx
153
154 #endif // TOOLBAR_BACKEND_H