/*************************************************************************** * Copyright (C) 2004 by Johan Maes - ON4QZ * * on4qz@telenet.be * * http://users.telenet.be/on4qz * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * * (at your option) any later version. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * * GNU General Public License for more details. * * * * You should have received a copy of the GNU General Public License * * along with this program; if not, write to the * * Free Software Foundation, Inc., * * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * ***************************************************************************/ #include "fgbgbutton.h" static const char* const image_data[] = { "56 56 5 1", "# c #313031", "c c #5a595a", "a c #838183", ". c #c5c2c5", "b c #ffffff", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", ".....................................#..................", "....................................##aaaaa.............", "...................................#######aa............", "..................................#########aa...........", "...................................#########a...........", "...........bbbbbbbbbbbbbbbbbbbbbbb..##...###a...........", "...........bbbbbbbbbbbbbbbbbbbbbbc...#...###a...........", "...........bbbbbbbbbbbbbbbbbbbbbbc.......###aaa.........", "...........bbbbbbbbbbbbbbbbbbbbbbc.....#######a.........", "...........bbbbbbbbbbbbbbbbbbbbbbc......#####a..........", "...........bbbbbbbbbbbbbbbbbbbbbbc.......###a...........", "...........bbbbbbbbbbbbbbbbbbbbbbc........#a............", "...........bbbbbbbbbbbbbbbbbbbbbbc......................", "...........bbbbbbbbbbbbbbbbbbbbbbc......................", "...........bbbbbbbbbbbbbbbbbbbbbbc......................", "...........bbbbbbbbbbbbbbbbbbbbbbcbbbbbbbbbb............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bbbbbbbbbbbbbbbbbbbbbbc#########a............", "...........bcccccccccccccccccccccc#########a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................b#####################a............", ".....................baaaaaaaaaaaaaaaaaaaaaa............", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................", "........................................................"}; fgbgButton::fgbgButton(QWidget *parent, const char *name) : QFrame(parent, name),imageData( (const char **) image_data ) { setMinimumSize( QSize( 58, 58 ) ); setMaximumSize( QSize( 58, 58 ) ); setPaletteBackgroundPixmap( imageData ); setFrameShape( QFrame::StyledPanel ); setFrameShadow( QFrame::Sunken ); setLineWidth( 2 ); } fgbgButton::~fgbgButton() { } void fgbgButton::mouseDoubleClickEvent(QMouseEvent *) { QColor temp; temp=fgColor; fgColor=bgColor; bgColor=temp; updateColors(); } void fgbgButton::setForegroundColor(QColor c) { fgColor=c; updateColors(); } void fgbgButton::setBackgroundColor(QColor c) { bgColor=c; updateColors(); } QColor fgbgButton::getForegroundColor() { return fgColor; } QColor fgbgButton::getBackgroundColor() { return bgColor; } void fgbgButton::updateColors() { QPainter p(&imageData); // draw background rectangle p.setBrush(bgColor); p.setPen(bgColor); p.drawRect(22,22,21,21); p.setBrush(fgColor); p.setPen(fgColor); p.drawRect(12,12,21,21); setPaletteBackgroundPixmap( imageData ); repaint(FALSE); }