-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathDataObject.cpp
60 lines (44 loc) · 1.33 KB
/
DataObject.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
#ifdef __GNUG__
// #pragma interface
#endif
#include <wx/mstream.h>
#include <wx/txtstrm.h>
#include "DataObject.h"
#include "enumers.h"
TimingEditorSignaDataObject::TimingEditorSignaDataObject(Signal *sig):
wxDataObjectSimple(wxDataFormat(TimingEditorSignalFormatId)),
m_sig(sig)
{}
TimingEditorSignaDataObject::~TimingEditorSignaDataObject()
{
delete m_sig;
}
//wxDataObjectSimple::GetDataSize
size_t TimingEditorSignaDataObject::GetDataSize() const
{
wxMemoryOutputStream memstream;
m_sig->serialize( memstream );
if ( memstream.GetLength() != wxInvalidOffset )
return( memstream.GetLength() );
return( 0 );
}
//wxDataObjectSimple::GetDataHere
bool TimingEditorSignaDataObject::GetDataHere(void *buf) const
{
wxMemoryOutputStream memstream;
m_sig->serialize(memstream);
///copy the data
wxInt32 len = memstream.CopyTo((char *)buf, memstream.GetLength() );
///check that copied data has the same length as the data in the memorystream
if ( len == memstream.GetLength() )
return true;
else
return false;
}
//wxDataObjectSimple::SetData
bool TimingEditorSignaDataObject::SetData(size_t len, const void *buf)
{
wxMemoryInputStream memstream((char *)buf, len);
m_sig->deserialize(memstream);
return true;
}