-/* This file is part of
- * ======================================================
- *
- * LyX, The Document Processor
+/**
+ * \file Toolbar.C
+ * This file is part of LyX, the document processor.
+ * Licence details can be found in the file COPYING.
*
- * Copyright 1995 Matthias Ettrich
- * Copyright 1995-2001 The LyX Team.
+ * \author Lars Gullik Bjønnes
*
- * This file is Copyright 1996-1998
- * Lars Gullik Bjønnes
- *
- * ====================================================== */
-
-// Added pseudo-action handling, asierra 180296
+ * Full author contact details are available in file CREDITS
+ */
#include <config.h>
-#ifdef __GNUG__
-#pragma implementation "Toolbar.h"
-#endif
#include "Toolbar.h"
-#include "Toolbar_pimpl.h"
+#include "ToolbarBackend.h"
#include "debug.h"
#include "LyXAction.h"
using std::endl;
-extern LyXAction lyxaction;
-
-
-Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
+Toolbar::Toolbar()
+ : last_textclass_(-1)
{
- pimpl_ = new Pimpl(o, x, y);
-
- pimpl_->reset();
-
- // extracts the toolbar actions from tbd
- for (ToolbarDefaults::const_iterator cit = tbd.begin();
- cit != tbd.end(); ++cit) {
- pimpl_->add((*cit));
- lyxerr[Debug::GUI] << "tool action: "
- << (*cit) << endl;
- }
}
Toolbar::~Toolbar()
{
- delete pimpl_;
-}
-
-
-void Toolbar::set(bool doingmain)
-{
- pimpl_->set(doingmain);
}
-void Toolbar::activate()
+void Toolbar::init()
{
- pimpl_->activate();
-}
+ // extracts the toolbars from the backend
+ ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
+ ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
-
-void Toolbar::deactivate()
-{
- pimpl_->deactivate();
+ for (; cit != end; ++cit)
+ add(*cit);
}
-void Toolbar::update()
+void Toolbar::update(bool in_math, bool in_table)
{
- pimpl_->update();
-}
-
+ update();
+ // extracts the toolbars from the backend
+ ToolbarBackend::Toolbars::const_iterator cit = toolbarbackend.begin();
+ ToolbarBackend::Toolbars::const_iterator end = toolbarbackend.end();
-void Toolbar::setLayout(string const & layout)
-{
- pimpl_->setLayout(layout);
-}
-
-
-void Toolbar::updateLayoutList(bool force)
-{
- pimpl_->updateLayoutList(force);
-}
-
-
-void Toolbar::openLayoutList()
-{
- pimpl_->openLayoutList();
-}
-
-
-void Toolbar::clearLayoutList()
-{
- pimpl_->clearLayoutList();
-}
-
-
-void Toolbar::push(int nth)
-{
- pimpl_->push(nth);
+ for (; cit != end; ++cit) {
+ if (cit->flags & ToolbarBackend::MATH)
+ displayToolbar(*cit, in_math);
+ else if (cit->flags & ToolbarBackend::TABLE)
+ displayToolbar(*cit, in_table);
+ }
}
-void Toolbar::add(string const & func, bool doclean)
+bool Toolbar::updateLayoutList(int textclass)
{
- int const tf = lyxaction.LookupFunc(func);
-
- if (tf == -1) {
- lyxerr << "Toolbar::add: no LyX command called`"
- << func << "'exists!" << endl;
- } else {
- pimpl_->add(tf, doclean);
- }
+ // update the layout display
+ if (last_textclass_ != textclass) {
+ updateLayoutList();
+ last_textclass_ = textclass;
+ return true;
+ } else
+ return false;
}