]> git.lyx.org Git - lyx.git/blob - src/frontends/qt2/iconpalette.C
some math fixes
[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 "debug.h"
12  
13 #include "iconpalette.h"
14
15 #include <qlayout.h>
16 #include <qpushbutton.h>
17 #include <qpixmap.h>
18 #include <qtooltip.h>
19
20 using std::endl;
21  
22 IconPalette::IconPalette(QWidget * parent, char const * name)
23         : QWidget(parent, name), crow_(0), ccol_(0)
24 {
25         QVBoxLayout * top = new QVBoxLayout(this);
26         QHBoxLayout * row = new QHBoxLayout(top);
27         layout_ = new QGridLayout(row);
28         row->addStretch(0);
29         top->addStretch(0);
30 }
31
32
33 void IconPalette::add(QPixmap const & pixmap, string name, string tooltip)
34 {
35         QPushButton * p = new QPushButton(this);
36         p->setFixedSize(40, 40);
37         p->setPixmap(pixmap);
38         QToolTip::add(p, tooltip.c_str());
39         layout_->addWidget(p, crow_, ccol_);
40         if (++ccol_ == 5) {
41                 ccol_ = 0;
42                 ++crow_;
43         }
44         resize(5 * 40, crow_ * 40);
45         button_map_[p] = name;
46         connect(p, SIGNAL(clicked()), this, SLOT(clicked())); 
47 }
48
49
50 void IconPalette::clicked()
51 {
52         string name = button_map_[(QPushButton*)(sender())];
53         emit button_clicked(name);
54 }
55
56
57 void IconPalette::resizeEvent(QResizeEvent * e)
58 {
59         lyxerr << "resize panel to " << e->size().width() << "," << e->size().height() << endl;
60 }