[PD-cvs] externals/bbogart/popup popup.c,1.14,1.15
IOhannes m zmölnig
zmoelnig at users.sourceforge.net
Tue Jun 7 10:49:26 CEST 2005
Update of /cvsroot/pure-data/externals/bbogart/popup
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16483
Modified Files:
popup.c
Log Message:
added a "disable"-message to turn off graphical chosing (you can still choose via float/symbol-messages)
Index: popup.c
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup.c,v
retrieving revision 1.14
retrieving revision 1.15
diff -C2 -d -r1.14 -r1.15
*** popup.c 6 Jun 2005 17:18:18 -0000 1.14
--- popup.c 7 Jun 2005 08:49:23 -0000 1.15
***************
*** 60,64 ****
int x_maxoptions;
! int initialized; /* 1 when we are allowed to draw, 0 otherwise */
} t_popup;
--- 60,65 ----
int x_maxoptions;
! int initialized; /* 1 when we are allowed to draw, 0 otherwise */
! int x_disabled; /* when disabled, graphical chosing is prohibited */
} t_popup;
***************
*** 157,170 ****
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
! if(x->initialized)sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
! if(x->initialized)sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -relief raised -background \"%s\" -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -tearoff 0\n",
x,canvas,x,x,x->x_colour->s_name,temp_name->s_name,x,x);
! for(i=0 ; i<x->x_num_options ; i++)
! {
! if(x->initialized)sys_vgui(".x%x.c.s%x.menu add command -label \"%s\" -command {.x%x.c.s%x configure -text \"%s\" ; popup_sel%x \"%d\"} \n",
! canvas, x, x->x_options[i]->s_name, canvas, x, x->x_options[i]->s_name, x, i);
! }
DEBUG(post("id: .x%x.c.s%x", canvas, x);)
--- 158,174 ----
/* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
! if(x->initialized)
! {
! sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
! sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -relief raised -background \"%s\" -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -tearoff 0\n",
x,canvas,x,x,x->x_colour->s_name,temp_name->s_name,x,x);
! for(i=0 ; i<x->x_num_options ; i++)
! {
! sys_vgui(".x%x.c.s%x.menu add command -label \"%s\" -command {.x%x.c.s%x configure -text \"%s\" ; popup_sel%x \"%d\"} \n",
! canvas, x, x->x_options[i]->s_name, canvas, x, x->x_options[i]->s_name, x, i);
! }
! }
DEBUG(post("id: .x%x.c.s%x", canvas, x);)
***************
*** 177,185 ****
DEBUG(post("drawme start");)
! /* by drawing, we "initialize" the popup */
! if(!x->initialized){
! x->initialized=1;
! }
!
DEBUG(post("drawme %d",firsttime);)
--- 181,186 ----
DEBUG(post("drawme start");)
! /* by drawing, we "initialize" the popup */
! x->initialized=1;
DEBUG(post("drawme %d",firsttime);)
***************
*** 199,202 ****
--- 200,205 ----
draw_inlets(x, glist, firsttime, 2,2);
// draw_handle(x, glist, firsttime);
+ sys_vgui(".x%x.c.s%x configure -state \"%s\"\n", canvas, x, x->x_disabled?"disabled":"active");
+
// Output a bang to first outlet when we're ready to receive float messages the first time!.
***************
*** 213,225 ****
DEBUG(post("erase start");)
! if(x->initialized)sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
! if(x->initialized)sys_vgui(".x%x.c delete %xS\n",glist_getcanvas(glist), x);
/* inlets and outlets */
! if(x->initialized)sys_vgui(".x%x.c delete %xi\n",glist_getcanvas(glist),x); /* Added tag for all inlets of one instance */
! if(x->initialized)sys_vgui(".x%x.c delete %xo\n",glist_getcanvas(glist),x); /* Added tag for all outlets of one instance */
! if(x->initialized)sys_vgui(".x%x.c delete %xhandle\n",glist_getcanvas(glist),x,0);
DEBUG(post("erase end");)
--- 216,230 ----
DEBUG(post("erase start");)
! if(x->initialized){
! sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
! sys_vgui(".x%x.c delete %xS\n",glist_getcanvas(glist), x);
/* inlets and outlets */
! sys_vgui(".x%x.c delete %xi\n",glist_getcanvas(glist),x); /* Added tag for all inlets of one instance */
! sys_vgui(".x%x.c delete %xo\n",glist_getcanvas(glist),x); /* Added tag for all outlets of one instance */
! sys_vgui(".x%x.c delete %xhandle\n",glist_getcanvas(glist),x,0);
! }
DEBUG(post("erase end");)
***************
*** 274,279 ****
t_popup *x = (t_popup *)z;
! if (state) {
! if(x->initialized)sys_vgui(".x%x.c create rectangle \
%d %d %d %d -tags %xSEL -outline blue\n",
glist_getcanvas(glist),
--- 279,285 ----
t_popup *x = (t_popup *)z;
! if(x->initialized){
! if (state) {
! sys_vgui(".x%x.c create rectangle \
%d %d %d %d -tags %xSEL -outline blue\n",
glist_getcanvas(glist),
***************
*** 281,288 ****
text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height-2,
x);
! }
! else {
! if(x->initialized)sys_vgui(".x%x.c delete %xSEL\n",
! glist_getcanvas(glist), x);
}
--- 287,295 ----
text_xpix(&x->x_obj, glist) + x->x_rect_width, text_ypix(&x->x_obj, glist) + x->x_rect_height-2,
x);
! }
! else {
! sys_vgui(".x%x.c delete %xSEL\n",
! glist_getcanvas(glist), x);
! }
}
***************
*** 384,388 ****
/* function to change the popup's menu */
! void popup_options(t_popup* x, t_symbol *s, int argc, t_atom *argv)
{
DEBUG(post("options start");)
--- 391,395 ----
/* function to change the popup's menu */
! static void popup_options(t_popup* x, t_symbol *s, int argc, t_atom *argv)
{
DEBUG(post("options start");)
***************
*** 447,451 ****
} else {
! pd_error(x, "popup: Valid menu selections are from %d to %d\npopup: You entered %d.", 0, x->x_num_options, i);
}
--- 454,458 ----
} else {
! pd_error(x, "popup: Valid menu selections are from %d to %d\npopup: You entered %d.", 0, x->x_num_options-1, i);
}
***************
*** 478,482 ****
/* Function to append symbols to popup list */
! void popup_append(t_popup* x, t_symbol *s, int argc, t_atom *argv)
{
DEBUG(post("append start");)
--- 485,489 ----
/* Function to append symbols to popup list */
! static void popup_append(t_popup* x, t_symbol *s, int argc, t_atom *argv)
{
DEBUG(post("append start");)
***************
*** 515,518 ****
--- 522,533 ----
}
+ static void popup_disable(t_popup*x, t_float f){
+ x->x_disabled=(f>0.f);
+ if(x->x_glist && glist_isvisible(x->x_glist)){
+ t_canvas *canvas=glist_getcanvas(x->x_glist);
+ sys_vgui(".x%x.c.s%x configure -state \"%s\"\n", canvas, x, x->x_disabled?"disabled":"active");
+ }
+ }
+
***************
*** 552,555 ****
--- 567,572 ----
x->initialized=0;
+ x->x_disabled=0;
+
switch(argc){
case 0: break; /* just use default values */
***************
*** 630,633 ****
--- 647,655 ----
0);
+ class_addmethod(popup_class, (t_method)popup_disable,
+ gensym("disable"),
+ A_FLOAT,
+ 0);
+
class_doaddfloat(popup_class, (t_method)popup_iselect);
More information about the Pd-cvs
mailing list