#ifndef FORM_EDITOR_PROPERTIES__PROPERTIES_H #define FORM_EDITOR_PROPERTIES__PROPERTIES_H #include "PropertiesEditor.h" template class PropertiesBase : public IPartBase { public: PropertiesBase(T* c) : _This(c) {} virtual ~PropertiesBase() {} virtual void InitProperties() {} virtual int OpenProperties(); virtual void ClearProperties() { GetProperties().Clear(); } virtual int ExecuteProperties(const Size& wndSize = Null); Array& GetProperties() { return _Properties; } const Array& GetProperties() const { return _Properties; } int GetPropertyGroupCount() const { return GetPropertiesGroups().GetCount(); } Vector GetPropertiesGroups() const; Array GetPropertiesByGroup(const String& group); T* GetObject() { return _This; } private: T* _This; Array _Properties; }; template Vector PropertiesBase::GetPropertiesGroups() const { const Array& props = GetProperties(); Vector result; for (int i = 0; i < props.GetCount(); ++i) { bool found = false; for (int j = 0; j < result.GetCount(); ++j) if (props[i].MetaString("Group") == result[j]) { found = true; break; } if (!found) result << props[i].MetaString("Group"); } return result; } template Array PropertiesBase::GetPropertiesByGroup(const String& group) { Array& props = GetProperties(); Array result; for (int i = 0; i < props.GetCount(); ++i) { if (props[i].MetaString("Group") == group) result.Add(&props[i]); } return result; } template int PropertiesBase::OpenProperties() { return PropertiesWindow >(this).Execute(); } template int PropertiesBase::ExecuteProperties(const Size& wndSize) { PropertiesWindow > wnd(this); if (!IsNull(wndSize)) wnd.GetWorkArea().CenterRect(wndSize); int r = wnd.Execute(); return r; } #endif