kdeui Library API Documentation

kfontdialog.h

00001 /*
00002     $Id: kfontdialog.h,v 1.69 2004/07/08 16:34:15 faure 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   Q_PROPERTY( QFont font READ font WRITE setFont )
00055   
00056 public:
00062   enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00063 
00069   enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00070 
00105   KFontChooser(QWidget *parent = 0L, const char *name = 0L,
00106            bool onlyFixed = false,
00107            const QStringList &fontList = QStringList(),
00108            bool makeFrame = true, int visibleListSize=8,
00109                bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L );
00110 
00114   virtual ~KFontChooser();
00115 
00127   void enableColumn( int column, bool state );
00128 
00136   void setFont( const QFont &font, bool onlyFixed = false );
00137 
00142   int fontDiffFlags();
00143 
00147   QFont font() const { return selFont; }
00148 
00152   void setColor( const QColor & col );
00153 
00158   QColor color() const;
00159 
00163   void setBackgroundColor( const QColor & col );
00164 
00169   QColor backgroundColor() const;
00170 
00177   void setSizeIsRelative( QButton::ToggleState relative );
00178 
00183   QButton::ToggleState sizeIsRelative() const;
00184 
00185 
00189   QString sampleText() const { return sampleEdit->text(); }
00190 
00201   void setSampleText( const QString &text )
00202   {
00203     sampleEdit->setText( text );
00204   }
00205 
00213   static QString getXLFD( const QFont &theFont )
00214     { return theFont.rawName(); }
00215 
00227   enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00228 
00236   static void getFontList( QStringList &list, uint fontListCriteria);
00237 
00241   virtual QSize sizeHint( void ) const;
00242 
00243 signals:
00247   void fontSelected( const QFont &font );
00248 
00249 private slots:
00250   void toggled_checkbox();
00251   void family_chosen_slot(const QString&);
00252   void size_chosen_slot(const QString&);
00253   void style_chosen_slot(const QString&);
00254   void displaySample(const QFont &font);
00255   void showXLFDArea(bool);
00256   void size_value_slot(int);
00257 private:
00258   void fillFamilyListBox(bool onlyFixedFonts = false);
00259   void fillSizeList();
00260   // This one must be static since getFontList( QStringList, char*) is so
00261   static void addFont( QStringList &list, const char *xfont );
00262 
00263   void setupDisplay();
00264 
00265   // pointer to an optinally supplied list of fonts to
00266   // inserted into the fontdialog font-family combo-box
00267   QStringList  fontList;
00268 
00269   KIntNumInput *sizeOfFont;
00270 
00271   QLineEdit    *sampleEdit;
00272   QLineEdit    *xlfdEdit;
00273 
00274   QLabel       *familyLabel;
00275   QLabel       *styleLabel;
00276   QCheckBox    *familyCheckbox;
00277   QCheckBox    *styleCheckbox;
00278   QCheckBox    *sizeCheckbox;
00279   QLabel       *sizeLabel;
00280   KListBox     *familyListBox;
00281   KListBox     *styleListBox;
00282   KListBox     *sizeListBox;
00283   QComboBox    *charsetsCombo; // BIC: remove in KDE4
00284   QCheckBox    *sizeIsRelativeCheckBox;
00285 
00286   QFont        selFont;
00287 
00288   QString      selectedStyle;
00289   int          selectedSize;
00290   QMap<QString, QString> currentStyles;
00291 
00292   bool usingFixed;
00293 
00294 protected:
00295   virtual void virtual_hook( int id, void* data );
00296 private:
00297   class KFontChooserPrivate;
00298   KFontChooserPrivate *d;
00299 };
00300 
00324 class KFontDialog : public KDialogBase  {
00325     Q_OBJECT
00326 
00327 public:
00350   KFontDialog( QWidget *parent = 0L, const char *name = 0,
00351            bool onlyFixed = false, bool modal = false,
00352            const QStringList &fontlist = QStringList(),
00353            bool makeFrame = true, bool diff = false,
00354                QButton::ToggleState *sizeIsRelativeState = 0L );
00355 
00363   void setFont( const QFont &font, bool onlyFixed = false )
00364     { chooser->setFont(font, onlyFixed); }
00365 
00369   QFont font() const { return chooser->font(); }
00370 
00377   void setSizeIsRelative( QButton::ToggleState relative )
00378     { chooser->setSizeIsRelative( relative ); }
00379 
00384   QButton::ToggleState sizeIsRelative() const
00385     { return chooser->sizeIsRelative(); }
00386 
00406   static int getFont( QFont &theFont, bool onlyFixed = false,
00407               QWidget *parent = 0L, bool makeFrame = true,
00408                       QButton::ToggleState *sizeIsRelativeState = 0L );
00409 
00442   static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
00443               QWidget *parent = 0L, bool makeFrame = true,
00444                       QButton::ToggleState *sizeIsRelativeState = 0L );
00445 
00465   static int getFontAndText( QFont &theFont, QString &theString,
00466                  bool onlyFixed = false, QWidget *parent = 0L,
00467                  bool makeFrame = true,
00468                              QButton::ToggleState *sizeIsRelativeState = 0L );
00469 
00470 signals:
00476   void fontSelected( const QFont &font );
00477 
00478 protected:
00479   KFontChooser *chooser;
00480 
00481 protected:
00482   virtual void virtual_hook( int id, void* data );
00483 private:
00484   class KFontDialogPrivate;
00485   KFontDialogPrivate *d;
00486 
00487 };
00488 
00489 #endif
KDE Logo
This file is part of the documentation for kdeui Library Version 3.3.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Sun Jan 15 13:32:52 2006 by doxygen 1.4.2 written by Dimitri van Heesch, © 1997-2003