mday@pollack.mmwb.ucsf.edu (Mark Day) (11/13/90)
According to the XView programming manual, the value of a slider is an integer, yet this manual also states that: "Sliders are appropriate for situations where it is desired to make fine adjustments over a continuous range of values" It's not obvious to me that integer values will always have the precision necessary for making these "fine adjustments". 1. Is there a floating point slider hidden somewhere in the xview library? 2. Is the xview specification "frozen", or is there still time to add such a beast? 3. Has anyone implemented an xview floating point slider that I can borrow? (I'll return it, I promise) Mark Day Dept. of Pharmaceutical Chemistry mday@zeno.mmwb.ucsf.edu University of California, San Francisco ..ucbvax!ucsfcgl!mday Voice: (415) 476-5326 FAX: (415) 476-0688
tomj@Eng.Sun.COM (Tom Jacobs) (11/14/90)
>According to the XView programming manual, the value of a slider is >an integer, yet this manual also states that: > "Sliders are appropriate for situations where it is desired to make > fine adjustments over a continuous range of values" > >It's not obvious to me that integer values will always have the precision >necessary for making these "fine adjustments". > >1. Is there a floating point slider hidden somewhere in the xview library? No, sorry. >2. Is the xview specification "frozen", or is there still time to add such > a beast? XView is constantly being improved and enhanced. You have two avenues to get this functionality. 1) Submit a "Request for Feature Enhansement" (aka RFE) to Sun and/or xviewbugs, or 2) Pick-up the publicly available source to XView and modify the source to use floating point on your own. Considering our already long list of RFEs, new features and quality goals, I'd suggest #2 if you need it anytime soon. >3. Has anyone implemented an xview floating point slider that I can borrow? > (I'll return it, I promise) Not that I've heard of... >Mark Day >Dept. of Pharmaceutical Chemistry mday@zeno.mmwb.ucsf.edu >University of California, San Francisco ..ucbvax!ucsfcgl!mday >Voice: (415) 476-5326 FAX: (415) 476-0688 --- Tom Jacobs ARPA: tomj@Eng.Sun.com Engineering Manager, XView UUCP: sun!tomj Windows & Graphics Software Sun Microsystems, Inc.
Charles.Tierney@West.Sun.COM (Charlie Tierney - Sun San Francisco SE) (11/14/90)
Somebody recently posted a message annuncing the availability of some type of generalized floating point extension to xview. For the life of me I can't remember exactly who posted it or what the package did (I want to say it does graphs). Would someone in our large and esteemed audience please enlighten Mr. Day and myself? Thank You, Charlie Tierney 415.781.8140 Systems Engineer Sun San Francisco
salzman@Eng.Sun.COM (Isaac Salzman) (11/14/90)
>mday@pollack.mmwb.ucsf.edu (Mark Day) writes: >1. Is there a floating point slider hidden somewhere in the xview library? no. >2. Is the xview specification "frozen", or is there still time to add such a b >east? actually, you mean that *OPEN LOOK* spec. i doub't it's completely "frozen", but i have no idea about the status of other types of sliders and panel items in general. what's really needed is a general purpose slider (so you can have strings or whatever you want instead of just numeric values - int, float, or otherwise). >3. Has anyone implemented an xview floating point slider that I can borrow? >(I'll return it, I promise) sort of. i hacked one up using a normal slider and a PANEL_TEXT (with LOTS of help from Devguide). basically, you create a PANEL_SLIDER with no decorations (labels, text output of value, etc.). drop a PANEL_TEXT in front of it: make it read only. so it looks like this: This is a Float Slider: ____ I---[]----------I If you really want to label the ends of the slider, dump a couple PANEL_MESSAGE items in front of/behind the slider end points. so it's not really a floating pt. slider, but it looks like one. you package things up so that when the slider value changes, the associated text item is updated to reflect the floating point value. when you get the value from the slider you need to convert it to floating pt. i've got it in some code i'm hacking on, and it seems to work just fine. i've chopped out the relevant pieces (along with an example main that i threw together off the top of my head) and included them below. it's relatively straightforward. if you have any problems trying to use this, drop me some (private) e-mail. ciao! -- * Isaac J. Salzman ---- * Sun Microsystems Inc., Audio Tools & Integration /o o/ / * 2550 Garcia Ave., Mt. View, CA 94043-1100, MS: MTV23-03 | v | | * AT&T : +1 415-336-4338 _| |_/ * Internet : salzman@Eng.Sun.COM / | | * UUCP : ...!sun!salzman | | | ------------------------------------------------------------------ #include <xview/xview.h> #include <xview/panel.h> #include <math.h> /* attach a ptr to this struct to a slider to cvt it's value to * the appropriate fp value and stuff it in the text area. */ #define FPSTRLEN 10 /* string len for cvt'ing floats... */ #define CVTODBL(val, scale) ((double)(val * (double)scale)) #define CVTOINT(val, scale) (nint(val / (double)scale)) struct float_slider_data { Panel_text text; /* text item to set w/float value */ double scale; /* scale factor */ }; Attr_attribute FPSLIDERKEY; /* for sliders - to cvt to floating pt. */ /* convert a slider to "floating point" slider. */ void make_float_slider(slider, text, scale) Panel_slider slider; Panel_text text; double scale; { struct float_slider_data *fsdp; if (!(fsdp = (struct float_slider_data *) calloc(1, sizeof(struct float_slider_data)))) { fprintf(stderr,"warning: can't malloc float_slider_data\n"); return; } fsdp->scale = scale; fsdp->text = text; xv_set(slider, PANEL_NOTIFY_LEVEL, PANEL_ALL, /* ALWAYS send notify events */ XV_KEY_DATA, FPSLIDERKEY, fsdp, NULL); } /* update the text item associated with a "floating pt" slider. * if FPSLIDERKEY isn't set on the slider, ignore... */ void update_float_slider_text(slider, val) Panel_slider slider; int val; { struct float_slider_data *fsdp; int ival; double dval; char sval[FPSTRLEN]; if (!(fsdp = (struct float_slider_data *) xv_get(slider, XV_KEY_DATA, FPSLIDERKEY))) { fprintf(stderr, "warning: can't get FPSLIDERKEY for slider\n"); return; } /* XXX the precision should depend on the size of the text * area and the min/max and scale ... */ dval = CVTODBL(val, fsdp->scale); if (dval < 10.0) sprintf(sval, "%2.4f", dval); else sprintf(sval, "%4.2f", dval); xv_set(fsdp->text, PANEL_VALUE, sval, NULL); } /* a routine for getting the floating pt. value of the slider */ double get_float_slider_value(s) Panel_slider s; { struct float_slider_data *fsdp; ival i; if (fsdp = (struct float_slider_data *) xv_get(s, XV_KEY_DATA, FPSLIDERKEY)) { ival = xv_get(s, PANEL_VALUE); return (CVTODBL(ival, fsdp->scale)); } return (0.0); } /* typical notify proc for a "floating pt. slider" */ void slider_notify(item, value, event) Panel_item item; int value; Event *event; { /* do stuff with slider value, if you want, then update the * the associated text item for the floating pt. slider. */ update_float_slider_text(item, value); } main() { Frame f; Panel p; Panel_slider s; Panel_text t; xv_init(...); FPSLIDERKEY = xv_unique_key(); f = xv_create(NULL, FRAME, ...); p = xv_create(f, PANEL, ...); s = xv_create(p, PANEL_SLIDER, ..., PANEL_NOTIFY_PROC, slider_notify, NULL); t = xv_create(p, PANEL_TEXT, ...); /* scale is 0.10, so if the MIN is 0 and the MAX is 10, you'll get * 0.0 to 1.0 in 1/10 unit increments (0.10, 0.20, ..., 1.0). make_float_slider(s, t, 0.10); /* set slider (and slider text) to some initial value. */ xv_set(s, PANEL_VALUE, CVTOINT(0.20, 0.10), NULL); update_float_slider_text(s, CVTOINT(0.20, 0.10)); /* and off you go. everytime the slider is moved, the associated * text item will be updated to represent the floating pt. * value of the slider. */ xv_main_loop(f); }
susan.bickford@East.Sun.COM (Susan Bickford-NorthEast Area Technology Mgr) (11/14/90)
> Somebody recently posted a message annuncing the availability > of some type of generalized floating point extension to xview. > > For the life of me I can't remember exactly who posted it or > what the package did (I want to say it does graphs). > > Would someone in our large and esteemed audience please > enlighten Mr. Day and myself? I think you are referring to the KL Group in Toronto. Their number is (416) 594-1026. Ask for Greg Kiessling. They are doing some very interesting work with XView extensions. Susan Bickford Sun Microsystems Systems Engineer - NorthEast Area sbickford@sun.com