OK, didn't get a chance for a coffee break, so I did this over lunch
instead...

Here's the scroll-wheel slider demo:

Save as wheel.cxx then compile with

Fltk-config --compile wheel.cxx

#include <FL/Fl.H>
#include <FL/Fl_Double_Window.H>
#include <FL/Fl_Value_Slider.H>

class wheel_slider: public Fl_Value_Slider
{
        int handle(int);
public:
        wheel_slider(int x, int y, int w, int h, const char *l=0) : 
        Fl_Value_Slider (x,y,w,h,l) {}
};

int wheel_slider::handle(int ev) {
        // do the base-class actions
        int res = Fl_Value_Slider::handle(ev);
        // now check for wheel-mouse events
    if (ev == FL_MOUSEWHEEL) {
                // for wheel - use dy
                int dy = Fl::event_dy();
                double v1 = value(); // current value
                v1 = increment(v1, dy); // change
                v1 = clamp(v1); // clamp to valuator limits
                value(v1); // update widget
                return 1; // say we ate this event
        }
        return res;
} // handle

static wheel_slider *level, *l2;

int main(int argc, char **argv) {
        Fl_Double_Window *main_win = new Fl_Double_Window(300, 400,
"Slider Window");
        main_win->begin();
        
        level = new wheel_slider(135, 20, 30, 195, "Level");
        level->type(FL_VERT_NICE_SLIDER);
        level->minimum(100);
        level->maximum(0);
        level->step(1);
        
        l2 = new wheel_slider(20, 270, 260, 30, "Pan");
        l2->type(FL_HOR_NICE_SLIDER);
        l2->minimum(0);
        l2->maximum(100);
        l2->step(-1);

        main_win->end();
        main_win->show(argc, argv);
        return Fl::run();
} // main

/* end of file */





SELEX Sensors and Airborne Systems Limited
Registered Office: Sigma House, Christopher Martin Road, Basildon, Essex SS14 
3EL
A company registered in England & Wales.  Company no. 02426132
********************************************************************
This email and any attachments are confidential to the intended
recipient and may also be privileged. If you are not the intended
recipient please delete it from your system and notify the sender.
You should not copy it or use it for any purpose nor disclose or
distribute its contents to any other person.
********************************************************************

_______________________________________________
fltk mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk

Reply via email to