kdeui Library API Documentation

KFontChooser Class Reference

While KFontChooser as an ordinary widget can be embedded in custom dialogs and therefore is very flexible, in most cases it is preferable to use the convenience functions in KFontDialog. A font selection widget. More...

#include <kfontdialog.h>

Inheritance diagram for KFontChooser:

Inheritance graph
[legend]
Collaboration diagram for KFontChooser:

Collaboration graph
[legend]
List of all members.

Public Types

enum  FontColumn { FamilyList = 0x01, StyleList = 0x02, SizeList = 0x04 }
 
  • FamilyList - Identifies the family (leftmost) list.
More...

enum  FontDiff { FontDiffFamily = 0x01, FontDiffStyle = 0x02, FontDiffSize = 0x04 }
 
  • FontDiffFamily - Identifies a requested change in the font family.
More...

enum  FontListCriteria { FixedWidthFonts = 0x01, ScalableFonts = 0x02, SmoothScalableFonts = 0x04 }
 The selection criteria for the font families shown in the dialog. More...


Signals

void fontSelected (const QFont &font)
 Emitted whenever the selected font changes.


Public Member Functions

 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)
 Constructs a font picker widget.

virtual ~KFontChooser ()
 Destructs the font chooser.

void enableColumn (int column, bool state)
 Enables or disable a font column in the chooser.

void setFont (const QFont &font, bool onlyFixed=false)
 Sets the currently selected font in the chooser.

int fontDiffFlags ()
QFont font () const
void setColor (const QColor &col)
 Sets the color to use in the preview.

QColor color () const
void setBackgroundColor (const QColor &col)
 Sets the background color to use in the preview.

QColor backgroundColor () const
void setSizeIsRelative (QButton::ToggleState relative)
 Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size.

QButton::ToggleState sizeIsRelative () const
QString sampleText () const
void setSampleText (const QString &text)
 Sets the sample text.

virtual QSize sizeHint (void) const
 Reimplemented for internal reasons.


Static Public Member Functions

QString getXLFD (const QFont &theFont)
 Converts a QFont into the corresponding X Logical Font Description (XLFD).

void getFontList (QStringList &list, uint fontListCriteria)
 Creates a list of font strings.


Protected Member Functions

virtual void virtual_hook (int id, void *data)

Detailed Description

While KFontChooser as an ordinary widget can be embedded in custom dialogs and therefore is very flexible, in most cases it is preferable to use the convenience functions in KFontDialog. A font selection widget.

Author:
Preston Brown <pbrown@kde.org>, Bernd Wuebben <wuebben@kde.org>
Version:
Id
kfontdialog.h,v 1.61 2002/09/11 02:18:25 orlovich Exp

Definition at line 51 of file kfontdialog.h.


Member Enumeration Documentation

enum KFontChooser::FontColumn
 

  • FamilyList - Identifies the family (leftmost) list.

  • StyleList - Identifies the style (center) list.
  • SizeList - Identifies the size (rightmost) list.

Definition at line 61 of file kfontdialog.h.

enum KFontChooser::FontDiff
 

  • FontDiffFamily - Identifies a requested change in the font family.

  • FontDiffStyle - Identifies a requested change in the font style.
  • FontDiffSize - Identifies a requested change in the font size.

Definition at line 68 of file kfontdialog.h.

enum KFontChooser::FontListCriteria
 

The selection criteria for the font families shown in the dialog.

  • FixedWidthFont when included only fixed-width fonts are returned. The fonts where the width of every character is equal.
  • ScalableFont when included only scalable fonts are returned; certain configurations allow bitmap fonts to remain unscaled and thus these fonts have limited number of sizes.
  • SmoothScalableFont when included only return smooth scalable fonts. this will return only non-bitmap fonts which are scalable to any size requested. Setting this option to true will mean the "scalable" flag is irrelavant.

Definition at line 222 of file kfontdialog.h.


Constructor & Destructor Documentation

KFontChooser::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
 

Constructs a font picker widget.

It normally comes up with all font families present on the system; the getFont method below does allow some more fine-tuning of the selection of fonts that will be displayed in the dialog.

Consider the following code snippet;

QStringList list; KFontChooser::getFontList(list,SmoothScalableFonts); KFontChooser chooseFont = new KFontChooser(0, "FontList", false, list);

The above creates a font chooser dialog with only SmoothScaleble fonts.

Parameters:
parent The parent widget.
name The widget name.
onlyFixedFonts Only display fonts which have fixed-width character sizes.
fontList A list of fonts to display, in XLFD format. If no list is formatted, the internal KDE font list is used. If that has not been created, X is queried, and all fonts available on the system are displayed.
diff Display the difference version dialog. See KFontDialog::getFontDiff().
visibleListSize The minimum number of visible entries in the fontlists.
sizeIsRelativeState If not zero the widget will show a checkbox where the user may choose whether the font size is to be interpreted as relative size. Initial state of this checkbox will be set according to *sizeIsRelativeState, user choice may be retrieved by calling sizeIsRelative().

Definition at line 96 of file kfontdialog.cpp.

References QToolTip::add(), QWhatsThis::add(), QGridLayout::addLayout(), QGridLayout::addMultiCellWidget(), QGridLayout::addWidget(), KGlobal::config(), QListBox::findItem(), QWidget::fontMetrics(), fontSelected(), QString::fromLatin1(), KGlobalSettings::generalFont(), QListBox::insertItem(), QListBox::insertStringList(), KStdAccel::label(), KDialog::marginHint(), KStdAccel::name(), QString::number(), QWidget::QWidget(), KConfigBase::readBoolEntry(), QLineEdit::setAlignment(), QGridLayout::setColStretch(), QWidget::setEnabled(), setFont(), KIntNumInput::setMinValue(), QListBox::setSelected(), setSizeIsRelative(), QLineEdit::setText(), QCheckBox::setTristate(), and KDialog::spacingHint().

KFontChooser::~KFontChooser  )  [virtual]
 

Destructs the font chooser.

Definition at line 341 of file kfontdialog.cpp.


Member Function Documentation

void KFontChooser::enableColumn int  column,
bool  state
 

Enables or disable a font column in the chooser.

Use this function if your application does not need or supports all font properties.

Parameters:
font Specifie the columns. An or'ed combination of FamilyList, StyleList and SizeList is possible.
state If false the columns are disabled.

Definition at line 415 of file kfontdialog.cpp.

void KFontChooser::setFont const QFont font,
bool  onlyFixed = false
 

Sets the currently selected font in the chooser.

Parameters:
font The font to select.
onlyFixed Readjust the font list to display only fixed width fonts if true, or vice-versa.

Definition at line 432 of file kfontdialog.cpp.

Referenced by KFontChooser(), and KFontDialog::setFont().

int KFontChooser::fontDiffFlags  ) 
 

Returns:
The bitmask corresponding to the attributes the user wishes to change.

Definition at line 449 of file kfontdialog.cpp.

References QCheckBox::isChecked().

Referenced by KFontDialog::getFontDiff().

QFont KFontChooser::font  )  const [inline]
 

Returns:
The currently selected font in the chooser.

Reimplemented from QWidget.

Definition at line 144 of file kfontdialog.h.

Referenced by KFontDialog::font(), KFontDialog::getFont(), KFontDialog::getFontAndText(), and KFontDialog::getFontDiff().

void KFontChooser::setColor const QColor col  ) 
 

Sets the color to use in the preview.

Definition at line 365 of file kfontdialog.cpp.

References QPalette::setColor().

QColor KFontChooser::color  )  const
 

Returns:
The color currently used in the preview (default: black)

Definition at line 373 of file kfontdialog.cpp.

void KFontChooser::setBackgroundColor const QColor col  ) 
 

Sets the background color to use in the preview.

Definition at line 378 of file kfontdialog.cpp.

References QPalette::setColor().

QColor KFontChooser::backgroundColor  )  const
 

Returns:
The background color currently used in the preview (default: white)

Definition at line 386 of file kfontdialog.cpp.

void KFontChooser::setSizeIsRelative QButton::ToggleState  relative  ) 
 

Sets the state of the checkbox indicating whether the font size is to be interpreted as relative size.

NOTE: If parameter sizeIsRelative was not set in the constructor of the widget this setting will be ignored.

Definition at line 391 of file kfontdialog.cpp.

References QCheckBox::setChecked(), and QCheckBox::setNoChange().

Referenced by KFontChooser(), and KFontDialog::setSizeIsRelative().

QButton::ToggleState KFontChooser::sizeIsRelative  )  const
 

Returns:
Whether the font size is to be interpreted as relative size (default: QButton:Off)

Definition at line 402 of file kfontdialog.cpp.

References QCheckBox::state().

Referenced by KFontDialog::getFont(), KFontDialog::getFontAndText(), KFontDialog::getFontDiff(), and KFontDialog::sizeIsRelative().

QString KFontChooser::sampleText  )  const [inline]
 

Returns:
The current text in the sample text input area.

Definition at line 184 of file kfontdialog.h.

References QLineEdit::text().

Referenced by KFontDialog::getFontAndText().

void KFontChooser::setSampleText const QString text  )  [inline]
 

Sets the sample text.

Normally you should not change this text, but it can be better to do this if the default text is too large for the edit area when using the default font of your application.

Parameters:
text The new sample text. The current will be removed.

Definition at line 196 of file kfontdialog.h.

References QLineEdit::setText().

QString KFontChooser::getXLFD const QFont theFont  )  [inline, static]
 

Converts a QFont into the corresponding X Logical Font Description (XLFD).

Parameters:
theFont The font to convert.
Returns:
A string representing the given font in XLFD format.

Definition at line 208 of file kfontdialog.h.

References QFont::rawName().

void KFontChooser::getFontList QStringList list,
uint  fontListCriteria
[static]
 

Creates a list of font strings.

Parameters:
list The list is returned here.
fontListCriteria should contain all the restrictions for font selection as OR-ed values
See also:
KFontChooser::FontListCriteria for the individual values

Definition at line 640 of file kfontdialog.cpp.

References QFontDatabase::families(), QFontDatabase::isBitmapScalable(), QFontDatabase::isFixedPitch(), QFontDatabase::isSmoothlyScalable(), and QStringList::sort().

Referenced by KFontCombo::KFontCombo().

QSize KFontChooser::sizeHint void   )  const [virtual]
 

Reimplemented for internal reasons.

Reimplemented from QWidget.

Definition at line 409 of file kfontdialog.cpp.

References QWidget::minimumSizeHint().

void KFontChooser::fontSelected const QFont font  )  [signal]
 

Emitted whenever the selected font changes.

Referenced by KFontChooser().


The documentation for this class was generated from the following files:
KDE Logo
This file is part of the documentation for kdelibs Version 3.1.5.
Documentation copyright © 1996-2002 the KDE developers.
Generated on Wed Jan 28 13:00:56 2004 by doxygen 1.3.4 written by Dimitri van Heesch, © 1997-2001