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