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
00027
00028
00029 #ifndef _K_FONT_DIALOG_LOCAL_H_
00030 #define _K_FONT_DIALOG_LOCAL_H_
00031
00032 #include <QLineEdit>
00033 #include <q3button.h>
00034
00035 #include <QLabel>
00036 #include <kdialog.h>
00037
00038 #include <koffice_export.h>
00039
00040 class QComboBox;
00041 class QCheckBox;
00042 class QFont;
00043 class Q3GroupBox;
00044 class QLabel;
00045 class QStringList;
00046 class KListBox;
00047 class KIntNumInput;
00059 class KOTEXT_EXPORT KFontChooser_local : public QWidget
00060 {
00061 Q_OBJECT
00062 Q_PROPERTY( QFont font READ font WRITE setFont )
00063
00064 public:
00070 enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00071
00077 enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00078
00113 KFontChooser_local(QWidget *parent = 0L,
00114 bool onlyFixed = false,
00115 const QStringList &fontList = QStringList(),
00116 bool makeFrame = true, int visibleListSize=8,
00117 bool diff = false, Qt::CheckState *sizeIsRelativeState = 0L );
00118
00122 virtual ~KFontChooser_local();
00123
00135 void enableColumn( int column, bool state );
00136
00144 void setFont( const QFont &font, bool onlyFixed = false );
00145
00150 int fontDiffFlags();
00151
00155 QFont font() const { return selFont; }
00156
00160 void setColor( const QColor & col );
00161
00166 QColor color() const;
00167
00171 void setBackgroundColor( const QColor & col );
00172
00177 QColor backgroundColor() const;
00178
00185 void setSizeIsRelative( Qt::CheckState relative );
00186
00191 Qt::CheckState sizeIsRelative() const;
00192
00193
00197 QString sampleText() const { return sampleEdit->text(); }
00198
00209 void setSampleText( const QString &text )
00210 {
00211 sampleEdit->setText( text );
00212 }
00213
00219 void setSampleBoxVisible( bool visible )
00220 {
00221 ( visible ) ? sampleEdit->show() : sampleEdit->hide();
00222 }
00223
00231 static QString getXLFD( const QFont &theFont )
00232 { return theFont.rawName(); }
00233
00245 enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00246
00254 static void getFontList( QStringList &list, uint fontListCriteria);
00255
00262 void setFamilyList( const QStringList & list );
00263
00267 virtual QSize sizeHint( void ) const;
00268
00269 signals:
00273 void fontSelected( const QFont &font );
00274
00275 private slots:
00276 void toggled_checkbox();
00277 void family_chosen_slot(const QString&);
00278 void size_chosen_slot(const QString&);
00279 void style_chosen_slot(const QString&);
00280 void displaySample(const QFont &font);
00281 void showXLFDArea(bool);
00282 void size_value_slot(int);
00283 private:
00284 void fillFamilyListBox(bool onlyFixedFonts = false);
00285 void fillSizeList();
00286
00287 static void addFont( QStringList &list, const char *xfont );
00288
00289 void setupDisplay();
00290
00291
00292
00293 QStringList fontList;
00294
00295 KIntNumInput *sizeOfFont;
00296
00297 QLineEdit *sampleEdit;
00298 QLineEdit *xlfdEdit;
00299
00300 QLabel *familyLabel;
00301 QLabel *styleLabel;
00302 QCheckBox *familyCheckbox;
00303 QCheckBox *styleCheckbox;
00304 QCheckBox *sizeCheckbox;
00305 QLabel *sizeLabel;
00306 KListBox *familyListBox;
00307 KListBox *styleListBox;
00308 KListBox *sizeListBox;
00309 QComboBox *charsetsCombo;
00310 QCheckBox *sizeIsRelativeCheckBox;
00311
00312 QFont selFont;
00313
00314 QString selectedFamily;
00315 QString selectedStyle;
00316 int selectedSize;
00317 QMap<QString, QString> currentStyles;
00318
00319 bool usingFixed;
00320
00321 protected:
00322 virtual void virtual_hook( int id, void* data );
00323 private:
00324 class KFontChooser_localPrivate;
00325 KFontChooser_localPrivate *d;
00326 };
00327
00352 class KOTEXT_EXPORT KFontDialog_local : public KDialog {
00353 Q_OBJECT
00354
00355 public:
00378 KFontDialog_local( QWidget *parent = 0L, const char *name = 0,
00379 bool onlyFixed = false, bool modal = false,
00380 const QStringList &fontlist = QStringList(),
00381 bool makeFrame = true, bool diff = false,
00382 Qt::CheckState *sizeIsRelativeState = 0L );
00383
00391 void setFont( const QFont &font, bool onlyFixed = false )
00392 { chooser->setFont(font, onlyFixed); }
00393
00397 QFont font() const { return chooser->font(); }
00398
00405 void setSizeIsRelative( Qt::CheckState relative )
00406 { chooser->setSizeIsRelative( relative ); }
00407
00412 Qt::CheckState sizeIsRelative() const
00413 { return chooser->sizeIsRelative(); }
00414
00434 static int getFont( QFont &theFont, bool onlyFixed = false,
00435 QWidget *parent = 0L, bool makeFrame = true,
00436 Qt::CheckState *sizeIsRelativeState = 0L );
00437
00470 static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
00471 QWidget *parent = 0L, bool makeFrame = true,
00472 Qt::CheckState *sizeIsRelativeState = 0L );
00473
00493 static int getFontAndText( QFont &theFont, QString &theString,
00494 bool onlyFixed = false, QWidget *parent = 0L,
00495 bool makeFrame = true,
00496 Qt::CheckState *sizeIsRelativeState = 0L );
00497
00498 signals:
00504 void fontSelected( const QFont &font );
00505
00506 protected:
00507 KFontChooser_local *chooser;
00508
00509 protected:
00510 virtual void virtual_hook( int id, void* data );
00511 private:
00512 class KFontDialog_localPrivate;
00513 KFontDialog_localPrivate *d;
00514
00515 };
00516
00517 #endif