GTK+ IOStream  Beta
<< GTK+ >> add C++ IOStream operators to GTK+. Now with extra abilities ... like network serialisation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Scale.H
Go to the documentation of this file.
1 /* Copyright 2000-2013 Matt Flax <flatmax@flatmax.org>
2  This file is part of GTK+ IOStream class set
3 
4  GTK+ IOStream is free software; you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation; either version 2 of the License, or
7  (at your option) any later version.
8 
9  GTK+ IOStream is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You have received a copy of the GNU General Public License
15  along with GTK+ IOStream
16  */
17 #ifndef SCALE_H_
18 #define SCALE_H_
19 
20 #include <iomanip>
21 #include <gtk/gtk.h>
22 
24 public:
25  int min, max, step;
26  void (*func)(void *arg1, void *arg2);
27  gpointer data;
28 };
29 #define SCALESTRUCT (scaleFuncData)
30 
31 class Scale {
32 public:
33  GtkWidget *scale;
34 public:
35  GtkWidget* getWidget(void){return scale;}
36  void show(void){gtk_widget_show(scale);}
37  void hide(void){gtk_widget_hide(scale);}
38 
39  ~Scale(void){
40  // gtk_widget_destroy(scale);
41  //#ifdef DEBUG
42  // cout<<"Scale::~Scale"<<endl;
43  //#endif
44  }
45 
46  double getCount(GtkRange * widget){
47  return gtk_range_get_value(widget);
48  }
49  double getCount(void){
50  return gtk_range_get_value((GtkRange*)scale);
51  }
52 
53  Scale& operator =(double pos){
54  gtk_range_set_value((GtkRange*)scale,pos);
55  return *this;
56  }
57  Scale& operator =(int pos){
58  return this->operator=((double)pos);
59  }
60 };
61 
62 class VScale : public Scale {
63 public:
64  VScale(int min, int max, int step){
65  scale = gtk_vscale_new_with_range(min,max,step);
66  }
67 
69  scale = gtk_vscale_new_with_range(sf.min,sf.max,sf.step);
70  if (sf.func){ //set the callback
71  g_signal_connect(G_OBJECT((GtkScale*)scale), "value_changed",GTK_SIGNAL_FUNC(sf.func), sf.data);
72  }
73  }
74 };
75 
76 class HScale : public Scale {
77 public:
78  HScale(int min, int max, int step){
79  scale = gtk_hscale_new_with_range(min,max,step);
80  }
82  scale = gtk_hscale_new_with_range(sf.min,sf.max,sf.step);
83  gtk_scale_set_draw_value((GtkScale*)scale, FALSE);
84  if (sf.func){ //set the callback
85  g_signal_connect(G_OBJECT((GtkScale*)scale), "value_changed",GTK_SIGNAL_FUNC(sf.func), sf.data);
86  }
87  }
88 };
89 
90 #endif //SCALE_H_