RE: [Plib-users] legend update
Brought to you by:
sjbaker
|
From: stathis <st...@nt...> - 2002-01-29 17:23:47
|
Hi again,
I read carefully what everyone proposed. For my purposes the sliderCB as I initialy said
is a "generic" callback used by many sliders, so the static idea is not solving it (globally
defined pointers to arrays of chars do, but need 1 for each slider). I think the best
solution would be to actually derive a class from puSlider as Sebastian said. To quickly
solve it I ended up hacking a little bit the pu.h.I know I shouldn't but I have to get a
solution quickly for now.
Here is what I've done, which I am sure is not the most compact and correct way of
doing it, but it works for now:
pu.h around line 415:
char string [ PUSTRING_MAX ] ;
char formatted [ PUSTRING_MAX ] ; // I added this to store my formatted string
pu.h around line 482:
char *getStringValue () { return res_string ? res_string : string ; }
// I added the one below
char *getStringValue (const char * format) {
sprintf(formatted, format, string);
return res_string ? res_string : formatted ;
}
This allows me to change my initial solution with the long digit output
from:
slicb->setLegend(slicb->getStringValue());
to:
slicb->setLegend(slicb->getStringValue("%.4s"));
Now all my sliders will return me a user defined formatted output. I don't think this will
break the other widgets, but feel free to correct me.
I'm sorry I don't mean to intrude the inner workings of this so nice library so I will move
my stuff where it belongs when time and skill allows. (Be kind I'm not a pro programmer).
Thank you very much for the input.
stathis
|