kdeui Library API Documentation

kfontdialog.h

00001 /*
00002     $Id: kfontdialog.h 353310 2004-10-10 10:27:49Z bhards $
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;
00052 class KDEUI_EXPORT KFontChooser : public QWidget
00053 {
00054   Q_OBJECT
00055   Q_PROPERTY( QFont font READ font WRITE setFont )
00056 
00057 public:
00063   enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00064 
00070   enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00071 
00106   KFontChooser(QWidget *parent = 0L, const char *name = 0L,
00107            bool onlyFixed = false,
00108            const QStringList &fontList = QStringList(),
00109            bool makeFrame = true, int visibleListSize=8,
00110                bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L );
00111 
00115   virtual ~KFontChooser();
00116 
00128   void enableColumn( int column, bool state );
00129 
00137   void setFont( const QFont &font, bool onlyFixed = false );
00138 
00143   int fontDiffFlags();
00144 
00148   QFont font() const { return selFont; }
00149 
00153   void setColor( const QColor & col );
00154 
00159   QColor color() const;
00160 
00164   void setBackgroundColor( const QColor & col );
00165 
00170   QColor backgroundColor() const;
00171 
00178   void setSizeIsRelative( QButton::ToggleState relative );
00179 
00184   QButton::ToggleState sizeIsRelative() const;
00185 
00186 
00190   QString sampleText() const { return sampleEdit->text(); }
00191 
00202   void setSampleText( const QString &text )
00203   {
00204     sampleEdit->setText( text );
00205   }
00206 
00214   static QString getXLFD( const QFont &theFont )
00215     { return theFont.rawName(); }
00216 
00228   enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00229 
00237   static void getFontList( QStringList &list, uint fontListCriteria);
00238 
00242   virtual QSize sizeHint( void ) const;
00243 
00244 signals:
00248   void fontSelected( const QFont &font );
00249 
00250 private slots:
00251   void toggled_checkbox();
00252   void family_chosen_slot(const QString&);
00253   void size_chosen_slot(const QString&);
00254   void style_chosen_slot(const QString&);
00255   void displaySample(const QFont &font);
00256   void showXLFDArea(bool);
00257   void size_value_slot(int);
00258 private:
00259   void fillFamilyListBox(bool onlyFixedFonts = false);
00260   void fillSizeList();
00261   // This one must be static since getFontList( QStringList, char*) is so
00262   static void addFont( QStringList &list, const char *xfont );
00263 
00264   void setupDisplay();
00265 
00266   // pointer to an optinally supplied list of fonts to
00267   // inserted into the fontdialog font-family combo-box
00268   QStringList  fontList;
00269 
00270   KIntNumInput *sizeOfFont;
00271 
00272   QLineEdit    *sampleEdit;
00273   QLineEdit    *xlfdEdit;
00274 
00275   QLabel       *familyLabel;
00276   QLabel       *styleLabel;
00277   QCheckBox    *familyCheckbox;
00278   QCheckBox    *styleCheckbox;
00279   QCheckBox    *sizeCheckbox;
00280   QLabel       *sizeLabel;
00281   KListBox     *familyListBox;
00282   KListBox     *styleListBox;
00283   KListBox     *sizeListBox;
00284   QComboBox    *charsetsCombo; // BIC: remove in KDE4
00285   QCheckBox    *sizeIsRelativeCheckBox;
00286 
00287   QFont        selFont;
00288 
00289   QString      selectedStyle;
00290   int          selectedSize;
00291   QMap<QString, QString> currentStyles;
00292 
00293   bool usingFixed;
00294 
00295 protected:
00296   virtual void virtual_hook( int id, void* data );
00297 private:
00298   class KFontChooserPrivate;
00299   KFontChooserPrivate *d;
00300 };
00301 
00326 class KDEUI_EXPORT KFontDialog : public KDialogBase  {
00327     Q_OBJECT
00328 
00329 public:
00352   KFontDialog( QWidget *parent = 0L, const char *name = 0,
00353            bool onlyFixed = false, bool modal = false,
00354            const QStringList &fontlist = QStringList(),
00355            bool makeFrame = true, bool diff = false,
00356                QButton::ToggleState *sizeIsRelativeState = 0L );
00357 
00365   void setFont( const QFont &font, bool onlyFixed = false )
00366     { chooser->setFont(font, onlyFixed); }
00367 
00371   QFont font() const { return chooser->font(); }
00372 
00379   void setSizeIsRelative( QButton::ToggleState relative )
00380     { chooser->setSizeIsRelative( relative ); }
00381 
00386   QButton::ToggleState sizeIsRelative() const
00387     { return chooser->sizeIsRelative(); }
00388 
00408   static int getFont( QFont &theFont, bool onlyFixed = false,
00409               QWidget *parent = 0L, bool makeFrame = true,
00410                       QButton::ToggleState *sizeIsRelativeState = 0L );
00411 
00444   static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
00445               QWidget *parent = 0L, bool makeFrame = true,
00446                       QButton::ToggleState *sizeIsRelativeState = 0L );
00447 
00467   static int getFontAndText( QFont &theFont, QString &theString,
00468                  bool onlyFixed = false, QWidget *parent = 0L,
00469                  bool makeFrame = true,
00470                              QButton::ToggleState *sizeIsRelativeState = 0L );
00471 
00472 signals:
00478   void fontSelected( const QFont &font );
00479 
00480 protected:
00481   KFontChooser *chooser;
00482 
00483 protected:
00484   virtual void virtual_hook( int id, void* data );
00485 private:
00486   class KFontDialogPrivate;
00487   KFontDialogPrivate *d;
00488 
00489 };
00490 
00491 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.4.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Feb 8 08:01:25 2006 by doxygen 1.4.4 written by Dimitri van Heesch, © 1997-2003