• Skip to content
  • Skip to link menu
KDE 3.5 API Reference
  • KDE API Reference
  • API Reference
  • Sitemap
  • Contact Us
 

kdeui

kfontdialog.h

Go to the documentation of this file.
00001 /*
00002     $Id: kfontdialog.h 465272 2005-09-29 09:47:40Z mueller $
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., 51 Franklin Street, Fifth Floor,
00024     Boston, MA 02110-1301, 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;
00054 class KDEUI_EXPORT KFontChooser : public QWidget
00055 {
00056   Q_OBJECT
00057   Q_PROPERTY( QFont font READ font WRITE setFont )
00058 
00059 public:
00065   enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00066 
00072   enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00073 
00108   KFontChooser(QWidget *parent = 0L, const char *name = 0L,
00109            bool onlyFixed = false,
00110            const QStringList &fontList = QStringList(),
00111            bool makeFrame = true, int visibleListSize=8,
00112                bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L );
00113 
00117   virtual ~KFontChooser();
00118 
00130   void enableColumn( int column, bool state );
00131 
00139   void setFont( const QFont &font, bool onlyFixed = false );
00140 
00145   int fontDiffFlags();
00146 
00150   QFont font() const { return selFont; }
00151 
00155   void setColor( const QColor & col );
00156 
00161   QColor color() const;
00162 
00166   void setBackgroundColor( const QColor & col );
00167 
00172   QColor backgroundColor() const;
00173 
00180   void setSizeIsRelative( QButton::ToggleState relative );
00181 
00186   QButton::ToggleState sizeIsRelative() const;
00187 
00188 
00192   QString sampleText() const { return sampleEdit->text(); }
00193 
00204   void setSampleText( const QString &text )
00205   {
00206     sampleEdit->setText( text );
00207   }
00208 
00215   void setSampleBoxVisible( bool visible )
00216   {
00217     sampleEdit->setShown( visible );
00218   }
00219 
00227   static QString getXLFD( const QFont &theFont )
00228     { return theFont.rawName(); }
00229 
00241   enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00242 
00250   static void getFontList( QStringList &list, uint fontListCriteria);
00251 
00255   virtual QSize sizeHint( void ) const;
00256 
00257 signals:
00261   void fontSelected( const QFont &font );
00262 
00263 private slots:
00264   void toggled_checkbox();
00265   void family_chosen_slot(const QString&);
00266   void size_chosen_slot(const QString&);
00267   void style_chosen_slot(const QString&);
00268   void displaySample(const QFont &font);
00269   void showXLFDArea(bool);
00270   void size_value_slot(int);
00271 private:
00272   void fillFamilyListBox(bool onlyFixedFonts = false);
00273   void fillSizeList();
00274   // This one must be static since getFontList( QStringList, char*) is so
00275   static void addFont( QStringList &list, const char *xfont );
00276 
00277   void setupDisplay();
00278 
00279   // pointer to an optinally supplied list of fonts to
00280   // inserted into the fontdialog font-family combo-box
00281   QStringList  fontList;
00282 
00283   KIntNumInput *sizeOfFont;
00284 
00285   QLineEdit    *sampleEdit;
00286   QLineEdit    *xlfdEdit;
00287 
00288   QLabel       *familyLabel;
00289   QLabel       *styleLabel;
00290   QCheckBox    *familyCheckbox;
00291   QCheckBox    *styleCheckbox;
00292   QCheckBox    *sizeCheckbox;
00293   QLabel       *sizeLabel;
00294   KListBox     *familyListBox;
00295   KListBox     *styleListBox;
00296   KListBox     *sizeListBox;
00297   QComboBox    *charsetsCombo; // BIC: remove in KDE4
00298   QCheckBox    *sizeIsRelativeCheckBox;
00299 
00300   QFont        selFont;
00301 
00302   QString      selectedStyle;
00303   int          selectedSize;
00304   QMap<QString, QString> currentStyles;
00305 
00306   bool usingFixed;
00307 
00308 protected:
00309   virtual void virtual_hook( int id, void* data );
00310 private:
00311   class KFontChooserPrivate;
00312   KFontChooserPrivate *d;
00313 };
00314 
00339 class KDEUI_EXPORT KFontDialog : public KDialogBase  {
00340     Q_OBJECT
00341 
00342 public:
00365   KFontDialog( QWidget *parent = 0L, const char *name = 0,
00366            bool onlyFixed = false, bool modal = false,
00367            const QStringList &fontlist = QStringList(),
00368            bool makeFrame = true, bool diff = false,
00369                QButton::ToggleState *sizeIsRelativeState = 0L );
00370 
00378   void setFont( const QFont &font, bool onlyFixed = false )
00379     { chooser->setFont(font, onlyFixed); }
00380 
00384   QFont font() const { return chooser->font(); }
00385 
00392   void setSizeIsRelative( QButton::ToggleState relative )
00393     { chooser->setSizeIsRelative( relative ); }
00394 
00399   QButton::ToggleState sizeIsRelative() const
00400     { return chooser->sizeIsRelative(); }
00401 
00421   static int getFont( QFont &theFont, bool onlyFixed = false,
00422               QWidget *parent = 0L, bool makeFrame = true,
00423                       QButton::ToggleState *sizeIsRelativeState = 0L );
00424 
00457   static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
00458               QWidget *parent = 0L, bool makeFrame = true,
00459                       QButton::ToggleState *sizeIsRelativeState = 0L );
00460 
00480   static int getFontAndText( QFont &theFont, QString &theString,
00481                  bool onlyFixed = false, QWidget *parent = 0L,
00482                  bool makeFrame = true,
00483                              QButton::ToggleState *sizeIsRelativeState = 0L );
00484 
00485 signals:
00491   void fontSelected( const QFont &font );
00492 
00493 protected:
00494   KFontChooser *chooser;
00495 
00496 protected:
00497   virtual void virtual_hook( int id, void* data );
00498 private:
00499   class KFontDialogPrivate;
00500   KFontDialogPrivate *d;
00501 
00502 };
00503 
00504 #endif

kdeui

Skip menu "kdeui"
  • Main Page
  • Namespace List
  • Class Hierarchy
  • Alphabetical List
  • Class List
  • File List
  • Namespace Members
  • Class Members
  • Related Pages

API Reference

Skip menu "API Reference"
  • dcop
  • DNSSD
  • interfaces
  • Kate
  • kconf_update
  • KDECore
  • KDED
  • kdefx
  • KDEsu
  • kdeui
  • KDocTools
  • KHTML
  • KImgIO
  • KInit
  • kio
  • kioslave
  • KJS
  • KNewStuff
  • KParts
  • KUtils
Generated for API Reference by doxygen 1.5.9
This website is maintained by Adriaan de Groot and Allen Winter.
KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal