00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
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
00275 static void addFont( QStringList &list, const char *xfont );
00276
00277 void setupDisplay();
00278
00279
00280
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;
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