From 54b697cd49d3946ecd1f264c0741f36568822819 Mon Sep 17 00:00:00 2001 From: Manolo Gouy Date: Thu, 19 Apr 2018 10:39:46 +0000 Subject: Reorganise access to the value of the GUI scaling factor with public getter and protected, virtual setter member functions. git-svn-id: file:///fltk/svn/fltk/branches/branch-1.4@12858 ea41ed52-d2ee-0310-a9c1-e6b18d33e121 --- src/Fl_Graphics_Driver.cxx | 99 +++++++++++----------- src/drivers/GDI/Fl_GDI_Graphics_Driver.H | 1 + src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx | 8 +- src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx | 4 +- src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx | 28 +++--- .../GDI/Fl_GDI_Graphics_Driver_line_style.cxx | 2 +- src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx | 32 +++---- src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx | 2 +- src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H | 1 + src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx | 8 +- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx | 6 +- .../Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx | 28 +++--- src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx | 48 +++++------ src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx | 86 +++++++++---------- 14 files changed, 177 insertions(+), 176 deletions(-) (limited to 'src') diff --git a/src/Fl_Graphics_Driver.cxx b/src/Fl_Graphics_Driver.cxx index efabe5f90..8f9371f17 100644 --- a/src/Fl_Graphics_Driver.cxx +++ b/src/Fl_Graphics_Driver.cxx @@ -203,12 +203,12 @@ bool Fl_Graphics_Driver::overlay_rect_unscaled() scale() and in slightly modifying that to help support tiled images. */ void Fl_Graphics_Driver::cache_size(Fl_Image *img, int &width, int &height) { - if ( int(scale_) == scale_ ) { - width = width * scale_; - height = height * scale_; + if ( int(scale()) == scale() ) { + width = width * scale(); + height = height * scale(); } else { - width = (width+1) * scale_; - height = (height+1) * scale_; + width = (width+1) * scale(); + height = (height+1) * scale(); } } @@ -290,8 +290,8 @@ void Fl_Graphics_Driver::draw_rgb(Fl_RGB_Image *img, int XP, int YP, int WP, int if (start_image(img, XP, YP, WP, HP, cx, cy, XP, YP, WP, HP)) { return; } - int need_scaled_drawing = ( fabs(img->w() - img->data_w()/scale_)/img->w() > 0.05 || - fabs(img->h() - img->data_h()/scale_)/img->h() > 0.05 ); + int need_scaled_drawing = ( fabs(img->w() - img->data_w()/scale())/img->w() > 0.05 || + fabs(img->h() - img->data_h()/scale())/img->h() > 0.05 ); // to allow rescale at runtime int w2, h2, *pw, *ph; if (need_scaled_drawing) { @@ -337,14 +337,13 @@ Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name, Fl_Fontsize Size) { } Fl_Scalable_Graphics_Driver::Fl_Scalable_Graphics_Driver() : Fl_Graphics_Driver() { - scale_ = 1; line_width_ = 0; } void Fl_Scalable_Graphics_Driver::rect(int x, int y, int w, int h) { - if (int(scale_) == scale_) { - rect_unscaled(x * scale_, y * scale_, w * scale_, h * scale_); + if (int(scale()) == scale()) { + rect_unscaled(x * scale(), y * scale(), w * scale(), h * scale()); } else { xyline(x, y, x+w-1); yxline(x, y, y+h-1); @@ -355,28 +354,28 @@ void Fl_Scalable_Graphics_Driver::rect(int x, int y, int w, int h) void Fl_Scalable_Graphics_Driver::rectf(int x, int y, int w, int h) { - rectf_unscaled(x * scale_, y * scale_, w * scale_, h * scale_); + rectf_unscaled(x * scale(), y * scale(), w * scale(), h * scale()); } void Fl_Scalable_Graphics_Driver::point(int x, int y) { - point_unscaled(x * scale_, y * scale_); + point_unscaled(x * scale(), y * scale()); } void Fl_Scalable_Graphics_Driver::line(int x, int y, int x1, int y1) { if (y == y1) xyline(x, y, x1); else if (x == x1) yxline(x, y, y1); - else line_unscaled( x*scale_, y*scale_, x1*scale_, y1*scale_); + else line_unscaled( x*scale(), y*scale(), x1*scale(), y1*scale()); } void Fl_Scalable_Graphics_Driver::line(int x, int y, int x1, int y1, int x2, int y2) { if ( (y == y1 || x == x1) && (y2 == y1 || x2 == x1) ) { // only horizontal or vertical lines line(x, y, x1, y1); line(x1, y1, x2, y2); - } else line_unscaled( x*scale_, y*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_); + } else line_unscaled( x*scale(), y*scale(), x1*scale(), y1*scale(), x2*scale(), y2*scale()); } void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1) { - xyline_unscaled(x*scale_, y*scale_, x1*scale_); + xyline_unscaled(x*scale(), y*scale(), x1*scale()); } void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1, int y2) { @@ -391,7 +390,7 @@ void Fl_Scalable_Graphics_Driver::xyline(int x, int y, int x1, int y2, int x3) { } void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1) { - yxline_unscaled(x*scale_, y*scale_, y1*scale_); + yxline_unscaled(x*scale(), y*scale(), y1*scale()); } void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1, int x2) { @@ -406,19 +405,19 @@ void Fl_Scalable_Graphics_Driver::yxline(int x, int y, int y1, int x2, int y3) { } void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2) { - loop_unscaled(x0*scale_, y0*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_); + loop_unscaled(x0*scale(), y0*scale(), x1*scale(), y1*scale(), x2*scale(), y2*scale()); } void Fl_Scalable_Graphics_Driver::loop(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { - loop_unscaled(x0*scale_, y0*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_, x3*scale_, y3*scale_); + loop_unscaled(x0*scale(), y0*scale(), x1*scale(), y1*scale(), x2*scale(), y2*scale(), x3*scale(), y3*scale()); } void Fl_Scalable_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2) { - polygon_unscaled(x0*scale_, y0*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_); + polygon_unscaled(x0*scale(), y0*scale(), x1*scale(), y1*scale(), x2*scale(), y2*scale()); } void Fl_Scalable_Graphics_Driver::polygon(int x0, int y0, int x1, int y1, int x2, int y2, int x3, int y3) { - polygon_unscaled(x0*scale_, y0*scale_, x1*scale_, y1*scale_, x2*scale_, y2*scale_, x3*scale_, y3*scale_); + polygon_unscaled(x0*scale(), y0*scale(), x1*scale(), y1*scale(), x2*scale(), y2*scale(), x3*scale(), y3*scale()); } void Fl_Scalable_Graphics_Driver::circle(double x, double y, double r) { @@ -426,72 +425,72 @@ void Fl_Scalable_Graphics_Driver::circle(double x, double y, double r) { double yt = transform_y(x,y); double rx = r * (m.c ? sqrt(m.a*m.a+m.c*m.c) : fabs(m.a)); double ry = r * (m.b ? sqrt(m.b*m.b+m.d*m.d) : fabs(m.d)); - ellipse_unscaled(xt*scale_, yt*scale_, rx*scale_, ry*scale_); + ellipse_unscaled(xt*scale(), yt*scale(), rx*scale(), ry*scale()); } void Fl_Scalable_Graphics_Driver::font(Fl_Font face, Fl_Fontsize size) { if (!font_descriptor()) fl_open_display(); // to catch the correct initial value of scale_ - font_unscaled(face, size * scale_); + font_unscaled(face, size * scale()); } double Fl_Scalable_Graphics_Driver::width(const char *str, int n) { - return width_unscaled(str, n)/scale_; + return width_unscaled(str, n)/scale(); } double Fl_Scalable_Graphics_Driver::width(unsigned int c) { - return width_unscaled(c)/scale_; + return width_unscaled(c)/scale(); } Fl_Fontsize Fl_Scalable_Graphics_Driver::size() { if (!font_descriptor() ) return -1; - return size_unscaled()/scale_; + return size_unscaled()/scale(); } void Fl_Scalable_Graphics_Driver::text_extents(const char *str, int n, int &dx, int &dy, int &w, int &h) { text_extents_unscaled(str, n, dx, dy, w, h); - dx /= scale_; - dy /= scale_; - w /= scale_; - h /= scale_; + dx /= scale(); + dy /= scale(); + w /= scale(); + h /= scale(); } int Fl_Scalable_Graphics_Driver::height() { - return int(height_unscaled()/scale_); + return int(height_unscaled()/scale()); } int Fl_Scalable_Graphics_Driver::descent() { - return descent_unscaled()/scale_; + return descent_unscaled()/scale(); } void Fl_Scalable_Graphics_Driver::draw(const char *str, int n, int x, int y) { if (!size_ || !font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE); - Fl_Region r2 = scale_clip(scale_); - draw_unscaled(str, n, x*scale_, y*scale_); + Fl_Region r2 = scale_clip(scale()); + draw_unscaled(str, n, x*scale(), y*scale()); unscale_clip(r2); } void Fl_Scalable_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) { if (!size_ || !font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE); - Fl_Region r2 = scale_clip(scale_); - draw_unscaled(angle, str, n, x*scale_, y*scale_); + Fl_Region r2 = scale_clip(scale()); + draw_unscaled(angle, str, n, x*scale(), y*scale()); unscale_clip(r2); } void Fl_Scalable_Graphics_Driver::rtl_draw(const char* str, int n, int x, int y) { - rtl_draw_unscaled(str, n, x * scale_, y * scale_); + rtl_draw_unscaled(str, n, x * scale(), y * scale()); } void Fl_Scalable_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) { - arc_unscaled(x * scale_, y * scale_, w * scale_, h * scale_, a1, a2); + arc_unscaled(x * scale(), y * scale(), w * scale(), h * scale(), a1, a2); } void Fl_Scalable_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a2) { - pie_unscaled(x * scale_, y * scale_, w * scale_, h * scale_, a1, a2); + pie_unscaled(x * scale(), y * scale(), w * scale(), h * scale(), a1, a2); } void Fl_Scalable_Graphics_Driver::line_style(int style, int width, char* dashes) { - if (width == 0) line_width_ = scale_ < 2 ? 0 : scale_; - else line_width_ = width>0 ? width*scale_ : -width*scale_; + if (width == 0) line_width_ = scale() < 2 ? 0 : scale(); + else line_width_ = width>0 ? width*scale() : -width*scale(); line_style_unscaled(style, line_width_, dashes); } @@ -532,43 +531,43 @@ void Fl_Scalable_Graphics_Driver::draw_image_rescale(void *buf, Fl_Draw_Image_Cb } void Fl_Scalable_Graphics_Driver::draw_image(const uchar* buf, int X,int Y,int W,int H, int D, int L) { - if (scale_ == 1) { + if (scale() == 1) { draw_image_unscaled(buf, X,Y,W,H,D,L); } else { - draw_image_rescale((void*)buf, NULL, X, Y, W, H, D, L, false, scale_); + draw_image_rescale((void*)buf, NULL, X, Y, W, H, D, L, false, scale()); } } void Fl_Scalable_Graphics_Driver::draw_image(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) { - if (scale_ == 1) { + if (scale() == 1) { draw_image_unscaled(cb, data, X,Y,W,H,D); } else { - draw_image_rescale(data, cb, X, Y, W, H, D, 0, false, scale_); + draw_image_rescale(data, cb, X, Y, W, H, D, 0, false, scale()); } } void Fl_Scalable_Graphics_Driver::draw_image_mono(const uchar* buf, int X,int Y,int W,int H, int D, int L) { - if (scale_ == 1) { + if (scale() == 1) { draw_image_mono_unscaled(buf, X,Y,W,H,D,L); } else { - draw_image_rescale((void*)buf, NULL, X, Y, W, H, D, L, true, scale_); + draw_image_rescale((void*)buf, NULL, X, Y, W, H, D, L, true, scale()); } } void Fl_Scalable_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* data, int X,int Y,int W,int H, int D) { - if (scale_ == 1) { + if (scale() == 1) { draw_image_mono_unscaled(cb, data, X,Y,W,H,D); } else { - draw_image_rescale(data, cb, X, Y, W, H, D, 0, true, scale_); + draw_image_rescale(data, cb, X, Y, W, H, D, 0, true, scale()); } } void Fl_Scalable_Graphics_Driver::transformed_vertex(double xf, double yf) { - transformed_vertex0(xf * scale_, yf * scale_); + transformed_vertex0(xf * scale(), yf * scale()); } void Fl_Scalable_Graphics_Driver::vertex(double x,double y) { - transformed_vertex0((x*m.a + y*m.c + m.x) * scale_, (x*m.b + y*m.d + m.y) * scale_); + transformed_vertex0((x*m.a + y*m.c + m.x) * scale(), (x*m.b + y*m.d + m.y) * scale()); } void Fl_Scalable_Graphics_Driver::unscale_clip(Fl_Region r) { diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H index a4225d82d..7b4e76c81 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.H +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.H @@ -94,6 +94,7 @@ public: void untranslate_all(void); static HRGN scale_region(HRGN r, float f, Fl_GDI_Graphics_Driver *dr); virtual void scale(float f); + float scale() {return Fl_Graphics_Driver::scale();} protected: void transformed_vertex0(float x, float y); void fixloop(); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx index a07e97313..20d129e75 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver.cxx @@ -109,7 +109,7 @@ void Fl_GDI_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offsc HDC new_gc = CreateCompatibleDC(gc_); int save = SaveDC(new_gc); SelectObject(new_gc, bitmap); - BitBlt(gc_, x*scale_, y*scale_, w*scale_, h*scale_, new_gc, srcx*scale_, srcy*scale_, SRCCOPY); + BitBlt(gc_, x*scale(), y*scale(), w*scale(), h*scale(), new_gc, srcx*scale(), srcy*scale(), SRCCOPY); RestoreDC(new_gc, save); DeleteDC(new_gc); } @@ -147,7 +147,7 @@ void Fl_GDI_Graphics_Driver::translate_all(int x, int y) { depth = stack_height - 1; } GetWindowOrgEx((HDC)gc(), origins+depth); - SetWindowOrgEx((HDC)gc(), origins[depth].x - x*scale_, origins[depth].y - y*scale_, NULL); + SetWindowOrgEx((HDC)gc(), origins[depth].x - x*scale(), origins[depth].y - y*scale(), NULL); depth++; } @@ -230,9 +230,9 @@ void Fl_GDI_Graphics_Driver::set_spot(int font, int size, int X, int Y, int W, i void Fl_GDI_Graphics_Driver::scale(float f) { - if (f != scale_) { + if (f != scale()) { size_ = 0; - scale_ = f; + Fl_Graphics_Driver::scale(f); line_style(FL_SOLID); // scale also default line width } } diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx index 3b86650c8..9df0c8a39 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_color.cxx @@ -97,7 +97,7 @@ void Fl_GDI_Graphics_Driver::color(Fl_Color i) { } else { Fl_Graphics_Driver::color(i); Fl_XMap &xmap = fl_xmap[i]; - int tw = line_width_ ? line_width_ : int(scale_); if (!tw) tw = 1; + int tw = line_width_ ? line_width_ : int(scale()); if (!tw) tw = 1; if (!xmap.pen || xmap.pwidth != tw) { #if USE_COLORMAP if (fl_palette) { @@ -119,7 +119,7 @@ void Fl_GDI_Graphics_Driver::color(uchar r, uchar g, uchar b) { static Fl_XMap xmap; COLORREF c = RGB(r,g,b); Fl_Graphics_Driver::color( fl_rgb_color(r, g, b) ); - int tw = line_width_ ? line_width_ : int(scale_); if (!tw) tw = 1; + int tw = line_width_ ? line_width_ : int(scale()); if (!tw) tw = 1; if (!xmap.pen || c != xmap.rgb || tw != xmap.pwidth) { clear_xmap(xmap); set_xmap(xmap, c, tw); diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx index e67df4844..f66adba1e 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_image.cxx @@ -403,10 +403,10 @@ void Fl_GDI_Graphics_Driver::delete_bitmask(Fl_Bitmask bm) { } void Fl_GDI_Graphics_Driver::draw_fixed(Fl_Bitmap *bm, int X, int Y, int W, int H, int cx, int cy) { - X = X*scale_; - Y = Y*scale_; + X = X*scale(); + Y = Y*scale(); cache_size(bm, W, H); - cx *= scale_; cy *= scale_; + cx *= scale(); cy *= scale(); HDC tempdc = CreateCompatibleDC(gc_); int save = SaveDC(tempdc); @@ -504,10 +504,10 @@ void Fl_GDI_Graphics_Driver::cache(Fl_RGB_Image *img) void Fl_GDI_Graphics_Driver::draw_fixed(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, int cy) { - X = X*scale_; - Y = Y*scale_; + X = X*scale(); + Y = Y*scale(); cache_size(img, W, H); - cx *= scale_; cy *= scale_; + cx *= scale(); cy *= scale(); if (W + cx > img->data_w()) W = img->data_w() - cx; if (H + cy > img->data_h()) H = img->data_h() - cy; if (!*Fl_Graphics_Driver::id(img)) { @@ -549,10 +549,10 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP, int save = SaveDC(new_gc); SelectObject(new_gc, (HBITMAP)*Fl_Graphics_Driver::id(rgb)); if ( (rgb->d() % 2) == 0 ) { - alpha_blend_(XP*scale_, YP*scale_, W, H, new_gc, cx*scaleW, cy*scaleH, WP*scaleW, HP*scaleH); + alpha_blend_(XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, WP*scaleW, HP*scaleH); } else { SetStretchBltMode(gc_, HALFTONE); - StretchBlt(gc_, XP*scale_, YP*scale_, W, H, new_gc, cx*scaleW, cy*scaleH, WP*scaleW, HP*scaleH, SRCCOPY); + StretchBlt(gc_, XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, WP*scaleW, HP*scaleH, SRCCOPY); } RestoreDC(new_gc, save); DeleteDC(new_gc); @@ -632,11 +632,11 @@ void Fl_GDI_Graphics_Driver::cache(Fl_Bitmap *bm) { } void Fl_GDI_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int H, int cx, int cy) { - X = X*scale_; - Y = Y*scale_; + X = X*scale(); + Y = Y*scale(); cache_size(pxm, W, H); - cx *= scale_; cy *= scale_; - Fl_Region r2 = scale_clip(scale_); + cx *= scale(); cy *= scale(); + Fl_Region r2 = scale_clip(scale()); if (*Fl_Graphics_Driver::mask(pxm)) { HDC new_gc = CreateCompatibleDC(gc_); int save = SaveDC(new_gc); @@ -647,9 +647,9 @@ void Fl_GDI_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int RestoreDC(new_gc,save); DeleteDC(new_gc); } else { - float s = scale_; scale_ = 1; + float s = scale(); Fl_Graphics_Driver::scale(1); copy_offscreen(X, Y, W, H, (Fl_Offscreen)*Fl_Graphics_Driver::id(pxm), cx, cy); - scale_ = s; + Fl_Graphics_Driver::scale(s); } unscale_clip(r2); } diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx index 91f1a164d..19619e369 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_line_style.cxx @@ -48,7 +48,7 @@ void Fl_GDI_Graphics_Driver::line_style_unscaled(int style, float width, char* d } else { s1 |= style & 0xff; // allow them to pass any low 8 bits for style } - if ((style || n) && !width) width = scale_; // fix cards that do nothing for 0? + if ((style || n) && !width) width = scale(); // fix cards that do nothing for 0? if (!fl_current_xmap) color(FL_BLACK); LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()? int tw = width < 1? 1: width; diff --git a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx index 1dc681f49..5e8f9e1d7 100644 --- a/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx +++ b/src/drivers/GDI/Fl_GDI_Graphics_Driver_rect.cxx @@ -36,7 +36,7 @@ // --- line and polygon drawing with integer coordinates void Fl_GDI_Graphics_Driver::point_unscaled(float fx, float fy) { - int width = scale_ >= 1 ? scale_ : 1; + int width = scale() >= 1 ? scale() : 1; RECT rect; rect.left = fx; rect.top = fy; rect.right = fx + width; rect.bottom = fy + width; @@ -51,7 +51,7 @@ void Fl_GDI_Graphics_Driver::overlay_rect(int x, int y, int w , int h) { void Fl_GDI_Graphics_Driver::rect_unscaled(float x, float y, float w, float h) { if (w<=0 || h<=0) return; - int line_delta_ = (scale_ > 1.9 ? 1 : 0); + int line_delta_ = (scale() > 1.9 ? 1 : 0); x += line_delta_; y += line_delta_; int tw = line_width_ ? line_width_ : 1; // true line width MoveToEx(gc_, x, y, 0L); @@ -94,34 +94,34 @@ void Fl_GDI_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1, } void Fl_GDI_Graphics_Driver::xyline_unscaled(float x, float y, float x1) { - int line_delta_ = (scale_ > 1.75 ? 1 : 0); + int line_delta_ = (scale() > 1.75 ? 1 : 0); int tw = line_width_ ? line_width_ : 1; // true line width if (x > x1) { float exch = x; x = x1; x1 = exch; } - int ix = x+line_delta_; if (scale_ >= 2) ix -= int(scale_/2); + int ix = x+line_delta_; if (scale() >= 2) ix -= int(scale()/2); int iy = y+line_delta_; - if (scale_ > 1.9 && line_width_/scale_ >= 2) iy--; - int ix1 = int(x1/scale_+1.5)*scale_-1; // extend line to pixel before line beginning at x1/scale_ + 1 - ix1 += line_delta_; if (scale_ >= 2) ix1 -= 1;; if (scale_ >= 4) ix1 -= 1; + if (scale() > 1.9 && line_width_/scale() >= 2) iy--; + int ix1 = int(x1/scale()+1.5)*scale()-1; // extend line to pixel before line beginning at x1/scale_ + 1 + ix1 += line_delta_; if (scale() >= 2) ix1 -= 1;; if (scale() >= 4) ix1 -= 1; MoveToEx(gc_, ix, iy, 0L); LineTo(gc_, ix1+1, iy); // try and make sure no unfilled area lies between xyline(x,y,x1) and xyline(x,y+1,x1) - if (int(scale_) != scale_ && y+line_delta_ + scale_ >= iy + tw+1 - 0.001 ) { + if (int(scale()) != scale() && y+line_delta_ + scale() >= iy + tw+1 - 0.001 ) { MoveToEx(gc_, ix, iy+1, 0L); LineTo(gc_, ix1+1, iy+1); } } void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1) { if (y1 < y) { float exch = y; y = y1; y1 = exch;} - int line_delta_ = (scale_ > 1.75 ? 1 : 0); + int line_delta_ = (scale() > 1.75 ? 1 : 0); int tw = line_width_ ? line_width_ : 1; // true line width int ix = x+line_delta_; - if (scale_ > 1.9 && line_width_/scale_ >= 2) ix--; - int iy = y+line_delta_; if (scale_ >= 2) iy -= int(scale_/2); - int iy1 = int(y1/scale_+1.5)*scale_-1; - iy1 += line_delta_; if (scale_ >= 2) iy1 -= 1;; if (scale_ >= 4) iy1 -= 1; // extend line to pixel before line beginning at y1/scale_ + 1 + if (scale() > 1.9 && line_width_/scale() >= 2) ix--; + int iy = y+line_delta_; if (scale() >= 2) iy -= int(scale()/2); + int iy1 = int(y1/scale()+1.5)*scale()-1; + iy1 += line_delta_; if (scale() >= 2) iy1 -= 1;; if (scale() >= 4) iy1 -= 1; // extend line to pixel before line beginning at y1/scale_ + 1 MoveToEx(gc_, ix, iy, 0L); LineTo(gc_, ix, iy1+1); // try and make sure no unfilled area lies between yxline(x,y,y1) and yxline(x+1,y,y1) - if (int(scale_) != scale_ && x+line_delta_+scale_ >= ix + tw+1 -0.001) { + if (int(scale()) != scale() && x+line_delta_+scale() >= ix + tw+1 -0.001) { MoveToEx(gc_, ix+1, iy, 0L); LineTo(gc_, ix+1, iy1+1); } @@ -136,7 +136,7 @@ void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { if (x==x3 && x1==x2 && y==y1 && y3==y2) { // rectangular loop - if (scale_ > 1.9) { x += 1; y += 1; x1 += 1; y1 += 1; x2 += 1; y2 += 1; x3 += 1; y3 += 1;} + if (scale() > 1.9) { x += 1; y += 1; x1 += 1; y1 += 1; x2 += 1; y2 += 1; x3 += 1; y3 += 1;} } MoveToEx(gc_, x, y, 0L); LineTo(gc_, x1, y1); @@ -251,7 +251,7 @@ void Fl_GDI_Graphics_Driver::restore_clip() { fl_clip_state_number++; if (gc_) { HRGN r = NULL; - if (rstack[rstackptr]) r = scale_clip(scale_); + if (rstack[rstackptr]) r = scale_clip(scale()); SelectClipRgn(gc_, rstack[rstackptr]); // if region is NULL, clip is automatically cleared if (r) unscale_clip(r); } diff --git a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx index 698d3d9de..bd0504833 100644 --- a/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx +++ b/src/drivers/Quartz/Fl_Quartz_Graphics_Driver.cxx @@ -102,7 +102,7 @@ void Fl_Quartz_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Of src_bytes, 0L, false, kCGRenderingIntentDefault); CGDataProviderRelease(src_bytes); CGColorSpaceRelease(lut); - float s = scale_; + float s = scale(); Fl_Surface_Device *current = Fl_Surface_Device::surface(); // test whether osrc was created by fl_create_offscreen() fl_begin_offscreen(osrc); // does nothing if osrc was not created by fl_create_offscreen() diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H index 4eeb742f3..584b8114a 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.H @@ -107,6 +107,7 @@ public: void translate_all(int dx, int dy); void untranslate_all(); virtual void scale(float f); + float scale() {return Fl_Graphics_Driver::scale();} virtual int has_feature(driver_feature mask) { return mask & NATIVE; } virtual void *gc() { return gc_; } virtual void gc(void *value); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx index 946f8f8c1..d01d1156b 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver.cxx @@ -77,9 +77,9 @@ void Fl_Xlib_Graphics_Driver::gc(void *value) { void Fl_Xlib_Graphics_Driver::scale(float f) { #if USE_XFT - if (f != scale_) { + if (f != scale()) { size_ = 0; - scale_ = f; + Fl_Graphics_Driver::scale(f); //fprintf(stderr, "scale=%.2f\n", scale_); line_style(FL_SOLID); // scale also default line width /* Scaling >= 2 transforms 1-pixel wide lines into wider lines. @@ -92,13 +92,13 @@ void Fl_Xlib_Graphics_Driver::scale(float f) { Setting line_delta_ to 1 and offsetting all line, rectangle, text and clip coordinates by line_delta_ achieves what is wanted until scale_ <= 3.5. */ - line_delta_ = (scale_ > 1.75 ? 1 : 0); + line_delta_ = (scale() > 1.75 ? 1 : 0); } #endif } void Fl_Xlib_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen pixmap, int srcx, int srcy) { - XCopyArea(fl_display, pixmap, fl_window, gc_, srcx*scale_, srcy*scale_, w*scale_, h*scale_, (x+offset_x_)*scale_, (y+offset_y_)*scale_); + XCopyArea(fl_display, pixmap, fl_window, gc_, srcx*scale(), srcy*scale(), w*scale(), h*scale(), (x+offset_x_)*scale(), (y+offset_y_)*scale()); } diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx index 578c6b5b0..dc35080b3 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_arci.cxx @@ -28,13 +28,13 @@ void Fl_Xlib_Graphics_Driver::arc_unscaled(float x,float y,float w,float h,double a1,double a2) { if (w <= 0 || h <= 0) return; - XDrawArc(fl_display, fl_window, gc_, int(x+offset_x_*scale_), int(y+offset_y_*scale_), int(w-1), int(h-1), int(a1*64),int((a2-a1)*64)); + XDrawArc(fl_display, fl_window, gc_, int(x+offset_x_*scale()), int(y+offset_y_*scale()), int(w-1), int(h-1), int(a1*64),int((a2-a1)*64)); } void Fl_Xlib_Graphics_Driver::pie_unscaled(float x,float y,float w,float h,double a1,double a2) { if (w <= 0 || h <= 0) return; - x += offset_x_*scale_; - y += offset_y_*scale_; + x += offset_x_*scale(); + y += offset_y_*scale(); XDrawArc(fl_display, fl_window, gc_, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); XFillArc(fl_display, fl_window, gc_, x,y,w-1,h-1, int(a1*64),int((a2-a1)*64)); } diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx index e5d62492a..932a0e9ef 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_font_xft.cxx @@ -129,21 +129,21 @@ Fl_Fontsize Fl_Xlib_Graphics_Driver::size_unscaled() { return (Fl_Fontsize)(size_); } -static void correct_extents (float scale_, int &dx, int &dy, int &w, int &h) { - if (int(scale_) == scale_) { // correct for extents non divisible by integral scale_ - int delta = dx - int(dx/scale_)*scale_; +static void correct_extents (float s, int &dx, int &dy, int &w, int &h) { + if (int(s) == s) { // correct for extents non divisible by integral s + int delta = dx - int(dx/s)*s; if (delta) { dx -= delta; w += delta; } - delta = -dy - int((-dy)/scale_)*scale_; + delta = -dy - int((-dy)/s)*s; if (delta) { dy -= delta; h += delta; } - delta = h - int(h/scale_)*scale_; + delta = h - int(h/s)*s; if (delta) { h += delta; } - delta = w - int(w/scale_)*scale_; + delta = w - int(w/s)*s; if (delta) { w += delta; } @@ -778,7 +778,7 @@ void Fl_Xlib_Graphics_Driver::text_extents_unscaled(const char *c, int n, int &d h = gi.height; dx = -gi.x + line_delta_; dy = -gi.y + line_delta_; - correct_extents(scale_, dx, dy, w, h); + correct_extents(scale(), dx, dy, w, h); } void Fl_Xlib_Graphics_Driver::draw_unscaled(const char *str, int n, int x, int y) { @@ -814,9 +814,9 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(const char *str, int n, int x, int y const wchar_t *buffer = utf8reformat(str, n); #ifdef __CYGWIN__ - XftDrawString16(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (XftChar16 *)buffer, n); + XftDrawString16(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale()+line_delta_, y+offset_y_*scale()+line_delta_, (XftChar16 *)buffer, n); #else - XftDrawString32(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (XftChar32 *)buffer, n); + XftDrawString32(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale()+line_delta_, y+offset_y_*scale()+line_delta_, (XftChar32 *)buffer, n); #endif } } @@ -858,7 +858,7 @@ void Fl_Xlib_Graphics_Driver::drawUCS4(const void *str, int n, int x, int y) { color.color.blue = ((int)b)*0x101; color.color.alpha = 0xffff; - XftDrawString32(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, (FcChar32 *)str, n); + XftDrawString32(draw_, &color, ((Fl_Xlib_Font_Descriptor*)font_descriptor())->font, x+offset_x_*scale()+line_delta_, y+offset_y_*scale()+line_delta_, (FcChar32 *)str, n); } @@ -1223,12 +1223,12 @@ void Fl_Xlib_Graphics_Driver::font_unscaled(Fl_Font fnum, Fl_Fontsize size) { } void Fl_Xlib_Graphics_Driver::draw_unscaled(const char *str, int n, int x, int y) { - do_draw(0, str, n, x+offset_x_*scale_, y+offset_y_*scale_); + do_draw(0, str, n, x+offset_x_*scale(), y+offset_y_*scale()); } void Fl_Xlib_Graphics_Driver::draw_unscaled(int angle, const char *str, int n, int x, int y) { PangoMatrix mat = PANGO_MATRIX_INIT; // 1.6 - pango_matrix_translate(&mat, x+offset_x_*scale_, y+offset_y_*scale_); // 1.6 + pango_matrix_translate(&mat, x+offset_x_*scale(), y+offset_y_*scale()); // 1.6 double l = width_unscaled(str, n); pango_matrix_rotate(&mat, angle); // 1.6 pango_context_set_matrix(pctxt_, &mat); // 1.6 @@ -1242,7 +1242,7 @@ void Fl_Xlib_Graphics_Driver::draw_unscaled(int angle, const char *str, int n, i } void Fl_Xlib_Graphics_Driver::rtl_draw_unscaled(const char* str, int n, int x, int y) { - do_draw(1, str, n, x+offset_x_*scale_, y+offset_y_*scale_); + do_draw(1, str, n, x+offset_x_*scale(), y+offset_y_*scale()); } /* Compute dx, dy, w, h so that fl_rect(x+dx, y+dy, w, h) is the bounding box @@ -1332,7 +1332,7 @@ void Fl_Xlib_Graphics_Driver::text_extents_unscaled(const char *str, int n, int int y_correction; fl_pango_layout_get_pixel_extents(playout_, dx, dy, w, h, descent_unscaled(), height_unscaled(), y_correction); dy -= y_correction; - correct_extents(scale_, dx, dy, w, h); + correct_extents(scale(), dx, dy, w, h); } int Fl_Xlib_Graphics_Driver::height_unscaled() { diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx index 80fe2c8ce..05f3bd598 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_image.cxx @@ -582,7 +582,7 @@ void Fl_Xlib_Graphics_Driver::draw_image_unscaled(const uchar* buf, int x, int y if (alpha) d ^= FL_IMAGE_WITH_ALPHA; const int mono = (d>-3 && d<3); - innards(buf,x+offset_x_*scale_,y+offset_y_*scale_,w,h,d,l,mono,0,0,alpha,gc_); + innards(buf,x+offset_x_*scale(),y+offset_y_*scale(),w,h,d,l,mono,0,0,alpha,gc_); } void Fl_Xlib_Graphics_Driver::draw_image_unscaled(Fl_Draw_Image_Cb cb, void* data, @@ -592,16 +592,16 @@ void Fl_Xlib_Graphics_Driver::draw_image_unscaled(Fl_Draw_Image_Cb cb, void* dat if (alpha) d ^= FL_IMAGE_WITH_ALPHA; const int mono = (d>-3 && d<3); - innards(0,x+offset_x_*scale_,y+offset_y_*scale_,w,h,d,0,mono,cb,data,alpha,gc_); + innards(0,x+offset_x_*scale(),y+offset_y_*scale(),w,h,d,0,mono,cb,data,alpha,gc_); } void Fl_Xlib_Graphics_Driver::draw_image_mono_unscaled(const uchar* buf, int x, int y, int w, int h, int d, int l){ - innards(buf,x+offset_x_*scale_,y+offset_y_*scale_,w,h,d,l,1,0,0,0,gc_); + innards(buf,x+offset_x_*scale(),y+offset_y_*scale(),w,h,d,l,1,0,0,0,gc_); } void Fl_Xlib_Graphics_Driver::draw_image_mono_unscaled(Fl_Draw_Image_Cb cb, void* data, int x, int y, int w, int h,int d) { - innards(0,x+offset_x_*scale_,y+offset_y_*scale_,w,h,d,0,1,cb,data,0,gc_); + innards(0,x+offset_x_*scale(),y+offset_y_*scale(),w,h,d,0,1,cb,data,0,gc_); } void fl_rectf(int x, int y, int w, int h, uchar r, uchar g, uchar b) { @@ -625,13 +625,13 @@ void Fl_Xlib_Graphics_Driver::delete_bitmask(Fl_Bitmask bm) { } void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Bitmap *bm, int X, int Y, int W, int H, int cx, int cy) { - X = (X+offset_x_)*scale_; - Y = (Y+offset_y_)*scale_; + X = (X+offset_x_)*scale(); + Y = (Y+offset_y_)*scale(); cache_size(bm, W, H); - cx *= scale_; cy *= scale_; + cx *= scale(); cy *= scale(); XSetStipple(fl_display, gc_, *Fl_Graphics_Driver::id(bm)); - int ox = X-cx; if (ox < 0) ox += bm->w()*scale_; - int oy = Y-cy; if (oy < 0) oy += bm->h()*scale_; + int ox = X-cx; if (ox < 0) ox += bm->w()*scale(); + int oy = Y-cy; if (oy < 0) oy += bm->h()*scale(); XSetTSOrigin(fl_display, gc_, ox, oy); XSetFillStyle(fl_display, gc_, FillStippled); XFillRectangle(fl_display, fl_window, gc_, X, Y, W, H); @@ -723,17 +723,17 @@ void Fl_Xlib_Graphics_Driver::cache(Fl_RGB_Image *img) { void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_RGB_Image *img, int X, int Y, int W, int H, int cx, int cy) { - X = (X+offset_x_)*scale_; - Y = (Y+offset_y_)*scale_; + X = (X+offset_x_)*scale(); + Y = (Y+offset_y_)*scale(); cache_size(img, W, H); - cx *= scale_; cy *= scale_; + cx *= scale(); cy *= scale(); if (img->d() == 1 || img->d() == 3) { XCopyArea(fl_display, *Fl_Graphics_Driver::id(img), fl_window, gc_, cx, cy, W, H, X, Y); return; } // Composite image with alpha manually each time... - float s = scale_; - scale_ = 1; + float s = scale(); + Fl_Graphics_Driver::scale(1); int ox = offset_x_, oy = offset_y_; offset_x_ = offset_y_ = 0; Fl_X11_Screen_Driver *d = (Fl_X11_Screen_Driver*)Fl::screen_driver(); @@ -744,7 +744,7 @@ void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_RGB_Image *img, int X, int Y, int W, alpha_blend(img, X, Y, W, H, cx, cy); pop_clip(); d->scale(nscreen, keep); - scale_ = s; + Fl_Graphics_Driver::scale(s); offset_x_ = ox; offset_y_ = oy; } @@ -764,8 +764,8 @@ void Fl_Xlib_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP } cache_size(rgb, W, H); scale_and_render_pixmap( *Fl_Graphics_Driver::id(rgb), rgb->d(), - rgb->data_w() / double(rgb->w()*scale_), rgb->data_h() / double(rgb->h()*scale_), - cx*scale_, cy*scale_, (X + offset_x_)*scale_, (Y + offset_y_)*scale_, W, H); + rgb->data_w() / double(rgb->w()*scale()), rgb->data_h() / double(rgb->h()*scale()), + cx*scale(), cy*scale(), (X + offset_x_)*scale(), (Y + offset_y_)*scale(), W, H); } /* Draws with Xrender an Fl_Offscreen with optional scaling and accounting for transparency if necessary. @@ -783,7 +783,7 @@ int Fl_Xlib_Graphics_Driver::scale_and_render_pixmap(Fl_Offscreen pixmap, int de fprintf(stderr, "Failed to create Render pictures (%lu %lu)\n", src, dst); return 0; } - Fl_Region r = scale_clip(scale_); + Fl_Region r = scale_clip(scale()); const Fl_Region clipr = clip_region(); if (clipr) XRenderSetPictureClipRegion(fl_display, dst, clipr); @@ -822,11 +822,11 @@ void Fl_Xlib_Graphics_Driver::cache(Fl_Bitmap *bm) { } void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, int H, int cx, int cy) { - X = (X+offset_x_)*scale_; - Y = (Y+offset_y_)*scale_; + X = (X+offset_x_)*scale(); + Y = (Y+offset_y_)*scale(); cache_size(pxm, W, H); - cx *= scale_; cy *= scale_; - Fl_Region r2 = scale_clip(scale_); + cx *= scale(); cy *= scale(); + Fl_Region r2 = scale_clip(scale()); if (*Fl_Graphics_Driver::mask(pxm)) { // make X use the bitmap as a mask: XSetClipMask(fl_display, gc_, *Fl_Graphics_Driver::mask(pxm)); @@ -857,9 +857,9 @@ void Fl_Xlib_Graphics_Driver::draw_fixed(Fl_Pixmap *pxm, int X, int Y, int W, in } // put the old clip region back XSetClipOrigin(fl_display, gc_, 0, 0); - float s = scale_; scale_ = 1; + float s = scale(); Fl_Graphics_Driver::scale(1); restore_clip(); - scale_ = s; + Fl_Graphics_Driver::scale(s); } else XCopyArea(fl_display, *Fl_Graphics_Driver::id(pxm), fl_window, gc_, cx, cy, W, H, X, Y); unscale_clip(r2); diff --git a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx index 7ba5490b5..1d6e2752f 100644 --- a/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx +++ b/src/drivers/Xlib/Fl_Xlib_Graphics_Driver_rect.cxx @@ -214,8 +214,8 @@ void Fl_Xlib_Graphics_Driver::XDestroyRegion(Fl_Region r) { // called only when scale_ has integer value void Fl_Xlib_Graphics_Driver::rect_unscaled(float fx, float fy, float fw, float fh) { if (fw<=0 || fh<=0) return; - int deltaf = scale_ >= 2 ? scale_-1 : 0; - fx += offset_x_*scale_; fy += offset_y_*scale_; + int deltaf = scale() >= 2 ? scale()-1 : 0; + fx += offset_x_*scale(); fy += offset_y_*scale(); int x = fx; int y = fy; int w = int(fw) - 1 - deltaf; int h = int(fh) - 1 - deltaf; @@ -225,21 +225,21 @@ void Fl_Xlib_Graphics_Driver::rect_unscaled(float fx, float fy, float fw, float void Fl_Xlib_Graphics_Driver::rectf_unscaled(float fx, float fy, float fw, float fh) { if (fw<=0 || fh<=0) return; - int deltaf = scale_ >= 2 ? scale_/2 : 0; - fx += offset_x_*scale_; fy += offset_y_*scale_; + int deltaf = scale() >= 2 ? scale()/2 : 0; + fx += offset_x_*scale(); fy += offset_y_*scale(); int x = fx-deltaf; int y = fy-deltaf; // make sure no unfilled area lies between rectf(x,y,w,h) and rectf(x+w,y,1,h) or rectf(x,y+w,w,1) - int w = int(int(fx/scale_+fw/scale_+0.5)*scale_) - int(fx); - int h = int(int(fy/scale_+fh/scale_+0.5)*scale_) - int(fy); + int w = int(int(fx/scale()+fw/scale()+0.5)*scale()) - int(fx); + int h = int(int(fy/scale()+fh/scale()+0.5)*scale()) - int(fy); if (!clip_rect(x, y, w, h)) XFillRectangle(fl_display, fl_window, gc_, x+line_delta_, y+line_delta_, w, h); } void Fl_Xlib_Graphics_Driver::point_unscaled(float fx, float fy) { - int deltaf = scale_ >= 2 ? scale_/2 : 0; - int x = fx+offset_x_*scale_-deltaf; - int y = fy+offset_y_*scale_-deltaf; - int width = scale_ >= 1 ? scale_ : 1; + int deltaf = scale() >= 2 ? scale()/2 : 0; + int x = fx+offset_x_*scale()-deltaf; + int y = fy+offset_y_*scale()-deltaf; + int width = scale() >= 1 ? scale() : 1; // *FIXME* This needs X coordinate clipping: XFillRectangle(fl_display, fl_window, gc_, x+line_delta_, y+line_delta_, width, width); } @@ -247,75 +247,75 @@ void Fl_Xlib_Graphics_Driver::point_unscaled(float fx, float fy) { void Fl_Xlib_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1) { if (x == x1) yxline_unscaled(x, y, y1); else if (y == y1) xyline_unscaled(x, y, x1); - else draw_clipped_line(x+offset_x_*scale_+line_delta_, y+offset_y_*scale_+line_delta_, x1+offset_x_*scale_+line_delta_, y1+offset_y_*scale_+line_delta_); + else draw_clipped_line(x+offset_x_*scale()+line_delta_, y+offset_y_*scale()+line_delta_, x1+offset_x_*scale()+line_delta_, y1+offset_y_*scale()+line_delta_); } void Fl_Xlib_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1, float x2, float y2) { XPoint p[3]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1+offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1+offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XDrawLines(fl_display, fl_window, gc_, p, 3, 0); } void Fl_Xlib_Graphics_Driver::xyline_unscaled(float x, float y, float x1) { - x+=offset_x_*scale_; y+=offset_y_*scale_; x1 += offset_x_*scale_; + x+=offset_x_*scale(); y+=offset_y_*scale(); x1 += offset_x_*scale(); int tw = line_width_ ? line_width_ : 1; // true line width if (x > x1) { float exch = x; x = x1; x1 = exch; } - int ix = clip_xy(x+line_delta_); if (scale_ >= 2) ix -= int(scale_/2); + int ix = clip_xy(x+line_delta_); if (scale() >= 2) ix -= int(scale()/2); int iy = clip_xy(y+line_delta_); // make sure that line output by xyline(a,b,c) extends to pixel just at left of where xyline(c+1,b,d) begins - int ix1 = int(x1/scale_+1.5)*scale_-1; - ix1 += line_delta_; if (scale_ >= 4) ix1 -= 1; + int ix1 = int(x1/scale()+1.5)*scale()-1; + ix1 += line_delta_; if (scale() >= 4) ix1 -= 1; draw_clipped_line(ix, iy, ix1, iy); // make sure no unfilled area lies between xyline(x,y,x1) and xyline(x,y+1,x1) - if (y+line_delta_ + scale_ >= iy + tw+1 - 0.001 ) + if (y+line_delta_ + scale() >= iy + tw+1 - 0.001 ) draw_clipped_line(ix, iy+1, ix1, iy+1); } void Fl_Xlib_Graphics_Driver::yxline_unscaled(float x, float y, float y1) { - x+=offset_x_*scale_; y+=offset_y_*scale_; y1 += offset_y_*scale_; + x+=offset_x_*scale(); y+=offset_y_*scale(); y1 += offset_y_*scale(); int tw = line_width_ ? line_width_ : 1; // true line width if (y > y1) { float exch = y; y = y1; y1 = exch; } int ix = clip_xy(x+line_delta_); - int iy = clip_xy(y+line_delta_); if (scale_ >= 2) iy -= int(scale_/2); - int iy1 = int(y1/scale_+1.5)*scale_-1; + int iy = clip_xy(y+line_delta_); if (scale() >= 2) iy -= int(scale()/2); + int iy1 = int(y1/scale()+1.5)*scale()-1; // make sure that line output by yxline(a,b,c) extends to pixel just above where yxline(a,c+1,d) begins - iy1 += line_delta_; if (scale_ >= 4) iy1 -= 1; + iy1 += line_delta_; if (scale() >= 4) iy1 -= 1; draw_clipped_line(ix, iy, ix, iy1); // make sure no unfilled area lies between yxline(x,y,y1) and yxline(x+1,y,y1) - if (x+line_delta_+scale_ >= ix + tw+1 -0.001) + if (x+line_delta_+scale() >= ix + tw+1 -0.001) draw_clipped_line(ix+1, iy, ix+1, iy1); } void Fl_Xlib_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2) { XPoint p[4]; - p[0].x = x +offset_x_*scale_+line_delta_; p[0].y = y +offset_y_*scale_+line_delta_; - p[1].x = x1 +offset_x_*scale_+line_delta_; p[1].y = y1 +offset_y_*scale_+line_delta_; - p[2].x = x2 +offset_x_*scale_+line_delta_; p[2].y = y2 +offset_y_*scale_+line_delta_; - p[3].x = x +offset_x_*scale_+line_delta_; p[3].y = y +offset_y_*scale_+line_delta_; + p[0].x = x +offset_x_*scale()+line_delta_; p[0].y = y +offset_y_*scale()+line_delta_; + p[1].x = x1 +offset_x_*scale()+line_delta_; p[1].y = y1 +offset_y_*scale()+line_delta_; + p[2].x = x2 +offset_x_*scale()+line_delta_; p[2].y = y2 +offset_y_*scale()+line_delta_; + p[3].x = x +offset_x_*scale()+line_delta_; p[3].y = y +offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XDrawLines(fl_display, fl_window, gc_, p, 4, 0); } void Fl_Xlib_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { XPoint p[5]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1 +offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; - p[3].x = x3+offset_x_*scale_+line_delta_; p[3].y = y3+offset_y_*scale_+line_delta_; - p[4].x = x+offset_x_*scale_+line_delta_; p[4].y = y+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1 +offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; + p[3].x = x3+offset_x_*scale()+line_delta_; p[3].y = y3+offset_y_*scale()+line_delta_; + p[4].x = x+offset_x_*scale()+line_delta_; p[4].y = y+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XDrawLines(fl_display, fl_window, gc_, p, 5, 0); } void Fl_Xlib_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2) { XPoint p[4]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1+offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; - p[3].x = x+offset_x_*scale_+line_delta_; p[3].y = y+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1+offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; + p[3].x = x+offset_x_*scale()+line_delta_; p[3].y = y+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XFillPolygon(fl_display, fl_window, gc_, p, 3, Convex, 0); XDrawLines(fl_display, fl_window, gc_, p, 4, 0); @@ -323,11 +323,11 @@ void Fl_Xlib_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float void Fl_Xlib_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { XPoint p[5]; - p[0].x = x+offset_x_*scale_+line_delta_; p[0].y = y+offset_y_*scale_+line_delta_; - p[1].x = x1+offset_x_*scale_+line_delta_; p[1].y = y1+offset_y_*scale_+line_delta_; - p[2].x = x2+offset_x_*scale_+line_delta_; p[2].y = y2+offset_y_*scale_+line_delta_; - p[3].x = x3+offset_x_*scale_+line_delta_; p[3].y = y3+offset_y_*scale_+line_delta_; - p[4].x = x+offset_x_*scale_+line_delta_; p[4].y = y+offset_y_*scale_+line_delta_; + p[0].x = x+offset_x_*scale()+line_delta_; p[0].y = y+offset_y_*scale()+line_delta_; + p[1].x = x1+offset_x_*scale()+line_delta_; p[1].y = y1+offset_y_*scale()+line_delta_; + p[2].x = x2+offset_x_*scale()+line_delta_; p[2].y = y2+offset_y_*scale()+line_delta_; + p[3].x = x3+offset_x_*scale()+line_delta_; p[3].y = y3+offset_y_*scale()+line_delta_; + p[4].x = x+offset_x_*scale()+line_delta_; p[4].y = y+offset_y_*scale()+line_delta_; // *FIXME* This needs X coordinate clipping! XFillPolygon(fl_display, fl_window, gc_, p, 4, Convex, 0); XDrawLines(fl_display, fl_window, gc_, p, 5, 0); @@ -418,7 +418,7 @@ void Fl_Xlib_Graphics_Driver::restore_clip() { if (gc_) { Region r = rstack[rstackptr]; if (r) { - Region r2 = scale_clip(scale_); + Region r2 = scale_clip(scale()); XSetRegion(fl_display, gc_, rstack[rstackptr]); unscale_clip(r2); } -- cgit v1.2.3