05511198c09da57969ce1b9f35c094bed72e0c92
1 #ifndef FONT_LISTER_H
2 #define FONT_LISTER_H
4 /*
5 * Font selection widgets
6 *
7 * Authors:
8 * Chris Lahey <clahey@ximian.com>
9 * Lauris Kaplinski <lauris@kaplinski.com>
10 *
11 * Copyright (C) 1999-2001 Ximian, Inc.
12 * Copyright (C) 2002 Lauris Kaplinski
13 *
14 * Released under GNU GPL, read the file 'COPYING' for more information
15 */
17 #include <glibmm.h>
18 #include <gtkmm.h>
20 namespace Inkscape
21 {
22 /**
23 * This class enumerates fonts using libnrtype into reusable data stores and
24 * allows for random access to the font list
25 */
26 class FontLister
27 {
28 public:
29 ~FontLister ();
31 /** GtkTreeModelColumnRecord for the font list Gtk::ListStore
32 */
33 class FontListClass
34 : public Gtk::TreeModelColumnRecord
35 {
36 public:
37 /** Column containing the family name
38 */
39 Gtk::TreeModelColumn<std::string> font;
41 /** Column containing an std::vector<std::string> with style names
42 * for the corresponding family
43 */
44 Gtk::TreeModelColumn<GList*> styles;
46 FontListClass ()
47 {
48 add (font);
49 add (styles);
50 }
51 };
53 FontListClass FontList;
54 typedef std::map<std::string, Gtk::TreePath> IterMapType;
56 /** Returns the ListStore with the font names
57 *
58 * The return is const and the function is declared as const.
59 * The ListStore is ready to be used after class instantiation
60 * and should not (cannot) be modified.
61 */
62 const Glib::RefPtr<Gtk::ListStore>
63 get_font_list () const;
65 static Inkscape::FontLister*
66 get_instance ()
67 {
68 static Inkscape::FontLister* instance = new Inkscape::FontLister();
69 return instance;
70 }
72 Gtk::TreePath
73 get_row_for_font (std::string family)
74 {
75 IterMapType::iterator iter = font_list_store_iter_map.find (family);
76 return (*iter).second;
77 }
79 const NRNameList
80 get_name_list () const
81 {
82 return families;
83 }
86 private:
88 FontLister ();
90 NRNameList families;
92 Glib::RefPtr<Gtk::ListStore> font_list_store;
93 IterMapType font_list_store_iter_map;
95 };
96 }
98 #endif
100 /*
101 Local Variables:
102 mode:c++
103 c-file-style:"stroustrup"
104 c-file-offsets:((innamespace . 0)(inline-open . 0)(case-label . +))
105 indent-tabs-mode:nil
106 fill-column:99
107 End:
108 */
109 // vim: filetype=cpp:expandtab:shiftwidth=4:tabstop=8:softtabstop=4:encoding=utf-8:textwidth=99 :