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();
107 void remove_selected_kerning_pair();
109 void add_kerning_pair();
111 void create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
112 void glyphs_list_button_release(GdkEventButton* event);
114 void create_fonts_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
115 void fonts_list_button_release(GdkEventButton* event);
117 void create_kerning_pairs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
118 void kerning_pairs_list_button_release(GdkEventButton* event);
120 Inkscape::XML::SignalObserver _defs_observer; //in order to update fonts
121 Inkscape::XML::SignalObserver _glyphs_observer;
123 Gtk::HBox* AttrCombo(gchar* lbl, const SPAttributeEnum attr);
124 // Gtk::HBox* AttrSpin(gchar* lbl, const SPAttributeEnum attr);
125 Gtk::VBox* global_settings_tab();
126 AttrEntry* _familyname_entry;
128 Gtk::VBox* kerning_tab();
129 Gtk::VBox* glyphs_tab();
130 Gtk::Button _add;
131 Gtk::Button add_glyph_button;
132 Gtk::Button glyph_from_path_button;
133 Gtk::Button missing_glyph_button;
135 class Columns : public Gtk::TreeModel::ColumnRecord
136 {
137 public:
138 Columns()
139 {
140 add(spfont);
141 add(svgfont);
142 add(label);
143 }
145 Gtk::TreeModelColumn<SPFont*> spfont;
146 Gtk::TreeModelColumn<SvgFont*> svgfont;
147 Gtk::TreeModelColumn<Glib::ustring> label;
148 };
149 Glib::RefPtr<Gtk::ListStore> _model;
150 Columns _columns;
151 Gtk::TreeView _FontsList;
153 class GlyphsColumns : public Gtk::TreeModel::ColumnRecord
154 {
155 public:
156 GlyphsColumns()
157 {
158 add(glyph_node);
159 add(glyph_name);
160 add(unicode);
161 }
163 Gtk::TreeModelColumn<SPGlyph*> glyph_node;
164 Gtk::TreeModelColumn<Glib::ustring> glyph_name;
165 Gtk::TreeModelColumn<Glib::ustring> unicode;
166 };
167 GlyphsColumns _GlyphsListColumns;
168 Glib::RefPtr<Gtk::ListStore> _GlyphsListStore;
169 Gtk::TreeView _GlyphsList;
170 Gtk::ScrolledWindow _GlyphsListScroller;
172 class KerningPairColumns : public Gtk::TreeModel::ColumnRecord
173 {
174 public:
175 KerningPairColumns()
176 {
177 add(first_glyph);
178 add(second_glyph);
179 add(kerning_value);
180 add(spnode);
181 }
183 Gtk::TreeModelColumn<Glib::ustring> first_glyph;
184 Gtk::TreeModelColumn<Glib::ustring> second_glyph;
185 Gtk::TreeModelColumn<double> kerning_value;
186 Gtk::TreeModelColumn<SPGlyphKerning*> spnode;
187 };
188 KerningPairColumns _KerningPairsListColumns;
189 Glib::RefPtr<Gtk::ListStore> _KerningPairsListStore;
190 Gtk::TreeView _KerningPairsList;
191 Gtk::ScrolledWindow _KerningPairsListScroller;
192 Gtk::Button add_kernpair_button;
194 Gtk::VBox _font_settings;
195 Gtk::VBox global_vbox;
196 Gtk::VBox glyphs_vbox;
197 Gtk::VBox kerning_vbox;
198 Gtk::Entry _preview_entry;
200 Gtk::Menu _FontsContextMenu;
201 Gtk::Menu _GlyphsContextMenu;
202 Gtk::Menu _KerningPairsContextMenu;
204 SvgFontDrawingArea _font_da, kerning_preview;
205 GlyphComboBox first_glyph, second_glyph;
206 SPGlyphKerning* kerning_pair;
207 Gtk::SpinButton setwidth_spin;
208 Gtk::HScale kerning_slider;
210 class EntryWidget : public Gtk::HBox
211 {
212 public:
213 EntryWidget()
214 {
215 this->add(this->_label);
216 this->add(this->_entry);
217 }
218 void set_label(const gchar* l){
219 this->_label.set_text(l);
220 }
221 private:
222 Gtk::Label _label;
223 Gtk::Entry _entry;
224 };
225 EntryWidget _font_family, _font_variant;
226 };
228 } // namespace Dialog
229 } // namespace UI
230 } // namespace Inkscape
232 #endif //#ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H