]>
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 //-------------------------------------------------------------------------
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 class wxDataFormat
: public wxObject
62 DECLARE_CLASS( wxDataFormat
)
67 wxDataFormat( wxDataType type
);
68 wxDataFormat( const wxString
&id
);
69 wxDataFormat( wxDataFormat
&format
);
70 wxDataFormat( const GdkAtom atom
);
72 void SetType( wxDataType type
);
73 wxDataType
GetType() const;
75 wxString
GetId() const;
76 void SetId( const wxString
&id
);
88 //-------------------------------------------------------------------------
89 // wxDataBroker handles data and ormat negotiation for clipboard and DnD
90 //-------------------------------------------------------------------------
92 class wxDataBroker
: public wxObject
94 DECLARE_CLASS( wxDataBroker
)
101 /* add data object */
102 void Add( wxDataObject
*dataObject
, bool preferred
= FALSE
);
106 /* OLE implementation, the methods don't need to be overridden */
108 /* get number of supported formats */
109 virtual size_t GetFormatCount() const;
111 /* return nth supported format */
112 virtual wxDataFormat
&GetNthFormat( size_t nth
) const;
114 /* return preferrd/best supported format */
115 virtual wxDataFormat
&GetPreferredFormat() const;
117 /* search through m_dataObjects, return TRUE if found */
118 virtual bool IsSupportedFormat( wxDataFormat
&format
) const;
120 /* search through m_dataObjects and call child's GetSize() */
121 virtual size_t GetSize( wxDataFormat
& format
) const;
123 /* search through m_dataObjects and call child's WriteData(dest) */
124 virtual void WriteData( wxDataFormat
& format
, void *dest
) const;
130 wxList m_dataObjects
;
134 //----------------------------------------------------------------------------
135 // wxDataObject to be placed in wxDataBroker
136 //----------------------------------------------------------------------------
138 class wxDataObject
: public wxObject
140 DECLARE_DYNAMIC_CLASS( wxDataObject
)
150 /* write data to dest */
151 virtual void WriteData( void *dest
) const = 0;
153 /* get size of data */
154 virtual size_t GetSize() const = 0;
158 wxDataFormat
&GetFormat();
160 wxDataType
GetFormatType() const;
161 wxString
GetFormatId() const;
162 GdkAtom
GetFormatAtom() const;
164 wxDataFormat m_format
;
167 //----------------------------------------------------------------------------
168 // wxTextDataObject is a specialization of wxDataObject for text data
169 //----------------------------------------------------------------------------
171 class wxTextDataObject
: public wxDataObject
173 DECLARE_DYNAMIC_CLASS( wxTextDataObject
)
177 /* default constructor. call SetText() later or override
178 WriteData() and GetSize() for working on-demand */
182 wxTextDataObject( const wxString
& data
);
184 /* set current text data */
185 void SetText( const wxString
& data
);
187 /* get current text data */
188 wxString
GetText() const;
190 /* by default calls WriteString() with string set by constructor or
191 by SetText(). can be overridden for working on-demand */
192 virtual void WriteData( void *dest
) const;
194 /* by default, returns length of string as set by constructor or
195 by SetText(). can be overridden for working on-demand */
196 virtual size_t GetSize() const;
198 /* write string to dest */
199 void WriteString( const wxString
&str
, void *dest
) const;
206 //----------------------------------------------------------------------------
207 // wxFileDataObject is a specialization of wxDataObject for file names
208 //----------------------------------------------------------------------------
210 class wxFileDataObject
: public wxDataObject
212 DECLARE_DYNAMIC_CLASS( wxFileDataObject
)
216 /* default constructor */
219 /* add file name to list */
220 void AddFile( const wxString
&file
);
222 /* get all filename as one string. each file name is 0 terminated,
223 the list is double zero terminated */
224 wxString
GetFiles() const;
226 /* write list of filenames */
227 virtual void WriteData( void *dest
) const;
229 /* return length of list of filenames */
230 virtual size_t GetSize() const;
237 //----------------------------------------------------------------------------
238 // wxBitmapDataObject is a specialization of wxDataObject for bitmaps
239 //----------------------------------------------------------------------------
241 class wxBitmapDataObject
: public wxDataObject
243 DECLARE_DYNAMIC_CLASS( wxBitmapDataObject
)
247 /* see wxTextDataObject for explanation */
249 wxBitmapDataObject();
250 wxBitmapDataObject( const wxBitmap
& bitmap
);
252 void SetBitmap( const wxBitmap
&bitmap
);
253 wxBitmap
GetBitmap() const;
255 virtual void WriteData( void *dest
) const;
256 virtual size_t GetSize() const;
258 void WriteBitmap( const wxBitmap
&bitmap
, void *dest
) const;
266 //----------------------------------------------------------------------------
267 // wxPrivateDataObject is a specialization of wxDataObject for app specific data
268 //----------------------------------------------------------------------------
270 class wxPrivateDataObject
: public wxDataObject
272 DECLARE_DYNAMIC_CLASS( wxPrivateDataObject
)
276 /* see wxTextDataObject for explanation of functions */
278 wxPrivateDataObject();
279 ~wxPrivateDataObject();
281 /* the string Id identifies the format of clipboard or DnD data. a word
282 * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
283 * to the clipboard - the latter with the Id "application/wxword", an
284 * image manipulation program would put a wxBitmapDataObject and a
285 * wxPrivateDataObject to the clipboard - the latter with "image/png". */
287 void SetId( const wxString
& id
);
290 wxString
GetId() const;
292 /* set data. will make internal copy. */
293 void SetData( const char *data
, size_t size
);
295 /* returns pointer to data */
296 char* GetData() const;
298 virtual void WriteData( void *dest
) const;
299 virtual size_t GetSize() const;
301 void WriteData( const char *data
, void *dest
) const;