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 TQFrame
00035 {
00036         Q_OBJECT
00037   TQ_OBJECT
00038     public:
00039         FontColourButton(TQWidget* parent = 0, const char* name = 0);
00040         void          setDefaultFont();
00041         void          setFont(const TQFont&);
00042         void          setBgColour(const TQColor&);
00043         void          setFgColour(const TQColor&);
00044         bool          defaultFont() const    { return mDefaultFont; }
00045         TQFont         font() const           { return mFont; }
00046         TQColor        bgColour() const       { return mBgColour; }
00047         TQColor        fgColour() const       { return mFgColour; }
00048         virtual void  setReadOnly(bool ro)   { mReadOnly = ro; }
00049         virtual bool  isReadOnly() const     { return mReadOnly; }
00050 
00051     signals:
00052         void          selected();
00053 
00054     protected slots:
00055         void          slotButtonPressed();
00056 
00057     private:
00058         PushButton* mButton;
00059         TQColor      mBgColour, mFgColour;
00060         TQFont       mFont;
00061         TQLineEdit*  mSample;
00062         bool        mDefaultFont;
00063         bool        mReadOnly;
00064 };
00065 
00066 
00067 // Font and colour selection dialog displayed by the push button
00068 class FontColourDlg : public KDialogBase
00069 {
00070         Q_OBJECT
00071   TQ_OBJECT
00072     public:
00073         FontColourDlg(const TQColor& bg, const TQColor& fg, const TQFont&, bool defaultFont,
00074                       const TQString& caption, TQWidget* parent = 0, const char* name = 0);
00075         bool         defaultFont() const   { return mDefaultFont; }
00076         TQFont        font() const          { return mFont; }
00077         TQColor       bgColour() const      { return mBgColour; }
00078         TQColor       fgColour() const      { return mFgColour; }
00079         void         setReadOnly(bool);
00080         bool         isReadOnly() const    { return mReadOnly; }
00081 
00082     protected slots:
00083         virtual void slotOk();
00084 
00085     private:
00086         FontColourChooser* mChooser;
00087         TQColor             mBgColour, mFgColour;
00088         TQFont              mFont;
00089         bool               mDefaultFont;
00090         bool               mReadOnly;
00091 };
00092 
00093 #endif // FONTCOLOURBUTTON_H