]> git.lyx.org Git - lyx.git/blob - src/frontends/Toolbar.C
remove LFUN_TOOLBAR_PUSH
[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::update()
57 {
58         pimpl_->update();
59 }
60
61
62
63 void Toolbar::setLayout(string const & layout)
64 {
65         pimpl_->setLayout(layout);
66 }
67
68
69 bool Toolbar::updateLayoutList(int textclass)
70 {
71         // update the layout display
72         if (last_textclass_ != textclass) {
73                 pimpl_->updateLayoutList(true);
74                 last_textclass_ = textclass;
75                 return true;
76         } else {
77                 pimpl_->updateLayoutList(false);
78                 return false;
79         }
80 }
81
82
83 void Toolbar::openLayoutList()
84 {
85         pimpl_->openLayoutList();
86 }
87
88
89 void Toolbar::clearLayoutList()
90 {
91         pimpl_->clearLayoutList();
92 }
93
94
95 void Toolbar::add(string const & func, bool doclean)
96 {
97         int const tf = lyxaction.LookupFunc(func);
98
99         if (tf == -1) {
100                 lyxerr << "Toolbar::add: no LyX command called`"
101                        << func << "'exists!" << endl;
102         } else {
103                 pimpl_->add(tf, doclean);
104         }
105 }