#ifndef FORM_EDITOR_PROPERTIES__PROPERTY_H #define FORM_EDITOR_PROPERTIES__PROPERTY_H #include #include "PropertyEdits.h" class Property : public IObserver { public: Property() : _Edit(NULL), _Default(String()) {} virtual ~Property() { if (_Edit) _Edit->Release(); } virtual void OnUpdate(ISubject* s) { Set(Vector() << _Edit->GetData()); } Property& SetCalls(Callback1&> set, Callback2&> get); Property& AddMetaInfo(const String& s, const Value& v){ _Meta.Add(s, v); return *this; } Property& SetDefault(const Value& val) { _Default = val; return *this; } Property& SetEdit(IEditCtrl* edit, bool notify); Property& ToPane(Ctrl& c, int& cy, int space); void RestoreDefault() { Set(Vector() << _Default); } void Restore() { Set(Vector() << _Last); } void Apply() { Set(Vector() << _Edit->GetData()); } bool IsDefault() const; bool IsChanged() const; void Serialize(Stream& s) { s % _Last; } Value GetLast() const { return _Last; } Value GetDefault() const { return _Default; } Value GetMetaInfo(const char* s) const { return _Meta.Get(String(s), Value()); } String MetaString(const char* s) const { return _Meta.Get(String(s), Value()).ToString(); } Callback1&> Set; Callback2&> Get; private: Value _Last; Value _Default; IEditCtrl* _Edit; VectorMap _Meta; }; #endif