summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/extra/g_canvas.h
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/extra/g_canvas.h')
-rw-r--r--apps/plugins/pdbox/PDa/extra/g_canvas.h1204
1 files changed, 1204 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/extra/g_canvas.h b/apps/plugins/pdbox/PDa/extra/g_canvas.h
new file mode 100644
index 0000000000..54ab985feb
--- /dev/null
+++ b/apps/plugins/pdbox/PDa/extra/g_canvas.h
@@ -0,0 +1,1204 @@
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. */
4
5/* this file defines the structure for "glists" and related structures and
6functions. "Glists" and "canvases" and "graphs" used to be different
7structures until being unified in version 0.35.
8
9A glist occupies its own window if the "gl_havewindow" flag is set. Its
10appearance 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.
12
13A glist is "root" if it has no owner, i.e., a document window. In this
14case "gl_havewindow" is always set.
15
16We maintain a list of root windows, so that we can traverse the whole
17collection of everything in a Pd process.
18
19If a glist has a window it may still not be "mapped." Miniaturized
20windows aren't mapped, for example, but a window is also not mapped
21immediately upon creation. In either case gl_havewindow is true but
22gl_mapped is false.
23
24Closing a non-root window makes it invisible; closing a root destroys it.
25
26A glist that's just a text object on its parent is always "toplevel." An
27embedded glist can switch back and forth to appear as a toplevel by double-
28clicking on it. Single-clicking a text box makes the toplevel become visible
29and raises the window it's in.
30
31If a glist shows up as a graph on its parent, the graph is blanked while the
32glist has its own window, even if miniaturized.
33
34*/
35
36/* NOTE: this file describes Pd implementation details which may change
37in future releases. The public (stable) API is in m_pd.h. */
38
39#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
40extern "C" {
41#endif
42
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 ------------------------------- */
49
50typedef struct _updateheader
51{
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 */
55} t_updateheader;
56
57 /* types to support glists grabbing mouse motion or keys from parent */
58typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
59typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
60
61EXTERN_STRUCT _rtext;
62#define t_rtext struct _rtext
63
64EXTERN_STRUCT _gtemplate;
65#define t_gtemplate struct _gtemplate
66
67EXTERN_STRUCT _guiconnect;
68#define t_guiconnect struct _guiconnect
69
70EXTERN_STRUCT _tscalar;
71#define t_tscalar struct _tscalar
72
73EXTERN_STRUCT _canvasenvironment;
74#define t_canvasenvironment struct _canvasenvironment
75
76typedef struct _selection
77{
78 t_gobj *sel_what;
79 struct _selection *sel_next;
80} t_selection;
81
82 /* this structure is instantiated whenever a glist becomes visible. */
83typedef struct _editor
84{
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 */
108} t_editor;
109
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 */
116
117/* editor structure for "garrays". We don't bother to delete and regenerate
118this structure when the "garray" becomes invisible or visible, although we
119could do so if the structure gets big (like the "editor" above.) */
120
121typedef struct _arrayvis
122{
123 t_updateheader av_upd; /* update header structure */
124 t_garray *av_garray; /* owning structure */
125} t_arrayvis;
126
127/* the t_tick structure describes where to draw x and y "ticks" for a glist */
128
129typedef struct _tick /* where to put ticks on x or y axes */
130{
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 */
134} t_tick;
135
136/* the t_glist structure, which describes a list of elements that live on an
137area of a window.
138
139*/
140
141struct _glist
142{
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) */
149 int gl_pixheight;
150 float gl_x1; /* bounding rectangle in our own coordinates */
151 float gl_y1;
152 float gl_x2;
153 float gl_y2;
154 int gl_screenx1; /* screen coordinates when toplevel */
155 int gl_screeny1;
156 int gl_screenx2;
157 int gl_screeny2;
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 */
163 int gl_nylabels;
164 t_symbol **gl_ylabel;
165 float gl_ylabelx;
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 */
180};
181
182#define gl_gobj gl_obj.te_g
183#define gl_pd gl_gobj.g_pd
184
185/* a data structure to describe a field in a pure datum */
186
187#define DT_FLOAT 0
188#define DT_SYMBOL 1
189#define DT_LIST 2
190#define DT_ARRAY 3
191
192typedef struct _dataslot
193{
194 int ds_type;
195 t_symbol *ds_name;
196 t_symbol *ds_arraytemplate; /* filled in for arrays only */
197} t_dataslot;
198
199
200/* T.Grill - changed t_pd member to t_pdobj to avoid name clashed */
201typedef struct _template
202{
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 */
208} t_template;
209
210struct _array
211{
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 */
218 t_gstub *a_stub;
219};
220
221 /* structure for traversing all the connections in a glist */
222typedef struct _linetraverser
223{
224 t_canvas *tr_x;
225 t_object *tr_ob;
226 int tr_nout;
227 int tr_outno;
228 t_object *tr_ob2;
229 t_outlet *tr_outlet;
230 t_inlet *tr_inlet;
231 int tr_nin;
232 int tr_inno;
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;
237 int tr_nextoutno;
238} t_linetraverser;
239
240/* function types used to define graphical behavior for gobjs, a bit like X
241widgets. We don't use Pd methods because Pd's typechecking can't specify the
242types of pointer arguments. Also it's more convenient this way, since
243every "patchable" object can just get the "text" behaviors. */
244
245 /* Call this to get a gobj's bounding rectangle in pixels */
246typedef 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: */
249typedef void (*t_displacefn)(t_gobj *x, struct _glist *glist, int dx, int dy);
250 /* change color to show selection: */
251typedef void (*t_selectfn)(t_gobj *x, struct _glist *glist, int state);
252 /* change appearance to show activation/deactivation: */
253typedef void (*t_activatefn)(t_gobj *x, struct _glist *glist, int state);
254 /* warn a gobj it's about to be deleted */
255typedef void (*t_deletefn)(t_gobj *x, struct _glist *glist);
256 /* making visible or invisible */
257typedef void (*t_visfn)(t_gobj *x, struct _glist *glist, int flag);
258 /* field a mouse click (when not in "edit" mode) */
259typedef 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... */
262
263struct _widgetbehavior
264{
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;
270 t_visfn w_visfn;
271 t_clickfn w_clickfn;
272};
273
274/* -------- behaviors for scalars defined by objects in template --------- */
275/* these are set by "drawing commands" in g_template.c which add appearance to
276scalars, which live in some other window. If the scalar is just included
277in a canvas the "parent" is a misnomer. There is also a text scalar object
278which really does draw the scalar on the parent window; see g_scalar.c. */
279
280/* note how the click function wants the whole scalar, not the "data", so
281doesn't work on array elements... LATER reconsider this */
282
283 /* bounding rectangle: */
284typedef 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);
287 /* displace it */
288typedef void (*t_parentdisplacefn)(t_gobj *x, struct _glist *glist,
289 t_word *data, t_template *tmpl, float basex, float basey,
290 int dx, int dy);
291 /* change color to show selection */
292typedef void (*t_parentselectfn)(t_gobj *x, struct _glist *glist,
293 t_word *data, t_template *tmpl, float basex, float basey,
294 int state);
295 /* change appearance to show activation/deactivation: */
296typedef void (*t_parentactivatefn)(t_gobj *x, struct _glist *glist,
297 t_word *data, t_template *tmpl, float basex, float basey,
298 int state);
299 /* making visible or invisible */
300typedef void (*t_parentvisfn)(t_gobj *x, struct _glist *glist,
301 t_word *data, t_template *tmpl, float basex, float basey,
302 int flag);
303 /* field a mouse click */
304typedef 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);
307
308struct _parentwidgetbehavior
309{
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;
316};
317
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
326EXTERN void canvas_setcursor(t_glist *x, unsigned int cursornum);
327
328extern t_canvas *canvas_editing; /* last canvas to start text edting */
329extern t_canvas *canvas_whichfind; /* last canvas we did a find in */
330extern t_canvas *canvas_list; /* list of all root canvases */
331extern t_class *vinlet_class, *voutlet_class;
332extern int glist_valid; /* incremented when pointers might be stale */
333
334/* ------------------- functions on any gobj ----------------------------- */
335EXTERN void gobj_getrect(t_gobj *x, t_glist *owner, int *x1, int *y1,
336 int *x2, int *y2);
337EXTERN void gobj_displace(t_gobj *x, t_glist *owner, int dx, int dy);
338EXTERN void gobj_select(t_gobj *x, t_glist *owner, int state);
339EXTERN void gobj_activate(t_gobj *x, t_glist *owner, int state);
340EXTERN void gobj_delete(t_gobj *x, t_glist *owner);
341EXTERN void gobj_vis(t_gobj *x, t_glist *glist, int flag);
342EXTERN int gobj_click(t_gobj *x, struct _glist *glist,
343 int xpix, int ypix, int shift, int alt, int dbl, int doit);
344EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
345EXTERN void gobj_properties(t_gobj *x, struct _glist *glist);
346EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
347
348/* -------------------- functions on glists --------------------- */
349EXTERN t_glist *glist_new( void);
350EXTERN void glist_init(t_glist *x);
351EXTERN void glist_add(t_glist *x, t_gobj *g);
352EXTERN void glist_cleanup(t_glist *x);
353EXTERN void glist_free(t_glist *x);
354
355EXTERN void glist_clear(t_glist *x);
356EXTERN t_canvas *glist_getcanvas(t_glist *x);
357EXTERN int glist_isselected(t_glist *x, t_gobj *y);
358EXTERN void glist_select(t_glist *x, t_gobj *y);
359EXTERN void glist_deselect(t_glist *x, t_gobj *y);
360EXTERN void glist_noselect(t_glist *x);
361EXTERN void glist_selectall(t_glist *x);
362EXTERN void glist_delete(t_glist *x, t_gobj *y);
363EXTERN void glist_retext(t_glist *x, t_text *y);
364EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
365 t_glistkeyfn keyfn, int xpos, int ypos);
366EXTERN int glist_isvisible(t_glist *x);
367EXTERN int glist_istoplevel(t_glist *x);
368EXTERN t_glist *glist_findgraph(t_glist *x);
369EXTERN int glist_getfont(t_glist *x);
370EXTERN void glist_sort(t_glist *canvas);
371EXTERN void glist_read(t_glist *x, t_symbol *filename, t_symbol *format);
372EXTERN void glist_mergefile(t_glist *x, t_symbol *filename, t_symbol *format);
373
374EXTERN float glist_pixelstox(t_glist *x, float xpix);
375EXTERN float glist_pixelstoy(t_glist *x, float ypix);
376EXTERN float glist_xtopixels(t_glist *x, float xval);
377EXTERN float glist_ytopixels(t_glist *x, float yval);
378EXTERN float glist_dpixtodx(t_glist *x, float dxpix);
379EXTERN float glist_dpixtody(t_glist *x, float dypix);
380
381EXTERN void glist_redrawitem(t_glist *owner, t_gobj *gobj);
382EXTERN void glist_getnextxy(t_glist *gl, int *xval, int *yval);
383EXTERN void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv);
384EXTERN 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);
387EXTERN void glist_arraydialog(t_glist *parent, t_symbol *name,
388 t_floatarg size, t_floatarg saveit, t_floatarg newgraph);
389EXTERN t_binbuf *glist_writetobinbuf(t_glist *x, int wholething);
390EXTERN int glist_isgraph(t_glist *x);
391EXTERN void glist_redraw(t_glist *x);
392EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
393 char *tag, int x1, int y1, int x2, int y2);
394EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag);
395EXTERN void canvas_create_editor(t_glist *x, int createit);
396void canvas_deletelinesforio(t_canvas *x, t_text *text,
397 t_inlet *inp, t_outlet *outp);
398
399
400/* -------------------- functions on texts ------------------------- */
401EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize);
402EXTERN void text_drawborder(t_text *x, t_glist *glist, char *tag,
403 int width, int height, int firsttime);
404EXTERN void text_eraseborder(t_text *x, t_glist *glist, char *tag);
405EXTERN int text_xcoord(t_text *x, t_glist *glist);
406EXTERN int text_ycoord(t_text *x, t_glist *glist);
407EXTERN int text_xpix(t_text *x, t_glist *glist);
408EXTERN int text_ypix(t_text *x, t_glist *glist);
409EXTERN int text_shouldvis(t_text *x, t_glist *glist);
410
411/* -------------------- functions on rtexts ------------------------- */
412#define RTEXT_DOWN 1
413#define RTEXT_DRAG 2
414#define RTEXT_DBL 3
415#define RTEXT_SHIFT 4
416
417EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who);
418EXTERN t_rtext *glist_findrtext(t_glist *gl, t_text *who);
419EXTERN void rtext_draw(t_rtext *x);
420EXTERN void rtext_erase(t_rtext *x);
421EXTERN t_rtext *rtext_remove(t_rtext *first, t_rtext *x);
422EXTERN int rtext_height(t_rtext *x);
423EXTERN void rtext_displace(t_rtext *x, int dx, int dy);
424EXTERN void rtext_select(t_rtext *x, int state);
425EXTERN void rtext_activate(t_rtext *x, int state);
426EXTERN void rtext_free(t_rtext *x);
427EXTERN void rtext_key(t_rtext *x, int n, t_symbol *s);
428EXTERN void rtext_mouse(t_rtext *x, int xval, int yval, int flag);
429EXTERN void rtext_retext(t_rtext *x);
430EXTERN int rtext_width(t_rtext *x);
431EXTERN int rtext_height(t_rtext *x);
432EXTERN char *rtext_gettag(t_rtext *x);
433EXTERN void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
434
435/* -------------------- functions on canvases ------------------------ */
436EXTERN t_class *canvas_class;
437
438EXTERN t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv);
439EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
440EXTERN void canvas_vistext(t_canvas *x, t_text *y);
441EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
442EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
443EXTERN void canvas_stowconnections(t_canvas *x);
444EXTERN void canvas_restoreconnections(t_canvas *x);
445EXTERN void canvas_redraw(t_canvas *x);
446
447EXTERN t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *sym);
448EXTERN void canvas_rminlet(t_canvas *x, t_inlet *ip);
449EXTERN t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *sym);
450EXTERN void canvas_rmoutlet(t_canvas *x, t_outlet *op);
451EXTERN void canvas_redrawallfortemplate(t_canvas *tmpl);
452EXTERN void canvas_zapallfortemplate(t_canvas *tmpl);
453EXTERN void canvas_setusedastemplate(t_canvas *x);
454EXTERN t_canvas *canvas_getcurrent(void);
455EXTERN void canvas_setcurrent(t_canvas *x);
456EXTERN void canvas_unsetcurrent(t_canvas *x);
457EXTERN t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s);
458EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
459EXTERN void canvas_dirty(t_canvas *x, t_int n);
460EXTERN int canvas_getfont(t_canvas *x);
461typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
462
463EXTERN t_int *canvas_recurapply(t_canvas *x, t_canvasapply *fn,
464 t_int x1, t_int x2, t_int x3);
465
466EXTERN void canvas_resortinlets(t_canvas *x);
467EXTERN void canvas_resortoutlets(t_canvas *x);
468EXTERN void canvas_free(t_canvas *x);
469EXTERN void canvas_updatewindowlist( void);
470EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease);
471EXTERN int canvas_isabstraction(t_canvas *x);
472EXTERN int canvas_istable(t_canvas *x);
473EXTERN int canvas_showtext(t_canvas *x);
474EXTERN void canvas_vis(t_canvas *x, t_floatarg f);
475EXTERN t_canvasenvironment *canvas_getenv(t_canvas *x);
476EXTERN void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir);
477EXTERN void canvas_loadbang(t_canvas *x);
478EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
479 int *x1p, int *y1p, int *x2p, int *y2p);
480EXTERN int canvas_setdeleting(t_canvas *x, int flag);
481
482typedef 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 */
487EXTERN void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
488 const char *name);
489EXTERN void canvas_noundo(t_canvas *x);
490EXTERN int canvas_getindex(t_canvas *x, t_gobj *y);
491
492/* T.Grill - made public for dynamic object creation */
493/* in g_editor.c */
494EXTERN void canvas_connect(t_canvas *x,
495 t_floatarg fwhoout, t_floatarg foutno,t_floatarg fwhoin, t_floatarg finno);
496EXTERN void canvas_disconnect(t_canvas *x,
497 float index1, float outno, float index2, float inno);
498EXTERN int canvas_isconnected (t_canvas *x,
499 t_text *ob1, int n1, t_text *ob2, int n2);
500EXTERN void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy);
501
502
503/* ---- functions on canvasses as objects --------------------- */
504
505EXTERN void canvas_fattenforscalars(t_canvas *x,
506 int *x1, int *y1, int *x2, int *y2);
507EXTERN void canvas_visforscalars(t_canvas *x, t_glist *glist, int vis);
508EXTERN int canvas_clicksub(t_canvas *x, int xpix, int ypix, int shift,
509 int alt, int dbl, int doit);
510EXTERN t_glist *canvas_getglistonsuper(void);
511
512EXTERN void linetraverser_start(t_linetraverser *t, t_canvas *x);
513EXTERN t_outconnect *linetraverser_next(t_linetraverser *t);
514EXTERN void linetraverser_skipobject(t_linetraverser *t);
515
516/* --------------------- functions on tscalars --------------------- */
517
518EXTERN void tscalar_getrect(t_tscalar *x, t_glist *owner,
519 int *xp1, int *yp1, int *xp2, int *yp2);
520EXTERN void tscalar_vis(t_tscalar *x, t_glist *owner, int flag);
521EXTERN int tscalar_click(t_tscalar *x, int xpix, int ypix, int shift,
522 int alt, int dbl, int doit);
523
524/* --------- functions on garrays (graphical arrays) -------------------- */
525
526EXTERN t_template *garray_template(t_garray *x);
527
528/* -------------------- arrays --------------------- */
529EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *tmpl,
530 t_floatarg f, t_floatarg saveit);
531EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
532EXTERN void array_resize(t_array *x, t_template *tmpl, int n);
533EXTERN void array_free(t_array *x);
534
535/* --------------------- gpointers and stubs ---------------- */
536EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
537EXTERN void gstub_cutoff(t_gstub *gs);
538EXTERN void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x);
539
540/* --------------------- scalars ------------------------- */
541EXTERN void word_init(t_word *wp, t_template *tmpl, t_gpointer *gp);
542EXTERN void word_restore(t_word *wp, t_template *tmpl,
543 int argc, t_atom *argv);
544EXTERN t_scalar *scalar_new(t_glist *owner,
545 t_symbol *templatesym);
546EXTERN void scalar_getbasexy(t_scalar *x, float *basex, float *basey);
547
548/* ------helper routines for "garrays" and "plots" -------------- */
549EXTERN 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);
553
554EXTERN 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);
558
559EXTERN int array_getfields(t_symbol *elemtemplatesym,
560 t_canvas **elemtemplatecanvasp,
561 t_template **elemtemplatep, int *elemsizep,
562 int *xonsetp, int *yonsetp, int *wonsetp);
563
564/* --------------------- templates ------------------------- */
565EXTERN t_template *template_new(t_symbol *sym, int argc, t_atom *argv);
566EXTERN void template_free(t_template *x);
567EXTERN int template_match(t_template *x1, t_template *x2);
568EXTERN int template_find_field(t_template *x, t_symbol *name, int *p_onset,
569 int *p_type, t_symbol **p_arraytype);
570EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp,
571 int loud);
572EXTERN void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp,
573 t_float f, int loud);
574EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
575 t_word *wp, int loud);
576EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
577 t_word *wp, t_symbol *s, int loud);
578
579EXTERN t_template *gtemplate_get(t_gtemplate *x);
580EXTERN t_template *template_findbyname(t_symbol *s);
581EXTERN t_canvas *template_findcanvas(t_template *tmpl);
582
583EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname,
584 t_word *wp, int loud);
585EXTERN void template_setfloat(t_template *x, t_symbol *fieldname,
586 t_word *wp, t_float f, int loud);
587EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
588 t_word *wp, int loud);
589EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
590 t_word *wp, t_symbol *s, int loud);
591
592/* ----------------------- guiconnects, g_guiconnect.c --------- */
593EXTERN t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym);
594EXTERN void guiconnect_notarget(t_guiconnect *x, double timedelay);
595
596/* ------------- IEMGUI routines used in other g_ files ---------------- */
597EXTERN t_symbol *iemgui_raute2dollar(t_symbol *s);
598EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
599
600#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
601}
602#endif
603/* Copyright (c) 1997-1999 Miller Puckette.
604* For information on usage and redistribution, and for a DISCLAIMER OF ALL
605* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
606
607/* this file defines the structure for "glists" and related structures and
608functions. "Glists" and "canvases" and "graphs" used to be different
609structures until being unified in version 0.35.
610
611A glist occupies its own window if the "gl_havewindow" flag is set. Its
612appearance on its "parent" or "owner" (if it has one) is as a graph if
613"gl_isgraph" is set, and otherwise as a text box.
614
615A glist is "root" if it has no owner, i.e., a document window. In this
616case "gl_havewindow" is always set.
617
618We maintain a list of root windows, so that we can traverse the whole
619collection of everything in a Pd process.
620
621If a glist has a window it may still not be "mapped." Miniaturized
622windows aren't mapped, for example, but a window is also not mapped
623immediately upon creation. In either case gl_havewindow is true but
624gl_mapped is false.
625
626Closing a non-root window makes it invisible; closing a root destroys it.
627
628A glist that's just a text object on its parent is always "toplevel." An
629embedded glist can switch back and forth to appear as a toplevel by double-
630clicking on it. Single-clicking a text box makes the toplevel become visible
631and raises the window it's in.
632
633If a glist shows up as a graph on its parent, the graph is blanked while the
634glist has its own window, even if miniaturized.
635
636*/
637
638/* NOTE: this file describes Pd implementation details which may change
639in future releases. The public (stable) API is in m_pd.h. */
640
641#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
642extern "C" {
643#endif
644
645/* --------------------- geometry ---------------------------- */
646#define IOWIDTH 7 /* width of an inlet/outlet in pixels */
647#define IOMIDDLE ((IOWIDTH-1)/2)
648#define GLIST_DEFGRAPHWIDTH 200
649#define GLIST_DEFGRAPHHEIGHT 140
650/* ----------------------- data ------------------------------- */
651
652typedef struct _updateheader
653{
654 struct _updateheader *upd_next;
655 unsigned int upd_array:1; /* true if array, false if glist */
656 unsigned int upd_queued:1; /* true if we're queued */
657} t_updateheader;
658
659 /* types to support glists grabbing mouse motion or keys from parent */
660typedef void (*t_glistmotionfn)(void *z, t_floatarg dx, t_floatarg dy);
661typedef void (*t_glistkeyfn)(void *z, t_floatarg key);
662
663EXTERN_STRUCT _rtext;
664#define t_rtext struct _rtext
665
666EXTERN_STRUCT _gtemplate;
667#define t_gtemplate struct _gtemplate
668
669EXTERN_STRUCT _guiconnect;
670#define t_guiconnect struct _guiconnect
671
672EXTERN_STRUCT _tscalar;
673#define t_tscalar struct _tscalar
674
675EXTERN_STRUCT _canvasenvironment;
676#define t_canvasenvironment struct _canvasenvironment
677
678typedef struct _selection
679{
680 t_gobj *sel_what;
681 struct _selection *sel_next;
682} t_selection;
683
684 /* this structure is instantiated whenever a glist becomes visible. */
685typedef struct _editor
686{
687 t_updateheader e_upd; /* update header structure */
688 t_selection *e_updlist; /* list of objects to update */
689 t_rtext *e_rtext; /* text responder linked list */
690 t_selection *e_selection; /* head of the selection list */
691 t_rtext *e_textedfor; /* the rtext if any that we are editing */
692 t_gobj *e_grab; /* object being "dragged" */
693 t_glistmotionfn e_motionfn; /* ... motion callback */
694 t_glistkeyfn e_keyfn; /* ... keypress callback */
695 t_binbuf *e_connectbuf; /* connections to deleted objects */
696 t_binbuf *e_deleted; /* last stuff we deleted */
697 t_guiconnect *e_guiconnect; /* GUI connection for filtering messages */
698 struct _glist *e_glist; /* glist which owns this */
699 int e_xwas; /* xpos on last mousedown or motion event */
700 int e_ywas; /* ypos, similarly */
701 int e_selectline_index1; /* indices for the selected line if any */
702 int e_selectline_outno; /* (only valid if e_selectedline is set) */
703 int e_selectline_index2;
704 int e_selectline_inno;
705 t_outconnect *e_selectline_tag;
706 unsigned int e_onmotion: 3; /* action to take on motion */
707 unsigned int e_lastmoved: 1; /* one if mouse has moved since click */
708 unsigned int e_textdirty: 1; /* one if e_textedfor has changed */
709 unsigned int e_selectedline: 1; /* one if a line is selected */
710} t_editor;
711
712#define MA_NONE 0 /* e_onmotion: do nothing on mouse motion */
713#define MA_MOVE 1 /* drag the selection around */
714#define MA_CONNECT 2 /* make a connection */
715#define MA_REGION 3 /* selection region */
716#define MA_PASSOUT 4 /* send on to e_grab */
717#define MA_DRAGTEXT 5 /* drag in text editor to alter selection */
718
719/* editor structure for "garrays". We don't bother to delete and regenerate
720this structure when the "garray" becomes invisible or visible, although we
721could do so if the structure gets big (like the "editor" above.) */
722
723typedef struct _arrayvis
724{
725 t_updateheader av_upd; /* update header structure */
726 t_garray *av_garray; /* owning structure */
727} t_arrayvis;
728
729/* the t_tick structure describes where to draw x and y "ticks" for a glist */
730
731typedef struct _tick /* where to put ticks on x or y axes */
732{
733 float k_point; /* one point to draw a big tick at */
734 float k_inc; /* x or y increment per little tick */
735 int k_lperb; /* little ticks per big; 0 if no ticks to draw */
736} t_tick;
737
738/* the t_glist structure, which describes a list of elements that live on an
739area of a window.
740
741*/
742
743struct _glist
744{
745 t_object gl_obj; /* header in case we're a glist */
746 t_gobj *gl_list; /* the actual data */
747 struct _gstub *gl_stub; /* safe pointer handler */
748 int gl_valid; /* incremented when pointers might be stale */
749 struct _glist *gl_owner; /* parent glist, supercanvas, or 0 if none */
750 int gl_pixwidth; /* width in pixels (on parent, if a graph) */
751 int gl_pixheight;
752 float gl_x1; /* bounding rectangle in our own coordinates */
753 float gl_y1;
754 float gl_x2;
755 float gl_y2;
756 int gl_screenx1; /* screen coordinates when toplevel */
757 int gl_screeny1;
758 int gl_screenx2;
759 int gl_screeny2;
760 t_tick gl_xtick; /* ticks marking X values */
761 int gl_nxlabels; /* number of X coordinate labels */
762 t_symbol **gl_xlabel; /* ... an array to hold them */
763 float gl_xlabely; /* ... and their Y coordinates */
764 t_tick gl_ytick; /* same as above for Y ticks and labels */
765 int gl_nylabels;
766 t_symbol **gl_ylabel;
767 float gl_ylabelx;
768 t_editor *gl_editor; /* editor structure when visible */
769 t_symbol *gl_name; /* symbol bound here */
770 int gl_font; /* nominal font size in points, e.g., 10 */
771 struct _glist *gl_next; /* link in list of toplevels */
772 t_canvasenvironment *gl_env; /* root canvases and abstractions only */
773 unsigned int gl_havewindow:1; /* true if we own a window */
774 unsigned int gl_mapped:1; /* true if, moreover, it's "mapped" */
775 unsigned int gl_dirty:1; /* (root canvas only:) patch has changed */
776 unsigned int gl_loading:1; /* am now loading from file */
777 unsigned int gl_willvis:1; /* make me visible after loading */
778 unsigned int gl_edit:1; /* edit mode */
779 unsigned int gl_isdeleting:1; /* we're inside glist_delete -- hack! */
780 unsigned int gl_stretch:1; /* stretch contents on resize */
781 unsigned int gl_isgraph:1; /* show as graph on parent */
782};
783
784#define gl_gobj gl_obj.te_g
785#define gl_pd gl_gobj.g_pd
786
787/* a data structure to describe a field in a pure datum */
788
789#define DT_FLOAT 0
790#define DT_SYMBOL 1
791#define DT_LIST 2
792#define DT_ARRAY 3
793
794typedef struct _dataslot
795{
796 int ds_type;
797 t_symbol *ds_name;
798 t_symbol *ds_arraytemplate; /* filled in for arrays only */
799} t_dataslot;
800
801
802/* T.Grill - changed t_pd member to t_pdobj to avoid name clashed */
803typedef struct _template
804{
805 t_pd t_pdobj; /* header */
806 struct _gtemplate *t_list; /* list of "struct"/gtemplate objects */
807 t_symbol *t_sym; /* name */
808 int t_n; /* number of dataslots (fields) */
809 t_dataslot *t_vec; /* array of dataslots */
810} t_template;
811
812struct _array
813{
814 int a_n; /* number of elements */
815 int a_elemsize; /* size in bytes; LATER get this from template */
816 char *a_vec; /* array of elements */
817 t_symbol *a_templatesym; /* template for elements */
818 int a_valid; /* protection against stale pointers into array */
819 t_gpointer a_gp; /* pointer to scalar or array element we're in */
820 t_gstub *a_stub;
821};
822
823 /* structure for traversing all the connections in a glist */
824typedef struct _linetraverser
825{
826 t_canvas *tr_x;
827 t_object *tr_ob;
828 int tr_nout;
829 int tr_outno;
830 t_object *tr_ob2;
831 t_outlet *tr_outlet;
832 t_inlet *tr_inlet;
833 int tr_nin;
834 int tr_inno;
835 int tr_x11, tr_y11, tr_x12, tr_y12;
836 int tr_x21, tr_y21, tr_x22, tr_y22;
837 int tr_lx1, tr_ly1, tr_lx2, tr_ly2;
838 t_outconnect *tr_nextoc;
839 int tr_nextoutno;
840} t_linetraverser;
841
842/* function types used to define graphical behavior for gobjs, a bit like X
843widgets. We don't use Pd methods because Pd's typechecking can't specify the
844types of pointer arguments. Also it's more convenient this way, since
845every "patchable" object can just get the "text" behaviors. */
846
847 /* Call this to get a gobj's bounding rectangle in pixels */
848typedef void (*t_getrectfn)(t_gobj *x, struct _glist *glist,
849 int *x1, int *y1, int *x2, int *y2);
850 /* and this to displace a gobj: */
851typedef void (*t_displacefn)(t_gobj *x, struct _glist *glist, int dx, int dy);
852 /* change color to show selection: */
853typedef void (*t_selectfn)(t_gobj *x, struct _glist *glist, int state);
854 /* change appearance to show activation/deactivation: */
855typedef void (*t_activatefn)(t_gobj *x, struct _glist *glist, int state);
856 /* warn a gobj it's about to be deleted */
857typedef void (*t_deletefn)(t_gobj *x, struct _glist *glist);
858 /* making visible or invisible */
859typedef void (*t_visfn)(t_gobj *x, struct _glist *glist, int flag);
860 /* field a mouse click (when not in "edit" mode) */
861typedef int (*t_clickfn)(t_gobj *x, struct _glist *glist,
862 int xpix, int ypix, int shift, int alt, int dbl, int doit);
863 /* ... and later, resizing; getting/setting font or color... */
864
865struct _widgetbehavior
866{
867 t_getrectfn w_getrectfn;
868 t_displacefn w_displacefn;
869 t_selectfn w_selectfn;
870 t_activatefn w_activatefn;
871 t_deletefn w_deletefn;
872 t_visfn w_visfn;
873 t_clickfn w_clickfn;
874};
875
876/* -------- behaviors for scalars defined by objects in template --------- */
877/* these are set by "drawing commands" in g_template.c which add appearance to
878scalars, which live in some other window. If the scalar is just included
879in a canvas the "parent" is a misnomer. There is also a text scalar object
880which really does draw the scalar on the parent window; see g_scalar.c. */
881
882/* note how the click function wants the whole scalar, not the "data", so
883doesn't work on array elements... LATER reconsider this */
884
885 /* bounding rectangle: */
886typedef void (*t_parentgetrectfn)(t_gobj *x, struct _glist *glist,
887 t_word *data, t_template *tmpl, float basex, float basey,
888 int *x1, int *y1, int *x2, int *y2);
889 /* displace it */
890typedef void (*t_parentdisplacefn)(t_gobj *x, struct _glist *glist,
891 t_word *data, t_template *tmpl, float basex, float basey,
892 int dx, int dy);
893 /* change color to show selection */
894typedef void (*t_parentselectfn)(t_gobj *x, struct _glist *glist,
895 t_word *data, t_template *tmpl, float basex, float basey,
896 int state);
897 /* change appearance to show activation/deactivation: */
898typedef void (*t_parentactivatefn)(t_gobj *x, struct _glist *glist,
899 t_word *data, t_template *tmpl, float basex, float basey,
900 int state);
901 /* making visible or invisible */
902typedef void (*t_parentvisfn)(t_gobj *x, struct _glist *glist,
903 t_word *data, t_template *tmpl, float basex, float basey,
904 int flag);
905 /* field a mouse click */
906typedef int (*t_parentclickfn)(t_gobj *x, struct _glist *glist,
907 t_scalar *sc, t_template *tmpl, float basex, float basey,
908 int xpix, int ypix, int shift, int alt, int dbl, int doit);
909
910struct _parentwidgetbehavior
911{
912 t_parentgetrectfn w_parentgetrectfn;
913 t_parentdisplacefn w_parentdisplacefn;
914 t_parentselectfn w_parentselectfn;
915 t_parentactivatefn w_parentactivatefn;
916 t_parentvisfn w_parentvisfn;
917 t_parentclickfn w_parentclickfn;
918};
919
920 /* cursor definitions; used as return value for t_parentclickfn */
921#define CURSOR_RUNMODE_NOTHING 0
922#define CURSOR_RUNMODE_CLICKME 1
923#define CURSOR_RUNMODE_THICKEN 2
924#define CURSOR_RUNMODE_ADDPOINT 3
925#define CURSOR_EDITMODE_NOTHING 4
926#define CURSOR_EDITMODE_CONNECT 5
927#define CURSOR_EDITMODE_DISCONNECT 6
928EXTERN void canvas_setcursor(t_glist *x, unsigned int cursornum);
929
930extern t_canvas *canvas_editing; /* last canvas to start text edting */
931extern t_canvas *canvas_whichfind; /* last canvas we did a find in */
932extern t_canvas *canvas_list; /* list of all root canvases */
933extern t_class *vinlet_class, *voutlet_class;
934extern int glist_valid; /* incremented when pointers might be stale */
935
936/* ------------------- functions on any gobj ----------------------------- */
937EXTERN void gobj_getrect(t_gobj *x, t_glist *owner, int *x1, int *y1,
938 int *x2, int *y2);
939EXTERN void gobj_displace(t_gobj *x, t_glist *owner, int dx, int dy);
940EXTERN void gobj_select(t_gobj *x, t_glist *owner, int state);
941EXTERN void gobj_activate(t_gobj *x, t_glist *owner, int state);
942EXTERN void gobj_delete(t_gobj *x, t_glist *owner);
943EXTERN void gobj_vis(t_gobj *x, t_glist *glist, int flag);
944EXTERN int gobj_click(t_gobj *x, struct _glist *glist,
945 int xpix, int ypix, int shift, int alt, int dbl, int doit);
946EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
947EXTERN void gobj_properties(t_gobj *x, struct _glist *glist);
948EXTERN void gobj_save(t_gobj *x, t_binbuf *b);
949
950/* -------------------- functions on glists --------------------- */
951EXTERN t_glist *glist_new( void);
952EXTERN void glist_init(t_glist *x);
953EXTERN void glist_add(t_glist *x, t_gobj *g);
954EXTERN void glist_cleanup(t_glist *x);
955EXTERN void glist_free(t_glist *x);
956
957EXTERN void glist_clear(t_glist *x);
958EXTERN t_canvas *glist_getcanvas(t_glist *x);
959EXTERN int glist_isselected(t_glist *x, t_gobj *y);
960EXTERN void glist_select(t_glist *x, t_gobj *y);
961EXTERN void glist_deselect(t_glist *x, t_gobj *y);
962EXTERN void glist_noselect(t_glist *x);
963EXTERN void glist_selectall(t_glist *x);
964EXTERN void glist_delete(t_glist *x, t_gobj *y);
965EXTERN void glist_retext(t_glist *x, t_text *y);
966EXTERN void glist_grab(t_glist *x, t_gobj *y, t_glistmotionfn motionfn,
967 t_glistkeyfn keyfn, int xpos, int ypos);
968EXTERN int glist_isvisible(t_glist *x);
969EXTERN int glist_istoplevel(t_glist *x);
970EXTERN t_glist *glist_findgraph(t_glist *x);
971EXTERN int glist_getfont(t_glist *x);
972EXTERN void glist_sort(t_glist *canvas);
973EXTERN void glist_read(t_glist *x, t_symbol *filename, t_symbol *format);
974EXTERN void glist_mergefile(t_glist *x, t_symbol *filename, t_symbol *format);
975
976EXTERN float glist_pixelstox(t_glist *x, float xpix);
977EXTERN float glist_pixelstoy(t_glist *x, float ypix);
978EXTERN float glist_xtopixels(t_glist *x, float xval);
979EXTERN float glist_ytopixels(t_glist *x, float yval);
980EXTERN float glist_dpixtodx(t_glist *x, float dxpix);
981EXTERN float glist_dpixtody(t_glist *x, float dypix);
982
983EXTERN void glist_redrawitem(t_glist *owner, t_gobj *gobj);
984EXTERN void glist_getnextxy(t_glist *gl, int *xval, int *yval);
985EXTERN void glist_glist(t_glist *g, t_symbol *s, int argc, t_atom *argv);
986EXTERN t_glist *glist_addglist(t_glist *g, t_symbol *sym,
987 float x1, float y1, float x2, float y2,
988 float px1, float py1, float px2, float py2);
989EXTERN void glist_arraydialog(t_glist *parent, t_symbol *name,
990 t_floatarg size, t_floatarg saveit, t_floatarg newgraph);
991EXTERN t_binbuf *glist_writetobinbuf(t_glist *x, int wholething);
992EXTERN int glist_isgraph(t_glist *x);
993EXTERN void glist_redraw(t_glist *x);
994EXTERN void glist_drawiofor(t_glist *glist, t_object *ob, int firsttime,
995 char *tag, int x1, int y1, int x2, int y2);
996EXTERN void glist_eraseiofor(t_glist *glist, t_object *ob, char *tag);
997EXTERN void canvas_create_editor(t_glist *x, int createit);
998void canvas_deletelinesforio(t_canvas *x, t_text *text,
999 t_inlet *inp, t_outlet *outp);
1000
1001
1002/* -------------------- functions on texts ------------------------- */
1003EXTERN void text_setto(t_text *x, t_glist *glist, char *buf, int bufsize);
1004EXTERN void text_drawborder(t_text *x, t_glist *glist, char *tag,
1005 int width, int height, int firsttime);
1006EXTERN void text_eraseborder(t_text *x, t_glist *glist, char *tag);
1007EXTERN int text_xcoord(t_text *x, t_glist *glist);
1008EXTERN int text_ycoord(t_text *x, t_glist *glist);
1009EXTERN int text_xpix(t_text *x, t_glist *glist);
1010EXTERN int text_ypix(t_text *x, t_glist *glist);
1011EXTERN int text_shouldvis(t_text *x, t_glist *glist);
1012
1013/* -------------------- functions on rtexts ------------------------- */
1014#define RTEXT_DOWN 1
1015#define RTEXT_DRAG 2
1016#define RTEXT_DBL 3
1017#define RTEXT_SHIFT 4
1018
1019EXTERN t_rtext *rtext_new(t_glist *glist, t_text *who);
1020EXTERN t_rtext *glist_findrtext(t_glist *gl, t_text *who);
1021EXTERN void rtext_draw(t_rtext *x);
1022EXTERN void rtext_erase(t_rtext *x);
1023EXTERN t_rtext *rtext_remove(t_rtext *first, t_rtext *x);
1024EXTERN int rtext_height(t_rtext *x);
1025EXTERN void rtext_displace(t_rtext *x, int dx, int dy);
1026EXTERN void rtext_select(t_rtext *x, int state);
1027EXTERN void rtext_activate(t_rtext *x, int state);
1028EXTERN void rtext_free(t_rtext *x);
1029EXTERN void rtext_key(t_rtext *x, int n, t_symbol *s);
1030EXTERN void rtext_mouse(t_rtext *x, int xval, int yval, int flag);
1031EXTERN void rtext_retext(t_rtext *x);
1032EXTERN int rtext_width(t_rtext *x);
1033EXTERN int rtext_height(t_rtext *x);
1034EXTERN char *rtext_gettag(t_rtext *x);
1035EXTERN void rtext_gettext(t_rtext *x, char **buf, int *bufsize);
1036
1037/* -------------------- functions on canvases ------------------------ */
1038EXTERN t_class *canvas_class;
1039
1040EXTERN t_canvas *canvas_new(void *dummy, t_symbol *sel, int argc, t_atom *argv);
1041EXTERN t_symbol *canvas_makebindsym(t_symbol *s);
1042EXTERN void canvas_vistext(t_canvas *x, t_text *y);
1043EXTERN void canvas_fixlinesfor(t_canvas *x, t_text *text);
1044EXTERN void canvas_deletelinesfor(t_canvas *x, t_text *text);
1045EXTERN void canvas_stowconnections(t_canvas *x);
1046EXTERN void canvas_restoreconnections(t_canvas *x);
1047EXTERN void canvas_redraw(t_canvas *x);
1048
1049EXTERN t_inlet *canvas_addinlet(t_canvas *x, t_pd *who, t_symbol *sym);
1050EXTERN void canvas_rminlet(t_canvas *x, t_inlet *ip);
1051EXTERN t_outlet *canvas_addoutlet(t_canvas *x, t_pd *who, t_symbol *sym);
1052EXTERN void canvas_rmoutlet(t_canvas *x, t_outlet *op);
1053EXTERN void canvas_redrawallfortemplate(t_canvas *tmpl);
1054EXTERN void canvas_zapallfortemplate(t_canvas *tmpl);
1055EXTERN void canvas_setusedastemplate(t_canvas *x);
1056EXTERN t_canvas *canvas_getcurrent(void);
1057EXTERN void canvas_setcurrent(t_canvas *x);
1058EXTERN void canvas_unsetcurrent(t_canvas *x);
1059EXTERN t_symbol *canvas_realizedollar(t_canvas *x, t_symbol *s);
1060EXTERN t_canvas *canvas_getrootfor(t_canvas *x);
1061EXTERN void canvas_dirty(t_canvas *x, t_int n);
1062EXTERN int canvas_getfont(t_canvas *x);
1063typedef int (*t_canvasapply)(t_canvas *x, t_int x1, t_int x2, t_int x3);
1064
1065EXTERN t_int *canvas_recurapply(t_canvas *x, t_canvasapply *fn,
1066 t_int x1, t_int x2, t_int x3);
1067
1068EXTERN void canvas_resortinlets(t_canvas *x);
1069EXTERN void canvas_resortoutlets(t_canvas *x);
1070EXTERN void canvas_free(t_canvas *x);
1071EXTERN void canvas_updatewindowlist( void);
1072EXTERN void canvas_editmode(t_canvas *x, t_floatarg yesplease);
1073EXTERN int canvas_isabstraction(t_canvas *x);
1074EXTERN int canvas_istable(t_canvas *x);
1075EXTERN int canvas_showtext(t_canvas *x);
1076EXTERN void canvas_vis(t_canvas *x, t_floatarg f);
1077EXTERN t_canvasenvironment *canvas_getenv(t_canvas *x);
1078EXTERN void canvas_rename(t_canvas *x, t_symbol *s, t_symbol *dir);
1079EXTERN void canvas_loadbang(t_canvas *x);
1080EXTERN int canvas_hitbox(t_canvas *x, t_gobj *y, int xpos, int ypos,
1081 int *x1p, int *y1p, int *x2p, int *y2p);
1082EXTERN int canvas_setdeleting(t_canvas *x, int flag);
1083
1084typedef void (*t_undofn)(t_canvas *canvas, void *buf,
1085 int action); /* a function that does UNDO/REDO */
1086#define UNDO_FREE 0 /* free current undo/redo buffer */
1087#define UNDO_UNDO 1 /* undo */
1088#define UNDO_REDO 2 /* redo */
1089EXTERN void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
1090 const char *name);
1091EXTERN void canvas_noundo(t_canvas *x);
1092EXTERN int canvas_getindex(t_canvas *x, t_gobj *y);
1093
1094/* T.Grill - made public for dynamic object creation */
1095/* in g_editor.c */
1096EXTERN void canvas_connect(t_canvas *x,
1097 t_floatarg fwhoout, t_floatarg foutno,t_floatarg fwhoin, t_floatarg finno);
1098EXTERN void canvas_disconnect(t_canvas *x,
1099 float index1, float outno, float index2, float inno);
1100EXTERN int canvas_isconnected (t_canvas *x,
1101 t_text *ob1, int n1, t_text *ob2, int n2);
1102EXTERN void canvas_selectinrect(t_canvas *x, int lox, int loy, int hix, int hiy);
1103
1104
1105/* ---- functions on canvasses as objects --------------------- */
1106
1107EXTERN void canvas_fattenforscalars(t_canvas *x,
1108 int *x1, int *y1, int *x2, int *y2);
1109EXTERN void canvas_visforscalars(t_canvas *x, t_glist *glist, int vis);
1110EXTERN int canvas_clicksub(t_canvas *x, int xpix, int ypix, int shift,
1111 int alt, int dbl, int doit);
1112EXTERN t_glist *canvas_getglistonsuper(void);
1113
1114EXTERN void linetraverser_start(t_linetraverser *t, t_canvas *x);
1115EXTERN t_outconnect *linetraverser_next(t_linetraverser *t);
1116EXTERN void linetraverser_skipobject(t_linetraverser *t);
1117
1118/* --------------------- functions on tscalars --------------------- */
1119
1120EXTERN void tscalar_getrect(t_tscalar *x, t_glist *owner,
1121 int *xp1, int *yp1, int *xp2, int *yp2);
1122EXTERN void tscalar_vis(t_tscalar *x, t_glist *owner, int flag);
1123EXTERN int tscalar_click(t_tscalar *x, int xpix, int ypix, int shift,
1124 int alt, int dbl, int doit);
1125
1126/* --------- functions on garrays (graphical arrays) -------------------- */
1127
1128EXTERN t_template *garray_template(t_garray *x);
1129
1130/* -------------------- arrays --------------------- */
1131EXTERN t_garray *graph_array(t_glist *gl, t_symbol *s, t_symbol *tmpl,
1132 t_floatarg f, t_floatarg saveit);
1133EXTERN t_array *array_new(t_symbol *templatesym, t_gpointer *parent);
1134EXTERN void array_resize(t_array *x, t_template *tmpl, int n);
1135EXTERN void array_free(t_array *x);
1136
1137/* --------------------- gpointers and stubs ---------------- */
1138EXTERN t_gstub *gstub_new(t_glist *gl, t_array *a);
1139EXTERN void gstub_cutoff(t_gstub *gs);
1140EXTERN void gpointer_setglist(t_gpointer *gp, t_glist *glist, t_scalar *x);
1141
1142/* --------------------- scalars ------------------------- */
1143EXTERN void word_init(t_word *wp, t_template *tmpl, t_gpointer *gp);
1144EXTERN void word_restore(t_word *wp, t_template *tmpl,
1145 int argc, t_atom *argv);
1146EXTERN t_scalar *scalar_new(t_glist *owner,
1147 t_symbol *templatesym);
1148EXTERN void scalar_getbasexy(t_scalar *x, float *basex, float *basey);
1149
1150/* ------helper routines for "garrays" and "plots" -------------- */
1151EXTERN int array_doclick(t_array *array, t_glist *glist, t_gobj *gobj,
1152 t_symbol *elemtemplatesym,
1153 float linewidth, float xloc, float xinc, float yloc,
1154 int xpix, int ypix, int shift, int alt, int dbl, int doit);
1155
1156EXTERN void array_getcoordinate(t_glist *glist,
1157 char *elem, int xonset, int yonset, int wonset, int indx,
1158 float basex, float basey, float xinc,
1159 float *xp, float *yp, float *wp);
1160
1161EXTERN int array_getfields(t_symbol *elemtemplatesym,
1162 t_canvas **elemtemplatecanvasp,
1163 t_template **elemtemplatep, int *elemsizep,
1164 int *xonsetp, int *yonsetp, int *wonsetp);
1165
1166/* --------------------- templates ------------------------- */
1167EXTERN t_template *template_new(t_symbol *sym, int argc, t_atom *argv);
1168EXTERN void template_free(t_template *x);
1169EXTERN int template_match(t_template *x1, t_template *x2);
1170EXTERN int template_find_field(t_template *x, t_symbol *name, int *p_onset,
1171 int *p_type, t_symbol **p_arraytype);
1172EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname, t_word *wp,
1173 int loud);
1174EXTERN void template_setfloat(t_template *x, t_symbol *fieldname, t_word *wp,
1175 t_float f, int loud);
1176EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
1177 t_word *wp, int loud);
1178EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
1179 t_word *wp, t_symbol *s, int loud);
1180
1181EXTERN t_template *gtemplate_get(t_gtemplate *x);
1182EXTERN t_template *template_findbyname(t_symbol *s);
1183EXTERN t_canvas *template_findcanvas(t_template *tmpl);
1184
1185EXTERN t_float template_getfloat(t_template *x, t_symbol *fieldname,
1186 t_word *wp, int loud);
1187EXTERN void template_setfloat(t_template *x, t_symbol *fieldname,
1188 t_word *wp, t_float f, int loud);
1189EXTERN t_symbol *template_getsymbol(t_template *x, t_symbol *fieldname,
1190 t_word *wp, int loud);
1191EXTERN void template_setsymbol(t_template *x, t_symbol *fieldname,
1192 t_word *wp, t_symbol *s, int loud);
1193
1194/* ----------------------- guiconnects, g_guiconnect.c --------- */
1195EXTERN t_guiconnect *guiconnect_new(t_pd *who, t_symbol *sym);
1196EXTERN void guiconnect_notarget(t_guiconnect *x, double timedelay);
1197
1198/* ------------- IEMGUI routines used in other g_ files ---------------- */
1199EXTERN t_symbol *iemgui_raute2dollar(t_symbol *s);
1200EXTERN t_symbol *iemgui_dollar2raute(t_symbol *s);
1201
1202#if defined(_LANGUAGE_C_PLUS_PLUS) || defined(__cplusplus)
1203}
1204#endif