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

_DEFS(gdkmm,gdk)
_CC_INCLUDE(gdk/gdk.h)

#include <glibmm/refptr.h>
#include <glibmm/value.h>

/* Shadow DELETE macro (from winnt.h).
 * It interferes with Gdk::Event::Type::DELETE.
 */
#if defined(DELETE) && !defined(GTKMM_MACRO_SHADOW_DELETE)
enum { GTKMM_MACRO_DEFINITION_DELETE = DELETE };
#undef DELETE
enum { DELETE = GTKMM_MACRO_DEFINITION_DELETE };
#define DELETE DELETE
#define GTKMM_MACRO_SHADOW_DELETE 1
#endif

#ifndef DOXYGEN_SHOULD_SKIP_THIS
extern "C" { typedef union _GdkEvent GdkEvent; }
#endif /* DOXYGEN_SHOULD_SKIP_THIS */

namespace Gdk
{
class Screen;
class Seat;
class Window;

/** Represents an event.
 */
class Event
{
  _CLASS_GDKEVENT(Event, GdkEvent)
  _IGNORE(gdk_event_new, gdk_event_copy, gdk_event_free)
public:

  _WRAP_ENUM(Type, GdkEventType,
    s#^DOUBLE_BUTTON_PRESS$##,
    s#^2BUTTON_PRESS#DOUBLE_BUTTON_PRESS#,
    s#^TRIPLE_BUTTON_PRESS$##,
    s#^3BUTTON_PRESS#TRIPLE_BUTTON_PRESS#
  )

  /** Discover whether the event is valid.
   * For instance,
   * @code
   * if (event)
   *   do_something();
   * @endcode
   *
   * @newin{3,92}
   */
  explicit operator bool() const noexcept;

  _WRAP_METHOD(Event::Type get_event_type() const, gdk_event_get_event_type)

  /**
   * Returns the window which received the event
   */
  _MEMBER_GET_GOBJECT(window, any.window, Gdk::Window, GdkWindow*)
  _IGNORE(gdk_event_get_window)

  /**
   * Returns @c true if the event was sent explicitly (e.g. using @c XSendEvent)
   */
  bool is_send_event() const;

  //_WRAP_METHOD(void	gdk_event_handler_set(GdkEventFunc func, gpointer data, GDestroyNotify  notify), gdk_event_handler_set)

  _WRAP_METHOD(static void set_show_events(bool show_events), gdk_set_show_events)
  _WRAP_METHOD(static bool get_show_events(), gdk_get_show_events)

  _IGNORE(gdk_event_set_screen) //deprecated
  _WRAP_METHOD(Glib::RefPtr<Screen> get_screen(), gdk_event_get_screen, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Screen> get_screen() const, gdk_event_get_screen, refreturn, constversion)

  _WRAP_METHOD(Glib::RefPtr<Seat> get_seat(), gdk_event_get_seat, refreturn, newin "3,90")
  _WRAP_METHOD(Glib::RefPtr<const Seat> get_seat() const, gdk_event_get_seat, refreturn, constversion, newin "3,90")

  _WRAP_METHOD(static Event get(), gdk_event_get)
  _WRAP_METHOD(static Event peek(), gdk_event_peek)
  _WRAP_METHOD(void put(), gdk_event_put)
  _WRAP_METHOD(static bool events_pending(), gdk_events_pending)

  //TODO: If GdkDeviceTool is wrapped in gtkmm, wrap gdk_event_get_device_tool().
  _IGNORE(gdk_event_set_device_tool) // "Should be rarely used"

  // Belong to subclasses:
  _IGNORE(gdk_event_get_time, gdk_event_get_state, gdk_event_get_keyval,
    gdk_event_get_keycode, gdk_event_get_scancode, gdk_event_get_coords,
    gdk_event_get_root_coords, gdk_event_get_button, gdk_event_get_device,
    gdk_event_get_click_count, gdk_event_get_scroll_deltas,
    gdk_event_get_scroll_direction, gdk_event_get_event_sequence,
    gdk_event_get_pointer_emulated, gdk_event_get_axis, gdk_event_triggers_context_menu,
    gdk_event_is_scroll_stop_event, gdk_event_request_motions)
};

} // namespace Gdk
