]> git.lyx.org Git - lyx.git/blob - src/ToolbarBackend.h
add comment
[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 LyXLex;
25
26
27 ///
28 class ToolbarBackend {
29 public:
30         /// The special toolbar actions
31         enum ItemType {
32                 /// the command buffer
33                 MINIBUFFER = -3,
34                 /// adds space between buttons in the toolbar
35                 SEPARATOR = -2,
36                 /// a special combox insead of a button
37                 LAYOUTS = -1,
38         };
39
40         /// action, tooltip
41         typedef std::pair<FuncRequest, docstring> Item;
42
43         /// the toolbar items
44         typedef std::vector<Item> Items;
45
46         /// toolbar flags
47         enum Flags {
48                 ON = 1, //< always shown
49                 OFF = 2, //< never shown
50                 MATH = 4, //< shown when in math
51                 TABLE = 8, //< shown when in table
52                 TOP = 16, //< show at top
53                 BOTTOM = 32, //< show at bottom
54                 LEFT = 64, //< show at left
55                 RIGHT = 128, //< show at right
56                 REVIEW = 256, //< shown when change tracking is enabled
57                 AUTO = 512  //< only if AUTO is set, will MATH, TABLE and REIVEW is used
58         };
59
60         /// a toolbar
61         struct Toolbar {
62                 /// toolbar name
63                 std::string name;
64                 /// toolbar GUI name
65                 std::string gui_name;
66                 /// toolbar contents
67                 Items items;
68                 /// flags
69                 Flags flags;
70         };
71
72         typedef std::vector<Toolbar> Toolbars;
73
74         typedef Items::const_iterator item_iterator;
75
76         ToolbarBackend();
77
78         /// iterator for all toolbars
79         Toolbars::const_iterator begin() const { return usedtoolbars.begin(); }
80
81         Toolbars::const_iterator end() const { return usedtoolbars.end(); }
82
83         Toolbars::iterator begin() { return usedtoolbars.begin(); }
84
85         Toolbars::iterator end() { return usedtoolbars.end(); }
86
87         /// read a toolbar from the file
88         void read(LyXLex &);
89
90         /// read the used toolbars
91         void readToolbars(LyXLex &);
92
93         /// return a full path of an XPM for the given action
94         static std::string const getIcon(FuncRequest const &);
95
96 private:
97         /// add the given lfun with tooltip if relevant
98         void add(Toolbar & tb, FuncRequest const &,
99                  docstring const & tooltip = docstring());
100
101         /// all the toolbars
102         Toolbars toolbars;
103
104         /// toolbars listed
105         Toolbars usedtoolbars;
106 };
107
108 /// The global instance
109 extern ToolbarBackend toolbarbackend;
110
111
112
113 } // namespace lyx
114
115 #endif // TOOLBAR_BACKEND_H