aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-03 23:49:23 +0000
committerHans-Christoph Steiner <eighthave@users.sourceforge.net>2007-11-03 23:49:23 +0000
commit02fa90c79d916339235320b94535f798486e77a4 (patch)
treea87c2126b6bc6112b6d205e2bb84b55512e383d1
parent9a39d26529bddefddc276b45becfbce79bb35bf1 (diff)
initial sketch of the idea to provide access to Pd's gui in Pd, compiles, but doesn't work yet
svn path=/trunk/externals/hcs/; revision=8926
-rw-r--r--sys_gui-help.pd4
-rw-r--r--sys_gui.c62
2 files changed, 66 insertions, 0 deletions
diff --git a/sys_gui-help.pd b/sys_gui-help.pd
new file mode 100644
index 0000000..1eca1c7
--- /dev/null
+++ b/sys_gui-help.pd
@@ -0,0 +1,4 @@
+#N canvas 0 22 454 304 10;
+#X msg 84 83 blah blah blah;
+#X obj 89 152 sys_gui;
+#X connect 0 0 1 0;
diff --git a/sys_gui.c b/sys_gui.c
new file mode 100644
index 0000000..cb3fd9a
--- /dev/null
+++ b/sys_gui.c
@@ -0,0 +1,62 @@
+#include <stdio.h>
+#include <string.h>
+#include <m_pd.h>
+#include <g_canvas.h>
+
+static t_class *sys_gui_class;
+
+typedef struct _sys_gui
+{
+ t_object x_obj;
+} t_sys_gui;
+
+
+static void *sys_gui_anything(t_sys_gui *x, t_symbol *s, int argc, t_atom *argv)
+{
+ int i = 0;
+ int firsttime = 1;
+ t_symbol *tmp_symbol = s;
+ char tmp_string[MAXPDSTRING];
+ char send_buffer[MAXPDSTRING] = "\0";
+
+ do {
+ tmp_symbol = atom_getsymbolarg(i, argc, argv);
+ if(tmp_symbol == &s_)
+ {
+ snprintf(tmp_string, MAXPDSTRING, "%g", atom_getfloatarg(i, argc , argv));
+ strncat(send_buffer, tmp_string, MAXPDSTRING);
+ }
+ else
+ {
+ strncat(send_buffer, tmp_symbol->s_name, MAXPDSTRING);
+ }
+ i++;
+ if(firsttime) firsttime = 0;
+ } while(i<argc);
+ strncat(send_buffer, " ;\n", MAXPDSTRING);
+ post(send_buffer);
+ sys_gui(send_buffer);
+}
+
+
+static void *sys_gui_new(t_symbol *s, int argc, t_atom *argv)
+{
+ t_sys_gui *x = (t_sys_gui *)pd_new(sys_gui_class);
+
+ outlet_new(&x->x_obj, &s_anything);
+
+ return(x);
+}
+
+static void sys_gui_free(t_sys_gui *x)
+{
+}
+
+void sys_gui_setup(void)
+{
+ sys_gui_class = class_new(gensym("sys_gui"),
+ (t_newmethod)sys_gui_new, (t_method)sys_gui_free,
+ sizeof(t_sys_gui), 0, 0);
+
+ class_addanything(sys_gui_class, (t_method)sys_gui_anything);
+}