/* Copyright (C) 2019 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 <glibmm/interface.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/interface_p.h)
_PINCLUDE(gdk/gdk.h)

#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C"
{
typedef struct _GtkRootInterface GtkRootInterface;
}
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

namespace Gdk
{
class Display;
class Surface;
}

namespace Gtk
{
class Widget;

/** Root widgets.
 *
 * %Gtk::Root is the interface implemented by all widgets that can act as a toplevel
 * widget to a hierarchy of widgets. The root widget takes care of providing the
 * connection to the windowing system and manages layout, drawing and event delivery
 * for its widget hierarchy.
 *
 * The obvious example of a %Gtk::Root is Gtk::Window.
 *
 * @see Gtk::Window
 * @newin{3,96}
 */
class Root : public Glib::Interface
{
  _CLASS_INTERFACE(Root, GtkRoot, GTK_ROOT, GtkRootInterface)

public:
  _WRAP_METHOD(static Widget* get_for_surface(const Glib::RefPtr<const Gdk::Surface>& surface),
    gtk_root_get_for_surface)

  /** If @a focus is not the current focus widget, and is focusable, sets
   * it as the focus widget for the root.
   *
   * To set the focus to a particular widget in the root, it is usually
   * more convenient to use Gtk::Widget::grab_focus() instead of this function.
   *
   * @param focus Widget to be the new focus widget.
   */
  _WRAP_METHOD(void set_focus(Widget& focus), gtk_root_set_focus)

  /** Unsets the focus widget for the root.
   */
  void unset_focus();

  _WRAP_METHOD(Widget* get_focus(), gtk_root_get_focus)
  _WRAP_METHOD(const Widget* get_focus() const, gtk_root_get_focus, constversion)

  _WRAP_PROPERTY("focus-widget", Widget*)

protected:
#m4 _CONVERSION(`Glib::RefPtr<Gdk::Display>', `GdkDisplay*', __CONVERT_REFPTR_TO_P)
  _WRAP_VFUNC(Glib::RefPtr<Gdk::Display> get_display(), "get_display", refreturn)
  //?_WRAP_VFUNC(GskRenderer* get_renderer(), "get_renderer")
  _WRAP_VFUNC(void get_surface_transform(int& x, int& y), "get_surface_transform")
};

} // namespace Gtk
