ZynAddSubFX/FLTK: updated to SVN revision 6826

Updated FLTK to SVN revision 6841 of branch-1.3:

- Fixed glibc 2.10 compiler problems (Fedora 11 and others)
  with scandir() and strchr() (STR #2222)
- Fl_Scroll mods for global scrollbar size control
- various other minor stuff (see SVN log)
(cherry picked from commit 803fd68a56)
This commit is contained in:
Tobias Doerffel
2009-08-05 19:03:19 +02:00
parent 84e0dc1b81
commit 8485cf3157
11 changed files with 293 additions and 92 deletions

View File

@@ -1,5 +1,7 @@
CHANGES IN FLTK 1.3.0
- Fixed glibc 2.10 compiler problems (Fedora 11 and others)
with scandir() and strchr() (STR #2222)
- Corrected const methods of Fl_Text_{Buffer|Display|Selection}
to be declared const, corrected an Fl_Text_Buffer attrib. typo
- Fixed OpenGL shared context handling (STR #2135)

View File

@@ -82,7 +82,7 @@
simply incrementing such an index will not reliably advance to the next character
in the text buffer.
Indices and pointers into the text buffer shoudl always point at an 7 bit ASCII
Indices and pointers into the text buffer should always point at a 7 bit ASCII
character or the beginning of a utf8 character sequence. Behavior for false
utf8 sequences and pointers into the middle of a seqeunce are undefined.
@@ -116,7 +116,7 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
/** \internal Positin of the cursor in the document */
int position_;
/** \internal Position of the other and of the selected text. If \p position_ equals
/** \internal Position of the other end of the selected text. If \p position_ equals
\p mark_, no text is selected */
int mark_;
@@ -130,7 +130,7 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
/** \internal Maximum size of buffer. \todo Is this really needed? */
int maximum_size_;
/** \internal Shorcut key that will get this widget the focus. */
/** \internal Shortcut key that will fetch focus for this widget. */
int shortcut_;
/** \internal This is set if no text but only the cursor needs updating. */
@@ -174,16 +174,16 @@ class FL_EXPORT Fl_Input_ : public Fl_Widget {
protected:
/* Finds the start of a word. */
/* Find the start of a word. */
int word_start(int i) const;
/* Finds the end of a word. */
/* Find the end of a word. */
int word_end(int i) const;
/* Finds the start of a line. */
/* Find the start of a line. */
int line_start(int i) const;
/* Finds the end of a line. */
/* Find the end of a line. */
int line_end(int i) const;
/* Draw the text in the passed bounding box. */
@@ -215,7 +215,7 @@ public:
/* Change the size of the widget. */
void resize(int, int, int, int);
/* Creator */
/* Constructor */
Fl_Input_(int, int, int, int, const char* = 0);
/* Destructor */

View File

@@ -95,11 +95,33 @@ class FL_EXPORT Fl_Scroll : public Fl_Group {
int xposition_, yposition_;
int width_, height_;
int oldx, oldy;
int scrollbar_size_;
static void hscrollbar_cb(Fl_Widget*, void*);
static void scrollbar_cb(Fl_Widget*, void*);
void fix_scrollbar_order();
static void draw_clip(void*,int,int,int,int);
private:
//
// Structure to manage scrollbar and widget interior sizes.
//
// Private for now -- we'd like to expose some of this at
// some point to solve STR#1895.)
//
typedef struct {
int scrollsize; // the scrollsize (global|local)
int innerbox_x, innerbox_y, innerbox_w, innerbox_h; // widget's inner box (excludes scrollbars)
int innerchild_x, innerchild_y, innerchild_w, innerchild_h; // widget's inner box including scrollbars
int child_l, child_r, child_b, child_t; // child bounding box: left/right/bottom/top
int hneeded, vneeded; // hor + ver scrollbar visibility
int hscroll_x, hscroll_y, hscroll_w, hscroll_h; // hor scrollbar size/position
int vscroll_x, vscroll_y, vscroll_w, vscroll_h; // ver scrollbar size/position
int hpos, hsize, hfirst, htotal; // hor scrollbar values (pos/size/first/total)
int vpos, vsize, vfirst, vtotal; // ver scrollbar values (pos/size/first/total)
} ScrollInfo;
void recalc_scrollbars(ScrollInfo &si);
protected:
void bbox(int&,int&,int&,int&);
@@ -131,6 +153,41 @@ public:
int yposition() const {return yposition_;}
void scroll_to(int, int);
void clear();
/**
Gets the current size of the scrollbars' troughs, in pixels.
If this value is zero (default), this widget will use the
Fl::scrollbar_size() value as the scrollbar's width.
\returns Scrollbar size in pixels, or 0 if the global Fl::scrollsize() is being used.
\see Fl::scrollbar_size(int)
*/
int scrollbar_size() const {
return(scrollbar_size_);
}
/**
Sets the pixel size of the scrollbars' troughs to the \p size, in pixels.
Normally you should not need this method, and should use
Fl::scrollbar_size(int) instead to manage the size of ALL
your widgets' scrollbars. This ensures your application
has a consistent UI, is the default behavior, and is normally
what you want.
Only use THIS method if you really need to override the global
scrollbar size. The need for this should be rare.
Setting \p size to the special value of 0 causes the widget to
track the global Fl::scrollbar_size(), which is the default.
\param[in] size Sets the scrollbar size in pixels.\n
If 0 (default), scrollbar size tracks the global Fl::scrollbar_size()
\see Fl::scrollbar_size()
*/
void scrollbar_size(int size) {
if ( size != scrollbar_size_ ) redraw();
scrollbar_size_ = size;
}
};
#endif

View File

@@ -75,7 +75,9 @@ class FL_EXPORT Fl_Window : public Fl_Group {
FL_NOBORDER = 8,
FL_FORCE_POSITION = 16,
FL_NON_MODAL = 32,
FL_OVERRIDE = 256
FL_OVERRIDE = 256,
FL_MENU_WINDOW = 4096,
FL_TOOLTIP_WINDOW = 8192
};
void _Fl_Window(); // constructor innards
@@ -177,7 +179,7 @@ public:
being delivered to other windows in the same program, and will also
remain on top of the other windows (if the X window manager supports
the "transient for" property). Several modal windows may be shown at
once, in which case only the last one shown gets events. You can See
once, in which case only the last one shown gets events. You can see
which window (if any) is modal by calling
Fl::modal().
*/
@@ -194,6 +196,45 @@ public:
/** Returns true if this window is modal or non-modal. */
int non_modal() const {return flags() & (FL_NON_MODAL|FL_MODAL);}
/**
Marks the window as a menu window.
This is intended for internal use, but it can also be used if you
write your own menu handling. However, this is not recommended.
This flag is used for correct "parenting" of windows in communication
with the windowing system. Modern X window managers can use different
flags to distinguish menu and tooltip windows from normal windows.
This must be called before the window is shown and cannot be changed
later.
*/
void set_menu_window() {set_flag(FL_MENU_WINDOW);}
/** Returns true if this window is a menu window. */
int menu_window() const {return flags() & FL_MENU_WINDOW;}
/**
Marks the window as a tooltip window.
This is intended for internal use, but it can also be used if you
write your own tooltip handling. However, this is not recommended.
This flag is used for correct "parenting" of windows in communication
with the windowing system. Modern X window managers can use different
flags to distinguish menu and tooltip windows from normal windows.
This must be called before the window is shown and cannot be changed
later.
\note Since Fl_Tooltip_Window is derived from Fl_Menu_Window, this
also \b clears the menu_window() state.
*/
void set_tooltip_window() { set_flag(FL_TOOLTIP_WINDOW);
clear_flag(FL_MENU_WINDOW); }
/** Returns true if this window is a tooltip window. */
int tooltip_window() const {return flags() & FL_TOOLTIP_WINDOW;}
/**
Position the window so that the mouse is pointing at the
given position, or at the center of the given widget, which may be the

View File

@@ -1493,13 +1493,23 @@ static Fl_Widget **dwidgets = 0;
/**
Schedules a widget for deletion at the next call to the event loop.
Use this method to delete a widget inside a callback function.
To avoid early deletion of widgets, this function
should be called toward the end of a callback and only after any call
to the event loop (Fl:wait(), Fl::flush(), fl_ask(), etc).
Use this method to delete a widget inside a callback function.
To avoid early deletion of widgets, this function should be called
toward the end of a callback and only after any call to the event
loop (Fl::wait(), Fl::flush(), Fl::check(), fl_ask(), etc.).
When deleting groups or windows, you must only delete the group or
window widget and not the individual child widgets.
\since FLTK 1.3 it is not necessary to remove widgets from their parent
groups or windows before calling this, because it will be done in the
widget's destructor, but it is not a failure to do this nevertheless.
\note In FLTK 1.1 you \b must remove widgets from their parent group
(or window) before deleting them.
\see Fl_Widget::~Fl_Widget()
*/
void Fl::delete_widget(Fl_Widget *wi) {
if (!wi) return;

View File

@@ -1046,7 +1046,7 @@ Fl_File_Chooser::newdir()
// Get a directory name from the user
if ((dir = fl_input("%s", new_directory_label, NULL)) == NULL)
if ((dir = fl_input("%s", new_directory_label, (char *)NULL)) == NULL)
return;
// Make it relative to the current directory as needed...

View File

@@ -268,6 +268,7 @@ menutitle::menutitle(int X, int Y, int W, int H, const Fl_Menu_Item* L) :
end();
set_modal();
clear_border();
set_menu_window();
menu = L;
if (L->labelcolor_ || Fl::scheme() || L->labeltype_ > FL_NO_LABEL) clear_overlay();
}
@@ -286,6 +287,7 @@ menuwindow::menuwindow(const Fl_Menu_Item* m, int X, int Y, int Wp, int Hp,
end();
set_modal();
clear_border();
set_menu_window();
menu = m;
if (m) m = m->first(); // find the first item that needs to be rendered
drawn_selected = -1;

View File

@@ -52,6 +52,9 @@ void Fl_Scroll::fix_scrollbar_order() {
}
}
// Draw widget's background and children within a specific clip region
// So widget can just redraw damaged parts.
//
void Fl_Scroll::draw_clip(void* v,int X, int Y, int W, int H) {
fl_push_clip(X,Y,W,H);
Fl_Scroll* s = (Fl_Scroll*)v;
@@ -92,6 +95,126 @@ void Fl_Scroll::draw_clip(void* v,int X, int Y, int W, int H) {
fl_pop_clip();
}
/**
Calculate visibility/size/position of scrollbars, find children's bounding box.
The \p si paramater will be filled with data from the calculations.
Derived classes can make use of this call to figure out the scrolling area
eg. during resize() handling.
\param[in] si -- ScrollInfo structure
\returns Structure containing the calculated info.
*/
void Fl_Scroll::recalc_scrollbars(ScrollInfo &si) {
// inner box of widget (excluding scrollbars)
si.innerbox_x = x()+Fl::box_dx(box());
si.innerbox_y = y()+Fl::box_dy(box());
si.innerbox_w = w()-Fl::box_dw(box());
si.innerbox_h = h()-Fl::box_dh(box());
// accumulate a bounding box for all the children
si.child_l = si.innerbox_x;
si.child_r = si.innerbox_x;
si.child_b = si.innerbox_y;
si.child_t = si.innerbox_y;
int first = 1;
Fl_Widget*const* a = array();
for (int i=children()-2; i--;) {
Fl_Widget* o = *a++;
if ( first ) {
first = 0;
si.child_l = o->x();
si.child_r = o->x()+o->w();
si.child_b = o->y()+o->h();
si.child_t = o->y();
} else {
if (o->x() < si.child_l) si.child_l = o->x();
if (o->y() < si.child_t) si.child_t = o->y();
if (o->x()+o->w() > si.child_r) si.child_r = o->x()+o->w();
if (o->y()+o->h() > si.child_b) si.child_b = o->y()+o->h();
}
}
// Turn the scrollbars on and off as necessary.
// See if children would fit if we had no scrollbars...
{
int X = si.innerbox_x;
int Y = si.innerbox_y;
int W = si.innerbox_w;
int H = si.innerbox_h;
si.scrollsize = scrollbar_size_ ? scrollbar_size_ : Fl::scrollbar_size();
si.vneeded = 0;
si.hneeded = 0;
if (type() & VERTICAL) {
if ((type() & ALWAYS_ON) || si.child_t < Y || si.child_b > Y+H) {
si.vneeded = 1;
W -= si.scrollsize;
if (scrollbar.align() & FL_ALIGN_LEFT) X += si.scrollsize;
}
}
if (type() & HORIZONTAL) {
if ((type() & ALWAYS_ON) || si.child_l < X || si.child_r > X+W) {
si.hneeded = 1;
H -= si.scrollsize;
if (scrollbar.align() & FL_ALIGN_TOP) Y += si.scrollsize;
// recheck vertical since we added a horizontal scrollbar
if (!si.vneeded && (type() & VERTICAL)) {
if ((type() & ALWAYS_ON) || si.child_t < Y || si.child_b > Y+H) {
si.vneeded = 1;
W -= si.scrollsize;
if (scrollbar.align() & FL_ALIGN_LEFT) X += si.scrollsize;
}
}
}
}
si.innerchild_x = X;
si.innerchild_y = Y;
si.innerchild_w = W;
si.innerchild_h = H;
}
// calculate hor scrollbar position
si.hscroll_x = si.innerchild_x;
si.hscroll_y = (scrollbar.align() & FL_ALIGN_TOP)
? si.innerbox_y
: si.innerbox_y + si.innerbox_h - si.scrollsize;
si.hscroll_w = si.innerchild_w;
si.hscroll_h = si.scrollsize;
// calculate ver scrollbar position
si.vscroll_x = (scrollbar.align() & FL_ALIGN_LEFT)
? si.innerbox_x
: si.innerbox_x + si.innerbox_w - si.scrollsize;
si.vscroll_y = si.innerchild_y;
si.vscroll_w = si.scrollsize;
si.vscroll_h = si.innerchild_h;
// calculate h/v scrollbar values (pos/size/first/total)
si.hpos = si.innerchild_x - si.child_l;
si.hsize = si.innerchild_w;
si.hfirst = 0;
si.htotal = si.child_r - si.child_l;
if ( si.hpos < 0 ) { si.htotal += (-si.hpos); si.hfirst = si.hpos; }
si.vpos = si.innerchild_y - si.child_t;
si.vsize = si.innerchild_h;
si.vfirst = 0;
si.vtotal = si.child_b - si.child_t;
if ( si.vpos < 0 ) { si.vtotal += (-si.vpos); si.vfirst = si.vpos; }
// printf("DEBUG --- ScrollInfo ---\n");
// printf("DEBUG scrollsize: %d\n", si.scrollsize);
// printf("DEBUG hneeded, vneeded: %d %d\n", si.hneeded, si.vneeded);
// printf("DEBUG innerbox xywh: %d %d %d %d\n", si.innerbox_x, si.innerbox_y, si.innerbox_w, si.innerbox_h);
// printf("DEBUG innerchild xywh: %d %d %d %d\n", si.innerchild_x, si.innerchild_y, si.innerchild_w, si.innerchild_h);
// printf("DEBUG child lrbt: %d %d %d %d\n", si.child_l, si.child_r, si.child_b, si.child_t);
// printf("DEBUG hscroll xywh: %d %d %d %d\n", si.hscroll_x, si.hscroll_y, si.hscroll_w, si.hscroll_h);
// printf("DEBUG vscroll xywh: %d %d %d %d\n", si.vscroll_x, si.vscroll_y, si.vscroll_w, si.vscroll_h);
// printf("DEBUG horz scroll vals: %d %d %d %d\n", si.hpos, si.hsize, si.hfirst, si.htotal);
// printf("DEBUG vert scroll vals: %d %d %d %d\n", si.vpos, si.vsize, si.vfirst, si.vtotal);
// printf("DEBUG \n");
}
/**
Returns the bounding box for the interior of the scrolling area, inside
the scrollbars.
@@ -157,79 +280,43 @@ void Fl_Scroll::draw() {
}
}
// accumulate bounding box of children:
int l = X; int r = X; int t = Y; int b = Y;
Fl_Widget*const* a = array();
for (int i=children()-2; i--;) {
Fl_Object* o = *a++;
if (o->x() < l) l = o->x();
if (o->y() < t) t = o->y();
if (o->x()+o->w() > r) r = o->x()+o->w();
if (o->y()+o->h() > b) b = o->y()+o->h();
}
// Calculate where scrollbars should go, and draw them
{
ScrollInfo si;
recalc_scrollbars(si);
// turn the scrollbars on and off as necessary:
// See if children would fit if we had no scrollbars...
X = x()+Fl::box_dx(box());
Y = y()+Fl::box_dy(box());
W = w()-Fl::box_dw(box());
H = h()-Fl::box_dh(box());
int vneeded = 0;
int hneeded = 0;
if (type() & VERTICAL) {
if ((type() & ALWAYS_ON) || t < Y || b > Y+H) {
vneeded = 1;
W -= scrollbar.w();
if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar.w();
}
}
if (type() & HORIZONTAL) {
if ((type() & ALWAYS_ON) || l < X || r > X+W) {
hneeded = 1;
H -= hscrollbar.h();
if (scrollbar.align() & FL_ALIGN_TOP) Y += hscrollbar.h();
// recheck vertical since we added a horizontal scrollbar
if (!vneeded && (type() & VERTICAL)) {
if ((type() & ALWAYS_ON) || t < Y || b > Y+H) {
vneeded = 1;
W -= scrollbar.w();
if (scrollbar.align() & FL_ALIGN_LEFT) X += scrollbar.w();
}
// Now that we know what's needed, make it so.
if (si.vneeded && !scrollbar.visible()) {
scrollbar.set_visible();
d = FL_DAMAGE_ALL;
}
else if (!si.vneeded && scrollbar.visible()) {
scrollbar.clear_visible();
draw_clip(this, si.vscroll_x, si.vscroll_y, si.vscroll_w, si.vscroll_h);
d = FL_DAMAGE_ALL;
}
if (si.hneeded && !hscrollbar.visible()) {
hscrollbar.set_visible();
d = FL_DAMAGE_ALL;
}
else if (!si.hneeded && hscrollbar.visible()) {
hscrollbar.clear_visible();
draw_clip(this, si.hscroll_x, si.hscroll_y, si.hscroll_w, si.hscroll_h);
d = FL_DAMAGE_ALL;
}
else if ( hscrollbar.h() != si.scrollsize || scrollbar.w() != si.scrollsize ) {
// scrollsize changed
d = FL_DAMAGE_ALL;
}
}
}
// Now that we know what's needed, make it so.
if (vneeded && !scrollbar.visible()) {
scrollbar.set_visible();
d = FL_DAMAGE_ALL;
}
else if (!vneeded && scrollbar.visible()) {
scrollbar.clear_visible();
draw_clip(this,
scrollbar.align()&FL_ALIGN_LEFT ? X : X+W-scrollbar.w(),
Y, scrollbar.w(), H);
d = FL_DAMAGE_ALL;
}
if (hneeded && !hscrollbar.visible()) {
hscrollbar.set_visible();
d = FL_DAMAGE_ALL;
}
else if (!hneeded && hscrollbar.visible()) {
hscrollbar.clear_visible();
draw_clip(this,
X, scrollbar.align()&FL_ALIGN_TOP ? Y : Y+H-hscrollbar.h(),
W, hscrollbar.h());
d = FL_DAMAGE_ALL;
}
scrollbar.resize(scrollbar.align()&FL_ALIGN_LEFT ? X-scrollbar.w() : X+W,
Y, scrollbar.w(), H);
scrollbar.value(oldy = yposition_ = (Y-t), H, 0, b-t);
scrollbar.resize(si.vscroll_x, si.vscroll_y, si.vscroll_w, si.vscroll_h);
oldy = yposition_ = si.vpos; // si.innerchild_y - si.child_t;
scrollbar.value(si.vpos, si.vsize, si.vfirst, si.vtotal);
hscrollbar.resize(X,
scrollbar.align()&FL_ALIGN_TOP ? Y-hscrollbar.h() : Y+H,
W, hscrollbar.h());
hscrollbar.value(oldx = xposition_ = (X-l), W, 0, r-l);
hscrollbar.resize(si.hscroll_x, si.hscroll_y, si.hscroll_w, si.hscroll_h);
oldx = xposition_ = si.hpos; // si.innerchild_x - si.child_l;
hscrollbar.value(si.hpos, si.hsize, si.hfirst, si.htotal);
}
// draw the scrollbars:
if (d & FL_DAMAGE_ALL) {
@@ -254,7 +341,7 @@ void Fl_Scroll::resize(int X, int Y, int W, int H) {
// move all the children:
Fl_Widget*const* a = array();
for (int i=children()-2; i--;) {
Fl_Object* o = *a++;
Fl_Widget* o = *a++;
o->position(o->x()+dx, o->y()+dy);
}
if (dw==0 && dh==0) {
@@ -312,8 +399,9 @@ Fl_Scroll::Fl_Scroll(int X,int Y,int W,int H,const char* L)
hscrollbar(X,Y+H-Fl::scrollbar_size(),
W-Fl::scrollbar_size(),Fl::scrollbar_size()) {
type(BOTH);
xposition_ = 0;
yposition_ = 0;
xposition_ = oldx = 0;
yposition_ = oldy = 0;
scrollbar_size_ = 0;
hscrollbar.type(FL_HORIZONTAL);
hscrollbar.callback(hscrollbar_cb);
scrollbar.callback(scrollbar_cb);

View File

@@ -52,6 +52,7 @@ public:
/** Creates the box window */
Fl_TooltipBox() : Fl_Menu_Window(0, 0) {
set_override();
set_tooltip_window();
end();
}
void draw();

View File

@@ -1,5 +1,5 @@
//
// "$Id: filename_list.cxx 6641 2009-01-20 11:10:29Z fabien $"
// "$Id: filename_list.cxx 6833 2009-07-23 22:51:56Z AlbrechtS $"
//
// Filename list routines for the Fast Light Tool Kit (FLTK).
//
@@ -78,7 +78,7 @@ int fl_filename_list(const char *d, dirent ***list,
#ifndef HAVE_SCANDIR
int n = scandir(d, list, 0, sort);
#elif defined(__hpux) || defined(__CYGWIN__) || (__GLIBC__ >= 2 && __GLIBC_MINOR__ >= 10 )
// HP-UX, Cygwin define the comparison function like this:
// HP-UX, Cygwin and POSIX (2008) define the comparison function like this:
int n = scandir(d, list, 0, (int(*)(const dirent **, const dirent **))sort);
#elif defined(__osf__)
// OSF, DU 4.0x
@@ -126,5 +126,5 @@ int fl_filename_list(const char *d, dirent ***list,
}
//
// End of "$Id: filename_list.cxx 6641 2009-01-20 11:10:29Z fabien $".
// End of "$Id: filename_list.cxx 6833 2009-07-23 22:51:56Z AlbrechtS $".
//

View File

@@ -1,5 +1,5 @@
//
// "$Id: fl_set_fonts_xft.cxx 6616 2009-01-01 21:28:26Z matt $"
// "$Id: fl_set_fonts_xft.cxx 6833 2009-07-23 22:51:56Z AlbrechtS $"
//
// More font utilities for the Fast Light Tool Kit (FLTK).
//
@@ -380,5 +380,5 @@ int Fl::get_font_sizes(Fl_Font fnum, int*& sizep) {
}
//
// End of "$Id: fl_set_fonts_xft.cxx 6616 2009-01-01 21:28:26Z matt $".
// End of "$Id: fl_set_fonts_xft.cxx 6833 2009-07-23 22:51:56Z AlbrechtS $".
//