]> git.saurik.com Git - wxWidgets.git/blame - include/wx/motif/dataobj.h
fixed #if !NOPCH to be #if !defined(NOPCH)
[wxWidgets.git] / include / wx / motif / dataobj.h
CommitLineData
dc63c944
JS
1///////////////////////////////////////////////////////////////////////////////
2// Name: dataobj.h
3// Purpose: declaration of the wxDataObject class
4// Author: Julian Smart
5// RCS-ID: $Id$
6// Copyright: (c) 1998 Julian Smart
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_DATAOBJ_H_
11#define _WX_DATAOBJ_H_
12
13#ifdef __GNUG__
aed0ed3c 14#pragma interface "dataobj.h"
dc63c944
JS
15#endif
16
17#include "wx/defs.h"
18#include "wx/object.h"
19#include "wx/string.h"
20#include "wx/bitmap.h"
21
22//-------------------------------------------------------------------------
23// classes
24//-------------------------------------------------------------------------
25
26class WXDLLEXPORT wxDataObject;
27class WXDLLEXPORT wxTextDataObject;
28class WXDLLEXPORT wxBitmapDataObject;
29class WXDLLEXPORT wxPrivateDataObject;
30class WXDLLEXPORT wxFileDataObject;
31
32//-------------------------------------------------------------------------
33// wxDataObject
34//-------------------------------------------------------------------------
35
36class WXDLLEXPORT wxDataObject: public wxObject
37{
38 DECLARE_ABSTRACT_CLASS( wxDataObject )
39
40public:
41
42 wxDataObject() {}
43 ~wxDataObject() {}
44
45 virtual wxDataFormat GetFormat() const = 0;
46
47 // implementation
48};
49
50// ----------------------------------------------------------------------------
51// wxTextDataObject is a specialization of wxDataObject for text data
52// ----------------------------------------------------------------------------
53
54class WXDLLEXPORT wxTextDataObject : public wxDataObject
55{
56 DECLARE_DYNAMIC_CLASS( wxTextDataObject )
57
58public:
59
60 wxTextDataObject() {}
61 wxTextDataObject( const wxString& strText )
62 : m_strText(strText) { }
63
64 virtual wxDataFormat GetFormat() const
65 { return wxDF_TEXT; }
66
67 void SetText( const wxString& strText)
68 { m_strText = strText; }
69
70 wxString GetText() const
71 { return m_strText; }
72
73private:
74 wxString m_strText;
75
76};
77
78// ----------------------------------------------------------------------------
79// wxFileDataObject is a specialization of wxDataObject for file names
80// ----------------------------------------------------------------------------
81
82class WXDLLEXPORT wxFileDataObject : public wxDataObject
83{
84 DECLARE_DYNAMIC_CLASS( wxFileDataObject )
85
86public:
87
88 wxFileDataObject(void) {}
89
90 virtual wxDataFormat GetFormat() const
91 { return wxDF_FILENAME; }
92
93 void AddFile( const wxString &file )
94 { m_files += file; m_files += (char)0; }
95
96 wxString GetFiles() const
97 { return m_files; }
98
99private:
100 wxString m_files;
101
102};
103
104// ----------------------------------------------------------------------------
105// wxBitmapDataObject is a specialization of wxDataObject for bitmaps
106// ----------------------------------------------------------------------------
107
108class WXDLLEXPORT wxBitmapDataObject : public wxDataObject
109{
110 DECLARE_DYNAMIC_CLASS( wxBitmapDataObject )
111
112public:
113
114 wxBitmapDataObject(void) {}
115
116 virtual wxDataFormat GetFormat() const
117 { return wxDF_BITMAP; }
118
119 void SetBitmap( const wxBitmap &bitmap )
120 { m_bitmap = bitmap; }
121
122 wxBitmap GetBitmap() const
123 { return m_bitmap; }
124
125private:
126 wxBitmap m_bitmap;
127};
128
129// ----------------------------------------------------------------------------
130// wxPrivateDataObject is a specialization of wxDataObject for app specific data
131// ----------------------------------------------------------------------------
132
133class WXDLLEXPORT wxPrivateDataObject : public wxDataObject
134{
135 DECLARE_DYNAMIC_CLASS( wxPrivateDataObject )
136
137public:
138
139 wxPrivateDataObject();
140
141 ~wxPrivateDataObject();
142
143 virtual wxDataFormat GetFormat() const
144 { return wxDF_PRIVATE; }
145
146 // the string ID identifies the format of clipboard or DnD data. a word
147 // processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
148 // to the clipboard - the latter with the Id "WXWORD_FORMAT".
149
150 void SetId( const wxString& id )
151 { m_id = id; }
152
153 wxString GetId() const
154 { return m_id; }
155
156 // will make internal copy
157 void SetData( const char *data, size_t size );
158
159 size_t GetDataSize() const
160 { return m_size; }
161
162 char* GetData() const
163 { return m_data; }
164
165private:
166 size_t m_size;
167 char* m_data;
168 wxString m_id;
169};
170
171
172#endif
173 //_WX_DATAOBJ_H_
174