Following the advice of Greg Ercolano I have created the
directories fltk-3.0.x-r9366 and fltk-3.0.x-r9367.
Then I have copied the contents of fltk-3.0.x-r9701 into
these directories and called 'make distclean'.
Then in fltk-3.0.x-r9366 I have called 'svn update -r9366';
and in fltk-3.0.x-r9367 I have called 'svn update -r9367'.
Then I have first compiled and installed fltk-3.0.x-r9366,
then fltk-3.0.x-r9367.
Between fltk-3.0.x-r9366 and fltk-3.0.x-r9367 a bug has been
inserted into ScrollGroup.
The bug does allow only an origin of (0,0) for a ScrollGroup.
The attached file 'group.cxx' shows that with fltk-3.0.x-r9366
a BMP file can be scrolled; but with fltk-3.0.x-r9367 scrolling
the BMP file shows a broken image.
My BMP file has a size of 720x486 to allow scrolling.
winfried
-------------------------------------------------------
#include <fltk3/run.h>
#include <fltk3/DoubleWindow.h>
#include <fltk3/Window.h>
#include <fltk3/draw.h>
#include <fltk3/Group.h>
#include <fltk3/ScrollGroup.h>
#include <fltk3/Box.h>
#include <fltk3/Button.h>
#include <fltk3/Widget.h>
#include <fltk3/Image.h>
#include <fltk3/RGBImage.h>
#include <fltk3/SharedImage.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
static fltk3::DoubleWindow *win;
static fltk3::Group *grp;
static fltk3::ScrollGroup *scroll;
static fltk3::Widget *wid;
static fltk3::SharedImage *img;
#define WIN_W 640
#define WIN_H 400
#define BORDER_SIZE 5
#define BAR_SIZE 17
#define GROUP_X 10
#define GROUP_Y 10
#define BUT_X GROUP_X + 5
#define BUT_Y GROUP_Y + 5
#define BUT_H 25
#define SCROLL_X GROUP_X
#define SCROLL_Y GROUP_Y + 5 + BUT_H + 5
#define GROUP_W (WIN_W - GROUP_X - GROUP_X)
#define GROUP_H (WIN_H - GROUP_Y - BORDER_SIZE)
#define SCROLL_W GROUP_W
#define SCROLL_H GROUP_H - SCROLL_Y
static void exit_cb(fltk3::Widget *w, void *v)
{
exit(0);
}
static void load_file(const char *fname)
{
if(fname)
{
int t = 0;
int a = 0;
int w, h, win_w, win_h, hbar, vbar;
img = fltk3::SharedImage::get(fname);
if(img)
{
int win_w, win_h, scr_h, scr_w, iw, ih;
int has_hbar, has_vbar;
unsigned char type;
has_hbar = has_vbar = 0;
iw = img->w(); ih = img->h();
if(iw > SCROLL_W - BAR_SIZE) has_hbar = BAR_SIZE;
if(ih > SCROLL_H - BAR_SIZE) has_vbar = BAR_SIZE;
if(has_vbar)
{
scr_h = SCROLL_H;
}
else
{
scr_h = ih + has_hbar;
}
if(has_hbar)
{
scr_w = SCROLL_W;
}
else
{
scr_w = iw + has_vbar;
}
win_h = SCROLL_Y + scr_h + BORDER_SIZE;
win_w = SCROLL_X + scr_w + SCROLL_X;
if(win_w < 120) win_w = 120;
grp->h(win_h - GROUP_Y - BORDER_SIZE);
grp->w(win_w - GROUP_X - GROUP_X);
printf("%s:%d: WIN(%d,%d) GROUP(%d,%d,%d,%d) SCROLL(%d,%d)\n",
__FILE__,__LINE__,win_w, win_h,
grp->x(),grp->y(),grp->w(),grp->h(),
scr_w, scr_h);
/* win->resize(win->x(), win->y(), win_w, win_h); */
win->size(win_w, win_h);
scroll->size(scr_w, scr_h);
wid->size(img->w(), img->h());
wid->image(img);
type = 0;
if(has_hbar) type |= fltk3::ScrollGroup::HORIZONTAL;
if(has_vbar) type |= fltk3::ScrollGroup::VERTICAL;
scroll->type(type);
scroll->scroll_to(0,0);
win->redraw();
}
}
}
int main(int argc, char *argv[])
{
char *fname;
FILE *fp;
fltk3::register_images();
if(argc == 2)
{
fname = argv[1];
fp = fopen(fname, "r");
if(fp == NULL)
{
fname = NULL;
}
else
{
fclose(fp);
}
}
else
{
fname = NULL;
}
win = new fltk3::DoubleWindow(WIN_W, WIN_H, "ScrollGroup Test");
win->begin();
grp = new fltk3::Group(GROUP_X, GROUP_Y, GROUP_W, GROUP_H);
grp->begin();
fltk3::Button *but1 = new fltk3::Button(BUT_X, BUT_Y, 80, BUT_H, "Exit");
but1->callback(exit_cb);
scroll = new fltk3::ScrollGroup(SCROLL_X, SCROLL_Y, SCROLL_W, SCROLL_H);
scroll->box(fltk3::FLAT_BOX);
scroll->begin();
wid = new fltk3::Widget(0, 0, SCROLL_W, SCROLL_H);
wid->box(fltk3::FLAT_BOX);
wid->color(fltk3::WHITE);
scroll->end();
scroll->resizable(wid);
grp->end();
win->end();
win->show();
load_file(fname);
return fltk3::run();
}
diff -u --recursive fltk-3.0.x-r9366/src/fltk3/ScrollGroup.cxx
fltk-3.0.x-r9367/src/fltk3/ScrollGroup.cxx
--- fltk-3.0.x-r9366/src/fltk3/ScrollGroup.cxx 2012-10-24 15:18:19.139346650
+0200
+++ fltk-3.0.x-r9367/src/fltk3/ScrollGroup.cxx 2012-10-24 15:30:14.081394161
+0200
@@ -1,9 +1,9 @@
//
-// "$Id: ScrollGroup.cxx 9048 2011-09-18 20:11:00Z matt $"
+// "$Id: ScrollGroup.cxx 9560 2012-05-30 21:04:33Z matt $"
//
// Scroll widget for the Fast Light Tool Kit (FLTK).
//
-// Copyright 1998-2010 by Bill Spitzak and others.
+// Copyright 1998-2012 by Bill Spitzak and others.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Library General Public
@@ -62,32 +62,30 @@
fltk3::push_clip(X,Y,W,H);
fltk3::ScrollGroup* s = (fltk3::ScrollGroup*)v;
// erase background as needed...
- switch (s->box()) {
- case fltk3::NO_BOX :
- case fltk3::UP_FRAME :
- case fltk3::DOWN_FRAME :
- case fltk3::THIN_UP_FRAME :
- case fltk3::THIN_DOWN_FRAME :
- case fltk3::ENGRAVED_FRAME :
- case fltk3::EMBOSSED_FRAME :
- case fltk3::BORDER_FRAME :
- case fltk3::SHADOW_FRAME :
- case fltk3::ROUNDED_FRAME :
- case fltk3::OVAL_FRAME :
- case fltk3::PLASTIC_UP_FRAME :
- case fltk3::PLASTIC_DOWN_FRAME :
- if (s->parent() == (fltk3::Group *)s->window() && fltk3::scheme_bg_) {
- fltk3::scheme_bg_->draw(X-(X%((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->w()),
- Y-(Y%((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->h()),
- W+((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->w(),
- H+((fltk3::TiledImage *)fltk3::scheme_bg_)->image()->h());
- break;
- }
-
- default :
- fltk3::color(s->color());
- fltk3::rectf(X,Y,W,H);
- break;
+ fltk3::Box* sbx = s->box();
+ if ( sbx==fltk3::NO_BOX
+ || sbx==fltk3::UP_FRAME
+ || sbx==fltk3::DOWN_FRAME
+ || sbx==fltk3::THIN_UP_FRAME
+ || sbx==fltk3::THIN_DOWN_FRAME
+ || sbx==fltk3::ENGRAVED_FRAME
+ || sbx==fltk3::EMBOSSED_FRAME
+ || sbx==fltk3::BORDER_FRAME
+ || sbx==fltk3::SHADOW_FRAME
+ || sbx==fltk3::ROUNDED_FRAME
+ || sbx==fltk3::OVAL_FRAME
+ || sbx==fltk3::PLASTIC_UP_FRAME
+ || sbx==fltk3::PLASTIC_DOWN_FRAME)
+ {
+ if (s->parent() == (fltk3::Group *)s->window() && fltk3::scheme_bg_) {
+ fltk3::scheme_bg_->draw(X-(X%((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->w()),
+ Y-(Y%((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->h()),
+ W+((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->w(),
+ H+((fltk3::TiledImage
*)fltk3::scheme_bg_)->image()->h());
+ }
+ } else {
+ fltk3::color(s->color());
+ fltk3::rectf(X,Y,W,H);
}
fltk3::Widget*const* a = s->array();
for (int i=s->children()-2; i--;) {
@@ -109,8 +107,8 @@
void fltk3::ScrollGroup::recalc_scrollbars(ScrollInfo &si) {
// inner box of widget (excluding scrollbars)
- si.innerbox_x = x()+fltk3::box_dx(box());
- si.innerbox_y = y()+fltk3::box_dy(box());
+ si.innerbox_x = fltk3::box_dx(box());
+ si.innerbox_y = fltk3::box_dy(box());
si.innerbox_w = w()-fltk3::box_dw(box());
si.innerbox_h = h()-fltk3::box_dh(box());
@@ -229,8 +227,8 @@
outside of the draw() method (STR #1895).
*/
void fltk3::ScrollGroup::bbox(int& X, int& Y, int& W, int& H) {
- X = x()+fltk3::box_dx(box());
- Y = y()+fltk3::box_dy(box());
+ X = fltk3::box_dx(box());
+ Y = fltk3::box_dy(box());
W = w()-fltk3::box_dw(box());
H = h()-fltk3::box_dh(box());
if (scrollbar.visible()) {
@@ -250,7 +248,7 @@
uchar d = damage();
if (d & fltk3::DAMAGE_ALL) { // full redraw
- draw_box(box(),x(),y(),w(),h(),color());
+ draw_box(box(),0,0,w(),h(),color());
draw_clip(this, X, Y, W, H);
} else {
if (d & fltk3::DAMAGE_SCROLL) {
@@ -396,11 +394,12 @@
that it is destroyed last.
*/
fltk3::ScrollGroup::ScrollGroup(int X,int Y,int W,int H,const char* L)
- : fltk3::Group(X,Y,W,H,L),
- scrollbar(X+W-fltk3::scrollbar_size(),Y,
- fltk3::scrollbar_size(),H-fltk3::scrollbar_size()),
- hscrollbar(X,Y+H-fltk3::scrollbar_size(),
- W-fltk3::scrollbar_size(),fltk3::scrollbar_size()) {
+: fltk3::Group(X,Y,W,H,L),
+ scrollbar(X+W-fltk3::scrollbar_size(),Y,
+ fltk3::scrollbar_size(),H-fltk3::scrollbar_size()),
+ hscrollbar(X,Y+H-fltk3::scrollbar_size(),
+ W-fltk3::scrollbar_size(),fltk3::scrollbar_size())
+{
type(BOTH);
xposition_ = oldx = 0;
yposition_ = oldy = 0;
@@ -416,5 +415,5 @@
}
//
-// End of "$Id: ScrollGroup.cxx 9048 2011-09-18 20:11:00Z matt $".
+// End of "$Id: ScrollGroup.cxx 9560 2012-05-30 21:04:33Z matt $".
//
_______________________________________________
fltk-bugs mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-bugs