blob: 8c8bfeb5d594ac981643adb4a539b8457eb4c44f [file] [log] [blame]
DRC2ff39b82011-07-28 08:38:59 +00001//
2// "$Id: Fl_Printer.cxx 8565 2011-04-06 13:43:09Z manolo $"
3//
4// Encompasses platform-specific printing-support code and
5// PostScript output code for the Fast Light Tool Kit (FLTK).
6//
7// Copyright 2010 by Bill Spitzak and others.
8//
9// This library is free software; you can redistribute it and/or
10// modify it under the terms of the GNU Library General Public
11// License as published by the Free Software Foundation; either
12// version 2 of the License, or (at your option) any later version.
13//
14// This library is distributed in the hope that it will be useful,
15// but WITHOUT ANY WARRANTY; without even the implied warranty of
16// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17// Library General Public License for more details.
18//
19// You should have received a copy of the GNU Library General Public
20// License along with this library; if not, write to the Free Software
21// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
22// USA.
23//
24// Please report all bugs and problems to:
25//
26// http://www.fltk.org/str.php
27//
28
29#include <FL/Fl_Printer.H>
30
31#ifdef __APPLE__
32//#include "Fl_Quartz_Printer.mm"
33#elif defined(WIN32)
34#include "Fl_GDI_Printer.cxx"
35#endif
36
37#include "Fl_PostScript.cxx"
38
39// print dialog customization strings
40/** [this text may be customized at run-time] */
41const char *Fl_Printer::dialog_title = "Print";
42/** [this text may be customized at run-time] */
43const char *Fl_Printer::dialog_printer = "Printer:";
44/** [this text may be customized at run-time] */
45const char *Fl_Printer::dialog_range = "Print Range";
46/** [this text may be customized at run-time] */
47const char *Fl_Printer::dialog_copies = "Copies";
48/** [this text may be customized at run-time] */
49const char *Fl_Printer::dialog_all = "All";
50/** [this text may be customized at run-time] */
51const char *Fl_Printer::dialog_pages = "Pages";
52/** [this text may be customized at run-time] */
53const char *Fl_Printer::dialog_from = "From:";
54/** [this text may be customized at run-time] */
55const char *Fl_Printer::dialog_to = "To:";
56/** [this text may be customized at run-time] */
57const char *Fl_Printer::dialog_properties = "Properties...";
58/** [this text may be customized at run-time] */
59const char *Fl_Printer::dialog_copyNo = "# Copies:";
60/** [this text may be customized at run-time] */
61const char *Fl_Printer::dialog_print_button = "Print";
62/** [this text may be customized at run-time] */
63const char *Fl_Printer::dialog_cancel_button = "Cancel";
64/** [this text may be customized at run-time] */
65const char *Fl_Printer::dialog_print_to_file = "Print To File";
66/** [this text may be customized at run-time] */
67const char *Fl_Printer::property_title = "Printer Properties";
68/** [this text may be customized at run-time] */
69const char *Fl_Printer::property_pagesize = "Page Size:";
70/** [this text may be customized at run-time] */
71const char *Fl_Printer::property_mode = "Output Mode:";
72/** [this text may be customized at run-time] */
73const char *Fl_Printer::property_use = "Use";
74/** [this text may be customized at run-time] */
75const char *Fl_Printer::property_save = "Save";
76/** [this text may be customized at run-time] */
77const char *Fl_Printer::property_cancel = "Cancel";
78
79const char *Fl_Printer::class_id = "Fl_Printer";
80#if defined(__APPLE__) || defined(WIN32) || defined(FL_DOXYGEN)
81const char *Fl_System_Printer::class_id = Fl_Printer::class_id;
82#endif
83#if !( defined(__APPLE__) || defined(WIN32) )
84const char *Fl_PostScript_Printer::class_id = Fl_Printer::class_id;
85#endif
86
87#if defined(__APPLE__) || defined(WIN32)
88void Fl_System_Printer::set_current(void)
89{
90#ifdef __APPLE__
91 fl_gc = (CGContextRef)gc;
92#elif defined(WIN32)
93 fl_gc = (HDC)gc;
94#endif
95 this->Fl_Surface_Device::set_current();
96}
97
98void Fl_System_Printer::origin(int *x, int *y)
99{
100 Fl_Paged_Device::origin(x, y);
101}
102
103#endif
104
105Fl_Printer::Fl_Printer(void) {
106#if defined(WIN32) || defined(__APPLE__)
107 printer = new Fl_System_Printer();
108#else
109 printer = new Fl_PostScript_Printer();
110#endif
111}
112
113int Fl_Printer::start_job(int pagecount, int *frompage, int *topage)
114{
115 return printer->start_job(pagecount, frompage, topage);
116}
117
118int Fl_Printer::start_page(void)
119{
120 return printer->start_page();
121}
122
123int Fl_Printer::printable_rect(int *w, int *h)
124{
125 return printer->printable_rect(w, h);
126}
127
128void Fl_Printer::margins(int *left, int *top, int *right, int *bottom)
129{
130 printer->margins(left, top, right, bottom);
131}
132
133void Fl_Printer::origin(int *x, int *y)
134{
135 printer->origin(x, y);
136}
137
138void Fl_Printer::origin(int x, int y)
139{
140 printer->origin(x, y);
141}
142
143void Fl_Printer::scale(float scale_x, float scale_y)
144{
145 printer->scale(scale_x, scale_y);
146}
147
148void Fl_Printer::rotate(float angle)
149{
150 printer->rotate(angle);
151}
152
153void Fl_Printer::translate(int x, int y)
154{
155 printer->translate(x, y);
156}
157
158void Fl_Printer::untranslate(void)
159{
160 printer->untranslate();
161}
162
163int Fl_Printer::end_page (void)
164{
165 return printer->end_page();
166}
167
168void Fl_Printer::end_job (void)
169{
170 printer->end_job();
171}
172
173void Fl_Printer::print_widget(Fl_Widget* widget, int delta_x, int delta_y)
174{
175 printer->print_widget(widget, delta_x, delta_y);
176}
177
178void Fl_Printer::print_window_part(Fl_Window *win, int x, int y, int w, int h, int delta_x, int delta_y)
179{
180 printer->print_window_part(win, x, y, w, h, delta_x, delta_y);
181}
182
183void Fl_Printer::set_current(void)
184{
185 printer->set_current();
186}
187
188Fl_Graphics_Driver* Fl_Printer::driver(void)
189{
190 return printer->driver();
191}
192
193Fl_Printer::~Fl_Printer(void)
194{
195 delete printer;
196}
197
198
199//
200// End of "$Id: Fl_Printer.cxx 8565 2011-04-06 13:43:09Z manolo $".
201//