DO NOT REPLY TO THIS MESSAGE. INSTEAD, POST ANY RESPONSES TO THE LINK BELOW.
[STR New]
Link: http://www.fltk.org/str.php?L2798
Version: 1.3-current
It seems that X11 use short value for drawing string (XDrawString),
for Fl_Tree_Item, it can make problem of drawing labels when x, y overflow
short max/min values.
In this sample, there is 4 labels that must not appear (out of bound).
A naive patch attached to prevent simple cases to happen.
I keep fltk gurus for a better solution.
#include <FL/Fl.H>
#include <FL/Fl_Window.H>
#include <FL/fl_draw.H>
struct MyWindow : Fl_Window {
MyWindow() : Fl_Window( 30,50,500,300, "Label bug" )
{}
void draw() {
fl_draw( "01", 0, 30 );
fl_draw( "0123", 0, 40+65536 );
fl_draw( "012345", 0, 50-65536 );
fl_draw( "0123", -20, 60 );
fl_rtl_draw( "01", 2, 50, 130 );
fl_rtl_draw( "0123", 4, 50, 140+65536 );
fl_rtl_draw( "012345", 6, 50, 150-65536 );
fl_rtl_draw( "0123", 4, -20, 160 );
}
};
int main() {
MyWindow w;
w.show();
return Fl::run();
}
Link: http://www.fltk.org/str.php?L2798
Version: 1.3-currentIndex: fl_font_x.cxx
===================================================================
--- fl_font_x.cxx (révision 9209)
+++ fl_font_x.cxx (copie de travail)
@@ -17,6 +17,16 @@
//
#ifndef FL_DOXYGEN
+namespace {
+ const int SHRT_MAX = 32676;
+ const int SHRT_MIN = -32666;
+
+ int clip_to_short(int x, int y ) {
+ return ( x < SHRT_MIN || x > SHRT_MAX || y < SHRT_MIN || y > SHRT_MAX );
+ }
+}
+
+
Fl_Font_Descriptor::Fl_Font_Descriptor(const char* name) {
font = XCreateUtf8FontStruct(fl_display, name);
if (!font) {
@@ -314,11 +324,12 @@
font_gc = fl_gc;
XSetFont(fl_display, fl_gc, font_descriptor()->font->fid);
}
- if (fl_gc) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font,
fl_gc, x, y, c, n);
+ if (fl_gc ) XUtf8DrawString(fl_display, fl_window, font_descriptor()->font,
fl_gc, x, y, c, n);
}
void Fl_Xlib_Graphics_Driver::draw(int angle, const char *str, int n, int x,
int y) {
fprintf(stderr,"ROTATING TEXT NOT IMPLEMENTED\n");
+ if ( clip_to_short( x, y ) ) return;
this->draw(str, n, (int)x, (int)y);
}
@@ -327,7 +338,7 @@
if (!font_descriptor()) this->font(FL_HELVETICA, FL_NORMAL_SIZE);
font_gc = fl_gc;
}
- if (fl_gc) XUtf8DrawRtlString(fl_display, fl_window,
font_descriptor()->font, fl_gc, x, y, c, n);
+ if (fl_gc ) XUtf8DrawRtlString(fl_display, fl_window,
font_descriptor()->font, fl_gc, x, y, c, n);
}
#endif // FL_DOXYGEN
//
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs