ardour/libs/gtkmm2/gtk/src/selectiondata.hg
Paul Davis 449aab3c46 rollback to 3428, before the mysterious removal of libs/* at 3431/3432
git-svn-id: svn://localhost/ardour2/branches/3.0@3435 d708f5d6-7413-0410-9779-e7cbd77b26cf
2008-06-02 21:41:35 +00:00

117 lines
4.7 KiB
Text

/* $Id: selectiondata.hg,v 1.9 2006/07/05 16:59:28 murrayc Exp $ */
/* 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 Library General Public
* License as published by the Free Software Foundation, ) either
* version 2 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library, ) if not, write to the Free
* Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
_DEFS(gtkmm,gtk)
#include <gdkmm/display.h>
namespace Gtk
{
#ifndef DOXYGEN_SHOULD_SKIP_THIS
class TextBuffer;
#endif //DOXYGEN_SHOULD_SKIP_THIS
class SelectionData
{
_CLASS_BOXEDTYPE(SelectionData, GtkSelectionData, NONE, gtk_selection_data_copy, gtk_selection_data_free)
_IGNORE(gtk_selection_data_copy, gtk_selection_data_free)
public:
//TODO : document this. It's like the other set(), but it uses this SelectionData's target type.
//Why would you ever want to use any other type?
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_ by called
* from a selection handler callback. A 0-byte terminates the stored data.
* @param type The type of the selection.
* @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_ by called
* from a selection handler callback.
* @param type The type of the selection.
* @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 <tt>true</tt> if the selection was successfully set,
* otherwise <tt>false</tt>.
*/
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<Gdk::Pixbuf>& pixbuf), gtk_selection_data_set_pixbuf)
_WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_pixbuf(), gtk_selection_data_get_pixbuf)
_WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> 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 Glib::StringArrayHandle&',`gchar**',`const_cast<char**>(($3).data())')
_WRAP_METHOD(bool set_uris(const Glib::StringArrayHandle& uris), gtk_selection_data_set_uris)
_WRAP_METHOD(Glib::StringArrayHandle get_uris() const, gtk_selection_data_get_uris)
_MEMBER_GET(data, data, const guint8*, const guint8*)
_MEMBER_GET(length, length, int, gint)
std::string get_data_as_string() const;
std::string get_target() const;
/// See also Gtk::Clipboard::request_targets()
Gdk::ArrayHandle_AtomString get_targets() const;
_IGNORE(gtk_selection_data_get_targets)
/** Returns the ID of the selection.
*/
_MEMBER_GET(selection, selection, GdkAtom, GdkAtom)
/** Returns the type of the data as set by SelectionData::set().
*/
std::string get_data_type() const; // get_type() already exists
_MEMBER_GET(format, format, int, gint)
_MEMBER_GET_GOBJECT(display, display, Gdk::Display, GdkDisplay*)
_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<TextBuffer>& 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