2006-03-05 17:24:44 +00:00
|
|
|
/**
|
|
|
|
* \file iconpalette.C
|
|
|
|
* This file is part of LyX, the document processor.
|
|
|
|
* Licence details can be found in the file COPYING.
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*
|
|
|
|
* Full author contact details are available in file CREDITS.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "iconpalette.h"
|
|
|
|
#include "qt_helpers.h"
|
2006-11-19 17:12:33 +00:00
|
|
|
#include "controllers/ControlMath.h" // for find_xpm
|
2006-08-17 08:49:05 +00:00
|
|
|
|
2006-03-05 17:24:44 +00:00
|
|
|
#include <QPixmap>
|
2006-05-08 11:44:37 +00:00
|
|
|
#include <QGridLayout>
|
2006-08-17 08:49:05 +00:00
|
|
|
#include <QPushButton>
|
|
|
|
#include <QToolTip>
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
using std::make_pair;
|
|
|
|
using std::string;
|
|
|
|
using std::vector;
|
|
|
|
|
|
|
|
|
2006-10-21 00:16:43 +00:00
|
|
|
namespace lyx {
|
2006-11-19 17:12:33 +00:00
|
|
|
namespace frontend {
|
2006-10-21 00:16:43 +00:00
|
|
|
|
2006-11-19 17:12:33 +00:00
|
|
|
IconPalette::IconPalette(QWidget * parent, char const ** entries)
|
|
|
|
: QWidget(parent)
|
2006-03-05 17:24:44 +00:00
|
|
|
{
|
2006-11-19 17:12:33 +00:00
|
|
|
QGridLayout * layout_ = new QGridLayout(this);
|
|
|
|
layout_->setSpacing(0);
|
|
|
|
|
|
|
|
int const button_size = 40;
|
|
|
|
for (int i = 0; *entries[i]; ++i) {
|
|
|
|
QPushButton * p = new QPushButton;
|
|
|
|
p->setFixedSize(button_size, button_size);
|
|
|
|
p->setIcon(QPixmap(toqstr(lyx::frontend::find_xpm(entries[i]))));
|
|
|
|
p->setToolTip(toqstr(string("\\") + entries[i]));
|
|
|
|
connect(p, SIGNAL(clicked()), this, SLOT(clicked()));
|
|
|
|
buttons_.push_back(make_pair(p, entries[i]));
|
|
|
|
// put in a grid layout with 5 cols
|
|
|
|
int const row = i/5;
|
|
|
|
layout_->addWidget(p, row, i - 5*row);
|
|
|
|
}
|
2006-03-05 17:24:44 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IconPalette::clicked()
|
|
|
|
{
|
2006-10-22 17:58:09 +00:00
|
|
|
vector<Button>::const_iterator it = buttons_.begin();
|
|
|
|
vector<Button>::const_iterator const end = buttons_.end();
|
2006-03-05 17:24:44 +00:00
|
|
|
for (; it != end; ++it) {
|
|
|
|
if (sender() == it->first) {
|
2006-10-22 17:58:09 +00:00
|
|
|
// emit signal
|
2006-06-30 14:11:50 +00:00
|
|
|
button_clicked(it->second);
|
2006-03-05 17:24:44 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2006-11-19 17:12:33 +00:00
|
|
|
} // namespace frontend
|
2006-10-21 00:16:43 +00:00
|
|
|
} // namespace lyx
|
|
|
|
|
2006-05-18 08:51:12 +00:00
|
|
|
#include "iconpalette_moc.cpp"
|