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;
00052 class KDEUI_EXPORT KFontChooser :
public QWidget
00053 {
00054 Q_OBJECT
00055 Q_PROPERTY(
QFont font READ font WRITE setFont )
00056
00057
public:
00063 enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
00064
00070 enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
00071
00106 KFontChooser(
QWidget *parent = 0L,
const char *name = 0L,
00107
bool onlyFixed =
false,
00108
const QStringList &fontList =
QStringList(),
00109
bool makeFrame =
true,
int visibleListSize=8,
00110
bool diff =
false, QButton::ToggleState *sizeIsRelativeState = 0L );
00111
00115
virtual ~KFontChooser();
00116
00128
void enableColumn(
int column,
bool state );
00129
00137
void setFont(
const QFont &font,
bool onlyFixed =
false );
00138
00143
int fontDiffFlags();
00144
00148 QFont font()
const {
return selFont; }
00149
00153
void setColor(
const QColor & col );
00154
00159
QColor color() const;
00160
00164
void setBackgroundColor( const
QColor & col );
00165
00170
QColor backgroundColor() const;
00171
00178
void setSizeIsRelative(
QButton::ToggleState relative );
00179
00184
QButton::ToggleState sizeIsRelative() const;
00185
00186
00190 QString sampleText()
const {
return sampleEdit->text(); }
00191
00202 void setSampleText(
const QString &text )
00203 {
00204 sampleEdit->setText( text );
00205 }
00206
00214 static QString getXLFD(
const QFont &theFont )
00215 {
return theFont.
rawName(); }
00216
00228 enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
00229
00237
static void getFontList(
QStringList &list, uint fontListCriteria);
00238
00242
virtual QSize sizeHint(
void ) const;
00243
00244 signals:
00248
void fontSelected( const
QFont &font );
00249
00250 private slots:
00251
void toggled_checkbox();
00252
void family_chosen_slot(const
QString&);
00253
void size_chosen_slot(const QString&);
00254
void style_chosen_slot(const QString&);
00255
void displaySample(const
QFont &font);
00256
void showXLFDArea(
bool);
00257
void size_value_slot(
int);
00258 private:
00259
void fillFamilyListBox(
bool onlyFixedFonts = false);
00260
void fillSizeList();
00261
00262 static
void addFont(
QStringList &list, const
char *xfont );
00263
00264
void setupDisplay();
00265
00266
00267
00268
QStringList fontList;
00269
00270
KIntNumInput *sizeOfFont;
00271
00272
QLineEdit *sampleEdit;
00273
QLineEdit *xlfdEdit;
00274
00275
QLabel *familyLabel;
00276
QLabel *styleLabel;
00277
QCheckBox *familyCheckbox;
00278
QCheckBox *styleCheckbox;
00279
QCheckBox *sizeCheckbox;
00280
QLabel *sizeLabel;
00281
KListBox *familyListBox;
00282
KListBox *styleListBox;
00283
KListBox *sizeListBox;
00284
QComboBox *charsetsCombo;
00285
QCheckBox *sizeIsRelativeCheckBox;
00286
00287
QFont selFont;
00288
00289 QString selectedStyle;
00290
int selectedSize;
00291
QMap<QString, QString> currentStyles;
00292
00293
bool usingFixed;
00294
00295 protected:
00296 virtual
void virtual_hook(
int id,
void* data );
00297 private:
00298 class KFontChooserPrivate;
00299 KFontChooserPrivate *d;
00300 };
00301
00326 class KDEUI_EXPORT
KFontDialog : public
KDialogBase {
00327 Q_OBJECT
00328
00329
public:
00352
KFontDialog(
QWidget *parent = 0L,
const char *name = 0,
00353
bool onlyFixed =
false,
bool modal =
false,
00354
const QStringList &fontlist =
QStringList(),
00355
bool makeFrame =
true,
bool diff =
false,
00356 QButton::ToggleState *sizeIsRelativeState = 0L );
00357
00365 void setFont(
const QFont &font,
bool onlyFixed =
false )
00366 { chooser->setFont(font, onlyFixed); }
00367
00371 QFont font()
const {
return chooser->font(); }
00372
00379 void setSizeIsRelative( QButton::ToggleState relative )
00380 { chooser->setSizeIsRelative( relative ); }
00381
00386 QButton::ToggleState sizeIsRelative()
const
00387
{
return chooser->sizeIsRelative(); }
00388
00408
static int getFont(
QFont &theFont,
bool onlyFixed =
false,
00409
QWidget *parent = 0L,
bool makeFrame =
true,
00410 QButton::ToggleState *sizeIsRelativeState = 0L );
00411
00444
static int getFontDiff(
QFont &theFont,
int &diffFlags,
bool onlyFixed =
false,
00445
QWidget *parent = 0L,
bool makeFrame =
true,
00446 QButton::ToggleState *sizeIsRelativeState = 0L );
00447
00467
static int getFontAndText(
QFont &theFont, QString &theString,
00468
bool onlyFixed =
false,
QWidget *parent = 0L,
00469
bool makeFrame =
true,
00470 QButton::ToggleState *sizeIsRelativeState = 0L );
00471
00472 signals:
00478
void fontSelected(
const QFont &font );
00479
00480
protected:
00481 KFontChooser *chooser;
00482
00483
protected:
00484
virtual void virtual_hook(
int id,
void* data );
00485
private:
00486
class KFontDialogPrivate;
00487 KFontDialogPrivate *d;
00488
00489 };
00490
00491
#endif