summaryrefslogtreecommitdiffstats
path: root/Project/ElementDataObject.cpp
diff options
context:
space:
mode:
authorThales1330 <thaleslima.ufu@gmail.com>2016-12-29 14:14:21 -0200
committerGitHub <noreply@github.com>2016-12-29 14:14:21 -0200
commitc5343c718cf80620c2fc7452a4315f7ddb9e5826 (patch)
tree3d5dbd283f31004cc6ef826c2b75d5e5ed9d9f27 /Project/ElementDataObject.cpp
parent28e9cc4d9df63cb12c01d49017172c5f39ca9c22 (diff)
parent3750a0691f4975045647f3f70d8215fb1884e6fb (diff)
downloadPSP.git-c5343c718cf80620c2fc7452a4315f7ddb9e5826.tar.gz
PSP.git-c5343c718cf80620c2fc7452a4315f7ddb9e5826.tar.xz
PSP.git-c5343c718cf80620c2fc7452a4315f7ddb9e5826.zip
Merge pull request #4 from Thales1330/wip/copy-paste
Wip copy paste
Diffstat (limited to 'Project/ElementDataObject.cpp')
-rw-r--r--Project/ElementDataObject.cpp39
1 files changed, 39 insertions, 0 deletions
diff --git a/Project/ElementDataObject.cpp b/Project/ElementDataObject.cpp
new file mode 100644
index 0000000..a5ac165
--- /dev/null
+++ b/Project/ElementDataObject.cpp
@@ -0,0 +1,39 @@
+#include "ElementDataObject.h"
+
+ElementDataObject::ElementDataObject()
+ : wxDataObjectSimple(wxDataFormat("PSPCopy"))
+{
+ m_elementsLists = new ElementsLists();
+}
+
+ElementDataObject::ElementDataObject(std::vector<Element*> elementList)
+ : wxDataObjectSimple(wxDataFormat("PSPCopy"))
+{
+ m_elementsLists = new ElementsLists();
+ if(elementList.size() > 0) {
+ // Separate buses (parents) from the rest of the elements (childs).
+ for(auto it = elementList.begin(), itEnd = elementList.end(); it != itEnd; ++it) {
+ Element* copy = (*it)->GetCopy();
+ if(copy) {
+ if(typeid(*copy) == typeid(Bus))
+ m_elementsLists->parentList.push_back((Bus*)copy);
+ else
+ m_elementsLists->elementList.push_back(copy);
+ }
+ }
+ }
+}
+
+ElementDataObject::~ElementDataObject() {}
+size_t ElementDataObject::GetDataSize() const { return sizeof(void*); }
+bool ElementDataObject::GetDataHere(void* buf) const
+{
+ *(ElementsLists**)buf = m_elementsLists;
+ return true;
+}
+
+bool ElementDataObject::SetData(size_t len, const void* buf)
+{
+ m_elementsLists = *(ElementsLists**)buf;
+ return true;
+}