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

_DEFS(gdkmm,gdk)

#include <glibmm/refptr.h>
#include <gdkmm/enums.h>
#include <gdkmm/rectangle.h>
#include <gdk/gdk.h> // For GdkPopupLayout.

_CC_INCLUDE(gdk/gdk.h)

namespace Gdk
{
_WRAP_ENUM(AnchorHints, GdkAnchorHints, decl_prefix GDKMM_API)

/** Information for presenting popups.
 *
 * Popups are positioned relative to their parent surface.
 * The %Gdk::PopupLayout class contains information that is
 * necessary to do so.
 *
 * @newin{3,98}
 */
class GDKMM_API PopupLayout final
{
  // GdkPopupLayout is actually registered as a boxed type, but it has custom
  // reference-counting instead of copy/free functions, so we use it via RefPtr.
  _CLASS_OPAQUE_REFCOUNTED(PopupLayout, GdkPopupLayout, NONE, gdk_popup_layout_ref, gdk_popup_layout_unref, GDKMM_API)
  _IGNORE(gdk_popup_layout_ref, gdk_popup_layout_unref)
public:

  _WRAP_METHOD(static Glib::RefPtr<PopupLayout> create(const Rectangle& anchor_rect,
    Gravity rect_anchor, Gravity surface_anchor), gdk_popup_layout_new)
  _WRAP_METHOD(Glib::RefPtr<PopupLayout> copy() const, gdk_popup_layout_copy)
  _WRAP_METHOD(bool equal(const Glib::RefPtr<const PopupLayout>& other) const, gdk_popup_layout_equal)

  _WRAP_METHOD(void set_anchor_rect(const Rectangle& anchor_rect), gdk_popup_layout_set_anchor_rect)
  _WRAP_METHOD(Rectangle get_anchor_rect() const, gdk_popup_layout_get_anchor_rect)
  _WRAP_METHOD(void set_rect_anchor(Gravity anchor), gdk_popup_layout_set_rect_anchor)
  _WRAP_METHOD(Gravity get_rect_anchor() const, gdk_popup_layout_get_rect_anchor)
  _WRAP_METHOD(void set_surface_anchor(Gravity anchor), gdk_popup_layout_set_surface_anchor)
  _WRAP_METHOD(Gravity get_surface_anchor() const, gdk_popup_layout_get_surface_anchor)
  _WRAP_METHOD(void set_anchor_hints(AnchorHints anchor_hints), gdk_popup_layout_set_anchor_hints)
  _WRAP_METHOD(AnchorHints get_anchor_hints() const, gdk_popup_layout_get_anchor_hints)
  _WRAP_METHOD(void set_offset(int dx, int dy), gdk_popup_layout_set_offset)
  _WRAP_METHOD(void get_offset(int& dx, int& dy), gdk_popup_layout_get_offset)
  _WRAP_METHOD(void set_shadow_width(int left, int right, int top, int bottom),
    gdk_popup_layout_set_shadow_width)

  /** Sets the shadow width of the popup.
   *
   * The shadow width corresponds to the part of the computed
   * surface size that would consist of the shadow margin
   * surrounding the window, would there be any.
   *
   * @newin{4,2}
   * @param width Width of all parts of the shadow.
   */
  void set_shadow_width(int width);

  _WRAP_METHOD(void get_shadow_width(int& left, int& right, int& top, int& bottom) const,
    gdk_popup_layout_get_shadow_width)
};

} // namespace Gdk
