Update of /cvsroot/pure-data/externals/tkwidgets
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26942
Modified Files:
text.c
Added Files:
checkbutton-help.pd checkbutton.c
Log Message:
- created functions to generate all the various Tk IDs and tags and ported
text.c to use those functions
- started sketch for checkbutton.c
--- NEW FILE: checkbutton.c ---
/* [checkbutton] object for dislaying a check box
Copyright (C) 2002-2004 Guenter Geiger
Copyright (C) 2007 Hans-Christoph Steiner <hans(a)at.or.at>
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
This is part of the tkwidgets library for Pd.
*/
#include "shared/tkwidgets.h"
/* ------------------------ class variables --------------------------------- */
static t_class *checkbutton_class;
static t_widgetbehavior checkbutton_widgetbehavior;
typedef struct _checkbutton
{
t_object x_obj;
t_glist* x_glist;
int x_width;
int x_height;
/* IDs for Tk widgets */
t_symbol* tcl_namespace;
t_symbol* receive_name; /* name to bind to to receive callbacks */
t_symbol* canvas_id;
t_symbol* widget_id;
t_symbol* handle_id;
t_symbol* all_tag;
t_outlet* x_data_outlet;
t_outlet* x_status_outlet;
} t_checkbutton;
static char *checkbutton_tk_options[] = {
"activebackground",
"activeforeground",
"anchor",
"background",
"bitmap",
"borderwidth",
"command",
"compound",
"cursor",
"disabledforeground",
"font",
"foreground",
"height",
"highlightbackground",
"highlightcolor",
"highlightthickness",
"image",
"indicatoron",
"justify",
"offrelief",
"offvalue",
"onvalue",
"overrelief",
"padx",
"pady",
"relief",
"selectcolor",
"selectimage",
"state",
"takefocus",
"text",
"textvariable",
"underline",
"variable",
"width",
"wraplength"
};
/* -------------------- 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);
}
/* --------------------- checkbutton widgetbehaviour ------------------------ */
static void checkbutton_getrect(t_gobj *z, t_glist *glist,
int *xp1, int *yp1, int *xp2, int *yp2)
{
t_checkbutton* x = (t_checkbutton*)z;
*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;
}
static void checkbutton_delete(t_gobj *z, t_glist *glist)
{
t_text *x = (t_text *)z;
canvas_deletelinesfor(glist_getcanvas(glist), x);
}
static void checkbutton_vis(t_gobj *z, t_glist *glist, int vis)
{
t_checkbutton* s = (t_checkbutton*)z;
if (vis)
checkbutton_drawme(s, glist);
else
checkbutton_erase(s, glist);
}
/* --------------------------- standard class functions --------------------- */
static void checkbutton_free(t_checkbutton *x)
{
pd_unbind(&x->x_obj.ob_pd, x->receive_name);
}
static void *checkbutton_new(t_symbol* s, int argc, t_atom *argv)
{
t_checkbutton *x = (t_checkbutton *)pd_new(checkbutton_class);
x->x_glist = (t_glist*) canvas_getcurrent();
x->x_width = 15;
x->x_height = 15;
outlet_new(&x->x_obj, &s_float);
return (x);
}
void checkbutton_setup(void)
{
checkbutton_class = class_new(gensym("checkbutton"), (t_newmethod)checkbutton_new,
(t_method)checkbutton_free,
sizeof(t_checkbutton), 0, A_GIMME,0);
checkbutton_widgetbehavior.w_getrectfn = checkbutton_getrect;
checkbutton_widgetbehavior.w_displacefn = NULL;
checkbutton_widgetbehavior.w_selectfn = NULL;
checkbutton_widgetbehavior.w_activatefn = NULL;
checkbutton_widgetbehavior.w_deletefn = checkbutton_delete;
checkbutton_widgetbehavior.w_visfn = checkbutton_vis;
checkbutton_widgetbehavior.w_clickfn = NULL;
class_setwidget(checkbutton_class, &checkbutton_widgetbehavior);
}
--- NEW FILE: checkbutton-help.pd ---
#N canvas 351 228 450 300 10;
#X obj 178 105 checkbutton;
Index: text.c
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/text.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -C2 -d -r1.5 -r1.6
*** text.c 15 Nov 2007 17:27:03 -0000 1.5
--- text.c 21 Nov 2007 22:19:12 -0000 1.6
***************
*** 44,71 ****
typedef struct _textwidget
{
! t_object x_obj;
! t_canvas* x_canvas;
! t_glist* x_glist;
!
! t_symbol* receive_name;
!
! t_binbuf* options_binbuf;
! int size_x;
! int size_y;
! int x_have_scrollbars;
! int x_resizing;
! int x_selected;
/* IDs for Tk widgets */
! char* tcl_namespace;
! char* canvas_id;
! char* frame_id;
! char* text_id;
! char* scrollbar_id;
! char* handle_id;
! char* window_tag;
! char* all_tag;
t_outlet* x_data_outlet;
--- 44,69 ----
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;
! int x_selected;
/* IDs for Tk widgets */
! t_symbol* tcl_namespace;
! t_symbol* receive_name; /* name to bind to to receive callbacks */
! t_symbol* canvas_id;
! t_symbol* frame_id;
! t_symbol* widget_id;
! t_symbol* scrollbar_id;
! t_symbol* handle_id;
! t_symbol* window_id;
! t_symbol* all_tag;
t_outlet* x_data_outlet;
***************
*** 114,118 ****
! /* move these to tkwidgets.c */
static t_symbol *scrollbars_symbol;
static t_symbol *size_symbol;
--- 112,116 ----
! /* common symbols to preload */
static t_symbol *scrollbars_symbol;
static t_symbol *size_symbol;
***************
*** 163,174 ****
// TODO: only send if there is a value, not when blank
sys_vgui("lappend ::%s::store_list -%s \n",
! x->tcl_namespace, textwidget_tk_options[i]);
sys_vgui("lappend ::%s::store_list [%s cget -%s] \n",
! x->tcl_namespace, x->text_id, textwidget_tk_options[i]);
post("option %d: %s", i, textwidget_tk_options[i]);
}
sys_vgui("pd [concat %s store_callback $::%s::store_list \\;]\n",
! x->receive_name->s_name, x->tcl_namespace);
! sys_vgui("unset ::%s::store_list \n", x->tcl_namespace);
}
--- 161,172 ----
// TODO: only send if there is a value, not when blank
sys_vgui("lappend ::%s::store_list -%s \n",
! x->tcl_namespace->s_name, textwidget_tk_options[i]);
sys_vgui("lappend ::%s::store_list [%s cget -%s] \n",
! x->tcl_namespace->s_name, x->widget_id, textwidget_tk_options[i]);
post("option %d: %s", i, textwidget_tk_options[i]);
}
sys_vgui("pd [concat %s store_callback $::%s::store_list \\;]\n",
! x->receive_name->s_name, x->tcl_namespace->s_name);
! sys_vgui("unset ::%s::store_list \n", x->tcl_namespace->s_name);
}
***************
*** 178,217 ****
}
! static void set_tk_widget_ids(t_textwidget *x, t_canvas *canvas)
{
- char buf[MAXPDSTRING];
-
x->x_canvas = canvas;
!
! /* Tk ID for the current canvas that this object is drawn in */
! sprintf(buf,".x%lx.c", (long unsigned int) canvas);
! x->canvas_id = getbytes(strlen(buf));
! strcpy(x->canvas_id, buf);
!
! /* Tk ID for the "frame" the other things are drawn in */
! sprintf(buf,"%s.frame%lx", x->canvas_id, (long unsigned int)x);
! x->frame_id = getbytes(strlen(buf));
! strcpy(x->frame_id, buf);
!
! sprintf(buf,"%s.text%lx", x->frame_id, (long unsigned int)x);
! x->text_id = getbytes(strlen(buf));
! strcpy(x->text_id, buf); /* Tk ID for the "text", the meat! */
!
! sprintf(buf,"%s.window%lx", x->canvas_id, (long unsigned int)x);
! x->window_tag = getbytes(strlen(buf));
! strcpy(x->window_tag, buf); /* Tk ID for the resizing "window" */
! post("");
!
! sprintf(buf,"%s.handle%lx", x->canvas_id, (long unsigned int)x);
! x->handle_id = getbytes(strlen(buf));
! strcpy(x->handle_id, buf); /* Tk ID for the resizing "handle" */
!
! sprintf(buf,"%s.scrollbar%lx", x->frame_id, (long unsigned int)x);
! x->scrollbar_id = getbytes(strlen(buf));
! strcpy(x->scrollbar_id, buf); /* Tk ID for the optional "scrollbar" */
!
! sprintf(buf,"all%lx", (long unsigned int)x);
! x->all_tag = getbytes(strlen(buf));
! strcpy(x->all_tag, buf); /* Tk ID for the optional "scrollbar" */
}
--- 176,188 ----
}
! static void set_tkwidgets_ids(t_textwidget *x, t_canvas *canvas)
{
x->x_canvas = canvas;
! x->canvas_id = tkwidgets_gen_canvas_id(x->x_canvas);
! x->frame_id = tkwidgets_gen_frame_id((t_object*)x, x->canvas_id);
! 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);
}
***************
*** 234,240 ****
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, onset, text_ypix(&x->x_obj, glist) - 2,
onset + IOWIDTH, text_ypix(&x->x_obj, glist),
! x, i, x, x->all_tag);
}
for (i = 0; i < total_outlets; i++) /* outlets */
--- 205,211 ----
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 */
***************
*** 242,248 ****
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, 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);
}
}
--- 213,219 ----
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);
}
}
***************
*** 252,257 ****
DEBUG(post("erase_inlets"););
/* Added tag for all inlets/outlets of one instance */
! sys_vgui("%s delete %xi\n", x->canvas_id, x);
! sys_vgui("%s delete %xo\n", x->canvas_id, x);
}
--- 223,228 ----
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);
}
***************
*** 260,264 ****
{
sys_vgui("pack %s -side right -fill y -before %s \n",
! x->scrollbar_id, x->text_id);
x->x_have_scrollbars = 1;
}
--- 231,235 ----
{
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;
}
***************
*** 266,270 ****
static void erase_scrollbar(t_textwidget *x)
{
! sys_vgui("pack forget %s \n", x->scrollbar_id);
x->x_have_scrollbars = 0;
}
--- 237,241 ----
static void erase_scrollbar(t_textwidget *x)
{
! sys_vgui("pack forget %s \n", x->scrollbar_id->s_name);
x->x_have_scrollbars = 0;
}
***************
*** 274,285 ****
#ifdef __APPLE__
sys_vgui("bind %s <Mod1-Key> {pdtk_canvas_ctrlkey %s %%K 0}\n",
! x->text_id, x->canvas_id);
sys_vgui("bind %s <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %s %%K 1}\n",
! x->text_id, x->canvas_id);
#else
sys_vgui("bind %s <Control-Key> {pdtk_canvas_ctrlkey %s %%K 0}\n",
! x->text_id, x->canvas_id);
sys_vgui("bind %s <Control-Shift-Key> {pdtk_canvas_ctrlkey %s %%K 1}\n",
! x->text_id, x->canvas_id);
#endif
}
--- 245,256 ----
#ifdef __APPLE__
sys_vgui("bind %s <Mod1-Key> {pdtk_canvas_ctrlkey %s %%K 0}\n",
! x->widget_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <Mod1-Shift-Key> {pdtk_canvas_ctrlkey %s %%K 1}\n",
! x->widget_id->s_name, x->canvas_id->s_name);
#else
sys_vgui("bind %s <Control-Key> {pdtk_canvas_ctrlkey %s %%K 0}\n",
! x->widget_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <Control-Shift-Key> {pdtk_canvas_ctrlkey %s %%K 1}\n",
! x->widget_id->s_name, x->canvas_id->s_name);
#endif
}
***************
*** 290,313 ****
sys_vgui("bind %s <Button> {pdtk_canvas_sendclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b 0}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
sys_vgui("bind %s <ButtonRelease> {pdtk_canvas_mouseup %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
sys_vgui("bind %s <Shift-Button> {pdtk_canvas_click %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b 1}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
sys_vgui("bind %s <Button-2> {pdtk_canvas_rightclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
sys_vgui("bind %s <Button-3> {pdtk_canvas_rightclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
sys_vgui("bind %s <Control-Button> {pdtk_canvas_rightclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
/* mouse motion */
sys_vgui("bind %s <Motion> {pdtk_canvas_motion %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] 0}\n",
! x->text_id, x->canvas_id, x->canvas_id, x->canvas_id);
}
--- 261,291 ----
sys_vgui("bind %s <Button> {pdtk_canvas_sendclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b 0}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <ButtonRelease> {pdtk_canvas_mouseup %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <Shift-Button> {pdtk_canvas_click %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b 1}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <Button-2> {pdtk_canvas_rightclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <Button-3> {pdtk_canvas_rightclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
sys_vgui("bind %s <Control-Button> {pdtk_canvas_rightclick %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] %%b}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
/* mouse motion */
sys_vgui("bind %s <Motion> {pdtk_canvas_motion %s \
[expr %%X - [winfo rootx %s]] [expr %%Y - [winfo rooty %s]] 0}\n",
! x->widget_id->s_name, x->canvas_id->s_name,
! x->canvas_id->s_name, x->canvas_id->s_name);
}
***************
*** 319,336 ****
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
! sys_vgui("destroy %s\n", x->frame_id);
! sys_vgui("frame %s \n", x->frame_id);
sys_vgui("text %s -border 1 \
-highlightthickness 1 -relief sunken -bg \"%s\" -yscrollcommand {%s set} \n",
! x->text_id, DEFAULT_COLOR, x->scrollbar_id);
sys_vgui("scrollbar %s -command {%s yview}\n",
! x->scrollbar_id, x->text_id);
! sys_vgui("pack %s -side left -fill both -expand 1 \n", x->text_id);
! sys_vgui("pack %s -side bottom -fill both -expand 1 \n", x->frame_id);
bind_standard_keys(x);
bind_button_events(x);
sys_vgui("bind %s <KeyRelease> {+pd %s keyup %%N \\;} \n",
! x->text_id, x->receive_name->s_name);
}
--- 297,314 ----
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
! sys_vgui("destroy %s\n", x->frame_id->s_name);
! sys_vgui("frame %s \n", x->frame_id->s_name);
sys_vgui("text %s -border 1 \
-highlightthickness 1 -relief sunken -bg \"%s\" -yscrollcommand {%s set} \n",
! x->widget_id->s_name, DEFAULT_COLOR, x->scrollbar_id->s_name);
sys_vgui("scrollbar %s -command {%s yview}\n",
! x->scrollbar_id->s_name, x->widget_id->s_name);
! sys_vgui("pack %s -side left -fill both -expand 1 \n", x->widget_id->s_name);
! sys_vgui("pack %s -side bottom -fill both -expand 1 \n", x->frame_id->s_name);
bind_standard_keys(x);
bind_button_events(x);
sys_vgui("bind %s <KeyRelease> {+pd %s keyup %%N \\;} \n",
! x->widget_id->s_name, x->receive_name->s_name);
}
***************
*** 338,342 ****
{
DEBUG(post("textwidget_drawme: firsttime %d canvas %lx glist %lx", firsttime, x->x_canvas, glist););
! set_tk_widget_ids(x,glist_getcanvas(glist));
if (firsttime)
{
--- 316,320 ----
{
DEBUG(post("textwidget_drawme: firsttime %d canvas %lx glist %lx", firsttime, x->x_canvas, glist););
! set_tkwidgets_ids(x,glist_getcanvas(glist));
if (firsttime)
{
***************
*** 345,356 ****
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,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
! x->frame_id, x->window_tag, x->all_tag, x->size_x, x->size_y);
}
else
{
post("NO MORE COORDS");
! // sys_vgui("%s coords %s %d %d\n", x->canvas_id, x->all_tag,
// text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
}
--- 323,334 ----
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));
}
***************
*** 362,369 ****
DEBUG(post("textwidget_erase: canvas %lx glist %lx", x->x_canvas, glist););
! set_tk_widget_ids(x,glist_getcanvas(glist));
erase_inlets(x);
! sys_vgui("destroy %s\n", x->frame_id);
! sys_vgui("%s delete %s\n", x->canvas_id, x->all_tag);
}
--- 340,347 ----
DEBUG(post("textwidget_erase: canvas %lx glist %lx", x->x_canvas, glist););
! 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);
}
***************
*** 392,399 ****
if (glist_isvisible(glist))
{
! set_tk_widget_ids(x,glist_getcanvas(glist));
! sys_vgui("%s move %s %d %d\n", x->canvas_id, x->all_tag, dx, dy);
! sys_vgui("%s move RSZ %d %d\n", x->canvas_id, dx, dy);
! /* sys_vgui("%s coords %s %d %d %d %d\n", x->canvas_id, x->all_tag,
text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
text_xpix(&x->x_obj, glist) + x->size_x,
--- 370,377 ----
if (glist_isvisible(glist))
{
! set_tkwidgets_ids(x,glist_getcanvas(glist));
! 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,
***************
*** 413,417 ****
{
sys_vgui("%s configure -bg #bdbddd -state disabled -cursor $cursor_editmode_nothing\n",
! x->text_id);
x->x_selected = 1;
}
--- 391,395 ----
{
sys_vgui("%s configure -bg #bdbddd -state disabled -cursor $cursor_editmode_nothing\n",
! x->widget_id->s_name);
x->x_selected = 1;
}
***************
*** 419,425 ****
{
sys_vgui("%s configure -bg grey -state normal -cursor xterm\n",
! x->text_id);
/* activatefn never gets called with 0, so destroy here */
! sys_vgui("destroy %s\n", x->handle_id);
x->x_selected = 0;
}
--- 397,403 ----
{
sys_vgui("%s configure -bg grey -state normal -cursor xterm\n",
! x->widget_id->s_name);
/* activatefn never gets called with 0, so destroy here */
! sys_vgui("destroy %s\n", x->handle_id->s_name);
x->x_selected = 0;
}
***************
*** 437,441 ****
sys_vgui("canvas %s -width %d -height %d -bg #ddd -bd 0 \
-highlightthickness 3 -highlightcolor {#f00} -cursor bottom_right_corner\n",
! x->handle_id, TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT);
int handle_x1 = x2 - TKW_HANDLE_WIDTH;
int handle_y1 = y2 - (TKW_HANDLE_HEIGHT - TKW_HANDLE_INSET);
--- 415,419 ----
sys_vgui("canvas %s -width %d -height %d -bg #ddd -bd 0 \
-highlightthickness 3 -highlightcolor {#f00} -cursor bottom_right_corner\n",
! x->handle_id->s_name, TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT);
int handle_x1 = x2 - TKW_HANDLE_WIDTH;
int handle_y1 = y2 - (TKW_HANDLE_HEIGHT - TKW_HANDLE_INSET);
***************
*** 444,459 ****
/* no worky, this should draw MAC OS X style lines on the resize handle */
/* sys_vgui("%s create line %d %d %d %d -fill black -tags RESIZE_LINES\n", */
! /* x->handle_id, handle_x2, handle_y1, handle_x1, handle_y2); */
sys_vgui("%s create window %d %d -anchor nw -width %d -height %d -window %s -tags RSZ\n",
! x->canvas_id, handle_x1, handle_y1,
TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT,
! x->handle_id, x->all_tag);
! sys_vgui("raise %s\n", x->handle_id);
sys_vgui("bind %s <Button> {pd [concat %s resize_click 1 \\;]}\n",
! x->handle_id, x->receive_name->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s resize_click 0 \\;]}\n",
! x->handle_id, x->receive_name->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s resize_motion %%x %%y \\;]}\n",
! x->handle_id, x->receive_name->s_name);
}
}
--- 422,437 ----
/* no worky, this should draw MAC OS X style lines on the resize handle */
/* sys_vgui("%s create line %d %d %d %d -fill black -tags RESIZE_LINES\n", */
! /* x->handle_id->s_name, handle_x2, handle_y1, handle_x1, handle_y2); */
sys_vgui("%s create window %d %d -anchor nw -width %d -height %d -window %s -tags RSZ\n",
! x->canvas_id->s_name, handle_x1, handle_y1,
TKW_HANDLE_WIDTH, TKW_HANDLE_HEIGHT,
! x->handle_id->s_name, x->all_tag->s_name);
! sys_vgui("raise %s\n", x->handle_id->s_name);
sys_vgui("bind %s <Button> {pd [concat %s resize_click 1 \\;]}\n",
! x->handle_id->s_name, x->receive_name->s_name);
sys_vgui("bind %s <ButtonRelease> {pd [concat %s resize_click 0 \\;]}\n",
! x->handle_id->s_name, x->receive_name->s_name);
sys_vgui("bind %s <Motion> {pd [concat %s resize_motion %%x %%y \\;]}\n",
! x->handle_id->s_name, x->receive_name->s_name);
}
}
***************
*** 506,520 ****
{
tmp_float = atom_getfloatarg(i, argc , argv);
! sys_vgui("lappend ::%s::list %g \n", x->tcl_namespace, tmp_float );
}
else
{
! sys_vgui("lappend ::%s::list %s \n", x->tcl_namespace, tmp_symbol->s_name );
}
}
! sys_vgui("append ::%s::list \" \"\n", x->tcl_namespace);
sys_vgui("%s insert end $::%s::list ; unset ::%s::list \n",
! x->text_id, x->tcl_namespace, x->tcl_namespace );
! sys_vgui("%s yview end-2char \n", x->text_id );
}
--- 484,498 ----
{
tmp_float = atom_getfloatarg(i, argc , argv);
! sys_vgui("lappend ::%s::list %g \n", x->tcl_namespace->s_name, tmp_float );
}
else
{
! sys_vgui("lappend ::%s::list %s \n", x->tcl_namespace->s_name, tmp_symbol->s_name );
}
}
! sys_vgui("append ::%s::list \" \"\n", x->tcl_namespace->s_name);
sys_vgui("%s insert end $::%s::list ; unset ::%s::list \n",
! x->widget_id->s_name, x->tcl_namespace->s_name, x->tcl_namespace->s_name );
! sys_vgui("%s yview end-2char \n", x->widget_id->s_name );
}
***************
*** 531,550 ****
if(tmp_int < 10)
{
! sys_vgui("%s insert end %d\n", x->text_id, tmp_int);
}
else if(tmp_int == 10)
{
! sys_vgui("%s insert end {\n}\n", x->text_id);
}
else
{
! sys_vgui("%s insert end [format \"%c\" %d]\n", x->text_id, tmp_int);
}
}
else
{
! sys_vgui("%s insert end %s\n", x->text_id, tmp_symbol->s_name );
}
! sys_vgui("%s yview end-2char \n", x->text_id );
}
--- 509,528 ----
if(tmp_int < 10)
{
! sys_vgui("%s insert end %d\n", x->widget_id->s_name, tmp_int);
}
else if(tmp_int == 10)
{
! sys_vgui("%s insert end {\n}\n", x->widget_id->s_name);
}
else
{
! sys_vgui("%s insert end [format \"%c\" %d]\n", x->widget_id->s_name, tmp_int);
}
}
else
{
! sys_vgui("%s insert end %s\n", x->widget_id->s_name, tmp_symbol->s_name );
}
! sys_vgui("%s yview end-2char \n", x->widget_id->s_name );
}
***************
*** 552,556 ****
static void textwidget_clear(t_textwidget* x)
{
! sys_vgui("%s delete 0.0 end \n", x->text_id);
}
--- 530,534 ----
static void textwidget_clear(t_textwidget* x)
{
! sys_vgui("%s delete 0.0 end \n", x->widget_id->s_name);
}
***************
*** 570,574 ****
sys_vgui("pd [concat %s output [string map {\",\" \"\\\\,\" \";\" \"\\\\;\"} \
[%s get 0.0 end]] \\;]\n",
! x->receive_name->s_name, x->text_id);
}
--- 548,552 ----
sys_vgui("pd [concat %s output [string map {\",\" \"\\\\,\" \";\" \"\\\\;\"} \
[%s get 0.0 end]] \\;]\n",
! x->receive_name->s_name, x->widget_id->s_name);
}
***************
*** 653,657 ****
post("argument_buffer: %s", argument_buffer);
sys_vgui("%s configure -%s {%s} \n",
! x->text_id, s->s_name, argument_buffer);
store_options(x);
}
--- 631,635 ----
post("argument_buffer: %s", argument_buffer);
sys_vgui("%s configure -%s {%s} \n",
! x->widget_id->s_name, s->s_name, argument_buffer);
store_options(x);
}
***************
*** 680,685 ****
if(s == &s_)
{
! query_options(x->receive_name, x->text_id,
! sizeof(textwidget_tk_options)/sizeof(char *), textwidget_tk_options);
query_scrollbars(x);
query_size(x);
--- 658,664 ----
if(s == &s_)
{
! tkwidgets_query_options(x->receive_name, x->widget_id->s_name,
! sizeof(textwidget_tk_options)/sizeof(char *),
! textwidget_tk_options);
query_scrollbars(x);
query_size(x);
***************
*** 690,694 ****
query_size(x);
else
! query_options(x->receive_name, x->text_id, 1, &(s->s_name));
}
--- 669,673 ----
query_size(x);
else
! tkwidgets_query_options(x->receive_name, x->widget_id->s_name, 1, &(s->s_name));
}
***************
*** 709,713 ****
{
sys_vgui("%s itemconfigure %s -width %d -height %d\n",
! x->canvas_id, x->window_tag, x->size_x, x->size_y);
erase_inlets(x);
textwidget_draw_inlets(x, x->x_glist, 1, TOTAL_INLETS, TOTAL_OUTLETS);
--- 688,692 ----
{
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);
***************
*** 776,783 ****
x->size_y += dy;
sys_vgui("%s itemconfigure %s -width %d -height %d\n",
! x->canvas_id, x->window_tag,
x->size_x, x->size_y);
sys_vgui("%s move RSZ %d %d\n",
! x->canvas_id, dx, dy);
}
}
--- 755,763 ----
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);
! canvas_fixlinesfor(x->x_glist, (t_text *)x);
}
}
***************
*** 793,797 ****
DEBUG(post("textwidget_new"););
t_textwidget *x = (t_textwidget *)pd_new(textwidget_class);
- char buf[MAXPDSTRING];
x->options_binbuf = binbuf_new();
--- 773,776 ----
***************
*** 819,835 ****
}
! x->x_data_outlet = outlet_new(&x->x_obj, &s_float);
! x->x_status_outlet = outlet_new(&x->x_obj, &s_symbol);
!
! sprintf(buf,"text%lx",(long unsigned int)x);
! x->tcl_namespace = getbytes(strlen(buf));
! strcpy(x->tcl_namespace, buf);
!
! sprintf(buf,"#%s", x->tcl_namespace);
! x->receive_name = gensym(buf);
pd_bind(&x->x_obj.ob_pd, x->receive_name);
x->x_glist = canvas_getcurrent();
! set_tk_widget_ids(x, x->x_glist);
return (x);
--- 798,811 ----
}
! 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->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_symbol);
return (x);