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

#include <gdkmm/screen.h>
#include <gdkmm/applaunchcontext.h>
#include <gdkmm/types.h> //For ModifierType
_DEFS(gdkmm,gdk)
_PINCLUDE(glibmm/private/object_p.h)

#m4 _PUSH(SECTION_CC_PRE_INCLUDES)
#undef GDK_DISABLE_DEPRECATED
#define GDK_DISABLE_DEPRECATION_WARNINGS 1
#m4 _POP()

namespace Gdk
{

_CC_INCLUDE(gdk/gdk.h)

class DeviceManager;

 /** Gdk::Display object's purpose is two fold:
 *   To grab/ungrab keyboard focus and mouse pointer
 *   To manage and provide information about the Gdk::Screen(s) available for this Gdk::Display
 *
 * Gdk::Display objects are the GDK representation of the X Display which can be described as a workstation consisting
 * of a keyboard a pointing device (such as a mouse) and one or more screens. It is used to open and keep track of
 * various Gdk::Screen objects currently instantiated by the application. It is also used to grab and release the keyboard
 * and the mouse pointer.
 */
class Display : public Glib::Object
{
  _CLASS_GOBJECT(Display,GdkDisplay,GDK_DISPLAY,Glib::Object,GObject)
protected:
  _CTOR_DEFAULT

public:
  _WRAP_METHOD(static Glib::RefPtr<Display> open(const Glib::ustring& display_name), gdk_display_open, refreturn)

  _WRAP_METHOD(Glib::ustring get_name() const, gdk_display_get_name)

  _WRAP_METHOD(int get_n_screens() const, gdk_display_get_n_screens, deprecated "The number of screens is always 1.")
  _WRAP_METHOD(Glib::RefPtr<Screen> get_screen(int screen_num = 0), gdk_display_get_screen, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Screen> get_screen(int screen_num = 0) const, gdk_display_get_screen, refreturn, constversion)

  _WRAP_METHOD(Glib::RefPtr<Screen> get_default_screen(), gdk_display_get_default_screen, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Screen> get_default_screen() const, gdk_display_get_default_screen, refreturn, constversion)

  _IGNORE(gdk_display_pointer_ungrab, gdk_display_keyboard_ungrab,
    gdk_display_pointer_is_grabbed, gdk_display_device_is_grabbed) //deprecated

  _WRAP_METHOD(void beep(), gdk_display_beep)
  _WRAP_METHOD(void sync(), gdk_display_sync)
  _WRAP_METHOD(void	close(), gdk_display_close)
  _WRAP_METHOD(bool is_closed() const, gdk_display_is_closed)


  _IGNORE(gdk_display_list_devices) //deprecated

  //TODO: Use C++ Gdk::Event:
  //TODO: get_event() might remove the event - if so, then there should not be a const version:
  _WRAP_METHOD(GdkEvent* get_event(), gdk_display_get_event)
  _WRAP_METHOD(const GdkEvent* get_event() const, gdk_display_get_event, constversion)

  _WRAP_METHOD(GdkEvent* peek_event(), gdk_display_peek_event)
  _WRAP_METHOD(GdkEvent* peek_event() const, gdk_display_peek_event, constversion)
  _WRAP_METHOD(void put_event(GdkEvent* event), gdk_display_put_event)
  _WRAP_METHOD(bool has_pending() const, gdk_display_has_pending)

  _WRAP_METHOD(void set_double_click_time(guint msec), gdk_display_set_double_click_time, deprecated "No replacement method. Applications should not set this.")
  _WRAP_METHOD(void set_double_click_distance(guint distance), gdk_display_set_double_click_distance, deprecated "No replacement method. Applications should not set this.")

  _WRAP_METHOD(static Glib::RefPtr<Display> get_default(), gdk_display_get_default, refreturn)


  _IGNORE(gdk_display_get_pointer, gdk_display_get_core_pointer,
    gdk_display_get_window_at_pointer, gdk_display_warp_pointer) //deprecated

  _WRAP_METHOD(static Glib::RefPtr<Display> open_default_libgtk_only(), gdk_display_open_default_libgtk_only, refreturn)

  _WRAP_METHOD(GdkKeymap* get_keymap(), gdk_keymap_get_for_display)
  _WRAP_METHOD(const GdkKeymap* get_keymap() const, gdk_keymap_get_for_display, constversion)

  bool set_selection_owner(const Glib::RefPtr<Window>& owner, Glib::ustring& selection, guint32 time_, bool send_event);
  Glib::RefPtr<Window> get_selection_owner(const Glib::ustring& selection);

  /** Send a response to SelectionRequest event.
   *
   * @newin{2,2}
   * @param requestor Window to which to deliver response.
   * @param selection Selection that was requested.
   * @param target Target that was selected.
   * @param property Property in which the selection owner stored the data,
   * or "None" to indicate that the request was rejected.
   * @param time_ Timestamp.
   */
  void selection_send_notify(const Glib::RefPtr<Window>& requestor, Glib::ustring& selection, Glib::ustring& target, Glib::ustring& property, guint32 time_);

  _WRAP_METHOD(void flush(), gdk_display_flush)
  _WRAP_METHOD(bool supports_cursor_alpha() const, gdk_display_supports_cursor_alpha)
  _WRAP_METHOD(bool supports_cursor_color() const, gdk_display_supports_cursor_color)
  _WRAP_METHOD(guint get_default_cursor_size() const, gdk_display_get_default_cursor_size)
  _WRAP_METHOD(void get_maximal_cursor_size(guint& width, guint& height), gdk_display_get_maximal_cursor_size)

  _WRAP_METHOD(Glib::RefPtr<Window> get_default_group(), gdk_display_get_default_group, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Window> get_default_group() const, gdk_display_get_default_group, refreturn, constversion)

  _WRAP_METHOD(bool supports_selection_notification() const, gdk_display_supports_selection_notification)
  _WRAP_METHOD(bool request_selection_notification(const Glib::ustring& selection), gdk_display_request_selection_notification)

  _WRAP_METHOD(bool supports_clipboard_persistence() const, gdk_display_supports_clipboard_persistence)

  /** Issues a request to the clipboard manager to store the clipboard data,
   * saving all available targets.
   * On X11, this is a special program that works according to the freedesktop clipboard specification,
   * available at http://www.freedesktop.org/Standards/clipboard-manager-spec.
   * @newin{2,6}
   *
   * @param clipboard_window A Gdk::Window belonging to the clipboard owner.
   * @param time_ A timestamp.
   */
  void store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_);

  void store_clipboard(const Glib::RefPtr<Gdk::Window>& clipboard_window, guint32 time_, const std::vector<Glib::ustring>& targets);
  _IGNORE(gdk_display_store_clipboard)

  _WRAP_METHOD(bool supports_shapes() const, gdk_display_supports_shapes)
  _WRAP_METHOD(bool supports_input_shapes() const, gdk_display_supports_input_shapes)
  _WRAP_METHOD(bool supports_composite() const, gdk_display_supports_composite)
  _WRAP_METHOD(void notify_startup_complete(const Glib::ustring& startup_id), gdk_display_notify_startup_complete)

  _WRAP_METHOD(Glib::RefPtr<DeviceManager> get_device_manager(), gdk_display_get_device_manager, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const DeviceManager> get_device_manager() const, gdk_display_get_device_manager, refreturn, constversion)

#m4 _CONVERSION(`GdkAppLaunchContext*',`Glib::RefPtr<AppLaunchContext>', `Glib::wrap($3)')
#m4 _CONVERSION(`GdkAppLaunchContext*',`Glib::RefPtr<const AppLaunchContext>', `Glib::wrap($3)')
  _WRAP_METHOD(Glib::RefPtr<AppLaunchContext> get_app_launch_context(), gdk_display_get_app_launch_context, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const AppLaunchContext> get_app_launch_context() const, gdk_display_get_app_launch_context, refreturn, constversion)


  //We use no_default_handler because GdkDisplayClass is private.

  _WRAP_SIGNAL(void closed(bool is_error), closed, no_default_handler)
  _WRAP_SIGNAL(void opened(), opened, no_default_handler)

  // There are no properties.
  // We don't wrap the vfuncs because GdkDisplayClass is private.
};

} // namespace Gdk
