/* Copyright (C) 2020 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 <http://www.gnu.org/licenses/>.
 */

#include <gtkmm/widget.h>
#include <gtkmm/native.h>
#include <gtkmm/root.h>
#include <gdkmm/drag.h>
#include <gdkmm/paintable.h>
#include <glibmm/value.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(gtkmm/private/widget_p.h)

namespace Gtk
{

/** A toplevel to use as drag icon.
 *
 * %Gtk::DragIcon is a Gtk::Root implementation with the sole purpose
 * to serve as a drag icon during DND operations. A drag icon moves
 * with the pointer during a drag operation and is destroyed when
 * the drag ends.
 *
 * To set up a drag icon and associate it with an ongoing drag operation,
 * use get_for_drag() to get the icon for a drag. You can
 * then use it like any other widget and use set_child() to
 * set whatever widget should be used for the drag icon.
 *
 * Keep in mind that drag icons do not allow user input.
 *
 * @ingroup Widgets
 * @newin{3,98}
 */
class GTKMM_API DragIcon : public Widget, public Native, public Root
{
  _CLASS_GTKOBJECT(DragIcon, GtkDragIcon, GTK_DRAG_ICON, Gtk::Widget, GtkWidget, , , GTKMM_API)
  _IMPLEMENTS_INTERFACE(Native)
  _IMPLEMENTS_INTERFACE(Root)
  _STRUCT_NOT_HIDDEN

public:
  _WRAP_METHOD(static DragIcon* get_for_drag(const Glib::RefPtr<Gdk::Drag>& drag), gtk_drag_icon_get_for_drag)

  _WRAP_METHOD(void set_child(Widget& child), gtk_drag_icon_set_child)
  void unset_child();
  _WRAP_METHOD(Widget* get_child(), gtk_drag_icon_get_child)
  _WRAP_METHOD(const Widget* get_child() const, gtk_drag_icon_get_child, constversion)

  _WRAP_METHOD(static void set_from_paintable(const Glib::RefPtr<Gdk::Drag>& drag,
    const Glib::RefPtr<Gdk::Paintable>& paintable, int hot_x, int hot_y),
    gtk_drag_icon_set_from_paintable)

  _WRAP_METHOD(static Widget* create_widget_for_value(const Glib::ValueBase& value),
    gtk_drag_icon_create_widget_for_value)

  _WRAP_PROPERTY("child", Widget*)
};

} // namespace Gtk
