| 1 |
/* Copyright (C) 2011 The gtkmm Development Team |
| 2 |
* |
| 3 |
* This library is free software; you can redistribute it and/or |
| 4 |
* modify it under the terms of the GNU Lesser General Public |
| 5 |
* License as published by the Free Software Foundation; either |
| 6 |
* version 2.1 of the License, or (at your option) any later version. |
| 7 |
* |
| 8 |
* This library is distributed in the hope that it will be useful, |
| 9 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 10 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 11 |
* Lesser General Public License for more details. |
| 12 |
* |
| 13 |
* You should have received a copy of the GNU Lesser General Public |
| 14 |
* License along with this library; if not, see <https://www.gnu.org/licenses/>. |
| 15 |
*/ |
| 16 |
|
| 17 |
_CONFIGINCLUDE(gtkmmconfig.h) |
| 18 |
|
| 19 |
_DEFS(gtkmm,gtk) |
| 20 |
_PINCLUDE(glibmm/private/interface_p.h) |
| 21 |
|
| 22 |
#include <glibmm/interface.h> |
| 23 |
#include <pangomm/fontface.h> |
| 24 |
#include <pangomm/fontdescription.h> |
| 25 |
#include <pangomm/fontfamily.h> |
| 26 |
#include <pangomm/fontmap.h> |
| 27 |
|
| 28 |
#ifndef DOXYGEN_SHOULD_SKIP_THIS |
| 29 |
extern "C" |
| 30 |
{ |
| 31 |
typedef struct _GtkFontChooserIface GtkFontChooserIface; |
| 32 |
} |
| 33 |
#endif /* DOXYGEN_SHOULD_SKIP_THIS */ |
| 34 |
|
| 35 |
namespace Gtk |
| 36 |
{ |
| 37 |
|
| 38 |
/** An interface implemented by widgets displaying fonts. |
| 39 |
* |
| 40 |
* FontChooser widgets list the available fonts, styles and |
| 41 |
* sizes, allowing the user to select a font. |
| 42 |
* |
| 43 |
* To set the font which is initially selected, use set_font_name(). |
| 44 |
* |
| 45 |
* To get the selected font use get_font_name(). |
| 46 |
* |
| 47 |
* To change the text which is shown in the preview area, use set_preview_text(). |
| 48 |
* |
| 49 |
* @ingroup FontChooser |
| 50 |
* @newin{3,2} |
| 51 |
*/ |
| 52 |
class GTKMM_API FontChooser : public Glib::Interface |
| 53 |
{ |
| 54 |
_CLASS_INTERFACE(FontChooser, GtkFontChooser, GTK_FONT_CHOOSER, GtkFontChooserIface, , , GTKMM_API) |
| 55 |
public: |
| 56 |
|
| 57 |
_WRAP_METHOD(Glib::RefPtr<Pango::FontFamily> get_font_family(), gtk_font_chooser_get_font_family, refreturn) |
| 58 |
_WRAP_METHOD(Glib::RefPtr<const Pango::FontFamily> get_font_family() const, gtk_font_chooser_get_font_family, refreturn, constversion) |
| 59 |
|
| 60 |
_WRAP_METHOD(Glib::RefPtr<Pango::FontFace> get_font_face(), gtk_font_chooser_get_font_face, refreturn) |
| 61 |
_WRAP_METHOD(Glib::RefPtr<const Pango::FontFace> get_font_face() const, gtk_font_chooser_get_font_face, refreturn, constversion) |
| 62 |
|
| 63 |
_WRAP_METHOD(int get_font_size() const, gtk_font_chooser_get_font_size) |
| 64 |
|
| 65 |
#m4 _CONVERSION(`PangoFontDescription*',`Pango::FontDescription',`Glib::wrap(const_cast<PangoFontDescription*>($3), false)') |
| 66 |
_WRAP_METHOD(Pango::FontDescription get_font_desc() const, gtk_font_chooser_get_font_desc) |
| 67 |
_WRAP_METHOD(void set_font_desc(const Pango::FontDescription& font_desc), gtk_font_chooser_set_font_desc) |
| 68 |
|
| 69 |
_WRAP_METHOD(Glib::ustring get_font() const, gtk_font_chooser_get_font) |
| 70 |
_WRAP_METHOD(void set_font(const Glib::ustring& fontname), gtk_font_chooser_set_font) |
| 71 |
_WRAP_METHOD(Glib::ustring get_preview_text() const, gtk_font_chooser_get_preview_text) |
| 72 |
_WRAP_METHOD(void set_preview_text(const Glib::ustring& text),gtk_font_chooser_set_preview_text) |
| 73 |
|
| 74 |
_WRAP_METHOD(bool get_show_preview_entry() const, gtk_font_chooser_get_show_preview_entry) |
| 75 |
_WRAP_METHOD(void set_show_preview_entry(bool show_preview_entry = true), gtk_font_chooser_set_show_preview_entry) |
| 76 |
|
| 77 |
/** Font filter callback. |
| 78 |
* For instance, |
| 79 |
* @code |
| 80 |
* bool on_font_fitler(const Glib::RefPtr<const Pango::FontFamily>& font_family, const Glib::RefPtr<const Pango::FontFace>& font_face); |
| 81 |
* @endcode |
| 82 |
* |
| 83 |
* @param font_family A Pango FontFamily. |
| 84 |
* @param font_face A Font Face belonging to the @a font_family. |
| 85 |
* @result true if the font should be displayed. |
| 86 |
* |
| 87 |
* This is used for deciding what fonts should be shown in a FontChooser. |
| 88 |
* See set_filter_func(). |
| 89 |
* |
| 90 |
* @newin{3,4} |
| 91 |
*/ |
| 92 |
typedef sigc::slot<bool, const Glib::RefPtr<const Pango::FontFamily>&, const Glib::RefPtr<const Pango::FontFace>&> SlotFontFilter; |
| 93 |
|
| 94 |
/** Adds a filter function that decides which fonts to display in the font chooser. |
| 95 |
* |
| 96 |
* @param slot A callback, to be called for each font. |
| 97 |
* |
| 98 |
* @newin{3,4} |
| 99 |
*/ |
| 100 |
void set_filter_func(const SlotFontFilter& slot); |
| 101 |
_IGNORE(gtk_font_chooser_set_filter_func) |
| 102 |
|
| 103 |
_WRAP_METHOD(void set_font_map(const Glib::RefPtr<Pango::FontMap>& fontmap), gtk_font_chooser_set_font_map) |
| 104 |
|
| 105 |
_WRAP_METHOD(Glib::RefPtr<Pango::FontMap> get_font_map(), gtk_font_chooser_get_font_map, refreturn) |
| 106 |
_WRAP_METHOD(Glib::RefPtr<const Pango::FontMap> get_font_map() const, gtk_font_chooser_get_font_map, refreturn, constversion) |
| 107 |
|
| 108 |
|
| 109 |
//TODO: Remove no_default_handler when we can break ABI. |
| 110 |
_WRAP_SIGNAL(void font_activated(const Glib::ustring& fontname), "font-activated", no_default_handler) |
| 111 |
|
| 112 |
_WRAP_PROPERTY("font", Glib::ustring) |
| 113 |
_WRAP_PROPERTY("font-desc", Pango::FontDescription) |
| 114 |
_WRAP_PROPERTY("preview_text", Glib::ustring) |
| 115 |
_WRAP_PROPERTY("show-preview-entry", bool) |
| 116 |
}; |
| 117 |
|
| 118 |
} // namespace Gtk |