• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdelibs API Reference
  • KDE Home
  • Contact Us
 

KDEUI

Public Types | Signals | Public Member Functions | Static Public Member Functions | Properties | List of all members
KFontChooser Class Reference

#include <kfontchooser.h>

Inheritance diagram for KFontChooser:
Inheritance graph
[legend]

Public Types

enum  DisplayFlag { NoDisplayFlags = 0, FixedFontsOnly = 1, DisplayFrame = 2, ShowDifferences = 4 }
 
enum  FontColumn { FamilyList =0x01, StyleList =0x02, SizeList =0x04 }
 
enum  FontDiff {
  NoFontDiffFlags = 0, FontDiffFamily = 1, FontDiffStyle = 2, FontDiffSize = 4,
  AllFontDiffs = FontDiffFamily | FontDiffStyle | FontDiffSize
}
 
enum  FontListCriteria { FixedWidthFonts =0x01, ScalableFonts =0x02, SmoothScalableFonts =0x04 }
 

Signals

void fontSelected (const QFont &font)
 

Public Member Functions

 KFontChooser (QWidget *parent=0L, const DisplayFlags &flags=DisplayFrame, const QStringList &fontList=QStringList(), int visibleListSize=8, Qt::CheckState *sizeIsRelativeState=0L)
 
virtual ~KFontChooser ()
 
QColor backgroundColor () const
 
QColor color () const
 
void enableColumn (int column, bool state)
 
QFont font () const
 
FontDiffFlags fontDiffFlags () const
 
QString sampleText () const
 
void setBackgroundColor (const QColor &col)
 
void setColor (const QColor &col)
 
void setFont (const QFont &font, bool onlyFixed=false)
 
void setSampleBoxVisible (bool visible)
 
void setSampleText (const QString &text)
 
void setSizeIsRelative (Qt::CheckState relative)
 
virtual QSize sizeHint (void) const
 
Qt::CheckState sizeIsRelative () const
 

Static Public Member Functions

static void getFontList (QStringList &list, uint fontListCriteria)
 

Properties

QColor backgroundColor
 
QColor color
 
QFont font
 
QString sampleText
 
Qt::CheckState sizeIsRelative
 

Detailed Description

A font selection widget.

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.

kfontchooser.png
KDE Font Chooser Widget
See also
KFontRequester
Author
Preston Brown pbrow.nosp@m.n@kd.nosp@m.e.org, Bernd Wuebben wuebb.nosp@m.en@k.nosp@m.de.or.nosp@m.g

Definition at line 47 of file kfontchooser.h.

Member Enumeration Documentation

enum KFontChooser::DisplayFlag
  • FixedFontsOnly only show fixed fonts, excluding proportional fonts
  • DisplayFrame show a visual frame around the chooser
  • ShowDifferences display the font differences interfaces
Enumerator
NoDisplayFlags 
FixedFontsOnly 
DisplayFrame 
ShowDifferences 

Definition at line 81 of file kfontchooser.h.

enum KFontChooser::FontColumn
  • FamilyList - Identifies the family (leftmost) list.
  • StyleList - Identifies the style (center) list.
  • SizeList - Identifies the size (rightmost) list.
Enumerator
FamilyList 
StyleList 
SizeList 

Definition at line 62 of file kfontchooser.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.
Enumerator
NoFontDiffFlags 
FontDiffFamily 
FontDiffStyle 
FontDiffSize 
AllFontDiffs 

Definition at line 69 of file kfontchooser.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.
Enumerator
FixedWidthFonts 
ScalableFonts 
SmoothScalableFonts 

Definition at line 232 of file kfontchooser.h.

Constructor & Destructor Documentation

KFontChooser::KFontChooser ( QWidget *  parent = 0L,
const DisplayFlags &  flags = DisplayFrame,
const QStringList &  fontList = QStringList(),
int  visibleListSize = 8,
Qt::CheckState *  sizeIsRelativeState = 0L 
)
explicit

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, KFontChooser::SmoothScalableFonts);
KFontChooser *chooseFont = new KFontChooser(0, NoDisplayFlags, list);

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

Parameters
parentThe parent widget.
flagsDefines how the font chooser is displayed.
See also
DisplayFlags
Parameters
fontListA 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.
visibleListSizeThe minimum number of visible entries in the fontlists.
sizeIsRelativeStateIf 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 156 of file kfontchooser.cpp.

KFontChooser::~KFontChooser ( )
virtual

Destructs the font chooser.

Definition at line 443 of file kfontchooser.cpp.

Member Function Documentation

QColor KFontChooser::backgroundColor ( ) const
Returns
The background color currently used in the preview (default: the base color of the active colorgroup)
QColor KFontChooser::color ( ) const
Returns
The color currently used in the preview (default: the text color of the active color group)
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
columnSpecify the columns. An or'ed combination of FamilyList, StyleList and SizeList is possible.
stateIf false the columns are disabled.

Definition at line 517 of file kfontchooser.cpp.

QFont KFontChooser::font ( ) const
Returns
The currently selected font in the chooser.
KFontChooser::FontDiffFlags KFontChooser::fontDiffFlags ( ) const
Returns
The bitmask corresponding to the attributes the user wishes to change.

Definition at line 551 of file kfontchooser.cpp.

void KFontChooser::fontSelected ( const QFont &  font)
signal

Emitted whenever the selected font changes.

void KFontChooser::getFontList ( QStringList &  list,
uint  fontListCriteria 
)
static

Creates a list of font strings.

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

Definition at line 1000 of file kfontchooser.cpp.

QString KFontChooser::sampleText ( ) const
Returns
The current text in the sample text input area.
void KFontChooser::setBackgroundColor ( const QColor &  col)

Sets the background color to use in the preview.

Definition at line 465 of file kfontchooser.cpp.

void KFontChooser::setColor ( const QColor &  col)

Sets the color to use in the preview.

Definition at line 448 of file kfontchooser.cpp.

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

Sets the currently selected font in the chooser.

Parameters
fontThe font to select.
onlyFixedReadjust the font list to display only fixed width fonts if true, or vice-versa.

Definition at line 535 of file kfontchooser.cpp.

void KFontChooser::setSampleBoxVisible ( bool  visible)

Shows or hides the sample text box.

Parameters
visibleSet it to true to show the box, to false to hide it.

Definition at line 506 of file kfontchooser.cpp.

void KFontChooser::setSampleText ( const QString &  text)

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
textThe new sample text. The current will be removed.

Definition at line 501 of file kfontchooser.cpp.

void KFontChooser::setSizeIsRelative ( Qt::CheckState  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 478 of file kfontchooser.cpp.

QSize KFontChooser::sizeHint ( void  ) const
virtual

Reimplemented for internal reasons.

Definition at line 511 of file kfontchooser.cpp.

Qt::CheckState KFontChooser::sizeIsRelative ( ) const
Returns
Whether the font size is to be interpreted as relative size (default: QButton:Off)

Property Documentation

QColor KFontChooser::backgroundColor
readwrite

Definition at line 52 of file kfontchooser.h.

QColor KFontChooser::color
readwrite

Definition at line 51 of file kfontchooser.h.

QFont KFontChooser::font
readwrite

Definition at line 50 of file kfontchooser.h.

QString KFontChooser::sampleText
readwrite

Definition at line 54 of file kfontchooser.h.

Qt::CheckState KFontChooser::sizeIsRelative
readwrite

Definition at line 53 of file kfontchooser.h.


The documentation for this class was generated from the following files:
  • kfontchooser.h
  • kfontchooser.cpp
This file is part of the KDE documentation.
Documentation copyright © 1996-2014 The KDE developers.
Generated on Tue Oct 14 2014 22:49:17 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

KDEUI

Skip menu "KDEUI"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members
  • Modules
  • Related Pages

kdelibs API Reference

Skip menu "kdelibs API Reference"
  • DNSSD
  • Interfaces
  •   KHexEdit
  •   KMediaPlayer
  •   KSpeech
  •   KTextEditor
  • kconf_update
  • KDE3Support
  •   KUnitTest
  • KDECore
  • KDED
  • KDEsu
  • KDEUI
  • KDEWebKit
  • KDocTools
  • KFile
  • KHTML
  • KImgIO
  • KInit
  • kio
  • KIOSlave
  • KJS
  •   KJS-API
  • kjsembed
  •   WTF
  • KNewStuff
  • KParts
  • KPty
  • Kross
  • KUnitConversion
  • KUtils
  • Nepomuk
  • Nepomuk-Core
  • Nepomuk
  • Plasma
  • Solid
  • Sonnet
  • ThreadWeaver

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal