lib

KFontDialog_local.h

00001 /*
00002     $Id: kfontdialog.h,v 1.71 2004/10/10 10:27:49 bhards 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., 51 Franklin Street, Fifth Floor,
00024  * Boston, MA 02110-1301, USA.
00025 */
00026 
00027 /*This local copy has been added to be able to hide the preview pane of the font chooser. A patch has been made in kdelibs since 3.5. This local copy can be disposed of when we require kdelibs 3.5 and higher*/
00028 
00029 #ifndef _K_FONT_DIALOG_LOCAL_H_
00030 #define _K_FONT_DIALOG_LOCAL_H_
00031 
00032 #include <qlineedit.h>
00033 #include <qbutton.h>
00034 #include <kdialogbase.h>
00035 
00036 #include <koffice_export.h>
00037 
00038 class QComboBox;
00039 class QCheckBox;
00040 class QFont;
00041 class QGroupBox;
00042 class QLabel;
00043 class QStringList;
00044 class KListBox;
00045 class KIntNumInput;
00057 class KOTEXT_EXPORT KFontChooser_local : public QWidget
00058 {
00059   Q_OBJECT
00060   Q_PROPERTY( QFont font READ font WRITE setFont )
00061 
00062 public:
00068   enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00069 
00075   enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00076 
00111   KFontChooser_local(QWidget *parent = 0L, const char *name = 0L,
00112            bool onlyFixed = false,
00113            const QStringList &fontList = QStringList(),
00114            bool makeFrame = true, int visibleListSize=8,
00115                bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L );
00116 
00120   virtual ~KFontChooser_local();
00121 
00133   void enableColumn( int column, bool state );
00134 
00142   void setFont( const QFont &font, bool onlyFixed = false );
00143 
00148   int fontDiffFlags();
00149 
00153   QFont font() const { return selFont; }
00154 
00158   void setColor( const QColor & col );
00159 
00164   QColor color() const;
00165 
00169   void setBackgroundColor( const QColor & col );
00170 
00175   QColor backgroundColor() const;
00176 
00183   void setSizeIsRelative( QButton::ToggleState relative );
00184 
00189   QButton::ToggleState sizeIsRelative() const;
00190 
00191 
00195   QString sampleText() const { return sampleEdit->text(); }
00196 
00207   void setSampleText( const QString &text )
00208   {
00209     sampleEdit->setText( text );
00210   }
00211 
00217   void setSampleBoxVisible( bool visible )
00218   {
00219     ( visible ) ? sampleEdit->show() : sampleEdit->hide();
00220   }
00221 
00229   static QString getXLFD( const QFont &theFont )
00230     { return theFont.rawName(); }
00231 
00243   enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00244 
00252   static void getFontList( QStringList &list, uint fontListCriteria);
00253 
00260   void setFamilyList( QStringList list );
00261 
00265   virtual QSize sizeHint( void ) const;
00266 
00267 signals:
00271   void fontSelected( const QFont &font );
00272 
00273 private slots:
00274   void toggled_checkbox();
00275   void family_chosen_slot(const QString&);
00276   void size_chosen_slot(const QString&);
00277   void style_chosen_slot(const QString&);
00278   void displaySample(const QFont &font);
00279   void showXLFDArea(bool);
00280   void size_value_slot(int);
00281 private:
00282   void fillFamilyListBox(bool onlyFixedFonts = false);
00283   void fillSizeList();
00284   // This one must be static since getFontList( QStringList, char*) is so
00285   static void addFont( QStringList &list, const char *xfont );
00286 
00287   void setupDisplay();
00288 
00289   // pointer to an optinally supplied list of fonts to
00290   // inserted into the fontdialog font-family combo-box
00291   QStringList  fontList;
00292 
00293   KIntNumInput *sizeOfFont;
00294 
00295   QLineEdit    *sampleEdit;
00296   QLineEdit    *xlfdEdit;
00297 
00298   QLabel       *familyLabel;
00299   QLabel       *styleLabel;
00300   QCheckBox    *familyCheckbox;
00301   QCheckBox    *styleCheckbox;
00302   QCheckBox    *sizeCheckbox;
00303   QLabel       *sizeLabel;
00304   KListBox     *familyListBox;
00305   KListBox     *styleListBox;
00306   KListBox     *sizeListBox;
00307   QComboBox    *charsetsCombo; // BIC: remove in KDE4
00308   QCheckBox    *sizeIsRelativeCheckBox;
00309 
00310   QFont        selFont;
00311 
00312   QString      selectedFamily;
00313   QString      selectedStyle;
00314   int          selectedSize;
00315   QMap<QString, QString> currentStyles;
00316 
00317   bool usingFixed;
00318 
00319 protected:
00320   virtual void virtual_hook( int id, void* data );
00321 private:
00322   class KFontChooser_localPrivate;
00323   KFontChooser_localPrivate *d;
00324 };
00325 
00350 class KOTEXT_EXPORT KFontDialog_local : public KDialogBase  {
00351     Q_OBJECT
00352 
00353 public:
00376   KFontDialog_local( QWidget *parent = 0L, const char *name = 0,
00377            bool onlyFixed = false, bool modal = false,
00378            const QStringList &fontlist = QStringList(),
00379            bool makeFrame = true, bool diff = false,
00380                QButton::ToggleState *sizeIsRelativeState = 0L );
00381 
00389   void setFont( const QFont &font, bool onlyFixed = false )
00390     { chooser->setFont(font, onlyFixed); }
00391 
00395   QFont font() const { return chooser->font(); }
00396 
00403   void setSizeIsRelative( QButton::ToggleState relative )
00404     { chooser->setSizeIsRelative( relative ); }
00405 
00410   QButton::ToggleState sizeIsRelative() const
00411     { return chooser->sizeIsRelative(); }
00412 
00432   static int getFont( QFont &theFont, bool onlyFixed = false,
00433               QWidget *parent = 0L, bool makeFrame = true,
00434                       QButton::ToggleState *sizeIsRelativeState = 0L );
00435 
00468   static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
00469               QWidget *parent = 0L, bool makeFrame = true,
00470                       QButton::ToggleState *sizeIsRelativeState = 0L );
00471 
00491   static int getFontAndText( QFont &theFont, QString &theString,
00492                  bool onlyFixed = false, QWidget *parent = 0L,
00493                  bool makeFrame = true,
00494                              QButton::ToggleState *sizeIsRelativeState = 0L );
00495 
00496 signals:
00502   void fontSelected( const QFont &font );
00503 
00504 protected:
00505   KFontChooser_local *chooser;
00506 
00507 protected:
00508   virtual void virtual_hook( int id, void* data );
00509 private:
00510   class KFontDialog_localPrivate;
00511   KFontDialog_localPrivate *d;
00512 
00513 };
00514 
00515 #endif
KDE Home | KDE Accessibility Home | Description of Access Keys