]> git.lyx.org Git - lyx.git/blob - src/frontends/Toolbar.C
namespace grfx -> lyx::graphics
[lyx.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
14 #include "Toolbar.h"
15 #include "ToolbarBackend.h"
16 #include "Toolbar_pimpl.h"
17 #include "debug.h"
18 #include "LyXAction.h"
19
20 using std::endl;
21
22 Toolbar::Toolbar(LyXView * o, int x, int y)
23         : last_textclass_(-1)
24 {
25         pimpl_ = new Pimpl(o, x, y);
26
27         // extracts the toolbars from the backend
28         ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
29         ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
30
31         for (; cit != end; ++cit)
32                 pimpl_->add(*cit);
33 }
34
35
36 Toolbar::~Toolbar()
37 {
38         delete pimpl_;
39 }
40
41
42 void Toolbar::update(bool in_math, bool in_table)
43 {
44         pimpl_->update();
45
46         // extracts the toolbars from the backend
47         ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
48         ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
49
50         for (; cit != end; ++cit) {
51                 if (cit->flags & ToolbarBackend::MATH)
52                         pimpl_->displayToolbar(*cit, in_math);
53                 else if (cit->flags & ToolbarBackend::TABLE)
54                         pimpl_->displayToolbar(*cit, in_table);
55         }
56 }
57
58
59
60 void Toolbar::setLayout(string const & layout)
61 {
62         pimpl_->setLayout(layout);
63 }
64
65
66 bool Toolbar::updateLayoutList(int textclass)
67 {
68         // update the layout display
69         if (last_textclass_ != textclass) {
70                 pimpl_->updateLayoutList(true);
71                 last_textclass_ = textclass;
72                 return true;
73         } else {
74                 pimpl_->updateLayoutList(false);
75                 return false;
76         }
77 }
78
79
80 void Toolbar::openLayoutList()
81 {
82         pimpl_->openLayoutList();
83 }
84
85
86 void Toolbar::clearLayoutList()
87 {
88         pimpl_->clearLayoutList();
89 }