kdeui Library API Documentation

kfontdialog.h

00001 /*
00002     $Id: kfontdialog.h,v 1.61 2002/09/11 02:18:25 orlovich Exp $
00003 
00004     Requires the Qt widget libraries, available at no cost at
00005     http://www.troll.no
00006 
00007     Copyright (C) 1997 Bernd Johannes Wuebben <wuebben@kde.org>
00008     Copyright (c) 1999 Preston Brown <pbrown@kde.org>
00009     Copyright (c) 1999 Mario Weilguni <mweilguni@kde.org>
00010 
00011     This library is free software; you can redistribute it and/or
00012     modify it under the terms of the GNU Library General Public
00013     License as published by the Free Software Foundation; either
00014     version 2 of the License, or (at your option) any later version.
00015 
00016     This library is distributed in the hope that it will be useful,
00017     but WITHOUT ANY WARRANTY; without even the implied warranty of
00018     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019     Library General Public License for more details.
00020 
00021     You should have received a copy of the GNU Library General Public License
00022     along with this library; see the file COPYING.LIB.  If not, write to
00023     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00024     Boston, MA 02111-1307, USA.
00025 */
00026 #ifndef _K_FONT_DIALOG_H_
00027 #define _K_FONT_DIALOG_H_
00028 
00029 #include <qlineedit.h>
00030 #include <qbutton.h>
00031 #include <kdialogbase.h>
00032 
00033 class QComboBox;
00034 class QCheckBox;
00035 class QFont;
00036 class QGroupBox;
00037 class QLabel;
00038 class QStringList;
00039 class KListBox;
00040 class KIntNumInput;
00051 class KFontChooser : public QWidget
00052 {
00053   Q_OBJECT
00054 
00055 public:
00061   enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00062 
00068   enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00069 
00102   KFontChooser(QWidget *parent = 0L, const char *name = 0L,
00103            bool onlyFixed = false,
00104            const QStringList &fontList = QStringList(),
00105            bool makeFrame = true, int visibleListSize=8,
00106                bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L );
00107 
00111   virtual ~KFontChooser();
00112 
00124   void enableColumn( int column, bool state );
00125 
00133   void setFont( const QFont &font, bool onlyFixed = false );
00134 
00139   int fontDiffFlags();
00140 
00144   QFont font() const { return selFont; }
00145 
00149   void setColor( const QColor & col );
00150 
00154   QColor color() const;
00155 
00159   void setBackgroundColor( const QColor & col );
00160 
00164   QColor backgroundColor() const;
00165 
00172   void setSizeIsRelative( QButton::ToggleState relative );
00173 
00178   QButton::ToggleState sizeIsRelative() const;
00179 
00180 
00184   QString sampleText() const { return sampleEdit->text(); }
00185 
00196   void setSampleText( const QString &text )
00197   {
00198     sampleEdit->setText( text );
00199   }
00200 
00208   static QString getXLFD( const QFont &theFont )
00209     { return theFont.rawName(); }
00210 
00222   enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00223 
00231   static void getFontList( QStringList &list, uint fontListCriteria);
00232 
00236   virtual QSize sizeHint( void ) const;
00237 
00238 signals:
00242   void fontSelected( const QFont &font );
00243 
00244 private slots:
00245   void toggled_checkbox();
00246   void family_chosen_slot(const QString&);
00247   void size_chosen_slot(const QString&);
00248   void style_chosen_slot(const QString&);
00249   void displaySample(const QFont &font);
00250   void showXLFDArea(bool);
00251   void size_value_slot(int);
00252 private:
00253   void fillFamilyListBox(bool onlyFixedFonts = false);
00254   void fillSizeList();
00255   // This one must be static since getFontList( QStringList, char*) is so
00256   static void addFont( QStringList &list, const char *xfont );
00257 
00258   void setupDisplay();
00259 
00260   // pointer to an optinally supplied list of fonts to
00261   // inserted into the fontdialog font-family combo-box
00262   QStringList  fontList;
00263 
00264   KIntNumInput *sizeOfFont;
00265 
00266   QLineEdit    *sampleEdit;
00267   QLineEdit    *xlfdEdit;
00268 
00269   QLabel       *familyLabel;
00270   QLabel       *styleLabel;
00271   QCheckBox    *familyCheckbox;
00272   QCheckBox    *styleCheckbox;
00273   QCheckBox    *sizeCheckbox;
00274   QLabel       *sizeLabel;
00275   KListBox     *familyListBox;
00276   KListBox     *styleListBox;
00277   KListBox     *sizeListBox;
00278   QComboBox    *charsetsCombo;
00279   QCheckBox    *sizeIsRelativeCheckBox;
00280 
00281   QFont        selFont;
00282 
00283   QString      selectedStyle;
00284   int          selectedSize;
00285   QMap<QString, QString> currentStyles;
00286 
00287   bool usingFixed;
00288 
00289 protected:
00290   virtual void virtual_hook( int id, void* data );
00291 private:
00292   class KFontChooserPrivate;
00293   KFontChooserPrivate *d;
00294 };
00295 
00319 class KFontDialog : public KDialogBase  {
00320     Q_OBJECT
00321 
00322 public:
00345   KFontDialog( QWidget *parent = 0L, const char *name = 0,
00346            bool onlyFixed = false, bool modal = false,
00347            const QStringList &fontlist = QStringList(),
00348            bool makeFrame = true, bool diff = false,
00349                QButton::ToggleState *sizeIsRelativeState = 0L );
00350 
00358   void setFont( const QFont &font, bool onlyFixed = false )
00359     { chooser->setFont(font, onlyFixed); }
00360 
00364   QFont font() const { return chooser->font(); }
00365 
00372   void setSizeIsRelative( QButton::ToggleState relative )
00373     { chooser->setSizeIsRelative( relative ); }
00374 
00379   QButton::ToggleState sizeIsRelative() const
00380     { return chooser->sizeIsRelative(); }
00381 
00401   static int getFont( QFont &theFont, bool onlyFixed = false,
00402               QWidget *parent = 0L, bool makeFrame = true,
00403                       QButton::ToggleState *sizeIsRelativeState = 0L );
00404 
00437   static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
00438               QWidget *parent = 0L, bool makeFrame = true,
00439                       QButton::ToggleState *sizeIsRelativeState = 0L );
00440 
00460   static int getFontAndText( QFont &theFont, QString &theString,
00461                  bool onlyFixed = false, QWidget *parent = 0L,
00462                  bool makeFrame = true,
00463                              QButton::ToggleState *sizeIsRelativeState = 0L );
00464 
00465 signals:
00471   void fontSelected( const QFont &font );
00472 
00473 protected:
00474   KFontChooser *chooser;
00475 
00476 protected:
00477   virtual void virtual_hook( int id, void* data );
00478 private:
00479   class KFontDialogPrivate;
00480   KFontDialogPrivate *d;
00481 
00482 };
00483 
00484 #endif
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.0.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Oct 8 12:20:59 2003 by doxygen 1.2.18 written by Dimitri van Heesch, © 1997-2001