Skip to content
Snippets Groups Projects
Commit 808b4719 authored by Per Hedbor's avatar Per Hedbor
Browse files

New optional widget: GTK.Databox

Rev: src/post_modules/GTK/Makefile.in:1.18
Rev: src/post_modules/GTK/build_pgtk.pike:1.26
Rev: src/post_modules/GTK/configure.in:1.13
Rev: src/post_modules/GTK/make_example_image.pike:1.5
Rev: src/post_modules/GTK/options.in:1.7
Rev: src/post_modules/GTK/source/gtkdatabox.pre:1.1
parent f7dfce0a
Branches
Tags
No related merge requests found
...@@ -4,7 +4,7 @@ VPATH=@srcdir@:@srcdir@/../..:../..:. ...@@ -4,7 +4,7 @@ VPATH=@srcdir@:@srcdir@/../..:../..:.
MODNAME=GTK MODNAME=GTK
DEST=@prefix@/lib/pike/modules/ DEST=@prefix@/lib/pike/modules/
OBJS=dummy.o OBJS=dummy.o
MODULE_LDFLAGS=@LDFLAGS@ @LIBS@ @GTKEXTRA_LIBS@ @PGTK_LIBS@ @GNOME_LIBS@ @LIBGLADE_LIBS@ MODULE_LDFLAGS=@LDFLAGS@ @LIBS@ @DATABOX_LIBS@ @GTKEXTRA_LIBS@ @PGTK_LIBS@ @GNOME_LIBS@ @LIBGLADE_LIBS@
MODULE_CFLAGS=@PGTK_CFLAGS@ @GTKEXTRA_CFLAGS@ @GNOME_CFLAGS@ @LIBGLADE_CFLAGS@ MODULE_CFLAGS=@PGTK_CFLAGS@ @GTKEXTRA_CFLAGS@ @GNOME_CFLAGS@ @LIBGLADE_CFLAGS@
CONFIG_HEADERS=config.h CONFIG_HEADERS=config.h
MODULE_CLEAN_EXTRA=pgtk*.c MODULE_CLEAN_EXTRA=pgtk*.c
......
...@@ -1185,6 +1185,8 @@ void do_default_sprintf( int args, int offset, int len ) ...@@ -1185,6 +1185,8 @@ void do_default_sprintf( int args, int offset, int len )
if( null ) if( null )
post += " arg"+na+"[_i] = NULL;\n"; post += " arg"+na+"[_i] = NULL;\n";
break; break;
case "!floatarray":
free_res=1; // Somewhat misleading reuse of variable...
case "floatarray": case "floatarray":
if(!i_added++) if(!i_added++)
args += " int _i;\n"; args += " int _i;\n";
...@@ -1193,9 +1195,10 @@ void do_default_sprintf( int args, int offset, int len ) ...@@ -1193,9 +1195,10 @@ void do_default_sprintf( int args, int offset, int len )
format_string += "%a"; format_string += "%a";
args += " struct array *_arg"+na+";\n"; args += " struct array *_arg"+na+";\n";
args += " gfloat *arg"+na+";\n"; args += " gfloat *arg"+na+";\n";
fin += " free(arg"+na+");\n"; if(!free_res)
fin += " g_free(arg"+na+");\n";
sargs += (",&_arg"+na); sargs += (",&_arg"+na);
post += (" arg"+na+"=malloc(sizeof(gfloat)* (_arg"+na+"->size));\n" post += (" arg"+na+"=g_malloc(sizeof(gfloat)* (_arg"+na+"->size));\n"
" for(_i=0; _i<_arg"+na+"->size; _i++)\n" " for(_i=0; _i<_arg"+na+"->size; _i++)\n"
" {\n" " {\n"
" if(_arg"+na+"->item[_i].type != T_FLOAT)\n" " if(_arg"+na+"->item[_i].type != T_FLOAT)\n"
...@@ -1206,6 +1209,8 @@ void do_default_sprintf( int args, int offset, int len ) ...@@ -1206,6 +1209,8 @@ void do_default_sprintf( int args, int offset, int len )
" arg"+na+"[_i] = _arg"+na+"->item[_i].u.float_number;\n" " arg"+na+"[_i] = _arg"+na+"->item[_i].u.float_number;\n"
" }\n"); " }\n");
break; break;
case "!doublearray":
free_res=1; // Somewhat misleading reuse of variable...
case "doublearray": case "doublearray":
if(!i_added++) if(!i_added++)
args += " int _i;\n"; args += " int _i;\n";
...@@ -1214,9 +1219,10 @@ void do_default_sprintf( int args, int offset, int len ) ...@@ -1214,9 +1219,10 @@ void do_default_sprintf( int args, int offset, int len )
format_string += "%a"; format_string += "%a";
args += " struct array *_arg"+na+";\n"; args += " struct array *_arg"+na+";\n";
args += " gdouble *arg"+na+";\n"; args += " gdouble *arg"+na+";\n";
fin += " free(arg"+na+");\n"; if(!free_res)
fin += " g_free(arg"+na+");\n";
sargs += (",&_arg"+na); sargs += (",&_arg"+na);
post += (" arg"+na+"=malloc(sizeof(gfloat)* (_arg"+na+"->size));\n" post += (" arg"+na+"=g_malloc(sizeof(gfloat)* (_arg"+na+"->size));\n"
" for(_i=0; _i<_arg"+na+"->size; _i++)\n" " for(_i=0; _i<_arg"+na+"->size; _i++)\n"
" {\n" " {\n"
" if(_arg"+na+"->item[_i].type != T_FLOAT)\n" " if(_arg"+na+"->item[_i].type != T_FLOAT)\n"
...@@ -1227,6 +1233,8 @@ void do_default_sprintf( int args, int offset, int len ) ...@@ -1227,6 +1233,8 @@ void do_default_sprintf( int args, int offset, int len )
" arg"+na+"[_i] = (gdouble)_arg"+na+"->item[_i].u.float_number;\n" " arg"+na+"[_i] = (gdouble)_arg"+na+"->item[_i].u.float_number;\n"
" }\n"); " }\n");
break; break;
case "!intarray":
free_res=1; // Somewhat misleading reuse of variable...
case "intarray": case "intarray":
if(!i_added++) args += " int _i;\n"; if(!i_added++) args += " int _i;\n";
fundef += ",array(int)"; fundef += ",array(int)";
...@@ -1234,9 +1242,10 @@ void do_default_sprintf( int args, int offset, int len ) ...@@ -1234,9 +1242,10 @@ void do_default_sprintf( int args, int offset, int len )
format_string += "%a"; format_string += "%a";
args += " struct array *_arg"+na+";\n"; args += " struct array *_arg"+na+";\n";
args += " gint *arg"+na+";\n"; args += " gint *arg"+na+";\n";
fin += " free(arg"+na+");\n"; if(!free_res)
fin += " g_free(arg"+na+");\n";
sargs += (",&_arg"+na); sargs += (",&_arg"+na);
post += (" arg"+na+"=malloc(sizeof(gint)* (1+_arg"+na+"->size));\n" post += (" arg"+na+"=g_malloc(sizeof(gint)* (1+_arg"+na+"->size));\n"
" for(_i=0; _i<_arg"+na+"->size; _i++)\n" " for(_i=0; _i<_arg"+na+"->size; _i++)\n"
" {\n" " {\n"
" if(_arg"+na+"->item[_i].type != T_INT)\n" " if(_arg"+na+"->item[_i].type != T_INT)\n"
......
...@@ -324,7 +324,6 @@ fi ...@@ -324,7 +324,6 @@ fi
AC_CHECK_HEADERS( X11/xpm.h ) AC_CHECK_HEADERS( X11/xpm.h )
AC_CHECK_LIB(Xpm, XpmReadFileToXpmImage) AC_CHECK_LIB(Xpm, XpmReadFileToXpmImage)
AC_PATH_PROG(GTKEXTRA_CONFIG,gtkextra-config,no) AC_PATH_PROG(GTKEXTRA_CONFIG,gtkextra-config,no)
AC_SUBST(pgtk_has_gtkextra) AC_SUBST(pgtk_has_gtkextra)
...@@ -347,6 +346,34 @@ fi ...@@ -347,6 +346,34 @@ fi
AC_CHECK_LIB(gtkdatabox, main,,,`gtk-config --libs`)
AC_CHECK_HEADERS(gtkdatabox.h)
AC_SUBST(pgtk_have_gtkdatabox)
AC_SUBST(DATABOX_LIBS)
DATABOX_LIBS=""
AC_MSG_CHECKING([gtkdatabox support]);
if test x$ac_cv_lib_gtkdatabox_main = xyes ; then
if test x$ac_cv_header_gtkdatabox_h = xyes; then
AC_MSG_RESULT(yes)
DATABOX_LIBS=-lgtkdatabox
pgtk_has_gtkdatabox=gtkdatabox
else
AC_MSG_RESULT(no)
pgtk_has_gtkdatabox=nogtkdatabox
echo "*******************************************"
echo " Warning: Partial gtkdatabox installation "
echo " Library found, but no header files. "
echo " Databox support will be disabled. "
echo " The widget is available from "
echo " http://www.eudoxos.net/gtk/gtkdatabox/ "
echo "*******************************************"
fi
else
pgtk_has_gtkdatabox=nogtkdatabox
fi
AC_MSG_CHECKING([OpenGL]) AC_MSG_CHECKING([OpenGL])
LIBS="$saved_LIBS $GL_LDOPTS -lGL" LIBS="$saved_LIBS $GL_LDOPTS -lGL"
......
...@@ -4,8 +4,12 @@ object get_widget_from( string what ) ...@@ -4,8 +4,12 @@ object get_widget_from( string what )
{ {
array err; array err;
mixed res; mixed res;
err = catch { err = catch
{
if( search(what, "return") == -1 )
res= compile_string( "object foo(){ return "+what+"; }")()->foo(); res= compile_string( "object foo(){ return "+what+"; }")()->foo();
else
res= compile_string( "object foo(){ "+what+" }")()->foo();
}; };
if(!res) if(!res)
werror("Error while compiling or running "+what+"\n: %s\n", err?err[0]:"No return value"); werror("Error while compiling or running "+what+"\n: %s\n", err?err[0]:"No return value");
...@@ -118,8 +122,7 @@ void grab(object w) ...@@ -118,8 +122,7 @@ void grab(object w)
void got_event( mixed a, mixed b, object e ) void got_event( mixed a, mixed b, object e )
{ {
if(e->type == "expose" ) call_out(grab, 0.3, w );
call_out(grab, 0.01, w );
} }
void show_recursively(object w) void show_recursively(object w)
...@@ -157,7 +160,7 @@ int main(int argc, array (string) argv) ...@@ -157,7 +160,7 @@ int main(int argc, array (string) argv)
ex = w = get_widget_from( argv[1] ); ex = w = get_widget_from( argv[1] );
w->set_border_width( 20 ); w->set_border_width( 20 );
} }
w->signal_connect( "event", got_event, w ); w->signal_connect( "map_event", got_event, w );
w->signal_connect( "destroy", _exit, 1 ); w->signal_connect( "destroy", _exit, 1 );
show_recursively( w ); show_recursively( w );
return -1; return -1;
......
...@@ -5,3 +5,4 @@ ...@@ -5,3 +5,4 @@
@pgtk_has_gnome@ @pgtk_has_gnome@
@pgtk_has_docklets@ @pgtk_has_docklets@
@pgtk_has_gtkextra@ @pgtk_has_gtkextra@
@pgtk_has_gtkdatabox@
require gtkdatabox;
class databox;
inherit vbox;
#include <gtkdatabox.h>
ADD_INCLUDE(#include <gtkdatabox.h>);
// GtkDatabox is designed to display large amounts of numerical data
// fast and easy. Thousands of data points (X and Y coordinate) may be
// displayed without any problems, zooming and scrolling as well as
// optional rulers are already included.
// <p>
// The widget may be used as display for oscilloscopes or other
// applications that need to display fast changes in their data.
// IMG: GTK.Databox x=GTK.Databox(); x->data_add_x_y(3, ({ 1.0, 0.5, 0.0 }), ({1.0, -1.0, 0.0}),GDK.Color(Image.Color.red), GTK.DataboxLines,2); x->rescale(); x->set_usize(300,300); return x;
constant int GTK_DATABOX_NOT_DISPLAYED;
constant int GTK_DATABOX_POINTS;
constant int GTK_DATABOX_LINES;
constant int GTK_DATABOX_BARS;
signal zoomed;
signal marked;
signal selection_started;
signal selection_changed;
signal selection_stopped;
signal selection_canceled;
void create();
// Create a new databox widget
void show_rulers();
void hide_rulers();
void show_cross();
void hide_cross();
void show_scrollbars();
void hide_scrollbars();
void enable_zoom();
void disable_zoom();
%{
static GtkDataboxCoord get_coord(int offset,int args)
{
GtkDataboxCoord c;
if( args < offset+2)
error("too few arguments\n");
if( sp[-args+offset].type != T_INT )
error("Bad argument %d\n", offset );
else
c.x = sp[-args+offset].u.integer;
if( sp[-args+offset+1].type != T_INT )
error("Bad argument %d\n", offset );
else
c.y = sp[-args+offset+1].u.integer;
return c;
}
static GtkDataboxValue get_value(int offset,int args)
{
GtkDataboxValue c;
if( args < offset+2)
error("too few arguments\n");
if( sp[-args+offset].type != T_FLOAT )
error("Bad argument %d\n", offset );
else
c.x = sp[-args+offset].u.float_number;
if( sp[-args+offset+1].type != T_FLOAT )
error("Bad argument %d\n", offset );
else
c.y = sp[-args+offset+1].u.float_number;
return c;
}
static void push_value( GtkDataboxValue v )
{
push_text( "x" ); push_float( v.x );
push_text( "y" ); push_float( v.y );
f_aggregate_mapping( 4 );
}
%}
FUNCTION(data_get_value, "function(int,int:mapping)");
NAME_ARGS(x,y);
{
GtkDataboxValue v;
gtk_databox_data_get_value(GTK_DATABOX(THIS->obj), get_coord(0,args), &v );
push_value( v );
}
FUNCTION(data_get_visible_extrema, "function(void:array(mapping))");
{
GtkDataboxValue v1,v2;
gtk_databox_data_get_visible_extrema(GTK_DATABOX(THIS->obj), &v1, &v2 );
push_value( v1 );
push_value( v2 );
f_aggregate(2);
}
FUNCTION(data_get_extrema, "function(void:array(mapping))");
{
GtkDataboxValue v1,v2;
gtk_databox_data_get_extrema(GTK_DATABOX(THIS->obj), &v1, &v2 );
push_value( v1 );
push_value( v2 );
f_aggregate(2);
}
void rescale();
FUNCTION(rescale_with_values, "function(float,float,float,float:object)");
NAME_ARGS(minx,miny,maxx,maxy);
{
gtk_databox_rescale_with_values(GTK_DATABOX(THIS->obj),
get_value( 0, args ),
get_value( 2, args ));
RETURN_THIS();
}
int set_color(int index, *GDK.Color color );
int set_data_type( int index, int type, int dot_size );
// Type is one of CONST(GTK_DATABOX_)
int data_add_x_y( int nelems, !floatarray x, !floatarray y, *GDK.Color color, int type, int dot_size );
// Type is one of CONST(GTK_DATABOX_)
int data_add_x( int nelems, !floatarray x, int shared_Y_index, *GDK.Color color, int type, int dot_size );
// Type is one of CONST(GTK_DATABOX_)
int data_add_y( int nelems, !floatarray y, int shared_X_index, *GDK.Color color, int type, int dot_size );
// Type is one of CONST(GTK_DATABOX_)
int data_destroy( int index );
int data_destroy_all( );
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment