]> git.saurik.com Git - wxWidgets.git/blob - include/wx/motif/dataobj.h
Whole lot of stuff for new wxFileDialog
[wxWidgets.git] / include / wx / motif / dataobj.h
1 ///////////////////////////////////////////////////////////////////////////////
2 // Name: dataobj.h
3 // Purpose: declaration of the wxDataObject class
4 // Author: Julian Smart
5 // RCS-ID: $Id$
6 // Copyright: (c) 1998 Julian Smart
7 // Licence: wxWindows licence
8 ///////////////////////////////////////////////////////////////////////////////
9
10 #ifndef _WX_DATAOBJ_H_
11 #define _WX_DATAOBJ_H_
12
13 #ifdef __GNUG__
14 #pragma interface "dataobj.h"
15 #endif
16
17 #include "wx/defs.h"
18 #include "wx/object.h"
19 #include "wx/string.h"
20 #include "wx/bitmap.h"
21
22 //-------------------------------------------------------------------------
23 // classes
24 //-------------------------------------------------------------------------
25
26 class wxDataFormat;
27 class wxDataObject;
28 class wxTextDataObject;
29
30 //-------------------------------------------------------------------------
31 // wxDataFormat
32 //-------------------------------------------------------------------------
33
34 class wxDataFormat : public wxObject
35 {
36 DECLARE_CLASS( wxDataFormat )
37
38 public:
39 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 );
45
46 void SetType( wxDataFormatId type );
47 wxDataFormatId GetType() const;
48
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". */
54
55 wxString GetId() const;
56 void SetId( const wxChar *id );
57
58 Atom GetAtom();
59 void SetAtom(Atom atom) { m_hasAtom = TRUE; m_atom = atom; }
60
61 // implicit conversion to wxDataFormatId
62 operator wxDataFormatId() const { return m_type; }
63
64 bool operator==(wxDataFormatId type) const { return m_type == type; }
65 bool operator!=(wxDataFormatId type) const { return m_type != type; }
66
67 private:
68 wxDataFormatId m_type;
69 wxString m_id;
70 bool m_hasAtom;
71 Atom m_atom;
72 };
73
74 //----------------------------------------------------------------------------
75 // wxDataObject to be placed in wxDataBroker
76 //----------------------------------------------------------------------------
77
78 class wxDataObject : public wxObject
79 {
80 DECLARE_DYNAMIC_CLASS( wxDataObject )
81
82 public:
83
84 /* constructor */
85 wxDataObject();
86
87 /* destructor */
88 ~wxDataObject();
89
90 /* write data to dest */
91 virtual void WriteData( void *dest ) const = 0;
92
93 /* get size of data */
94 virtual size_t GetSize() const = 0;
95
96 /* implementation */
97
98 wxDataFormat &GetFormat();
99
100 wxDataFormatId GetFormatType() const;
101 wxString GetFormatId() const;
102 Atom GetFormatAtom() const;
103
104 wxDataFormat m_format;
105 };
106
107 //----------------------------------------------------------------------------
108 // wxTextDataObject is a specialization of wxDataObject for text data
109 //----------------------------------------------------------------------------
110
111 class wxTextDataObject : public wxDataObject
112 {
113 DECLARE_DYNAMIC_CLASS( wxTextDataObject )
114
115 public:
116
117 /* default constructor. call SetText() later or override
118 WriteData() and GetSize() for working on-demand */
119 wxTextDataObject();
120
121 /* constructor */
122 wxTextDataObject( const wxString& data );
123
124 /* set current text data */
125 void SetText( const wxString& data );
126
127 /* get current text data */
128 wxString GetText() const;
129
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;
133
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;
137
138 /* write string to dest */
139 void WriteString( const wxString &str, void *dest ) const;
140
141 /* implementation */
142
143 wxString m_data;
144 };
145
146
147 #endif
148 //_WX_DATAOBJ_H_
149