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