]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/iconpalette.C
Add basic bits of Qt's math panel. Hacked together (no MVC yet) but
[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->addLayout(layout_);
25         row->addStretch(0);
26         //top->addLayout(row);
27         top->addStretch(0);
28 }
29
30
31 void IconPalette::add(QPixmap const & pixmap, string name, string tooltip)
32 {
33         QPushButton * p = new QPushButton(this);
34         p->setFixedSize(35, 35);
35         p->setPixmap(pixmap);
36         QToolTip::add(p, tooltip.c_str());
37         layout_->addWidget(p, crow_, ccol_);
38         if (++ccol_ == 6) {
39                 ccol_ = 0;
40                 ++crow_;
41         }
42         button_map_[p] = name;
43         connect(p, SIGNAL(clicked()), this, SLOT(clicked())); 
44 }
45
46
47 void IconPalette::clicked()
48 {
49         string name = button_map_[(QPushButton*)(sender())];
50         emit button_clicked(name);
51 }