Debian Codegraph @

gtk/src/pagesetup.hg

raw
1 /* Copyright (C) 2006 The gtkmm Development Team
2 *
3 * This library is free software; you can redistribute it and/or
4 * modify it under the terms of the GNU Lesser General Public
5 * License as published by the Free Software Foundation; either
6 * version 2.1 of the License, or (at your option) any later version.
7 *
8 * This library is distributed in the hope that it will be useful,
9 * but WITHOUT ANY WARRANTY; without even the implied warranty of
10 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 * Lesser General Public License for more details.
12 *
13 * You should have received a copy of the GNU Lesser General Public
14 * License along with this library; if not, see <https://www.gnu.org/licenses/>.
15 */
16
17 #include <glibmm/object.h>
18 #include <gtkmm/enums.h>
19 #include <gtkmm/papersize.h>
20
21 _DEFS(gtkmm,gtk)
22 _PINCLUDE(glibmm/private/object_p.h)
23
24 namespace Gtk
25 {
26
27 /** A PageSetup object stores the page size, orientation and margins. You can get one of these from the page setup dialog
28 * and then pass it to the PrintOperation when printing. The benefit of splitting this out of the PrintSettings is that
29 * these affect the actual layout of the page, and thus need to be set long before the user prints.
30 *
31 * The margins specified in this object are the "print margins", i.e. the parts of the page that the printer cannot print
32 * on. These are different from the layout margins that a word processor uses; they are typically used to determine the
33 * minimal size for the layout margins.
34 *
35 * To obtain a PageSetup use PageSetup::create() to get the defaults, or use run_page_setup_dialog() to show the page
36 * setup dialog and receive the resulting page setup.
37 *
38 * @newin{2,10}
39 *
40 * @ingroup Printing
41 */
42 class GTKMM_API PageSetup : public Glib::Object
43 {
44 _CLASS_GOBJECT(PageSetup, GtkPageSetup, GTK_PAGE_SETUP, Glib::Object, GObject, , , GTKMM_API)
45 protected:
46 _CTOR_DEFAULT
47
48 public:
49 _WRAP_CREATE()
50
51 /** Reads the page setup from the "Page Setup" group in the key file @a key_file.
52 * Returns a new PageSetup object with the restored
53 * page setup, or an empty RefPtr if an error occurred.
54 *
55 * @param key_file The KeyFile to retrieve the page setup from.
56 * @result The restored PageSetup
57 *
58 * @throws KeyFileError
59 *
60 * @newin{2,14}
61 */
62 static Glib::RefPtr<PageSetup> create_from_key_file(const Glib::KeyFile& key_file);
63
64 /** Reads the page setup from the group @a group_name in the key file @a key_file.
65 * Returns a new PageSetup object with the restored
66 * page setup, or an empty RefPtr if an error occurred.
67 *
68 * @param key_file The KeyFile to retrieve the page setup from.
69 * @param group_name The name of the group in the key_file to read.
70 * @result The restored PageSetup
71 *
72 * @throws KeyFileError
73 *
74 * @newin{2,14}
75 */
76 static Glib::RefPtr<PageSetup> create_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& group_name);
77 _IGNORE(gtk_page_setup_new_from_key_file)
78
79 /** Reads the page setup from the file @a file_name. Returns a
80 * new PageSetup object with the restored page setup,
81 * or an empty RefPtr if an error occurred. See save_to_file().
82 *
83 * @param file_name The filename to read the page setup from.
84 * @result The restored PageSetup
85 *
86 * @newin{2,14}
87 */
88 static Glib::RefPtr<PageSetup> create_from_file(const std::string& file_name);
89 _IGNORE(gtk_page_setup_new_from_file)
90
91 _WRAP_METHOD(Glib::RefPtr<PageSetup> copy() const, gtk_page_setup_copy)
92
93 //The from_ infix was added to these functions to make them clearer. GTK+ didn't want to change them.
94 _WRAP_METHOD(bool load_from_file(const std::string& file_name), gtk_page_setup_load_file, errthrow)
95
96 #m4 _CONVERSION(`const Glib::KeyFile&', `GKeyFile*', __FCR2P)
97 _WRAP_METHOD(bool load_from_key_file(const Glib::KeyFile& key_file, const Glib::ustring& group_name), gtk_page_setup_load_key_file, errthrow)
98
99 /** Reads the page setup from the "Page Setup" group in the key file @a key_file.
100 *
101 * @param key_file The KeyFile to retrieve the page setup from.
102 * @result true on success
103 *
104 * @throws KeyFileError
105 *
106 * @newin{2,14}
107 */
108 bool load_from_key_file(const Glib::KeyFile& key_file);
109
110 _WRAP_METHOD(PageOrientation get_orientation() const, gtk_page_setup_get_orientation)
111 _WRAP_METHOD(void set_orientation(PageOrientation orientation), gtk_page_setup_set_orientation)
112
113 _WRAP_METHOD(PaperSize get_paper_size(), gtk_page_setup_get_paper_size)
114 _WRAP_METHOD(const PaperSize get_paper_size() const, gtk_page_setup_get_paper_size, constversion)
115 _WRAP_METHOD(void set_paper_size(const PaperSize& size), gtk_page_setup_set_paper_size)
116
117 _WRAP_METHOD(double get_top_margin(Unit unit) const, gtk_page_setup_get_top_margin)
118 _WRAP_METHOD(void set_top_margin(double margin, Unit unit), gtk_page_setup_set_top_margin)
119
120 _WRAP_METHOD(double get_bottom_margin(Unit unit) const, gtk_page_setup_get_bottom_margin)
121 _WRAP_METHOD(void set_bottom_margin(double margin, Unit unit), gtk_page_setup_set_bottom_margin)
122
123 _WRAP_METHOD(double get_left_margin(Unit unit) const, gtk_page_setup_get_left_margin)
124 _WRAP_METHOD(void set_left_margin(double margin, Unit unit), gtk_page_setup_set_left_margin)
125
126 _WRAP_METHOD(double get_right_margin(Unit unit) const, gtk_page_setup_get_right_margin)
127 _WRAP_METHOD(void set_right_margin(double margin, Unit unit), gtk_page_setup_set_right_margin)
128
129 _WRAP_METHOD(void set_paper_size_and_default_margins(const PaperSize& size),
130 gtk_page_setup_set_paper_size_and_default_margins)
131
132 _WRAP_METHOD(double get_paper_width(Unit unit) const, gtk_page_setup_get_paper_width)
133 _WRAP_METHOD(double get_paper_height(Unit unit) const, gtk_page_setup_get_paper_height)
134
135 _WRAP_METHOD(double get_page_width(Unit unit) const, gtk_page_setup_get_page_width)
136 _WRAP_METHOD(double get_page_height(Unit unit) const, gtk_page_setup_get_page_height)
137
138 //The save_ prefix was added to these functions to make them clearer. GTK+ didn't want to change them.
139 _WRAP_METHOD(bool save_to_file(const std::string& file_name) const, gtk_page_setup_to_file, errthrow)
140
141 #m4 _CONVERSION(`Glib::KeyFile&', `GKeyFile*', __FR2P)
142 _WRAP_METHOD(void save_to_key_file(Glib::KeyFile& key_file, const Glib::ustring& group_name) const, gtk_page_setup_to_key_file)
143
144 /** This function adds the page setup from @a setup to @a key_file,
145 * in the group "Page Setup"
146 *
147 * @newin{2,12}
148 *
149 * @param key_file The G::KeyFile to save the page setup to.
150 */
151 void save_to_key_file(Glib::KeyFile& key_file) const;
152 };
153
154 } // namespace Gtk