/*
 * 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 <gdkmm/rectangle.h>
#include <glibmm/object.h>
#include <cairomm/fontoptions.h>

_DEFS(gdkmm,gdk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gdk
{

class Display;
class Visual;
class Window;

/** Object representing a physical screen
 * Gdk::Screen objects are the GDK representation of a physical screen. It is used throughout GDK and GTK+ to specify
 * which screen the top level windows are to be displayed on. It is also used to query the screen specification and
 * default settings such as the screen width (get_width()), etc.
 * Note that a screen may consist of multiple monitors which are merged to form a large screen area.
 */
class Screen : public Glib::Object
{
  _CLASS_GOBJECT(Screen,GdkScreen,GDK_SCREEN,Glib::Object,GObject)
protected:

public:
  _WRAP_METHOD(Glib::RefPtr<Window> get_root_window(), gdk_screen_get_root_window, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Window> get_root_window() const, gdk_screen_get_root_window, refreturn, constversion)

  _WRAP_METHOD(Glib::RefPtr<Display> get_display(), gdk_screen_get_display, refreturn)
  _WRAP_METHOD(Glib::RefPtr<const Display> get_display() const, gdk_screen_get_display, refreturn, constversion)

#m4 _CONVERSION(`GList*',`std::vector< Glib::RefPtr<Window> >',`Glib::ListHandler< Glib::RefPtr<Window> >::list_to_vector($3, Glib::OWNERSHIP_SHALLOW)')
  _WRAP_METHOD(std::vector< Glib::RefPtr<Window> > get_toplevel_windows(), gdk_screen_get_toplevel_windows)

  _WRAP_METHOD(static Glib::RefPtr<Screen> get_default(), gdk_screen_get_default, refreturn)

  template <class ValueType>
  bool get_setting(const Glib::ustring& name, ValueType& value) const;
  _IGNORE(gdk_screen_get_setting)

  _WRAP_METHOD(void set_resolution(double dpi), gdk_screen_set_resolution)
  _WRAP_METHOD(double get_resolution() const, gdk_screen_get_resolution)

  //We use no_default_handler because GdkDisplayManagerClass is private.

  _WRAP_SIGNAL(void monitors_changed(), monitors-changed, no_default_handler)

  _WRAP_PROPERTY("resolution", double)
};

template <class ValueType>
bool Screen::get_setting(const Glib::ustring& name, ValueType& value) const
{
  Glib::Value<ValueType> glibmmvalue;
  glibmmvalue.init(Glib::Value<ValueType>::value_type());

  gboolean result = gdk_screen_get_setting(const_cast<GdkScreen*>(gobj()), name.c_str(), glibmmvalue.gobj());

  value = glibmmvalue.get();
  return result;
}

} // namespace Gdk
