/* Copyright (C) 2002 The gtkmm Development Team
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, see .
*/
_CONFIGINCLUDE(gtkmmconfig.h)
_DEFS(gtkmm,gtk)
#include
#include
#include
namespace Gtk
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
class GTKMM_API TextBuffer;
#endif //DOXYGEN_SHOULD_SKIP_THIS
class GTKMM_API SelectionData
{
_CLASS_BOXEDTYPE(SelectionData, GtkSelectionData, NONE, gtk_selection_data_copy, gtk_selection_data_free, GTKMM_API)
_IGNORE(gtk_selection_data_copy, gtk_selection_data_free)
public:
/** Assign a memory block of raw data.
* Store new data into the Gtk::SelectionData object. Should _only_ be called
* from a selection handler callback. A 0-byte terminates the stored data.
* The type of data is determined by get_target().
* @param format The data format, i.e. the number of bits in a unit.
* @param data Pointer to the data (will be copied).
* @param length The length of the data block in bytes.
*/
void set(int format, const guint8* data, int length);
/** Assign a memory block of raw data.
* Store new data into the Gtk::SelectionData object. Should _only_ be called
* from a selection handler callback. A 0-byte terminates the stored data.
* @param type The type of the selection data.
* @param format The data format, i.e. the number of bits in a unit.
* @param data Pointer to the data (will be copied).
* @param length The length of the data block in bytes.
*/
void set(const std::string& type, int format, const guint8* data, int length);
/** Assign a string of raw data.
* Store new data into the Gtk::SelectionData object. Should _only_ be called
* from a selection handler callback.
* @param type The type of the selection data.
* @param data A string that contains the data (does not have to be text).
*/
void set(const std::string& type, const std::string& data);
_IGNORE(gtk_selection_data_set)
/** Assign UTF-8 encoded text.
* Sets the contents of the selection from a UTF-8 encoded string.
* The string is converted to the form determined by get_target().
* @param data A UTF-8 encoded string.
* @return true if the selection was successfully set,
* otherwise false.
*/
bool set_text(const Glib::ustring& data);
_IGNORE(gtk_selection_data_set_text)
/** Gets the contents of the selection data as a UTF-8 string.
* @return If the selection data contained a recognized text type and
* it could be converted to UTF-8, a string containing the converted text,
* otherwise an empty string.
*/
Glib::ustring get_text() const;
_IGNORE(gtk_selection_data_get_text)
_WRAP_METHOD(bool set_pixbuf(const Glib::RefPtr& pixbuf), gtk_selection_data_set_pixbuf)
_WRAP_METHOD(Glib::RefPtr get_pixbuf(), gtk_selection_data_get_pixbuf)
_WRAP_METHOD(Glib::RefPtr get_pixbuf() const, gtk_selection_data_get_pixbuf, constversion)
dnl The constness of gtk_selection_data_set_uris() is not quite right:
#m4 _CONVERSION(`const std::vector&',`gchar**',`const_cast(Glib::ArrayHandler::vector_to_array($3).data())')
_WRAP_METHOD(bool set_uris(const std::vector& uris), gtk_selection_data_set_uris)
#m4 _CONVERSION(`gchar**',`std::vector',`Glib::ArrayHandler::array_to_vector($3, Glib::OWNERSHIP_DEEP)')
_WRAP_METHOD(std::vector get_uris() const, gtk_selection_data_get_uris)
_WRAP_METHOD(const guchar* get_data() const, gtk_selection_data_get_data)
_WRAP_METHOD(int get_length() const, gtk_selection_data_get_length)
_WRAP_METHOD(const guchar* get_data(int& length) const, gtk_selection_data_get_data_with_length)
/** Retrieves the raw data of the selection as a std::string.
* @return The raw data of the selection. Contains 0-bytes, if the selection data does.
*/
std::string get_data_as_string() const;
#m4 _CONVERSION(`GdkAtom',`std::string',`Gdk::AtomString::to_cpp_type ($3)')
_WRAP_METHOD(std::string get_selection() const, gtk_selection_data_get_selection)
/** Retrieves the target of the selection.
*
* @newin{2,14}
**/
std::string get_target() const;
_IGNORE(gtk_selection_data_get_target)
/// See also Gtk::Clipboard::request_targets()
std::vector get_targets() const;
_IGNORE(gtk_selection_data_get_targets)
/** Returns the type of the data as set by SelectionData::set().
*/
std::string get_data_type() const; // get_type() already exists
_IGNORE(gtk_selection_data_get_data_type)
_WRAP_METHOD(int get_format() const, gtk_selection_data_get_format)
_WRAP_METHOD(Glib::RefPtr get_display(), gtk_selection_data_get_display, refreturn)
_WRAP_METHOD(Glib::RefPtr get_display() const, gtk_selection_data_get_display, refreturn, constversion)
_WRAP_METHOD(bool targets_include_uri() const, gtk_selection_data_targets_include_uri)
_WRAP_METHOD(bool targets_include_text() const, gtk_selection_data_targets_include_text)
_WRAP_METHOD(bool targets_include_rich_text(const Glib::RefPtr& buffer) const, gtk_selection_data_targets_include_rich_text)
_WRAP_METHOD(bool targets_include_image(bool writable = true) const, gtk_selection_data_targets_include_image)
};
} // namespace Gtk