// -*- c++ -*-
// Generated by gtkmmproc -- DO NOT MODIFY!
#ifndef _GTKMM_SELECTIONDATA_H
#define _GTKMM_SELECTIONDATA_H

#include <glibmm.h>

/* $Id: selectiondata.hg,v 1.8 2002/12/29 23:08:50 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.
 */


#include <gdkmm/display.h>


#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef struct _GtkSelectionData GtkSelectionData; }
#endif

namespace Gtk
{

class SelectionData
{
  public:
#ifndef DOXYGEN_SHOULD_SKIP_THIS
  typedef SelectionData CppObjectType;
  typedef GtkSelectionData BaseObjectType;

  static GType get_type() G_GNUC_CONST;
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

  SelectionData();

  explicit SelectionData(GtkSelectionData* gobject, bool make_a_copy = true);

  SelectionData(const SelectionData& other);
  SelectionData& operator=(const SelectionData& other);

  ~SelectionData();

  void swap(SelectionData& other);

  ///Provides access to the underlying C instance.
  GtkSelectionData*       gobj()       { return gobject_; }

  ///Provides access to the underlying C instance.
  const GtkSelectionData* gobj() const { return gobject_; }

  // The caller is responsible for freeing it. Use when directly setting fields in structs.
  GtkSelectionData* gobj_copy() const;

protected:
  GtkSelectionData* gobject_;

private:

  
public:

  /** 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);
  

  /** 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);
  

  /** 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;
  

  const guint8* get_data() const;
  int get_length() const;

  std::string get_data_as_string() const;

  std::string get_target() const;

  /// See Gtk::Clipboard::request_targets()
  Gdk::ArrayHandle_AtomString get_targets() const;
  

  /** Returns the ID of the selection.
   */
  GdkAtom get_selection() const;

  /** Returns the type of the data as set by SelectionData::set().
   */
  std::string get_data_type() const; // get_type() already exists

  int get_format() const;
  Glib::RefPtr<Gdk::Display> get_display();
  Glib::RefPtr<const Gdk::Display> get_display() const;

  
  /** Given a Gtk::SelectionData object holding a list of targets,
   * determines if any of the targets in @a targets  can be used to
   * provide text.
   * @return <tt>true</tt> if @a selection_data  holds a list of targets,
   * and a suitable target for text is included, otherwise <tt>false</tt>.
   */
  bool targets_include_text() const;


};

} // namespace Gtk


namespace Gtk
{

/** @relates Gtk::SelectionData */
inline void swap(SelectionData& lhs, SelectionData& rhs)
  { lhs.swap(rhs); }

} // namespace Gtk

namespace Glib
{

/** @relates Gtk::SelectionData */
Gtk::SelectionData wrap(GtkSelectionData* object, bool take_copy = false);

#ifndef DOXYGEN_SHOULD_SKIP_THIS
template <>
class Value<Gtk::SelectionData> : public Glib::Value_Boxed<Gtk::SelectionData>
{};
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

} // namespace Glib

#endif /* _GTKMM_SELECTIONDATA_H */

