From a82a5be5088ca396af8816d7faf8515a35e4efc2 Mon Sep 17 00:00:00 2001 From: JucaBlues Date: Fri, 11 Jul 2008 07:28:13 +0000 Subject: [PATCH] Text Preview entry box on SVGFonts dialog (unfortunately crashing sometimes, dont know why) --- src/ui/dialog/svg-fonts-dialog.cpp | 22 +++++++++++++++++++--- src/ui/dialog/svg-fonts-dialog.h | 7 +++++-- 2 files changed, 24 insertions(+), 5 deletions(-) diff --git a/src/ui/dialog/svg-fonts-dialog.cpp b/src/ui/dialog/svg-fonts-dialog.cpp index 38639a20d..5fa90966c 100644 --- a/src/ui/dialog/svg-fonts-dialog.cpp +++ b/src/ui/dialog/svg-fonts-dialog.cpp @@ -18,7 +18,7 @@ #include "svg-fonts-dialog.h" SvgFontDrawingArea::SvgFontDrawingArea(){ - this->text = (gchar*) "A@!A!@A"; + this->text = "Sample Text"; this->svgfont = NULL; ((Gtk::Widget*) this)->set_size_request(150, 50); } @@ -27,7 +27,7 @@ void SvgFontDrawingArea::set_svgfont(SvgFont* svgfont){ this->svgfont = svgfont; } -void SvgFontDrawingArea::set_text(gchar* text){ +void SvgFontDrawingArea::set_text(Glib::ustring text){ this->text = text; } @@ -42,7 +42,7 @@ bool SvgFontDrawingArea::on_expose_event (GdkEventExpose *event){ cr->set_font_face( Cairo::RefPtr(new Cairo::FontFace(this->svgfont->get_font_face(), false /* does not have reference */)) ); cr->set_font_size (20); cr->move_to (20, 20); - cr->show_text (this->text); + cr->show_text (this->text.c_str()); } return TRUE; } @@ -72,6 +72,12 @@ void SvgFontsDialog::update_fonts() } } +void SvgFontsDialog::on_preview_text_changed(){ +// _font_da.set_text((gchar*) _preview_entry.get_text().c_str()); + _font_da.set_text(_preview_entry.get_text()); + _font_da.redraw(); +} + void SvgFontsDialog::on_font_selection_changed(){ _font_da.set_svgfont(this->get_selected_svgfont()); _font_da.redraw(); @@ -101,7 +107,17 @@ SvgFontsDialog::SvgFontsDialog() this->update_fonts(); + _preview_entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_preview_text_changed)); + _getContents()->add((Gtk::Widget&) _font_da); + _getContents()->add(_preview_entry); + +/* Gtk::HBox* preview_box = Gtk::manage(new Gtk::HBox()); + _preview_entry.signal_changed().connect(sigc::mem_fun(*this, &SvgFontsDialog::on_preview_text_changed)); + preview_box->add(_preview_entry); + preview_box->add((Gtk::Widget&) _font_da); + + _getContents()->add(*preview_box);*/ _getContents()->show_all(); //Settings for the selected SVGFont: diff --git a/src/ui/dialog/svg-fonts-dialog.h b/src/ui/dialog/svg-fonts-dialog.h index 044ce5d44..789ccafcf 100644 --- a/src/ui/dialog/svg-fonts-dialog.h +++ b/src/ui/dialog/svg-fonts-dialog.h @@ -30,12 +30,12 @@ class SvgFontDrawingArea : Gtk::DrawingArea{ public: SvgFontDrawingArea(); - void set_text(gchar*); + void set_text(Glib::ustring); void set_svgfont(SvgFont*); void redraw(); private: SvgFont* svgfont; - gchar* text; + Glib::ustring text; bool on_expose_event (GdkEventExpose *event); }; @@ -56,6 +56,7 @@ public: void update_fonts(); SvgFont* get_selected_svgfont(); void on_font_selection_changed(); + void on_preview_text_changed(); private: class Columns : public Gtk::TreeModel::ColumnRecord { @@ -75,7 +76,9 @@ private: Columns _columns; Gtk::TreeView _font_list; Gtk::VBox _font_settings; + Gtk::Entry _preview_entry; SvgFontDrawingArea _font_da; + class EntryWidget : public Gtk::HBox { public: -- 2.30.2