Re: [Plib-users] legend update
Brought to you by:
sjbaker
|
From: Sebastian U. <ud...@ha...> - 2002-01-29 17:25:41
|
On Tue, 29 Jan 2002, sj...@li... (Stephen J Baker) wrote:
> Date: Tue, 29 Jan 2002 11:01:25 -0600 (CST)
> To: <pli...@li...>
> From: sj...@li... (Stephen J Baker)
> Reply-To: sj...@li...
> Subject: Re: [Plib-users] legend update
[...]
> > A possible, but not the best, solution would be to abuse the slider's
> > string buffer to store the legend string.
>
> Yuk.
Hehe ... I know it sounds ugly, but it does work since the callback is
invoked in puSlider::doHit () *after* the setValue () call, which does fill
the string value buffer with the floating-point number.
So, basically, you connect the widget's string value buffer to it's legend
pointer once and then override the content of the string buffer on every
slider movement from the callback.
Okay ... Yuk :).
> > You could also derive your own
> > class from puSlider and add a char[] array member.
>
> That would work...or you could use the 'userdata' field to hold the
> array - that's *probably* what I would do.
So you would place something like that in the callback:
/* [...] */
if ( sli -> getUserData () == NULL )
{
char *p = new char [10] ;
sli -> setUserData ( p ) ;
}
snprintf ( (char *) sli -> getUserData (), 10, "%.2f", sli -> getFloatValue () ) ;
/* [...] */
Mhm ... you had take care of the deallocation of the array then ...
- Sebastian
|