]>
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
)
66 wxDataFormat( wxDataType type
);
67 wxDataFormat( const wxString
&id
);
68 wxDataFormat( wxDataFormat
&format
);
69 wxDataFormat( const GdkAtom atom
);
72 wxString
GetId() const;
73 void SetId( const wxString
&id
);
84 //-------------------------------------------------------------------------
85 // wxDataBroker handles data and ormat negotiation for clipboard and DnD
86 //-------------------------------------------------------------------------
88 class wxDataBroker
: public wxObject
90 DECLARE_CLASS( wxDataBroker
)
98 void Add( wxDataObject
*dataObject
, bool preferred
= FALSE
);
102 /* OLE implementation, the methods don't need to be overridden */
104 /* get number of supported formats */
105 virtual size_t GetFormatCount() const;
107 /* return nth supported format */
108 virtual wxDataFormat
&GetNthFormat( size_t nth
) const;
110 /* return preferrd/best supported format */
111 virtual wxDataFormat
&GetPreferredFormat() const;
113 /* search through m_dataObjects, return TRUE if found */
114 virtual bool IsSupportedFormat( wxDataFormat
&format
) const;
116 /* search through m_dataObjects and call child's GetSize() */
117 virtual size_t GetSize( wxDataFormat
& format
) const;
119 /* search through m_dataObjects and call child's WriteData(dest) */
120 virtual void WriteData( wxDataFormat
& format
, void *dest
) const;
126 wxList m_dataObjects
;
130 //----------------------------------------------------------------------------
131 // wxDataObject to be placed in wxDataBroker
132 //----------------------------------------------------------------------------
134 class wxDataObject
: public wxObject
136 DECLARE_DYNAMIC_CLASS( wxDataObject
)
146 /* write data to dest */
147 virtual void WriteData( void *dest
) const = 0;
149 /* get size of data */
150 virtual size_t GetSize() const = 0;
154 virtual wxDataFormat
&GetFormat() const;
156 wxDataFormat
*m_format
;
159 //----------------------------------------------------------------------------
160 // wxTextDataObject is a specialization of wxDataObject for text data
161 //----------------------------------------------------------------------------
163 class wxTextDataObject
: public wxDataObject
165 DECLARE_DYNAMIC_CLASS( wxTextDataObject
)
169 /* default constructor. call SetText() later or override
170 WriteData() and GetSize() for working on-demand */
174 wxTextDataObject( const wxString
& data
);
176 /* set current text data */
177 void SetText( const wxString
& data
);
179 /* get current text data */
180 wxString
GetText() const;
182 /* by default calls WriteString() with string set by constructor or
183 by SetText(). can be overridden for working on-demand */
184 virtual void WriteData( void *dest
) const;
186 /* by default, returns length of string as set by constructor or
187 by SetText(). can be overridden for working on-demand */
188 virtual size_t GetSize() const;
190 /* write string to dest */
191 void WriteString( const wxString
&str
, void *dest
) const;
198 //----------------------------------------------------------------------------
199 // wxFileDataObject is a specialization of wxDataObject for file names
200 //----------------------------------------------------------------------------
202 class wxFileDataObject
: public wxDataObject
204 DECLARE_DYNAMIC_CLASS( wxFileDataObject
)
208 /* default constructor */
211 /* add file name to list */
212 void AddFile( const wxString
&file
);
214 /* get all filename as one string. each file name is 0 terminated,
215 the list is double zero terminated */
216 wxString
GetFiles() const;
218 /* write list of filenames */
219 virtual void WriteData( void *dest
) const;
221 /* return length of list of filenames */
222 virtual size_t GetSize() const;
229 //----------------------------------------------------------------------------
230 // wxBitmapDataObject is a specialization of wxDataObject for bitmaps
231 //----------------------------------------------------------------------------
233 class wxBitmapDataObject
: public wxDataObject
235 DECLARE_DYNAMIC_CLASS( wxBitmapDataObject
)
239 /* see wxTextDataObject for explanation */
241 wxBitmapDataObject();
242 wxBitmapDataObject( const wxBitmap
& bitmap
);
244 void SetBitmap( const wxBitmap
&bitmap
);
245 wxBitmap
GetBitmap() const;
247 virtual void WriteData( void *dest
) const;
248 virtual size_t GetSize() const;
250 void WriteBitmap( const wxBitmap
&bitmap
, void *dest
) const;
258 //----------------------------------------------------------------------------
259 // wxPrivateDataObject is a specialization of wxDataObject for app specific data
260 //----------------------------------------------------------------------------
262 class wxPrivateDataObject
: public wxDataObject
264 DECLARE_DYNAMIC_CLASS( wxPrivateDataObject
)
268 /* see wxTextDataObject for explanation of functions */
270 wxPrivateDataObject();
271 ~wxPrivateDataObject();
273 /* the string Id identifies the format of clipboard or DnD data. a word
274 * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
275 * to the clipboard - the latter with the Id "application/wxword", an
276 * image manipulation program would put a wxBitmapDataObject and a
277 * wxPrivateDataObject to the clipboard - the latter with "image/png". */
279 void SetId( const wxString
& id
);
282 wxString
GetId() const;
284 /* set data. will make internal copy. */
285 void SetData( const char *data
, size_t size
);
287 /* returns pointer to data */
288 char* GetData() const;
290 virtual void WriteData( void *dest
) const;
291 virtual size_t GetSize() const;
293 void WriteData( const char *data
, void *dest
) const;