Contents page

Rules for Tools/DragSlider()

     long DragSlider(struct Window *window, struct Gadget *gadget,
                long width, long (*routine)(), char vertical)

    `struct Window *window'
          Window for slider.

    `struct Gadget *gadget'
          Gadget that defines slider.

    `long width'
          Slider button width.

    `long (*routine)()'
          Routine to draw button.

    `char vertical'
          TRUE if vertical slider.

     Use  `DragSlider()' in conjunction with `DrawSlider()' to create
     the sliders used extensively by the Bars&Pipes Tool control
     windows.  Each slider corresponds to an Intuition Boolean gadget
     and the bounding box of the gadget describes the region the slider
     may move within.

     To drag the slider, call `DragSlider()', passing it the window to
     draw in, the gadget, so it knows the dimensions of the slider, the
     width of the button in pixels, a routine to draw the data in the
     button, and a flag that is set if this is a vertical slider. When
     the user finally releases the slider, `DragSlider()' returns the
     final position of the slider.  The final position is actually the
     value returned by your draw routine, so you can tailor that
     routine to return a value in the appropriate range.

     `DragSlider()' calls your draw routine every time the mouse moves.
     `DragSlider()' erases the button, so your routine need only redraw
     the contents.  Here's a sample routine that converts the slider
     position into a number between 0 and 99, draws that number into
     the knob, and returns it:
long dragroutine(rastport,x,y,position) struct RastPort *rastport;    
                                                 /* RastPort to draw in.  */ 
    short x,y;                    /* Coordinates of button.  *.
    unsigned short position;      /* The slider position. */ 
    char text[20];
    position = position / 655;

     To use `DragSlider()', set up your window to receive Intuition
     When the user clicks on your slider's Boolean gadget, respond to
     the `GADGETDOWN' event with a call to `DragSlider()'.  The
     following example uses a horizontal slider 30 pixels wide:
	 newvalue = (*functions->DragSlider)(window,gadget,30,dragroutine,0);

     See DrawSlider().