/* Copyright (C) 2006 The gtkmm Development Team
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Library General Public
 * License as published by the Free Software Foundation; either
 * version 2 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
 * Library General Public License for more details.
 *
 * You should have received a copy of the GNU Library General Public
 * License along with this library; if not, write to the Free
 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
 */

#include <glibmm/object.h>
#include <gtkmm/enums.h>
#include <gtkmm/papersize.h>

_DEFS(gtkmm,gtk)
_PINCLUDE(glibmm/private/object_p.h)

namespace Gtk
{

/** A PageSetup object stores the page size, orientation and margins. You can get one of these from the page setup dialog 
 * and then pass it to the PrintOperation when printing. The benefit of splitting this out of the PrintSettings is that 
 * these affect the actual layout of the page, and thus need to be set long before the user prints.
 *
 * The margins specified in this object are the "print margins", i.e. the parts of the page that the printer cannot print  
 * on. These are different from the layout margins that a word processor uses; they are typically used to determine the 
 * minimal size for the layout margins.
 *
 * To obtain a PageSetup use PageSetup::create() to get the defaults, or use run_page_setup_dialog() to show the page 
 * setup dialog and receive the resulting page setup. 
 *
 * @newin2p10
 *
 * @ingroup Printing
 */
class PageSetup : public Glib::Object
{
  _CLASS_GOBJECT(PageSetup, GtkPageSetup, GTK_PAGE_SETUP, Glib::Object, GObject)
protected:
  _CTOR_DEFAULT

#if 0 //TODO: Reimplement, or add _construct_from_* functions in GTK+.
GtkPageSetup	  *gtk_page_setup_new_from_file	    (const gchar         *file_name,
						     GError              **error);
GtkPageSetup	  *gtk_page_setup_new_from_key_file (GKeyFile            *key_file,
						     const gchar         *group_name,
						     GError             **error);
#endif

public:
  _WRAP_CREATE()

  _IGNORE(gtk_page_setup_copy)

  _WRAP_METHOD(PageOrientation get_orientation() const, gtk_page_setup_get_orientation)
  _WRAP_METHOD(void set_orientation(PageOrientation orientation), gtk_page_setup_set_orientation)

  _WRAP_METHOD(PaperSize get_paper_size(), gtk_page_setup_get_paper_size)
  _WRAP_METHOD(const PaperSize get_paper_size() const, gtk_page_setup_get_paper_size, constversion)
  _WRAP_METHOD(void set_paper_size(const PaperSize& paper_size), gtk_page_setup_set_paper_size)

  _WRAP_METHOD(double get_top_margin(Unit unit) const, gtk_page_setup_get_top_margin)
  _WRAP_METHOD(void set_top_margin(double margin, Unit unit), gtk_page_setup_set_top_margin)

  _WRAP_METHOD(double get_bottom_margin(Unit unit) const, gtk_page_setup_get_bottom_margin)
  _WRAP_METHOD(void set_bottom_margin(double margin, Unit unit), gtk_page_setup_set_bottom_margin)

  _WRAP_METHOD(double get_left_margin(Unit unit) const, gtk_page_setup_get_left_margin)
  _WRAP_METHOD(void set_left_margin(double margin, Unit unit), gtk_page_setup_set_left_margin)

  _WRAP_METHOD(double get_right_margin(Unit unit) const, gtk_page_setup_get_right_margin)
  _WRAP_METHOD(void set_right_margin(double margin, Unit unit), gtk_page_setup_set_right_margin)

  _WRAP_METHOD(void set_paper_size_and_default_margins(const PaperSize& paper_size),
               gtk_page_setup_set_paper_size_and_default_margins)

  _WRAP_METHOD(double get_paper_width(Unit unit) const, gtk_page_setup_get_paper_width)
  _WRAP_METHOD(double get_paper_height(Unit unit) const, gtk_page_setup_get_paper_height)

  _WRAP_METHOD(double get_page_width(Unit unit) const, gtk_page_setup_get_page_width)
  _WRAP_METHOD(double get_page_height(Unit unit) const, gtk_page_setup_get_page_height)

  //The save_ prefix was added to these functions to make them clearer. GTK+ didn't want to change them.
  _WRAP_METHOD(bool save_to_file(const std::string& file_name) const, gtk_page_setup_to_file, errthrow)

  #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
  _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name), gtk_page_setup_to_key_file)

  /** This function adds the page setup from @a setup to @a key_file,
   * in the group "Page Setup"
   * 
   * @newin2p12
   * @param key_file The G::KeyFile to save the page setup to.
   */
  void save_to_key_file(Glib::KeyFile& key_file);


};

} // namespace Gtk
