1 /* Copyright (c) 1997-1999 Miller Puckette.
2 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
3 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
5 /* this file defines the structure for "glists" and related structures and
6 functions. "Glists" and "canvases" and "graphs" used to be different
7 structures until being unified in version 0.35.
9 A glist occupies its own window if the "gl_havewindow" flag is set. Its
10 appearance on its "parent" or "owner" (if it has one) is as a graph if
11 "gl_isgraph" is set, and otherwise as a text box.
13 A glist is "root" if it has no owner, i.e., a document window. In this
14 case "gl_havewindow" is always set.
16 We maintain a list of root windows, so that we can traverse the whole
17 collection of everything in a Pd process.
19 If a glist has a window it may still not be "mapped." Miniaturized
20 windows aren't mapped, for example, but a window is also not mapped
21 immediately upon creation. In either case gl_havewindow is true but
24 Closing a non-root window makes it invisible; closing a root destroys it.
26 A glist that's just a text object on its parent is always "toplevel." An
27 embedded glist can switch back and forth to appear as a toplevel by double-
28 clicking on it. Single-clicking a text box makes the toplevel become visible
29 and raises the window it's in.
31 If a glist shows up as a graph on its parent, the graph is blanked while the
32 glist has its own window, even if miniaturized.
36 /* NOTE: this file describes Pd implementation details which may change
37 in future releases. The public (stable) API is in ../src/m_pd.h. */
39 #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
43 /* --------------------- geometry ---------------------------- */
44 #define IOWIDTH 7 /* width of an inlet/outlet in pixels */
45 #define IOMIDDLE ((IOWIDTH-1)/2)
46 #define GLIST_DEFGRAPHWIDTH 200
47 #define GLIST_DEFGRAPHHEIGHT 140
48 /* ----------------------- data ------------------------------- */
50 typedef struct _updateheader
52 struct _updateheader
*upd_next
;
53 unsigned int upd_array
:1; /* true if array, false if glist */
54 unsigned int upd_queued
:1; /* true if we're queued */
57 /* types to support glists grabbing mouse motion or keys from parent */
58 typedef void (*t_glistmotionfn
)(void *z
, t_floatarg dx
, t_floatarg dy
);
59 typedef void (*t_glistkeyfn
)(void *z
, t_floatarg key
);
62 #define t_rtext struct _rtext
64 EXTERN_STRUCT _gtemplate
;
65 #define t_gtemplate struct _gtemplate
67 EXTERN_STRUCT _guiconnect
;
68 #define t_guiconnect struct _guiconnect
70 EXTERN_STRUCT _tscalar
;
71 #define t_tscalar struct _tscalar
73 EXTERN_STRUCT _canvasenvironment
;
74 #define t_canvasenvironment struct _canvasenvironment
76 typedef struct _selection
79 struct _selection
*sel_next
;
82 /* this structure is instantiated whenever a glist becomes visible. */
83 typedef struct _editor
85 t_updateheader e_upd
; /* update header structure */
86 t_selection
*e_updlist
; /* list of objects to update */
87 t_rtext
*e_rtext
; /* text responder linked list */
88 t_selection
*e_selection
; /* head of the selection list */
89 t_rtext
*e_textedfor
; /* the rtext if any that we are editing */
90 t_gobj
*e_grab
; /* object being "dragged" */
91 t_glistmotionfn e_motionfn
; /* ... motion callback */
92 t_glistkeyfn e_keyfn
; /* ... keypress callback */
93 t_binbuf
*e_connectbuf
; /* connections to deleted objects */
94 t_binbuf
*e_deleted
; /* last stuff we deleted */
95 t_guiconnect
*e_guiconnect
; /* GUI connection for filtering messages */
96 struct _glist
*e_glist
; /* glist which owns this */
97 int e_xwas
; /* xpos on last mousedown or motion event */
98 int e_ywas
; /* ypos, similarly */
99 int e_selectline_index1
; /* indices for the selected line if any */
100 int e_selectline_outno
; /* (only valid if e_selectedline is set) */
101 int e_selectline_index2
;
102 int e_selectline_inno
;
103 t_outconnect
*e_selectline_tag
;
104 unsigned int e_onmotion
: 3; /* action to take on motion */
105 unsigned int e_lastmoved
: 1; /* one if mouse has moved since click */
106 unsigned int e_textdirty
: 1; /* one if e_textedfor has changed */
107 unsigned int e_selectedline
: 1; /* one if a line is selected */
110 #define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */
111 #define MA_MOVE 1 /* drag the selection around */
112 #define MA_CONNECT 2 /* make a connection */
113 #define MA_REGION 3 /* selection region */
114 #define MA_PASSOUT 4 /* send on to e_grab */
115 #define MA_DRAGTEXT 5 /* drag in text editor to alter selection */
117 /* editor structure for "garrays". We don't bother to delete and regenerate
118 this structure when the "garray" becomes invisible or visible, although we
119 could do so if the structure gets big (like the "editor" above.) */
121 typedef struct _arrayvis
123 t_updateheader av_upd
; /* update header structure */
124 t_garray
*av_garray
; /* owning structure */
127 /* the t_tick structure describes where to draw x and y "ticks" for a glist */
129 typedef struct _tick
/* where to put ticks on x or y axes */
131 float k_point
; /* one point to draw a big tick at */
132 float k_inc
; /* x or y increment per little tick */
133 int k_lperb
; /* little ticks per big; 0 if no ticks to draw */
136 /* the t_glist structure, which describes a list of elements that live on an
143 t_object gl_obj
; /* header in case we're a glist */
144 t_gobj
*gl_list
; /* the actual data */
145 struct _gstub
*gl_stub
; /* safe pointer handler */
146 int gl_valid
; /* incremented when pointers might be stale */
147 struct _glist
*gl_owner
; /* parent glist, supercanvas, or 0 if none */
148 int gl_pixwidth
; /* width in pixels (on parent, if a graph) */
150 float gl_x1
; /* bounding rectangle in our own coordinates */
154 int gl_screenx1
; /* screen coordinates when toplevel */
158 t_tick gl_xtick
; /* ticks marking X values */
159 int gl_nxlabels
; /* number of X coordinate labels */
160 t_symbol
**gl_xlabel
; /* ... an array to hold them */
161 float gl_xlabely
; /* ... and their Y coordinates */
162 t_tick gl_ytick
; /* same as above for Y ticks and labels */
164 t_symbol
**gl_ylabel
;
166 t_editor
*gl_editor
; /* editor structure when visible */
167 t_symbol
*gl_name
; /* symbol bound here */
168 int gl_font
; /* nominal font size in points, e.g., 10 */
169 struct _glist
*gl_next
; /* link in list of toplevels */
170 t_canvasenvironment
*gl_env
; /* root canvases and abstractions only */
171 unsigned int gl_havewindow
:1; /* true if we own a window */
172 unsigned int gl_mapped
:1; /* true if, moreover, it's "mapped" */
173 unsigned int gl_dirty
:1; /* (root canvas only:) patch has changed */
174 unsigned int gl_loading
:1; /* am now loading from file */
175 unsigned int gl_willvis
:1; /* make me visible after loading */
176 unsigned int gl_edit
:1; /* edit mode */
177 unsigned int gl_isdeleting
:1; /* we're inside glist_delete -- hack! */
178 unsigned int gl_stretch
:1; /* stretch contents on resize */
179 unsigned int gl_isgraph
:1; /* show as graph on parent */
182 #define gl_gobj gl_obj.te_g
183 #define gl_pd gl_gobj.g_pd
185 /* a data structure to describe a field in a pure datum */
192 typedef struct _dataslot
196 t_symbol
*ds_arraytemplate
; /* filled in for arrays only */
200 /* T.Grill - changed t_pd member to t_pdobj to avoid name clashed */
201 typedef struct _template
203 t_pd t_pdobj
; /* header */
204 struct _gtemplate
*t_list
; /* list of "struct"/gtemplate objects */
205 t_symbol
*t_sym
; /* name */
206 int t_n
; /* number of dataslots (fields) */
207 t_dataslot
*t_vec
; /* array of dataslots */
212 int a_n
; /* number of elements */
213 int a_elemsize
; /* size in bytes; LATER get this from template */
214 char *a_vec
; /* array of elements */
215 t_symbol
*a_templatesym
; /* template for elements */
216 int a_valid
; /* protection against stale pointers into array */
217 t_gpointer a_gp
; /* pointer to scalar or array element we're in */
221 /* structure for traversing all the connections in a glist */
222 typedef struct _linetraverser
233 int tr_x11
, tr_y11
, tr_x12
, tr_y12
;
234 int tr_x21
, tr_y21
, tr_x22
, tr_y22
;
235 int tr_lx1
, tr_ly1
, tr_lx2
, tr_ly2
;
236 t_outconnect
*tr_nextoc
;
240 /* function types used to define graphical behavior for gobjs, a bit like X
241 widgets. We don't use Pd methods because Pd's typechecking can't specify the
242 types of pointer arguments. Also it's more convenient this way, since
243 every "patchable" object can just get the "text" behaviors. */
245 /* Call this to get a gobj's bounding rectangle in pixels */
246 typedef void (*t_getrectfn
)(t_gobj
*x
, struct _glist
*glist
,
247 int *x1
, int *y1
, int *x2
, int *y2
);
248 /* and this to displace a gobj: */
249 typedef void (*t_displacefn
)(t_gobj
*x
, struct _glist
*glist
, int dx
, int dy
);
250 /* change color to show selection: */
251 typedef void (*t_selectfn
)(t_gobj
*x
, struct _glist
*glist
, int state
);
252 /* change appearance to show activation/deactivation: */
253 typedef void (*t_activatefn
)(t_gobj
*x
, struct _glist
*glist
, int state
);
254 /* warn a gobj it's about to be deleted */
255 typedef void (*t_deletefn
)(t_gobj
*x
, struct _glist
*glist
);
256 /* making visible or invisible */
257 typedef void (*t_visfn
)(t_gobj
*x
, struct _glist
*glist
, int flag
);
258 /* field a mouse click (when not in "edit" mode) */
259 typedef int (*t_clickfn
)(t_gobj
*x
, struct _glist
*glist
,
260 int xpix
, int ypix
, int shift
, int alt
, int dbl
, int doit
);
261 /* ... and later, resizing; getting/setting font or color... */
263 struct _widgetbehavior
265 t_getrectfn w_getrectfn
;
266 t_displacefn w_displacefn
;
267 t_selectfn w_selectfn
;
268 t_activatefn w_activatefn
;
269 t_deletefn w_deletefn
;
274 /* -------- behaviors for scalars defined by objects in template --------- */
275 /* these are set by "drawing commands" in g_template.c which add appearance to
276 scalars, which live in some other window. If the scalar is just included
277 in a canvas the "parent" is a misnomer. There is also a text scalar object
278 which really does draw the scalar on the parent window; see g_scalar.c. */
280 /* note how the click function wants the whole scalar, not the "data", so
281 doesn't work on array elements... LATER reconsider this */
283 /* bounding rectangle: */
284 typedef void (*t_parentgetrectfn
)(t_gobj
*x
, struct _glist
*glist
,
285 t_word
*data
, t_template
*tmpl
, float basex
, float basey
,
286 int *x1
, int *y1
, int *x2
, int *y2
);
288 typedef void (*t_parentdisplacefn
)(t_gobj
*x
, struct _glist
*glist
,
289 t_word
*data
, t_template
*tmpl
, float basex
, float basey
,
291 /* change color to show selection */
292 typedef void (*t_parentselectfn
)(t_gobj
*x
, struct _glist
*glist
,
293 t_word
*data
, t_template
*tmpl
, float basex
, float basey
,
295 /* change appearance to show activation/deactivation: */
296 typedef void (*t_parentactivatefn
)(t_gobj
*x
, struct _glist
*glist
,
297 t_word
*data
, t_template
*tmpl
, float basex
, float basey
,
299 /* making visible or invisible */
300 typedef void (*t_parentvisfn
)(t_gobj
*x
, struct _glist
*glist
,
301 t_word
*data
, t_template
*tmpl
, float basex
, float basey
,
303 /* field a mouse click */
304 typedef int (*t_parentclickfn
)(t_gobj
*x
, struct _glist
*glist
,
305 t_scalar
*sc
, t_template
*tmpl
, float basex
, float basey
,
306 int xpix
, int ypix
, int shift
, int alt
, int dbl
, int doit
);
308 struct _parentwidgetbehavior
310 t_parentgetrectfn w_parentgetrectfn
;
311 t_parentdisplacefn w_parentdisplacefn
;
312 t_parentselectfn w_parentselectfn
;
313 t_parentactivatefn w_parentactivatefn
;
314 t_parentvisfn w_parentvisfn
;
315 t_parentclickfn w_parentclickfn
;
318 /* cursor definitions; used as return value for t_parentclickfn */
319 #define CURSOR_RUNMODE_NOTHING 0
320 #define CURSOR_RUNMODE_CLICKME 1
321 #define CURSOR_RUNMODE_THICKEN 2
322 #define CURSOR_RUNMODE_ADDPOINT 3
323 #define CURSOR_EDITMODE_NOTHING 4
324 #define CURSOR_EDITMODE_CONNECT 5
325 #define CURSOR_EDITMODE_DISCONNECT 6
326 EXTERN
void canvas_setcursor(t_glist
*x
, unsigned int cursornum
);
328 extern t_canvas
*canvas_editing
; /* last canvas to start text edting */
329 extern t_canvas
*canvas_whichfind
; /* last canvas we did a find in */
330 extern t_canvas
*canvas_list
; /* list of all root canvases */
331 extern t_class
*vinlet_class
, *voutlet_class
;
332 extern int glist_valid
; /* incremented when pointers might be stale */
334 /* ------------------- functions on any gobj ----------------------------- */
335 EXTERN
void gobj_getrect(t_gobj
*x
, t_glist
*owner
, int *x1
, int *y1
,
337 EXTERN
void gobj_displace(t_gobj
*x
, t_glist
*owner
, int dx
, int dy
);
338 EXTERN
void gobj_select(t_gobj
*x
, t_glist
*owner
, int state
);
339 EXTERN
void gobj_activate(t_gobj
*x
, t_glist
*owner
, int state
);
340 EXTERN
void gobj_delete(t_gobj
*x
, t_glist
*owner
);
341 EXTERN
void gobj_vis(t_gobj
*x
, t_glist
*glist
, int flag
);
342 EXTERN
int gobj_click(t_gobj
*x
, struct _glist
*glist
,
343 int xpix
, int ypix
, int shift
, int alt
, int dbl
, int doit
);
344 EXTERN
void gobj_save(t_gobj
*x
, t_binbuf
*b
);
345 EXTERN
void gobj_properties(t_gobj
*x
, struct _glist
*glist
);
346 EXTERN
void gobj_save(t_gobj
*x
, t_binbuf
*b
);
348 /* -------------------- functions on glists --------------------- */
349 EXTERN t_glist
*glist_new( void);
350 EXTERN
void glist_init(t_glist
*x
);
351 EXTERN
void glist_add(t_glist
*x
, t_gobj
*g
);
352 EXTERN
void glist_cleanup(t_glist
*x
);
353 EXTERN
void glist_free(t_glist
*x
);
355 EXTERN
void glist_clear(t_glist
*x
);
356 EXTERN t_canvas
*glist_getcanvas(t_glist
*x
);
357 EXTERN
int glist_isselected(t_glist
*x
, t_gobj
*y
);
358 EXTERN
void glist_select(t_glist
*x
, t_gobj
*y
);
359 EXTERN
void glist_deselect(t_glist
*x
, t_gobj
*y
);
360 EXTERN
void glist_noselect(t_glist
*x
);
361 EXTERN
void glist_selectall(t_glist
*x
);
362 EXTERN
void glist_delete(t_glist
*x
, t_gobj
*y
);
363 EXTERN
void glist_retext(t_glist
*x
, t_text
*y
);
364 EXTERN
void glist_grab(t_glist
*x
, t_gobj
*y
, t_glistmotionfn motionfn
,
365 t_glistkeyfn keyfn
, int xpos
, int ypos
);
366 EXTERN
int glist_isvisible(t_glist
*x
);
367 EXTERN
int glist_istoplevel(t_glist
*x
);
368 EXTERN t_glist
*glist_findgraph(t_glist
*x
);
369 EXTERN
int glist_getfont(t_glist
*x
);
370 EXTERN
void glist_sort(t_glist
*canvas
);
371 EXTERN
void glist_read(t_glist
*x
, t_symbol
*filename
, t_symbol
*format
);
372 EXTERN
void glist_mergefile(t_glist
*x
, t_symbol
*filename
, t_symbol
*format
);
374 EXTERN
float glist_pixelstox(t_glist
*x
, float xpix
);
375 EXTERN
float glist_pixelstoy(t_glist
*x
, float ypix
);
376 EXTERN
float glist_xtopixels(t_glist
*x
, float xval
);
377 EXTERN
float glist_ytopixels(t_glist
*x
, float yval
);
378 EXTERN
float glist_dpixtodx(t_glist
*x
, float dxpix
);
379 EXTERN
float glist_dpixtody(t_glist
*x
, float dypix
);
381 EXTERN
void glist_redrawitem(t_glist
*owner
, t_gobj
*gobj
);
382 EXTERN
void glist_getnextxy(t_glist
*gl
, int *xval
, int *yval
);
383 EXTERN
void glist_glist(t_glist
*g
, t_symbol
*s
, int argc
, t_atom
*argv
);
384 EXTERN t_glist
*glist_addglist(t_glist
*g
, t_symbol
*sym
,
385 float x1
, float y1
, float x2
, float y2
,
386 float px1
, float py1
, float px2
, float py2
);
387 EXTERN
void glist_arraydialog(t_glist
*parent
, t_symbol
*name
,
388 t_floatarg size
, t_floatarg saveit
, t_floatarg newgraph
);
389 EXTERN t_binbuf
*glist_writetobinbuf(t_glist
*x
, int wholething
);
390 EXTERN
int glist_isgraph(t_glist
*x
);
391 EXTERN
void glist_redraw(t_glist
*x
);
392 EXTERN
void glist_drawiofor(t_glist
*glist
, t_object
*ob
, int firsttime
,
393 char *tag
, int x1
, int y1
, int x2
, int y2
);
394 EXTERN
void glist_eraseiofor(t_glist
*glist
, t_object
*ob
, char *tag
);
395 EXTERN
void canvas_create_editor(t_glist
*x
, int createit
);
396 void canvas_deletelinesforio(t_canvas
*x
, t_text
*text
,
397 t_inlet
*inp
, t_outlet
*outp
);
400 /* -------------------- functions on texts ------------------------- */
401 EXTERN
void text_setto(t_text
*x
, t_glist
*glist
, char *buf
, int bufsize
);
402 EXTERN
void text_drawborder(t_text
*x
, t_glist
*glist
, char *tag
,
403 int width
, int height
, int firsttime
);
404 EXTERN
void text_eraseborder(t_text
*x
, t_glist
*glist
, char *tag
);
405 EXTERN
int text_xcoord(t_text
*x
, t_glist
*glist
);
406 EXTERN
int text_ycoord(t_text
*x
, t_glist
*glist
);
407 EXTERN
int text_xpix(t_text
*x
, t_glist
*glist
);
408 EXTERN
int text_ypix(t_text
*x
, t_glist
*glist
);
409 EXTERN
int text_shouldvis(t_text
*x
, t_glist
*glist
);
411 /* -------------------- functions on rtexts ------------------------- */
415 #define RTEXT_SHIFT 4
417 EXTERN t_rtext
*rtext_new(t_glist
*glist
, t_text
*who
);
418 EXTERN t_rtext
*glist_findrtext(t_glist
*gl
, t_text
*who
);
419 EXTERN
void rtext_draw(t_rtext
*x
);
420 EXTERN
void rtext_erase(t_rtext
*x
);
421 EXTERN t_rtext
*rtext_remove(t_rtext
*first
, t_rtext
*x
);
422 EXTERN
int rtext_height(t_rtext
*x
);
423 EXTERN
void rtext_displace(t_rtext
*x
, int dx
, int dy
);
424 EXTERN
void rtext_select(t_rtext
*x
, int state
);
425 EXTERN
void rtext_activate(t_rtext
*x
, int state
);
426 EXTERN
void rtext_free(t_rtext
*x
);
427 EXTERN
void rtext_key(t_rtext
*x
, int n
, t_symbol
*s
);
428 EXTERN
void rtext_mouse(t_rtext
*x
, int xval
, int yval
, int flag
);
429 EXTERN
void rtext_retext(t_rtext
*x
);
430 EXTERN
int rtext_width(t_rtext
*x
);
431 EXTERN
int rtext_height(t_rtext
*x
);
432 EXTERN
char *rtext_gettag(t_rtext
*x
);
433 EXTERN
void rtext_gettext(t_rtext
*x
, char **buf
, int *bufsize
);
435 /* -------------------- functions on canvases ------------------------ */
436 EXTERN t_class
*canvas_class
;
438 EXTERN t_canvas
*canvas_new(void *dummy
, t_symbol
*sel
, int argc
, t_atom
*argv
);
439 EXTERN t_symbol
*canvas_makebindsym(t_symbol
*s
);
440 EXTERN
void canvas_vistext(t_canvas
*x
, t_text
*y
);
441 EXTERN
void canvas_fixlinesfor(t_canvas
*x
, t_text
*text
);
442 EXTERN
void canvas_deletelinesfor(t_canvas
*x
, t_text
*text
);
443 EXTERN
void canvas_stowconnections(t_canvas
*x
);
444 EXTERN
void canvas_restoreconnections(t_canvas
*x
);
445 EXTERN
void canvas_redraw(t_canvas
*x
);
447 EXTERN t_inlet
*canvas_addinlet(t_canvas
*x
, t_pd
*who
, t_symbol
*sym
);
448 EXTERN
void canvas_rminlet(t_canvas
*x
, t_inlet
*ip
);
449 EXTERN t_outlet
*canvas_addoutlet(t_canvas
*x
, t_pd
*who
, t_symbol
*sym
);
450 EXTERN
void canvas_rmoutlet(t_canvas
*x
, t_outlet
*op
);
451 EXTERN
void canvas_redrawallfortemplate(t_canvas
*tmpl
);
452 EXTERN
void canvas_zapallfortemplate(t_canvas
*tmpl
);
453 EXTERN
void canvas_setusedastemplate(t_canvas
*x
);
454 EXTERN t_canvas
*canvas_getcurrent(void);
455 EXTERN
void canvas_setcurrent(t_canvas
*x
);
456 EXTERN
void canvas_unsetcurrent(t_canvas
*x
);
457 EXTERN t_symbol
*canvas_realizedollar(t_canvas
*x
, t_symbol
*s
);
458 EXTERN t_canvas
*canvas_getrootfor(t_canvas
*x
);
459 EXTERN
void canvas_dirty(t_canvas
*x
, t_int n
);
460 EXTERN
int canvas_getfont(t_canvas
*x
);
461 typedef int (*t_canvasapply
)(t_canvas
*x
, t_int x1
, t_int x2
, t_int x3
);
463 EXTERN t_int
*canvas_recurapply(t_canvas
*x
, t_canvasapply
*fn
,
464 t_int x1
, t_int x2
, t_int x3
);
466 EXTERN
void canvas_resortinlets(t_canvas
*x
);
467 EXTERN
void canvas_resortoutlets(t_canvas
*x
);
468 EXTERN
void canvas_free(t_canvas
*x
);
469 EXTERN
void canvas_updatewindowlist( void);
470 EXTERN
void canvas_editmode(t_canvas
*x
, t_floatarg yesplease
);
471 EXTERN
int canvas_isabstraction(t_canvas
*x
);
472 EXTERN
int canvas_istable(t_canvas
*x
);
473 EXTERN
int canvas_showtext(t_canvas
*x
);
474 EXTERN
void canvas_vis(t_canvas
*x
, t_floatarg f
);
475 EXTERN t_canvasenvironment
*canvas_getenv(t_canvas
*x
);
476 EXTERN
void canvas_rename(t_canvas
*x
, t_symbol
*s
, t_symbol
*dir
);
477 EXTERN
void canvas_loadbang(t_canvas
*x
);
478 EXTERN
int canvas_hitbox(t_canvas
*x
, t_gobj
*y
, int xpos
, int ypos
,
479 int *x1p
, int *y1p
, int *x2p
, int *y2p
);
480 EXTERN
int canvas_setdeleting(t_canvas
*x
, int flag
);
482 typedef void (*t_undofn
)(t_canvas
*canvas
, void *buf
,
483 int action
); /* a function that does UNDO/REDO */
484 #define UNDO_FREE 0 /* free current undo/redo buffer */
485 #define UNDO_UNDO 1 /* undo */
486 #define UNDO_REDO 2 /* redo */
487 EXTERN
void canvas_setundo(t_canvas
*x
, t_undofn undofn
, void *buf
,
489 EXTERN
void canvas_noundo(t_canvas
*x
);
490 EXTERN
int canvas_getindex(t_canvas
*x
, t_gobj
*y
);
492 /* T.Grill - made public for dynamic object creation */
494 EXTERN
void canvas_connect(t_canvas
*x
,
495 t_floatarg fwhoout
, t_floatarg foutno
,t_floatarg fwhoin
, t_floatarg finno
);
496 EXTERN
void canvas_disconnect(t_canvas
*x
,
497 float index1
, float outno
, float index2
, float inno
);
498 EXTERN
int canvas_isconnected (t_canvas
*x
,
499 t_text
*ob1
, int n1
, t_text
*ob2
, int n2
);
500 EXTERN
void canvas_selectinrect(t_canvas
*x
, int lox
, int loy
, int hix
, int hiy
);
503 /* ---- functions on canvasses as objects --------------------- */
505 EXTERN
void canvas_fattenforscalars(t_canvas
*x
,
506 int *x1
, int *y1
, int *x2
, int *y2
);
507 EXTERN
void canvas_visforscalars(t_canvas
*x
, t_glist
*glist
, int vis
);
508 EXTERN
int canvas_clicksub(t_canvas
*x
, int xpix
, int ypix
, int shift
,
509 int alt
, int dbl
, int doit
);
510 EXTERN t_glist
*canvas_getglistonsuper(void);
512 EXTERN
void linetraverser_start(t_linetraverser
*t
, t_canvas
*x
);
513 EXTERN t_outconnect
*linetraverser_next(t_linetraverser
*t
);
514 EXTERN
void linetraverser_skipobject(t_linetraverser
*t
);
516 /* --------------------- functions on tscalars --------------------- */
518 EXTERN
void tscalar_getrect(t_tscalar
*x
, t_glist
*owner
,
519 int *xp1
, int *yp1
, int *xp2
, int *yp2
);
520 EXTERN
void tscalar_vis(t_tscalar
*x
, t_glist
*owner
, int flag
);
521 EXTERN
int tscalar_click(t_tscalar
*x
, int xpix
, int ypix
, int shift
,
522 int alt
, int dbl
, int doit
);
524 /* --------- functions on garrays (graphical arrays) -------------------- */
526 EXTERN t_template
*garray_template(t_garray
*x
);
528 /* -------------------- arrays --------------------- */
529 EXTERN t_garray
*graph_array(t_glist
*gl
, t_symbol
*s
, t_symbol
*tmpl
,
530 t_floatarg f
, t_floatarg saveit
);
531 EXTERN t_array
*array_new(t_symbol
*templatesym
, t_gpointer
*parent
);
532 EXTERN
void array_resize(t_array
*x
, t_template
*tmpl
, int n
);
533 EXTERN
void array_free(t_array
*x
);
535 /* --------------------- gpointers and stubs ---------------- */
536 EXTERN t_gstub
*gstub_new(t_glist
*gl
, t_array
*a
);
537 EXTERN
void gstub_cutoff(t_gstub
*gs
);
538 EXTERN
void gpointer_setglist(t_gpointer
*gp
, t_glist
*glist
, t_scalar
*x
);
540 /* --------------------- scalars ------------------------- */
541 EXTERN
void word_init(t_word
*wp
, t_template
*tmpl
, t_gpointer
*gp
);
542 EXTERN
void word_restore(t_word
*wp
, t_template
*tmpl
,
543 int argc
, t_atom
*argv
);
544 EXTERN t_scalar
*scalar_new(t_glist
*owner
,
545 t_symbol
*templatesym
);
546 EXTERN
void scalar_getbasexy(t_scalar
*x
, float *basex
, float *basey
);
548 /* ------helper routines for "garrays" and "plots" -------------- */
549 EXTERN
int array_doclick(t_array
*array
, t_glist
*glist
, t_gobj
*gobj
,
550 t_symbol
*elemtemplatesym
,
551 float linewidth
, float xloc
, float xinc
, float yloc
,
552 int xpix
, int ypix
, int shift
, int alt
, int dbl
, int doit
);
554 EXTERN
void array_getcoordinate(t_glist
*glist
,
555 char *elem
, int xonset
, int yonset
, int wonset
, int indx
,
556 float basex
, float basey
, float xinc
,
557 float *xp
, float *yp
, float *wp
);
559 EXTERN
int array_getfields(t_symbol
*elemtemplatesym
,
560 t_canvas
**elemtemplatecanvasp
,
561 t_template
**elemtemplatep
, int *elemsizep
,
562 int *xonsetp
, int *yonsetp
, int *wonsetp
);
564 /* --------------------- templates ------------------------- */
565 EXTERN t_template
*template_new(t_symbol
*sym
, int argc
, t_atom
*argv
);
566 EXTERN
void template_free(t_template
*x
);
567 EXTERN
int template_match(t_template
*x1
, t_template
*x2
);
568 EXTERN
int template_find_field(t_template
*x
, t_symbol
*name
, int *p_onset
,
569 int *p_type
, t_symbol
**p_arraytype
);
570 EXTERN t_float
template_getfloat(t_template
*x
, t_symbol
*fieldname
, t_word
*wp
,
572 EXTERN
void template_setfloat(t_template
*x
, t_symbol
*fieldname
, t_word
*wp
,
573 t_float f
, int loud
);
574 EXTERN t_symbol
*template_getsymbol(t_template
*x
, t_symbol
*fieldname
,
575 t_word
*wp
, int loud
);
576 EXTERN
void template_setsymbol(t_template
*x
, t_symbol
*fieldname
,
577 t_word
*wp
, t_symbol
*s
, int loud
);
579 EXTERN t_template
*gtemplate_get(t_gtemplate
*x
);
580 EXTERN t_template
*template_findbyname(t_symbol
*s
);
581 EXTERN t_canvas
*template_findcanvas(t_template
*tmpl
);
583 EXTERN t_float
template_getfloat(t_template
*x
, t_symbol
*fieldname
,
584 t_word
*wp
, int loud
);
585 EXTERN
void template_setfloat(t_template
*x
, t_symbol
*fieldname
,
586 t_word
*wp
, t_float f
, int loud
);
587 EXTERN t_symbol
*template_getsymbol(t_template
*x
, t_symbol
*fieldname
,
588 t_word
*wp
, int loud
);
589 EXTERN
void template_setsymbol(t_template
*x
, t_symbol
*fieldname
,
590 t_word
*wp
, t_symbol
*s
, int loud
);
592 /* ----------------------- guiconnects, g_guiconnect.c --------- */
593 EXTERN t_guiconnect
*guiconnect_new(t_pd
*who
, t_symbol
*sym
);
594 EXTERN
void guiconnect_notarget(t_guiconnect
*x
, double timedelay
);
596 /* ------------- IEMGUI routines used in other g_ files ---------------- */
597 EXTERN t_symbol
*iemgui_raute2dollar(t_symbol
*s
);
598 EXTERN t_symbol
*iemgui_dollar2raute(t_symbol
*s
);
600 #if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)