From 793e85a57f27906a05a8fbfb487cf0dca5304dbb Mon Sep 17 00:00:00 2001 From: Vulpovile Date: Sat, 22 Oct 2022 08:47:14 -0700 Subject: [PATCH] Added properties --- src/include/PropertiesV2/BaseProperty.h | 29 ++++++++++++++++++++++ src/include/PropertiesV2/BoolProperty.h | 23 +++++++++++++++++ src/include/PropertiesV2/Property.h | 21 ++++++++++++++++ src/include/PropertiesV2/StringProperty.h | 22 ++++++++++++++++ src/source/PropertiesV2/BaseProperty.cpp | 14 +++++++++++ src/source/PropertiesV2/BoolProperty.cpp | 16 ++++++++++++ src/source/PropertiesV2/Property.cpp | 17 +++++++++++++ src/source/PropertiesV2/StringProperty.cpp | 16 ++++++++++++ 8 files changed, 158 insertions(+) create mode 100644 src/include/PropertiesV2/BaseProperty.h create mode 100644 src/include/PropertiesV2/BoolProperty.h create mode 100644 src/include/PropertiesV2/Property.h create mode 100644 src/include/PropertiesV2/StringProperty.h create mode 100644 src/source/PropertiesV2/BaseProperty.cpp create mode 100644 src/source/PropertiesV2/BoolProperty.cpp create mode 100644 src/source/PropertiesV2/Property.cpp create mode 100644 src/source/PropertiesV2/StringProperty.cpp diff --git a/src/include/PropertiesV2/BaseProperty.h b/src/include/PropertiesV2/BaseProperty.h new file mode 100644 index 0000000..e0dab49 --- /dev/null +++ b/src/include/PropertiesV2/BaseProperty.h @@ -0,0 +1,29 @@ +#pragma once +#include +#include +#include "propertyGrid.h" +class Instance; + +/** + DO NOT INHERIT FROM THIS CLASS!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + INHERIT FROM PROPERTY INSTEAD +*/ +class BaseProperty +{ +public: + BaseProperty(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner) { + _name = name; + _desc = desc; + _owner = owner; + _catalog = catalog; + } + ~BaseProperty(void){}; + + virtual PROPGRIDITEM getPropGridItem(); + virtual void setProperty(LPPROPGRIDITEM &pItem); +protected: + Instance* _owner; + LPSTR _name; + LPSTR _desc; + LPSTR _catalog; +}; diff --git a/src/include/PropertiesV2/BoolProperty.h b/src/include/PropertiesV2/BoolProperty.h new file mode 100644 index 0000000..5371be0 --- /dev/null +++ b/src/include/PropertiesV2/BoolProperty.h @@ -0,0 +1,23 @@ +#pragma once +#include "Property.h" + +class BoolProperty : public Property +{ +public: + typedef void (Instance::*instanceSetter)(bool); + //Win32 why + ~BoolProperty(void){}; + BoolProperty(LPSTR name, LPSTR desc, LPSTR catalog, bool value, Instance * owner, instanceSetter setterFunc) + :Property(name, desc, catalog, value, owner) + { + this->setterFunc = setterFunc; + } + const void setValue(bool val){ + (_owner->*setterFunc)(val); + _value = val; + } + PROPGRIDITEM getPropGridItem(); + void setProperty(LPPROPGRIDITEM &pItem); +private: + instanceSetter setterFunc; +}; diff --git a/src/include/PropertiesV2/Property.h b/src/include/PropertiesV2/Property.h new file mode 100644 index 0000000..3dd896e --- /dev/null +++ b/src/include/PropertiesV2/Property.h @@ -0,0 +1,21 @@ +#pragma once +#include "PropertiesV2/BaseProperty.h" + +template +class Property : public BaseProperty +{ +public: + Property(LPSTR name, LPSTR desc, LPSTR catalog, T value, Instance * owner) + :BaseProperty(name, desc, catalog, owner) + { + _value = value; + } + ~Property(void){}; + const T getValue() { + return _value; + } + virtual PROPGRIDITEM getPropGridItem(); + virtual void setProperty(LPPROPGRIDITEM &pItem); +protected: + T _value; +}; diff --git a/src/include/PropertiesV2/StringProperty.h b/src/include/PropertiesV2/StringProperty.h new file mode 100644 index 0000000..ff7c79e --- /dev/null +++ b/src/include/PropertiesV2/StringProperty.h @@ -0,0 +1,22 @@ +#pragma once +#include "Property.h" + +class StringProperty : public Property +{ +public: + typedef void (Instance::*instanceSetter)(std::string); + ~StringProperty(void){}; + StringProperty(LPSTR name, LPSTR desc, LPSTR catalog, std::string value, Instance * owner, instanceSetter setterFunc) + :Property(name, desc, catalog, value, owner) + { + this->setterFunc = setterFunc; + } + const void setValue(std::string val){ + (_owner->*setterFunc)(val); + _value = val; + } + PROPGRIDITEM getPropGridItem(); + void setProperty(LPPROPGRIDITEM &pItem); +private: + instanceSetter setterFunc; +}; diff --git a/src/source/PropertiesV2/BaseProperty.cpp b/src/source/PropertiesV2/BaseProperty.cpp new file mode 100644 index 0000000..e88952e --- /dev/null +++ b/src/source/PropertiesV2/BaseProperty.cpp @@ -0,0 +1,14 @@ +#include "PropertiesV2/BaseProperty.h" + +PROPGRIDITEM BaseProperty::getPropGridItem(){ + PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + pItem.lpszCatalog=_catalog; + pItem.lpszPropName=_name; + pItem.lpszPropDesc=_desc; + pItem.iItemType=PIT_EDIT; + return pItem; +} + +void BaseProperty::setProperty(LPPROPGRIDITEM &pItem){ +} \ No newline at end of file diff --git a/src/source/PropertiesV2/BoolProperty.cpp b/src/source/PropertiesV2/BoolProperty.cpp new file mode 100644 index 0000000..89d5e90 --- /dev/null +++ b/src/source/PropertiesV2/BoolProperty.cpp @@ -0,0 +1,16 @@ +#include "PropertiesV2/BoolProperty.h" + +PROPGRIDITEM BoolProperty::getPropGridItem(){ + PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + pItem.lpszCatalog=_catalog; + pItem.lpszPropName=_name; + pItem.lpszPropDesc=_desc; + pItem.lpCurValue=_value; + pItem.iItemType=PIT_CHECK; + return pItem; +} + +void BoolProperty::setProperty(LPPROPGRIDITEM &pItem){ + setValue(pItem->lpCurValue == TRUE); +} \ No newline at end of file diff --git a/src/source/PropertiesV2/Property.cpp b/src/source/PropertiesV2/Property.cpp new file mode 100644 index 0000000..ac154d4 --- /dev/null +++ b/src/source/PropertiesV2/Property.cpp @@ -0,0 +1,17 @@ +#include "PropertiesV2/Property.h" + +template +PROPGRIDITEM Property::getPropGridItem(){ + PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + pItem.lpszCatalog=_catalog; + pItem.lpszPropName=_name; + pItem.lpszPropDesc=_desc; + pItem.lpCurValue="invalid"; + pItem.iItemType=PIT_EDIT; + return pItem; +} + +template +void Property::setProperty(LPPROPGRIDITEM &pItem){ +} \ No newline at end of file diff --git a/src/source/PropertiesV2/StringProperty.cpp b/src/source/PropertiesV2/StringProperty.cpp new file mode 100644 index 0000000..d7df2ac --- /dev/null +++ b/src/source/PropertiesV2/StringProperty.cpp @@ -0,0 +1,16 @@ +#include "PropertiesV2/StringProperty.h" + +PROPGRIDITEM StringProperty::getPropGridItem(){ + PROPGRIDITEM pItem; + PropGrid_ItemInit(pItem); + pItem.lpszCatalog=_catalog; + pItem.lpszPropName=_name; + pItem.lpszPropDesc=_desc; + pItem.lpCurValue=(LPARAM)_value.c_str(); + pItem.iItemType=PIT_EDIT; + return pItem; +} + +void StringProperty::setProperty(LPPROPGRIDITEM &pItem){ + setValue((LPSTR)pItem->lpCurValue); +} \ No newline at end of file