Remove compilation warnings issued by Visual Studio 2019.

This commit is contained in:
ManoloFLTK 2021-02-13 21:12:52 +01:00
parent 5ade8fcb09
commit 9fad601401
23 changed files with 205 additions and 201 deletions

View File

@ -102,8 +102,8 @@ void Fl_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen
int px = srcx, py = srcy, pw = w, ph = h; int px = srcx, py = srcy, pw = w, ph = h;
if (px < 0) {px = 0; pw += srcx; x -= srcx;} if (px < 0) {px = 0; pw += srcx; x -= srcx;}
if (py < 0) {py = 0; ph += srcy; y -= srcy;} if (py < 0) {py = 0; ph += srcy; y -= srcy;}
if (px + pw > px_width/s) {pw = px_width/s - px;} if (px + pw > px_width/s) {pw = int(px_width/s) - px;}
if (py + ph > px_height/s) {ph = px_height/s - py;} if (py + ph > px_height/s) {ph = int(px_height/s) - py;}
uchar *img = fl_read_image(NULL, px, py, pw, ph, 0); uchar *img = fl_read_image(NULL, px, py, pw, ph, 0);
if (surface) { if (surface) {
Fl_Surface_Device::pop_current(); Fl_Surface_Device::pop_current();
@ -751,7 +751,7 @@ void Fl_Scalable_Graphics_Driver::circle(double x, double y, double r) {
void Fl_Scalable_Graphics_Driver::font(Fl_Font face, Fl_Fontsize size) { 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_ if (!font_descriptor()) fl_open_display(); // to catch the correct initial value of scale_
font_unscaled(face, size * scale()); font_unscaled(face, Fl_Fontsize(size * scale()));
} }
double Fl_Scalable_Graphics_Driver::width(const char *str, int n) { double Fl_Scalable_Graphics_Driver::width(const char *str, int n) {
@ -764,15 +764,15 @@ double Fl_Scalable_Graphics_Driver::width(unsigned int c) {
Fl_Fontsize Fl_Scalable_Graphics_Driver::size() { Fl_Fontsize Fl_Scalable_Graphics_Driver::size() {
if (!font_descriptor() ) return -1; if (!font_descriptor() ) return -1;
return size_unscaled()/scale(); return Fl_Fontsize(size_unscaled()/scale());
} }
void Fl_Scalable_Graphics_Driver::text_extents(const char *str, int n, int &dx, int &dy, int &w, int &h) { 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); text_extents_unscaled(str, n, dx, dy, w, h);
dx /= scale(); dx = int(dx / scale());
dy /= scale(); dy = int(dy / scale());
w /= scale(); w = int(w / scale());
h /= scale(); h = int(h / scale());
} }
int Fl_Scalable_Graphics_Driver::height() { int Fl_Scalable_Graphics_Driver::height() {
@ -780,25 +780,25 @@ int Fl_Scalable_Graphics_Driver::height() {
} }
int Fl_Scalable_Graphics_Driver::descent() { int Fl_Scalable_Graphics_Driver::descent() {
return descent_unscaled()/scale(); return int(descent_unscaled()/scale());
} }
void Fl_Scalable_Graphics_Driver::draw(const char *str, int n, int x, int y) { 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); if (!size_ || !font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
Fl_Region r2 = scale_clip(scale()); Fl_Region r2 = scale_clip(scale());
draw_unscaled(str, n, x*scale(), y*scale()); draw_unscaled(str, n, int(x*scale()), int(y*scale()));
unscale_clip(r2); unscale_clip(r2);
} }
void Fl_Scalable_Graphics_Driver::draw(int angle, const char *str, int n, int x, int y) { 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); if (!size_ || !font_descriptor()) font(FL_HELVETICA, FL_NORMAL_SIZE);
Fl_Region r2 = scale_clip(scale()); Fl_Region r2 = scale_clip(scale());
draw_unscaled(angle, str, n, x*scale(), y*scale()); draw_unscaled(angle, str, n, int(x*scale()), int(y*scale()));
unscale_clip(r2); unscale_clip(r2);
} }
void Fl_Scalable_Graphics_Driver::rtl_draw(const char* str, int n, int x, int y) { 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, int(x * scale()), int(y * scale()));
} }
void Fl_Scalable_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) { void Fl_Scalable_Graphics_Driver::arc(int x,int y,int w,int h,double a1,double a2) {
@ -810,9 +810,9 @@ void Fl_Scalable_Graphics_Driver::pie(int x,int y,int w,int h,double a1,double a
} }
void Fl_Scalable_Graphics_Driver::line_style(int style, int width, char* dashes) { void Fl_Scalable_Graphics_Driver::line_style(int style, int width, char* dashes) {
if (width == 0) line_width_ = scale() < 2 ? 0 : scale(); if (width == 0) line_width_ = int(scale() < 2 ? 0 : scale());
else line_width_ = width>0 ? width*scale() : -width*scale(); else line_width_ = int(width>0 ? width*scale() : -width*scale());
line_style_unscaled(style, line_width_, dashes); line_style_unscaled(style, float(line_width_), dashes);
} }
/* read the image data from a pointer or with a callback, scale it, and draw it */ /* read the image data from a pointer or with a callback, scale it, and draw it */
@ -840,12 +840,12 @@ void Fl_Scalable_Graphics_Driver::draw_image_rescale(void *buf, Fl_Draw_Image_Cb
rgb->alloc_array = 1; rgb->alloc_array = 1;
Fl_RGB_Scaling keep = Fl_Image::RGB_scaling(); Fl_RGB_Scaling keep = Fl_Image::RGB_scaling();
Fl_Image::RGB_scaling(Fl_Image::scaling_algorithm()); Fl_Image::RGB_scaling(Fl_Image::scaling_algorithm());
Fl_RGB_Image *scaled_rgb = (Fl_RGB_Image*)rgb->copy(ceil(W * s), ceil(H * s)); Fl_RGB_Image *scaled_rgb = (Fl_RGB_Image*)rgb->copy(int(ceil(W * s)), int(ceil(H * s)));
Fl_Image::RGB_scaling(keep); Fl_Image::RGB_scaling(keep);
delete rgb; delete rgb;
if (scaled_rgb) { if (scaled_rgb) {
Fl_Region r2 = scale_clip(s); Fl_Region r2 = scale_clip(s);
draw_image_unscaled(scaled_rgb->array, X * s, Y * s, scaled_rgb->w(), scaled_rgb->h(), depth); draw_image_unscaled(scaled_rgb->array, int(X * s), int(Y * s), scaled_rgb->w(), scaled_rgb->h(), depth);
unscale_clip(r2); unscale_clip(r2);
delete scaled_rgb; delete scaled_rgb;
} }
@ -884,11 +884,11 @@ void Fl_Scalable_Graphics_Driver::draw_image_mono(Fl_Draw_Image_Cb cb, void* dat
} }
void Fl_Scalable_Graphics_Driver::transformed_vertex(double xf, double yf) { void Fl_Scalable_Graphics_Driver::transformed_vertex(double xf, double yf) {
transformed_vertex0(xf * scale(), yf * scale()); transformed_vertex0(float(xf * scale()), float(yf * scale()));
} }
void Fl_Scalable_Graphics_Driver::vertex(double x,double y) { 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(float((x*m.a + y*m.c + m.x) * scale()), float((x*m.b + y*m.d + m.y) * scale()));
} }
void Fl_Scalable_Graphics_Driver::unscale_clip(Fl_Region r) { void Fl_Scalable_Graphics_Driver::unscale_clip(Fl_Region r) {

View File

@ -1132,7 +1132,7 @@ Fl_Help_View::draw()
utf8l = buf.size() - utf8l; // length of added UTF-8 text utf8l = buf.size() - utf8l; // length of added UTF-8 text
const char *oldptr = ptr; const char *oldptr = ptr;
ptr = strchr(ptr, ';') + 1; ptr = strchr(ptr, ';') + 1;
entity_extra_length += ptr - (oldptr-1) - utf8l; // extra length between html entity and UTF-8 entity_extra_length += int(ptr - (oldptr-1)) - utf8l; // extra length between html entity and UTF-8
} }
if ((fsize + 2) > hh) if ((fsize + 2) > hh)

View File

@ -79,7 +79,7 @@ int Fl_Menu_::item_pathname_(char *name,
if (m->submenu()) { // submenu? descend if (m->submenu()) { // submenu? descend
if (m->flags & FL_SUBMENU_POINTER) { if (m->flags & FL_SUBMENU_POINTER) {
// SUBMENU POINTER? Recurse to descend // SUBMENU POINTER? Recurse to descend
int slen = strlen(name); int slen = (int)strlen(name);
const Fl_Menu_Item *submenu = (const Fl_Menu_Item*)m->user_data(); const Fl_Menu_Item *submenu = (const Fl_Menu_Item*)m->user_data();
if (m->label()) { if (m->label()) {
if (*name) SAFE_STRCAT("/"); if (*name) SAFE_STRCAT("/");

View File

@ -217,7 +217,7 @@ Fl_RGB_Image *Fl_Screen_Driver::traverse_to_gl_subwindows(Fl_Group *g, int x, in
Fl_RGB_Image *img = traverse_to_gl_subwindows(c->as_window(), origin_x - c->x(), Fl_RGB_Image *img = traverse_to_gl_subwindows(c->as_window(), origin_x - c->x(),
origin_y - c->y(), width, height, full_img); origin_y - c->y(), width, height, full_img);
if (img == full_img) continue; if (img == full_img) continue;
write_image_inside(full_img, img, (origin_x - x) * full_img_scale, (origin_y - y) * full_img_scale); write_image_inside(full_img, img, int((origin_x - x) * full_img_scale), int((origin_y - y) * full_img_scale));
delete img; delete img;
} }
} }
@ -360,11 +360,11 @@ void Fl_Screen_Driver::transient_scale_display(float f, int nscreen)
Fl_Screen_Driver *d = Fl::screen_driver(); Fl_Screen_Driver *d = Fl::screen_driver();
float s = d->scale(nscreen); float s = d->scale(nscreen);
if (s > 3) s = 3; // limit the growth of the transient window if (s > 3) s = 3; // limit the growth of the transient window
Fl_Image_Surface *surf = new Fl_Image_Surface(w*s, w*s/2); Fl_Image_Surface *surf = new Fl_Image_Surface(int(w*s), int(w*s/2));
Fl_Surface_Device::push_current(surf); Fl_Surface_Device::push_current(surf);
fl_color(FL_BLACK); fl_color(FL_BLACK);
fl_rectf(-1, -1, w*s+2, w*s+2); fl_rectf(-1, -1, int(w*s)+2, int(w*s)+2);
Fl_Box *b = new Fl_Box(FL_RFLAT_BOX, 0, 0, w*s, w*s/2, ""); Fl_Box *b = new Fl_Box(FL_RFLAT_BOX, 0, 0, int(w*s), int(w*s/2), "");
b->color(FL_WHITE); b->color(FL_WHITE);
surf->draw(b); surf->draw(b);
delete b; delete b;
@ -374,14 +374,14 @@ void Fl_Screen_Driver::transient_scale_display(float f, int nscreen)
//create a window shaped with the rounded box //create a window shaped with the rounded box
int X, Y, W, H; int X, Y, W, H;
Fl::screen_xywh(X, Y, W, H, nscreen); Fl::screen_xywh(X, Y, W, H, nscreen);
w /= d->scale(nscreen)/s; w = int(w / (d->scale(nscreen)/s));
Fl_Window *win = new Fl_Window((X + W/2) -w/2, (Y + H/2) -w/4, w, w/2, 0); Fl_Window *win = new Fl_Window((X + W/2) -w/2, (Y + H/2) -w/4, w, w/2, 0);
b = new Fl_Box(FL_FLAT_BOX, 0, 0, w, w/2, NULL); b = new Fl_Box(FL_FLAT_BOX, 0, 0, w, w/2, NULL);
char str[10]; char str[10];
sprintf(str, "%d %%", int(f * 100 + 0.5)); sprintf(str, "%d %%", int(f * 100 + 0.5));
b->copy_label(str); b->copy_label(str);
b->labelfont(FL_TIMES_BOLD); b->labelfont(FL_TIMES_BOLD);
b->labelsize(30 * s / d->scale(nscreen)); b->labelsize(Fl_Fontsize(30 * s / d->scale(nscreen)));
b->labelcolor(FL_BLACK); b->labelcolor(FL_BLACK);
b->color(Fl_Tooltip::color()); b->color(Fl_Tooltip::color());
win->end(); win->end();
@ -427,9 +427,9 @@ int Fl_Screen_Driver::scale_handler(int event)
#else #else
// scaling factors for the standard GUI // scaling factors for the standard GUI
static float scaling_values[] = { static float scaling_values[] = {
0.5, 2.f/3, 0.8, 0.9, 1.0, 0.5f, 2.f/3, 0.8f, 0.9f, 1.0f,
1.1, 1.2, 4.f/3, 1.5, 1.7, 1.1f, 1.2f, 4.f/3, 1.5f, 1.7f,
2.0, 2.4, 3.0}; 2.0f, 2.4f, 3.0f};
#endif #endif
float f, old_f = screen_dr->scale(screen)/initial_scale; float f, old_f = screen_dr->scale(screen)/initial_scale;
if (key == '0' || key == 0xE0) f = 1; if (key == '0' || key == 0xE0) f = 1;

View File

@ -512,7 +512,7 @@ void Fl_Simple_Terminal::append(const char *s, int len) {
// Remove ansi codes and adjust style buffer accordingly. // Remove ansi codes and adjust style buffer accordingly.
if ( ansi() ) { if ( ansi() ) {
int nstyles = stable_size_ / STE_SIZE; int nstyles = stable_size_ / STE_SIZE;
if ( len < 0 ) len = strlen(s); if ( len < 0 ) len = (int)strlen(s);
// New text buffer (after ansi codes parsed+removed) // New text buffer (after ansi codes parsed+removed)
char *ntm = (char*)malloc(len+1); // new text memory char *ntm = (char*)malloc(len+1); // new text memory
char *ntp = ntm; char *ntp = ntm;

View File

@ -357,10 +357,10 @@ unsigned Fl_System_Driver::utf8to_mb(const char* src, unsigned srclen, char* dst
fl_utf8towc(src, srclen, buf, length+1); fl_utf8towc(src, srclen, buf, length+1);
} }
if (dstlen) { if (dstlen) {
ret = wcstombs(dst, buf, dstlen); ret = (int)wcstombs(dst, buf, dstlen);
if (ret >= (int)dstlen-1) ret = wcstombs(0,buf,0); if (ret >= (int)dstlen-1) ret = (int)wcstombs(0,buf,0);
} else { } else {
ret = wcstombs(0,buf,0); ret = (int)wcstombs(0,buf,0);
} }
if (buf != lbuf) free(buf); if (buf != lbuf) free(buf);
if (ret >= 0) return (unsigned)ret; if (ret >= 0) return (unsigned)ret;
@ -379,9 +379,9 @@ unsigned Fl_System_Driver::utf8from_mb(char* dst, unsigned dstlen, const char* s
wchar_t* buf = lbuf; wchar_t* buf = lbuf;
int length; int length;
unsigned ret; unsigned ret;
length = mbstowcs(buf, src, 1024); length = (int)mbstowcs(buf, src, 1024);
if (length >= 1024) { if (length >= 1024) {
length = mbstowcs(0, src, 0)+1; length = (int)mbstowcs(0, src, 0)+1;
buf = (wchar_t*)(malloc(length*sizeof(wchar_t))); buf = (wchar_t*)(malloc(length*sizeof(wchar_t)));
mbstowcs(buf, src, length); mbstowcs(buf, src, length);
} }

View File

@ -2045,7 +2045,7 @@ int Fl_Text_Display::handle_vline(
w = ((int(xAbs/tab)+1)*tab) - xAbs; w = ((int(xAbs/tab)+1)*tab) - xAbs;
styleX = startX+w; startStyle = i; styleX = startX+w; startStyle = i;
if (mode==DRAW_LINE) if (mode==DRAW_LINE)
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 ); draw_string( style|BG_ONLY_MASK, int(startX), Y, int(startX+w), 0, 0 );
if (mode==FIND_INDEX && startX+w>rightClip) { if (mode==FIND_INDEX && startX+w>rightClip) {
// find x pos inside block // find x pos inside block
free(lineStr); free(lineStr);
@ -2062,21 +2062,21 @@ int Fl_Text_Display::handle_vline(
} }
if (mode==DRAW_LINE) { if (mode==DRAW_LINE) {
if (startIndex!=startStyle) { if (startIndex!=startStyle) {
fl_push_clip(startX, Y, w+1, mMaxsize); fl_push_clip(int(startX), Y, int(w)+1, mMaxsize);
draw_string( style, styleX, Y, startX+w, lineStr+startStyle, i-startStyle ); draw_string( style, int(styleX), Y, int(startX+w), lineStr+startStyle, i-startStyle );
fl_pop_clip(); fl_pop_clip();
} else { } else {
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex ); draw_string( style, int(startX), Y, int(startX+w), lineStr+startIndex, i-startIndex );
} }
} }
if (mode==FIND_INDEX && startX+w>rightClip) { if (mode==FIND_INDEX && startX+w>rightClip) {
// find x pos inside block // find x pos inside block
int di; int di;
if (startIndex!=startStyle) { if (startIndex!=startStyle) {
di = find_x(lineStr+startStyle, i-startStyle, style, -(rightClip-styleX)); // STR #2788 di = find_x(lineStr+startStyle, i-startStyle, style, -int(rightClip-styleX)); // STR #2788
di = lineStartPos + startStyle + di; di = lineStartPos + startStyle + di;
} else { } else {
di = find_x(lineStr+startIndex, i-startIndex, style, -(rightClip-startX)); // STR #2788 di = find_x(lineStr+startIndex, i-startIndex, style, -int(rightClip-startX)); // STR #2788
di = lineStartPos + startIndex + di; di = lineStartPos + startIndex + di;
} }
free(lineStr); free(lineStr);
@ -2102,7 +2102,7 @@ int Fl_Text_Display::handle_vline(
double xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x; double xAbs = (mode==GET_WIDTH) ? startX : startX+mHorizOffset-text_area.x;
w = ((int(xAbs/tab)+1)*tab) - xAbs; w = ((int(xAbs/tab)+1)*tab) - xAbs;
if (mode==DRAW_LINE) if (mode==DRAW_LINE)
draw_string( style|BG_ONLY_MASK, startX, Y, startX+w, 0, 0 ); draw_string( style|BG_ONLY_MASK, int(startX), Y, int(startX+w), 0, 0 );
if (mode==FIND_INDEX) { if (mode==FIND_INDEX) {
// find x pos inside block // find x pos inside block
free(lineStr); free(lineStr);
@ -2115,21 +2115,21 @@ int Fl_Text_Display::handle_vline(
if (mode==DRAW_LINE) { if (mode==DRAW_LINE) {
// STR 2531 // STR 2531
if (startIndex!=startStyle) { if (startIndex!=startStyle) {
fl_push_clip(startX, Y, w+1, mMaxsize); fl_push_clip(int(startX), Y, int(w)+1, mMaxsize);
draw_string( style, styleX, Y, startX+w, lineStr+startStyle, i-startStyle ); draw_string( style, int(styleX), Y, int(startX+w), lineStr+startStyle, i-startStyle );
fl_pop_clip(); fl_pop_clip();
} else { } else {
draw_string( style, startX, Y, startX+w, lineStr+startIndex, i-startIndex ); draw_string( style, int(startX), Y, int(startX+w), lineStr+startIndex, i-startIndex );
} }
} }
if (mode==FIND_INDEX) { if (mode==FIND_INDEX) {
// find x pos inside block // find x pos inside block
int di; int di;
if (startIndex!=startStyle) { if (startIndex!=startStyle) {
di = find_x(lineStr+startStyle, i-startStyle, style, -(rightClip-styleX)); // STR #2788 di = find_x(lineStr+startStyle, i-startStyle, style, -int(rightClip-styleX)); // STR #2788
di = lineStartPos + startStyle + di; di = lineStartPos + startStyle + di;
} else { } else {
di = find_x(lineStr+startIndex, i-startIndex, style, -(rightClip-startX)); // STR #2788 di = find_x(lineStr+startIndex, i-startIndex, style, -int(rightClip-startX)); // STR #2788
di = lineStartPos + startIndex + di; di = lineStartPos + startIndex + di;
} }
free(lineStr); free(lineStr);
@ -2139,14 +2139,14 @@ int Fl_Text_Display::handle_vline(
} }
if (mode==GET_WIDTH) { if (mode==GET_WIDTH) {
free(lineStr); free(lineStr);
return startX+w; return int(startX+w);
} }
// clear the rest of the line // clear the rest of the line
startX += w; startX += w;
style = position_style(lineStartPos, lineLen, i); style = position_style(lineStartPos, lineLen, i);
if (mode==DRAW_LINE) if (mode==DRAW_LINE)
draw_string( style|BG_ONLY_MASK, startX, Y, text_area.x+text_area.w, lineStr, lineLen ); draw_string( style|BG_ONLY_MASK, int(startX), Y, text_area.x+text_area.w, lineStr, lineLen );
free(lineStr); free(lineStr);
IS_UTF8_ALIGNED2(buffer(), (lineStartPos+lineLen)) IS_UTF8_ALIGNED2(buffer(), (lineStartPos+lineLen))

View File

@ -239,10 +239,10 @@ bool Fl_Window_Driver::is_a_rescale_ = false;
void Fl_Window_Driver::resize_after_scale_change(int ns, float old_f, float new_f) { void Fl_Window_Driver::resize_after_scale_change(int ns, float old_f, float new_f) {
screen_num(ns); screen_num(ns);
Fl_Graphics_Driver::default_driver().scale(new_f); Fl_Graphics_Driver::default_driver().scale(new_f);
int X = pWindow->x()*old_f/new_f, Y = pWindow->y()*old_f/new_f; int X = int(pWindow->x() * old_f / new_f), Y = int(pWindow->y() * old_f / new_f);
int W, H; int W, H;
if (pWindow->fullscreen_active()) { if (pWindow->fullscreen_active()) {
W = pWindow->w() * old_f/new_f; H = pWindow->h() * old_f/new_f; W = int(pWindow->w() * old_f / new_f); H = int(pWindow->h() * old_f / new_f);
} else { } else {
W = pWindow->w(); H = pWindow->h(); W = pWindow->w(); H = pWindow->h();
int sX, sY, sW, sH; int sX, sY, sW, sH;

View File

@ -573,9 +573,9 @@ void Fl_WinAPI_Screen_Driver::desktop_scale_factor() {
UINT dpiX, dpiY; UINT dpiX, dpiY;
HRESULT r = fl_GetDpiForMonitor ? fl_GetDpiForMonitor(hm, 0, &dpiX, &dpiY) : !S_OK; HRESULT r = fl_GetDpiForMonitor ? fl_GetDpiForMonitor(hm, 0, &dpiX, &dpiY) : !S_OK;
if (r != S_OK) { dpiX = dpiY = 96; } if (r != S_OK) { dpiX = dpiY = 96; }
dpi[ns][0] = dpiX; dpi[ns][0] = float(dpiX);
dpi[ns][1] = dpiY; dpi[ns][1] = float(dpiY);
scale(ns, dpiX / 96.); scale(ns, dpiX / 96.f);
//fprintf(LOG, "desktop_scale_factor ns=%d factor=%.2f dpi=%.1f\n", ns, scale(ns), dpi[ns][0]); //fprintf(LOG, "desktop_scale_factor ns=%d factor=%.2f dpi=%.1f\n", ns, scale(ns), dpi[ns][0]);
} }
} }
@ -639,8 +639,8 @@ int Fl_WinAPI_Screen_Driver::get_mouse_unscaled(int &mx, int &my) {
int Fl_WinAPI_Screen_Driver::get_mouse(int &x, int &y) { int Fl_WinAPI_Screen_Driver::get_mouse(int &x, int &y) {
int n = get_mouse_unscaled(x, y); int n = get_mouse_unscaled(x, y);
float s = scale(n); float s = scale(n);
x = x / s; x = int(x / s);
y = y / s; y = int(y / s);
return n; return n;
} }
@ -887,8 +887,8 @@ void Fl_WinAPI_System_Driver::paste(Fl_Widget &receiver, int clipboard, const ch
Fl_Surface_Device::push_current(surf); Fl_Surface_Device::push_current(surf);
fl_color(FL_WHITE); // draw white background fl_color(FL_WHITE); // draw white background
fl_rectf(0, 0, width, height); fl_rectf(0, 0, width, height);
rect.right *= scaling; // apply scaling to the metafile draw operation rect.right = LONG(rect.right * scaling); // apply scaling to the metafile draw operation
rect.bottom *= scaling; rect.bottom = LONG(rect.bottom * scaling);
PlayEnhMetaFile((HDC)fl_graphics_driver->gc(), (HENHMETAFILE)h, &rect); // draw metafile to offscreen buffer PlayEnhMetaFile((HDC)fl_graphics_driver->gc(), (HENHMETAFILE)h, &rect); // draw metafile to offscreen buffer
image = surf->image(); image = surf->image();
Fl_Surface_Device::pop_current(); Fl_Surface_Device::pop_current();
@ -1013,11 +1013,11 @@ static int mouse_event(Fl_Window *window, int what, int button,
float scale = Fl::screen_driver()->scale(window->screen_num()); float scale = Fl::screen_driver()->scale(window->screen_num());
Fl::e_x = pt.x = (signed short)LOWORD(lParam); Fl::e_x = pt.x = (signed short)LOWORD(lParam);
Fl::e_y = pt.y = (signed short)HIWORD(lParam); Fl::e_y = pt.y = (signed short)HIWORD(lParam);
Fl::e_x /= scale; Fl::e_x = int(Fl::e_x / scale);
Fl::e_y /= scale; Fl::e_y = int(Fl::e_y / scale);
ClientToScreen(fl_xid(window), &pt); ClientToScreen(fl_xid(window), &pt);
Fl::e_x_root = pt.x / scale; Fl::e_x_root = int(pt.x / scale);
Fl::e_y_root = pt.y / scale; Fl::e_y_root = int(pt.y / scale);
#ifdef USE_CAPTURE_MOUSE_WIN #ifdef USE_CAPTURE_MOUSE_WIN
Fl_Window *mouse_window = window; // save "mouse window" Fl_Window *mouse_window = window; // save "mouse window"
#endif #endif
@ -1206,7 +1206,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
Fl_WinAPI_Screen_Driver *sd = (Fl_WinAPI_Screen_Driver*)Fl::screen_driver(); Fl_WinAPI_Screen_Driver *sd = (Fl_WinAPI_Screen_Driver*)Fl::screen_driver();
int ns = Fl_Window_Driver::driver(window)->screen_num(); int ns = Fl_Window_Driver::driver(window)->screen_num();
sd->dpi[ns][0] = sd->dpi[ns][1] = HIWORD(wParam); sd->dpi[ns][0] = sd->dpi[ns][1] = HIWORD(wParam);
float f = HIWORD(wParam) / 96.; float f = HIWORD(wParam) / 96.f;
GetClientRect(hWnd, &r); GetClientRect(hWnd, &r);
float old_f = float(r.right) / window->w(); float old_f = float(r.right) / window->w();
Fl::screen_driver()->scale(ns, f); Fl::screen_driver()->scale(ns, f);
@ -1255,10 +1255,10 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
RECT r_box; RECT r_box;
if (scale != 1 && GetRgnBox(R, &r_box) != NULLREGION) { if (scale != 1 && GetRgnBox(R, &r_box) != NULLREGION) {
// add de-scaled update region to i->region in FLTK units // add de-scaled update region to i->region in FLTK units
r_box.left /= scale; r_box.left = LONG(r_box.left / scale);
r_box.right /= scale; r_box.right = LONG(r_box.right / scale);
r_box.top /= scale; r_box.top = LONG(r_box.top / scale);
r_box.bottom /= scale; r_box.bottom = LONG(r_box.bottom / scale);
Fl_Region R3 = CreateRectRgn(r_box.left, r_box.top, r_box.right + 1, r_box.bottom + 1); Fl_Region R3 = CreateRectRgn(r_box.left, r_box.top, r_box.right + 1, r_box.bottom + 1);
if (!i->region) i->region = R3; if (!i->region) i->region = R3;
else { else {
@ -1567,7 +1567,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
} else { } else {
Fl::handle(FL_SHOW, window); Fl::handle(FL_SHOW, window);
resize_bug_fix = window; resize_bug_fix = window;
window->size(ceil(LOWORD(lParam) / scale), ceil(HIWORD(lParam) / scale)); window->size(int(ceil(LOWORD(lParam) / scale)), int(ceil(HIWORD(lParam) / scale)));
// fprintf(LOG,"WM_SIZE size(%.0f,%.0f) graph(%d,%d) s=%.2f\n", // fprintf(LOG,"WM_SIZE size(%.0f,%.0f) graph(%d,%d) s=%.2f\n",
// ceil(LOWORD(lParam)/scale),ceil(HIWORD(lParam)/scale), // ceil(LOWORD(lParam)/scale),ceil(HIWORD(lParam)/scale),
// LOWORD(lParam),HIWORD(lParam),scale); // LOWORD(lParam),HIWORD(lParam),scale);
@ -1589,7 +1589,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
Fl_WinAPI_Screen_Driver *sd = (Fl_WinAPI_Screen_Driver *)Fl::screen_driver(); Fl_WinAPI_Screen_Driver *sd = (Fl_WinAPI_Screen_Driver *)Fl::screen_driver();
Fl_WinAPI_Window_Driver *wd = Fl_WinAPI_Window_Driver::driver(window); Fl_WinAPI_Window_Driver *wd = Fl_WinAPI_Window_Driver::driver(window);
int olds = wd->screen_num(); int olds = wd->screen_num();
int news = sd->screen_num_unscaled(nx + window->w() * scale / 2, ny + window->h() * scale / 2); int news = sd->screen_num_unscaled(nx + int(window->w() * scale / 2), ny + int(window->h() * scale / 2));
if (news == -1) if (news == -1)
news = olds; news = olds;
float s = sd->scale(news); float s = sd->scale(news);
@ -1608,7 +1608,7 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPar
else if (!Fl_WinAPI_Window_Driver::data_for_resize_window_between_screens_.busy) else if (!Fl_WinAPI_Window_Driver::data_for_resize_window_between_screens_.busy)
wd->screen_num(news); wd->screen_num(news);
} }
window->position(round(nx/scale), round(ny/scale)); window->position(int(round(nx/scale)), int(round(ny/scale)));
break; break;
} // case WM_MOVE } // case WM_MOVE
@ -1733,10 +1733,10 @@ static int fake_X_wm_style(const Fl_Window *w, int &X, int &Y, int &bt, int &bx,
RECT r; RECT r;
int drawingX, drawingY; // drawing coordinates of window top-left int drawingX, drawingY; // drawing coordinates of window top-left
r.left = drawingX = round(w->x() * s); r.left = drawingX = int(round(w->x() * s));
r.top = drawingY = round(w->y() * s); r.top = drawingY = int(round(w->y() * s));
r.right = drawingX + w->w() * s; r.right = drawingX + int(w->w() * s);
r.bottom = drawingY + w->h() * s; r.bottom = drawingY + int(w->h() * s);
// get the decoration rectangle for the desired client rectangle // get the decoration rectangle for the desired client rectangle
typedef BOOL(WINAPI* AdjustWindowRectExForDpi_type)(LPRECT, DWORD, BOOL, DWORD, UINT); typedef BOOL(WINAPI* AdjustWindowRectExForDpi_type)(LPRECT, DWORD, BOOL, DWORD, UINT);
@ -1745,7 +1745,7 @@ static int fake_X_wm_style(const Fl_Window *w, int &X, int &Y, int &bt, int &bx,
BOOL ok; BOOL ok;
if ( fl_AdjustWindowRectExForDpi) { if ( fl_AdjustWindowRectExForDpi) {
Fl_WinAPI_Screen_Driver *sd = (Fl_WinAPI_Screen_Driver*)Fl::screen_driver(); Fl_WinAPI_Screen_Driver *sd = (Fl_WinAPI_Screen_Driver*)Fl::screen_driver();
UINT dpi = sd->dpi[Fl_Window_Driver::driver(w)->screen_num()][0]; UINT dpi = UINT(sd->dpi[Fl_Window_Driver::driver(w)->screen_num()][0]);
ok = fl_AdjustWindowRectExForDpi(&r, style, FALSE, styleEx, dpi); ok = fl_AdjustWindowRectExForDpi(&r, style, FALSE, styleEx, dpi);
} else } else
ok = AdjustWindowRectEx(&r, style, FALSE, styleEx); ok = AdjustWindowRectEx(&r, style, FALSE, styleEx);
@ -1802,7 +1802,7 @@ static int fake_X_wm_style(const Fl_Window *w, int &X, int &Y, int &bt, int &bx,
// Find screen that contains most of the window // Find screen that contains most of the window
// FIXME: this ought to be the "work area" instead of the entire screen ! // FIXME: this ought to be the "work area" instead of the entire screen !
int scr_x = 0, scr_y = 0, scr_w = 0, scr_h = 0; int scr_x = 0, scr_y = 0, scr_w = 0, scr_h = 0;
int ns = Fl::screen_num(round(X / s), round(Y / s), W / s, H / s); int ns = Fl::screen_num(int(round(X / s)), int(round(Y / s)), int(W / s), int(H / s));
((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->screen_xywh_unscaled(scr_x, scr_y, scr_w, scr_h, ns); ((Fl_WinAPI_Screen_Driver*)Fl::screen_driver())->screen_xywh_unscaled(scr_x, scr_y, scr_w, scr_h, ns);
// Make border's lower right corner visible // Make border's lower right corner visible
if (scr_x + scr_w < X + W) if (scr_x + scr_w < X + W)
@ -1885,7 +1885,7 @@ void Fl_WinAPI_Window_Driver::resize(int X, int Y, int W, int H) {
int dummy_x, dummy_y, bt, bx, by; int dummy_x, dummy_y, bt, bx, by;
// compute window position and size in scaled units // compute window position and size in scaled units
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
int scaledX = round(X * s), scaledY = round(Y * s), scaledW = int(W * s), scaledH = int(H * s); int scaledX = int(round(X * s)), scaledY = int(round(Y * s)), scaledW = int(W * s), scaledH = int(H * s);
// Ignore window managing when resizing, so that windows (and more // Ignore window managing when resizing, so that windows (and more
// specifically menus) can be moved offscreen. // specifically menus) can be moved offscreen.
if (fake_X_wm(dummy_x, dummy_y, bt, bx, by)) { if (fake_X_wm(dummy_x, dummy_y, bt, bx, by)) {
@ -2035,10 +2035,10 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
} }
Fl_Window_Driver::driver(w)->screen_num(nscreen); Fl_Window_Driver::driver(w)->screen_num(nscreen);
float s = Fl::screen_driver()->scale(nscreen); float s = Fl::screen_driver()->scale(nscreen);
int xp = round(w->x() * s); // these are in graphical units int xp = int(round(w->x() * s)); // these are in graphical units
int yp = round(w->y() * s); int yp = int(round(w->y() * s));
int wp = w->w() * s; int wp = int(w->w() * s);
int hp = w->h() * s; int hp = int(w->h() * s);
int showit = 1; int showit = 1;
@ -2105,8 +2105,8 @@ Fl_X *Fl_WinAPI_Window_Driver::makeWindow() {
if (!Fl::grab()) { if (!Fl::grab()) {
xp = xwm; xp = xwm;
yp = ywm; yp = ywm;
x(round(xp / s)); x(int(round(xp / s)));
y(round(yp / s)); y(int(round(yp / s)));
} }
xp -= bx; xp -= bx;
yp -= by + bt; yp -= by + bt;
@ -2225,15 +2225,15 @@ void Fl_WinAPI_Window_Driver::set_minmax(LPMINMAXINFO minmax) {
hd += td; hd += td;
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
minmax->ptMinTrackSize.x = s * minw() + wd; minmax->ptMinTrackSize.x = LONG(s * minw()) + wd;
minmax->ptMinTrackSize.y = s * minh() + hd; minmax->ptMinTrackSize.y = LONG(s * minh()) + hd;
if (maxw()) { if (maxw()) {
minmax->ptMaxTrackSize.x = s * maxw() + wd; minmax->ptMaxTrackSize.x = LONG(s * maxw()) + wd;
minmax->ptMaxSize.x = s * maxw() + wd; minmax->ptMaxSize.x = LONG(s * maxw()) + wd;
} }
if (maxh()) { if (maxh()) {
minmax->ptMaxTrackSize.y = s * maxh() + hd; minmax->ptMaxTrackSize.y = LONG(s * maxh()) + hd;
minmax->ptMaxSize.y = s * maxh() + hd; minmax->ptMaxSize.y = LONG(s * maxh()) + hd;
} }
} }
@ -2756,11 +2756,11 @@ void Fl_WinAPI_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image *&top, F
Fl::check(); Fl::check();
HDC save_gc = (HDC)fl_graphics_driver->gc(); HDC save_gc = (HDC)fl_graphics_driver->gc();
fl_graphics_driver->gc(GetDC(NULL)); fl_graphics_driver->gc(GetDC(NULL));
int ww = w() * scaling + 2 * wsides; int ww = int(w() * scaling) + 2 * wsides;
wsides /= scaling; wsides = int(wsides / scaling);
if (wsides < 1) if (wsides < 1)
wsides = 1; wsides = 1;
ww /= scaling; ww = int(ww / scaling);
if (wsides <= 1) if (wsides <= 1)
ww = w() + 2 * wsides; ww = w() + 2 * wsides;
// capture the 4 window sides from screen // capture the 4 window sides from screen
@ -2769,11 +2769,11 @@ void Fl_WinAPI_Window_Driver::capture_titlebar_and_borders(Fl_RGB_Image *&top, F
if (htop && r.right - r.left > offset) { if (htop && r.right - r.left > offset) {
top = dr->read_win_rectangle_unscaled(r.left+offset, r.top, r.right - r.left-offset, htop, 0); top = dr->read_win_rectangle_unscaled(r.left+offset, r.top, r.right - r.left-offset, htop, 0);
if (scaling != 1 && top) if (scaling != 1 && top)
top->scale(ww, htop / scaling, 0, 1); top->scale(ww, int(htop / scaling), 0, 1);
} }
if (wsides) { if (wsides) {
left = dr->read_win_rectangle_unscaled(r.left + offset, r.top + htop, wsides, h() * scaling, 0); left = dr->read_win_rectangle_unscaled(r.left + offset, r.top + htop, wsides, int(h() * scaling), 0);
right = dr->read_win_rectangle_unscaled(r.right - wsides, r.top + htop, wsides, h() * scaling, 0); right = dr->read_win_rectangle_unscaled(r.right - wsides, r.top + htop, wsides, int(h() * scaling), 0);
bottom = dr->read_win_rectangle_unscaled(r.left+offset, r.bottom - hbottom, ww, hbottom, 0); bottom = dr->read_win_rectangle_unscaled(r.left+offset, r.bottom - hbottom, ww, hbottom, 0);
if (scaling != 1) { if (scaling != 1) {
if (left) left->scale(wsides, h(), 0, 1); if (left) left->scale(wsides, h(), 0, 1);

View File

@ -77,7 +77,7 @@ Fl_GDI_Copy_Surface_Driver::~Fl_GDI_Copy_Surface_Driver() {
SetClipboardData (CF_ENHMETAFILE, hmf); SetClipboardData (CF_ENHMETAFILE, hmf);
// then put a BITMAP version of the graphics in the clipboard // then put a BITMAP version of the graphics in the clipboard
float scaling = driver()->scale(); float scaling = driver()->scale();
int W = width * scaling, H = height * scaling; int W = int(width * scaling), H = int(height * scaling);
RECT rect = {0, 0, W, H}; RECT rect = {0, 0, W, H};
Fl_Image_Surface *surf = new Fl_Image_Surface(W, H); Fl_Image_Surface *surf = new Fl_Image_Surface(W, H);
Fl_Surface_Device::push_current(surf); Fl_Surface_Device::push_current(surf);

View File

@ -104,7 +104,8 @@ HDC fl_makeDC(HBITMAP bitmap) {
} }
void Fl_GDI_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen bitmap, int srcx, int srcy) { void Fl_GDI_Graphics_Driver::copy_offscreen(int x, int y, int w, int h, Fl_Offscreen bitmap, int srcx, int srcy) {
x *= scale(); y *= scale(); w *= scale(); h *= scale(); srcx *= scale(); srcy *= scale(); x = int(x * scale()); y = int(y * scale()); w = int(w * scale()); h = int(h * scale());
srcx = int(srcx * scale()); srcy = int(srcy * scale());
if (srcx < 0) {w += srcx; x -= srcx; srcx = 0;} if (srcx < 0) {w += srcx; x -= srcx; srcx = 0;}
if (srcy < 0) {h += srcy; y -= srcy; srcy = 0;} if (srcy < 0) {h += srcy; y -= srcy; srcy = 0;}
int off_width, off_height; int off_width, off_height;
@ -157,7 +158,7 @@ void Fl_GDI_Graphics_Driver::translate_all(int x, int y) {
depth = stack_height - 1; depth = stack_height - 1;
} }
GetWindowOrgEx((HDC)gc(), origins+depth); GetWindowOrgEx((HDC)gc(), origins+depth);
SetWindowOrgEx((HDC)gc(), origins[depth].x - x*scale(), origins[depth].y - y*scale(), NULL); SetWindowOrgEx((HDC)gc(), int(origins[depth].x - x*scale()), int(origins[depth].y - y*scale()), NULL);
depth++; depth++;
} }
@ -179,8 +180,8 @@ void Fl_GDI_Graphics_Driver::transformed_vertex0(float x, float y) {
p_size = p ? 2*p_size : 16; p_size = p ? 2*p_size : 16;
p = (POINT*)realloc((void*)p, p_size*sizeof(*p)); p = (POINT*)realloc((void*)p, p_size*sizeof(*p));
} }
p[n].x = x; p[n].x = int(x);
p[n].y = y; p[n].y = int(y);
n++; n++;
} }
} }
@ -255,14 +256,14 @@ HRGN Fl_GDI_Graphics_Driver::scale_region(HRGN r, float f, Fl_GDI_Graphics_Drive
POINT pt = {0, 0}; POINT pt = {0, 0};
if (dr && dr->depth >= 1) { // account for translation if (dr && dr->depth >= 1) { // account for translation
GetWindowOrgEx((HDC)dr->gc(), &pt); GetWindowOrgEx((HDC)dr->gc(), &pt);
pt.x *= (f - 1); pt.x = int(pt.x * (f - 1));
pt.y *= (f - 1); pt.y = int(pt.y * (f - 1));
} }
RECT *rects = (RECT*)&(pdata->Buffer); RECT *rects = (RECT*)&(pdata->Buffer);
int delta = (f > 1.75 ? 1 : 0) - int(f/2); int delta = (f > 1.75 ? 1 : 0) - int(f/2);
for (DWORD i = 0; i < pdata->rdh.nCount; i++) { for (DWORD i = 0; i < pdata->rdh.nCount; i++) {
int x = rects[i].left * f + pt.x; int x = int(rects[i].left * f) + pt.x;
int y = rects[i].top * f + pt.y; int y = int(rects[i].top * f) + pt.y;
RECT R2; RECT R2;
R2.left = x + delta; R2.left = x + delta;
R2.top = y + delta; R2.top = y + delta;

View File

@ -32,29 +32,29 @@
void Fl_GDI_Graphics_Driver::arc_unscaled(float x, float y, float w, float h, double a1, double a2) { void Fl_GDI_Graphics_Driver::arc_unscaled(float x, float y, float w, float h, double a1, double a2) {
if (w <= 0 || h <= 0) return; if (w <= 0 || h <= 0) return;
int xa = x+w/2+int(w*cos(a1/180.0*M_PI)); int xa = int( x+w/2+int(w*cos(a1/180.0*M_PI)) );
int ya = y+h/2-int(h*sin(a1/180.0*M_PI)); int ya = int( y+h/2-int(h*sin(a1/180.0*M_PI)) );
int xb = x+w/2+int(w*cos(a2/180.0*M_PI)); int xb = int( x+w/2+int(w*cos(a2/180.0*M_PI)) );
int yb = y+h/2-int(h*sin(a2/180.0*M_PI)); int yb = int( y+h/2-int(h*sin(a2/180.0*M_PI)) );
if (fabs(a1 - a2) < 90) { if (fabs(a1 - a2) < 90) {
if (xa == xb && ya == yb) SetPixel(gc_, xa, ya, fl_RGB()); if (xa == xb && ya == yb) SetPixel(gc_, xa, ya, fl_RGB());
else Arc(gc_, x, y, x+w, y+h, xa, ya, xb, yb); else Arc(gc_, int(x), int(y), int(x+w), int(y+h), xa, ya, xb, yb);
} else Arc(gc_, x, y, x+w, y+h, xa, ya, xb, yb); } else Arc(gc_, int(x), int(y), int(x+w), int(y+h), xa, ya, xb, yb);
} }
void Fl_GDI_Graphics_Driver::pie_unscaled(float x, float y, float w, float h, double a1, double a2) { void Fl_GDI_Graphics_Driver::pie_unscaled(float x, float y, float w, float h, double a1, double a2) {
if (w <= 0 || h <= 0) return; if (w <= 0 || h <= 0) return;
if (a1 == a2) return; if (a1 == a2) return;
int xa = x+w/2+int(w*cos(a1/180.0*M_PI)); int xa = int( x+w/2+int(w*cos(a1/180.0*M_PI)) );
int ya = y+h/2-int(h*sin(a1/180.0*M_PI)); int ya = int( y+h/2-int(h*sin(a1/180.0*M_PI)) );
int xb = x+w/2+int(w*cos(a2/180.0*M_PI)); int xb = int( x+w/2+int(w*cos(a2/180.0*M_PI)) );
int yb = y+h/2-int(h*sin(a2/180.0*M_PI)); int yb = int( y+h/2-int(h*sin(a2/180.0*M_PI)) );
SelectObject(gc_, fl_brush()); SelectObject(gc_, fl_brush());
if (fabs(a1 - a2) < 90) { if (fabs(a1 - a2) < 90) {
if (xa == xb && ya == yb) { if (xa == xb && ya == yb) {
MoveToEx(gc_, x+w/2, y+h/2, 0L); MoveToEx(gc_, int(x+w/2), int(y+h/2), 0L);
LineTo(gc_, xa, ya); LineTo(gc_, xa, ya);
SetPixel(gc_, xa, ya, fl_RGB()); SetPixel(gc_, xa, ya, fl_RGB());
} else Pie(gc_, x, y, x+w, y+h, xa, ya, xb, yb); } else Pie(gc_, int(x), int(y), int(x+w), int(y+h), xa, ya, xb, yb);
} else Pie(gc_, x, y, x+w, y+h, xa, ya, xb, yb); } else Pie(gc_, int(x), int(y), int(x+w), int(y+h), xa, ya, xb, yb);
} }

View File

@ -398,10 +398,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) { 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(); X = int(X * scale());
Y = Y*scale(); Y = int(Y * scale());
cache_size(bm, W, H); cache_size(bm, W, H);
cx *= scale(); cy *= scale(); cx = int(cx * scale()); cy = int(cy * scale());
HDC tempdc = CreateCompatibleDC(gc_); HDC tempdc = CreateCompatibleDC(gc_);
int save = SaveDC(tempdc); int save = SaveDC(tempdc);
@ -467,7 +467,8 @@ void Fl_GDI_Printer_Graphics_Driver::draw_bitmap(Fl_Bitmap *bm, int XP, int YP,
// draw it to printer context with background color as transparent // draw it to printer context with background color as transparent
float scaleW = bm->data_w()/float(bm->w()); float scaleW = bm->data_w()/float(bm->w());
float scaleH = bm->data_h()/float(bm->h()); float scaleH = bm->data_h()/float(bm->h());
fl_TransparentBlt(gc_, X, Y, W, H, tempdc, cx * scaleW, cy * scaleH, W * scaleW, H * scaleH, RGB(r, g, b) ); fl_TransparentBlt(gc_, X, Y, W, H, tempdc,
int(cx * scaleW), int(cy * scaleH), int(W * scaleW), int(H * scaleH), RGB(r, g, b) );
delete img_surf; delete img_surf;
RestoreDC(tempdc, save); RestoreDC(tempdc, save);
DeleteDC(tempdc); DeleteDC(tempdc);
@ -498,10 +499,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) { 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(); X = int(X * scale());
Y = Y*scale(); Y = int(Y * scale());
cache_size(img, W, H); cache_size(img, W, H);
cx *= scale(); cy *= scale(); cx = int(cx * scale()); cy = int(cy * scale());
if (W + cx > img->data_w()) W = img->data_w() - cx; if (W + cx > img->data_w()) W = img->data_w() - cx;
if (H + cy > img->data_h()) H = img->data_h() - cy; if (H + cy > img->data_h()) H = img->data_h() - cy;
if (!*Fl_Graphics_Driver::id(img)) { if (!*Fl_Graphics_Driver::id(img)) {
@ -542,8 +543,8 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP,
HDC new_gc = CreateCompatibleDC(gc_); HDC new_gc = CreateCompatibleDC(gc_);
int save = SaveDC(new_gc); int save = SaveDC(new_gc);
SelectObject(new_gc, (HBITMAP)*Fl_Graphics_Driver::id(rgb)); SelectObject(new_gc, (HBITMAP)*Fl_Graphics_Driver::id(rgb));
Wfull = W*(rgb->data_w()/float(Wfull)); Hfull = H*(rgb->data_h()/float(Hfull)); Wfull = int(W * (rgb->data_w() / float(Wfull))); Hfull = int(H * (rgb->data_h() / float(Hfull)));
int cx2 = cx * scale(), cy2 = cy * scale(); int cx2 = int(cx * scale()), cy2 = int(cy * scale());
if (cx2+Wfull > rgb->data_w()) Wfull = rgb->data_w()-cx2; if (cx2+Wfull > rgb->data_w()) Wfull = rgb->data_w()-cx2;
if (cy2+Hfull > rgb->data_h()) Hfull = rgb->data_h()-cy2; if (cy2+Hfull > rgb->data_h()) Hfull = rgb->data_h()-cy2;
float scaleW = float(rgb->data_w())/rgb->w(); float scaleW = float(rgb->data_w())/rgb->w();
@ -554,10 +555,10 @@ void Fl_GDI_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP, int WP,
float s = scale(); scale(1); cache_size(rgb, Wfull, Hfull); scale(s); float s = scale(); scale(1); cache_size(rgb, Wfull, Hfull); scale(s);
} }
if ( (rgb->d() % 2) == 0 ) { if ( (rgb->d() % 2) == 0 ) {
alpha_blend_(XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, Wfull, Hfull); alpha_blend_(int(XP*scale()), int(YP*scale()), W, H, new_gc, int(cx*scaleW), int(cy*scaleH), Wfull, Hfull);
} else { } else {
SetStretchBltMode(gc_, HALFTONE); SetStretchBltMode(gc_, HALFTONE);
StretchBlt(gc_, XP*scale(), YP*scale(), W, H, new_gc, cx*scaleW, cy*scaleH, Wfull, Hfull, SRCCOPY); StretchBlt(gc_, int(XP*scale()), int(YP*scale()), W, H, new_gc, int(cx*scaleW), int(cy*scaleH), Wfull, Hfull, SRCCOPY);
} }
RestoreDC(new_gc, save); RestoreDC(new_gc, save);
DeleteDC(new_gc); DeleteDC(new_gc);
@ -582,7 +583,7 @@ void Fl_GDI_Printer_Graphics_Driver::draw_rgb(Fl_RGB_Image *rgb, int XP, int YP,
if ( *pw != rgb->data_w() || *ph != rgb->data_h()) rgb->uncache(); if ( *pw != rgb->data_w() || *ph != rgb->data_h()) rgb->uncache();
} }
if (!*id(rgb)) cache(rgb); if (!*id(rgb)) cache(rgb);
draw_fixed(rgb, 0, 0, WP/tr.eM11, HP/tr.eM22, cx/tr.eM11, cy/tr.eM22); draw_fixed(rgb, 0, 0, int(WP / tr.eM11), int(HP / tr.eM22), int(cx / tr.eM11), int(cy / tr.eM22));
SetWorldTransform(gc_, &old_tr); SetWorldTransform(gc_, &old_tr);
} }
@ -637,10 +638,10 @@ 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) { 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(); X = int(X * scale());
Y = Y*scale(); Y = int(Y * scale());
cache_size(pxm, W, H); cache_size(pxm, W, H);
cx *= scale(); cy *= scale(); cx = int(cx * scale()); cy = int(cy * scale());
Fl_Region r2 = scale_clip(scale()); Fl_Region r2 = scale_clip(scale());
if (*Fl_Graphics_Driver::mask(pxm)) { if (*Fl_Graphics_Driver::mask(pxm)) {
HDC new_gc = CreateCompatibleDC(gc_); HDC new_gc = CreateCompatibleDC(gc_);
@ -688,8 +689,8 @@ void Fl_GDI_Printer_Graphics_Driver::draw_pixmap(Fl_Pixmap *pxm, int XP, int YP,
// print all of offscreen but its parts in background color // print all of offscreen but its parts in background color
float scaleW = pxm->data_w()/float(pxm->w()); float scaleW = pxm->data_w()/float(pxm->w());
float scaleH = pxm->data_h()/float(pxm->h()); float scaleH = pxm->data_h()/float(pxm->h());
fl_TransparentBlt(gc_, X, Y, W, H, new_gc, cx * scaleW, cy * scaleH, W * scaleW, H * scaleH, fl_TransparentBlt(gc_, X, Y, W, H, new_gc,
need_pixmap_bg_color ); int(cx * scaleW), int(cy * scaleH), int(W * scaleW), int(H * scaleH), need_pixmap_bg_color );
RestoreDC(new_gc,save); RestoreDC(new_gc,save);
DeleteDC(new_gc); DeleteDC(new_gc);
need_pixmap_bg_color = 0; need_pixmap_bg_color = 0;

View File

@ -48,7 +48,7 @@ void Fl_GDI_Graphics_Driver::line_style_unscaled(int style, float width, char* d
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); if (!fl_current_xmap) color(FL_BLACK);
LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()? LOGBRUSH penbrush = {BS_SOLID,fl_RGB(),0}; // can this be fl_brush()?
int tw = width < 1? 1: width; int tw = ( width < 1.f ? 1 : int(width) );
HPEN newpen = ExtCreatePen(s1, tw, &penbrush, n, n ? a : 0); HPEN newpen = ExtCreatePen(s1, tw, &penbrush, n, n ? a : 0);
if (!newpen) { if (!newpen) {
Fl::error("fl_line_style(): Could not create GDI pen object."); Fl::error("fl_line_style(): Could not create GDI pen object.");

View File

@ -33,10 +33,10 @@
// --- line and polygon drawing with integer coordinates // --- line and polygon drawing with integer coordinates
void Fl_GDI_Graphics_Driver::point_unscaled(float fx, float fy) { void Fl_GDI_Graphics_Driver::point_unscaled(float fx, float fy) {
int width = scale() >= 1 ? scale() : 1; int width = (scale() >= 1 ? int(scale()) : 1);
RECT rect; RECT rect;
rect.left = fx; rect.top = fy; rect.left = int(fx); rect.top = int(fy);
rect.right = fx + width; rect.bottom = fy + width; rect.right = int(fx) + width; rect.bottom = int(fy) + width;
FillRect(gc_, &rect, fl_brush()); FillRect(gc_, &rect, fl_brush());
} }
@ -71,32 +71,32 @@ void Fl_GDI_Graphics_Driver::focus_rect(int x, int y, int w, int h) {
void Fl_GDI_Graphics_Driver::rectf_unscaled(float x, float y, float w, float h) { void Fl_GDI_Graphics_Driver::rectf_unscaled(float x, float y, float w, float h) {
if (w<=0 || h<=0) return; if (w<=0 || h<=0) return;
RECT rect; RECT rect;
rect.left = x; rect.top = y; rect.left = int(x); rect.top = int(y);
rect.right = x + w; rect.bottom = y + h; rect.right = int(x + w); rect.bottom = int(y + h);
FillRect(gc_, &rect, fl_brush()); FillRect(gc_, &rect, fl_brush());
} }
void Fl_GDI_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1) { void Fl_GDI_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1) {
MoveToEx(gc_, x, y, 0L); MoveToEx(gc_, int(x), int(y), 0L);
LineTo(gc_, x1, y1); LineTo(gc_, int(x1), int(y1));
SetPixel(gc_, x1, y1, fl_RGB()); SetPixel(gc_, int(x1), int(y1), fl_RGB());
} }
void Fl_GDI_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1, float x2, float y2) { void Fl_GDI_Graphics_Driver::line_unscaled(float x, float y, float x1, float y1, float x2, float y2) {
MoveToEx(gc_, x, y, 0L); MoveToEx(gc_, int(x), int(y), 0L);
LineTo(gc_, x1, y1); LineTo(gc_, int(x1), int(y1));
LineTo(gc_, x2, y2); LineTo(gc_, int(x2), int(y2));
SetPixel(gc_, x2, y2, fl_RGB()); SetPixel(gc_, int(x2), int(y2), fl_RGB());
} }
void Fl_GDI_Graphics_Driver::xyline_unscaled(float x, float y, float x1) { 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 int tw = line_width_ ? line_width_ : 1; // true line width
if (x > x1) { float exch = x; x = x1; x1 = exch; } if (x > x1) { float exch = x; x = x1; x1 = exch; }
int ix = x+line_delta_; if (scale() >= 2) ix -= int(scale()/2); int ix = int(x) + line_delta_; if (scale() >= 2.f) ix -= int(scale()/2);
int iy = y+line_delta_; int iy = int(y) + line_delta_;
if (scale() > 1.9 && line_width_/scale() >= 2) iy--; 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 int ix1 = int( int(x1/scale()+1.5f) * 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; ix1 += line_delta_; if (scale() >= 2) ix1 -= 1;; if (scale() >= 4) ix1 -= 1;
MoveToEx(gc_, ix, iy, 0L); LineTo(gc_, ix1+1, iy); 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) // try and make sure no unfilled area lies between xyline(x,y,x1) and xyline(x,y+1,x1)
@ -110,10 +110,10 @@ void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1) {
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 tw = line_width_ ? line_width_ : 1; // true line width
int ix = x+line_delta_; int ix = int(x) + line_delta_;
if (scale() > 1.9 && line_width_/scale() >= 2) ix--; if (scale() > 1.9 && line_width_/scale() >= 2) ix--;
int iy = y+line_delta_; if (scale() >= 2) iy -= int(scale()/2); int iy = int(y) + line_delta_; if (scale() >= 2) iy -= int(scale()/2);
int iy1 = int(y1/scale()+1.5)*scale()-1; int iy1 = int( 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 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); 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) // try and make sure no unfilled area lies between yxline(x,y,y1) and yxline(x+1,y,y1)
@ -124,35 +124,35 @@ void Fl_GDI_Graphics_Driver::yxline_unscaled(float x, float y, float y1) {
} }
void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2) { void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2) {
MoveToEx(gc_, x, y, 0L); MoveToEx(gc_, int(x), int(y), 0L);
LineTo(gc_, x1, y1); LineTo(gc_, int(x1), int(y1));
LineTo(gc_, x2, y2); LineTo(gc_, int(x2), int(y2));
LineTo(gc_, x, y); LineTo(gc_, int(x), int(y));
} }
void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { void Fl_GDI_Graphics_Driver::loop_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) {
MoveToEx(gc_, x, y, 0L); MoveToEx(gc_, int(x), int(y), 0L);
LineTo(gc_, x1, y1); LineTo(gc_, int(x1), int(y1));
LineTo(gc_, x2, y2); LineTo(gc_, int(x2), int(y2));
LineTo(gc_, x3, y3); LineTo(gc_, int(x3), int(y3));
LineTo(gc_, x, y); LineTo(gc_, int(x), int(y));
} }
void Fl_GDI_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2) { void Fl_GDI_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2) {
POINT p[3]; POINT p[3];
p[0].x = x; p[0].y = y; p[0].x = int(x); p[0].y = int(y);
p[1].x = x1; p[1].y = y1; p[1].x = int(x1); p[1].y = int(y1);
p[2].x = x2; p[2].y = y2; p[2].x = int(x2); p[2].y = int(y2);
SelectObject(gc_, fl_brush()); SelectObject(gc_, fl_brush());
Polygon(gc_, p, 3); Polygon(gc_, p, 3);
} }
void Fl_GDI_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) { void Fl_GDI_Graphics_Driver::polygon_unscaled(float x, float y, float x1, float y1, float x2, float y2, float x3, float y3) {
POINT p[4]; POINT p[4];
p[0].x = x; p[0].y = y; p[0].x = int(x); p[0].y = int(y);
p[1].x = x1; p[1].y = y1; p[1].x = int(x1); p[1].y = int(y1);
p[2].x = x2; p[2].y = y2; p[2].x = int(x2); p[2].y = int(y2);
p[3].x = x3; p[3].y = y3; p[3].x = int(x3); p[3].y = int(y3);
SelectObject(gc_, fl_brush()); SelectObject(gc_, fl_brush());
Polygon(gc_, p, 4); Polygon(gc_, p, 4);
} }

View File

@ -42,7 +42,7 @@ void Fl_GDI_Graphics_Driver::end_line() {
void Fl_GDI_Graphics_Driver::end_loop() { void Fl_GDI_Graphics_Driver::end_loop() {
fixloop(); fixloop();
if (n>2) transformed_vertex0(p[0].x, p[0].y); if (n>2) transformed_vertex0(float(p[0].x), float(p[0].y));
end_line(); end_line();
} }
@ -67,7 +67,7 @@ void Fl_GDI_Graphics_Driver::begin_complex_polygon() {
void Fl_GDI_Graphics_Driver::gap() { void Fl_GDI_Graphics_Driver::gap() {
while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--; while (n>gap_+2 && p[n-1].x == p[gap_].x && p[n-1].y == p[gap_].y) n--;
if (n > gap_+2) { if (n > gap_+2) {
transformed_vertex0(p[gap_].x, p[gap_].y); transformed_vertex0(float(p[gap_].x), float(p[gap_].y));
counts[numcount++] = n-gap_; counts[numcount++] = n-gap_;
gap_ = n; gap_ = n;
} else { } else {

View File

@ -2122,7 +2122,7 @@ Fl_EPS_File_Surface::Fl_EPS_File_Surface(int width, int height, FILE *eps, Fl_Co
ps->close_cmd_ = closef; ps->close_cmd_ = closef;
if (ps->output) { if (ps->output) {
float s = Fl::screen_scale(0); float s = Fl::screen_scale(0);
ps->start_eps(width*s, height*s); ps->start_eps(int(width*s), int(height*s));
#if USE_PANGO #if USE_PANGO
cairo_save(ps->cr()); cairo_save(ps->cr());
ps->left_margin = ps->top_margin = 0; ps->left_margin = ps->top_margin = 0;

View File

@ -116,7 +116,7 @@ void Fl_PostScript_Graphics_Driver::write85(void *data, const uchar *p, int len)
const uchar *last = p + len; const uchar *last = p + len;
while (p < last) { while (p < last) {
int c = 4 - big->l4; int c = 4 - big->l4;
if (last-p < c) c = last-p; if (last-p < c) c = int(last-p);
memcpy(big->bytes4 + big->l4, p, c); memcpy(big->bytes4 + big->l4, p, c);
p += c; p += c;
big->l4 += c; big->l4 += c;

View File

@ -146,10 +146,10 @@ void Fl_WinAPI_Screen_Driver::screen_work_area(int &X, int &Y, int &W, int &H, i
{ {
if (num_screens < 0) init(); if (num_screens < 0) init();
if (n < 0 || n >= num_screens) n = 0; if (n < 0 || n >= num_screens) n = 0;
X = work_area[n].left/scale_of_screen[n]; X = int(work_area[n].left/scale_of_screen[n]);
Y = work_area[n].top/scale_of_screen[n]; Y = int(work_area[n].top/scale_of_screen[n]);
W = (work_area[n].right - work_area[n].left)/scale_of_screen[n]; W = int((work_area[n].right - work_area[n].left)/scale_of_screen[n]);
H = (work_area[n].bottom - work_area[n].top)/scale_of_screen[n]; H = int((work_area[n].bottom - work_area[n].top)/scale_of_screen[n]);
} }
@ -161,10 +161,10 @@ void Fl_WinAPI_Screen_Driver::screen_xywh(int &X, int &Y, int &W, int &H, int n)
n = 0; n = 0;
if (num_screens > 0) { if (num_screens > 0) {
X = screens[n].left/scale_of_screen[n]; X = int(screens[n].left/scale_of_screen[n]);
Y = screens[n].top/scale_of_screen[n]; Y = int(screens[n].top/scale_of_screen[n]);
W = (screens[n].right - screens[n].left)/scale_of_screen[n]; W = int((screens[n].right - screens[n].left)/scale_of_screen[n]);
H = (screens[n].bottom - screens[n].top)/scale_of_screen[n]; H = int((screens[n].bottom - screens[n].top)/scale_of_screen[n]);
} else { } else {
/* Fallback if something is broken... */ /* Fallback if something is broken... */
X = 0; X = 0;
@ -501,14 +501,14 @@ Fl_WinAPI_Screen_Driver::read_win_rectangle(
{ {
float s = Fl_Surface_Device::surface()->driver()->scale(); float s = Fl_Surface_Device::surface()->driver()->scale();
int ws, hs; int ws, hs;
if (int(s) == s) { ws = w * s; hs = h * s;} if (int(s) == s) { ws = int(w * s); hs = int(h * s);}
else { else {
ws = (w+1)*s; // approximates what Fl_Graphics_Driver::cache_size() does ws = int((w+1) * s); // approximates what Fl_Graphics_Driver::cache_size() does
hs = (h+1)*s; hs = int((h+1) * s);
if (ws < 1) ws = 1; if (ws < 1) ws = 1;
if (hs < 1) hs = 1; if (hs < 1) hs = 1;
} }
return read_win_rectangle_unscaled(X*s, Y*s, ws, hs, win); return read_win_rectangle_unscaled(int(X*s), int(Y*s), ws, hs, win);
} }
Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win) Fl_RGB_Image *Fl_WinAPI_Screen_Driver::read_win_rectangle_unscaled(int X, int Y, int w, int h, Fl_Window *win)

View File

@ -121,7 +121,7 @@ int Fl_WinAPI_Window_Driver::decorated_w()
int bt, bx, by; int bt, bx, by;
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
border_width_title_bar_height(bx, by, bt); border_width_title_bar_height(bx, by, bt);
int mini_bx = bx/s; if (mini_bx < 1) mini_bx = 1; int mini_bx = int(bx/s); if (mini_bx < 1) mini_bx = 1;
return w() + 2 * mini_bx; return w() + 2 * mini_bx;
} }
@ -130,8 +130,8 @@ int Fl_WinAPI_Window_Driver::decorated_h()
int bt, bx, by; int bt, bx, by;
border_width_title_bar_height(bx, by, bt); border_width_title_bar_height(bx, by, bt);
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
int mini_by = by/s; if (mini_by < 1) mini_by = 1; int mini_by = int(by / s); if (mini_by < 1) mini_by = 1;
return h() + (bt + by)/s + mini_by; return h() + int((bt + by) / s) + mini_by;
} }
@ -285,8 +285,8 @@ void Fl_WinAPI_Window_Driver::draw_begin()
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
if ((shape_data_->lw_ != s*w() || shape_data_->lh_ != s*h()) && shape_data_->shape_) { if ((shape_data_->lw_ != s*w() || shape_data_->lh_ != s*h()) && shape_data_->shape_) {
// size of window has changed since last time // size of window has changed since last time
shape_data_->lw_ = s*w(); shape_data_->lw_ = int(s * w());
shape_data_->lh_ = s*h(); shape_data_->lh_ = int(s * h());
Fl_Image* temp = shape_data_->effective_bitmap_ ? shape_data_->effective_bitmap_ : shape_data_->shape_; Fl_Image* temp = shape_data_->effective_bitmap_ ? shape_data_->effective_bitmap_ : shape_data_->shape_;
temp = temp->copy(shape_data_->lw_, shape_data_->lh_); temp = temp->copy(shape_data_->lw_, shape_data_->lh_);
HRGN region = bitmap2region(temp); HRGN region = bitmap2region(temp);
@ -601,7 +601,7 @@ void Fl_WinAPI_Window_Driver::fullscreen_off(int X, int Y, int W, int H) {
Fl_X::i(pWindow)->xid = xid; Fl_X::i(pWindow)->xid = xid;
// compute window position and size in scaled units // compute window position and size in scaled units
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
int scaledX = ceil(X*s), scaledY= ceil(Y*s), scaledW = ceil(W*s), scaledH = ceil(H*s); int scaledX = int(ceil(X*s)), scaledY= int(ceil(Y*s)), scaledW = int(ceil(W*s)), scaledH = int(ceil(H*s));
// Adjust for decorations (but not if that puts the decorations // Adjust for decorations (but not if that puts the decorations
// outside the screen) // outside the screen)
if ((X != x()) || (Y != y())) { if ((X != x()) || (Y != y())) {
@ -649,7 +649,9 @@ int Fl_WinAPI_Window_Driver::scroll(int src_x, int src_y, int src_w, int src_h,
first_time = 0; first_time = 0;
} }
float s = Fl::screen_driver()->scale(screen_num()); float s = Fl::screen_driver()->scale(screen_num());
src_x *= s; src_y *= s; src_w *= s; src_h *= s; dest_x *= s; dest_y *= s; src_x = int(src_x * s); src_y = int(src_y * s);
src_w = int(src_w * s); src_h = int(src_h * s);
dest_x = int(dest_x * s); dest_y = int(dest_y * s);
// Now check if the source scrolling area is fully visible. // Now check if the source scrolling area is fully visible.
// If it is, we will do a quick scroll and just update the // If it is, we will do a quick scroll and just update the
// newly exposed area. If it is not, we go the safe route and // newly exposed area. If it is not, we go the safe route and

View File

@ -89,8 +89,8 @@ public:
Fl_Window *target = fl_find( hWnd ); Fl_Window *target = fl_find( hWnd );
if (target) { if (target) {
float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(target)->screen_num()); float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(target)->screen_num());
Fl::e_x_root /= s; Fl::e_x_root = int(Fl::e_x_root / s);
Fl::e_y_root /= s; Fl::e_y_root = int(Fl::e_y_root / s);
Fl::e_x = Fl::e_x_root-target->x(); Fl::e_x = Fl::e_x_root-target->x();
Fl::e_y = Fl::e_y_root-target->y(); Fl::e_y = Fl::e_y_root-target->y();
} }
@ -124,8 +124,8 @@ public:
Fl::e_y_root = pt.y; Fl::e_y_root = pt.y;
if (fl_dnd_target_window) { if (fl_dnd_target_window) {
float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(fl_dnd_target_window)->screen_num()); float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(fl_dnd_target_window)->screen_num());
Fl::e_x_root /= s; Fl::e_x_root = int(Fl::e_x_root /s);
Fl::e_y_root /= s; Fl::e_y_root = int(Fl::e_y_root /s);
Fl::e_x = Fl::e_x_root-fl_dnd_target_window->x(); Fl::e_x = Fl::e_x_root-fl_dnd_target_window->x();
Fl::e_y = Fl::e_y_root-fl_dnd_target_window->y(); Fl::e_y = Fl::e_y_root-fl_dnd_target_window->y();
} }
@ -161,8 +161,8 @@ public:
Fl::e_x_root = pt.x; Fl::e_x_root = pt.x;
Fl::e_y_root = pt.y; Fl::e_y_root = pt.y;
float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(target)->screen_num()); float s = Fl::screen_driver()->scale(Fl_Window_Driver::driver(target)->screen_num());
Fl::e_x_root /= s; Fl::e_x_root = int(Fl::e_x_root / s);
Fl::e_y_root /= s; Fl::e_y_root = int(Fl::e_y_root / s);
if (target) { if (target) {
Fl::e_x = Fl::e_x_root-target->x(); Fl::e_x = Fl::e_x_root-target->x();
Fl::e_y = Fl::e_y_root-target->y(); Fl::e_y = Fl::e_y_root-target->y();

View File

@ -78,7 +78,7 @@ static const char* expand_text_(const char* from, char*& buf, int maxbuf, double
if (o > e) { if (o > e) {
if (maxbuf) break; // don't overflow buffer if (maxbuf) break; // don't overflow buffer
l_local_buff += (o - e) + 200; // enlarge buffer l_local_buff += int(o - e) + 200; // enlarge buffer
buf = (char*)realloc(local_buf, l_local_buff); buf = (char*)realloc(local_buf, l_local_buff);
e = buf + l_local_buff - 4; // update pointers to buffer content e = buf + l_local_buff - 4; // update pointers to buffer content
o = buf + (o - local_buf); o = buf + (o - local_buf);

View File

@ -119,7 +119,7 @@ int fl_convert_pixmap(const char*const* cdata, uchar* out, Fl_Color bg) {
return 0; return 0;
typedef uchar uchar4[4]; typedef uchar uchar4[4];
uchar4 *colors = new uchar4[1<<(chars_per_pixel*8)]; uchar4 *colors = new uchar4[ int(1<<(chars_per_pixel*8)) ];
if (Fl_Graphics_Driver::need_pixmap_bg_color) { if (Fl_Graphics_Driver::need_pixmap_bg_color) {
color_count = 0; color_count = 0;