1 /* 2 JSDSlider.cpp 3 Dr.H.Reh 4 27.11.2004 5 6 Based on source code from Be Inc. RIP 7 Copyright 1995 Be Incorporated, All Rights Reserved. 8 */ 9 10 #include "JSDSlider.h" 11 12 #include <stdlib.h> 13 #include <stdio.h> 14 #include <string.h> 15 16 17 JSDSlider::JSDSlider(BRect frame, const char* name, const char *label, 18 BMessage *msg, int32 min, int32 max, thumb_style t) 19 : BSlider(frame, name, label, msg, min, max, t) 20 { 21 } 22 23 24 JSDSlider::~JSDSlider() 25 { 26 } 27 28 29 #ifdef __HAIKU__ 30 const 31 #endif 32 char* 33 JSDSlider::UpdateText() const 34 { 35 // When the slider's Draw method is called, this method will also be called. 36 // If its return value is non-NULL, then it will be drawn with the rest of 37 // the slider 38 static char string[64]; 39 string[0] = 0; 40 41 if (!strcmp("gamma", Name())) { 42 float gamma; 43 gamma = exp((Value() * log(2.0) * 0.01) ); 44 sprintf(string, " %.2f", gamma); 45 } else if (!strcmp("inkDensity", Name()) ) { 46 float density = Value(); 47 density = (density / 127.0) * 100.0; 48 sprintf(string," %.0f%%", density); 49 } 50 51 fResult.SetTo(string); 52 #ifdef __HAIKU__ 53 return fResult.String(); 54 #else 55 return const_cast<char*>(fResult.String()); 56 #endif 57 } 58