Code

Translations. French translation minor update.
[inkscape.git] / src / ui / dialog / svg-fonts-dialog.h
1 /** @file
2  * @brief SVG Fonts dialog
3  */
4 /* Authors:
5  *   Felipe CorrĂȘa da Silva Sanches <juca@members.fsf.org>
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 reset_missing_glyph_description();
103         void add_glyph();
104         void glyph_unicode_edit(const Glib::ustring&, const Glib::ustring&);
105         void glyph_name_edit(const Glib::ustring&, const Glib::ustring&);
106         void remove_selected_glyph();
107         void remove_selected_font();
108         void remove_selected_kerning_pair();
110         void add_kerning_pair();
112         void create_glyphs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
113         void glyphs_list_button_release(GdkEventButton* event);
115         void create_fonts_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
116         void fonts_list_button_release(GdkEventButton* event);
118         void create_kerning_pairs_popup_menu(Gtk::Widget& parent, sigc::slot<void> rem);
119         void kerning_pairs_list_button_release(GdkEventButton* event);
121     Inkscape::XML::SignalObserver _defs_observer; //in order to update fonts
122     Inkscape::XML::SignalObserver _glyphs_observer;
124     Gtk::HBox* AttrCombo(gchar* lbl, const SPAttributeEnum attr);
125 //    Gtk::HBox* AttrSpin(gchar* lbl, const SPAttributeEnum attr);
126     Gtk::VBox* global_settings_tab();
127         AttrEntry* _familyname_entry;
129     Gtk::VBox* kerning_tab();
130     Gtk::VBox* glyphs_tab();
131     Gtk::Button _add;
132     Gtk::Button add_glyph_button;
133         Gtk::Button glyph_from_path_button;
134         Gtk::Button missing_glyph_button;
135         Gtk::Button missing_glyph_reset_button;
137     class Columns : public Gtk::TreeModel::ColumnRecord
138         {
139         public:
140             Columns()
141             {
142                 add(spfont);
143                 add(svgfont);
144                 add(label);
145             }
147             Gtk::TreeModelColumn<SPFont*> spfont;
148             Gtk::TreeModelColumn<SvgFont*> svgfont;
149             Gtk::TreeModelColumn<Glib::ustring> label;
150     };
151     Glib::RefPtr<Gtk::ListStore> _model;
152     Columns _columns;
153     Gtk::TreeView _FontsList;
155     class GlyphsColumns : public Gtk::TreeModel::ColumnRecord
156         {
157         public:
158             GlyphsColumns()
159             {
160                                 add(glyph_node);
161                                 add(glyph_name);
162                                 add(unicode);
163                         }
165             Gtk::TreeModelColumn<SPGlyph*> glyph_node;
166             Gtk::TreeModelColumn<Glib::ustring> glyph_name;
167             Gtk::TreeModelColumn<Glib::ustring> unicode;
168     };
169     GlyphsColumns _GlyphsListColumns;
170     Glib::RefPtr<Gtk::ListStore> _GlyphsListStore;
171     Gtk::TreeView _GlyphsList;
172     Gtk::ScrolledWindow _GlyphsListScroller;
174     class KerningPairColumns : public Gtk::TreeModel::ColumnRecord
175         {
176         public:
177             KerningPairColumns()
178             {
179                                 add(first_glyph);
180                                 add(second_glyph);
181                                 add(kerning_value);
182                                 add(spnode);
183                         }
185             Gtk::TreeModelColumn<Glib::ustring> first_glyph;
186             Gtk::TreeModelColumn<Glib::ustring> second_glyph;
187             Gtk::TreeModelColumn<double> kerning_value;
188             Gtk::TreeModelColumn<SPGlyphKerning*> spnode;
189     };
190     KerningPairColumns _KerningPairsListColumns;
191     Glib::RefPtr<Gtk::ListStore> _KerningPairsListStore;
192     Gtk::TreeView _KerningPairsList;
193     Gtk::ScrolledWindow _KerningPairsListScroller;
194         Gtk::Button add_kernpair_button;
196     Gtk::VBox _font_settings;
197         Gtk::VBox global_vbox;
198         Gtk::VBox glyphs_vbox;
199     Gtk::VBox kerning_vbox;
200     Gtk::Entry _preview_entry;
202     Gtk::Menu _FontsContextMenu;
203     Gtk::Menu _GlyphsContextMenu;
204     Gtk::Menu _KerningPairsContextMenu;
206     SvgFontDrawingArea _font_da, kerning_preview;
207     GlyphComboBox first_glyph, second_glyph;
208     SPGlyphKerning* kerning_pair;
209     Gtk::SpinButton setwidth_spin;
210     Gtk::HScale kerning_slider;
212     class EntryWidget : public Gtk::HBox
213         {
214         public:
215             EntryWidget()
216             {
217                 this->add(this->_label);
218                 this->add(this->_entry);
219             }
220             void set_label(const gchar* l){
221                 this->_label.set_text(l);
222             }
223         private:
224             Gtk::Label _label;
225             Gtk::Entry _entry;
226         };
227     EntryWidget _font_family, _font_variant;
228 };
230 } // namespace Dialog
231 } // namespace UI
232 } // namespace Inkscape
234 #endif //#ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H