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 (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();
153 lyx::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 lyx::to_utf8(_()) is correct
169 if (lyx::to_utf8(_(itname)) == name) {
170 FuncRequest const func(LFUN_LAYOUT, itname,
176 lyxerr << "ERROR (layoutSelected): layout not found!"