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.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
00285 static void addFont( QStringList &list, const char *xfont );
00286
00287 void setupDisplay();
00288
00289
00290
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;
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