From 52d2cbf5ddfabbda04c3207659e80ee4fce087e9 Mon Sep 17 00:00:00 2001 From: andreja6 Date: Tue, 23 Oct 2018 13:42:10 -0700 Subject: [PATCH] Removed useless class, properties work --- G3DTest.vcproj | 10 +--------- Instance.cpp | 14 +++++++------- Instance.h | 6 +++--- PhysicalInstance.cpp | 18 +++++++++--------- PhysicalInstance.h | 4 ++-- Property.cpp | 15 --------------- Property.h | 11 ----------- PropertyWindow.cpp | 19 ++++++++----------- 8 files changed, 30 insertions(+), 67 deletions(-) delete mode 100644 Property.cpp delete mode 100644 Property.h diff --git a/G3DTest.vcproj b/G3DTest.vcproj index 80a844a..a244185 100644 --- a/G3DTest.vcproj +++ b/G3DTest.vcproj @@ -176,7 +176,7 @@ SuppressStartupBanner="true" GenerateDebugInformation="true" ProgramDatabaseFile=".\Debug/G3DTest.pdb" - SubSystem="2" + SubSystem="1" TargetMachine="1" /> - - @@ -407,10 +403,6 @@ RelativePath=".\PartType.h" > - - diff --git a/Instance.cpp b/Instance.cpp index de3ac11..99e1f5f 100644 --- a/Instance.cpp +++ b/Instance.cpp @@ -41,26 +41,26 @@ PROPGRIDITEM Instance::createPGI(LPSTR catalog, LPSTR propName, LPSTR propDesc, return pItem; } -void Instance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem) +void Instance::PropUpdate(LPPROPGRIDITEM item) { - if((DWORD)&name == addr) + if(strcmp(item->lpszPropName, "Name") == 0) { - name = pItem.lpCurValue; + name = item->lpCurValue; } } -std::vector Instance::getProperties() +std::vector Instance::getProperties() { - std::vector properties; + std::vector properties; - properties.push_back(Property(createPGI( + properties.push_back(createPGI( "Properties", "Name", "The name of this instance", (LPARAM)name.c_str(), PIT_EDIT - ), (DWORD)&name)); + )); return properties; } diff --git a/Instance.h b/Instance.h index 65513f9..44eb41a 100644 --- a/Instance.h +++ b/Instance.h @@ -1,7 +1,7 @@ #pragma once #include -#include "Property.h" +#include "propertyGrid.h" class Instance { public: @@ -20,8 +20,8 @@ public: void removeChild(Instance*); Instance* getParent(); virtual Instance* clone() const { return new Instance(*this); } - virtual std::vector getProperties(); - virtual void PropUpdate(DWORD &addr, PROPGRIDITEM &pItem); + virtual std::vector getProperties(); + virtual void PropUpdate(LPPROPGRIDITEM pItem); protected: std::string className; Instance* parent; // Another pointer. diff --git a/PhysicalInstance.cpp b/PhysicalInstance.cpp index a6aabfb..5d98a63 100644 --- a/PhysicalInstance.cpp +++ b/PhysicalInstance.cpp @@ -214,35 +214,35 @@ PhysicalInstance::~PhysicalInstance(void) } -void PhysicalInstance::PropUpdate(DWORD &addr, PROPGRIDITEM &pItem) +void PhysicalInstance::PropUpdate(LPPROPGRIDITEM item) { - if((DWORD)&name == addr) + if(strcmp(item->lpszPropName, "Name") == 0) { - name = pItem.lpCurValue; + name = (LPTSTR)item->lpCurValue; } } -std::vector PhysicalInstance::getProperties() +std::vector PhysicalInstance::getProperties() { - std::vector properties; + std::vector properties; - properties.push_back(Property(createPGI( + properties.push_back(createPGI( "Properties", "Name", "The name of this instance", (LPARAM)name.c_str(), PIT_EDIT - ), (DWORD)&name)); + )); char pso[512]; - properties.push_back(Property(createPGI( + properties.push_back(createPGI( "Item", "Offset", "The position of the object in the workspace", (LPARAM)"Coming soon", PIT_EDIT - ), (DWORD)&position)); + )); return properties; } diff --git a/PhysicalInstance.h b/PhysicalInstance.h index f3fd26a..1e46b52 100644 --- a/PhysicalInstance.h +++ b/PhysicalInstance.h @@ -33,8 +33,8 @@ public: bool anchored; Vector3 rotVelocity; bool collides(Box); - virtual std::vector getProperties(); - virtual void PropUpdate(DWORD &addr, PROPGRIDITEM &pItem); + virtual std::vector getProperties(); + virtual void PropUpdate(LPPROPGRIDITEM pItem); private: Vector3 position; Vector3 size; diff --git a/Property.cpp b/Property.cpp deleted file mode 100644 index 4780735..0000000 --- a/Property.cpp +++ /dev/null @@ -1,15 +0,0 @@ -#include "Property.h" - -Property::Property(PROPGRIDITEM item, DWORD addr) -{ - this->addr = addr; - this->item = item; -} - -Property::~Property(void) -{ -} - - - - diff --git a/Property.h b/Property.h deleted file mode 100644 index 59536c6..0000000 --- a/Property.h +++ /dev/null @@ -1,11 +0,0 @@ -#pragma once -#include -#include "propertyGrid.h" -class Property -{ -public: - PROPGRIDITEM item; - DWORD addr; - Property(PROPGRIDITEM item, DWORD addr); - ~Property(void); -}; diff --git a/PropertyWindow.cpp b/PropertyWindow.cpp index 2a6dbdd..966f50b 100644 --- a/PropertyWindow.cpp +++ b/PropertyWindow.cpp @@ -1,7 +1,6 @@ #define _WINSOCKAPI_ #include #include "WindowFunctions.h" -#include "Property.h" #include "resource.h" #include "PropertyWindow.h" @@ -10,7 +9,7 @@ Property ∝ } PRGP;*/ -std::vector prop; +std::vector prop; Instance* selectedInstance; LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { @@ -32,14 +31,12 @@ LRESULT CALLBACK PropProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) { case PGN_PROPERTYCHANGE: { - if(selectedInstance != NULL) - { - for(size_t i = 0; i < prop.size(); i++) - { - MessageBox(NULL, (LPCSTR)prop.at(i).item.lpCurValue, "A", MB_OK); - selectedInstance->PropUpdate(prop.at(i).addr, prop.at(i).item); - } - } + if (IDC_PROPERTYGRID==wParam) { + LPNMHDR pnm = (LPNMHDR)lParam; + LPNMPROPGRID lpnmp = (LPNMPROPGRID)pnm; + LPPROPGRIDITEM item = PropGrid_GetItemData(pnm->hwndFrom,lpnmp->iIndex); + selectedInstance->PropUpdate(item); + } } break; } @@ -143,7 +140,7 @@ void PropertyWindow::SetProperties(Instance * instance) selectedInstance = instance; for(size_t i = 0; i < prop.size(); i++) { - ::PROPGRIDITEM item = prop.at(i).item; + ::PROPGRIDITEM item = prop.at(i); PropGrid_AddItem(_propGrid, &item); //PRGP propgp; //propgp.instance = instance;