Added properties
This commit is contained in:
29
src/include/PropertiesV2/BaseProperty.h
Normal file
29
src/include/PropertiesV2/BaseProperty.h
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
#pragma once
|
||||||
|
#include <string>
|
||||||
|
#include <G3DAll.h>
|
||||||
|
#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;
|
||||||
|
};
|
||||||
23
src/include/PropertiesV2/BoolProperty.h
Normal file
23
src/include/PropertiesV2/BoolProperty.h
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Property.h"
|
||||||
|
|
||||||
|
class BoolProperty : public Property<bool>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
21
src/include/PropertiesV2/Property.h
Normal file
21
src/include/PropertiesV2/Property.h
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "PropertiesV2/BaseProperty.h"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
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;
|
||||||
|
};
|
||||||
22
src/include/PropertiesV2/StringProperty.h
Normal file
22
src/include/PropertiesV2/StringProperty.h
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
#pragma once
|
||||||
|
#include "Property.h"
|
||||||
|
|
||||||
|
class StringProperty : public Property<std::string>
|
||||||
|
{
|
||||||
|
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;
|
||||||
|
};
|
||||||
14
src/source/PropertiesV2/BaseProperty.cpp
Normal file
14
src/source/PropertiesV2/BaseProperty.cpp
Normal file
@@ -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){
|
||||||
|
}
|
||||||
16
src/source/PropertiesV2/BoolProperty.cpp
Normal file
16
src/source/PropertiesV2/BoolProperty.cpp
Normal file
@@ -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);
|
||||||
|
}
|
||||||
17
src/source/PropertiesV2/Property.cpp
Normal file
17
src/source/PropertiesV2/Property.cpp
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
#include "PropertiesV2/Property.h"
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
PROPGRIDITEM Property<T>::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 <typename T>
|
||||||
|
void Property<T>::setProperty(LPPROPGRIDITEM &pItem){
|
||||||
|
}
|
||||||
16
src/source/PropertiesV2/StringProperty.cpp
Normal file
16
src/source/PropertiesV2/StringProperty.cpp
Normal file
@@ -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);
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user