kalarm

fontcolourbutton.h

00001 /*
00002  *  fontcolourbutton.h  -  pushbutton widget to select a font and colour
00003  *  Program:  kalarm
00004  *  Copyright © 2003,2007 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 <tqfont.h>
00025 #include <tqcolor.h>
00026 #include <tqframe.h>
00027 #include <kdialogbase.h>
00028 
00029 class TQLineEdit;
00030 class FontColourChooser;
00031 class PushButton;
00032 
00033 
00034 class FontColourButton : public QFrame
00035 {
00036         Q_OBJECT
00037     public:
00038         FontColourButton(TQWidget* parent = 0, const char* name = 0);
00039         void          setDefaultFont();
00040         void          setFont(const TQFont&);
00041         void          setBgColour(const TQColor&);
00042         void          setFgColour(const TQColor&);
00043         bool          defaultFont() const    { return mDefaultFont; }
00044         TQFont         font() const           { return mFont; }
00045         TQColor        bgColour() const       { return mBgColour; }
00046         TQColor        fgColour() const       { return mFgColour; }
00047         virtual void  setReadOnly(bool ro)   { mReadOnly = ro; }
00048         virtual bool  isReadOnly() const     { return mReadOnly; }
00049 
00050     signals:
00051         void          selected();
00052 
00053     protected slots:
00054         void          slotButtonPressed();
00055 
00056     private:
00057         PushButton* mButton;
00058         TQColor      mBgColour, mFgColour;
00059         TQFont       mFont;
00060         TQLineEdit*  mSample;
00061         bool        mDefaultFont;
00062         bool        mReadOnly;
00063 };
00064 
00065 
00066 // Font and colour selection dialog displayed by the push button
00067 class FontColourDlg : public KDialogBase
00068 {
00069         Q_OBJECT
00070     public:
00071         FontColourDlg(const TQColor& bg, const TQColor& fg, const TQFont&, bool defaultFont,
00072                       const TQString& caption, TQWidget* parent = 0, const char* name = 0);
00073         bool         defaultFont() const   { return mDefaultFont; }
00074         TQFont        font() const          { return mFont; }
00075         TQColor       bgColour() const      { return mBgColour; }
00076         TQColor       fgColour() const      { return mFgColour; }
00077         void         setReadOnly(bool);
00078         bool         isReadOnly() const    { return mReadOnly; }
00079 
00080     protected slots:
00081         virtual void slotOk();
00082 
00083     private:
00084         FontColourChooser* mChooser;
00085         TQColor             mBgColour, mFgColour;
00086         TQFont              mFont;
00087         bool               mDefaultFont;
00088         bool               mReadOnly;
00089 };
00090 
00091 #endif // FONTCOLOURBUTTON_H