File: datatransfer.h

package info (click to toggle)
wxpython4.0 4.2.3%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 221,752 kB
  • sloc: cpp: 962,555; python: 230,573; ansic: 170,731; makefile: 51,756; sh: 9,342; perl: 1,564; javascript: 584; php: 326; xml: 200
file content (113 lines) | stat: -rw-r--r-- 3,264 bytes parent folder | download | duplicates (4)
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
///////////////////////////////////////////////////////////////////////////////
// Name:        wx/osx/private/datatransfer.h
// Purpose:     OS X specific data transfer implementation
// Author:      Stefan Csomor
// Created:     2019-03-29
// Copyright:   (c) 2019 Stefan Csomor <vadim@wxwidgets.org>
// Licence:     wxWindows licence
///////////////////////////////////////////////////////////////////////////////

#ifndef _WX_OSX_PRIVATE_DATATRANSFER_H_
#define _WX_OSX_PRIVATE_DATATRANSFER_H_

#include "wx/osx/private.h"
#include "wx/osx/dataform.h"

class WXDLLIMPEXP_FWD_CORE wxDataObject;

class WXDLLIMPEXP_CORE wxOSXDataSourceItem
{
public:
    virtual ~wxOSXDataSourceItem();

    virtual wxDataFormat::NativeFormat AvailableType(CFArrayRef types) const = 0;

    virtual bool GetData( const wxDataFormat& dataFormat, wxMemoryBuffer& target) = 0;

    virtual bool GetData( wxDataFormat::NativeFormat type, wxMemoryBuffer& target) = 0;

    virtual CFDataRef DoGetData(wxDataFormat::NativeFormat type) const = 0;
};

class WXDLLIMPEXP_CORE wxOSXDataSource
{
public:
    // the number of source items
    virtual size_t GetItemCount() const = 0;

    // get source item by index, needs to be deleted after use
    virtual const wxOSXDataSourceItem* GetItem(size_t pos) const = 0;

    // returns true if there is any data in this source conforming to dataFormat
    virtual bool IsSupported(const wxDataFormat &dataFormat);

    // returns true if there is any data in this source supported by dataobj
    virtual bool IsSupported(const wxDataObject &dataobj);

    // returns true if there is any data in this source of types
    virtual bool HasData(CFArrayRef types) const = 0;

};

class WXDLLIMPEXP_CORE wxOSXDataSinkItem
{
public:
    virtual ~wxOSXDataSinkItem();

    virtual void SetFilename(const wxString& filename);

    // translating from wx into native representation
    virtual void SetData(const wxDataFormat& format, const void *buf, size_t size) = 0;

    // translating from wx into native representation
    virtual void SetData(wxDataFormat::NativeFormat format, const void *buf, size_t size) = 0;

   // native implementation for setting data
    virtual void DoSetData(wxDataFormat::NativeFormat format, CFDataRef data) = 0;
};


class WXDLLIMPEXP_CORE wxOSXDataSink
{
public:
    // delete all created sink items
    virtual void Clear() = 0;

    // create a new sink item
    virtual wxOSXDataSinkItem* CreateItem() = 0;

    // flush the created sink items into the system sink representation
    virtual void Flush() = 0 ;
};

class WXDLLIMPEXP_CORE wxOSXPasteboard : public wxOSXDataSink, public wxOSXDataSource
{
public:
    wxOSXPasteboard(OSXPasteboard native);
    ~wxOSXPasteboard();

    // sink methods

    virtual wxOSXDataSinkItem* CreateItem() wxOVERRIDE;

    void Clear() wxOVERRIDE;

    void Flush() wxOVERRIDE;

    // source methods

    virtual size_t GetItemCount() const wxOVERRIDE;

    virtual const wxOSXDataSourceItem* GetItem(size_t pos) const wxOVERRIDE;

    virtual bool HasData(CFArrayRef types) const wxOVERRIDE;

    static wxOSXPasteboard* GetGeneralClipboard();
private:
    void DeleteSinkItems();

    OSXPasteboard m_pasteboard;
    wxVector<wxOSXDataSinkItem*> m_sinkItems;
};

#endif