kalarm
fontcolourbutton.h
Go to the documentation of this file.00001 /* 00002 * fontcolourbutton.h - pushbutton widget to select a font and colour 00003 * Program: kalarm 00004 * Copyright © 2003-2008 by David Jarvie <djarvie@kde.org> 00005 * 00006 * This program is free software; you can redistribute it and/or modify 00007 * it under the terms of the GNU General Public License as published by 00008 * the Free Software Foundation; either version 2 of the License, or 00009 * (at your option) any later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00014 * GNU General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU General Public License along 00017 * with this program; if not, write to the Free Software Foundation, Inc., 00018 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 00019 */ 00020 00021 #ifndef FONTCOLOURBUTTON_H 00022 #define FONTCOLOURBUTTON_H 00023 00024 #include "pushbutton.h" 00025 #include <kdialog.h> 00026 #include <QFont> 00027 #include <QColor> 00028 00029 class FontColourChooser; 00030 00031 00032 class FontColourButton : public PushButton 00033 { 00034 Q_OBJECT 00035 public: 00036 explicit FontColourButton(QWidget* parent = 0); 00037 void setDefaultFont(); 00038 void setFont(const QFont&); 00039 void setBgColour(const QColor& c) { mBgColour = c; } 00040 void setFgColour(const QColor& c) { mFgColour = c; } 00041 bool defaultFont() const { return mDefaultFont; } 00042 QFont font() const { return mFont; } 00043 QColor bgColour() const { return mBgColour; } 00044 QColor fgColour() const { return mFgColour; } 00045 virtual void setReadOnly(bool ro) { mReadOnly = ro; } 00046 virtual bool isReadOnly() const { return mReadOnly; } 00047 00048 signals: 00049 void selected(const QColor& fg, const QColor& bg); 00050 00051 protected slots: 00052 void slotButtonPressed(); 00053 00054 private: 00055 QColor mBgColour, mFgColour; 00056 QFont mFont; 00057 bool mDefaultFont; 00058 bool mReadOnly; 00059 }; 00060 00061 00062 // Font and colour selection dialog displayed by the push button 00063 class FontColourDlg : public KDialog 00064 { 00065 Q_OBJECT 00066 public: 00067 FontColourDlg(const QColor& bg, const QColor& fg, const QFont&, bool defaultFont, 00068 const QString& caption, QWidget* parent = 0); 00069 bool defaultFont() const { return mDefaultFont; } 00070 QFont font() const { return mFont; } 00071 QColor bgColour() const { return mBgColour; } 00072 QColor fgColour() const { return mFgColour; } 00073 void setReadOnly(bool); 00074 bool isReadOnly() const { return mReadOnly; } 00075 00076 protected slots: 00077 virtual void slotOk(); 00078 00079 private: 00080 FontColourChooser* mChooser; 00081 QColor mBgColour, mFgColour; 00082 QFont mFont; 00083 bool mDefaultFont; 00084 bool mReadOnly; 00085 }; 00086 00087 #endif // FONTCOLOURBUTTON_H
KDE 4.2 API Reference