[PD-cvs] externals/tkwidgets/shared tkwidgets.c, 1.4, 1.5 tkwidgets.h, 1.4, 1.5

Hans-Christoph Steiner eighthave at users.sourceforge.net
Thu Nov 22 01:38:01 CET 2007


Update of /cvsroot/pure-data/externals/tkwidgets/shared
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13704/shared

Modified Files:
	tkwidgets.c tkwidgets.h 
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: tkwidgets.c
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/shared/tkwidgets.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tkwidgets.c	21 Nov 2007 22:19:12 -0000	1.4
--- tkwidgets.c	22 Nov 2007 00:37:59 -0000	1.5
***************
*** 55,65 ****
  }
  
- void tkwidgets_set_ids(t_object *x, t_tkwidgets *tkw, t_canvas *canvas)
- {
- 
-     tkw->canvas = canvas;
- }
- 
- 
  t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name)
  {
--- 55,58 ----
***************
*** 97,132 ****
  }
  
! t_symbol* tkwidgets_gen_window_id(t_object* x, t_symbol* canvas_id)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"%s.window%lx", canvas_id->s_name, (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"%s.handle%lx", canvas_id->s_name, (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"%s.scrollbar%lx", frame_id->s_name, (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_all_tag(t_object *x)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"all%lx", (long unsigned int)x);
      return gensym(buf);
  }
  
! void tkwidgets_draw_inlets(t_object *x, t_glist *glist, 
!                  int total_inlets, int total_outlets)
  {
!     // TODO perhaps I should try to use glist_drawiofor() from g_text.c
  }
  
--- 90,126 ----
  }
  
! t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"%s.handle%lx", canvas_id->s_name, (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"%s.scrollbar%lx", frame_id->s_name, (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* canvas_id)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"%s.window%lx", canvas_id->s_name, (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_iolets_tag(t_object* x)
  {
      char buf[MAXPDSTRING];
!     sprintf(buf,"iolets%lx", (long unsigned int)x);
      return gensym(buf);
  }
  
! t_symbol* tkwidgets_gen_all_tag(t_object *x)
  {
!     char buf[MAXPDSTRING];
!     sprintf(buf,"all%lx", (long unsigned int)x);
!     return gensym(buf);
  }
  
***************
*** 141,152 ****
  }
  
  
! /*
! void query_options()
  {
!     
  }
  
  
  
- */
--- 135,181 ----
  }
  
+ /* -------------------- inlets/outlets -------------------------------------- */
+  
+ static int calculate_onset(int x_location, int width,
+                            int current_iolet, int total_iolets)
+ {
+     post("calculate_onset");
+     return(x_location + (width - IOWIDTH)                               \
+            * current_iolet / (total_iolets == 1 ? 1 : total_iolets - 1));
+ }
  
! void tkwidgets_draw_inlets(t_object *x, t_glist *glist, t_symbol *canvas_id,
!                            t_symbol *iolets_tag, t_symbol *all_tag,
!                            int width, int height,
!                            int total_inlets, int total_outlets)
  {
!     int i, onset;
!     int x_location = text_xpix(x, glist);
!     int y_location = text_ypix(x, glist);
! 
!     for (i = 0; i < total_inlets; i++)  /* inlets */
!     {
!         onset = calculate_onset(x_location, width, i, total_inlets);
!         sys_vgui("%s create rectangle %d %d %d %d -tags {%s %s}\n",
!                  canvas_id->s_name, onset, y_location - 2,
!                  onset + IOWIDTH, y_location,
!                  iolets_tag->s_name, all_tag->s_name);
!         sys_vgui("%s raise %s\n", canvas_id->s_name, iolets_tag->s_name);
!     }
!     for (i = 0; i < total_outlets; i++) /* outlets */
!     {
!         onset = calculate_onset(x_location, width, i, total_outlets);
!         sys_vgui("%s create rectangle %d %d %d %d -tags {%s %s}\n",
!                  canvas_id->s_name, onset, y_location + height,
!                  onset + IOWIDTH, y_location + height + 2,
!                  iolets_tag->s_name, all_tag->s_name);
!         sys_vgui("%s raise %s\n", canvas_id->s_name, iolets_tag->s_name);
!     }
  }
  
+ void tkwidgets_erase_inlets(t_symbol* canvas_id, t_symbol* iolets_tag)
+ {
+     sys_vgui("%s delete %s\n", canvas_id->s_name, iolets_tag); 
+ }
  
  

Index: tkwidgets.h
===================================================================
RCS file: /cvsroot/pure-data/externals/tkwidgets/shared/tkwidgets.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** tkwidgets.h	21 Nov 2007 22:19:12 -0000	1.4
--- tkwidgets.h	22 Nov 2007 00:37:59 -0000	1.5
***************
*** 49,53 ****
      t_symbol* canvas_id;     /* the canvas that is showing this widget */
      t_symbol* frame_id;      /* the frame around the widget and supporters */
!     t_symbol* window_id;     /* the window that contains the widget */
      t_symbol* widget_id;     /* the core widget */
      t_symbol* handle_id;     /* the resizing handle */
--- 49,53 ----
      t_symbol* canvas_id;     /* the canvas that is showing this widget */
      t_symbol* frame_id;      /* the frame around the widget and supporters */
!     t_symbol* window_tag;     /* the window that contains the widget */
      t_symbol* widget_id;     /* the core widget */
      t_symbol* handle_id;     /* the resizing handle */
***************
*** 74,85 ****
  t_symbol* tkwidgets_gen_frame_id(t_object* x, t_symbol* canvas_id);
  t_symbol* tkwidgets_gen_widget_id(t_object* x, t_symbol* parent_id);
! t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* parent_id);
! t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* parent_id);
  t_symbol* tkwidgets_gen_all_tag(t_object *x);
  
  
  // TODO perhaps I should try to use glist_drawiofor() from g_text.c
! void tkwidgets_draw_inlets(t_object *x, t_glist *glist, 
!                  int total_inlets, int total_outlets);
  void tkwidgets_draw_handle(); // TODO draw resize handle when selected in editmode
  void tkwidgets_draw_resize_window(); // TODO draw the resize window while resizing
--- 74,91 ----
  t_symbol* tkwidgets_gen_frame_id(t_object* x, t_symbol* canvas_id);
  t_symbol* tkwidgets_gen_widget_id(t_object* x, t_symbol* parent_id);
! t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id);
! t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id);
! t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* canvas_id);
! t_symbol* tkwidgets_gen_iolets_tag(t_object* x);
  t_symbol* tkwidgets_gen_all_tag(t_object *x);
  
  
  // TODO perhaps I should try to use glist_drawiofor() from g_text.c
! void tkwidgets_draw_inlets(t_object *x, t_glist *glist, t_symbol *canvas_id,
!                            t_symbol *iolets_tag, t_symbol *all_tag,
!                            int width, int height,
!                            int total_inlets, int total_outlets);
! void tkwidgets_erase_inlets(t_symbol* canvas_id, t_symbol* iolets_tag);
! 
  void tkwidgets_draw_handle(); // TODO draw resize handle when selected in editmode
  void tkwidgets_draw_resize_window(); // TODO draw the resize window while resizing





More information about the Pd-cvs mailing list