24 #define _USE_MATH_DEFINES 31 double round(
double number) {
33 return number < 0.0 ? ceil(number - 0.5) : floor(number + 0.5);
36 extern double round(
double);
40 #ifndef SCALE_MAX_DISPLAY_MAX_PRECISION 41 #define SCALE_MAX_DISPLAY_MAX_PRECISION 37 55 ScaleFuncData(
double mi,
double ma,
double st,
void (*fn)(
void *,
void *), gpointer da) {
69 ScaleFuncData(
double mi,
double ma,
double st, GCallback fn, gpointer da) {
73 func=(void (*)(
void*,
void*))fn;
80 void (*
func)(
void *arg1,
void *arg2);
83 #define SCALESTRUCT(mi,ma,st,fn,da) ScaleFuncData(mi,ma,st,fn,da) 165 step=fabs(step)-floor(fabs(step))/10.;
168 while ((step*=10.)<1.)
171 gtk_scale_set_digits(GTK_SCALE(current()),digits);
179 GtkAdjustment *adj=gtk_range_get_adjustment(GTK_RANGE(wid));
180 #if GTK_MAJOR_VERSION!=2 181 double step_size=gtk_adjustment_get_step_increment(adj);
183 double step_size=adj->step_increment;
185 int rounded=(int)
round(gtk_range_get_value(GTK_RANGE(wid))/step_size);
186 gtk_range_set_value(GTK_RANGE(wid),step_size*(
double)rounded);
199 return gtk_range_get_value(wid);
207 return gtk_range_get_value((GtkRange*)current());
208 return std::numeric_limits<double>::quiet_NaN();
216 GtkAdjustment* gtkAdj=gtk_range_get_adjustment(GTK_RANGE(current()));
217 #if GTK_MAJOR_VERSION!=2 218 return gtk_adjustment_get_step_increment(gtkAdj);
220 return gtkAdj->step_increment;
223 return std::numeric_limits<double>::quiet_NaN();
231 GtkAdjustment* gtkAdj=gtk_range_get_adjustment(GTK_RANGE(current()));
232 #if GTK_MAJOR_VERSION!=2 233 return gtk_adjustment_set_step_increment(gtkAdj, step);
235 gtkAdj->step_increment=
step;
237 gtk_range_set_adjustment(GTK_RANGE(current()), gtkAdj);
246 GtkAdjustment* gtkAdj=gtk_range_get_adjustment(GTK_RANGE(current()));
247 #if GTK_MAJOR_VERSION!=2 248 gtk_adjustment_set_lower(gtkAdj, lower);
252 gtk_range_set_adjustment(GTK_RANGE(current()), gtkAdj);
262 GtkAdjustment* gtkAdj=gtk_range_get_adjustment(GTK_RANGE(current()));
263 #if GTK_MAJOR_VERSION!=2 264 gtk_adjustment_set_upper(gtkAdj, upper);
268 gtk_range_set_adjustment(GTK_RANGE(current()), gtkAdj);
277 GtkAdjustment* gtkAdj=gtk_range_get_adjustment(GTK_RANGE(current()));
278 #if GTK_MAJOR_VERSION!=2 279 return gtk_adjustment_get_lower(gtkAdj);
281 return gtkAdj->lower;
291 GtkAdjustment* gtkAdj=gtk_range_get_adjustment(GTK_RANGE(current()));
292 #if GTK_MAJOR_VERSION!=2 293 return gtk_adjustment_get_upper(gtkAdj);
295 return gtkAdj->upper;
306 gtk_range_set_value((GtkRange*)current(),pos);
315 return this->operator=((
double)pos);
323 gtk_scale_set_draw_value((GtkScale*)current(), FALSE);
333 gtk_widget_show(current());
335 g_signal_connect(G_OBJECT((GtkScale*)current()),
"value_changed",reinterpret_cast<GCallback>(sf.
func), sf.
data);
346 gtk_widget_show(current());
348 g_signal_connect(G_OBJECT((GtkScale*)current()),
"value_changed",reinterpret_cast<GCallback>(sf.
func), sf.
data);
359 GtkWidget *c=current();
362 for (
int i=1; i<=getCount(); i++) {
363 if (next()==widget) {
378 g_signal_connect_after(G_OBJECT(current()),
"value_changed",reinterpret_cast<GCallback>(sfd.
func), sfd.
data);
386 g_signal_handlers_disconnect_by_func(G_OBJECT(current()), (
void*)(sfd.
func), sfd.
data);
397 g_signal_connect(G_OBJECT(current()),
"value_changed",reinterpret_cast<GCallback>(quantiseVal), NULL);
399 g_signal_handlers_disconnect_matched(G_OBJECT((GtkButton*)current()), G_SIGNAL_MATCH_FUNC, 0, 0, NULL, reinterpret_cast<gpointer>(quantiseVal), NULL);
407 gtk_range_set_inverted(GTK_RANGE(current()),isInverted);
void setStep(double step)
virtual ~Scales(void)
destructor
VScaleFuncData(double mi, double ma, double st)
static void quantiseVal(void *wid, void *data)
double max
The maximum value.
void setUpper(double upper)
VScaleFuncData(double mi, double ma, double st, GCallback fn, gpointer da)
void signalConnectAfter(ScaleFuncData sfd)
connect a callback to execute after the currently connected callbacks
VScaleFuncData(double mi, double ma, double st, void(*fn)(void *, void *), gpointer da)
int findIndex(GtkWidget *widget)
double step
The stepping value.
void setDigits(double step)
void add(TYPE newElement)
Adds as the current element ... Added to the next of the current lug.
HScaleFuncData(double mi, double ma, double st)
HScaleFuncData(double mi, double ma, double st, GCallback fn, gpointer da)
gpointer data
The user data to pass to the callback function.
HScaleFuncData(double mi, double ma, double st, void(*fn)(void *, void *), gpointer da)
double precision function round(x)
ScaleFuncData(double mi, double ma, double st, void(*fn)(void *, void *), gpointer da)
void invert(bool isInverted)
#define SCALE_MAX_DISPLAY_MAX_PRECISION
the maximum precision we want to show
void(* func)(void *arg1, void *arg2)
The callback function.
void setLower(double lower)
double min
The minimum value.
Scales & operator<<(HScaleFuncData sf)
void quantise(bool isQuantised)
ScaleFuncData(double mi, double ma, double st, GCallback fn, gpointer da)
void signalRemove(ScaleFuncData sfd)
disconnect the callback
static double getVal(GtkRange *wid)
Scales & operator<<(VScaleFuncData sf)