summaryrefslogtreecommitdiff
path: root/libs/gtkmm2/gtk/src/papersize.hg
diff options
context:
space:
mode:
Diffstat (limited to 'libs/gtkmm2/gtk/src/papersize.hg')
-rw-r--r--libs/gtkmm2/gtk/src/papersize.hg108
1 files changed, 108 insertions, 0 deletions
diff --git a/libs/gtkmm2/gtk/src/papersize.hg b/libs/gtkmm2/gtk/src/papersize.hg
new file mode 100644
index 0000000000..3c421b3feb
--- /dev/null
+++ b/libs/gtkmm2/gtk/src/papersize.hg
@@ -0,0 +1,108 @@
+/* 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.
+ */
+
+_DEFS(gtkmm,gtk)
+
+namespace Gtk
+{
+
+/** Common paper names, from PWG 5101.1-2002 PWG: Standard for Media Standardized Names
+ *
+ */
+const Glib::ustring PAPER_NAME_A3 = "iso_a3";
+const Glib::ustring PAPER_NAME_A4 = "iso_a4";
+const Glib::ustring PAPER_NAME_A5 = "iso_a5";
+const Glib::ustring PAPER_NAME_B5 = "iso_b5";
+const Glib::ustring PAPER_NAME_LETTER = "na_letter";
+const Glib::ustring PAPER_NAME_EXECUTIVE = "na_executive";
+const Glib::ustring PAPER_NAME_LEGAL = "na_legal";
+
+_WRAP_ENUM(Unit, GtkUnit)
+
+/** PaperSize handles paper sizes. It uses the standard called "PWG 5101.1-2002 PWG: Standard for Media Standardized Names"
+ * to name the paper sizes (and to get the data for the page sizes). In addition to standard paper sizes, PaperSize allows
+ * to construct custom paper sizes with arbitrary dimensions.
+ *
+ * The PaperSize object stores not only the dimensions (width and height) of a paper size and its name, it also provides
+ * default print margins.
+ *
+ * @newin2p10
+ *
+ * @ingroup Printing
+ */
+class PaperSize
+{
+ // Cannot pass the _new function here, it must accept the 'name' argument.
+ _CLASS_BOXEDTYPE(PaperSize, GtkPaperSize, NONE, gtk_paper_size_copy, gtk_paper_size_free)
+public:
+ // Allowing no argument works because gtk_paper_size_new() will call
+ // gtk_paper_size_get_default() in case of NULL.
+ /// If a name is not specified, a default value will be used.
+ explicit PaperSize(const Glib::ustring& name = "");
+ explicit PaperSize(const Glib::ustring& ppd_name, const Glib::ustring& ppd_display_name, double width, double height);
+ explicit PaperSize(const Glib::ustring& name, const Glib::ustring& display_name, double width, double height, Unit unit);
+
+ explicit PaperSize(const Glib::KeyFile& key_file, const Glib::ustring& group_name = Glib::ustring());
+
+ _IGNORE(gtk_paper_size_copy, gtk_paper_size_free, gtk_paper_size_is_equal)
+ bool equal(const PaperSize& other) const;
+
+ /** Returns true if the PaperSize is a valid object.
+ * @newin2p12
+ */
+ operator bool() const;
+
+ //TODO: Check this conversion and type:
+ #m4 _CONVERSION(`GList*', `Glib::ListHandle<PaperSize>', `$2($3, Glib::OWNERSHIP_DEEP)')
+ //TODO: _WRAP_METHOD(static Glib::ListHandle<PaperSize> get_paper_sizes(bool include_custom = true) const, gtk_paper_size_get_paper_sizes)
+
+ _WRAP_METHOD(Glib::ustring get_name() const, gtk_paper_size_get_name)
+ _WRAP_METHOD(Glib::ustring get_display_name() const, gtk_paper_size_get_display_name)
+ _WRAP_METHOD(Glib::ustring get_ppd_name() const, gtk_paper_size_get_ppd_name)
+
+ _WRAP_METHOD(double get_width(Unit unit) const, gtk_paper_size_get_width)
+ _WRAP_METHOD(double get_height(Unit unit) const, gtk_paper_size_get_height)
+ _WRAP_METHOD(bool is_custom() const, gtk_paper_size_is_custom)
+
+ _WRAP_METHOD(void set_size(double width, double height, Unit unit), gtk_paper_size_set_size)
+ _WRAP_METHOD(double get_default_top_margin(Unit unit) const, gtk_paper_size_get_default_top_margin)
+ _WRAP_METHOD(double get_default_bottom_margin(Unit unit) const, gtk_paper_size_get_default_bottom_margin)
+ _WRAP_METHOD(double get_default_left_margin(Unit unit) const, gtk_paper_size_get_default_left_margin)
+ _WRAP_METHOD(double get_default_right_margin(Unit unit) const, gtk_paper_size_get_default_right_margin)
+
+ _WRAP_METHOD(static Glib::ustring get_default(), gtk_paper_size_get_default)
+
+ #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
+ _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name), gtk_paper_size_to_key_file)
+
+ /** This function adds the paper size to @a key_file in the first group.
+ *
+ * @newin2p12
+ * @param key_file The Glib::KeyFile to save the paper size to.
+ */
+ void save_to_key_file(Glib::KeyFile& key_file);
+};
+
+/** @relates Gtk::PaperSize */
+inline bool operator==(const PaperSize& lhs, const PaperSize& rhs)
+ { return lhs.equal(rhs); }
+
+/** @relates Gtk::PaperSize */
+inline bool operator!=(const PaperSize& lhs, const PaperSize& rhs)
+ { return !lhs.equal(rhs); }
+
+} // namespace Gtk