Update of /cvsroot/pure-data/externals/tkwidgets In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13704
Modified Files: checkbutton-help.pd checkbutton.c text.c Log Message:
- moved iolet drawing/erasing to tkwidgets common
- added iolets roughly to [checkbutton]
- cleaned up naming in text.c a bit
- moved t_widgetbehavior setup to textwidget_setup()
Index: checkbutton.c =================================================================== RCS file: /cvsroot/pure-data/externals/tkwidgets/checkbutton.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** checkbutton.c 21 Nov 2007 22:19:12 -0000 1.1 --- checkbutton.c 22 Nov 2007 00:37:59 -0000 1.2 *************** *** 1,5 **** /* [checkbutton] object for dislaying a check box
- Copyright (C) 2002-2004 Guenter Geiger Copyright (C) 2007 Hans-Christoph Steiner hans@at.or.at
--- 1,4 ---- *************** *** 24,27 **** --- 23,31 ---- #include "shared/tkwidgets.h"
+ #define DEBUG(x) x + + #define TOTAL_INLETS 1 + #define TOTAL_OUTLETS 2 + /* ------------------------ class variables --------------------------------- */
*************** *** 31,38 **** typedef struct _checkbutton { ! t_object x_obj; ! t_glist* x_glist; ! int x_width; ! int x_height;
/* IDs for Tk widgets */ --- 35,45 ---- typedef struct _checkbutton { ! t_object x_obj; ! t_canvas* x_canvas; /* canvas this widget is currently drawn in */ ! t_glist* x_glist; /* glist that owns this widget */ ! t_binbuf* options_binbuf;/* binbuf to save options state in */ ! ! int width; ! int height;
/* IDs for Tk widgets */ *************** *** 42,45 **** --- 49,54 ---- t_symbol* widget_id; t_symbol* handle_id; + t_symbol* window_tag; + t_symbol* iolets_tag; t_symbol* all_tag;
*************** *** 87,103 **** };
/* -------------------- widget helper functions------------------------------ */
static void checkbutton_drawme(t_checkbutton *x, t_glist *glist) { ! sys_vgui("checkbutton %s\n", x->widget_id); }
! static void checkbutton_erase(t_checkbutton* x,t_glist* glist) { ! sys_vgui("%s delete %s\n", x->canvas_id, x->widget_id); }
--- 96,165 ---- };
+ /* -------------------- function prototypes --------------------------------- */ + + static void checkbutton_query_callback(t_checkbutton *x, t_symbol *s, int argc, t_atom *argv); + /* -------------------- widget helper functions------------------------------ */
+ static void set_tkwidgets_ids(t_checkbutton* x, t_canvas* canvas) + { + x->x_canvas = canvas; + x->canvas_id = tkwidgets_gen_canvas_id(x->x_canvas); + x->widget_id = tkwidgets_gen_widget_id((t_object*)x, x->canvas_id); + x->window_tag = tkwidgets_gen_window_tag((t_object*)x, x->canvas_id); + x->handle_id = tkwidgets_gen_handle_id((t_object *)x, x->canvas_id); + } + static void checkbutton_drawme(t_checkbutton *x, t_glist *glist) { ! ! 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_inlets((t_object*)x, glist, ! x->canvas_id, x->iolets_tag, x->all_tag, ! x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS); ! sys_vgui("%s create window %d %d -anchor nw -window %s -tags {%s %s}\n", ! x->canvas_id->s_name, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), ! x->widget_id->s_name, ! x->window_tag->s_name, x->all_tag->s_name); }
! static void checkbutton_erase(t_checkbutton* x, t_glist* glist) { ! set_tkwidgets_ids(x, glist_getcanvas(glist)); ! sys_vgui("destroy %s\n", x->widget_id->s_name); ! sys_vgui("%s delete %s\n", x->canvas_id->s_name, x->all_tag->s_name); }
+ /* --------------------- query functions ------------------------------------ */ + + static void query_size(t_checkbutton *x) + { + t_atom coords[3]; + SETSYMBOL(coords, gensym("size")); + SETFLOAT(coords + 1, (t_float)x->width); + SETFLOAT(coords + 2, (t_float)x->height); + checkbutton_query_callback(x, gensym("query_callback"), 3, coords); + } + + static void checkbutton_query(t_checkbutton *x, t_symbol *s) + { + post("checkbutton_query %s", s->s_name); + if(s == &s_) + { + tkwidgets_query_options(x->receive_name, x->widget_id, + sizeof(checkbutton_tk_options)/sizeof(char *), + checkbutton_tk_options); + query_size(x); + } + else if(s == gensym("size")) + query_size(x); + else + tkwidgets_query_options(x->receive_name, x->widget_id, 1, &(s->s_name)); + }
*************** *** 110,115 **** *xp1 = text_xpix(&x->x_obj, glist); *yp1 = text_ypix(&x->x_obj, glist); ! *xp2 = text_xpix(&x->x_obj, glist) + x->x_width; ! *yp2 = text_ypix(&x->x_obj, glist) + x->x_height; }
--- 172,177 ---- *xp1 = text_xpix(&x->x_obj, glist); *yp1 = text_ypix(&x->x_obj, glist); ! *xp2 = text_xpix(&x->x_obj, glist) + x->width; ! *yp2 = text_ypix(&x->x_obj, glist) + x->height; }
*************** *** 129,132 **** --- 191,227 ---- }
+ /* --------------------------- methods -------------------------------------- */ + + static void checkbutton_size(t_checkbutton *x, t_float width, t_float height) + { + DEBUG(post("checkbutton_size");); + x->height = height; + x->width = width; + if(glist_isvisible(x->x_glist)) + { + sys_vgui("%s itemconfigure %s -width %d -height %d\n", + x->canvas_id->s_name, x->window_tag->s_name, x->width, x->height); + // erase_inlets(x); + // tkwidgets_draw_inlets(x, x->x_glist, TOTAL_INLETS, TOTAL_OUTLETS); + canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet + } + } + + /* --------------------------- 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); + } + } + /* --------------------------- standard class functions --------------------- */
*************** *** 142,149 **** x->x_glist = (t_glist*) canvas_getcurrent();
! x->x_width = 15; ! x->x_height = 15;
- outlet_new(&x->x_obj, &s_float); return (x); } --- 237,255 ---- x->x_glist = (t_glist*) canvas_getcurrent();
! x->width = 15; ! x->height = 15; ! ! x->tcl_namespace = tkwidgets_gen_tcl_namespace((t_object*)x, s); ! x->receive_name = tkwidgets_gen_callback_name(x->tcl_namespace); ! pd_bind(&x->x_obj.ob_pd, x->receive_name); ! ! x->x_glist = canvas_getcurrent(); ! set_tkwidgets_ids(x, x->x_glist); ! x->iolets_tag = tkwidgets_gen_iolets_tag((t_object*)x); ! x->all_tag = tkwidgets_gen_all_tag((t_object*)x); ! ! x->x_data_outlet = outlet_new(&x->x_obj, &s_float); ! x->x_status_outlet = outlet_new(&x->x_obj, &s_anything);
return (x); } *************** *** 155,158 **** --- 261,273 ---- sizeof(t_checkbutton), 0, A_GIMME,0);
+ class_addmethod(checkbutton_class, (t_method)checkbutton_query, + gensym("query"), A_DEFSYMBOL, 0); + class_addmethod(checkbutton_class, (t_method)checkbutton_size, + gensym("size"), A_DEFFLOAT, A_DEFFLOAT, 0); + + /* callbacks */ + class_addmethod(checkbutton_class, (t_method)checkbutton_query_callback, + gensym("query_callback"), A_GIMME, 0); + checkbutton_widgetbehavior.w_getrectfn = checkbutton_getrect; checkbutton_widgetbehavior.w_displacefn = NULL;
Index: checkbutton-help.pd =================================================================== RCS file: /cvsroot/pure-data/externals/tkwidgets/checkbutton-help.pd,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** checkbutton-help.pd 21 Nov 2007 22:19:12 -0000 1.1 --- checkbutton-help.pd 22 Nov 2007 00:37:59 -0000 1.2 *************** *** 1,2 **** ! #N canvas 351 228 450 300 10; #X obj 178 105 checkbutton; --- 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;
Index: text.c =================================================================== RCS file: /cvsroot/pure-data/externals/tkwidgets/text.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** text.c 21 Nov 2007 22:19:12 -0000 1.6 --- text.c 22 Nov 2007 00:37:59 -0000 1.7 *************** *** 28,31 **** --- 28,33 ---- /* TODO: add size to query and save */ /* TODO: add scrollbars to query and save */ + /* TODO: remove glist from _erase() args */ + /* TODO: window name "handle1376fc00" already exists in parent */
*************** *** 42,55 **** #define DEBUG(x) x
typedef struct _textwidget { t_object x_obj; ! t_canvas* x_canvas; /* canvas/glist this widget is currently drawn in*/ t_glist* x_glist; /* glist that owns this widget */ t_binbuf* options_binbuf;/* binbuf to save options state in */
! int size_x; ! int size_y; ! int x_have_scrollbars;
int x_resizing; --- 44,60 ---- #define DEBUG(x) x
+ static t_class *textwidget_class; + static t_widgetbehavior textwidget_widgetbehavior; + typedef struct _textwidget { t_object x_obj; ! t_canvas* x_canvas; /* canvas this widget is currently drawn in */ t_glist* x_glist; /* glist that owns this widget */ t_binbuf* options_binbuf;/* binbuf to save options state in */
! int width; ! int height; ! int have_scrollbars;
int x_resizing; *************** *** 64,68 **** t_symbol* scrollbar_id; t_symbol* handle_id; ! t_symbol* window_id; t_symbol* all_tag;
--- 69,74 ---- t_symbol* scrollbar_id; t_symbol* handle_id; ! t_symbol* window_tag; ! t_symbol* iolets_tag; t_symbol* all_tag;
*************** *** 71,76 **** } t_textwidget;
- static t_class *textwidget_class; - static char *textwidget_tk_options[] = { "autoseparators", --- 77,80 ---- *************** *** 125,153 **** static t_symbol *down_symbol;
! /* function prototypes */ ! ! static void textwidget_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2); ! static void textwidget_displace(t_gobj *z, t_glist *glist, int dx, int dy); ! static void textwidget_select(t_gobj *z, t_glist *glist, int state); ! static void textwidget_activate(t_gobj *z, t_glist *glist, int state); ! static void textwidget_delete(t_gobj *z, t_glist *glist); ! static void textwidget_vis(t_gobj *z, t_glist *glist, int vis); ! //static int textwidget_click(t_gobj *z, t_glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit); ! static void textwidget_save(t_gobj *z, t_binbuf *b);
static void textwidget_query_callback(t_textwidget *x, t_symbol *s, int argc, t_atom *argv);
! static t_widgetbehavior textwidget_widgetbehavior = { ! w_getrectfn: textwidget_getrect, ! w_displacefn: textwidget_displace, ! w_selectfn: textwidget_select, ! w_activatefn: textwidget_activate, ! w_deletefn: textwidget_delete, ! w_visfn: textwidget_vis, ! w_clickfn: NULL, ! }; ! ! /* widget helper functions */
static void store_options(t_textwidget *x) --- 129,138 ---- static t_symbol *down_symbol;
! /* -------------------- function prototypes --------------------------------- */
static void textwidget_query_callback(t_textwidget *x, t_symbol *s, int argc, t_atom *argv);
! /* -------------------- widget helper functions ----------------------------- */
static void store_options(t_textwidget *x) *************** *** 183,236 **** x->widget_id = tkwidgets_gen_widget_id((t_object*)x, x->frame_id); x->scrollbar_id = tkwidgets_gen_scrollbar_id((t_object*)x, x->frame_id); ! x->window_id = tkwidgets_gen_window_id((t_object*)x, x->frame_id); x->handle_id = tkwidgets_gen_handle_id((t_object *)x, x->canvas_id); }
- static int calculate_onset(t_textwidget *x, t_glist *glist, - int current_iolet, int total_iolets) - { - post("calculate_onset"); - return(text_xpix(&x->x_obj, glist) + (x->size_x - IOWIDTH) \ - * current_iolet / (total_iolets == 1 ? 1 : total_iolets - 1)); - } - - static void textwidget_draw_inlets(t_textwidget *x, t_glist *glist, int firsttime, - int total_inlets, int total_outlets) - { - DEBUG(post("textwidget_draw_inlets in: %d out: %d", total_inlets, total_outlets);); - int i, onset; - - for (i = 0; i < total_inlets; i++) /* inlets */ - { - onset = calculate_onset(x, glist, i, total_inlets); - sys_vgui("%s create rectangle %d %d %d %d -tags {%xi%d %xi %s}\n", - x->canvas_id->s_name, onset, text_ypix(&x->x_obj, glist) - 2, - onset + IOWIDTH, text_ypix(&x->x_obj, glist), - x, i, x, x->all_tag->s_name); - } - for (i = 0; i < total_outlets; i++) /* outlets */ - { - onset = calculate_onset(x, glist, i, total_outlets); - sys_vgui("%s create rectangle %d %d %d %d -tags {%xo%d %xo %s}\n", - x->canvas_id->s_name, onset, text_ypix(&x->x_obj, glist) + x->size_y, - onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->size_y + 2, - x, i, x, x->all_tag->s_name); - } - } - - static void erase_inlets(t_textwidget *x) - { - DEBUG(post("erase_inlets");); - /* Added tag for all inlets/outlets of one instance */ - sys_vgui("%s delete %xi\n", x->canvas_id->s_name, x); - sys_vgui("%s delete %xo\n", x->canvas_id->s_name, x); - - } - static void draw_scrollbar(t_textwidget *x) { sys_vgui("pack %s -side right -fill y -before %s \n", x->scrollbar_id->s_name, x->widget_id->s_name); ! x->x_have_scrollbars = 1; }
--- 168,180 ---- x->widget_id = tkwidgets_gen_widget_id((t_object*)x, x->frame_id); x->scrollbar_id = tkwidgets_gen_scrollbar_id((t_object*)x, x->frame_id); ! x->window_tag = tkwidgets_gen_window_tag((t_object*)x, x->frame_id); x->handle_id = tkwidgets_gen_handle_id((t_object *)x, x->canvas_id); }
static void draw_scrollbar(t_textwidget *x) { sys_vgui("pack %s -side right -fill y -before %s \n", x->scrollbar_id->s_name, x->widget_id->s_name); ! x->have_scrollbars = 1; }
*************** *** 238,242 **** { sys_vgui("pack forget %s \n", x->scrollbar_id->s_name); ! x->x_have_scrollbars = 0; }
--- 182,186 ---- { sys_vgui("pack forget %s \n", x->scrollbar_id->s_name); ! x->have_scrollbars = 0; }
*************** *** 313,338 **** }
! static void textwidget_drawme(t_textwidget *x, t_glist *glist, int firsttime) { ! DEBUG(post("textwidget_drawme: firsttime %d canvas %lx glist %lx", firsttime, x->x_canvas, glist);); set_tkwidgets_ids(x,glist_getcanvas(glist)); ! if (firsttime) ! { ! create_widget(x); ! textwidget_draw_inlets(x, glist, firsttime, TOTAL_INLETS, TOTAL_OUTLETS); ! if(x->x_have_scrollbars) draw_scrollbar(x); ! sys_vgui("%s create window %d %d -anchor nw -window %s \ -tags {%s %s} -width %d -height %d \n", x->canvas_id->s_name, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), ! x->frame_id->s_name, x->window_id->s_name, x->all_tag->s_name, x->size_x, x->size_y); ! } ! else ! { ! post("NO MORE COORDS"); ! // sys_vgui("%s coords %s %d %d\n", x->canvas_id->s_name, x->all_tag->s_name, ! // text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)); ! } ! } !
static void textwidget_erase(t_textwidget* x,t_glist* glist) --- 257,275 ---- }
! static void textwidget_drawme(t_textwidget *x, t_glist *glist) { ! DEBUG(post("textwidget_drawme: firsttime %d canvas %lx glist %lx", x->x_canvas, glist);); set_tkwidgets_ids(x,glist_getcanvas(glist)); ! create_widget(x); ! tkwidgets_draw_inlets((t_object*)x, glist, ! x->canvas_id, x->iolets_tag, x->all_tag, ! x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS); ! if(x->have_scrollbars) draw_scrollbar(x); ! sys_vgui("%s create window %d %d -anchor nw -window %s \ -tags {%s %s} -width %d -height %d \n", x->canvas_id->s_name, ! text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), ! x->frame_id->s_name, x->window_tag->s_name, x->all_tag->s_name, ! x->width, x->height); ! }
static void textwidget_erase(t_textwidget* x,t_glist* glist) *************** *** 341,345 ****
set_tkwidgets_ids(x,glist_getcanvas(glist)); ! erase_inlets(x); sys_vgui("destroy %s\n", x->frame_id->s_name); sys_vgui("%s delete %s\n", x->canvas_id->s_name, x->all_tag->s_name); --- 278,282 ----
set_tkwidgets_ids(x,glist_getcanvas(glist)); ! tkwidgets_erase_inlets(x->canvas_id, x->iolets_tag); sys_vgui("destroy %s\n", x->frame_id->s_name); sys_vgui("%s delete %s\n", x->canvas_id->s_name, x->all_tag->s_name); *************** *** 350,354 **** /* ------------------------ text widgetbehaviour----------------------------- */
- static void textwidget_getrect(t_gobj *z, t_glist *owner, int *xp1, int *yp1, int *xp2, int *yp2) --- 287,290 ---- *************** *** 358,363 **** *xp1 = text_xpix(&x->x_obj, owner); *yp1 = text_ypix(&x->x_obj, owner); ! *xp2 = *xp1 + x->size_x; ! *yp2 = *yp1 + x->size_y + 2; // add 2 to give space for outlets }
--- 294,299 ---- *xp1 = text_xpix(&x->x_obj, owner); *yp1 = text_ypix(&x->x_obj, owner); ! *xp2 = *xp1 + x->width; ! *yp2 = *yp1 + x->height + 2; // add 2 to give space for outlets }
*************** *** 373,381 **** sys_vgui("%s move %s %d %d\n", x->canvas_id->s_name, x->all_tag->s_name, dx, dy); sys_vgui("%s move RSZ %d %d\n", x->canvas_id->s_name, dx, dy); - /* sys_vgui("%s coords %s %d %d %d %d\n", x->canvas_id->s_name, x->all_tag->s_name, - text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1, - text_xpix(&x->x_obj, glist) + x->size_x, - text_ypix(&x->x_obj, glist) + x->size_y-2);*/ - // textwidget_drawme(x, glist, 0); canvas_fixlinesfor(glist_getcanvas(glist), (t_text*) x); } --- 309,312 ---- *************** *** 452,456 **** if (vis) { y = (t_rtext *) rtext_new(glist, (t_text *)z); ! textwidget_drawme(x, glist, 1); } else { --- 383,387 ---- if (vis) { y = (t_rtext *) rtext_new(glist, (t_text *)z); ! textwidget_drawme(x, glist); } else { *************** *** 612,616 **** x->x_obj.te_xpix, x->x_obj.te_ypix, atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), ! x->size_x, x->size_y, x->x_have_scrollbars); binbuf_addbinbuf(b, x->options_binbuf); binbuf_addv(b, ";"); --- 543,547 ---- x->x_obj.te_xpix, x->x_obj.te_ypix, atom_getsymbol(binbuf_getvec(x->x_obj.te_binbuf)), ! x->width, x->height, x->have_scrollbars); binbuf_addbinbuf(b, x->options_binbuf); binbuf_addv(b, ";"); *************** *** 640,644 **** t_atom state[2]; SETSYMBOL(state, scrollbars_symbol); ! SETFLOAT(state + 1, (t_float)x->x_have_scrollbars); textwidget_query_callback(x, gensym("query_callback"), 2, state); } --- 571,575 ---- t_atom state[2]; SETSYMBOL(state, scrollbars_symbol); ! SETFLOAT(state + 1, (t_float)x->have_scrollbars); textwidget_query_callback(x, gensym("query_callback"), 2, state); } *************** *** 648,653 **** t_atom coords[3]; SETSYMBOL(coords, size_symbol); ! SETFLOAT(coords + 1, (t_float)x->size_x); ! SETFLOAT(coords + 2, (t_float)x->size_y); textwidget_query_callback(x, gensym("query_callback"), 3, coords); } --- 579,584 ---- t_atom coords[3]; SETSYMBOL(coords, size_symbol); ! SETFLOAT(coords + 1, (t_float)x->width); ! SETFLOAT(coords + 2, (t_float)x->height); textwidget_query_callback(x, gensym("query_callback"), 3, coords); } *************** *** 658,662 **** if(s == &s_) { ! tkwidgets_query_options(x->receive_name, x->widget_id->s_name, sizeof(textwidget_tk_options)/sizeof(char *), textwidget_tk_options); --- 589,593 ---- if(s == &s_) { ! tkwidgets_query_options(x->receive_name, x->widget_id, sizeof(textwidget_tk_options)/sizeof(char *), textwidget_tk_options); *************** *** 669,678 **** query_size(x); else ! tkwidgets_query_options(x->receive_name, x->widget_id->s_name, 1, &(s->s_name)); }
static void textwidget_scrollbars(t_textwidget *x, t_float f) { ! if(f > 0) draw_scrollbar(x); else --- 600,610 ---- query_size(x); else ! tkwidgets_query_options(x->receive_name, x->widget_id, 1, &(s->s_name)); }
static void textwidget_scrollbars(t_textwidget *x, t_float f) { ! int value = (int) f; ! if(value > 0) draw_scrollbar(x); else *************** *** 683,699 **** { DEBUG(post("textwidget_size");); ! x->size_y = height; ! x->size_x = width; if(glist_isvisible(x->x_glist)) { sys_vgui("%s itemconfigure %s -width %d -height %d\n", ! x->canvas_id->s_name, x->window_id->s_name, x->size_x, x->size_y); ! erase_inlets(x); ! textwidget_draw_inlets(x, x->x_glist, 1, TOTAL_INLETS, TOTAL_OUTLETS); canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet } }
! /* callback functions */
static void textwidget_store_callback(t_textwidget *x, t_symbol *s, int argc, t_atom *argv) --- 615,633 ---- { DEBUG(post("textwidget_size");); ! x->height = height; ! x->width = width; if(glist_isvisible(x->x_glist)) { sys_vgui("%s itemconfigure %s -width %d -height %d\n", ! x->canvas_id->s_name, x->window_tag->s_name, x->width, x->height); ! tkwidgets_erase_inlets(x->canvas_id, x->iolets_tag); ! tkwidgets_draw_inlets((t_object*)x, x->x_glist, ! x->canvas_id, x->iolets_tag, x->all_tag, ! x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS); canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet } }
! /* -------------------- callback functions ---------------------------------- */
static void textwidget_store_callback(t_textwidget *x, t_symbol *s, int argc, t_atom *argv) *************** *** 733,737 **** if (canvas) { ! textwidget_draw_inlets(x, canvas, 1, TOTAL_INLETS, TOTAL_OUTLETS); canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet } --- 667,673 ---- if (canvas) { ! tkwidgets_draw_inlets((t_object*)x, canvas, ! x->canvas_id, x->iolets_tag, x->all_tag, ! x->width, x->height, TOTAL_INLETS, TOTAL_OUTLETS); canvas_fixlinesfor(x->x_glist, (t_text *)x); // 2nd inlet } *************** *** 739,743 **** else if (!x->x_resizing && newstate) { ! erase_inlets(x); } x->x_resizing = newstate; --- 675,679 ---- else if (!x->x_resizing && newstate) { ! tkwidgets_erase_inlets(x->canvas_id, x->iolets_tag); } x->x_resizing = newstate; *************** *** 752,760 **** if (glist_isvisible(x->x_glist)) { ! x->size_x += dx; ! x->size_y += dy; sys_vgui("%s itemconfigure %s -width %d -height %d\n", ! x->canvas_id->s_name, x->window_id->s_name, ! x->size_x, x->size_y); sys_vgui("%s move RSZ %d %d\n", x->canvas_id->s_name, dx, dy); --- 688,696 ---- 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 RSZ %d %d\n", x->canvas_id->s_name, dx, dy); *************** *** 764,767 **** --- 700,705 ---- }
+ /* --------------------------- standard class functions --------------------- */ + static void textwidget_free(t_textwidget *x) { *************** *** 782,794 **** { post("[text]: less than 3 arguments entered, default values used."); ! x->size_x = TEXT_DEFAULT_WIDTH; ! x->size_y = TEXT_DEFAULT_HEIGHT; ! x->x_have_scrollbars = 0; } else { ! x->size_x = atom_getint(argv); ! x->size_y = atom_getint(argv + 1); ! x->x_have_scrollbars = atom_getint(argv + 2); if(argc > 3) { --- 720,732 ---- { post("[text]: less than 3 arguments entered, default values used."); ! x->width = TEXT_DEFAULT_WIDTH; ! x->height = TEXT_DEFAULT_HEIGHT; ! x->have_scrollbars = 0; } else { ! x->width = atom_getint(argv); ! x->height = atom_getint(argv + 1); ! x->have_scrollbars = atom_getint(argv + 2); if(argc > 3) { *************** *** 804,807 **** --- 742,746 ---- x->x_glist = canvas_getcurrent(); set_tkwidgets_ids(x, x->x_glist); + x->iolets_tag = tkwidgets_gen_iolets_tag((t_object*)x); x->all_tag = tkwidgets_gen_all_tag((t_object*)x);
*************** *** 820,837 **** class_addanything(textwidget_class, (t_method)textwidget_option);
class_addmethod(textwidget_class, (t_method)textwidget_query, gensym("query"), A_DEFSYMBOL, 0); class_addmethod(textwidget_class, (t_method)textwidget_scrollbars, gensym("scrollbars"), A_DEFFLOAT, 0); - class_addmethod(textwidget_class, (t_method)textwidget_size, - gensym("size"), A_DEFFLOAT, A_DEFFLOAT, 0); class_addmethod(textwidget_class, (t_method)textwidget_set, gensym("set"), A_GIMME, 0); ! class_addmethod(textwidget_class, (t_method)textwidget_append, ! gensym("append"), A_GIMME, 0); ! class_addmethod(textwidget_class, (t_method)textwidget_key, ! gensym("key"), A_GIMME, 0); ! class_addmethod(textwidget_class, (t_method)textwidget_clear, ! gensym("clear"), 0); /* callbacks */ class_addmethod(textwidget_class, (t_method)textwidget_store_callback, --- 759,776 ---- class_addanything(textwidget_class, (t_method)textwidget_option);
+ class_addmethod(textwidget_class, (t_method)textwidget_append, + gensym("append"), A_GIMME, 0); + class_addmethod(textwidget_class, (t_method)textwidget_clear, + gensym("clear"), 0); + class_addmethod(textwidget_class, (t_method)textwidget_key, + gensym("key"), A_GIMME, 0); class_addmethod(textwidget_class, (t_method)textwidget_query, gensym("query"), A_DEFSYMBOL, 0); class_addmethod(textwidget_class, (t_method)textwidget_scrollbars, gensym("scrollbars"), A_DEFFLOAT, 0); class_addmethod(textwidget_class, (t_method)textwidget_set, gensym("set"), A_GIMME, 0); ! class_addmethod(textwidget_class, (t_method)textwidget_size, ! gensym("size"), A_DEFFLOAT, A_DEFFLOAT, 0); /* callbacks */ class_addmethod(textwidget_class, (t_method)textwidget_store_callback, *************** *** 849,853 **** class_addmethod(textwidget_class, (t_method)textwidget_resize_motion_callback, gensym("resize_motion"), A_FLOAT, A_FLOAT, 0); ! class_setwidget(textwidget_class,&textwidget_widgetbehavior); class_setsavefn(textwidget_class,&textwidget_save); --- 788,799 ---- class_addmethod(textwidget_class, (t_method)textwidget_resize_motion_callback, gensym("resize_motion"), A_FLOAT, A_FLOAT, 0); ! ! textwidget_widgetbehavior.w_getrectfn = textwidget_getrect; ! textwidget_widgetbehavior.w_displacefn = textwidget_displace; ! textwidget_widgetbehavior.w_selectfn = textwidget_select; ! textwidget_widgetbehavior.w_activatefn = textwidget_activate; ! textwidget_widgetbehavior.w_deletefn = textwidget_delete; ! textwidget_widgetbehavior.w_visfn = textwidget_vis; ! textwidget_widgetbehavior.w_clickfn = NULL; class_setwidget(textwidget_class,&textwidget_widgetbehavior); class_setsavefn(textwidget_class,&textwidget_save);