index ac9556e1433a953a402cf55c6b0b4de7d694c403..fa81e84ca7e754aa68028be49c0efc037229ae61 100644 (file)
#include "svg-fonts-dialog.h"
#include <glibmm/i18n.h>
#include <string.h>
+#include "xml/node.h"
SvgFontDrawingArea::SvgFontDrawingArea(){
this->text = "";
namespace UI {
namespace Dialog {
+/*
+Gtk::HBox* SvgFontsDialog::AttrEntry(gchar* lbl, const SPAttributeEnum attr){
+ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
+ hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
+ Gtk::Entry* entry = Gtk::manage(new Gtk::Entry());
+ hbox->add(* entry );
+ hbox->show_all();
+
+ entry->signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_attr_changed));
+ return hbox;
+}
+*/
+
+SvgFontsDialog::AttrEntry::AttrEntry(SvgFontsDialog* d, gchar* lbl, const SPAttributeEnum attr){
+ this->dialog = d;
+ this->attr = attr;
+ this->add(* Gtk::manage(new Gtk::Label(lbl)) );
+ this->add(entry);
+ this->show_all();
+
+ entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::AttrEntry::on_attr_changed));
+}
+
+void SvgFontsDialog::AttrEntry::on_attr_changed(){
+ g_warning("attr entry changed: %s", this->entry.get_text().c_str());
+
+ SPObject* o = NULL;
+ for(SPObject* node = this->dialog->get_selected_spfont()->children; node; node=node->next){
+ switch(this->attr){
+ case SP_PROP_FONT_FAMILY:
+ if (SP_IS_FONTFACE(node)){
+ o = node;
+ continue;
+ }
+ break;
+ default:
+ o = NULL;
+ }
+ }
+
+ const gchar* name = (const gchar*)sp_attribute_name(this->attr);
+ if(name && o) {
+ SP_OBJECT_REPR(o)->setAttribute((const gchar*) name, this->entry.get_text().c_str());
+ o->parent->requestModified(SP_OBJECT_MODIFIED_FLAG);
+
+ Glib::ustring undokey = "svgfonts:";
+ undokey += name;
+ sp_document_maybe_done(o->document, undokey.c_str(), SP_VERB_DIALOG_SVG_FONTS,
+ _("Set SVG Font attribute"));
+ }
+
+}
+
+Gtk::HBox* SvgFontsDialog::AttrCombo(gchar* lbl, const SPAttributeEnum attr){
+ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
+ hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
+ hbox->add(* Gtk::manage(new Gtk::ComboBox()) );
+ hbox->show_all();
+ return hbox;
+}
+
+/*
+Gtk::HBox* SvgFontsDialog::AttrSpin(gchar* lbl){
+ Gtk::HBox* hbox = Gtk::manage(new Gtk::HBox());
+ hbox->add(* Gtk::manage(new Gtk::Label(lbl)) );
+ hbox->add(* Gtk::manage(new Gtk::SpinBox()) );
+ hbox->show_all();
+ return hbox;
+}*/
+
/*** SvgFontsDialog ***/
GlyphComboBox::GlyphComboBox(){
Gtk::VBox* SvgFontsDialog::global_settings_tab(){
Gtk::VBox* global_vbox = Gtk::manage(new Gtk::VBox());
+ AttrEntry* familyname;
+ familyname = new AttrEntry(this, (gchar*) "Family Name", SP_PROP_FONT_FAMILY);
+
+ global_vbox->add(*familyname);
+ global_vbox->add(*AttrCombo((gchar*) "Style", SP_PROP_FONT_STYLE));
+ global_vbox->add(*AttrCombo((gchar*) "Variant", SP_PROP_FONT_VARIANT));
+ global_vbox->add(*AttrCombo((gchar*) "Weight", SP_PROP_FONT_WEIGHT));
+
//Set Width (horiz_adv_x):
Gtk::HBox* setwidth_hbox = Gtk::manage(new Gtk::HBox());
setwidth_hbox->add(*Gtk::manage(new Gtk::Label(_("Set width:"))));
Gtk::VBox* SvgFontsDialog::glyphs_tab(){
Gtk::VBox* glyphs_vbox = Gtk::manage(new Gtk::VBox());
+ glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) "Glyph Name", SP_ATTR_GLYPH_NAME));
+ glyphs_vbox->add(*new SvgFontsDialog::AttrEntry(this, (gchar*) "Unicode", SP_ATTR_UNICODE));
+ //glyphs_vbox->add(*AttrSpin((gchar*) "Horizontal Advance"), SP_ATTR_HORIZ_ADV_X);
+ //glyphs_vbox->add(*AttrCombo((gchar*) "Missing Glyph"), SP_ATTR_); ?
return glyphs_vbox;
}