Code

24da11f10760df258706fa22c1ecc1772306cdf1
[inkscape.git] / src / ui / dialog / svg-fonts-dialog.h
1 /**
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  *
9  * Released under GNU GPLv2 (or later).  Read the file 'COPYING' for more information.
10  */
12 #ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H
13 #define INKSCAPE_UI_DIALOG_SVG_FONTS_H
15 #include "ui/widget/panel.h"
16 #include "sp-font.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"
30 class SvgFontDrawingArea : Gtk::DrawingArea{
31 public:
32     SvgFontDrawingArea();
33     void set_text(Glib::ustring);
34     void set_svgfont(SvgFont*);
35     void set_size(int x, int y);
36     void redraw();
37 private:
38     int x,y;
39     SvgFont* svgfont;
40     Glib::ustring text;
41     bool on_expose_event (GdkEventExpose *event);
42 };
44 struct SPFont;
46 namespace Inkscape {
47 namespace UI {
48 namespace Dialog {
50 class GlyphComboBox : public Gtk::ComboBoxText {
51 public:
52     GlyphComboBox();
53     void update(SPFont*);
54 };
56 class SvgFontsDialog : public UI::Widget::Panel {
57 public:
58     SvgFontsDialog();
59     ~SvgFontsDialog();
61     static SvgFontsDialog &getInstance()
62     { return *new SvgFontsDialog(); }
64     void update_fonts();
65     SvgFont* get_selected_svgfont();
66     SPFont* get_selected_spfont();
67     void on_font_selection_changed();
68     void on_preview_text_changed();
69     void on_glyphs_changed();
70     void on_kerning_changed();
71 private:
72     class Columns : public Gtk::TreeModel::ColumnRecord
73         {
74         public:
75             Columns()
76             {
77                 add(spfont);
78                 add(svgfont);
79                 add(label);
80             }
82             Gtk::TreeModelColumn<SPFont*> spfont;
83             Gtk::TreeModelColumn<SvgFont*> svgfont;
84             Gtk::TreeModelColumn<Glib::ustring> label;
85     };
86     Glib::RefPtr<Gtk::ListStore> _model;
87     Columns _columns;
88     Gtk::TreeView _font_list;
89     Gtk::VBox _font_settings;
90     Gtk::Entry _preview_entry;
91     SvgFontDrawingArea _font_da, kerning_preview;
92     GlyphComboBox first_glyph, second_glyph;
93     SPGlyphKerning* kerning_pair;
94     Gtk::SpinButton kerning_spin;
96     class EntryWidget : public Gtk::HBox
97         {
98         public:
99             EntryWidget()
100             {
101                 this->add(this->_label);
102                 this->add(this->_entry);
103             }
104             void set_label(const gchar* l){
105                 this->_label.set_text(l);
106             }
107         private:
108             Gtk::Label _label;
109             Gtk::Entry _entry;
110         };
111     EntryWidget _font_family, _font_variant;
112 };
114 } // namespace Dialog
115 } // namespace UI
116 } // namespace Inkscape
118 #endif //#ifndef INKSCAPE_UI_DIALOG_SVG_FONTS_H