Scroll doesn't show all widgets after change of positions

27 views
Skip to first unread message

Edzard Egberts

unread,
Jun 14, 2017, 3:16:15 AM6/14/17
to 'ed' via fltk.general
FLTK 1.3.4 stable release, but I just tried Revision 12260 (BTW - is
there a way to query FLTK build number from software?):

I programmed a viewer to show images inside of a Fl_Scroll, but got the
problem, that the scroll initially does not show images at right side.

Appended is a minimal example that reproduced the problem under
CentOS-6/64bit and MS-Windows-7/32bit:

Clicking to a "Test" button will change columns between 5 and 10 and
shows missing drawing at right side. When there are 5 columns and after
scrolling the buttons down and up again, the whole area is drawn fine
(10 columns are not enough rows to scroll down and up).

I cannot find an error in my code, not even have a clue, what could be
wrong. :o(

Looks like the scroll doesn't know about its own area, but usage of
init_sizes() doesn't change anything.
main.cpp
Scrolltest.png

Greg Ercolano

unread,
Jun 14, 2017, 1:19:38 PM6/14/17
to fltkg...@googlegroups.com
On 06/14/17 00:15, Edzard Egberts wrote:
> for (int i= 0; i< pScroll->children(); ++i)

Keep in mind the scrollbars are also children of Fl_Scroll,
so don't resize them as part of your loop.

Make these changes to fix that problem:

for (int i= 0; i< pScroll->children(); ++i)
- { // Change position of the children
- pScroll->child(i)->resize(pScroll->x() + x, pScroll->y() + y, w, h);
+ {
+ Fl_Widget *o = pScroll->child(i);
+
+ // Skip scrollbars
+ if ( o == &(pScroll->scrollbar) || o == &(pScroll->hscrollbar) ) continue;
+
+ // Change position of the children
+ o->resize(pScroll->x() + x, pScroll->y() + y, w, h);

Greg Ercolano

unread,
Jun 14, 2017, 1:37:57 PM6/14/17
to fltkg...@googlegroups.com
On 06/14/17 00:15, Edzard Egberts wrote:
> (BTW - is there a way to query FLTK build number from software?)

Not that I'm aware of.
Would certainly be good if FLTK had that built into a variable like FL_SCM_VERSION
during builds. Perhaps for 1.4 we can add this.

In my own software, I use the Makefile to run a small perl script
to get the svnversion of FLTK, and define it as a string in the
macro variable FL_SCM_VERSION.

I like to show the build date + FLTK svn version# in my FLTK app's
"About" dialog, so customers can paste it back to me when they
encounter drawing problems. Helps for bisects.

Here's the perl script which outputs a .h file that defines some
macros with date/time + FLTK svn version info that my apps then #include:

# GET DATE/TIME
my ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time);
$year += 1900;
$date = sprintf("%02d/%02d/%02d,%02d:%02d", ($mon+1),$mday,($year % 100),$hour,$min);

# USE SVNVERSION TO GET FLTK REV#
my $scm_rev = `( cd FLTK/fltk && svnversion )`; chomp($scm_rev);
if ( $scm_rev eq "" ) { $scm_rev = "????"; }
print <<"EOF";
#ifndef COPYRIGHT_YEAR
#define COPYRIGHT_YEAR "$year"
#define BUILD_DATE "$date"
#define FL_SCM_VERSION "$scm_rev"
#endif
EOF
exit(0);

..and here's the Makefile target that runs it to generate the .h file:

----
copyright_year.h: FORCE
perl copyright_year.pl > copyright_year.h
----

Edzard Egberts

unread,
Jun 19, 2017, 2:46:07 AM6/19/17
to 'ed' via fltk.general
Greg Ercolano wrote:
> On 06/14/17 00:15, Edzard Egberts wrote:
>> for (int i= 0; i< pScroll->children(); ++i)
>
> Keep in mind the scrollbars are also children of Fl_Scroll,
> so don't resize them as part of your loop.

Thank you, I didn't realise this, because the resized scrollbar didn't
show up as a scrollbar. I saw two empty places at start of program, but
there was no hint, where they came from.

Reply all
Reply to author
Forward
0 new messages