wxMaxima
Loading...
Searching...
No Matches
CompositeDataObject.h
Go to the documentation of this file.
1// -*- mode: c++; c-file-style: "linux"; c-basic-offset: 2; indent-tabs-mode: nil -*-
2//
3// Copyright (C) 2020 Kuba Ober <kuba@bertec.com>
4//
5// This program is free software; you can redistribute it and/or modify
6// it under the terms of the GNU General Public License as published by
7// the Free Software Foundation; either version 2 of the License, or
8// (at your option) any later version.
9//
10// This program is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU General Public License for more details.
14//
15//
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19//
20// SPDX-License-Identifier: GPL-2.0+
21
22#ifndef COMPOSITEDATAOBJECT_H
23#define COMPOSITEDATAOBJECT_H
24
25#include <wx/clipbrd.h>
26#include <memory>
27#include <vector>
28
37class CompositeDataObject final : public wxDataObject
38{
39public:
41 virtual ~CompositeDataObject() override;
42
43 void Add(wxDataObject *object, bool preferred = false);
44 wxDataObject *GetObject(const wxDataFormat& format,
45 wxDataObjectBase::Direction dir = Get) const;
46 wxDataFormat GetPreferredFormat(Direction dir = Get) const override;
47 void SetPreferredFormat(const wxDataFormat &format);
48
49 size_t GetFormatCount(Direction dir = Get) const override;
50 void GetAllFormats(wxDataFormat *formats, Direction dir = Get) const override;
51 size_t GetDataSize(const wxDataFormat &format) const override;
52 bool GetDataHere(const wxDataFormat &format, void *buf) const override;
53
54#ifdef __WXMSW__
55 const void* GetSizeFromBuffer(const void* buffer, size_t* size,
56 const wxDataFormat& format) override;
57 void* SetSizeInBuffer(void* buffer, size_t size, const wxDataFormat& format) override;
58 size_t GetBufferOffset(const wxDataFormat& format) override;
59#endif
60
61private:
62 struct Entry
63 {
64 wxDataFormat format;
65 std::shared_ptr<wxDataObject> object;
66 Entry(const wxDataFormat &format, std::shared_ptr<wxDataObject> object) :
67 format(format), object(std::move(object)) {}
68 };
69 std::vector<Entry> m_entries;
70 wxDataFormat m_preferredFormat;
71};
72
73#endif // COMPOSITEDATAOBJECT_H
A composite data object like wxDataObjectComposite, but accepts also non-simple data objects....
Definition: CompositeDataObject.h:38