1 //
2 // "$Id: Fl_GDI_Printer.cxx,v 1.1 2004/11/24 20:31:46 cursorstar Exp $"
3 //
4 // WIN32 GDI printing device for the Fast Light Tool Kit (FLTK).
5 //
6 // Copyright (c) 2002 O'ksi'D
7 //
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 3 of the License, or (at your option) any later version.
12 //
13 // This library is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this library. If not, see <http://www.gnu.org/licenses/>.
20 //
21 // Please report all bugs and problems to "oksid@bluewin.ch".
22 //
23 #include <stdlib.h>
24 #include <math.h>
25 #include <FL/Fl.H>
26 #include <windows.h>
27 #include <wingdi.h>
28 #include <FL/math.h>
29
30 #include <FL/Fl_GDI_Printer.H>
31 //#include <commdlg.h>
32 #include <FL/x.H>
33 #include <FL/fl_draw.H>
34
35 //#include <FL/Fl_Group.H>
36
37
38
39 extern FL_EXPORT void set_xmaps(HPEN tmppen_, HBRUSH tmpbrush_, HPEN savepen_, Fl_Brush *brushes_, Fl_XMap * fl_xmap_, Fl_XMap xmap_);
40 extern FL_EXPORT void pop_xmaps();
41 extern FL_EXPORT void push_xmaps();
42
43
~Fl_GDI_Printer()44 Fl_GDI_Printer::~Fl_GDI_Printer(){
45
46
47 if(nPages)
48 EndPage(gc_);
49 EndDoc(gc_);
50
51 // cleaning pens&brushes...
52 if(xmap.pen)
53 DeleteObject((HGDIOBJ)(xmap.pen));
54 int i;
55 for(i=0; i<256; i++)
56 if(fl_xmap[i].pen)
57 DeleteObject((HGDIOBJ)(fl_xmap[i].pen));
58
59 for(i=0; i<FL_N_BRUSH; i++)
60 if(brushes[i].brush)
61 DeleteObject(brushes[i].brush);
62 //end clean
63
64 DeleteDC(gc_);
65 if(!GlobalUnlock(mode_))
66 GlobalFree(mode_);
67 }
68
69
70 extern HDC fl_gc_save;
71
set_current()72 Fl_Output_Device * Fl_GDI_Printer::set_current(){
73 if(fl == this) return this;
74 Fl_Output_Device * c = fl;
75 if(fl == &fltk){
76 fl_gc_save = fl_gc;
77 Fl::flush();
78 push_xmaps();
79 }
80 set_xmaps(tmppen, tmpbrush, savepen, brushes, fl_xmap, xmap);
81 fl = this;
82 fl_gc = gc_;
83 fl_clip_region(0);
84 return c;
85 }
86
87
88
89
draw(Fl_Widget * w)90 void Fl_GDI_Printer::draw(Fl_Widget * w){
91 Fl_Output_Device * cd =fl;
92 set_current();
93
94 w->redraw(); // making dirty
95
96 w->draw();
97
98 Fl_Output_Device::current(cd);
99 }
100
101
102
103
104
105 ////////////// gets the paper size from DEVMODE /////////////////////
106
gdipaper(DEVMODE * mod)107 static int gdipaper(DEVMODE *mod){
108 if(!(mod->dmFields & DM_PAPERSIZE)) return 0;
109
110 int paper;
111 switch (mod->dmPaperSize){
112 case DMPAPER_A3:
113 paper = Fl_Printer::A3; break;
114 case DMPAPER_A4:
115 paper = Fl_Printer::A4; break;
116 case DMPAPER_A5:
117 paper = Fl_Printer::A5; break;
118 //case DMPAPER_A6: paper = FL_A6; break;
119 case DMPAPER_B4:
120 paper = Fl_Printer::B4; break;
121 case DMPAPER_B5: paper = Fl_Printer::B5; break;
122 //case DMPAPER_B6: paper = FL_B6; break;
123 case DMPAPER_EXECUTIVE:
124 paper = Fl_Printer::EXECUTIVE; break;
125 case DMPAPER_FOLIO:
126 paper = Fl_Printer::FOLIO; break;
127 case DMPAPER_LEDGER:
128 paper = Fl_Printer::LEDGER; break;
129 case DMPAPER_LEGAL:
130 paper = Fl_Printer::LEGAL; break;
131 case DMPAPER_LETTER:
132 paper = Fl_Printer::LETTER; break;
133 case DMPAPER_TABLOID:
134 paper = Fl_Printer::TABLOID; break;
135 case DMPAPER_ENV_10:
136 paper = Fl_Printer::ENVELOPE; break;
137 default:
138 paper = -1;
139 }
140 return paper;
141 }
142
143 ////////////// sets the paper size in DEVMODE /////////////////////
144
gdipaper(DEVMODE * mode,int format)145 static int gdipaper(DEVMODE *mode, int format){
146 switch(format){
147 case Fl_Printer::A3: mode->dmPaperSize = DMPAPER_A3; break;
148 case Fl_Printer::A4: mode->dmPaperSize = DMPAPER_A4; break;
149 case Fl_Printer::A5: mode->dmPaperSize = DMPAPER_A5; break;
150
151 case Fl_Printer::B4: mode->dmPaperSize = DMPAPER_B4; break;
152 case Fl_Printer::B5: mode->dmPaperSize = DMPAPER_B5; break;
153
154 case Fl_Printer::EXECUTIVE: mode->dmPaperSize = DMPAPER_EXECUTIVE; break;
155 case Fl_Printer::FOLIO: mode->dmPaperSize = DMPAPER_FOLIO; break;
156 case Fl_Printer::LEDGER: mode->dmPaperSize = DMPAPER_LEDGER; break;
157 case Fl_Printer::LEGAL: mode->dmPaperSize = DMPAPER_LEGAL; break;
158 case Fl_Printer::LETTER: mode->dmPaperSize = DMPAPER_LETTER; break;
159 case Fl_Printer::TABLOID: mode->dmPaperSize = DMPAPER_TABLOID; break;
160 case Fl_Printer::ENVELOPE: mode->dmPaperSize = DMPAPER_ENV_9; break;
161 default: return -1;
162 }
163 return 0;
164 }
165
166
167 //////////////////////////////////////////////////////////////////////////////////////////////
168
Fl_GDI_Printer(HDC gc,DEVMODE * mode)169 Fl_GDI_Printer::Fl_GDI_Printer(HDC gc, DEVMODE * mode ):Fl_Printer(),/*delete_mode_(0),*/ style_(0),width_(0),dashes_(0),mask(0){
170
171 gc_=gc;
172
173 static DOCINFO DocInfo = { sizeof(DOCINFO), "FLTK Document", NULL,0 };// declare DocInfo for use and set the name of the print job as 'Name Of Document'
174 mode_ = (DEVMODE *)GlobalLock(mode);
175 int orientation_ = 0;
176 if(mode_->dmOrientation==DMORIENT_LANDSCAPE)
177 orientation_ = 1;
178 int paper;
179 if(mode_->dmFields & DM_PAPERSIZE){
180 paper = gdipaper(mode_);
181 if(mode_->dmOrientation == DMORIENT_PORTRAIT){
182 pw_ = Fl_Printer::page_formats[paper][0];
183 ph_ = Fl_Printer::page_formats[paper][1];
184 }else{
185 pw_ = Fl_Printer::page_formats[paper][1];
186 ph_ = Fl_Printer::page_formats[paper][0];
187 }
188 }
189
190 ResetDC(gc_,mode_);
191 //GlobalUnlock(mode_);
192 SetMapMode(gc_, MM_ANISOTROPIC);
193 SetTextAlign(gc_, TA_BASELINE|TA_LEFT);
194 SetBkMode(gc_, TRANSPARENT);
195 StartDoc(gc_, &DocInfo);
196 ix = GetDeviceCaps(gc_, LOGPIXELSX);
197 iy = GetDeviceCaps(gc_, LOGPIXELSY);
198 ox = GetDeviceCaps(gc_, PHYSICALOFFSETX);
199 oy = GetDeviceCaps(gc_, PHYSICALOFFSETY);
200 if(ix<iy)
201 max_res_=ix;
202 else
203 max_res_=iy;
204
205 nPages = 0;
206
207 int i;
208 // Unlike for static vars, here I have to zero the memory
209 for(i=0;i<FL_N_BRUSH;i++){
210 brushes[i].brush = 0;
211 brushes[i].usage = 0;
212 brushes[i].backref = 0;
213 }
214 tmppen = 0;
215 tmpbrush = 0;
216 savepen = 0;
217 for(i=0;i<256;i++){
218 fl_xmap[i].rgb = 0;
219 fl_xmap[i].pen = 0; // pen, 0 if none created yet
220 fl_xmap[i].brush = 0;
221 }
222 xmap.rgb=0;
223 xmap.brush =0;
224 xmap.pen = 0;
225 type_ = 0x200;
226 }
227
228
229 ///////////////////////////////// paging //////////////////////////////////////
230
231
set_page(int page)232 void Fl_GDI_Printer::set_page(int page){
233 if(page){
234 ResetDC(gc_,mode_);
235 SetMapMode(gc_, MM_ANISOTROPIC);
236 SetTextAlign(gc_, TA_BASELINE|TA_LEFT);
237 SetBkMode(gc_, TRANSPARENT);
238 StartPage(gc_);
239 ix = GetDeviceCaps(gc_, LOGPIXELSX);
240 iy = GetDeviceCaps(gc_, LOGPIXELSY);
241 ox = GetDeviceCaps(gc_, PHYSICALOFFSETX);
242 oy = GetDeviceCaps(gc_, PHYSICALOFFSETY);
243 }
244 SetViewportOrgEx(gc_,VOx = - ox, VOy = - oy,0); //setting origin to the upper left corner
245 SetViewportExtEx(gc_, VEx = (long)(ix * iy), VEy = (long)(iy *ix ),0);
246 SetWindowExtEx(gc_, WEx = iy * 72, WEy = ix * 72, 0); //72 pixels per inch mapping
247 SetWindowOrgEx(gc_, WOx = 0, WOy = 0,0);
248 }
249
250
251
page(double pw,double ph,int media)252 void Fl_GDI_Printer::page(double pw, double ph, int media){
253 if(nPages)
254 EndPage(gc_);
255 nPages++;
256 pw_=pw;
257 ph_=ph;
258 // if(pw>ph)
259 // orientation_ = 1;
260 //DEVMODE * mode = (DEVMODE *)GlobalLock(mode_);
261 if(ph>pw)
262 mode_->dmOrientation = DMORIENT_PORTRAIT;
263 else
264 mode_->dmOrientation = DMORIENT_LANDSCAPE;
265 if(media){
266 mode_->dmPaperWidth = (int) (pw*254/72);
267 mode_->dmPaperLength = (int) (ph*254/72);
268 mode_->dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH;
269 mode_->dmFields &= ~DM_PAPERSIZE;
270 }
271 //GlobalUnlock(mode_);
272 set_page(1);
273 };
274
275
page(int format)276 void Fl_GDI_Printer::page(int format){
277 // DEVMODE * mode = (DEVMODE *)GlobalLock(mode_);
278 if(nPages)
279 EndPage(gc_);
280 //DEVMODE * mode = (DEVMODE *)GlobalLock(mode_);
281 if(format & LANDSCAPE){
282 mode_->dmOrientation = DMORIENT_LANDSCAPE;
283 pw_ = page_formats[format & 0xFF][1];
284 ph_ = page_formats[format & 0xFF][0];
285 }else{
286 mode_->dmOrientation = DMORIENT_PORTRAIT;
287 pw_ = page_formats[format & 0xFF][0];
288 ph_ = page_formats[format & 0xFF][1];
289 }
290 if(format & MEDIA){
291 if(!gdipaper(mode_, format& 0xFF)){
292 mode_->dmFields &= ~DM_PAPERLENGTH & ~DM_PAPERWIDTH;
293 mode_->dmFields |= DM_PAPERSIZE;
294 }else{
295 mode_->dmPaperWidth = (int) (pw_*254/72);
296 mode_->dmPaperLength = (int) (ph_*254/72);
297 mode_->dmFields |= DM_PAPERLENGTH | DM_PAPERWIDTH;
298 mode_->dmFields &= ~DM_PAPERSIZE;
299 }
300 }
301 if(format & LANDSCAPE){
302 mode_->dmOrientation = DMORIENT_LANDSCAPE;
303 }else{
304 mode_->dmOrientation = DMORIENT_PORTRAIT;
305
306 }
307
308 //GlobalUnlock(mode_);
309 set_page(1);
310 };
311
312 //////////////////////// margins and placing of drawinds on the page ///////////////////////////
313
314
sty(int style,int width,char * dashes,int vex)315 void Fl_GDI_Printer::sty(int style, int width, char *dashes, int vex){
316 if(!(width)){
317 width=1;
318 if(!style && !dashes)
319 style |= FL_CAP_SQUARE | FL_JOIN_MITER; //adjustment for system drawings
320 }
321 if(!dashes || !(*dashes)){
322 if((style & 0xff) && ((style & 0xf00)==FL_CAP_SQUARE)) // square caps do not seem to work with dasges, not sure why
323 style = (style & ~0xf00)|FL_CAP_FLAT;
324 Fl_Output_Device::line_style(style, width*vex);
325 }else{
326
327 // Following is shameless copy from original fl_line_style with modifications.
328 // Has to be changed to avoid code redundance...
329
330 static DWORD Cap[4]= {PS_ENDCAP_FLAT, PS_ENDCAP_FLAT, PS_ENDCAP_ROUND, PS_ENDCAP_SQUARE};
331 static DWORD Join[4]={PS_JOIN_ROUND, PS_JOIN_MITER, PS_JOIN_ROUND, PS_JOIN_BEVEL};
332 int s1 = PS_GEOMETRIC | Cap[(style>>8)&3] | Join[(style>>12)&3];
333 DWORD a[16]; int n = 0;
334 s1 |= PS_USERSTYLE;
335 for (n = 0; n < 16 && *dashes; n++) a[n] = vex * *dashes++;
336 if ((style || n) && !width) width = 1; // fix cards that do nothing for 0?
337 LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()?
338 HPEN newpen = ExtCreatePen(s1, vex * width, &penbrush, n, n ? a : 0);
339 if (!newpen) {
340 Fl::error("Fl_GDI_Printer::line_style(): Could not create GDI pen object.");
341 return;
342 }
343 HPEN oldpen = (HPEN)SelectObject(fl_gc, newpen);
344 DeleteObject(oldpen);
345 fl_current_xmap->pen = newpen;
346 }
347 }
348
349
line_style(int style,int width,char * dashes)350 void Fl_GDI_Printer::line_style(int style, int width, char * dashes){
351 sty(style_ = style, width_ = width, dashes_ = dashes);
352 };
353
place(double x,double y,double tx,double ty,double s)354 void Fl_GDI_Printer::place(double x, double y, double tx, double ty, double s){
355 // SetViewportOrgEx(gc_, VOx = (long)(ix * (lm_+tx) /72 - ox + dx), VOy = (long)( iy *(tm_+th) /72 - oy + dy),0); //setting origin to the upper left corner inside margins
356
357 SetViewportOrgEx(gc_, VOx = (long)(ix * tx /72 - ox ), VOy = (long)( iy *ty /72 - oy),0); //setting origin to the upper left corner inside margins
358 SetWindowOrgEx(gc_, WOx = (long)x, WOy = (long)y,0);
359 SetViewportExtEx(gc_, VEx =(long)(ix * iy *s), VEy =(long)(iy * ix * s), 0);
360 SetWindowExtEx(gc_, WEx = iy *72, WEy = ix * 72,0);
361 };
362
363 /*
364 void Fl_GDI_Printer::place(double x, double y, double w, double h, double tx, double ty, double tw, double th,int align){
365 double dx, dy;
366 double s = tw/w;
367
368 if(s<(th/h)){
369 dx = 0;
370 dy = (th - s * h)*iy/144;
371 }else{
372 s=th/h;
373 dy = 0;
374 dx = (tw - s * w)*ix/144;
375 }
376
377 if(align & 3)
378 if(align & FL_ALIGN_TOP)
379 dy=0;
380 else
381 dy *= 2;
382 if(align & 12)
383 if(align & FL_ALIGN_LEFT)
384 dx = 0;
385 else
386 dx *= 2;
387
388 // SetViewportOrgEx(gc_, VOx = (long)(ix * (lm_+tx) /72 - ox + dx), VOy = (long)( iy *(tm_+th) /72 - oy + dy),0); //setting origin to the upper left corner inside margins
389
390 SetViewportOrgEx(gc_, VOx = (long)(ix * tx /72 - ox + dx), VOy = (long)( iy * ty /72 - oy + dy),0); //setting origin to the upper left corner inside margins
391
392 SetWindowOrgEx(gc_, WOx = (long)x, WOy = (long)y,0);
393 SetViewportExtEx(gc_, VEx =(long)(ix * iy *s), VEy =(long)(iy * ix * s), 0);
394 SetWindowExtEx(gc_, WEx = iy *72, WEy = ix * 72,0);
395 };
396
397 */
398 ///////////////// we need to re-implement path drawings (double) for sub-pixel placement of vertices /////////////
399
transformed_vertex(double x,double y)400 FL_EXPORT void Fl_GDI_Printer::transformed_vertex(double x, double y){
401 Fl_Output_Device::transformed_vertex((max_res_) * x, (max_res_) * y);
402 };
403
404 //struct matrix {double a, b, c, d, x, y;};
405
406 extern FL_EXPORT matrix * fl_get_matrix();
407
vertex(double x,double y)408 FL_EXPORT void Fl_GDI_Printer::vertex(double x, double y){
409 transformed_vertex(fl_transform_x(x,y), fl_transform_y(x,y));
410 };
411
412 extern int fl_what_loop;
413 enum {LINE, LOOP, POLYGON, POINT_};
414
circle(double x,double y,double r)415 FL_EXPORT void Fl_GDI_Printer::circle(double x, double y, double r){
416 matrix * m = fl_get_matrix();
417 double xt = fl_transform_x(x,y);
418 double yt = fl_transform_y(x,y);
419 /*
420 // very ugly hack because m matrix is static, to be modified.
421 double ma = fl_transform_dx(1,0);
422 double mb = fl_transform_dy(1,0);
423 double mc = fl_transform_dx(0,1);
424 double md = fl_transform_dy(0,1);
425 */
426
427 double rx = r * (m->c ? sqrt(m->a*m->a+m->c*m->c) : fabs(m->a));
428 double ry = r * (m->b ? sqrt(m->b*m->b+m->d*m->d) : fabs(m->d));
429 double llx = xt-rx;
430 double w = xt + rx - llx;
431 double lly = yt - ry;
432 double h = yt + ry - lly;
433
434 SetWindowExtEx(gc_, WEx*(max_res_), WEy*(max_res_), 0);
435 SetWindowOrgEx(gc_, WOx*(max_res_) , WOy*(max_res_) ,0);
436
437 if (fl_what_loop==POLYGON) {
438 SelectObject(fl_gc, fl_brush());
439 Pie(fl_gc, (int)rint((max_res_)*llx), (int)rint((max_res_)*lly), (int)rint((max_res_)*(llx+w)), (int)rint((max_res_)*(lly+h)), 0, 0, 0, 0);
440 SetWindowExtEx(gc_, WEx, WEy, 0);
441 SetWindowOrgEx(gc_, WOx, WOy,0);
442 }else{
443 sty(style_, width_, dashes_, max_res_);
444 Arc(fl_gc, (int)rint((max_res_)*llx), (int)rint((max_res_)*lly), (int)rint((max_res_)*(llx+w)), (int)rint((max_res_)*(lly+h)), 0, 0, 0, 0);
445 SetWindowExtEx(gc_, WEx, WEy, 0);
446 SetWindowOrgEx(gc_, WOx, WOy,0);
447 sty(style_, width_, dashes_);
448 }
449
450 }
451
452
set_subpixel()453 void Fl_GDI_Printer::set_subpixel(){
454 SetWindowExtEx(gc_, WEx*(max_res_), WEy*(max_res_), 0);
455 SetWindowOrgEx(gc_, WOx*(max_res_), WOy*(max_res_) ,0);
456 sty(style_, width_, dashes_, max_res_);
457 };
458
set_normal()459 void Fl_GDI_Printer::set_normal(){
460 SetWindowExtEx(gc_, WEx, WEy, 0);
461 SetWindowOrgEx(gc_, WOx, WOy,0);
462 sty(style_, width_, dashes_);
463 };
464
rectf(int x,int y,int w,int h)465 void Fl_GDI_Printer::rectf(int x, int y, int w, int h){
466 //Fl_Output_Device::rectf(x,y,w,h);
467 SetWindowExtEx(gc_, WEx * max_res_, WEy*(max_res_), 0);
468 SetWindowOrgEx(gc_, WOx * max_res_, WOy*(max_res_) ,0);
469 Fl_Output_Device::rectf((int)(max_res_ * (x-0.5)),(int)(max_res_ * (y-0.5)),(int)(max_res_*(w)), (int)(max_res_*(h)));
470 SetWindowExtEx(gc_, WEx, WEy, 0);
471 SetWindowOrgEx(gc_, WOx, WOy,0);
472 };
473
point(int x,int y)474 void Fl_GDI_Printer::point(int x, int y){
475 rectf(x,y,1,1);
476 };
477
478
arc(int x,int y,int w,int h,double a1,double a2)479 void Fl_GDI_Printer::arc(int x, int y, int w, int h, double a1, double a2){
480 set_subpixel();
481 Fl_Output_Device::arc((int)(max_res_ * (x)),(int)(max_res_ * (y)),(int)(max_res_*(w-1)), (int)(max_res_*(h-1)), a1, a2);
482 set_normal();
483 };
pie(int x,int y,int w,int h,double a1,double a2)484 void Fl_GDI_Printer::pie(int x, int y, int w, int h, double a1, double a2){
485 set_subpixel();
486 Fl_Output_Device::pie((int)(max_res_ * (x)),(int)(max_res_ * (y)),(int)(max_res_*(w-1)), (int)(max_res_*(h-1)), a1, a2);
487 set_normal();
488 };
489
490
xyline(int x,int y,int x1)491 void Fl_GDI_Printer::xyline(int x,int y, int x1){
492 MoveToEx(fl_gc, x, y, 0); LineTo(fl_gc, x1, y);
493 }
494
yxline(int x,int y,int y1)495 void Fl_GDI_Printer::yxline(int x, int y, int y1){
496 MoveToEx(fl_gc, x, y, 0); LineTo(fl_gc, x, y1);
497 }
498
xyline(int x,int y,int x1,int y2)499 void Fl_GDI_Printer::xyline(int x, int y, int x1, int y2) {
500 MoveToEx(fl_gc, x, y, 0);
501 LineTo(fl_gc, x1, y);
502 LineTo(fl_gc, x1, y2);
503 }
504
xyline(int x,int y,int x1,int y2,int x3)505 void Fl_GDI_Printer::xyline(int x, int y, int x1, int y2, int x3) {
506 MoveToEx(fl_gc, x, y, 0);
507 LineTo(fl_gc, x1, y);
508 LineTo(fl_gc, x1, y2);
509 LineTo(fl_gc, x3, y2);
510 };
511
yxline(int x,int y,int y1,int x2)512 void Fl_GDI_Printer::yxline(int x, int y, int y1, int x2) {
513 MoveToEx(fl_gc, x, y, 0);
514 LineTo(fl_gc, x, y1);
515 LineTo(fl_gc, x2, y1);
516 }
517
yxline(int x,int y,int y1,int x2,int y3)518 void Fl_GDI_Printer::yxline(int x, int y, int y1, int x2, int y3) {
519 MoveToEx(fl_gc, x, y, 0);
520 LineTo(fl_gc, x, y1);
521 LineTo(fl_gc, x2, y1);
522 LineTo(fl_gc, x2, y3);
523 };
524
525
line(int x,int y,int x1,int y1)526 void Fl_GDI_Printer::line(int x, int y, int x1, int y1) {
527 MoveToEx(fl_gc, x, y, 0L);
528 LineTo(fl_gc, x1, y1);
529 };
530
531
line(int x,int y,int x1,int y1,int x2,int y2)532 void Fl_GDI_Printer::line(int x, int y, int x1, int y1, int x2, int y2) {
533 MoveToEx(fl_gc, x, y, 0L);
534 LineTo(fl_gc, x1, y1);
535 LineTo(fl_gc, x2, y2);
536 };
537
end_line()538 FL_EXPORT void Fl_GDI_Printer::end_line(){
539 //LPSIZE l;
540 //GetViewportExtEx( gc_, l );
541 /*
542 SetWindowExtEx(gc_, WEx*(max_res_), WEy*(max_res_), 0);
543 SetWindowOrgEx(gc_, WOx*(max_res_), WOy*(max_res_) ,0);
544 //GetViewportExtEx( gc_, l );
545 sty(style_, width_, dashes_, max_res_);
546 */
547 set_subpixel();
548 Fl_Output_Device::end_line();
549 set_normal();
550 /*
551 SetWindowExtEx(gc_, WEx, WEy, 0);
552 SetWindowOrgEx(gc_, WOx, WOy,0);
553 sty(style_, width_, dashes_);
554 */
555 };
556
557
end_polygon()558 FL_EXPORT void Fl_GDI_Printer::end_polygon(){
559 set_subpixel();
560 /*
561 SetWindowExtEx(gc_, WEx*(max_res_), WEy*(max_res_), 0);
562 SetWindowOrgEx(gc_, WOx * (max_res_), WOy *(max_res_),0);
563 sty(style_, width_, dashes_, max_res_);
564 */
565 Fl_Output_Device::end_polygon();
566 set_normal();
567 /*
568 SetWindowExtEx(gc_, WEx, WEy, 0);
569 SetWindowOrgEx(gc_, WOx, WOy,0);
570 sty(style_, width_, dashes_);
571 */
572 };
573
574
end_loop()575 FL_EXPORT void Fl_GDI_Printer::end_loop(){
576 set_subpixel();
577 Fl_Output_Device::end_loop();
578 set_normal();
579 };
580
end_complex_polygon()581 FL_EXPORT void Fl_GDI_Printer::end_complex_polygon(){
582 set_subpixel();
583 Fl_Output_Device::end_complex_polygon();
584 set_normal();
585 };
586
587
588
589
590 //////// clipping, need to be re-implemented as orig. win32 functions are in device coordinates ///////////
591
push_clip(int x,int y,int w,int h)592 FL_EXPORT void Fl_GDI_Printer::push_clip(int x, int y, int w, int h){
593 Fl_Output_Device::push_clip(((x - WOx) * VEx - VEx/2) / WEx + VOx, ((y - WOy) * VEy - VEy/2 ) / WEy + VOy, w * VEx / WEx, h * VEy / WEy);
594 }
595
596 extern Fl_Region * fl_clip_stack;
597 extern int * fl_clip_stack_pointer;
598
not_clipped(int x,int y,int w,int h)599 FL_EXPORT int Fl_GDI_Printer::not_clipped(int x, int y, int w, int h){
600 Fl_Region r = fl_clip_stack[* fl_clip_stack_pointer];
601 if (!r) return 1;
602 RECT rect;
603 rect.left = ((x - WOx) * VEx -VEx/2)/ WEx + VOx;
604 rect.top = ((y - WOy) * VEy-VEy/2) / WEy + VOy;
605 rect.right = ((x + w - WOx) * VEx - VEx/2)/ WEx + VOx;
606 rect.bottom = ((y + h - WOy) * VEy-VEy/2) / WEy + VOy;
607 return RectInRegion(r,&rect);
608 }
609
clip_box(int x,int y,int w,int h,int & X,int & Y,int & W,int & H)610 FL_EXPORT int Fl_GDI_Printer::clip_box(int x, int y, int w, int h, int &X, int &Y, int &W, int &H){
611 int ret = Fl_Output_Device::clip_box(((x - WOx) * VEx - VEx/2)/ WEx + VOx, ((y - WOy) * VEy -VEy/2)/ WEy + VOy, w * VEx / WEx, h * VEy / WEy, X, Y, W, H);
612 X = (X - VOx ) * WEx / VEx + WOx;
613 Y = (Y - VOy ) * WEy / VEy + WOy;
614 W = W * WEx / VEx;
615 H = H * WEy / VEy;
616 return ret;
617 }
618
619 // -
620 //extern uchar **fl_mask_bitmap;
621
622
623