SVGFileProperty.h

00001 #ifndef _SVGFILEPROPERTY_H
00002 #define _SVGFILEPROPERTY_H
00003 // -------------------------------------------------------------------------
00004 #include <gtkmm.h>
00005 #include <SVGLoader.h>
00006 #include <iostream>
00007 #include <cassert>
00008 // -------------------------------------------------------------------------
00009 typedef Glib::Property<Glib::ustring> PType;
00010 // -------------------------------------------------------------------------
00019 class SVGFileProperty
00020 {
00021 protected:
00022 
00023     Glib::Property<Glib::ustring> m_property;   
00024     Gtk::Widget* m_owner;               
00025     Glib::ustring m_name;               
00026     SVGLoader loader;               
00028     sigc::connection err_idle_connection;       
00029     Glib::ustring err_msg;              
00032     void on_filename_changed()
00033     {
00034         assert( m_owner!=NULL );
00035 //      err_idle_connection.disconnect();
00036         try
00037         {
00038             loader.loadRsvgFile ( m_property.get_value() );
00039         }
00040         catch (std::string& err)
00041         {
00042             err_msg = err;
00043             std::cerr << m_owner->get_name() << ":"<< err_msg << std::endl;
00044 //          err_msg = err;
00045 //          err_idle_connection = Glib::signal_timeout().connect( sigc::mem_fun(*this, &SVGFileProperty::print_error_message), 1000 );
00046         }
00047     }
00049     bool print_error_message()
00050     {
00051         std::cerr << m_owner->get_name() << ":"<< err_msg << std::endl;
00052         return false;
00053     }
00054 
00055 public:
00056     SVGFileProperty(Gtk::Widget& owner, Glib::ustring name, Glib::ustring default_filename) :
00057         m_property( owner, name+"-svg-file", default_filename)
00058         ,m_owner(&owner)
00059         ,m_name(name)
00060     {
00061     }
00063     void connect_processing()
00064     {
00065         on_filename_changed();
00066         m_owner->connect_property_changed_with_return( m_name+"-svg-file", sigc::mem_fun(*this, &SVGFileProperty::on_filename_changed));
00067     }
00068 
00070     SVGLoader* get_loader() {return &loader;}
00072     SVGFileProperty& operator=( Glib::ustring new_value ) { m_property.set_value(new_value); return *this; }
00073 
00074     operator Glib::Property<Glib::ustring>&() { return m_property; }
00075     virtual ~SVGFileProperty() { err_idle_connection.disconnect(); }
00076 private:
00077     SVGFileProperty();
00078 };
00079 #endif

Документация по UniWidgets. Последние изменения: Fri Oct 10 09:57:49 2014. Создано системой  doxygen 1.5.9