ParticleAttribute.h
Go to the documentation of this file.00001 #ifndef PARTICLEATTRIBUTE_H_
00002 #define PARTICLEATTRIBUTE_H_
00003
00004 class ParticleAttribute: public EntityAttribute
00005 {
00006 std::string m_classname;
00007 std::string m_key;
00008 BrowsedPathEntry m_entry;
00009 NonModalEntry m_nonModal;
00010 public:
00011 ParticleAttribute (const std::string& classname, const std::string& key) :
00012 m_classname(classname), m_key(key), m_entry(BrowseCaller(*this)), m_nonModal(ApplyCaller(*this),
00013 UpdateCaller(*this))
00014 {
00015 m_nonModal.connect(m_entry.m_entry.m_entry);
00016 }
00017
00018 GtkWidget* getWidget () const
00019 {
00020 return GTK_WIDGET(m_entry.m_entry.m_frame);
00021 }
00022 void apply (void)
00023 {
00024 StringOutputStream value(64);
00025 value << ConvertUTF8ToLocale(gtk_entry_get_text(GTK_ENTRY(m_entry.m_entry.m_entry)));
00026 entitySetValue(m_classname, m_key, value.c_str());
00027 }
00028 typedef MemberCaller<ParticleAttribute, &ParticleAttribute::apply> ApplyCaller;
00029 void update (void)
00030 {
00031 const std::string value = entityGetValueForKey(m_key);
00032 gtk_entry_set_text(GTK_ENTRY(m_entry.m_entry.m_entry), value.c_str());
00033 }
00034 typedef MemberCaller<ParticleAttribute, &ParticleAttribute::update> UpdateCaller;
00035 void browse (const BrowsedPathEntry::SetPathCallback& setPath)
00036 {
00037 const char *filename = misc_particle_dialog(gtk_widget_get_toplevel(GTK_WIDGET(m_entry.m_entry.m_frame)));
00038 if (filename != 0) {
00039 setPath(filename);
00040 apply();
00041 }
00042 }
00043 typedef MemberCaller1<ParticleAttribute, const BrowsedPathEntry::SetPathCallback&, &ParticleAttribute::browse>
00044 BrowseCaller;
00045 };
00046
00047 #endif