[PD-cvs] externals/bbogart/popup popup.c,1.12,1.13

IOhannes m zmölnig zmoelnig at users.sourceforge.net
Mon Jun 6 18:05:35 CEST 2005


Update of /cvsroot/pure-data/externals/bbogart/popup
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28145

Modified Files:
	popup.c 
Log Message:
removed the constraint about not being able to loadbang the object with options


Index: popup.c
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/popup/popup.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -C2 -d -r1.12 -r1.13
*** popup.c	6 Jun 2005 15:13:43 -0000	1.12
--- popup.c	6 Jun 2005 16:05:31 -0000	1.13
***************
*** 59,62 ****
--- 59,64 ----
       t_symbol** x_options;
       int        x_maxoptions;
+ 
+   int initialized; /* 1 when we are allowed to draw, 0 otherwise */
  } t_popup;
  
***************
*** 64,68 ****
  
  /* Append " x " to the following line to show debugging messages */
! #define DEBUG(x) 
  
  
--- 66,70 ----
  
  /* Append " x " to the following line to show debugging messages */
! #define DEBUG(x)
  
  
***************
*** 155,166 ****
  
    /* Seems we have to delete the widget in case it already exists (Provided by Guenter)*/
!   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);
    }
--- 157,168 ----
  
    /* 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);
    }
***************
*** 174,177 ****
--- 176,186 ----
    t_canvas *canvas=glist_getcanvas(glist);
    DEBUG(post("drawme start");)
+ 
+     /* by drawing, we "initialize" the popup */
+     if(!x->initialized){
+       x->initialized=1;
+     }
+ 
+ 
    DEBUG(post("drawme %d",firsttime);)
       if (firsttime) {
***************
*** 204,216 ****
  
       DEBUG(post("erase start");)
!      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");)
--- 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");)
***************
*** 225,229 ****
      int *xp1, int *yp1, int *xp2, int *yp2)
  {
!     DEBUG(post("getrect start");)
  
      int width, height;
--- 234,238 ----
      int *xp1, int *yp1, int *xp2, int *yp2)
  {
!   DEBUG(post("getrect start");)
  
      int width, height;
***************
*** 249,253 ****
      if (glist_isvisible(glist))
      {
!       sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
  	       glist_getcanvas(glist), x,
  	       text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
--- 258,262 ----
      if (glist_isvisible(glist))
      {
!       if(x->initialized)sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
  	       glist_getcanvas(glist), x,
  	       text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
***************
*** 266,270 ****
       t_popup *x = (t_popup *)z;
       if (state) {
! 	  sys_vgui(".x%x.c create rectangle \
  %d %d %d %d -tags %xSEL -outline blue\n",
  		   glist_getcanvas(glist),
--- 275,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),
***************
*** 274,278 ****
       }
       else {
! 	  sys_vgui(".x%x.c delete %xSEL\n",
  		   glist_getcanvas(glist), x);
       }
--- 283,287 ----
       }
       else {
! 	  if(x->initialized)sys_vgui(".x%x.c delete %xSEL\n",
  		   glist_getcanvas(glist), x);
       }
***************
*** 384,388 ****
  	
  	/* delete old menu items */
! 	sys_vgui(".x%x.c.s%x.menu delete 0 end \n", x->x_glist, x);
  
          if(argc>x->x_maxoptions){
--- 393,397 ----
  	
  	/* delete old menu items */
! 	if(x->initialized)sys_vgui(".x%x.c.s%x.menu delete 0 end \n", x->x_glist, x);
  
          if(argc>x->x_maxoptions){
***************
*** 396,400 ****
  	{
  		x->x_options[i] = atom_getsymbol(argv+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", 
  			x->x_glist, x, x->x_options[i]->s_name, x->x_glist, x, x->x_options[i]->s_name, x, i);
  	}
--- 405,409 ----
  	{
  		x->x_options[i] = atom_getsymbol(argv+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", 
  			x->x_glist, x, x->x_options[i]->s_name, x->x_glist, x, x->x_options[i]->s_name, x, i);
  	}
***************
*** 409,413 ****
  
  	x->x_colour = col;
! 	sys_vgui(".x%x.c.s%x configure -background \"%s\"\n", x->x_glist, x, col->s_name);
  }
  
--- 418,422 ----
  
  	x->x_colour = col;
! 	if(x->initialized)sys_vgui(".x%x.c.s%x configure -background \"%s\"\n", x->x_glist, x, col->s_name);
  }
  
***************
*** 418,422 ****
  
  	x->x_name = name;
! 	sys_vgui(".x%x.c.s%x configure -text \"%s\"\n", x->x_glist, x, name->s_name);
  }
  
--- 427,431 ----
  
  	x->x_name = name;
! 	if(x->initialized)sys_vgui(".x%x.c.s%x configure -text \"%s\"\n", x->x_glist, x, name->s_name);
  }
  
***************
*** 429,437 ****
  	if( i<x->x_num_options && i>=0)
  	{
! 		sys_vgui(".x%x.c.s%x configure -text \"%s\" ; popup_sel%x \"%d\" \n",
  			glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name,x, i);
  
  	} else {
! 		post("popup: Valid menu selections are from %d to %d\npopup: You entered %d.", 0, x->x_num_options, i);
  	}
  
--- 438,447 ----
  	if( i<x->x_num_options && i>=0)
  	{
! 		if(x->initialized)sys_vgui(".x%x.c.s%x configure -text \"%s\" ; popup_sel%x \"%d\" \n",
  			glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name,x, i);
+                 else popup_output(x, i);
  
  	} else {
!           pd_error(x, "popup: Valid menu selections are from %d to %d\npopup: You entered %d.", 0, x->x_num_options, i);
  	}
  
***************
*** 449,454 ****
  	  if(x->x_options[i]->s_name == s->s_name)
  	  {
! 	    sys_vgui(".x%x.c.s%x configure -text \"%s\" ; popup_sel%x \"%d\" \n",
                          glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name,x, i);
  	    match = 1;
  	    break;
--- 459,465 ----
  	  if(x->x_options[i]->s_name == s->s_name)
  	  {
! 	    if(x->initialized)sys_vgui(".x%x.c.s%x configure -text \"%s\" ; popup_sel%x \"%d\" \n",
                          glist_getcanvas(x->x_glist), x, x->x_options[i]->s_name,x, i);
+             else popup_output(x, i);
  	    match = 1;
  	    break;
***************
*** 489,493 ****
          {
                  x->x_options[i] = atom_getsymbol(argv+i-x->x_num_options);
!                 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",
                          x->x_glist, x, x->x_options[i]->s_name, x->x_glist, x, x->x_options[i]->s_name, x, i);
          }
--- 500,504 ----
          {
                  x->x_options[i] = atom_getsymbol(argv+i-x->x_num_options);
!                 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",
                          x->x_glist, x, x->x_options[i]->s_name, x->x_glist, x, x->x_options[i]->s_name, x, i);
          }
***************
*** 533,536 ****
--- 544,549 ----
      x->x_options[0] = gensym("option");
  
+     x->initialized=0;
+ 
      switch(argc){
      case 0: break; /* just use default values */





More information about the Pd-cvs mailing list