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