/*
 * Copyright (C) 2010 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
 */

_CONFIGINCLUDE(gtkmmconfig.h)

#include <gtkmm/window.h>

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

namespace Gtk
{

/** A top-level container widget used to manage offscreen rendering of child widgets.
 * OffscreenWindow is strictly intended to be used for obtaining
 * snapshots of widgets that are not part of a normal widget hierarchy.
 * It differs from Gtk::Widget::get_snapshot() in that the widget you
 * want to get a snapshot of need not be displayed on the user's screen
 * as a part of a widget hierarchy.  However, since OffscreenWindow
 * is a top-level widget you cannot obtain snapshots of a full window
 * with it since you cannot pack a toplevel widget in another toplevel.
 *
 * The idea is to take a widget and manually set the state of it,
 * add it to an OffscreenWindow and then retrieve the snapshot
 * as a Gdk::Pixbuf.
 *
 * OffscreenWindow derives from Window only as an implementation
 * detail.  Applications should not use any API specific to #GtkWindow
 * to operate on this object.  It should be treated as a Bin that
 * has no parent widget.
 *
 * When contained offscreen widgets are redrawn, OffscreenWindow
 * will emit a "damage-event" signal.
 *
 * @newin{2,20}
 * @ingroup Containers
 * @ingroup Widgets
 */
class OffscreenWindow : public Window
{
  _CLASS_GTKOBJECT(OffscreenWindow, GtkOffscreenWindow, GTK_OFFSCREEN_WINDOW, Gtk::Window, GtkWindow)
  _UNMANAGEABLE
public:
  _CTOR_DEFAULT()

  //TODO: Should this always be const?
#m4 _CONVERSION(`cairo_surface_t*',`Cairo::RefPtr<Cairo::Surface>',`Cairo::RefPtr<Cairo::Surface>(new Cairo::Surface($3, true /* take reference */))')
#m4 _CONVERSION(`cairo_surface_t*',`Cairo::RefPtr<const Cairo::Surface>',`Cairo::RefPtr<Cairo::Surface>(new Cairo::Surface($3, true /* take reference */))')
  _WRAP_METHOD(Cairo::RefPtr<Cairo::Surface> get_surface(), gtk_offscreen_window_get_surface)
  _WRAP_METHOD(Cairo::RefPtr<const Cairo::Surface> get_surface() const, gtk_offscreen_window_get_surface)


  _WRAP_METHOD(Glib::RefPtr<Gdk::Pixbuf> get_pixbuf(), gtk_offscreen_window_get_pixbuf)
  _WRAP_METHOD(Glib::RefPtr<const Gdk::Pixbuf> get_pixbuf() const, gtk_offscreen_window_get_pixbuf)
};

} // namespace Gtk
