]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/iconpalette.C
some math dialog non-improvements
[lyx.git] / src / frontends / qt2 / iconpalette.C
1 /**
2  * \file iconpalette.C
3  * Copyright 2001 the LyX Team
4  * Read the file COPYING
5  *
6  * \author John Levon
7  */
8
9 #include <config.h>
10
11 #include "iconpalette.h"
12
13 #include <qlayout.h>
14 #include <qpushbutton.h>
15 #include <qpixmap.h>
16 #include <qtooltip.h>
17
18 IconPalette::IconPalette(QWidget * parent, char const * name)
19         : QWidget(parent, name), crow_(0), ccol_(0)
20 {
21         QVBoxLayout * top = new QVBoxLayout(this);
22         QHBoxLayout * row = new QHBoxLayout(top);
23         layout_ = new QGridLayout(row);
24         row->addStretch(0);
25         top->addStretch(0);
26 }
27
28
29 void IconPalette::add(QPixmap const & pixmap, string name, string tooltip)
30 {
31         QPushButton * p = new QPushButton(this);
32         p->setFixedSize(40, 40);
33         p->setPixmap(pixmap);
34         QToolTip::add(p, tooltip.c_str());
35         layout_->addWidget(p, crow_, ccol_);
36         if (++ccol_ == 5) {
37                 ccol_ = 0;
38                 ++crow_;
39         }
40         resize(5 * 40, crow_ * 40);
41         button_map_[p] = name;
42         connect(p, SIGNAL(clicked()), this, SLOT(clicked())); 
43 }
44
45
46 void IconPalette::clicked()
47 {
48         string name = button_map_[(QPushButton*)(sender())];
49         emit button_clicked(name);
50 }