custom buttons
[colorflood] / colorflood / src / colorbutton.cpp
1 /*
2   Copyright 2010 Serge Ziryukin <ftrvxmtrx@gmail.com>
3
4   This program is free software; you can redistribute it and/or modify
5   it under the terms of the GNU General Public License as published by
6   the Free Software Foundation; version 2 of the License.
7
8   This program is distributed in the hope that it will be useful,
9   but WITHOUT ANY WARRANTY; without even the implied warranty of
10   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
11   GNU General Public License for more details.
12 */
13
14 #include <QPainter>
15 #include "colorbutton.hpp"
16 #include "colorscheme.hpp"
17
18 ColorButton::ColorButton (QWidget *parent, int brush)
19     : QPushButton(parent),
20       brush(brush)
21 {
22     setFixedSize(64, 64);
23 }
24
25 void ColorButton::paintEvent (QPaintEvent * /* event */)
26 {
27     QPainter painter;
28     painter.begin(this);
29
30     const QVector<QBrush> &scheme = ColorScheme::instance().getScheme();
31     painter.fillRect(0, 0, 64, 64, scheme.at(brush));
32
33     painter.end();
34 }