lib Library API Documentation

koFrameButton.cc

00001 /* This file is part of the KDE project 00002 Copyright (c) 1999 Matthias Elter (me@kde.org) 00003 Copyright (c) 2001 Igor Jansen (rm@kde.org) 00004 00005 This library is free software; you can redistribute it and/or 00006 modify it under the terms of the GNU Library General Public 00007 License as published by the Free Software Foundation; either 00008 version 2 of the License, or (at your option) any later version. 00009 00010 This library is distributed in the hope that it will be useful, 00011 but WITHOUT ANY WARRANTY; without even the implied warranty of 00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00013 Library General Public License for more details. 00014 00015 You should have received a copy of the GNU Library General Public License 00016 along with this library; see the file COPYING.LIB. If not, write to 00017 the Free Software Foundation, Inc., 59 Temple Place - Suite 330, 00018 Boston, MA 02111-1307, USA. 00019 */ 00020 00021 #include "koFrameButton.h" 00022 00023 KoFrameButton::KoFrameButton(QWidget *parent, const char *name): 00024 QLabel(parent, name) 00025 { 00026 setAutoResize(true); 00027 setFrameStyle(Panel | Raised); 00028 setLineWidth(1); 00029 setMaximumHeight(8); 00030 mActive = false; 00031 mToggle = false; 00032 } 00033 00034 KoFrameButton::KoFrameButton(const QString &text, QWidget *parent, const char *name): 00035 QLabel(parent, name) 00036 { 00037 setFrameStyle(Panel | Raised); 00038 setLineWidth(1); 00039 setText(text); 00040 setAlignment(AlignHCenter | AlignVCenter); 00041 mActive = false; 00042 mToggle = false; 00043 } 00044 00045 KoFrameButton::KoFrameButton(const QPixmap &pixmap, QWidget *parent, const char *name): 00046 QLabel(parent, name) 00047 { 00048 setFrameStyle(Panel | Raised); 00049 setLineWidth(1); 00050 setPixmap(pixmap); 00051 mActive = false; 00052 mToggle = false; 00053 } 00054 00055 void KoFrameButton::mousePressEvent(QMouseEvent *) 00056 { 00057 setFrameStyle(Panel | Sunken); 00058 } 00059 00060 void KoFrameButton::mouseReleaseEvent(QMouseEvent *) 00061 { 00062 if(mToggle) 00063 { 00064 mActive = !mActive; 00065 if(mActive) 00066 setFrameStyle(Panel | Sunken); 00067 else 00068 setFrameStyle(Panel | Raised); 00069 } 00070 else 00071 setFrameStyle(Panel | Raised); 00072 00073 emit clicked(); 00074 emit clicked(mText); 00075 } 00076 00077 void KoFrameButton::setOn(bool v) 00078 { 00079 if(!mToggle) 00080 return; 00081 00082 mActive = v; 00083 00084 if(mActive) 00085 setFrameStyle(Panel | Sunken); 00086 else 00087 setFrameStyle(Panel | Raised); 00088 } 00089 00090 00091 void KoFrameButton::setToggleButton(bool v) 00092 { 00093 mToggle = v; 00094 } 00095 00096 void KoFrameButton::setText(const QString &t) 00097 { 00098 mText = t; 00099 QLabel::setText(t); 00100 } 00101 00102 #include "koFrameButton.moc"
KDE Logo
This file is part of the documentation for lib Library Version 1.3.5.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Nov 17 06:54:15 2004 by doxygen 1.3.7 written by Dimitri van Heesch, © 1997-2003