]> git.lyx.org Git - features.git/blob - src/frontends/Toolbar.C
*duck*
[features.git] / src / frontends / Toolbar.C
1 /**
2  * \file Toolbar.C
3  * Copyright 1995-2002 the LyX Team
4  * Read the file COPYING
5  *
6  * \author Lars Gullik Bjønnes <larsbj@lyx.org>
7  */
8
9 #include <config.h>
10
11 #ifdef __GNUG__
12 #pragma implementation "Toolbar.h"
13 #endif
14
15 #include "Toolbar.h"
16 #include "Toolbar_pimpl.h"
17 #include "debug.h"
18 #include "LyXAction.h"
19
20 using std::endl;
21
22 extern LyXAction lyxaction;
23
24
25 Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
26         : last_textclass_(-1)
27 {
28         pimpl_ = new Pimpl(o, x, y);
29
30         pimpl_->reset();
31
32         // extracts the toolbar actions from tbd
33         for (ToolbarDefaults::const_iterator cit = tbd.begin();
34              cit != tbd.end(); ++cit) {
35                 pimpl_->add((*cit));
36                 lyxerr[Debug::GUI] << "tool action: "
37                                        << (*cit) << endl;
38         }
39 }
40
41
42 Toolbar::~Toolbar()
43 {
44         delete pimpl_;
45 }
46
47
48 void Toolbar::set(bool doingmain)
49 {
50         pimpl_->set(doingmain);
51 }
52
53
54 void Toolbar::activate()
55 {
56         pimpl_->activate();
57 }
58
59
60 void Toolbar::deactivate()
61 {
62         pimpl_->deactivate();
63 }
64
65
66 void Toolbar::update()
67 {
68         pimpl_->update();
69 }
70
71
72
73 void Toolbar::setLayout(string const & layout)
74 {
75         pimpl_->setLayout(layout);
76 }
77
78
79 bool Toolbar::updateLayoutList(int textclass)
80 {
81         // update the layout display
82         if (last_textclass_ != textclass) {
83                 pimpl_->updateLayoutList(true);
84                 last_textclass_ = textclass;
85                 return true;
86         } else {
87                 pimpl_->updateLayoutList(false);
88                 return false;
89         }
90 }
91
92
93 void Toolbar::openLayoutList()
94 {
95         pimpl_->openLayoutList();
96 }
97
98
99 void Toolbar::clearLayoutList()
100 {
101         pimpl_->clearLayoutList();
102 }
103
104
105 void Toolbar::push(int nth)
106 {
107         pimpl_->push(nth);
108 }
109
110
111 void Toolbar::add(string const & func, bool doclean)
112 {
113         int const tf = lyxaction.LookupFunc(func);
114
115         if (tf == -1) {
116                 lyxerr << "Toolbar::add: no LyX command called`"
117                        << func << "'exists!" << endl;
118         } else {
119                 pimpl_->add(tf, doclean);
120         }
121 }