]> git.lyx.org Git - lyx.git/blob - src/ToolbarBackend.h
ba2bfa4c9a7c48107abeb328a85f2c49e84e289a
[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 unknown
8  *
9  * Full author contact details are available in file CREDITS
10  */
11
12 #ifndef TOOLBAR_BACKEND_H
13 #define TOOLBAR_BACKEND_H
14
15 #include <vector>
16 #include <algorithm>
17
18 #include "LString.h"
19
20 class LyXLex;
21
22 ///
23 class ToolbarBackend {
24 public:
25         /// The special toolbar actions
26         enum  ItemType {
27                 /// adds space between buttons in the toolbar
28                 SEPARATOR = -3,
29                 /// a special combox insead of a button
30                 LAYOUTS = -2,
31                 /// begin a new line of button (not working)
32                 NEWLINE = -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         /// a toolbar
42         struct Toolbar {
43                 /// toolbar UI name
44                 string name;
45                 /// toolbar contents
46                 Items items;
47         };
48
49         typedef std::vector<Toolbar> Toolbars;
50
51         typedef Items::const_iterator item_iterator;
52
53         ToolbarBackend();
54
55         /// iterator for all toolbars
56         Toolbars::const_iterator begin() const {
57                 return toolbars.begin();
58         }
59
60         Toolbars::const_iterator end() const {
61                 return toolbars.end();
62         }
63
64         /// read a toolbar from the file
65         void read(LyXLex &);
66
67         /// return a full path of an XPM for the given action
68         static string const getIcon(int action);
69
70 private:
71         /// add the given lfun with tooltip if relevant
72         void add(Toolbar & tb, int, string const & tooltip = string());
73
74         /// add the given lfun with tooltip if relevant
75         void add(Toolbar & tb, string const &, string const & tooltip);
76
77         /// all the toolbars
78         Toolbars toolbars;
79 };
80
81 /// The global instance
82 extern ToolbarBackend toolbarbackend;
83
84
85 #endif // TOOLBAR_BACKEND_H