From 7c932c25d6a74530e5b086d8b0d888546cad10cc Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Fri, 4 Feb 2011 09:17:45 +0000 Subject: [PATCH] Added the possibility to call Fl_Paged_Device::scale(factor) with a single argument. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8366 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- FL/Fl_Paged_Device.H | 2 +- FL/Fl_PostScript.H | 2 +- FL/Fl_Printer.H | 4 ++-- src/Fl_GDI_Printer.cxx | 1 + src/Fl_Paged_Device.cxx | 4 +++- src/Fl_PostScript.cxx | 1 + src/Fl_Quartz_Printer.mm | 1 + src/Fl_cocoa.mm | 2 +- 8 files changed, 11 insertions(+), 6 deletions(-) diff --git a/FL/Fl_Paged_Device.H b/FL/Fl_Paged_Device.H index 2782f6566..5504b5192 100644 --- a/FL/Fl_Paged_Device.H +++ b/FL/Fl_Paged_Device.H @@ -126,7 +126,7 @@ public: virtual void margins(int *left, int *top, int *right, int *bottom); virtual void origin(int x, int y); virtual void origin(int *x, int *y); - virtual void scale(float scale_x, float scale_y); + virtual void scale(float scale_x, float scale_y = 0.); virtual void rotate(float angle); virtual void translate(int x, int y); virtual void untranslate(void); diff --git a/FL/Fl_PostScript.H b/FL/Fl_PostScript.H index 2a734480a..80c5bd5c1 100644 --- a/FL/Fl_PostScript.H +++ b/FL/Fl_PostScript.H @@ -234,7 +234,7 @@ public: void margins(int *left, int *top, int *right, int *bottom); void origin(int *x, int *y); void origin(int x, int y); - void scale (float scale_x, float scale_y); + void scale (float scale_x, float scale_y = 0.); void rotate(float angle); void translate(int x, int y); void untranslate(void); diff --git a/FL/Fl_Printer.H b/FL/Fl_Printer.H index cc6e4cedc..7b68a459b 100644 --- a/FL/Fl_Printer.H +++ b/FL/Fl_Printer.H @@ -85,7 +85,7 @@ public: void margins(int *left, int *top, int *right, int *bottom); void origin(int *x, int *y); void origin(int x, int y); - void scale (float scale_x, float scale_y); + void scale (float scale_x, float scale_y = 0.); void rotate(float angle); void translate(int x, int y); void untranslate(void); @@ -160,7 +160,7 @@ public: void margins(int *left, int *top, int *right, int *bottom); void origin(int *x, int *y); void origin(int x, int y); - void scale(float scale_x, float scale_y); + void scale(float scale_x, float scale_y = 0.); void rotate(float angle); void translate(int x, int y); void untranslate(void); diff --git a/src/Fl_GDI_Printer.cxx b/src/Fl_GDI_Printer.cxx index 7e148e2bd..b02c8ecab 100644 --- a/src/Fl_GDI_Printer.cxx +++ b/src/Fl_GDI_Printer.cxx @@ -209,6 +209,7 @@ void Fl_System_Printer::origin (int deltax, int deltay) void Fl_System_Printer::scale (float scalex, float scaley) { + if (scaley == 0.) scaley = scalex; int w, h; SetWindowExtEx(fl_gc, (int)(720 / scalex + 0.5), (int)(720 / scaley + 0.5), NULL); printable_rect(&w, &h); diff --git a/src/Fl_Paged_Device.cxx b/src/Fl_Paged_Device.cxx index 6bdf24b30..75c0e9dc1 100644 --- a/src/Fl_Paged_Device.cxx +++ b/src/Fl_Paged_Device.cxx @@ -206,7 +206,9 @@ void Fl_Paged_Device::origin(int x, int y) {} After a scale() call, do a printable_rect() call to get the new dimensions of the printable page area. Successive scale() calls don't combine their effects. @param scale_x Horizontal dimensions of plot are multiplied by this quantity. - @param scale_y Same as above, vertically. + @param scale_y Same as above, vertically. + The value 0. is equivalent to setting \p scale_y = \p scale_x. Thus, scale(factor); + is equivalent to scale(factor, factor); */ void Fl_Paged_Device::scale (float scale_x, float scale_y) {} diff --git a/src/Fl_PostScript.cxx b/src/Fl_PostScript.cxx index 372b3e624..c317beeef 100644 --- a/src/Fl_PostScript.cxx +++ b/src/Fl_PostScript.cxx @@ -1402,6 +1402,7 @@ void Fl_PostScript_File_Device::origin(int x, int y) void Fl_PostScript_File_Device::scale (float s_x, float s_y) { + if (s_y == 0.) s_y = s_x; Fl_PostScript_Graphics_Driver *ps = driver(); ps->scale_x = s_x; ps->scale_y = s_y; diff --git a/src/Fl_Quartz_Printer.mm b/src/Fl_Quartz_Printer.mm index 946767375..153aef14a 100644 --- a/src/Fl_Quartz_Printer.mm +++ b/src/Fl_Quartz_Printer.mm @@ -193,6 +193,7 @@ void Fl_System_Printer::origin(int x, int y) void Fl_System_Printer::scale (float s_x, float s_y) { + if (s_y == 0.) s_y = s_x; scale_x = s_x; scale_y = s_y; CGContextRestoreGState(fl_gc); diff --git a/src/Fl_cocoa.mm b/src/Fl_cocoa.mm index 49af5d67a..ae328930a 100644 --- a/src/Fl_cocoa.mm +++ b/src/Fl_cocoa.mm @@ -2787,7 +2787,7 @@ int Fl_X::screen_init(XRectangle screens[], float dpi[]) if (win->w()>w || win->h()>h) { scale = (float)w/win->w(); if ((float)h/win->h() < scale) scale = (float)h/win->h(); - printer.scale(scale, scale); + printer.scale(scale); } //#define ROTATE 1 #ifdef ROTATE