xref: /haiku/src/libs/print/libprint/JSDSlider.cpp (revision b8a45b3a2df2379b4301bf3bd5949b9a105be4ba)
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(const char* name, const char* label,
18 	BMessage* msg, int32 min, int32 max)
19 	: BSlider(name, label, msg, min, max, B_HORIZONTAL)
20 {
21 }
22 
23 
24 JSDSlider::~JSDSlider()
25 {
26 }
27 
28 
29 const char*
30 JSDSlider::UpdateText() const
31 {
32 	// When the slider's Draw method is called, this method will also be called.
33 	// If its return value is non-NULL, then it will be drawn with the rest of
34 	// the slider
35 	static char string[64];
36 	string[0] = 0;
37 
38 	if (!strcmp("gamma", Name())) {
39 		float gamma;
40 		gamma = exp((Value() * log(2.0) * 0.01) );
41 		sprintf(string, " %.2f", gamma);
42 	} else if (!strcmp("inkDensity", Name()) ) {
43 		float density = Value();
44 		density = (density / 127.0) * 100.0;
45 		sprintf(string," %.0f%%", density);
46 	}
47 
48 	fResult.SetTo(string);
49 	return fResult.String();
50 }
51