/*
 * Copyright (C) 1998-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, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */

#include <gdkmm/display.h>
#include <gdkmm/pixbuf.h>

_DEFS(gdkmm,gdk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gdk
{

/** This represents a cursor.
 */
class Cursor : public Glib::Object
{
  _CLASS_GOBJECT(Cursor, GdkCursor, GDK_CURSOR, Glib::Object, GObject)
  _DO_NOT_DERIVE_GTYPE //We use DO_NOT_DERIVE_GTYPE because glib does not allow us to derive from a non-fundamental (abstract) type, for some reason.

protected:

  explicit Cursor(const Glib::RefPtr<Display>& display, const Glib::ustring& name);
  _IGNORE(gdk_cursor_new_from_name)

public:
  _WRAP_ENUM(Type, GdkCursorType)

  //We use _WRAP_METHOD() instead of _WRAP_CREATE() and constructors,
  //because the gdk_cursor_new_*() functions actually return existing instances sometimes,
  //but constructors assume that they own the instance.
  //And we would have to have to use the gdk_cursor_new_*() functions in the constructors anyway,
  //because they do more than just call g_object_new().
  _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, Type cursor_type), gdk_cursor_new_for_display)
  _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, const Glib::RefPtr<Pixbuf>& pixbuf, int x, int y), gdk_cursor_new_from_pixbuf)

#m4 _CONVERSION(`const ::Cairo::RefPtr< ::Cairo::Surface>&',`cairo_surface_t*',`($3) ? const_cast<cairo_surface_t*>(($3)->cobj()) : nullptr')
  _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, const ::Cairo::RefPtr< ::Cairo::Surface>& surface, double x, double y), gdk_cursor_new_from_surface)

  _WRAP_METHOD(static Glib::RefPtr<Cursor> create(const Glib::RefPtr<Display>& display, const Glib::ustring& name), gdk_cursor_new_from_name)

  _WRAP_METHOD(Glib::RefPtr<Display> get_display(), gdk_cursor_get_display, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Display> get_display() const, gdk_cursor_get_display, refreturn, constversion)

  _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_image(), gdk_cursor_get_image)
  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_image() const, gdk_cursor_get_image, constversion)

  //TODO: Should this always be const?
#m4 _CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr< ::Cairo::Surface>',`::Cairo::make_refptr_for_instance< ::Cairo::Surface>(new ::Cairo::Surface($3, true /* take reference */))')
#m4 _CONVERSION(`cairo_surface_t*',`::Cairo::RefPtr<const ::Cairo::Surface>',`::Cairo::make_refptr_for_instance< ::Cairo::Surface>(new ::Cairo::Surface($3, true /* take reference */))')
  _WRAP_METHOD(::Cairo::RefPtr< ::Cairo::Surface> get_surface(double& x_hot, double& y_hot), gdk_cursor_get_surface)
  _WRAP_METHOD(::Cairo::RefPtr<const ::Cairo::Surface> get_surface(double& x_hot, double& y_hot) const, gdk_cursor_get_surface, constversion)

  _WRAP_METHOD(Type get_cursor_type() const, gdk_cursor_get_cursor_type)
};

} //namespace Gdk
