AngleAttribute.h

Go to the documentation of this file.
00001 #ifndef ANGLEATTRIBUTE_H_
00002 #define ANGLEATTRIBUTE_H_
00003 
00004 class AngleAttribute: public EntityAttribute
00005 {
00006         std::string m_classname;
00007         std::string m_key;
00008         GtkEntry* m_entry;
00009         NonModalEntry m_nonModal;
00010     public:
00011         AngleAttribute (const std::string& classname, const std::string& key) :
00012             m_classname(classname), m_key(key), m_entry(0), m_nonModal(ApplyCaller(*this), UpdateCaller(*this))
00013         {
00014             GtkEntry* entry = numeric_entry_new();
00015             m_entry = entry;
00016             m_nonModal.connect(m_entry);
00017         }
00018 
00019         GtkWidget* getWidget () const
00020         {
00021             return GTK_WIDGET(m_entry);
00022         }
00023         void apply (void)
00024         {
00025             StringOutputStream angle(32);
00026             angle << angle_normalised(entry_get_float(m_entry));
00027             entitySetValue(m_classname, m_key, angle.c_str());
00028         }
00029         typedef MemberCaller<AngleAttribute, &AngleAttribute::apply> ApplyCaller;
00030 
00031         void update (void)
00032         {
00033             const std::string value = entityGetValueForKey(m_key);
00034             if (value.length() > 0) {
00035                 StringOutputStream angle(32);
00036                 angle << angle_normalised(string::toFloat(value));
00037                 gtk_entry_set_text(m_entry, angle.c_str());
00038             } else {
00039                 gtk_entry_set_text(m_entry, "0");
00040             }
00041         }
00042         typedef MemberCaller<AngleAttribute, &AngleAttribute::update> UpdateCaller;
00043 };
00044 
00045 #endif /* ANGLEATTRIBUTE_H_ */

Generated by  doxygen 1.6.2