2002-08-30 16:20:27 +00:00
|
|
|
/**
|
|
|
|
* \file iconpalette.C
|
|
|
|
* Copyright 2001 the LyX Team
|
|
|
|
* Read the file COPYING
|
|
|
|
*
|
|
|
|
* \author John Levon
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
2002-09-07 23:28:05 +00:00
|
|
|
#include "debug.h"
|
|
|
|
|
2002-08-30 16:20:27 +00:00
|
|
|
#include "iconpalette.h"
|
|
|
|
|
|
|
|
#include <qlayout.h>
|
|
|
|
#include <qpushbutton.h>
|
|
|
|
#include <qpixmap.h>
|
|
|
|
#include <qtooltip.h>
|
|
|
|
|
2002-09-07 23:28:05 +00:00
|
|
|
using std::endl;
|
|
|
|
|
2002-08-30 16:20:27 +00:00
|
|
|
IconPalette::IconPalette(QWidget * parent, char const * name)
|
|
|
|
: QWidget(parent, name), crow_(0), ccol_(0)
|
|
|
|
{
|
|
|
|
QVBoxLayout * top = new QVBoxLayout(this);
|
|
|
|
QHBoxLayout * row = new QHBoxLayout(top);
|
|
|
|
layout_ = new QGridLayout(row);
|
|
|
|
row->addStretch(0);
|
|
|
|
top->addStretch(0);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IconPalette::add(QPixmap const & pixmap, string name, string tooltip)
|
|
|
|
{
|
|
|
|
QPushButton * p = new QPushButton(this);
|
2002-09-06 01:44:02 +00:00
|
|
|
p->setFixedSize(40, 40);
|
2002-08-30 16:20:27 +00:00
|
|
|
p->setPixmap(pixmap);
|
|
|
|
QToolTip::add(p, tooltip.c_str());
|
|
|
|
layout_->addWidget(p, crow_, ccol_);
|
2002-09-06 01:44:02 +00:00
|
|
|
if (++ccol_ == 5) {
|
2002-08-30 16:20:27 +00:00
|
|
|
ccol_ = 0;
|
|
|
|
++crow_;
|
|
|
|
}
|
2002-09-06 01:44:02 +00:00
|
|
|
resize(5 * 40, crow_ * 40);
|
2002-08-30 16:20:27 +00:00
|
|
|
button_map_[p] = name;
|
|
|
|
connect(p, SIGNAL(clicked()), this, SLOT(clicked()));
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void IconPalette::clicked()
|
|
|
|
{
|
|
|
|
string name = button_map_[(QPushButton*)(sender())];
|
|
|
|
emit button_clicked(name);
|
|
|
|
}
|
2002-09-07 23:28:05 +00:00
|
|
|
|
|
|
|
|
|
|
|
void IconPalette::resizeEvent(QResizeEvent * e)
|
|
|
|
{
|
|
|
|
lyxerr << "resize panel to " << e->size().width() << "," << e->size().height() << endl;
|
|
|
|
}
|