2 // Generated by gtkmmproc -- DO NOT MODIFY!
3 #ifndef _GTKMM_SELECTIONDATA_H
4 #define _GTKMM_SELECTIONDATA_H
11 /* Copyright(C) 2002 The gtkmm Development Team
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.
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.
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.
29 #include <gdkmm/display.h>
32 #ifndef DOXYGEN_SHOULD_SKIP_THIS
33 extern "C" { typedef struct _GtkSelectionData GtkSelectionData; }
39 #ifndef DOXYGEN_SHOULD_SKIP_THIS
41 #endif //DOXYGEN_SHOULD_SKIP_THIS
46 #ifndef DOXYGEN_SHOULD_SKIP_THIS
47 typedef SelectionData CppObjectType;
48 typedef GtkSelectionData BaseObjectType;
50 static GType get_type() G_GNUC_CONST;
51 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
55 explicit SelectionData(GtkSelectionData* gobject, bool make_a_copy = true);
57 SelectionData(const SelectionData& other);
58 SelectionData& operator=(const SelectionData& other);
62 void swap(SelectionData& other);
64 ///Provides access to the underlying C instance.
65 GtkSelectionData* gobj() { return gobject_; }
67 ///Provides access to the underlying C instance.
68 const GtkSelectionData* gobj() const { return gobject_; }
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;
74 GtkSelectionData* gobject_;
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);
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.
93 void set(const std::string& type, int format, const guint8* data, int length);
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).
101 void set(const std::string& type, const std::string& data);
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>.
111 bool set_text(const Glib::ustring& data);
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.
119 Glib::ustring get_text() const;
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 ->target.
125 * @param pixbuf A Gdk::Pixbuf.
126 * @return <tt>true</tt> if the selection was successfully set,
127 * otherwise <tt>false</tt>.
131 bool set_pixbuf(const Glib::RefPtr<Gdk::Pixbuf>& pixbuf);
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().
141 Glib::RefPtr<Gdk::Pixbuf> get_pixbuf();
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().
151 Glib::RefPtr<const Gdk::Pixbuf> get_pixbuf() const;
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 ->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>.
165 bool set_uris(const Glib::StringArrayHandle& uris);
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().
175 Glib::StringArrayHandle get_uris() const;
177 const guint8* get_data() const;
178 int get_length() const;
180 std::string get_data_as_string() const;
182 std::string get_target() const;
184 /// See also Gtk::Clipboard::request_targets()
185 Gdk::ArrayHandle_AtomString get_targets() const;
188 /** Returns the ID of the selection.
190 GdkAtom get_selection() const;
192 /** Returns the type of the data as set by SelectionData::set().
194 std::string get_data_type() const; // get_type() already exists
196 int get_format() const;
197 Glib::RefPtr<Gdk::Display> get_display();
198 Glib::RefPtr<const Gdk::Display> get_display() const;
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>.
209 bool targets_include_uri() const;
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
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>.
217 bool targets_include_text() const;
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
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>.
229 bool targets_include_rich_text(const Glib::RefPtr<TextBuffer>& buffer) const;
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>.
241 bool targets_include_image(bool writable = true) const;
252 /** @relates Gtk::SelectionData
253 * @param lhs The left-hand side
254 * @param rhs The right-hand side
256 inline void swap(SelectionData& lhs, SelectionData& rhs)
264 /** A Glib::wrap() method for this object.
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.
270 * @relates Gtk::SelectionData
272 Gtk::SelectionData wrap(GtkSelectionData* object, bool take_copy = false);
274 #ifndef DOXYGEN_SHOULD_SKIP_THIS
276 class Value<Gtk::SelectionData> : public Glib::Value_Boxed<Gtk::SelectionData>
278 #endif /* DOXYGEN_SHOULD_SKIP_THIS */
283 #endif /* _GTKMM_SELECTIONDATA_H */