]>
git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dataobj.h
1 ///////////////////////////////////////////////////////////////////////////////
3 // Purpose: declaration of the wxDataObject class
4 // Author: Julian Smart
6 // Copyright: (c) 1998 Julian Smart
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
10 #ifndef _WX_DATAOBJ_H_
11 #define _WX_DATAOBJ_H_
14 #pragma interface "dataobj.h"
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/bitmap.h"
22 //-------------------------------------------------------------------------
24 //-------------------------------------------------------------------------
28 class wxTextDataObject
;
30 //-------------------------------------------------------------------------
32 //-------------------------------------------------------------------------
34 class wxDataFormat
: public wxObject
36 DECLARE_CLASS( wxDataFormat
)
40 wxDataFormat( wxDataFormatId type
);
41 wxDataFormat( const wxString
&id
);
42 wxDataFormat( const wxChar
*id
);
43 wxDataFormat( const wxDataFormat
&format
);
44 wxDataFormat( const Atom atom
);
46 void SetType( wxDataFormatId type
);
47 wxDataFormatId
GetType() const;
49 /* the string Id identifies the format of clipboard or DnD data. a word
50 * processor would e.g. add a wxTextDataObject and a wxPrivateDataObject
51 * to the clipboard - the latter with the Id "application/wxword", an
52 * image manipulation program would put a wxBitmapDataObject and a
53 * wxPrivateDataObject to the clipboard - the latter with "image/png". */
55 wxString
GetId() const;
56 void SetId( const wxChar
*id
);
59 void SetAtom(Atom atom
) { m_hasAtom
= TRUE
; m_atom
= atom
; }
61 // implicit conversion to wxDataFormatId
62 operator wxDataFormatId() const { return m_type
; }
64 bool operator==(wxDataFormatId type
) const { return m_type
== type
; }
65 bool operator!=(wxDataFormatId type
) const { return m_type
!= type
; }
68 wxDataFormatId m_type
;
74 //----------------------------------------------------------------------------
75 // wxDataObject to be placed in wxDataBroker
76 //----------------------------------------------------------------------------
78 class wxDataObject
: public wxObject
80 DECLARE_DYNAMIC_CLASS( wxDataObject
)
90 /* write data to dest */
91 virtual void WriteData( void *dest
) const = 0;
93 /* get size of data */
94 virtual size_t GetSize() const = 0;
98 wxDataFormat
&GetFormat();
100 wxDataFormatId
GetFormatType() const;
101 wxString
GetFormatId() const;
102 Atom
GetFormatAtom() const;
104 wxDataFormat m_format
;
107 //----------------------------------------------------------------------------
108 // wxTextDataObject is a specialization of wxDataObject for text data
109 //----------------------------------------------------------------------------
111 class wxTextDataObject
: public wxDataObject
113 DECLARE_DYNAMIC_CLASS( wxTextDataObject
)
117 /* default constructor. call SetText() later or override
118 WriteData() and GetSize() for working on-demand */
122 wxTextDataObject( const wxString
& data
);
124 /* set current text data */
125 void SetText( const wxString
& data
);
127 /* get current text data */
128 wxString
GetText() const;
130 /* by default calls WriteString() with string set by constructor or
131 by SetText(). can be overridden for working on-demand */
132 virtual void WriteData( void *dest
) const;
134 /* by default, returns length of string as set by constructor or
135 by SetText(). can be overridden for working on-demand */
136 virtual size_t GetSize() const;
138 /* write string to dest */
139 void WriteString( const wxString
&str
, void *dest
) const;