]> git.lyx.org Git - features.git/blob - src/frontends/Toolbar.C
1674f5ee7e6102d68ef3fe3983250ca74338a6ee
[features.git] / src / frontends / Toolbar.C
1 /**
2  * \file Toolbar.C
3  * This file is part of LyX, the document processor.
4  * Licence details can be found in the file COPYING.
5  *
6  * \author Lars Gullik Bjønnes
7  *
8  * Full author contact details are available in file CREDITS.
9  */
10
11 #include <config.h>
12
13 #include "Toolbar.h"
14
15 #include "debug.h"
16 #include "LyXAction.h"
17 #include "ToolbarBackend.h"
18
19 using std::string;
20 using std::endl;
21
22 Toolbar::Toolbar()
23         : last_textclass_(-1)
24 {
25 }
26
27
28 Toolbar::~Toolbar()
29 {
30 }
31
32
33 void Toolbar::init()
34 {
35         // extracts the toolbars from the backend
36         ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
37         ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
38
39         for (; cit != end; ++cit)
40                 add(*cit);
41 }
42
43
44 void Toolbar::display(string const & name, bool show)
45 {
46         ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
47         ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
48
49         for (; cit != end; ++cit) {
50                 if (cit->name == name) {
51                         displayToolbar(*cit, show);
52                         return;
53                 }
54         }
55
56         lyxerr[Debug::GUI] << "Toolbar::display: no toolbar named "
57                 << name << endl;
58 }
59
60
61 void Toolbar::update(bool in_math, bool in_table)
62 {
63         update();
64
65         // extracts the toolbars from the backend
66         ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
67         ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
68
69         for (; cit != end; ++cit) {
70                 if (cit->flags & ToolbarBackend::MATH)
71                         displayToolbar(*cit, in_math);
72                 else if (cit->flags & ToolbarBackend::TABLE)
73                         displayToolbar(*cit, in_table);
74         }
75 }
76
77
78 void Toolbar::clearLayoutList()
79 {
80         last_textclass_ = -1;
81 }
82
83
84 bool Toolbar::updateLayoutList(int textclass)
85 {
86         // update the layout display
87         if (last_textclass_ != textclass) {
88                 updateLayoutList();
89                 last_textclass_ = textclass;
90                 return true;
91         } else
92                 return false;
93 }