Debian Codegraph @

gtk/src/printjob.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/pagesetup.h>
19 #include <gtkmm/printer.h>
20 #include <gtkmm/printoperation.h>
21 #include <gtkmm/printsettings.h>
22 #include <cairomm/surface.h>
23
24 _DEFS(gtkmm,gtk)
25 _PINCLUDE(glibmm/private/object_p.h)
26
27 namespace Gtk
28 {
29
30 /** A PrintJob object represents a job that is sent to a printer. You only need to deal
31 * directly with print jobs if you use the non-portable PrintUnixDialog API.
32 *
33 * Use get_surface() to obtain the cairo surface onto which the pages must be drawn.
34 * Use send() to send the finished job to the printer.If you don't use cairo then
35 * PrintJob also supports printing of manually generated postscript, via set_source_file().
36 *
37 * @newin{2,10}
38 *
39 * @ingroup Printing
40 */
41 class GTKMM_API PrintJob : public Glib::Object
42 {
43 _CLASS_GOBJECT(PrintJob, GtkPrintJob, GTK_PRINT_JOB, Glib::Object, GObject, , , GTKMM_API)
44 _GTKMMPROC_WIN32_NO_WRAP
45
46 protected:
47 _WRAP_CTOR(PrintJob(const Glib::ustring& title, const Glib::RefPtr<Printer>& printer, const Glib::RefPtr<PrintSettings>& settings, const Glib::RefPtr<PageSetup>& page_setup), gtk_print_job_new)
48
49 public:
50 _WRAP_CREATE(const Glib::ustring& title, const Glib::RefPtr<Printer>& printer, const Glib::RefPtr<PrintSettings>& settings, const Glib::RefPtr<PageSetup>& page_setup)
51
52 _WRAP_METHOD(Glib::RefPtr<PrintSettings> get_settings(), gtk_print_job_get_settings, refreturn)
53 _WRAP_METHOD(Glib::RefPtr<const PrintSettings> get_settings() const, gtk_print_job_get_settings, refreturn, constversion)
54
55 _WRAP_METHOD(Glib::RefPtr<Printer> get_printer(), gtk_print_job_get_printer, refreturn)
56 _WRAP_METHOD(Glib::RefPtr<const Printer> get_printer() const, gtk_print_job_get_printer, refreturn, constversion)
57
58 _WRAP_METHOD(Glib::ustring get_title() const, gtk_print_job_get_title)
59 _WRAP_METHOD(PrintStatus get_status() const, gtk_print_job_get_status)
60 _WRAP_METHOD(void set_source_file(const std::string& filename), gtk_print_job_set_source_file, errthrow)
61
62 #m4 _CONVERSION(`cairo_surface_t*',`Cairo::RefPtr<Cairo::Surface>',`Cairo::RefPtr<Cairo::Surface>(new Cairo::Surface($3, false /* take reference */))')
63 #m4 _CONVERSION(`cairo_surface_t*',`Cairo::RefPtr<const Cairo::Surface>',`Cairo::RefPtr<Cairo::Surface>(new Cairo::Surface($3, false /* take reference */))')
64
65 _WRAP_METHOD(Cairo::RefPtr<Cairo::Surface> get_surface(), gtk_print_job_get_surface, errthrow)
66 _WRAP_METHOD(Cairo::RefPtr<const Cairo::Surface> get_surface() const, gtk_print_job_get_surface, errthrow)
67
68 _WRAP_METHOD(void set_track_print_status(bool track_status = true), gtk_print_job_set_track_print_status)
69 _WRAP_METHOD(bool get_track_print_status() const, gtk_print_job_get_track_print_status)
70
71 /** For example,
72 * void on_print_job_complete(const Glib::RefPtr<PrintJob>& job);
73 *
74 * @throws exception
75 */
76 typedef sigc::slot< void, const Glib::RefPtr<PrintJob>& > SlotPrintJobComplete;
77
78 /** Sends the print job off to the printer.
79 * @param slot A function to call when the job completes or an error occurs.
80 */
81 void send(const SlotPrintJobComplete& slot);
82 _IGNORE(gtk_print_job_send)
83
84 _WRAP_METHOD(PrintPages get_pages() const, gtk_print_job_get_pages)
85 _WRAP_METHOD(void set_pages(PrintPages pages), gtk_print_job_set_pages)
86
87 std::vector<PrintSettings::PageRange> get_page_ranges() const;
88 _IGNORE(gtk_print_job_get_page_ranges)
89
90 void set_page_ranges(const std::vector<PrintSettings::PageRange>& ranges);
91 _IGNORE(gtk_print_job_set_page_ranges)
92
93 _WRAP_METHOD(PageSet get_page_set() const, gtk_print_job_get_page_set)
94 _WRAP_METHOD(void set_page_set(PageSet page_set), gtk_print_job_set_page_set)
95 _WRAP_METHOD(int get_num_copies() const, gtk_print_job_get_num_copies)
96 _WRAP_METHOD(void set_num_copies(int num_copies), gtk_print_job_set_num_copies)
97 _WRAP_METHOD(double get_scale() const, gtk_print_job_get_scale)
98 _WRAP_METHOD(void set_scale(double scale), gtk_print_job_set_scale)
99 _WRAP_METHOD(guint get_n_up() const, gtk_print_job_get_n_up)
100 _WRAP_METHOD(void set_n_up(guint n_up), gtk_print_job_set_n_up)
101 _WRAP_METHOD(NumberUpLayout get_n_up_layout() const, gtk_print_job_get_n_up_layout)
102 _WRAP_METHOD(void set_n_up_layout(NumberUpLayout layout), gtk_print_job_set_n_up_layout)
103 _WRAP_METHOD(bool get_rotate() const, gtk_print_job_get_rotate)
104 _WRAP_METHOD(void set_rotate(bool rotate = true), gtk_print_job_set_rotate)
105 _WRAP_METHOD(bool get_collate() const, gtk_print_job_get_collate)
106 _WRAP_METHOD(void set_collate(bool collate = true), gtk_print_job_set_collate)
107 _WRAP_METHOD(bool get_reverse() const, gtk_print_job_get_reverse)
108 _WRAP_METHOD(void set_reverse(bool reverse = true), gtk_print_job_set_reverse)
109
110 _WRAP_SIGNAL(void status_changed(), "status_changed")
111
112 _WRAP_PROPERTY("title", Glib::ustring)
113 _WRAP_PROPERTY("printer", Glib::RefPtr<Printer>)
114 _WRAP_PROPERTY("settings", Glib::RefPtr<PrintSettings>)
115 _WRAP_PROPERTY("page_setup", Glib::RefPtr<PageSetup>)
116 _WRAP_PROPERTY("track-print-status", bool)
117 };
118
119 } // namespace Gtk