diff --git a/Blocks3D.vcproj b/Blocks3D.vcproj index 3e1c6cf..19cc2cb 100644 --- a/Blocks3D.vcproj +++ b/Blocks3D.vcproj @@ -677,10 +677,6 @@ - - @@ -970,10 +966,6 @@ - - diff --git a/src/include/DataModelV2/Instance.h b/src/include/DataModelV2/Instance.h index ee28095..fa75e7a 100644 --- a/src/include/DataModelV2/Instance.h +++ b/src/include/DataModelV2/Instance.h @@ -32,7 +32,7 @@ public: //Deprecated virtual void PropUpdate(LPPROPGRIDITEM &pItem); - virtual std::vector collectProperties(); + virtual std::vector collectProperties(); int listicon; protected: diff --git a/src/include/PropertiesV2/BaseProperty.h b/src/include/PropertiesV2/BaseProperty.h deleted file mode 100644 index e0dab49..0000000 --- a/src/include/PropertiesV2/BaseProperty.h +++ /dev/null @@ -1,29 +0,0 @@ -#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 index 5371be0..fa1222a 100644 --- a/src/include/PropertiesV2/BoolProperty.h +++ b/src/include/PropertiesV2/BoolProperty.h @@ -1,20 +1,20 @@ #pragma once #include "Property.h" -class BoolProperty : public Property +class BoolProperty : public Property { public: typedef void (Instance::*instanceSetter)(bool); //Win32 why - ~BoolProperty(void){}; + ~BoolProperty(void); BoolProperty(LPSTR name, LPSTR desc, LPSTR catalog, bool value, Instance * owner, instanceSetter setterFunc) - :Property(name, desc, catalog, value, owner) + :Property(name, desc, catalog, (void*)value, owner) { this->setterFunc = setterFunc; } const void setValue(bool val){ (_owner->*setterFunc)(val); - _value = val; + _value = (void *)val; } PROPGRIDITEM getPropGridItem(); void setProperty(LPPROPGRIDITEM &pItem); diff --git a/src/include/PropertiesV2/Property.h b/src/include/PropertiesV2/Property.h index 3dd896e..6d8c5de 100644 --- a/src/include/PropertiesV2/Property.h +++ b/src/include/PropertiesV2/Property.h @@ -1,21 +1,35 @@ #pragma once -#include "PropertiesV2/BaseProperty.h" +#include +#include "propertyGrid.h" -template -class Property : public BaseProperty +class Instance; + +class Property { public: - Property(LPSTR name, LPSTR desc, LPSTR catalog, T value, Instance * owner) - :BaseProperty(name, desc, catalog, owner) - { + Property(LPSTR name, LPSTR desc, LPSTR catalog, Instance * owner){ + _name = name; + _desc = desc; + _catalog = catalog; + _owner = owner; + } + Property(LPSTR name, LPSTR desc, LPSTR catalog, void* value, Instance * owner){ + _name = name; + _desc = desc; + _catalog = catalog; + _owner = owner; _value = value; } - ~Property(void){}; - const T getValue() { + ~Property(void){} + const void* getValue() { return _value; } virtual PROPGRIDITEM getPropGridItem(); virtual void setProperty(LPPROPGRIDITEM &pItem); protected: - T _value; + Instance* _owner; + LPSTR _name; + LPSTR _desc; + LPSTR _catalog; + void* _value; }; diff --git a/src/include/PropertiesV2/StringProperty.h b/src/include/PropertiesV2/StringProperty.h index ff7c79e..491a77d 100644 --- a/src/include/PropertiesV2/StringProperty.h +++ b/src/include/PropertiesV2/StringProperty.h @@ -1,14 +1,15 @@ #pragma once #include "Property.h" -class StringProperty : public Property +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) + :Property(name, desc, catalog, &_value, owner) { + this->_value = value; this->setterFunc = setterFunc; } const void setValue(std::string val){ @@ -18,5 +19,6 @@ public: PROPGRIDITEM getPropGridItem(); void setProperty(LPPROPGRIDITEM &pItem); private: + std::string _value; instanceSetter setterFunc; }; diff --git a/src/source/DataModelV2/Instance.cpp b/src/source/DataModelV2/Instance.cpp index b489ba2..751de2d 100644 --- a/src/source/DataModelV2/Instance.cpp +++ b/src/source/DataModelV2/Instance.cpp @@ -80,10 +80,10 @@ std::vector Instance::getProperties() } -std::vector Instance::collectProperties() +std::vector Instance::collectProperties() { - std::vector properties; - properties.push_back(StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName)); + std::vector properties; + properties.push_back(new StringProperty("Name", "The name of this instance", "Properties", name, this, &Instance::setName)); return properties; } diff --git a/src/source/PropertiesV2/BaseProperty.cpp b/src/source/PropertiesV2/BaseProperty.cpp deleted file mode 100644 index e88952e..0000000 --- a/src/source/PropertiesV2/BaseProperty.cpp +++ /dev/null @@ -1,14 +0,0 @@ -#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 index 89d5e90..9cc0b80 100644 --- a/src/source/PropertiesV2/BoolProperty.cpp +++ b/src/source/PropertiesV2/BoolProperty.cpp @@ -6,7 +6,7 @@ PROPGRIDITEM BoolProperty::getPropGridItem(){ pItem.lpszCatalog=_catalog; pItem.lpszPropName=_name; pItem.lpszPropDesc=_desc; - pItem.lpCurValue=_value; + pItem.lpCurValue=_value > 0; pItem.iItemType=PIT_CHECK; return pItem; } diff --git a/src/source/PropertiesV2/Property.cpp b/src/source/PropertiesV2/Property.cpp index ac154d4..ab70fd2 100644 --- a/src/source/PropertiesV2/Property.cpp +++ b/src/source/PropertiesV2/Property.cpp @@ -1,17 +1,14 @@ #include "PropertiesV2/Property.h" -template -PROPGRIDITEM Property::getPropGridItem(){ +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){ +void Property::setProperty(LPPROPGRIDITEM &pItem){ } \ No newline at end of file diff --git a/src/source/PropertyWindow.cpp b/src/source/PropertyWindow.cpp index 70890a2..243afd0 100644 --- a/src/source/PropertyWindow.cpp +++ b/src/source/PropertyWindow.cpp @@ -6,7 +6,7 @@ #include "strsafe.h" #include "Application.h" -std::vector prop; +std::vector prop; std::vector children; Instance * selectedInstance; Instance * parent = NULL; @@ -349,13 +349,13 @@ void PropertyWindow::UpdateSelected(std::vector instances) } Instance * instance = instances[0]; PropGrid_ResetContent(_propGrid); - prop = instance->getProperties(); + prop = instance->collectProperties(); //if (selectedInstance != instance) { selectedInstance = instance; for(size_t i = 0; i < prop.size(); i++) { - ::PROPGRIDITEM item = prop.at(i); + ::PROPGRIDITEM item = prop.at(i)->getPropGridItem(); PropGrid_AddItem(_propGrid, &item); //PRGP propgp; //propgp.instance = instance;