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