]>
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 // wxDataFormat (internal)
36 //-------------------------------------------------------------------------
38 class wxDataFormat
: public wxObject
40 DECLARE_CLASS( wxDataFormat
)
44 wxDataFormat( wxDataFormatId type
);
45 wxDataFormat( const wxString
&id
);
46 wxDataFormat( const wxChar
*id
);
47 wxDataFormat( wxDataFormat
&format
);
48 wxDataFormat( const GdkAtom atom
);
50 void SetType( wxDataFormatId type
);
51 wxDataFormatId
GetType() const;
53 /* the string Id identifies the format of clipboard or DnD data. a word
54 * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
55 * to the clipboard - the latter with the Id "application/wxword", an
56 * image manipulation program would put a wxBitmapDataObject and a
57 * wxPrivateDataObject to the clipboard - the latter with "image/png". */
59 wxString
GetId() const;
60 void SetId( const wxChar
*id
);
63 void SetAtom(GdkAtom atom
) { m_hasAtom
= TRUE
; m_atom
= atom
; }
66 wxDataFormatId m_type
;
72 //-------------------------------------------------------------------------
73 // wxDataBroker (internal)
74 //-------------------------------------------------------------------------
76 class wxDataBroker
: public wxObject
78 DECLARE_CLASS( wxDataBroker
)
86 void Add( wxDataObject
*dataObject
, bool preferred
= FALSE
);
90 /* OLE implementation, the methods don't need to be overridden */
92 /* get number of supported formats */
93 virtual size_t GetFormatCount() const;
95 /* return nth supported format */
96 virtual wxDataFormat
&GetNthFormat( size_t nth
) const;
98 /* return preferrd/best supported format */
99 virtual wxDataFormat
&GetPreferredFormat() const;
101 /* search through m_dataObjects, return TRUE if found */
102 virtual bool IsSupportedFormat( wxDataFormat
&format
) const;
104 /* search through m_dataObjects and call child's GetSize() */
105 virtual size_t GetSize( wxDataFormat
& format
) const;
107 /* search through m_dataObjects and call child's WriteData(dest) */
108 virtual void WriteData( wxDataFormat
& format
, void *dest
) const;
114 wxList m_dataObjects
;
118 //----------------------------------------------------------------------------
119 // wxDataObject to be placed in wxDataBroker
120 //----------------------------------------------------------------------------
122 class wxDataObject
: public wxObject
124 DECLARE_DYNAMIC_CLASS( wxDataObject
)
134 /* write data to dest */
135 virtual void WriteData( void *dest
) const = 0;
137 /* get size of data */
138 virtual size_t GetSize() const = 0;
142 wxDataFormat
&GetFormat();
144 wxDataFormatId
GetFormatType() const;
145 wxString
GetFormatId() const;
146 GdkAtom
GetFormatAtom() const;
148 wxDataFormat m_format
;
151 //----------------------------------------------------------------------------
152 // wxTextDataObject is a specialization of wxDataObject for text data
153 //----------------------------------------------------------------------------
155 class wxTextDataObject
: public wxDataObject
157 DECLARE_DYNAMIC_CLASS( wxTextDataObject
)
161 /* default constructor. call SetText() later or override
162 WriteData() and GetSize() for working on-demand */
166 wxTextDataObject( const wxString
& data
);
168 /* set current text data */
169 void SetText( const wxString
& data
);
171 /* get current text data */
172 wxString
GetText() const;
174 /* by default calls WriteString() with string set by constructor or
175 by SetText(). can be overridden for working on-demand */
176 virtual void WriteData( void *dest
) const;
178 /* by default, returns length of string as set by constructor or
179 by SetText(). can be overridden for working on-demand */
180 virtual size_t GetSize() const;
182 /* write string to dest */
183 void WriteString( const wxString
&str
, void *dest
) const;
190 //----------------------------------------------------------------------------
191 // wxFileDataObject is a specialization of wxDataObject for file names
192 //----------------------------------------------------------------------------
194 class wxFileDataObject
: public wxDataObject
196 DECLARE_DYNAMIC_CLASS( wxFileDataObject
)
200 /* default constructor */
203 /* add file name to list */
204 void AddFile( const wxString
&file
);
206 /* get all filename as one string. each file name is 0 terminated,
207 the list is double zero terminated */
208 wxString
GetFiles() const;
210 /* write list of filenames */
211 virtual void WriteData( void *dest
) const;
213 /* return length of list of filenames */
214 virtual size_t GetSize() const;
221 //----------------------------------------------------------------------------
222 // wxBitmapDataObject is a specialization of wxDataObject for bitmaps
223 //----------------------------------------------------------------------------
225 class wxBitmapDataObject
: public wxDataObject
227 DECLARE_DYNAMIC_CLASS( wxBitmapDataObject
)
231 /* see wxTextDataObject for explanation */
233 wxBitmapDataObject();
234 wxBitmapDataObject( const wxBitmap
& bitmap
);
236 void SetBitmap( const wxBitmap
&bitmap
);
237 wxBitmap
GetBitmap() const;
239 virtual void WriteData( void *dest
) const;
240 virtual size_t GetSize() const;
242 void WriteBitmap( const wxBitmap
&bitmap
, void *dest
) const;