]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk1/dataobj.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDataObject class
4 // Author: Robert Roebling
6 // Copyright: (c) 1998 Vadim Zeitlin, Robert Roebling
7 // Licence: wxWindows license
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef __GTKDATAOBJECTH__
11 #define __GTKDATAOBJECTH__
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/bitmap.h"
22 //-------------------------------------------------------------------------
24 //-------------------------------------------------------------------------
29 class wxTextDataObject
;
30 class wxBitmapDataObject
;
31 class wxPrivateDataObject
;
32 class wxFileDataObject
;
34 //-------------------------------------------------------------------------
35 // wxDataType (internal)
36 //-------------------------------------------------------------------------
41 wxDF_TEXT
= 1, /* CF_TEXT */
42 wxDF_BITMAP
= 2, /* CF_BITMAP */
43 wxDF_METAFILE
= 3, /* CF_METAFILEPICT */
47 wxDF_OEMTEXT
= 7, /* CF_OEMTEXT */
48 wxDF_DIB
= 8, /* CF_DIB */
53 wxDF_UNICODETEXT
= 13,
54 wxDF_ENHMETAFILE
= 14,
55 wxDF_FILENAME
= 15, /* CF_HDROP */
60 //-------------------------------------------------------------------------
61 // wxDataFormat (internal)
62 //-------------------------------------------------------------------------
64 class wxDataFormat
: public wxObject
66 DECLARE_CLASS( wxDataFormat
)
71 wxDataFormat( wxDataType type
);
72 wxDataFormat( const wxString
&id
);
73 wxDataFormat( const wxChar
*id
);
74 wxDataFormat( wxDataFormat
&format
);
75 wxDataFormat( const GdkAtom atom
);
77 void SetType( wxDataType type
);
78 wxDataType
GetType() const;
80 wxString
GetId() const;
81 void SetId( const wxChar
*id
);
93 //-------------------------------------------------------------------------
94 // wxDataBroker (internal)
95 //-------------------------------------------------------------------------
97 class wxDataBroker
: public wxObject
99 DECLARE_CLASS( wxDataBroker
)
106 /* add data object */
107 void Add( wxDataObject
*dataObject
, bool preferred
= FALSE
);
111 /* OLE implementation, the methods don't need to be overridden */
113 /* get number of supported formats */
114 virtual size_t GetFormatCount() const;
116 /* return nth supported format */
117 virtual wxDataFormat
&GetNthFormat( size_t nth
) const;
119 /* return preferrd/best supported format */
120 virtual wxDataFormat
&GetPreferredFormat() const;
122 /* search through m_dataObjects, return TRUE if found */
123 virtual bool IsSupportedFormat( wxDataFormat
&format
) const;
125 /* search through m_dataObjects and call child's GetSize() */
126 virtual size_t GetSize( wxDataFormat
& format
) const;
128 /* search through m_dataObjects and call child's WriteData(dest) */
129 virtual void WriteData( wxDataFormat
& format
, void *dest
) const;
135 wxList m_dataObjects
;
139 //----------------------------------------------------------------------------
140 // wxDataObject to be placed in wxDataBroker
141 //----------------------------------------------------------------------------
143 class wxDataObject
: public wxObject
145 DECLARE_DYNAMIC_CLASS( wxDataObject
)
155 /* write data to dest */
156 virtual void WriteData( void *dest
) const = 0;
158 /* get size of data */
159 virtual size_t GetSize() const = 0;
163 wxDataFormat
&GetFormat();
165 wxDataType
GetFormatType() const;
166 wxString
GetFormatId() const;
167 GdkAtom
GetFormatAtom() const;
169 wxDataFormat m_format
;
172 //----------------------------------------------------------------------------
173 // wxTextDataObject is a specialization of wxDataObject for text data
174 //----------------------------------------------------------------------------
176 class wxTextDataObject
: public wxDataObject
178 DECLARE_DYNAMIC_CLASS( wxTextDataObject
)
182 /* default constructor. call SetText() later or override
183 WriteData() and GetSize() for working on-demand */
187 wxTextDataObject( const wxString
& data
);
189 /* set current text data */
190 void SetText( const wxString
& data
);
192 /* get current text data */
193 wxString
GetText() const;
195 /* by default calls WriteString() with string set by constructor or
196 by SetText(). can be overridden for working on-demand */
197 virtual void WriteData( void *dest
) const;
199 /* by default, returns length of string as set by constructor or
200 by SetText(). can be overridden for working on-demand */
201 virtual size_t GetSize() const;
203 /* write string to dest */
204 void WriteString( const wxString
&str
, void *dest
) const;
211 //----------------------------------------------------------------------------
212 // wxFileDataObject is a specialization of wxDataObject for file names
213 //----------------------------------------------------------------------------
215 class wxFileDataObject
: public wxDataObject
217 DECLARE_DYNAMIC_CLASS( wxFileDataObject
)
221 /* default constructor */
224 /* add file name to list */
225 void AddFile( const wxString
&file
);
227 /* get all filename as one string. each file name is 0 terminated,
228 the list is double zero terminated */
229 wxString
GetFiles() const;
231 /* write list of filenames */
232 virtual void WriteData( void *dest
) const;
234 /* return length of list of filenames */
235 virtual size_t GetSize() const;
242 //----------------------------------------------------------------------------
243 // wxBitmapDataObject is a specialization of wxDataObject for bitmaps
244 //----------------------------------------------------------------------------
246 class wxBitmapDataObject
: public wxDataObject
248 DECLARE_DYNAMIC_CLASS( wxBitmapDataObject
)
252 /* see wxTextDataObject for explanation */
254 wxBitmapDataObject();
255 wxBitmapDataObject( const wxBitmap
& bitmap
);
257 void SetBitmap( const wxBitmap
&bitmap
);
258 wxBitmap
GetBitmap() const;
260 virtual void WriteData( void *dest
) const;
261 virtual size_t GetSize() const;
263 void WriteBitmap( const wxBitmap
&bitmap
, void *dest
) const;
271 //----------------------------------------------------------------------------
272 // wxPrivateDataObject is a specialization of wxDataObject for app specific data
273 //----------------------------------------------------------------------------
275 class wxPrivateDataObject
: public wxDataObject
277 DECLARE_DYNAMIC_CLASS( wxPrivateDataObject
)
281 /* see wxTextDataObject for explanation of functions */
283 wxPrivateDataObject();
284 ~wxPrivateDataObject();
286 /* the string Id identifies the format of clipboard or DnD data. a word
287 * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
288 * to the clipboard - the latter with the Id "application/wxword", an
289 * image manipulation program would put a wxBitmapDataObject and a
290 * wxPrivateDataObject to the clipboard - the latter with "image/png". */
292 void SetId( const wxString
& id
);
295 wxString
GetId() const;
297 /* set data. will make internal copy. */
298 void SetData( const char *data
, size_t size
);
300 /* returns pointer to data */
301 char* GetData() const;
303 virtual void WriteData( void *dest
) const;
304 virtual size_t GetSize() const;
306 void WriteData( const char *data
, void *dest
) const;