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"
33 Toolbars::Toolbars(LyXView & owner)
42 // extracts the toolbars from the backend
43 ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
44 ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
46 for (; cit != end; ++cit)
51 void Toolbars::display(string const & name, bool show)
53 ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
54 ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
56 for (; cit != end; ++cit) {
57 if (cit->name == name) {
58 displayToolbar(*cit, show);
63 lyxerr[Debug::GUI] << "Toolbar::display: no toolbar named "
68 void Toolbars::update(bool in_math, bool in_table, bool review)
72 // extracts the toolbars from the backend
73 ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
74 ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
76 for (; cit != end; ++cit) {
77 if (cit->flags & ToolbarBackend::MATH)
78 displayToolbar(*cit, in_math);
79 else if (cit->flags & ToolbarBackend::TABLE)
80 displayToolbar(*cit, in_table);
81 else if (cit->flags & ToolbarBackend::REVIEW)
82 displayToolbar(*cit, review);
87 void Toolbars::setLayout(string const & layout)
94 bool Toolbars::updateLayoutList(int textclass)
96 // update the layout display
97 if (last_textclass_ != textclass) {
100 last_textclass_ = textclass;
107 void Toolbars::openLayoutList()
114 void Toolbars::clearLayoutList()
116 last_textclass_ = -1;
122 void Toolbars::add(ToolbarBackend::Toolbar const & tbb)
124 ToolbarPtr tb_ptr = owner_.makeToolbar(tbb);
125 toolbars_[tbb.name] = tb_ptr;
127 if (tbb.flags & ToolbarBackend::ON)
132 if (tb_ptr->layout())
133 layout_ = tb_ptr->layout();
137 void Toolbars::displayToolbar(ToolbarBackend::Toolbar const & tbb,
140 ToolbarsMap::iterator it = toolbars_.find(tbb.name);
141 BOOST_ASSERT(it != toolbars_.end());
144 it->second->show(true);
146 it->second->hide(true);
150 void Toolbars::update()
152 ToolbarsMap::const_iterator it = toolbars_.begin();
153 ToolbarsMap::const_iterator const end = toolbars_.end();
154 for (; it != end; ++it)
155 it->second->update();
158 lyx::getStatus(FuncRequest(LFUN_LAYOUT)).enabled();
161 layout_->setEnabled(enable);
165 void layoutSelected(LyXView & lv, string const & name)
167 LyXTextClass const & tc = lv.buffer()->params().getLyXTextClass();
169 LyXTextClass::const_iterator it = tc.begin();
170 LyXTextClass::const_iterator const end = tc.end();
171 for (; it != end; ++it) {
172 string const & itname = (*it)->name();
173 // Yes, the lyx::to_utf8(_()) is correct
174 if (lyx::to_utf8(_(itname)) == name) {
175 FuncRequest const func(LFUN_LAYOUT, itname,
181 lyxerr << "ERROR (layoutSelected): layout not found!"