]> git.lyx.org Git - lyx.git/blob - src/frontends/Toolbar.C
Create a grfx::Loader class and so move large chunks of code out of
[lyx.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 "ToolbarDefaults.h"
17 #include "Toolbar_pimpl.h"
18 #include "debug.h"
19 #include "LyXAction.h"
20
21 using std::endl;
22
23 extern LyXAction lyxaction;
24
25
26 Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
27         : last_textclass_(-1)
28 {
29         pimpl_ = new Pimpl(o, x, y);
30
31         pimpl_->reset();
32
33         // extracts the toolbar actions from tbd
34         for (ToolbarDefaults::const_iterator cit = tbd.begin();
35              cit != tbd.end(); ++cit) {
36                 pimpl_->add((*cit));
37                 lyxerr[Debug::GUI] << "tool action: "
38                                        << (*cit) << endl;
39         }
40 }
41
42
43 Toolbar::~Toolbar()
44 {
45         delete pimpl_;
46 }
47
48
49 void Toolbar::set(bool doingmain)
50 {
51         pimpl_->set(doingmain);
52 }
53
54
55 void Toolbar::activate()
56 {
57         pimpl_->activate();
58 }
59
60
61 void Toolbar::deactivate()
62 {
63         pimpl_->deactivate();
64 }
65
66
67 void Toolbar::update()
68 {
69         pimpl_->update();
70 }
71
72
73
74 void Toolbar::setLayout(string const & layout)
75 {
76         pimpl_->setLayout(layout);
77 }
78
79
80 bool Toolbar::updateLayoutList(int textclass)
81 {
82         // update the layout display
83         if (last_textclass_ != textclass) {
84                 pimpl_->updateLayoutList(true);
85                 last_textclass_ = textclass;
86                 return true;
87         } else {
88                 pimpl_->updateLayoutList(false);
89                 return false;
90         }
91 }
92
93
94 void Toolbar::openLayoutList()
95 {
96         pimpl_->openLayoutList();
97 }
98
99
100 void Toolbar::clearLayoutList()
101 {
102         pimpl_->clearLayoutList();
103 }
104
105
106 void Toolbar::push(int nth)
107 {
108         pimpl_->push(nth);
109 }
110
111
112 void Toolbar::add(string const & func, bool doclean)
113 {
114         int const tf = lyxaction.LookupFunc(func);
115
116         if (tf == -1) {
117                 lyxerr << "Toolbar::add: no LyX command called`"
118                        << func << "'exists!" << endl;
119         } else {
120                 pimpl_->add(tf, doclean);
121         }
122 }