SoundAttribute.h

Go to the documentation of this file.
00001 #ifndef SOUNDATTRIBUTE_H_
00002 #define SOUNDATTRIBUTE_H_
00003 
00004 class SoundAttribute: public EntityAttribute
00005 {
00006         std::string m_classname;
00007         std::string m_key;
00008         BrowsedPathEntry m_entry;
00009         NonModalEntry m_nonModal;
00010     public:
00011         SoundAttribute (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<SoundAttribute, &SoundAttribute::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<SoundAttribute, &SoundAttribute::update> UpdateCaller;
00035         void browse (const BrowsedPathEntry::SetPathCallback& setPath)
00036         {
00037             // Display the Sound Chooser to get a sound from the user
00038             ui::SoundChooser sChooser;
00039             std::string sound = sChooser.chooseSound();
00040             if (sound.length() > 0) {
00041                 setPath(sound);
00042                 apply();
00043             }
00044         }
00045         typedef MemberCaller1<SoundAttribute, const BrowsedPathEntry::SetPathCallback&, &SoundAttribute::browse>
00046                 BrowseCaller;
00047 };
00048 
00049 #endif /* SOUNDATTRIBUTE_H_ */

Generated by  doxygen 1.6.2