3 * This file is part of LyX, the document processor.
4 * Licence details can be found in the file COPYING.
6 * \author Lars Gullik Bjønnes
7 * \author Angus Leeming
9 * Full author contact details are available in file CREDITS.
17 #include "bufferparams.h"
19 #include "funcrequest.h"
20 #include "FuncStatus.h"
23 #include "lyxtextclass.h"
30 Toolbars::Toolbars(LyXView & owner)
39 // extracts the toolbars from the backend
40 ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
41 ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
43 for (; cit != end; ++cit)
48 void Toolbars::display(string const & name, bool show)
50 ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
51 ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
53 for (; cit != end; ++cit) {
54 if (cit->name == name) {
55 displayToolbar(*cit, show);
60 lyxerr[Debug::GUI] << "Toolbar::display: no toolbar named "
65 void Toolbars::update(bool in_math, bool in_table)
69 // extracts the toolbars from the backend
70 ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
71 ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
73 for (; cit != end; ++cit) {
74 if (cit->flags & ToolbarBackend::MATH)
75 displayToolbar(*cit, in_math);
76 else if (cit->flags & ToolbarBackend::TABLE)
77 displayToolbar(*cit, in_table);
82 void Toolbars::setLayout(string const & layout)
89 bool Toolbars::updateLayoutList(int textclass)
91 // update the layout display
92 if (last_textclass_ != textclass) {
95 last_textclass_ = textclass;
102 void Toolbars::openLayoutList()
109 void Toolbars::clearLayoutList()
111 last_textclass_ = -1;
117 void Toolbars::add(ToolbarBackend::Toolbar const & tbb)
119 ToolbarPtr tb_ptr = make_toolbar(tbb, owner_);
120 toolbars_[tbb.name] = tb_ptr;
122 if (tbb.flags & ToolbarBackend::ON)
127 if (tb_ptr->layout())
128 layout_ = tb_ptr->layout();
132 void Toolbars::displayToolbar(ToolbarBackend::Toolbar const & tbb,
135 ToolbarsMap::iterator it = toolbars_.find(tbb.name);
136 BOOST_ASSERT(it != toolbars_.end());
139 it->second->show(true);
141 it->second->hide(true);
145 void Toolbars::update()
147 ToolbarsMap::const_iterator it = toolbars_.begin();
148 ToolbarsMap::const_iterator const end = toolbars_.end();
149 for (; it != end; ++it)
150 it->second->update();
152 bool const enable = owner_.getLyXFunc().
153 getStatus(FuncRequest(LFUN_LAYOUT)).enabled();
156 layout_->setEnabled(enable);
160 void layoutSelected(LyXView & lv, string const & name)
162 LyXTextClass const & tc = lv.buffer()->params().getLyXTextClass();
164 LyXTextClass::const_iterator it = tc.begin();
165 LyXTextClass::const_iterator const end = tc.end();
166 for (; it != end; ++it) {
167 string const & itname = (*it)->name();
168 // Yes, the _() is correct
169 if (_(itname) == name) {
170 FuncRequest const func(LFUN_LAYOUT, itname,
172 lv.getLyXFunc().dispatch(func);
176 lyxerr << "ERROR (layoutSelected): layout not found!"