add new sigc++2 directory
[ardour.git] / libs / gtkmm2 / gtk / gtkmm / selectiondata.h
1 // -*- c++ -*-
2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_SELECTIONDATA_H
4 #define _GTKMM_SELECTIONDATA_H
5
6
7 #include <glibmm.h>
8
9 /* $Id$ */
10
11 /* Copyright(C) 2002 The gtkmm Development Team
12  *
13  * This library is free software, ) you can redistribute it and/or
14  * modify it under the terms of the GNU Library General Public
15  * License as published by the Free Software Foundation, ) either
16  * version 2 of the License, or(at your option) any later version.
17  *
18  * This library is distributed in the hope that it will be useful,
19  * but WITHOUT ANY WARRANTY, ) without even the implied warranty of
20  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21  * Library General Public License for more details.
22  *
23  * You should have received a copy of the GNU Library General Public
24  * License along with this library, ) if not, write to the Free
25  * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26  */
27
28
29 #include <gdkmm/display.h>
30
31
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 extern "C" { typedef struct _GtkSelectionData GtkSelectionData; }
34 #endif
35
36 namespace Gtk
37 {
38
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
40 class TextBuffer;
41 #endif //DOXYGEN_SHOULD_SKIP_THIS
42
43 class SelectionData
44 {
45   public:
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47   typedef SelectionData CppObjectType;
48   typedef GtkSelectionData BaseObjectType;
49
50   static GType get_type() G_GNUC_CONST;
51 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
52
53   SelectionData();
54
55   explicit SelectionData(GtkSelectionData* gobject, bool make_a_copy = true);
56
57   SelectionData(const SelectionData& other);
58   SelectionData& operator=(const SelectionData& other);
59
60   ~SelectionData();
61
62   void swap(SelectionData& other);
63
64   ///Provides access to the underlying C instance.
65   GtkSelectionData*       gobj()       { return gobject_; }
66
67   ///Provides access to the underlying C instance.
68   const GtkSelectionData* gobj() const { return gobject_; }
69
70   ///Provides access to the underlying C instance. The caller is responsible for freeing it. Use when directly setting fields in structs.
71   GtkSelectionData* gobj_copy() const;
72
73 protected:
74   GtkSelectionData* gobject_;
75
76 private:
77
78   
79 public:
80
81   //TODO : document this. It's like the other set(), but it uses this SelectionData's target type.
82   //Why would you ever want to use any other type?
83   void set(int format, const guint8* data, int length);
84   
85   /** Assign a memory block of raw data.
86    * Store new data into the Gtk::SelectionData object. Should _only_ by called
87    * from a selection handler callback.  A 0-byte terminates the stored data.
88    * @param type The type of the selection.
89    * @param format The data format, i.e. the number of bits in a unit.
90    * @param data Pointer to the data (will be copied).
91    * @param length The length of the data block in bytes.
92    */
93   void set(const std::string& type, int format, const guint8* data, int length);
94
95   /** Assign a string of raw data.
96    * Store new data into the Gtk::SelectionData object. Should _only_ by called
97    * from a selection handler callback. 
98    * @param type The type of the selection.
99    * @param data A string that contains the data (does not have to be text).
100    */
101   void set(const std::string& type, const std::string& data);
102   
103
104   /** Assign UTF-8 encoded text.
105    * Sets the contents of the selection from a UTF-8 encoded string.
106    * The string is converted to the form determined by get_target().
107    * @param data A UTF-8 encoded string.
108    * @return <tt>true</tt> if the selection was successfully set,
109    * otherwise <tt>false</tt>.
110    */
111   bool set_text(const Glib::ustring& data);
112   
113
114   /** Gets the contents of the selection data as a UTF-8 string.
115    * @return If the selection data contained a recognized text type and
116    * it could be converted to UTF-8, a string containing the converted text,
117    * otherwise an empty string.
118    */
119   Glib::ustring get_text() const;
120   
121
122   /** Sets the contents of the selection from a Gdk::Pixbuf
123    * The pixbuf is converted to the form determined by
124    *  @a selection_data -&gt;target.
125    * @param pixbuf A Gdk::Pixbuf.
126    * @return <tt>true</tt> if the selection was successfully set,
127    * otherwise <tt>false</tt>.
128    * 
129    * @newin2p6.
130    */
131   bool set_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
132   
133   /** Gets the contents of the selection data as a Gdk::Pixbuf.
134    * @return If the selection data contained a recognized
135    * image type and it could be converted to a Gdk::Pixbuf, a 
136    * newly allocated pixbuf is returned, otherwise <tt>0</tt>.
137    * If the result is non-<tt>0</tt> it must be freed with Glib::object_unref().
138    * 
139    * @newin2p6.
140    */
141   Glib::RefPtr<Gdk::Pixbuf> get_pixbuf();
142   
143   /** Gets the contents of the selection data as a Gdk::Pixbuf.
144    * @return If the selection data contained a recognized
145    * image type and it could be converted to a Gdk::Pixbuf, a 
146    * newly allocated pixbuf is returned, otherwise <tt>0</tt>.
147    * If the result is non-<tt>0</tt> it must be freed with Glib::object_unref().
148    * 
149    * @newin2p6.
150    */
151   Glib::RefPtr<const Gdk::Pixbuf> get_pixbuf() const;
152   
153
154
155  
156   /** Sets the contents of the selection from a list of URIs.
157    * The string is converted to the form determined by
158    *  @a selection_data -&gt;target.
159    * @param uris A <tt>0</tt>-terminated array of strings hilding URIs.
160    * @return <tt>true</tt> if the selection was successfully set,
161    * otherwise <tt>false</tt>.
162    * 
163    * @newin2p6.
164    */
165   bool set_uris(const Glib::StringArrayHandle& uris);
166   
167   /** Gets the contents of the selection data as array of URIs.
168    * @return If the selection data contains a list of
169    * URIs, a newly allocated <tt>0</tt>-terminated string array
170    * containing the URIs, otherwise <tt>0</tt>. If the result is 
171    * non-<tt>0</tt> it must be freed with Glib::strfreev().
172    * 
173    * @newin2p6.
174    */
175   Glib::StringArrayHandle get_uris() const;
176
177    const guint8* get_data() const;
178     int get_length() const;
179  
180   std::string get_data_as_string() const;
181
182   std::string get_target() const;
183
184   /// See also Gtk::Clipboard::request_targets()
185   Gdk::ArrayHandle_AtomString get_targets() const;
186   
187
188   /** Returns the ID of the selection.
189    */
190    GdkAtom get_selection() const;
191  
192   /** Returns the type of the data as set by SelectionData::set().
193    */
194   std::string get_data_type() const; // get_type() already exists
195
196    int get_format() const;
197     Glib::RefPtr<Gdk::Display> get_display();
198   Glib::RefPtr<const Gdk::Display> get_display() const;
199  
200   
201   /** Given a Gtk::SelectionData object holding a list of targets,
202    * determines if any of the targets in @a targets  can be used to
203    * provide a list or URIs.
204    * @return <tt>true</tt> if @a selection_data  holds a list of targets,
205    * and a suitable target for text is included, otherwise <tt>false</tt>.
206    * 
207    * @newin2p10.
208    */
209   bool targets_include_uri() const;
210   
211   /** Given a Gtk::SelectionData object holding a list of targets,
212    * determines if any of the targets in @a targets  can be used to
213    * provide text.
214    * @return <tt>true</tt> if @a selection_data  holds a list of targets,
215    * and a suitable target for text is included, otherwise <tt>false</tt>.
216    */
217   bool targets_include_text() const;
218   
219   /** Given a Gtk::SelectionData object holding a list of targets,
220    * determines if any of the targets in @a targets  can be used to
221    * provide rich text.
222    * @param buffer A Gtk::TextBuffer.
223    * @return <tt>true</tt> if @a selection_data  holds a list of targets,
224    * and a suitable target for rich text is included,
225    * otherwise <tt>false</tt>.
226    * 
227    * @newin2p10.
228    */
229   bool targets_include_rich_text(const Glib::RefPtr<TextBuffer>& buffer) const;
230   
231   /** Given a Gtk::SelectionData object holding a list of targets,
232    * determines if any of the targets in @a targets  can be used to
233    * provide a Gdk::Pixbuf.
234    * @param writable Whether to accept only targets for which GTK+ knows
235    * how to convert a pixbuf into the format.
236    * @return <tt>true</tt> if @a selection_data  holds a list of targets,
237    * and a suitable target for images is included, otherwise <tt>false</tt>.
238    * 
239    * @newin2p6.
240    */
241   bool targets_include_image(bool writable = true) const;
242
243
244 };
245
246 } // namespace Gtk
247
248
249 namespace Gtk
250 {
251
252 /** @relates Gtk::SelectionData
253  * @param lhs The left-hand side
254  * @param rhs The right-hand side
255  */
256 inline void swap(SelectionData& lhs, SelectionData& rhs)
257   { lhs.swap(rhs); }
258
259 } // namespace Gtk
260
261 namespace Glib
262 {
263
264 /** A Glib::wrap() method for this object.
265  * 
266  * @param object The C instance.
267  * @param take_copy False if the result should take ownership of the C instance. True if it should take a new copy or ref.
268  * @result A C++ instance that wraps this C instance.
269  *
270  * @relates Gtk::SelectionData
271  */
272 Gtk::SelectionData wrap(GtkSelectionData* object, bool take_copy = false);
273
274 #ifndef DOXYGEN_SHOULD_SKIP_THIS
275 template <>
276 class Value<Gtk::SelectionData> : public Glib::Value_Boxed<Gtk::SelectionData>
277 {};
278 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
279
280 } // namespace Glib
281
282
283 #endif /* _GTKMM_SELECTIONDATA_H */
284