Commit 42918c82 authored by plgruener's avatar plgruener

record Mouse push relative to ScrollBox

parent 90a2608d
......@@ -5,13 +5,37 @@
#include <FL/Fl_Shared_Image.H>
#include <FL/Fl_PNG_Image.H>
class ScrollBox : public Fl_Box {
Fl_Scroll *scroll;
public:
int handle(int e) {
if ( e == FL_PUSH ) {
fprintf(stderr, "event_x,event_y: %d,%d, Hit on box: %d,%d\n",
Fl::event_x(),
Fl::event_y(),
Fl::event_x() - scroll->x() + scroll->hscrollbar.value(),
Fl::event_y() - scroll->y() + scroll->scrollbar.value());
}
return(Fl_Box::handle(e));
}
void SetScroll(Fl_Scroll *val) {
scroll = val;
}
ScrollBox(int x,int y,int w,int h,const char*l=0) : Fl_Box(x,y,w,h,l) {
color(FL_BLUE);
box(FL_FLAT_BOX);
}
};
int main (int argc, char **argv) {
fl_register_images();
Fl_PNG_Image picture("picture.png");
Fl_Double_Window window(600,400,"Dynamic Systems");
Fl_Scroll scroll(0,0,600,400);
Fl_PNG_Image picture("picture.png");
Fl_Box box(0,0,picture.w(),picture.h());
ScrollBox box(0,0,picture.w(),picture.h());
box.SetScroll(&scroll);
box.image(picture);
scroll.end();
window.resizable(window);
window.show();
return Fl::run();
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment