kfontdialog.h
/*
$Id: kfontdialog.h 465272 2005-09-29 09:47:40Z mueller $
Requires the Qt widget libraries, available at no cost at
http://www.troll.no
Copyright (C) 1997 Bernd Johannes Wuebben <wuebben@kde.org>
Copyright (c) 1999 Preston Brown <pbrown@kde.org>
Copyright (c) 1999 Mario Weilguni <mweilguni@kde.org>
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#ifndef _K_FONT_DIALOG_H_
#define _K_FONT_DIALOG_H_
#include <qlineedit.h>
#include <qbutton.h>
#include <kdialogbase.h>
class QComboBox;
class QCheckBox;
class QFont;
class QGroupBox;
class QLabel;
class QStringList;
class KListBox;
class KIntNumInput;
class KDEUI_EXPORT KFontChooser : public QWidget
{
Q_OBJECT
Q_PROPERTY( QFont font READ font WRITE setFont )
public:
enum FontColumn { FamilyList=0x01, StyleList=0x02, SizeList=0x04};
enum FontDiff { FontDiffFamily=0x01, FontDiffStyle=0x02, FontDiffSize=0x04 };
KFontChooser(QWidget *parent = 0L, const char *name = 0L,
bool onlyFixed = false,
const QStringList &fontList = QStringList(),
bool makeFrame = true, int visibleListSize=8,
bool diff = false, QButton::ToggleState *sizeIsRelativeState = 0L );
virtual ~KFontChooser();
void enableColumn( int column, bool state );
void setFont( const QFont &font, bool onlyFixed = false );
int fontDiffFlags();
QFont font() const { return selFont; }
void setColor( const QColor & col );
QColor color() const;
void setBackgroundColor( const QColor & col );
QColor backgroundColor() const;
void setSizeIsRelative( QButton::ToggleState relative );
QButton::ToggleState sizeIsRelative() const;
QString sampleText() const { return sampleEdit->text(); }
void setSampleText( const QString &text )
{
sampleEdit->setText( text );
}
void setSampleBoxVisible( bool visible )
{
sampleEdit->setShown( visible );
}
static QString getXLFD( const QFont &theFont )
{ return theFont.rawName(); }
enum FontListCriteria { FixedWidthFonts=0x01, ScalableFonts=0x02, SmoothScalableFonts=0x04 };
static void getFontList( QStringList &list, uint fontListCriteria);
virtual QSize sizeHint( void ) const;
signals:
void fontSelected( const QFont &font );
private slots:
void toggled_checkbox();
void family_chosen_slot(const QString&);
void size_chosen_slot(const QString&);
void style_chosen_slot(const QString&);
void displaySample(const QFont &font);
void showXLFDArea(bool);
void size_value_slot(int);
private:
void fillFamilyListBox(bool onlyFixedFonts = false);
void fillSizeList();
// This one must be static since getFontList( QStringList, char*) is so
static void addFont( QStringList &list, const char *xfont );
void setupDisplay();
// pointer to an optinally supplied list of fonts to
// inserted into the fontdialog font-family combo-box
QStringList fontList;
KIntNumInput *sizeOfFont;
QLineEdit *sampleEdit;
QLineEdit *xlfdEdit;
QLabel *familyLabel;
QLabel *styleLabel;
QCheckBox *familyCheckbox;
QCheckBox *styleCheckbox;
QCheckBox *sizeCheckbox;
QLabel *sizeLabel;
KListBox *familyListBox;
KListBox *styleListBox;
KListBox *sizeListBox;
QComboBox *charsetsCombo; // BIC: remove in KDE4
QCheckBox *sizeIsRelativeCheckBox;
QFont selFont;
QString selectedStyle;
int selectedSize;
QMap<QString, QString> currentStyles;
bool usingFixed;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KFontChooserPrivate;
KFontChooserPrivate *d;
};
class KDEUI_EXPORT KFontDialog : public KDialogBase {
Q_OBJECT
public:
KFontDialog( QWidget *parent = 0L, const char *name = 0,
bool onlyFixed = false, bool modal = false,
const QStringList &fontlist = QStringList(),
bool makeFrame = true, bool diff = false,
QButton::ToggleState *sizeIsRelativeState = 0L );
void setFont( const QFont &font, bool onlyFixed = false )
{ chooser->setFont(font, onlyFixed); }
QFont font() const { return chooser->font(); }
void setSizeIsRelative( QButton::ToggleState relative )
{ chooser->setSizeIsRelative( relative ); }
QButton::ToggleState sizeIsRelative() const
{ return chooser->sizeIsRelative(); }
static int getFont( QFont &theFont, bool onlyFixed = false,
QWidget *parent = 0L, bool makeFrame = true,
QButton::ToggleState *sizeIsRelativeState = 0L );
static int getFontDiff( QFont &theFont, int &diffFlags, bool onlyFixed = false,
QWidget *parent = 0L, bool makeFrame = true,
QButton::ToggleState *sizeIsRelativeState = 0L );
static int getFontAndText( QFont &theFont, QString &theString,
bool onlyFixed = false, QWidget *parent = 0L,
bool makeFrame = true,
QButton::ToggleState *sizeIsRelativeState = 0L );
signals:
void fontSelected( const QFont &font );
protected:
KFontChooser *chooser;
protected:
virtual void virtual_hook( int id, void* data );
private:
class KFontDialogPrivate;
KFontDialogPrivate *d;
};
#endif
KFontChooser::FontDiff
FontDiff
Definition: kfontdialog.h:72
KFontChooser::FontColumn
FontColumn
Definition: kfontdialog.h:65
KFontDialog::font
QFont font() const
Definition: kfontdialog.h:384
KFontDialog::setSizeIsRelative
void setSizeIsRelative(QButton::ToggleState relative)
Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size...
Definition: kfontdialog.h:392
KFontChooser::setSampleText
void setSampleText(const QString &text)
Sets the sample text.
Definition: kfontdialog.h:204
KDialogBase
A dialog base class with standard buttons and predefined layouts.
Definition: kdialogbase.h:191
KFontDialog::setFont
void setFont(const QFont &font, bool onlyFixed=false)
Sets the currently selected font in the dialog.
Definition: kfontdialog.h:378
KFontDialog
A font selection dialog.
Definition: kfontdialog.h:339
KFontChooser::getXLFD
static QString getXLFD(const QFont &theFont)
Converts a QFont into the corresponding X Logical Font Description (XLFD).
Definition: kfontdialog.h:227
KFontChooser
A font selection widget.
Definition: kfontdialog.h:54
KFontChooser::sampleText
QString sampleText() const
Definition: kfontdialog.h:192
KFontChooser::FontListCriteria
FontListCriteria
The selection criteria for the font families shown in the dialog.
Definition: kfontdialog.h:241
KFontDialog::sizeIsRelative
QButton::ToggleState sizeIsRelative() const
Definition: kfontdialog.h:399
KListBox
A variant of QListBox that honors KDE's system-wide settings.
Definition: klistbox.h:40
KFontChooser::setSampleBoxVisible
void setSampleBoxVisible(bool visible)
Shows or hides the sample text box.
Definition: kfontdialog.h:215
KFontChooser::font
QFont font() const
Definition: kfontdialog.h:150
KIntNumInput
An input widget for integer numbers, consisting of a spinbox and a slider.
Definition: knuminput.h:187

KDE Home | KDE Accessibility Home | Description of Access Keys