/*
 * Copyright (C) 2013 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 <gtkmm/bin.h>
#include <cairomm/types.h>

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

namespace Gtk
{

/** Context dependent bubbles.
 *
 * Gtk::Popover is a bubble-like context window, primarily meant to
 * provide context-dependent information or options. Popovers are
 * attached to a widget, passed at construction time on Gtk::Popover(),
 * or updated afterwards through Gtk::Popover::set_relative_to(), by
 * default they will point to the whole widget area, although this
 * behavior can be changed through Gtk::Popover::set_pointing_to().
 *
 * The position of a popover relative to the widget it is attached to
 * can also be changed through Gtk::Popover::set_position().
 *
 * By default, Gtk::Popover performs a GTK+ grab, in order to ensure
 * input events get redirected to it while it is shown, and also so
 * the popover is dismissed in the expected situations (clicks outside
 * the popover, or the Esc key being pressed). If no such modal behavior
 * is desired on a popover, Gtk::Popover::set_modal() may be called on it
 * to tweak its behavior.
 *
 * @ingroup Widgets
 * @newin{3,12}
 */
class Popover
  : public Bin
{
  _CLASS_GTKOBJECT(Popover, GtkPopover, GTK_POPOVER, Gtk::Bin, GtkBin)
public:

  /** Creates a new popover to point to @a relative_to
   *
   * @param relative_to The Gtk::Widget the popover is related to
   */
  _WRAP_CTOR(Popover(const Widget& relative_to), gtk_popover_new)


  _WRAP_METHOD(void set_relative_to(const Widget& relative_to), gtk_popover_set_relative_to)
  // transfer none
  _WRAP_METHOD(Widget* get_relative_to(), gtk_popover_get_relative_to)
  _WRAP_METHOD(const Widget* get_relative_to() const, gtk_popover_get_relative_to, constversion)

#m4 _CONVERSION(`const Cairo::RectangleInt&',`cairo_rectangle_int_t*', `const_cast<cairo_rectangle_int_t*>(&($3))')
  //This cannot take NULL to mean unset.
  _WRAP_METHOD(void set_pointing_to(const Cairo::RectangleInt& rect), gtk_popover_set_pointing_to)

#m4 _CONVERSION(`Cairo::RectangleInt&',`cairo_rectangle_int_t*', `&($3)')
  _WRAP_METHOD(bool get_pointing_to(Cairo::RectangleInt& rect) const, gtk_popover_get_pointing_to)

  _WRAP_METHOD(void set_position(PositionType position = POS_TOP), gtk_popover_set_position)
  _WRAP_METHOD(PositionType get_position() const, gtk_popover_get_position)

  _WRAP_METHOD(void set_modal(bool modal = true), gtk_popover_set_modal)
  _WRAP_METHOD(bool get_modal() const, gtk_popover_get_modal)


  _WRAP_PROPERTY("relative-to", Widget*)
// TODO
//  _WRAP_PROPERTY("pointing-to", Cairo::RectangleInt)
  _WRAP_PROPERTY("position", PositionType)
  _WRAP_PROPERTY("modal", bool)

  // Gtk::Popover has no signals nor vfuncs as of 3.12.
};

} // namespace Gtk
