I have written a small programm (see below). The scrollbar hesitates
to work properly.
If WITH_VBAR_VALUE is defined, the slider is too large.
If WITH_VBAR_VALUE is undefined, the slider is too small. A restrained
usage is possible: PUSH and WHEEL works, but DRAG does not work.
But: the children of the ScrollGroup do not move. I must enlarge the
window to see the Input an Button.
What am I missing? Must I write a handle() and a draw() method for
the ScrollGroup? Or should the standard methods do it?
winfried
#include <stdlib.h>
#include <fltk/run.h>
#include <fltk/draw.h>
#include <fltk/Widget.h>
#include <fltk/Window.h>
#include <fltk/ScrollGroup.h>
#include <fltk/Button.h>
#include <fltk/Box.h>
#include <fltk/Input.h>
#include <fltk/Color.h>
//#define WITH_VBAR_VALUE
using namespace fltk;
static ScrollGroup *scrollG;
static Input *inp;
static Button *but;
class Canvas : public Widget
{
void draw();
public:
Canvas(int X,int Y,int W,int H) : Widget(X,Y,W,H)
{
box(FLAT_BOX);
}
};
void Canvas::draw()
{
draw_box();
setfont(HELVETICA, h());
setcolor(RED);
drawtext("A", Rectangle(w(),h()), ALIGN_CENTER);
}
static Canvas *canvas;
void ScrollGroup::layout()
{
canvas = new Canvas(0,0,400,375);
canvas->color(fltk::color("orange"));
int X = 10, Y = 320;
inp = new Input(X, Y, 100, 25);
inp->text("HELLO");
X += 110;
but = new Button(X, Y, 50,25);
but->copy_label("But");
add(but); add(inp); add(canvas);
w(canvas->w()+17);
hscrollbar.hide();
#ifdef WITH_VBAR_VALUE
scrollbar.value(0,w()+17,0,375);
#endif
scrollbar.resize(w()-17,y(),17,h());
scrollbar.show();
}
void cancel_cb(Widget* o, void*)
{
exit(0);
}
int main(int argc, char** argv)
{
Window *win = new Window(417,340);
win->begin();
scrollG = new ScrollGroup(0,0,400,300);
scrollG->type(scrollG->VERTICAL);//scrollbar type
scrollG->box(DOWN_BOX);
scrollG->color(WHITE);
Button *b = new Button(50, 310, 60, 25, "Cancel");
b->callback(cancel_cb);
win->resizable(scrollG);
win->end();
win->show();
return run();
}
_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk