[PD-cvs] externals/bbogart/entry entry.c,1.6,1.7 makefile,1.2,1.3

Hans-Christoph Steiner eighthave at users.sourceforge.net
Wed Oct 24 02:36:03 CEST 2007


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

Modified Files:
	entry.c makefile 
Log Message:

- cleaned up unused variables
- added entry_free() function
- added structure to support second outlet outputing each keystroke:
  - second outlet
  - keyup message/entry_keyup method


Index: entry.c
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/entry/entry.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** entry.c	12 Dec 2005 18:32:40 -0000	1.6
--- entry.c	24 Oct 2007 00:36:01 -0000	1.7
***************
*** 21,24 ****
--- 21,29 ----
  #include <string.h>
  
+ /* TODO: make one .x%x.c.s%x replacement into x->x_widget_name */
+ /* TODO: make one .x%x.c replacement into x->x_canvas_name */
+ /* TODO: make "display only" option, to force box to never accept focus */
+ /* TODO: make focus option only accept regular and shifted chars, not Cmd, Alt, Ctrl */
+ /* TODO: make entry_save include whole classname, including namespace prefix */
  
  
***************
*** 36,57 ****
  #endif
  
  typedef struct _entry
  {
!      t_object x_obj;
! 
!      t_glist * x_glist;
!      int x_rect_width;
!      int x_rect_height;
!      t_symbol*  x_sym;
  	
!      int x_height;
!      int x_width;
! 	 
!      t_symbol* x_bgcolour;
!      t_symbol* x_fgcolour;
!      t_symbol* x_contents;
  
  } t_entry;
  
  /* widget helper functions */
  
--- 41,81 ----
  #endif
  
+ #define BACKGROUNDCOLOR "grey70"
+ 
  typedef struct _entry
  {
!     t_object x_obj;
!     
!     t_glist * x_glist;
!     int x_rect_width;
!     int x_rect_height;
!     t_symbol*  x_receive_name_symbol;
  	
! /* TODO: these all should be settable by messages */
!     int x_height;
!     int x_width;
! 
!     t_int x_mousefocus;
!     t_symbol* x_bgcolour;
!     t_symbol* x_fgcolour;
!     
! /* TODO: these all should be settable by messages
!     t_symbol *x_font_face;
!     t_float x_font_size;
!     t_symbol *x_font_weight;
  
+     t_float x_border;
+     t_float x_highlightthickness;
+     t_symbol *x_relief;
+ */
+     t_symbol* x_contents;
+ 
+     t_outlet* x_data_outlet;
+     t_outlet* x_status_outlet;
  } t_entry;
  
+ 
+ static t_class *entry_class;
+ 
  /* widget helper functions */
  
***************
*** 70,73 ****
--- 94,99 ----
  	  int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH) * i / nplus;
  	  if (firsttime)
+       {
+           /* left outlet, for data */
  	       sys_vgui(".x%x.c create rectangle %d %d %d %d -tags {%xo%d %xo}\n",
  			glist_getcanvas(glist),
***************
*** 75,83 ****
--- 101,119 ----
  			onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1,
  			x, i, x);
+           /* right outlet, for key status */
+ /*	       sys_vgui(".x%x.c create rectangle %d %d %d %d -tags {%xo%d %xo}\n",
+ 			glist_getcanvas(glist),
+ 			onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2,
+ 			onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1,
+ 			x, i, x);
+ */
+       }
  	  else
+       {
  	       sys_vgui(".x%x.c coords %xo%d %d %d %d %d\n",
  			glist_getcanvas(glist), x, i,
  			onset, text_ypix(&x->x_obj, glist) + x->x_rect_height - 2,
  			onset + IOWIDTH, text_ypix(&x->x_obj, glist) + x->x_rect_height-1);
+       }
       }
   /* inlets */
***************
*** 103,107 ****
  }
  
! 
  static void draw_handle(t_entry *x, t_glist *glist, int firsttime) {
    int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2);
--- 139,143 ----
  }
  
! /* currently unused
  static void draw_handle(t_entry *x, t_glist *glist, int firsttime) {
    int onset = text_xpix(&x->x_obj, glist) + (x->x_rect_width - IOWIDTH+2);
***************
*** 119,127 ****
  	     onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4);
  }
  
  static void create_widget(t_entry *x, t_glist *glist)
  {
-   char text[MAXPDSTRING];
-   int len,i;
    t_canvas *canvas=glist_getcanvas(glist);
    /* I guess this is for fine-tuning of the rect size based on width and height? */
--- 155,162 ----
  	     onset + IOWIDTH-2, text_ypix(&x->x_obj, glist) + x->x_rect_height-4);
  }
+ */
  
  static void create_widget(t_entry *x, t_glist *glist)
  {
    t_canvas *canvas=glist_getcanvas(glist);
    /* I guess this is for fine-tuning of the rect size based on width and height? */
***************
*** 136,142 ****
    sys_vgui("set %xw .x%x.c.s%x ; text $%xw -font {helvetica 10} -border 1 -highlightthickness 1 -relief sunken -bg \"%s\" -fg \"%s\" \n",
  		x,canvas,x,x,x->x_bgcolour->s_name,x->x_fgcolour->s_name);
!   sys_vgui("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", canvas, x, canvas, x);
!   sys_vgui("namespace eval entry%x {} \n", x);
!   
  }
  
--- 171,178 ----
    sys_vgui("set %xw .x%x.c.s%x ; text $%xw -font {helvetica 10} -border 1 -highlightthickness 1 -relief sunken -bg \"%s\" -fg \"%s\" \n",
  		x,canvas,x,x,x->x_bgcolour->s_name,x->x_fgcolour->s_name);
!   if(x->x_mousefocus)
!       sys_vgui("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", 
!                canvas, x, canvas, x); 
!   sys_vgui("namespace eval entry%p {} \n", x);
  }
  
***************
*** 167,172 ****
  static void entry_erase(t_entry* x,t_glist* glist)
  {
-      int n;
- 
       DEBUG(post("erase");)
       sys_vgui("destroy .x%x.c.s%x\n",glist_getcanvas(glist),x);
--- 203,206 ----
***************
*** 176,181 ****
       /* 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);
  }
--- 210,217 ----
       /* inlets and outlets */
       
! /* Added tag for all inlets of one instance */
!      sys_vgui(".x%x.c delete %xi\n",glist_getcanvas(glist),x); 
!      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);
  }
***************
*** 224,229 ****
       t_entry *x = (t_entry *)z;
       if (state) {
! 	  sys_vgui(".x%x.c create rectangle \
! %d %d %d %d -tags %xSEL -outline blue\n",
  		   glist_getcanvas(glist),
  		   text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
--- 260,264 ----
       t_entry *x = (t_entry *)z;
       if (state) {
! 	  sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xSEL -outline blue\n",
  		   glist_getcanvas(glist),
  		   text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist)-1,
***************
*** 239,246 ****
  static void entry_activate(t_gobj *z, t_glist *glist, int state)
  {
! /* What does this do, why commented out? 
      t_text *x = (t_text *)z;
      t_rtext *y = glist_findrtext(glist, x);
!     if (z->g_pd != gatom_class) rtext_activate(y, state);*/
  }
  
--- 274,282 ----
  static void entry_activate(t_gobj *z, t_glist *glist, int state)
  {
! /* this is currently unused
      t_text *x = (t_text *)z;
      t_rtext *y = glist_findrtext(glist, x);
!     if (z->g_pd != gatom_class) rtext_activate(y, state);
! */
  }
  
***************
*** 295,306 ****
    int i;
    t_symbol *tmp;
!   
    sys_vgui(".x%x.c.s%x delete 0.0 end \n", x->x_glist, x);
    for(i=0; i<argc ; i++)
    {
  	tmp = atom_getsymbol(argv+i);
! 	sys_vgui("lappend ::entry%x::list %s \n", x, tmp->s_name );
    }
!   sys_vgui(".x%x.c.s%x insert end $::entry%x::list ; unset ::entry%x::list \n", x->x_glist, x, x, x );
  }
  
--- 331,344 ----
    int i;
    t_symbol *tmp;
! 
!   tmp = s; /* this gets rid of the unused variable warning */
    sys_vgui(".x%x.c.s%x delete 0.0 end \n", x->x_glist, x);
    for(i=0; i<argc ; i++)
    {
  	tmp = atom_getsymbol(argv+i);
! 	sys_vgui("lappend ::entry%p::list %s \n", x, tmp->s_name );
    }
!   sys_vgui(".x%x.c.s%x insert end $::entry%p::list ; unset ::entry%p::list \n", 
!            x->x_glist, x, x, x );
  }
  
***************
*** 315,319 ****
  static void entry_output(t_entry* x, t_symbol *s, int argc, t_atom *argv)
  {
!   outlet_list(x->x_obj.ob_outlet, s, argc, argv );
  }
  
--- 353,357 ----
  static void entry_output(t_entry* x, t_symbol *s, int argc, t_atom *argv)
  {
!   outlet_list(x->x_data_outlet, s, argc, argv );
  }
  
***************
*** 327,337 ****
    sys_vgui("pd [concat entry%p output [.x%x.c.s%x get 0.0 end] \\;]\n", x, x->x_glist, x); */
  
!   sys_vgui("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", x->x_glist, x, x->x_glist, x);
  }
- 
  
  static void entry_save(t_gobj *z, t_binbuf *b)
  {
- 	int i;
      t_entry *x = (t_entry *)z;
  
--- 365,385 ----
    sys_vgui("pd [concat entry%p output [.x%x.c.s%x get 0.0 end] \\;]\n", x, x->x_glist, x); */
  
!   if(x->x_mousefocus)
!       sys_vgui("bind .x%x.c.s%x <Leave> {focus [winfo parent .x%x.c.s%x]} \n", 
!                x->x_glist, x, x->x_glist, x);
! }
!  
! static void entry_keyup(t_entry *x, t_symbol *s)
! {
!     outlet_symbol(x->x_status_outlet, s);
! }
!  
! static void entry_mousefocus(t_entry *x, t_float f)
! {
!     x->x_mousefocus = (t_int) f;
  }
  
  static void entry_save(t_gobj *z, t_binbuf *b)
  {
      t_entry *x = (t_entry *)z;
  
***************
*** 356,373 ****
  }
  
! static t_class *entry_class;
! 
  
  static void *entry_new(t_symbol *s, int argc, t_atom *argv)
  {
      t_entry *x = (t_entry *)pd_new(entry_class);
-     int i;
      char buf[256];
! 
      /*x->x_glist = (t_glist*)NULL;*/
      /*x->x_glist = canvas_getcurrent();*/
  
-     
      x->x_height = 1;
  	
  	if (argc < 4)
--- 404,422 ----
  }
  
! static void entry_free(t_entry *x)
! {
!     pd_unbind(&x->x_obj.ob_pd, x->x_receive_name_symbol);
! }
  
  static void *entry_new(t_symbol *s, int argc, t_atom *argv)
  {
      t_entry *x = (t_entry *)pd_new(entry_class);
      char buf[256];
!     
      /*x->x_glist = (t_glist*)NULL;*/
      /*x->x_glist = canvas_getcurrent();*/
  
      x->x_height = 1;
+     x->x_mousefocus = 1; 
  	
  	if (argc < 4)
***************
*** 394,410 ****
  
      /* Bind the recieve "entry%p" to the widget instance*/
!     sprintf(buf,"entry%p",x);
!     x->x_sym = gensym(buf);
!     pd_bind(&x->x_obj.ob_pd, x->x_sym);
  	
!     outlet_new(&x->x_obj, &s_float);
      return (x);
  }
  
  void entry_setup(void) {
!     entry_class = class_new(gensym("entry"), (t_newmethod)entry_new, 0,
! 				sizeof(t_entry),0,A_GIMME,0);
  				
  	class_addbang(entry_class, (t_method)entry_bang_output);
  	
  	class_addmethod(entry_class, (t_method)entry_output,
--- 443,470 ----
  
      /* Bind the recieve "entry%p" to the widget instance*/
!     snprintf(buf,MAXPDSTRING,"entry%p",x);
!     x->x_receive_name_symbol = gensym(buf);
!     pd_bind(&x->x_obj.ob_pd, x->x_receive_name_symbol);
  	
!     x->x_data_outlet = outlet_new(&x->x_obj, &s_float);
!     x->x_status_outlet = outlet_new(&x->x_obj, &s_symbol);
      return (x);
  }
  
  void entry_setup(void) {
!     entry_class = class_new(gensym("entry"), (t_newmethod)entry_new, 
!                             (t_method)entry_free, sizeof(t_entry),0,A_GIMME,0);
  				
  	class_addbang(entry_class, (t_method)entry_bang_output);
+ 
+     class_addmethod(entry_class, (t_method)entry_keyup,
+                     gensym("keyup"),
+                     A_DEFSYMBOL,
+                     0);
+ 
+     class_addmethod(entry_class, (t_method)entry_mousefocus,
+                     gensym("mousefocus"),
+                     A_DEFFLOAT,
+                     0);
  	
  	class_addmethod(entry_class, (t_method)entry_output,

Index: makefile
===================================================================
RCS file: /cvsroot/pure-data/externals/bbogart/entry/makefile,v
retrieving revision 1.2
retrieving revision 1.3
diff -C2 -d -r1.2 -r1.3
*** makefile	23 Aug 2005 12:23:32 -0000	1.2
--- makefile	24 Oct 2007 00:36:01 -0000	1.3
***************
*** 53,58 ****
  
  LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
!     -Wall -W -Wshadow -Wstrict-prototypes -Werror \
!     -Wno-unused -Wno-parentheses -Wno-switch
  
  LINUXINCLUDE =  -I../../src -I../../../pd/src
--- 53,58 ----
  
  LINUXCFLAGS = -DPD -O2 -funroll-loops -fomit-frame-pointer \
!     -Wall -W -Wshadow -Wstrict-prototypes
! 
  
  LINUXINCLUDE =  -I../../src -I../../../pd/src
***************
*** 70,79 ****
  .SUFFIXES: .pd_darwin
  
! DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes \
!     -Wno-unused -Wno-parentheses -Wno-switch
  
  .c.pd_darwin:
  	cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
! 	cc -bundle -undefined suppress -flat_namespace -o $*.pd_darwin $*.o 
  	rm -f $*.o
  
--- 70,78 ----
  .SUFFIXES: .pd_darwin
  
! DARWINCFLAGS = -DPD -O2 -Wall -W -Wshadow -Wstrict-prototypes
  
  .c.pd_darwin:
  	cc $(DARWINCFLAGS) $(LINUXINCLUDE) -o $*.o -c $*.c
! 	cc -bundle -bundle_loader ../../../pd/bin/pd -o $*.pd_darwin $*.o 
  	rm -f $*.o
  





More information about the Pd-cvs mailing list