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