gtkmm: Gtk::FontChooser Class Reference

gtkmm 3.4.0

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes

- Class List
- Class Index
- Class Hierarchy
- Class Members

Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Related Functions
Gtk::FontChooser Class Reference

An interface implemented by widgets displaying fonts. More...

Inheritance diagram for Gtk::FontChooser:
[legend]

List of all members.

## Public Types
typedef sigc::slot< bool, const Glib::RefPtr< const Pango::FontFamily > &, const Glib::RefPtr< const Pango::FontFace >& > | SlotFontFilter
| Font filter callback.
## Public Member Functions
virtual | ~FontChooser ()
GtkFontChooser* | gobj ()
| Provides access to the underlying C GObject.
const GtkFontChooser* | gobj () const
| Provides access to the underlying C GObject.
Glib::RefPtr< Pango::FontFamily > | get_font_family ()
| Gets the Pango::FontFamily representing the selected font family.
Glib::RefPtr< const Pango::FontFamily > | get_font_family () const
| Gets the Pango::FontFamily representing the selected font family.
Glib::RefPtr< Pango::FontFace > | get_font_face ()
| Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).
Glib::RefPtr< const Pango::FontFace > | get_font_face () const
| Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).
int | get_font_size () const
| The selected font size.
Pango::FontDescription | get_font_desc () const
| Gets the currently-selected font.
void | set_font_desc (const Pango::FontDescription& font_desc)
| Sets the currently-selected font from font_desc.
Glib::ustring | get_font () const
| Gets the currently-selected font name.
void | set_font (const Glib::ustring& font)
| Sets the currently-selected font.
Glib::ustring | get_preview_text () const
| Gets the text displayed in the preview area.
void | set_preview_text (const Glib::ustring& fontname)
| Sets the text displayed in the preview area.
bool | get_show_preview_entry () const
| Returns whether the preview entry is shown or not.
void | set_show_preview_entry (bool show_preview_entry=true)
| Shows or hides the editable preview entry.
void | set_filter_func (const SlotFontFilter& slot)
| Adds a filter function that decides which fonts to display in the font chooser.
Glib::SignalProxy1< void, const Glib::ustring& > | signal_font_activated ()
Glib::PropertyProxy < Glib::ustring > | property_font ()
| Font description as a string, e.g.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_font () const
| Font description as a string, e.g.
Glib::PropertyProxy < Pango::FontDescription > | property_font_desc ()
| Font description as a PangoFontDescription struct.
Glib::PropertyProxy_ReadOnly < Pango::FontDescription > | property_font_desc () const
| Font description as a PangoFontDescription struct.
Glib::PropertyProxy < Glib::ustring > | property_preview_text ()
| The text to display in order to demonstrate the selected font.
Glib::PropertyProxy_ReadOnly < Glib::ustring > | property_preview_text () const
| The text to display in order to demonstrate the selected font.
Glib::PropertyProxy< bool > | property_show_preview_entry ()
| Whether the preview text entry is shown or not.
Glib::PropertyProxy_ReadOnly < bool > | property_show_preview_entry () const
| Whether the preview text entry is shown or not.
## Static Public Member Functions
static void | add_interface (GType gtype_implementer)
## Protected Member Functions
| FontChooser ()
| You should derive from this class to use it.
## Related Functions
(Note that these are not member functions.)
Glib::RefPtr< Gtk::FontChooser > | wrap (GtkFontChooser* object, bool take_copy=false)
| A Glib::wrap() method for this object.

## Detailed Description

An interface implemented by widgets displaying fonts.

FontChooser widgets list the available fonts, styles and sizes, allowing the user to select a font.

To set the font which is initially selected, use set_font_name().

To get the selected font use get_font_name().

To change the text which is shown in the preview area, use set_preview_text().

Since gtkmm 3.2:

## Member Typedef Documentation

typedef sigc::slot<bool, const Glib::RefPtr<const Pango::FontFamily>&, const Glib::RefPtr<const Pango::FontFace>&> Gtk::FontChooser::SlotFontFilter

Font filter callback.

For instance,

     bool on_font_fitler(const Glib::RefPtr<const Pango::FontFamily>& font_family, const Glib::RefPtr<const Pango::FontFace>& font_face);

Parameters:

  font_family | A Pango FontFamily.
  font_face | A Font Face belonging to the font_family.

Returns:
  true if the font should be displayed.

This is used for deciding what fonts should be shown in a FontChooser. See set_filter_func().

Since gtkmm 3.4:

## Constructor & Destructor Documentation

Gtk::FontChooser::FontChooser | ( |  | ) | `[protected]`

You should derive from this class to use it.

virtual Gtk::FontChooser::~FontChooser | ( |  | ) | `[virtual]`

## Member Function Documentation

static void Gtk::FontChooser::add_interface | ( | GType | gtype_implementer | ) | `[static]`

Glib::ustring Gtk::FontChooser::get_font | ( |  | ) | const

Gets the currently-selected font name.

Note that this can be a different string than what you set with set_font(), as the font chooser widget may normalize font names and thus return a string with a different structure. For example, "Helvetica Italic Bold 12" could be normalized to "Helvetica Bold Italic 12".

Use pango_font_description_equal() if you want to compare two font descriptions.

Since gtkmm 3.2:

Returns:
  A string with the name of the current font, or `0` if no font is selected. You must free this string with Glib::free().

Pango::FontDescription Gtk::FontChooser::get_font_desc | ( |  | ) | const

Gets the currently-selected font.

Note that this can be a different string than what you set with set_font(), as the font chooser widget may normalize font names and thus return a string with a different structure. For example, "Helvetica Italic Bold 12" could be normalized to "Helvetica Bold Italic 12".

Use pango_font_description_equal() if you want to compare two font descriptions.

Since gtkmm 3.2:

Returns:
  A Pango::FontDescription for the current font, or `0` if no font is selected.

Glib::RefPtr<Pango::FontFace> Gtk::FontChooser::get_font_face | ( |  | ) |

Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).

If the selected font is not installed, returns `0`.

Since gtkmm 3.2:

Returns:
  A Pango::FontFace representing the selected font group details, or `0`. The returned object is owned by fontchooser and must not be modified or freed.

Glib::RefPtr<const Pango::FontFace> Gtk::FontChooser::get_font_face | ( |  | ) | const

Gets the Pango::FontFace representing the selected font group details (i.e. family, slant, weight, width, etc).

If the selected font is not installed, returns `0`.

Since gtkmm 3.2:

Returns:
  A Pango::FontFace representing the selected font group details, or `0`. The returned object is owned by fontchooser and must not be modified or freed.

Glib::RefPtr<Pango::FontFamily> Gtk::FontChooser::get_font_family | ( |  | ) |

Gets the Pango::FontFamily representing the selected font family.

Font families are a collection of font faces.

If the selected font is not installed, returns `0`.

Since gtkmm 3.2:

Returns:
  A Pango::FontFamily representing the selected font family, or `0`. The returned object is owned by fontchooser and must not be modified or freed.

Glib::RefPtr<const Pango::FontFamily> Gtk::FontChooser::get_font_family | ( |  | ) | const

Gets the Pango::FontFamily representing the selected font family.

Font families are a collection of font faces.

If the selected font is not installed, returns `0`.

Since gtkmm 3.2:

Returns:
  A Pango::FontFamily representing the selected font family, or `0`. The returned object is owned by fontchooser and must not be modified or freed.

int Gtk::FontChooser::get_font_size | ( |  | ) | const

The selected font size.

Since gtkmm 3.2:

Returns:
  A n integer representing the selected font size, or -1 if no font size is selected.

Glib::ustring Gtk::FontChooser::get_preview_text | ( |  | ) | const

Gets the text displayed in the preview area.

Since gtkmm 3.2:

Returns:
  The text displayed in the preview area.

bool Gtk::FontChooser::get_show_preview_entry | ( |  | ) | const

Returns whether the preview entry is shown or not.

Since gtkmm 3.2:

Returns:
  `true` if the preview entry is shown or `false` if it is hidden.

GtkFontChooser* Gtk::FontChooser::gobj | ( |  | ) | `[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

Reimplemented in Gtk::FontChooserDialog, and Gtk::FontChooserWidget.

const GtkFontChooser* Gtk::FontChooser::gobj | ( |  | ) | const`[inline]`

Provides access to the underlying C GObject.

Reimplemented from Glib::Interface.

Reimplemented in Gtk::FontChooserDialog, and Gtk::FontChooserWidget.

Glib::PropertyProxy< Glib::ustring > Gtk::FontChooser::property_font | ( |  | ) |

Font description as a string, e.g.

'Sans Italic 12'.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontChooser::property_font | ( |  | ) | const

Font description as a string, e.g.

'Sans Italic 12'.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy< Pango::FontDescription > Gtk::FontChooser::property_font_desc | ( |  | ) |

Font description as a PangoFontDescription struct.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Pango::FontDescription > Gtk::FontChooser::property_font_desc | ( |  | ) | const

Font description as a PangoFontDescription struct.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy< Glib::ustring > Gtk::FontChooser::property_preview_text | ( |  | ) |

The text to display in order to demonstrate the selected font.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< Glib::ustring > Gtk::FontChooser::property_preview_text | ( |  | ) | const

The text to display in order to demonstrate the selected font.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy< bool > Gtk::FontChooser::property_show_preview_entry | ( |  | ) |

Whether the preview text entry is shown or not.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

Glib::PropertyProxy_ReadOnly< bool > Gtk::FontChooser::property_show_preview_entry | ( |  | ) | const

Whether the preview text entry is shown or not.

You rarely need to use properties because there are get_ and set_ methods for almost all of them.

Returns:
  A PropertyProxy that allows you to get or set the property of the value, or receive notification when the value of the property changes.

void Gtk::FontChooser::set_filter_func | ( | const SlotFontFilter& | slot | ) |

Adds a filter function that decides which fonts to display in the font chooser.

Parameters:

  slot | A callback, to be called for each font.

Since gtkmm 3.4:

void Gtk::FontChooser::set_font | ( | const Glib::ustring & | font | ) |

Sets the currently-selected font.

Since gtkmm 3.2:

Parameters:

  fontname | A font name like "Helvetica 12" or "Times Bold 18".

void Gtk::FontChooser::set_font_desc | ( | const Pango::FontDescription & | font_desc | ) |

Sets the currently-selected font from font_desc.

Since gtkmm 3.2:

Parameters:

  font_desc | A Pango::FontDescription.

void Gtk::FontChooser::set_preview_text | ( | const Glib::ustring & | fontname | ) |

Sets the text displayed in the preview area.

The text is used to show how the selected font looks.

Since gtkmm 3.2:

Parameters:

  text | The text to display in the preview area.

void Gtk::FontChooser::set_show_preview_entry | ( | bool | show_preview_entry = `true` | ) |

Shows or hides the editable preview entry.

Since gtkmm 3.2:

Parameters:

  show_preview_entry | Whether to show the editable preview entry or not.

Glib::SignalProxy1< void,const Glib::ustring& > Gtk::FontChooser::signal_font_activated | ( |  | ) |

Slot Prototype:
  `void on_my_font_activated(const Glib::ustring& fontname)`

## Friends And Related Function Documentation

Glib::RefPtr< Gtk::FontChooser > wrap | ( | GtkFontChooser * | object,
|  | bool | take_copy = `false`
| ) |  | `[related]`

A Glib::wrap() method for this object.

Parameters:

  object | The C instance.
  take_copy | False if the result should take ownership of the C instance. True if it should take a new copy or ref.

Returns:
  A C++ instance that wraps this C instance.

The documentation for this class was generated from the following file:

- gtkmm/fontchooser.h