]> git.lyx.org Git - lyx.git/blob - src/ToolbarBackend.h
Changed references as to where/how known issues are shown, i.e. added reference to...
[lyx.git] / src / ToolbarBackend.h
1 // -*- C++ -*-
2 /**
3  * \file ToolbarBackend.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
24 class Lexer;
25
26 class ToolbarItem {
27 public:
28         enum Type {
29                 /// command/action
30                 COMMAND,
31                 /// the command buffer
32                 MINIBUFFER,
33                 /// adds space between buttons in the toolbar
34                 SEPARATOR,
35                 /// a special combox insead of a button
36                 LAYOUTS,
37                 /// a special widget to insert tabulars
38                 TABLEINSERT,
39                 /// 
40                 POPUPMENU,
41                 ///
42                 ICONPALETTE
43         };
44
45         ToolbarItem(Type type,
46                  FuncRequest const & func,
47                  docstring const & label = docstring());
48
49         ToolbarItem(Type type,
50                  std::string const & name = std::string(),
51                  docstring const & label = docstring());
52
53         ~ToolbarItem();
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         /// toolbar flags
70         enum Flags {
71                 ON = 1, //< show
72                 OFF = 2, //< do not show
73                 MATH = 4, //< show when in math
74                 TABLE = 8, //< show when in table
75                 TOP = 16, //< show at top
76                 BOTTOM = 32, //< show at bottom
77                 LEFT = 64, //< show at left
78                 RIGHT = 128, //< show at right
79                 REVIEW = 256, //< show when change tracking is enabled
80                 AUTO = 512  //< only if AUTO is set, when MATH, TABLE and REVIEW is used
81         };
82         /// the toolbar items
83         typedef std::vector<ToolbarItem> Items;
84
85         typedef Items::const_iterator item_iterator;
86
87         explicit ToolbarInfo(std::string const & name = std::string())
88                 : name(name) {}
89
90         /// toolbar name
91         std::string name;
92         /// toolbar GUI name
93         std::string gui_name;
94         /// toolbar contents
95         Items items;
96         /// flags
97         Flags flags;
98
99         /// read a toolbar from the file
100         ToolbarInfo & read(Lexer &);
101
102 private:
103         /// add toolbar item
104         void add(ToolbarItem const &);
105 };
106
107
108 ///
109 class ToolbarBackend {
110 public:
111         typedef std::vector<ToolbarInfo> Toolbars;
112
113         ToolbarBackend();
114
115         /// iterator for all toolbars
116         Toolbars::const_iterator begin() const { return usedtoolbars.begin(); }
117
118         Toolbars::const_iterator end() const { return usedtoolbars.end(); }
119
120         Toolbars::iterator begin() { return usedtoolbars.begin(); }
121
122         Toolbars::iterator end() { return usedtoolbars.end(); }
123
124         /// read toolbars from the file
125         void readToolbars(Lexer &);
126
127         /// read ui toolbar settings
128         void readToolbarSettings(Lexer &);
129         ///
130         ToolbarInfo const & getToolbar(std::string const & name) const;
131         ///
132         ToolbarInfo & getToolbar(std::string const & name);
133
134 private:
135         /// all the toolbars
136         Toolbars toolbars;
137
138         /// toolbars listed
139         Toolbars usedtoolbars;
140 };
141
142 /// The global instance
143 extern ToolbarBackend toolbarbackend;
144
145
146
147 } // namespace lyx
148
149 #endif // TOOLBAR_BACKEND_H