1 /** @file
2 * @brief SVG Fonts dialog
3 */
4 /* Authors:
5 * Felipe CorrĂȘa da Silva Sanches <felipe.sanches@gmail.com>
6 *
7 * Copyright (C) 2008 Authors
8 * Released under GNU GPLv2 (or later). Read the file 'COPYING' for more information.
9 */
11 #ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H
12 #define INKSCAPE_UI_DIALOG_SVG_FONTS_H
14 #include "ui/widget/panel.h"
15 #include "sp-font.h"
16 #include "sp-font-face.h"
17 #include "verbs.h"
18 #include "document.h"
19 #include "desktop.h"
20 #include "desktop-handles.h"
22 #include <gtkmm.h>
23 #include <gtkmm/liststore.h>
24 #include <gtkmm/treeview.h>
25 #include <gtkmm/entry.h>
26 #include <gtkmm/box.h>
28 #include "display/nr-svgfonts.h"
29 #include "attributes.h"
30 #include "xml/helper-observer.h"
32 class SvgFontDrawingArea : Gtk::DrawingArea{
33 public:
34 SvgFontDrawingArea();
35 void set_text(Glib::ustring);
36 void set_svgfont(SvgFont*);
37 void set_size(int x, int y);
38 void redraw();
39 private:
40 int x,y;
41 SvgFont* svgfont;
42 Glib::ustring text;
43 bool on_expose_event (GdkEventExpose *event);
44 };
46 struct SPFont;
48 namespace Inkscape {
49 namespace UI {
50 namespace Dialog {
52 class GlyphComboBox : public Gtk::ComboBoxText {
53 public:
54 GlyphComboBox();
55 void update(SPFont*);
56 };
58 class SvgFontsDialog : public UI::Widget::Panel {
59 public:
60 SvgFontsDialog();
61 ~SvgFontsDialog();
63 static SvgFontsDialog &getInstance()
64 { return *new SvgFontsDialog(); }
66 void update_fonts();
67 SvgFont* get_selected_svgfont();
68 SPFont* get_selected_spfont();
69 SPGlyph* get_selected_glyph();
70 SPGlyphKerning* get_selected_kerning_pair();
72 //TODO: these methods should be private, right?!
73 void on_font_selection_changed();
74 void on_kerning_pair_selection_changed();
75 void on_preview_text_changed();
76 void on_kerning_pair_changed();
77 void on_kerning_value_changed();
78 void on_setwidth_changed();
79 void add_font();
81 //TODO: AttrEntry is currently unused. Should we remove it?
82 class AttrEntry : public Gtk::HBox
83 {
84 public:
85 AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr);
86 void set_text(char*);
87 private:
88 SvgFontsDialog* dialog;
89 void on_attr_changed();
90 Gtk::Entry entry;
91 SPAttributeEnum attr;
92 };
94 private:
95 void update_glyphs();
96 void update_sensitiveness();
97 void update_global_settings_tab();
98 void populate_glyphs_box();
99 void populate_kerning_pairs_box();
100 void set_glyph_description_from_selected_path();
101 void missing_glyph_description_from_selected_path();
102 void add_glyph();
103 void glyph_unicode_edit(const Glib::ustring&, const Glib::ustring&);
104 void glyph_name_edit(const Glib::ustring&, const Glib::ustring&);
105 void remove_selected_glyph();
106 void remove_selected_font();
108 void add_kerning_pair();
110 void create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
111 void glyphs_list_button_release(GdkEventButton* event);
113 void create_fonts_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
114 void fonts_list_button_release(GdkEventButton* event);
116 Inkscape::XML::SignalObserver _defs_observer; //in order to update fonts
117 Inkscape::XML::SignalObserver _glyphs_observer;
119 Gtk::HBox* AttrCombo(gchar* lbl, const SPAttributeEnum attr);
120 // Gtk::HBox* AttrSpin(gchar* lbl, const SPAttributeEnum attr);
121 Gtk::VBox* global_settings_tab();
122 AttrEntry* _familyname_entry;
124 Gtk::VBox* kerning_tab();
125 Gtk::VBox* glyphs_tab();
126 Gtk::Button _add;
127 Gtk::Button add_glyph_button;
128 Gtk::Button glyph_from_path_button;
129 Gtk::Button missing_glyph_button;
131 class Columns : public Gtk::TreeModel::ColumnRecord
132 {
133 public:
134 Columns()
135 {
136 add(spfont);
137 add(svgfont);
138 add(label);
139 }
141 Gtk::TreeModelColumn<SPFont*> spfont;
142 Gtk::TreeModelColumn<SvgFont*> svgfont;
143 Gtk::TreeModelColumn<Glib::ustring> label;
144 };
145 Glib::RefPtr<Gtk::ListStore> _model;
146 Columns _columns;
147 Gtk::TreeView _FontsList;
149 class GlyphsColumns : public Gtk::TreeModel::ColumnRecord
150 {
151 public:
152 GlyphsColumns()
153 {
154 add(glyph_node);
155 add(glyph_name);
156 add(unicode);
157 }
159 Gtk::TreeModelColumn<SPGlyph*> glyph_node;
160 Gtk::TreeModelColumn<Glib::ustring> glyph_name;
161 Gtk::TreeModelColumn<Glib::ustring> unicode;
162 };
163 GlyphsColumns _GlyphsListColumns;
164 Glib::RefPtr<Gtk::ListStore> _GlyphsListStore;
165 Gtk::TreeView _GlyphsList;
166 Gtk::ScrolledWindow _GlyphsListScroller;
168 class KerningPairColumns : public Gtk::TreeModel::ColumnRecord
169 {
170 public:
171 KerningPairColumns()
172 {
173 add(first_glyph);
174 add(second_glyph);
175 add(kerning_value);
176 add(spnode);
177 }
179 Gtk::TreeModelColumn<Glib::ustring> first_glyph;
180 Gtk::TreeModelColumn<Glib::ustring> second_glyph;
181 Gtk::TreeModelColumn<double> kerning_value;
182 Gtk::TreeModelColumn<SPGlyphKerning*> spnode;
183 };
184 KerningPairColumns _KerningPairsListColumns;
185 Glib::RefPtr<Gtk::ListStore> _KerningPairsListStore;
186 Gtk::TreeView _KerningPairsList;
187 Gtk::ScrolledWindow _KerningPairsListScroller;
188 Gtk::Button add_kernpair_button;
190 Gtk::VBox _font_settings;
191 Gtk::VBox global_vbox;
192 Gtk::VBox glyphs_vbox;
193 Gtk::VBox kerning_vbox;
194 Gtk::Entry _preview_entry;
196 Gtk::Menu _FontsContextMenu;
197 Gtk::Menu _GlyphsContextMenu;
199 SvgFontDrawingArea _font_da, kerning_preview;
200 GlyphComboBox first_glyph, second_glyph;
201 SPGlyphKerning* kerning_pair;
202 Gtk::SpinButton setwidth_spin;
203 Gtk::HScale kerning_slider;
205 class EntryWidget : public Gtk::HBox
206 {
207 public:
208 EntryWidget()
209 {
210 this->add(this->_label);
211 this->add(this->_entry);
212 }
213 void set_label(const gchar* l){
214 this->_label.set_text(l);
215 }
216 private:
217 Gtk::Label _label;
218 Gtk::Entry _entry;
219 };
220 EntryWidget _font_family, _font_variant;
221 };
223 } // namespace Dialog
224 } // namespace UI
225 } // namespace Inkscape
227 #endif //#ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H