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