]> git.lyx.org Git - lyx.git/blob - src/ToolbarBackend.h
952d2649cf5942410bab910910620451734a623f
[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         /// possibly display types
42         enum DisplayType {
43                 OFF, //< never shown
44                 ON, //< always shown
45                 MATH, //< shown when in math
46                 TABLE //< shown when in table
47         };
48
49         /// a toolbar
50         struct Toolbar {
51                 /// toolbar UI name
52                 string name;
53                 /// toolbar contents
54                 Items items;
55                 /// display type
56                 DisplayType display_type;
57         };
58
59         typedef std::vector<Toolbar> Toolbars;
60
61         typedef Items::const_iterator item_iterator;
62
63         ToolbarBackend();
64
65         /// iterator for all toolbars
66         Toolbars::const_iterator begin() const {
67                 return toolbars.begin();
68         }
69
70         Toolbars::const_iterator end() const {
71                 return toolbars.end();
72         }
73
74         /// read a toolbar from the file
75         void read(LyXLex &);
76
77         /// return a full path of an XPM for the given action
78         static string const getIcon(int action);
79
80 private:
81         /// add the given lfun with tooltip if relevant
82         void add(Toolbar & tb, int, string const & tooltip = string());
83
84         /// add the given lfun with tooltip if relevant
85         void add(Toolbar & tb, string const &, string const & tooltip);
86
87         /// all the toolbars
88         Toolbars toolbars;
89 };
90
91 /// The global instance
92 extern ToolbarBackend toolbarbackend;
93
94
95 #endif // TOOLBAR_BACKEND_H