]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/gtk/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( wxDataFormat
&format
);
74 wxDataFormat( const GdkAtom atom
);
76 void SetType( wxDataType type
);
77 wxDataType
GetType() const;
79 wxString
GetId() const;
80 void SetId( const wxString
&id
);
92 //-------------------------------------------------------------------------
93 // wxDataBroker (internal)
94 //-------------------------------------------------------------------------
96 class wxDataBroker
: public wxObject
98 DECLARE_CLASS( wxDataBroker
)
105 /* add data object */
106 void Add( wxDataObject
*dataObject
, bool preferred
= FALSE
);
110 /* OLE implementation, the methods don't need to be overridden */
112 /* get number of supported formats */
113 virtual size_t GetFormatCount() const;
115 /* return nth supported format */
116 virtual wxDataFormat
&GetNthFormat( size_t nth
) const;
118 /* return preferrd/best supported format */
119 virtual wxDataFormat
&GetPreferredFormat() const;
121 /* search through m_dataObjects, return TRUE if found */
122 virtual bool IsSupportedFormat( wxDataFormat
&format
) const;
124 /* search through m_dataObjects and call child's GetSize() */
125 virtual size_t GetSize( wxDataFormat
& format
) const;
127 /* search through m_dataObjects and call child's WriteData(dest) */
128 virtual void WriteData( wxDataFormat
& format
, void *dest
) const;
134 wxList m_dataObjects
;
138 //----------------------------------------------------------------------------
139 // wxDataObject to be placed in wxDataBroker
140 //----------------------------------------------------------------------------
142 class wxDataObject
: public wxObject
144 DECLARE_DYNAMIC_CLASS( wxDataObject
)
154 /* write data to dest */
155 virtual void WriteData( void *dest
) const = 0;
157 /* get size of data */
158 virtual size_t GetSize() const = 0;
162 wxDataFormat
&GetFormat();
164 wxDataType
GetFormatType() const;
165 wxString
GetFormatId() const;
166 GdkAtom
GetFormatAtom() const;
168 wxDataFormat m_format
;
171 //----------------------------------------------------------------------------
172 // wxTextDataObject is a specialization of wxDataObject for text data
173 //----------------------------------------------------------------------------
175 class wxTextDataObject
: public wxDataObject
177 DECLARE_DYNAMIC_CLASS( wxTextDataObject
)
181 /* default constructor. call SetText() later or override
182 WriteData() and GetSize() for working on-demand */
186 wxTextDataObject( const wxString
& data
);
188 /* set current text data */
189 void SetText( const wxString
& data
);
191 /* get current text data */
192 wxString
GetText() const;
194 /* by default calls WriteString() with string set by constructor or
195 by SetText(). can be overridden for working on-demand */
196 virtual void WriteData( void *dest
) const;
198 /* by default, returns length of string as set by constructor or
199 by SetText(). can be overridden for working on-demand */
200 virtual size_t GetSize() const;
202 /* write string to dest */
203 void WriteString( const wxString
&str
, void *dest
) const;
210 //----------------------------------------------------------------------------
211 // wxFileDataObject is a specialization of wxDataObject for file names
212 //----------------------------------------------------------------------------
214 class wxFileDataObject
: public wxDataObject
216 DECLARE_DYNAMIC_CLASS( wxFileDataObject
)
220 /* default constructor */
223 /* add file name to list */
224 void AddFile( const wxString
&file
);
226 /* get all filename as one string. each file name is 0 terminated,
227 the list is double zero terminated */
228 wxString
GetFiles() const;
230 /* write list of filenames */
231 virtual void WriteData( void *dest
) const;
233 /* return length of list of filenames */
234 virtual size_t GetSize() const;
241 //----------------------------------------------------------------------------
242 // wxBitmapDataObject is a specialization of wxDataObject for bitmaps
243 //----------------------------------------------------------------------------
245 class wxBitmapDataObject
: public wxDataObject
247 DECLARE_DYNAMIC_CLASS( wxBitmapDataObject
)
251 /* see wxTextDataObject for explanation */
253 wxBitmapDataObject();
254 wxBitmapDataObject( const wxBitmap
& bitmap
);
256 void SetBitmap( const wxBitmap
&bitmap
);
257 wxBitmap
GetBitmap() const;
259 virtual void WriteData( void *dest
) const;
260 virtual size_t GetSize() const;
262 void WriteBitmap( const wxBitmap
&bitmap
, void *dest
) const;
270 //----------------------------------------------------------------------------
271 // wxPrivateDataObject is a specialization of wxDataObject for app specific data
272 //----------------------------------------------------------------------------
274 class wxPrivateDataObject
: public wxDataObject
276 DECLARE_DYNAMIC_CLASS( wxPrivateDataObject
)
280 /* see wxTextDataObject for explanation of functions */
282 wxPrivateDataObject();
283 ~wxPrivateDataObject();
285 /* the string Id identifies the format of clipboard or DnD data. a word
286 * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
287 * to the clipboard - the latter with the Id "application/wxword", an
288 * image manipulation program would put a wxBitmapDataObject and a
289 * wxPrivateDataObject to the clipboard - the latter with "image/png". */
291 void SetId( const wxString
& id
);
294 wxString
GetId() const;
296 /* set data. will make internal copy. */
297 void SetData( const char *data
, size_t size
);
299 /* returns pointer to data */
300 char* GetData() const;
302 virtual void WriteData( void *dest
) const;
303 virtual size_t GetSize() const;
305 void WriteData( const char *data
, void *dest
) const;