2002-06-12 02:54:19 +00:00
|
|
|
|
/**
|
|
|
|
|
* \file Toolbar.C
|
|
|
|
|
* Copyright 1995-2002 the LyX Team
|
|
|
|
|
* Read the file COPYING
|
2002-03-21 21:21:28 +00:00
|
|
|
|
*
|
2002-06-12 02:54:19 +00:00
|
|
|
|
* \author Lars Gullik Bj<EFBFBD>nnes <larsbj@lyx.org>
|
|
|
|
|
*/
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
|
|
#ifdef __GNUG__
|
|
|
|
|
#pragma implementation "Toolbar.h"
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
#include "Toolbar.h"
|
2002-06-19 03:54:18 +00:00
|
|
|
|
#include "ToolbarDefaults.h"
|
2000-07-24 13:53:19 +00:00
|
|
|
|
#include "Toolbar_pimpl.h"
|
|
|
|
|
#include "debug.h"
|
|
|
|
|
#include "LyXAction.h"
|
|
|
|
|
|
|
|
|
|
using std::endl;
|
|
|
|
|
|
|
|
|
|
extern LyXAction lyxaction;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Toolbar::Toolbar(LyXView * o, int x, int y, ToolbarDefaults const &tbd)
|
2002-06-18 15:44:30 +00:00
|
|
|
|
: last_textclass_(-1)
|
2000-07-24 13:53:19 +00:00
|
|
|
|
{
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2000-11-21 15:46:13 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
Toolbar::~Toolbar()
|
|
|
|
|
{
|
|
|
|
|
delete pimpl_;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::set(bool doingmain)
|
|
|
|
|
{
|
|
|
|
|
pimpl_->set(doingmain);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::activate()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->activate();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::deactivate()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->deactivate();
|
|
|
|
|
}
|
|
|
|
|
|
2000-08-24 23:10:28 +00:00
|
|
|
|
|
2000-07-24 13:53:19 +00:00
|
|
|
|
void Toolbar::update()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->update();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-03-02 16:39:54 +00:00
|
|
|
|
|
|
|
|
|
void Toolbar::setLayout(string const & layout)
|
2000-08-24 23:10:28 +00:00
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
pimpl_->setLayout(layout);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2002-06-18 15:44:30 +00:00
|
|
|
|
bool Toolbar::updateLayoutList(int textclass)
|
2000-08-24 23:10:28 +00:00
|
|
|
|
{
|
2002-06-18 15:44:30 +00:00
|
|
|
|
// update the layout display
|
|
|
|
|
if (last_textclass_ != textclass) {
|
|
|
|
|
pimpl_->updateLayoutList(true);
|
|
|
|
|
last_textclass_ = textclass;
|
|
|
|
|
return true;
|
|
|
|
|
} else {
|
|
|
|
|
pimpl_->updateLayoutList(false);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
}
|
|
|
|
|
|
2002-03-21 21:21:28 +00:00
|
|
|
|
|
2000-08-24 23:10:28 +00:00
|
|
|
|
void Toolbar::openLayoutList()
|
|
|
|
|
{
|
2000-07-24 13:53:19 +00:00
|
|
|
|
pimpl_->openLayoutList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::clearLayoutList()
|
|
|
|
|
{
|
|
|
|
|
pimpl_->clearLayoutList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::push(int nth)
|
|
|
|
|
{
|
2000-08-24 23:10:28 +00:00
|
|
|
|
pimpl_->push(nth);
|
|
|
|
|
}
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Toolbar::add(string const & func, bool doclean)
|
|
|
|
|
{
|
2000-11-21 15:46:13 +00:00
|
|
|
|
int const tf = lyxaction.LookupFunc(func);
|
2000-07-24 13:53:19 +00:00
|
|
|
|
|
|
|
|
|
if (tf == -1) {
|
|
|
|
|
lyxerr << "Toolbar::add: no LyX command called`"
|
2002-03-21 21:21:28 +00:00
|
|
|
|
<< func << "'exists!" << endl;
|
2000-07-24 13:53:19 +00:00
|
|
|
|
} else {
|
|
|
|
|
pimpl_->add(tf, doclean);
|
|
|
|
|
}
|
|
|
|
|
}
|