[PD-cvs] externals/tkwidgets checkbutton-help.pd, 1.2, 1.3 checkbutton.c, 1.7, 1.8 text.c, 1.15, 1.16
Hans-Christoph Steiner
eighthave at users.sourceforge.net
Sat Nov 24 08:00:47 CET 2007
Update of /cvsroot/pure-data/externals/tkwidgets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6588
Modified Files:
checkbutton-help.pd checkbutton.c text.c
Log Message:
- got the basics of checkbutton working, but I don't think it's saving yet.
- fixed minor namespace bug in text.c
Index: checkbutton.c
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/checkbutton.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -C2 -d -r1.7 -r1.8
*** checkbutton.c 24 Nov 2007 04:51:33 -0000 1.7
--- checkbutton.c 24 Nov 2007 07:00:45 -0000 1.8
***************
*** 21,24 ****
--- 21,27 ----
*/
+ /* TODO rectify char and pixel widths/heights ug */
+ /* TODO bind to <Configure> so that things are redrawn when the text changes */
+
#include "shared/tkwidgets.h"
***************
*** 67,71 ****
"bitmap",
"borderwidth",
! "command",
"compound",
"cursor",
--- 70,74 ----
"bitmap",
"borderwidth",
! // "command", /* problematic since it uses names based on pointers */
"compound",
"cursor",
***************
*** 94,98 ****
"textvariable",
"underline",
! "variable",
"width",
"wraplength"
--- 97,101 ----
"textvariable",
"underline",
! // "variable", /* problematic since it uses names based on pointers */
"width",
"wraplength"
***************
*** 118,123 ****
set_tkwidgets_ids(x,glist_getcanvas(glist));
sys_vgui("destroy %s\n", x->widget_id->s_name); /* just in case it exists */
! sys_vgui("checkbutton %s\n",
! x->widget_id->s_name);
tkwidgets_draw_iolets((t_object*)x, glist,
x->canvas_id, x->iolets_tag, x->all_tag,
--- 121,130 ----
set_tkwidgets_ids(x,glist_getcanvas(glist));
sys_vgui("destroy %s\n", x->widget_id->s_name); /* just in case it exists */
! sys_vgui("namespace eval %s {} \n", x->tcl_namespace->s_name);
! sys_vgui("set ::%s::state 0\n", x->tcl_namespace->s_name);
! sys_vgui("checkbutton %s -variable ::%s::state \
! -command {pd [concat %s output $::%s::state \\;]}\n",
! x->widget_id->s_name, x->tcl_namespace->s_name,
! x->receive_name->s_name, x->tcl_namespace->s_name);
tkwidgets_draw_iolets((t_object*)x, glist,
x->canvas_id, x->iolets_tag, x->all_tag,
***************
*** 193,196 ****
--- 200,225 ----
}
+ static void checkbutton_select(t_gobj *z, t_glist *glist, int state)
+ {
+ t_checkbutton *x = (t_checkbutton *)z;
+ DEBUG(post("checkbutton_select: canvas %lx glist %lx state %d", x->x_canvas, glist, state););
+
+ if( (state) && (!x->x_selected))
+ {
+ sys_vgui("set ::%s::bg [%s cget -bg]\n",
+ x->tcl_namespace->s_name, x->widget_id->s_name);
+ sys_vgui("%s configure -bg %s\n",
+ x->widget_id->s_name, TKW_SELECTION_COLOR);
+ x->x_selected = 1;
+ }
+ else if (!state)
+ {
+ sys_vgui("%s configure -bg $::%s::bg\n",
+ x->widget_id->s_name, x->tcl_namespace->s_name);
+ /* activatefn never gets called with 0, so destroy handle here */
+ sys_vgui("destroy %s\n", x->handle_id->s_name);
+ x->x_selected = 0;
+ }
+ }
static void checkbutton_delete(t_gobj *z, t_glist *glist)
{
***************
*** 219,222 ****
--- 248,285 ----
}
+ /* -------------------- methods for atoms ----------------------------------- */
+
+ /* this function uses the selector as the Tk option and applies the whole
+ * message directly to the Tk widget itself using Tk's "configure". This
+ * function is called when "anything" is received. */
+ static void checkbutton_set_option(t_checkbutton *x, t_symbol *s, int argc, t_atom *argv)
+ {
+ if(s != &s_list)
+ {
+ t_binbuf *argument_binbuf = binbuf_new();
+ char *argument_buffer;
+ int buffer_length;
+
+ binbuf_add(argument_binbuf, argc, argv);
+ binbuf_gettext(argument_binbuf, &argument_buffer, &buffer_length);
+ binbuf_free(argument_binbuf);
+ argument_buffer[buffer_length] = 0;
+ post("%s configure -%s {%s} \n",
+ x->widget_id->s_name, s->s_name, argument_buffer);
+ sys_vgui("%s configure -%s {%s} \n",
+ x->widget_id->s_name, s->s_name, argument_buffer);
+ tkwidgets_store_options(x->receive_name, x->tcl_namespace, x->widget_id,
+ sizeof(checkbutton_tk_options)/sizeof(char *),
+ (char **)&checkbutton_tk_options);
+ }
+ }
+
+ /* Pass the contents of the text widget onto the textwidget_output_callback
+ * fuction above */
+ static void checkbutton_bang_output(t_checkbutton* x)
+ {
+ sys_vgui("%s invoke", x->widget_id->s_name);
+ }
+
/* --------------------------- methods for pd space ------------------------- */
***************
*** 236,250 ****
/* --------------------------- callback functions --------------------------- */
! static void checkbutton_query_callback(t_checkbutton *x, t_symbol *s, int argc, t_atom *argv)
{
t_symbol *tmp_symbol = atom_getsymbolarg(0, argc, argv);
if(tmp_symbol != &s_)
- {
- post("tmp_symbol %s argc %d", tmp_symbol->s_name, argc);
outlet_anything(x->x_status_outlet, tmp_symbol, argc - 1, argv + 1);
}
else
{
! post("checkbutton_query_callback %s %d", s->s_name, argc);
}
}
--- 299,365 ----
/* --------------------------- callback functions --------------------------- */
! static void checkbutton_output_callback(t_checkbutton* x, t_float f)
! {
! outlet_float(x->x_data_outlet, f);
! }
!
! static void checkbutton_query_callback(t_checkbutton *x, t_symbol *s,
! int argc, t_atom *argv)
{
t_symbol *tmp_symbol = atom_getsymbolarg(0, argc, argv);
if(tmp_symbol != &s_)
outlet_anything(x->x_status_outlet, tmp_symbol, argc - 1, argv + 1);
+ else
+ post("checkbutton_query_callback %s %d", s->s_name, argc);
+ }
+
+ static void checkbutton_store_callback(t_checkbutton *x, t_symbol *s,
+ int argc, t_atom *argv)
+ {
+ if(s != &s_)
+ {
+ binbuf_clear(x->options_binbuf);
+ binbuf_restore(x->options_binbuf, argc, argv);
}
else
+ post("ERROR: does this ever happen?");
+ }
+
+ static void checkbutton_resize_click_callback(t_checkbutton *x, t_floatarg f)
+ {
+ t_canvas *canvas = (glist_isvisible(x->x_glist) ? x->x_canvas : 0);
+ int button_state = (int)f;
+ if(x->x_resizing && !button_state && canvas)
{
! tkwidgets_draw_iolets((t_object*)x, canvas,
! x->canvas_id, x->iolets_tag, x->all_tag,
! x->width, x->height);
! canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet
! }
! else if(!x->x_resizing && button_state)
! {
! tkwidgets_erase_iolets(x->canvas_id, x->iolets_tag);
! }
! x->x_resizing = button_state;
! }
!
! static void checkbutton_resize_motion_callback(t_checkbutton *x,
! t_floatarg f1, t_floatarg f2)
! {
! DEBUG(post("checkbutton_resize_motion_callback"););
! if (x->x_resizing)
! {
! int dx = (int)f1, dy = (int)f2;
! if (glist_isvisible(x->x_glist))
! {
! x->width += dx;
! x->height += dy;
! sys_vgui("%s itemconfigure %s -width %d -height %d\n",
! x->canvas_id->s_name, x->window_tag->s_name,
! x->width, x->height);
! sys_vgui("%s move RESIZE %d %d\n",
! x->canvas_id->s_name, dx, dy);
! canvas_fixlinesfor(x->x_glist, (t_text *)x);
! }
}
}
***************
*** 263,268 ****
x->options_binbuf = binbuf_new();
! x->width = 15;
! x->height = 15;
if(argc > 0) x->width = atom_getint(argv);
--- 378,383 ----
x->options_binbuf = binbuf_new();
! x->width = 30;
! x->height = 30;
if(argc > 0) x->width = atom_getint(argv);
***************
*** 290,293 ****
--- 405,410 ----
(t_method)checkbutton_free,
sizeof(t_checkbutton), 0, A_GIMME,0);
+ /* methods for atoms */
+ class_addanything(checkbutton_class, (t_method)checkbutton_set_option);
/* methods for pd space */
***************
*** 298,303 ****
--- 415,428 ----
/* callbacks */
+ class_addmethod(checkbutton_class, (t_method)checkbutton_output_callback,
+ gensym("output"), A_DEFFLOAT, 0);
class_addmethod(checkbutton_class, (t_method)checkbutton_query_callback,
gensym("query_callback"), A_GIMME, 0);
+ class_addmethod(checkbutton_class, (t_method)checkbutton_store_callback,
+ gensym("store_callback"), A_GIMME, 0);
+ class_addmethod(checkbutton_class, (t_method)checkbutton_resize_click_callback,
+ gensym("resize_click"), A_FLOAT, 0);
+ class_addmethod(checkbutton_class, (t_method)checkbutton_resize_motion_callback,
+ gensym("resize_motion"), A_FLOAT, A_FLOAT, 0);
/* widget behavior */
Index: checkbutton-help.pd
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/checkbutton-help.pd,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** checkbutton-help.pd 22 Nov 2007 00:37:59 -0000 1.2
--- checkbutton-help.pd 24 Nov 2007 07:00:45 -0000 1.3
***************
*** 1,11 ****
! #N canvas 148 397 467 404 10;
! #X obj 178 105 checkbutton;
! #X msg 98 58 query;
! #X obj 147 167 print QUERY;
! #X msg 147 49 query size;
! #X msg 241 60 size 100 100;
! #X msg 239 30 size 20 20;
#X connect 1 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
! #X connect 5 0 0 0;
--- 1,29 ----
! #N canvas 13 257 467 404 10;
! #X obj 166 173 checkbutton 90 20;
! #X msg 20 111 query;
! #X obj 263 255 print QUERY;
! #X msg 24 80 query size;
! #X msg 172 78 size 100 100;
! #X obj 144 168 cnv 15 160 80 empty empty empty 20 12 0 14 -233017 -66577
! 0;
! #X obj 69 259 print DATA;
! #X msg 204 144 cursor gumby;
! #X obj 155 262 tgl 15 0 empty empty empty 17 7 0 10 -262144 -1 -1 0
! 5;
! #X msg 192 121 text gumby;
! #X msg 159 53 size 90 20;
! #X msg 184 102 text "blah blah";
! #X obj 51 337 pddp/pddplink http://tcl.tk/man/tcl8.4/TkCmd/checkbutton.htm
! ;
! #X msg 141 21 onvalue 5;
! #X connect 0 0 6 0;
! #X connect 0 0 8 0;
! #X connect 0 1 2 0;
#X connect 1 0 0 0;
#X connect 3 0 0 0;
#X connect 4 0 0 0;
! #X connect 7 0 0 0;
! #X connect 9 0 0 0;
! #X connect 10 0 0 0;
! #X connect 11 0 0 0;
! #X connect 13 0 0 0;
Index: text.c
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/text.c,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -d -r1.15 -r1.16
*** text.c 24 Nov 2007 05:57:15 -0000 1.15
--- text.c 24 Nov 2007 07:00:45 -0000 1.16
***************
*** 162,166 ****
DEBUG(post("create_widget"););
! sys_vgui("namespace eval text%lx {} \n", x);
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
--- 162,166 ----
DEBUG(post("create_widget"););
! sys_vgui("namespace eval %s {} \n", x->tcl_namespace->s_name);
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
More information about the Pd-cvs
mailing list