summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_editor.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_editor.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_editor.c144
1 files changed, 126 insertions, 18 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_editor.c b/apps/plugins/pdbox/PDa/src/g_editor.c
index 1190739e1a..a5cce20e10 100644
--- a/apps/plugins/pdbox/PDa/src/g_editor.c
+++ b/apps/plugins/pdbox/PDa/src/g_editor.c
@@ -2,6 +2,14 @@
2* For information on usage and redistribution, and for a DISCLAIMER OF ALL 2* For information on usage and redistribution, and for a DISCLAIMER OF ALL
3* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ 3* WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
4 4
5#ifdef ROCKBOX
6#include "plugin.h"
7#include "pdbox.h"
8#include "m_pd.h"
9#include "m_imp.h"
10#include "s_stuff.h"
11#include "g_canvas.h"
12#else /* ROCKBOX */
5#include <stdlib.h> 13#include <stdlib.h>
6#include <stdio.h> 14#include <stdio.h>
7#include "m_pd.h" 15#include "m_pd.h"
@@ -9,6 +17,7 @@
9#include "s_stuff.h" 17#include "s_stuff.h"
10#include "g_canvas.h" 18#include "g_canvas.h"
11#include <string.h> 19#include <string.h>
20#endif /* ROCKBOX */
12 21
13void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename, 22void glist_readfrombinbuf(t_glist *x, t_binbuf *b, char *filename,
14 int selectem); 23 int selectem);
@@ -88,8 +97,10 @@ void glist_selectline(t_glist *x, t_outconnect *oc, int index1,
88 x->gl_editor->e_selectline_index2 = index2; 97 x->gl_editor->e_selectline_index2 = index2;
89 x->gl_editor->e_selectline_inno = inno; 98 x->gl_editor->e_selectline_inno = inno;
90 x->gl_editor->e_selectline_tag = oc; 99 x->gl_editor->e_selectline_tag = oc;
100#ifndef ROCKBOX
91 sys_vgui(".x%x.c itemconfigure l%x -fill blue\n", 101 sys_vgui(".x%x.c itemconfigure l%x -fill blue\n",
92 x, x->gl_editor->e_selectline_tag); 102 x, x->gl_editor->e_selectline_tag);
103#endif
93 } 104 }
94} 105}
95 106
@@ -98,8 +109,10 @@ void glist_deselectline(t_glist *x)
98 if (x->gl_editor) 109 if (x->gl_editor)
99 { 110 {
100 x->gl_editor->e_selectedline = 0; 111 x->gl_editor->e_selectedline = 0;
112#ifndef ROCKBOX
101 sys_vgui(".x%x.c itemconfigure l%x -fill black\n", 113 sys_vgui(".x%x.c itemconfigure l%x -fill black\n",
102 x, x->gl_editor->e_selectline_tag); 114 x, x->gl_editor->e_selectline_tag);
115#endif
103 } 116 }
104} 117}
105 118
@@ -166,7 +179,7 @@ void glist_deselect(t_glist *x, t_gobj *y)
166 } 179 }
167 else 180 else
168 { 181 {
169 for (sel = x->gl_editor->e_selection; sel2 = sel->sel_next; 182 for(sel = x->gl_editor->e_selection; (sel2 = sel->sel_next);
170 sel = sel2) 183 sel = sel2)
171 { 184 {
172 if (sel2->sel_what == y) 185 if (sel2->sel_what == y)
@@ -217,7 +230,7 @@ void glist_selectall(t_glist *x)
217 x->gl_editor->e_selection = sel; 230 x->gl_editor->e_selection = sel;
218 sel->sel_what = y; 231 sel->sel_what = y;
219 gobj_select(y, x, 1); 232 gobj_select(y, x, 1);
220 while (y = y->g_next) 233 while((y = y->g_next))
221 { 234 {
222 t_selection *sel2 = (t_selection *)getbytes(sizeof(*sel2)); 235 t_selection *sel2 = (t_selection *)getbytes(sizeof(*sel2));
223 sel->sel_next = sel2; 236 sel->sel_next = sel2;
@@ -290,11 +303,13 @@ void canvas_setundo(t_canvas *x, t_undofn undofn, void *buf,
290 canvas_undo_buf = buf; 303 canvas_undo_buf = buf;
291 canvas_undo_whatnext = UNDO_UNDO; 304 canvas_undo_whatnext = UNDO_UNDO;
292 canvas_undo_name = name; 305 canvas_undo_name = name;
306#ifndef ROCKBOX
293 if (x && glist_isvisible(x) && glist_istoplevel(x)) 307 if (x && glist_isvisible(x) && glist_istoplevel(x))
294 /* enable undo in menu */ 308 /* enable undo in menu */
295 sys_vgui("pdtk_undomenu .x%x %s no\n", x, name); 309 sys_vgui("pdtk_undomenu .x%x %s no\n", x, name);
296 else if (hadone) 310 else if (hadone)
297 sys_vgui("pdtk_undomenu nobody no no\n"); 311 sys_vgui("pdtk_undomenu nobody no no\n");
312#endif
298} 313}
299 314
300 /* clear undo if it happens to be for the canvas x. 315 /* clear undo if it happens to be for the canvas x.
@@ -316,8 +331,10 @@ static void canvas_undo(t_canvas *x)
316 /* post("undo"); */ 331 /* post("undo"); */
317 (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_UNDO); 332 (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_UNDO);
318 /* enable redo in menu */ 333 /* enable redo in menu */
334#ifndef ROCKBOX
319 if (glist_isvisible(x) && glist_istoplevel(x)) 335 if (glist_isvisible(x) && glist_istoplevel(x))
320 sys_vgui("pdtk_undomenu .x%x no %s\n", x, canvas_undo_name); 336 sys_vgui("pdtk_undomenu .x%x no %s\n", x, canvas_undo_name);
337#endif
321 canvas_undo_whatnext = UNDO_REDO; 338 canvas_undo_whatnext = UNDO_REDO;
322 } 339 }
323} 340}
@@ -333,8 +350,10 @@ static void canvas_redo(t_canvas *x)
333 /* post("redo"); */ 350 /* post("redo"); */
334 (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_REDO); 351 (*canvas_undo_fn)(canvas_undo_canvas, canvas_undo_buf, UNDO_REDO);
335 /* enable undo in menu */ 352 /* enable undo in menu */
353#ifndef ROCKBOX
336 if (glist_isvisible(x) && glist_istoplevel(x)) 354 if (glist_isvisible(x) && glist_istoplevel(x))
337 sys_vgui("pdtk_undomenu .x%x %s no\n", x, canvas_undo_name); 355 sys_vgui("pdtk_undomenu .x%x %s no\n", x, canvas_undo_name);
356#endif
338 canvas_undo_whatnext = UNDO_UNDO; 357 canvas_undo_whatnext = UNDO_UNDO;
339 } 358 }
340} 359}
@@ -352,6 +371,9 @@ typedef struct _undo_connect
352static void *canvas_undo_set_disconnect(t_canvas *x, 371static void *canvas_undo_set_disconnect(t_canvas *x,
353 int index1, int outno, int index2, int inno) 372 int index1, int outno, int index2, int inno)
354{ 373{
374#ifdef ROCKBOX
375 (void) x;
376#endif
355 t_undo_connect *buf = (t_undo_connect *)getbytes(sizeof(*buf)); 377 t_undo_connect *buf = (t_undo_connect *)getbytes(sizeof(*buf));
356 buf->u_index1 = index1; 378 buf->u_index1 = index1;
357 buf->u_outletno = outno; 379 buf->u_outletno = outno;
@@ -366,14 +388,16 @@ void canvas_disconnect(t_canvas *x,
366 t_linetraverser t; 388 t_linetraverser t;
367 t_outconnect *oc; 389 t_outconnect *oc;
368 linetraverser_start(&t, x); 390 linetraverser_start(&t, x);
369 while (oc = linetraverser_next(&t)) 391 while((oc = linetraverser_next(&t)))
370 { 392 {
371 int srcno = canvas_getindex(x, &t.tr_ob->ob_g); 393 int srcno = canvas_getindex(x, &t.tr_ob->ob_g);
372 int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g); 394 int sinkno = canvas_getindex(x, &t.tr_ob2->ob_g);
373 if (srcno == index1 && t.tr_outno == outno && 395 if (srcno == index1 && t.tr_outno == outno &&
374 sinkno == index2 && t.tr_inno == inno) 396 sinkno == index2 && t.tr_inno == inno)
375 { 397 {
398#ifndef ROCKBOX
376 sys_vgui(".x%x.c delete l%x\n", x, oc); 399 sys_vgui(".x%x.c delete l%x\n", x, oc);
400#endif
377 obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno); 401 obj_disconnect(t.tr_ob, t.tr_outno, t.tr_ob2, t.tr_inno);
378 break; 402 break;
379 } 403 }
@@ -432,7 +456,9 @@ typedef struct _undo_cut
432static void *canvas_undo_set_cut(t_canvas *x, int mode) 456static void *canvas_undo_set_cut(t_canvas *x, int mode)
433{ 457{
434 t_undo_cut *buf; 458 t_undo_cut *buf;
459#ifndef ROCKBOX
435 t_gobj *y; 460 t_gobj *y;
461#endif
436 t_linetraverser t; 462 t_linetraverser t;
437 t_outconnect *oc; 463 t_outconnect *oc;
438 int nnotsel= glist_selectionindex(x, 0, 0); 464 int nnotsel= glist_selectionindex(x, 0, 0);
@@ -443,7 +469,7 @@ static void *canvas_undo_set_cut(t_canvas *x, int mode)
443 /* store connections into/out of the selection */ 469 /* store connections into/out of the selection */
444 buf->u_reconnectbuf = binbuf_new(); 470 buf->u_reconnectbuf = binbuf_new();
445 linetraverser_start(&t, x); 471 linetraverser_start(&t, x);
446 while (oc = linetraverser_next(&t)) 472 while((oc = linetraverser_next(&t)))
447 { 473 {
448 int issel1 = glist_isselected(x, &t.tr_ob->ob_g); 474 int issel1 = glist_isselected(x, &t.tr_ob->ob_g);
449 int issel2 = glist_isselected(x, &t.tr_ob2->ob_g); 475 int issel2 = glist_isselected(x, &t.tr_ob2->ob_g);
@@ -488,7 +514,7 @@ static void canvas_undo_cut(t_canvas *x, void *z, int action)
488 { 514 {
489 t_gobj *y1, *y2; 515 t_gobj *y1, *y2;
490 glist_noselect(x); 516 glist_noselect(x);
491 for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2) 517 for(y1 = x->gl_list; (y2 = y1->g_next); y1 = y2)
492 ; 518 ;
493 if (y1) 519 if (y1)
494 { 520 {
@@ -514,7 +540,7 @@ static void canvas_undo_cut(t_canvas *x, void *z, int action)
514 else if (mode == UCUT_TEXT) 540 else if (mode == UCUT_TEXT)
515 { 541 {
516 t_gobj *y1, *y2; 542 t_gobj *y1, *y2;
517 for (y1 = x->gl_list; y2 = y1->g_next; y1 = y2) 543 for(y1 = x->gl_list; (y2 = y1->g_next); y1 = y2)
518 ; 544 ;
519 if (y1) 545 if (y1)
520 glist_delete(x, y1); 546 glist_delete(x, y1);
@@ -738,7 +764,9 @@ void canvas_setcursor(t_canvas *x, unsigned int cursornum)
738 } 764 }
739 if (xwas != x || cursorwas != cursornum) 765 if (xwas != x || cursorwas != cursornum)
740 { 766 {
767#ifndef ROCKBOX
741 sys_vgui(".x%x configure -cursor %s\n", x, cursorlist[cursornum]); 768 sys_vgui(".x%x configure -cursor %s\n", x, cursorlist[cursornum]);
769#endif
742 xwas = x; 770 xwas = x;
743 cursorwas = cursornum; 771 cursorwas = cursornum;
744 } 772 }
@@ -784,8 +812,14 @@ static void canvas_rightclick(t_canvas *x, int xpos, int ypos, t_gobj *y)
784 int canprop, canopen; 812 int canprop, canopen;
785 canprop = (!y || (y && class_getpropertiesfn(pd_class(&y->g_pd)))); 813 canprop = (!y || (y && class_getpropertiesfn(pd_class(&y->g_pd))));
786 canopen = (y && zgetfn(&y->g_pd, gensym("menu-open"))); 814 canopen = (y && zgetfn(&y->g_pd, gensym("menu-open")));
815#ifdef ROCKBOX
816 (void) x;
817 (void) xpos;
818 (void) ypos;
819#else /* ROCKBOX */
787 sys_vgui("pdtk_canvas_popup .x%x %d %d %d %d\n", 820 sys_vgui("pdtk_canvas_popup .x%x %d %d %d %d\n",
788 x, xpos, ypos, canprop, canopen); 821 x, xpos, ypos, canprop, canopen);
822#endif /* ROCKBOX */
789} 823}
790 824
791 /* tell GUI to create a properties dialog on the canvas. We tell 825 /* tell GUI to create a properties dialog on the canvas. We tell
@@ -793,11 +827,15 @@ static void canvas_rightclick(t_canvas *x, int xpos, int ypos, t_gobj *y)
793 naturally upward, whereas pixels grow downward. */ 827 naturally upward, whereas pixels grow downward. */
794static void canvas_properties(t_glist *x) 828static void canvas_properties(t_glist *x)
795{ 829{
830#ifdef ROCKBOX
831 (void) x;
832#else /* ROCKBOX */
796 char graphbuf[200]; 833 char graphbuf[200];
797 sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %g %g \n", 834 sprintf(graphbuf, "pdtk_canvas_dialog %%s %g %g %g %g \n",
798 glist_dpixtodx(x, 1), -glist_dpixtody(x, 1), 835 glist_dpixtodx(x, 1), -glist_dpixtody(x, 1),
799 (float)glist_isgraph(x), (float)x->gl_stretch); 836 (float)glist_isgraph(x), (float)x->gl_stretch);
800 gfxstub_new(&x->gl_pd, x, graphbuf); 837 gfxstub_new(&x->gl_pd, x, graphbuf);
838#endif /* ROCKBOX */
801} 839}
802 840
803 841
@@ -885,7 +923,11 @@ static void canvas_donecanvasdialog(t_glist *x, t_floatarg xperpix,
885 "open," or "help." */ 923 "open," or "help." */
886static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos) 924static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos)
887{ 925{
926#ifdef ROCKBOX
927 char namebuf[MAXPDSTRING];
928#else
888 char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING]; 929 char pathbuf[MAXPDSTRING], namebuf[MAXPDSTRING];
930#endif
889 t_gobj *y; 931 t_gobj *y;
890 for (y = x->gl_list; y; y = y->g_next) 932 for (y = x->gl_list; y; y = y->g_next)
891 { 933 {
@@ -936,9 +978,11 @@ static void canvas_done_popup(t_canvas *x, float which, float xpos, float ypos)
936 canvas_properties(x); 978 canvas_properties(x);
937 else if (which == 2) 979 else if (which == 2)
938 { 980 {
981#ifndef ROCKBOX
939 strcpy(pathbuf, sys_libdir->s_name); 982 strcpy(pathbuf, sys_libdir->s_name);
940 strcat(pathbuf, "/doc/5.reference/0.INTRO.txt"); 983 strcat(pathbuf, "/doc/5.reference/0.INTRO.txt");
941 sys_vgui("menu_opentext %s\n", pathbuf); 984 sys_vgui("menu_opentext %s\n", pathbuf);
985#endif
942 } 986 }
943} 987}
944 988
@@ -967,7 +1011,11 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
967 t_gobj *y; 1011 t_gobj *y;
968 int shiftmod, runmode, altmod, rightclick; 1012 int shiftmod, runmode, altmod, rightclick;
969 int x1, y1, x2, y2, clickreturned = 0; 1013 int x1, y1, x2, y2, clickreturned = 0;
970 1014
1015#ifdef ROCKBOX
1016 (void) which;
1017#endif
1018
971 if (!x->gl_editor) 1019 if (!x->gl_editor)
972 { 1020 {
973 bug("editor"); 1021 bug("editor");
@@ -1027,7 +1075,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
1027 return; 1075 return;
1028 } 1076 }
1029 /* if not a runmode left click, fall here. */ 1077 /* if not a runmode left click, fall here. */
1030 if (y = canvas_findhitbox(x, xpos, ypos, &x1, &y1, &x2, &y2)) 1078 if((y = canvas_findhitbox(x, xpos, ypos, &x1, &y1, &x2, &y2)))
1031 { 1079 {
1032 t_object *ob = pd_checkobject(&y->g_pd); 1080 t_object *ob = pd_checkobject(&y->g_pd);
1033 /* check you're in the rectangle */ 1081 /* check you're in the rectangle */
@@ -1071,14 +1119,18 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
1071 { 1119 {
1072 if (doit) 1120 if (doit)
1073 { 1121 {
1122#ifndef ROCKBOX
1074 int issignal = obj_issignaloutlet(ob, closest); 1123 int issignal = obj_issignaloutlet(ob, closest);
1124#endif
1075 x->gl_editor->e_onmotion = MA_CONNECT; 1125 x->gl_editor->e_onmotion = MA_CONNECT;
1076 x->gl_editor->e_xwas = xpos; 1126 x->gl_editor->e_xwas = xpos;
1077 x->gl_editor->e_ywas = ypos; 1127 x->gl_editor->e_ywas = ypos;
1128#ifndef ROCKBOX
1078 sys_vgui( 1129 sys_vgui(
1079 ".x%x.c create line %d %d %d %d -width %d -tags x\n", 1130 ".x%x.c create line %d %d %d %d -width %d -tags x\n",
1080 x, xpos, ypos, xpos, ypos, 1131 x, xpos, ypos, xpos, ypos,
1081 (issignal ? 2 : 1)); 1132 (issignal ? 2 : 1));
1133#endif
1082 } 1134 }
1083 else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT); 1135 else canvas_setcursor(x, CURSOR_EDITMODE_CONNECT);
1084 } 1136 }
@@ -1134,7 +1186,7 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
1134 float fx = xpos, fy = ypos; 1186 float fx = xpos, fy = ypos;
1135 t_glist *glist2 = glist_getcanvas(x); 1187 t_glist *glist2 = glist_getcanvas(x);
1136 linetraverser_start(&t, glist2); 1188 linetraverser_start(&t, glist2);
1137 while (oc = linetraverser_next(&t)) 1189 while((oc = linetraverser_next(&t)))
1138 { 1190 {
1139 float lx1 = t.tr_lx1, ly1 = t.tr_ly1, 1191 float lx1 = t.tr_lx1, ly1 = t.tr_ly1,
1140 lx2 = t.tr_lx2, ly2 = t.tr_ly2; 1192 lx2 = t.tr_lx2, ly2 = t.tr_ly2;
@@ -1158,8 +1210,10 @@ void canvas_doclick(t_canvas *x, int xpos, int ypos, int which,
1158 if (doit) 1210 if (doit)
1159 { 1211 {
1160 if (!shiftmod) glist_noselect(x); 1212 if (!shiftmod) glist_noselect(x);
1213#ifndef ROCKBOX
1161 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags x\n", 1214 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags x\n",
1162 x, xpos, ypos, xpos, ypos); 1215 x, xpos, ypos, xpos, ypos);
1216#endif
1163 x->gl_editor->e_xwas = xpos; 1217 x->gl_editor->e_xwas = xpos;
1164 x->gl_editor->e_ywas = ypos; 1218 x->gl_editor->e_ywas = ypos;
1165 x->gl_editor->e_onmotion = MA_REGION; 1219 x->gl_editor->e_onmotion = MA_REGION;
@@ -1178,7 +1232,7 @@ int canvas_isconnected (t_canvas *x, t_text *ob1, int n1,
1178 t_linetraverser t; 1232 t_linetraverser t;
1179 t_outconnect *oc; 1233 t_outconnect *oc;
1180 linetraverser_start(&t, x); 1234 linetraverser_start(&t, x);
1181 while (oc = linetraverser_next(&t)) 1235 while((oc = linetraverser_next(&t)))
1182 if (t.tr_ob == ob1 && t.tr_outno == n1 && 1236 if (t.tr_ob == ob1 && t.tr_outno == n1 &&
1183 t.tr_ob2 == ob2 && t.tr_inno == n2) 1237 t.tr_ob2 == ob2 && t.tr_inno == n2)
1184 return (1); 1238 return (1);
@@ -1193,10 +1247,15 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
1193 t_gobj *y2; 1247 t_gobj *y2;
1194 int xwas = x->gl_editor->e_xwas, 1248 int xwas = x->gl_editor->e_xwas,
1195 ywas = x->gl_editor->e_ywas; 1249 ywas = x->gl_editor->e_ywas;
1250#ifdef ROCKBOX
1251 (void) which;
1252#endif /* ROCKBOX */
1253#ifndef ROCKBOX
1196 if (doit) sys_vgui(".x%x.c delete x\n", x); 1254 if (doit) sys_vgui(".x%x.c delete x\n", x);
1197 else sys_vgui(".x%x.c coords x %d %d %d %d\n", 1255 else sys_vgui(".x%x.c coords x %d %d %d %d\n",
1198 x, x->gl_editor->e_xwas, 1256 x, x->gl_editor->e_xwas,
1199 x->gl_editor->e_ywas, xpos, ypos); 1257 x->gl_editor->e_ywas, xpos, ypos);
1258#endif /* ROCKBOX */
1200 1259
1201 if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12)) 1260 if ((y1 = canvas_findhitbox(x, xwas, ywas, &x11, &y11, &x12, &y12))
1202 && (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22))) 1261 && (y2 = canvas_findhitbox(x, xpos, ypos, &x21, &y21, &x22, &y22)))
@@ -1258,10 +1317,12 @@ void canvas_doconnect(t_canvas *x, int xpos, int ypos, int which, int doit)
1258 ((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0) 1317 ((x22-x21-IOWIDTH) * closest2)/(ninlet2-1) : 0)
1259 + IOMIDDLE; 1318 + IOMIDDLE;
1260 ly2 = y21; 1319 ly2 = y21;
1320#ifndef ROCKBOX
1261 sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", 1321 sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
1262 glist_getcanvas(x), 1322 glist_getcanvas(x),
1263 lx1, ly1, lx2, ly2, 1323 lx1, ly1, lx2, ly2,
1264 (obj_issignaloutlet(ob1, closest1) ? 2 : 1), oc); 1324 (obj_issignaloutlet(ob1, closest1) ? 2 : 1), oc);
1325#endif /* ROCKBOX */
1265 canvas_setundo(x, canvas_undo_connect, 1326 canvas_setundo(x, canvas_undo_connect,
1266 canvas_undo_set_connect(x, 1327 canvas_undo_set_connect(x,
1267 canvas_getindex(x, &ob1->ob_g), closest1, 1328 canvas_getindex(x, &ob1->ob_g), closest1,
@@ -1300,12 +1361,16 @@ static void canvas_doregion(t_canvas *x, int xpos, int ypos, int doit)
1300 loy = x->gl_editor->e_ywas, hiy = ypos; 1361 loy = x->gl_editor->e_ywas, hiy = ypos;
1301 else hiy = x->gl_editor->e_ywas, loy = ypos; 1362 else hiy = x->gl_editor->e_ywas, loy = ypos;
1302 canvas_selectinrect(x, lox, loy, hix, hiy); 1363 canvas_selectinrect(x, lox, loy, hix, hiy);
1364#ifndef ROCKBOX
1303 sys_vgui(".x%x.c delete x\n", x); 1365 sys_vgui(".x%x.c delete x\n", x);
1366#endif
1304 x->gl_editor->e_onmotion = 0; 1367 x->gl_editor->e_onmotion = 0;
1305 } 1368 }
1369#ifndef ROCKBOX
1306 else sys_vgui(".x%x.c coords x %d %d %d %d\n", 1370 else sys_vgui(".x%x.c coords x %d %d %d %d\n",
1307 x, x->gl_editor->e_xwas, 1371 x, x->gl_editor->e_xwas,
1308 x->gl_editor->e_ywas, xpos, ypos); 1372 x->gl_editor->e_ywas, xpos, ypos);
1373#endif
1309} 1374}
1310 1375
1311void canvas_mouseup(t_canvas *x, 1376void canvas_mouseup(t_canvas *x,
@@ -1395,7 +1460,11 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
1395 t_symbol *gotkeysym; 1460 t_symbol *gotkeysym;
1396 1461
1397 int down, shift; 1462 int down, shift;
1398 1463
1464#ifdef ROCKBOX
1465 (void) s;
1466#endif
1467
1399 if (ac < 3) 1468 if (ac < 3)
1400 return; 1469 return;
1401 if (!x->gl_editor) 1470 if (!x->gl_editor)
@@ -1411,7 +1480,11 @@ void canvas_key(t_canvas *x, t_symbol *s, int ac, t_atom *av)
1411 else if (av[1].a_type == A_FLOAT) 1480 else if (av[1].a_type == A_FLOAT)
1412 { 1481 {
1413 char buf[3]; 1482 char buf[3];
1483#ifdef ROCKBOX
1484 snprintf(buf, sizeof(buf)-1, "%c", (int)(av[1].a_w.w_float));
1485#else /* ROCKBOX */
1414 sprintf(buf, "%c", (int)(av[1].a_w.w_float)); 1486 sprintf(buf, "%c", (int)(av[1].a_w.w_float));
1487#endif /* ROCKBOX */
1415 gotkeysym = gensym(buf); 1488 gotkeysym = gensym(buf);
1416 } 1489 }
1417 else gotkeysym = gensym("?"); 1490 else gotkeysym = gensym("?");
@@ -1559,8 +1632,13 @@ void canvas_startmotion(t_canvas *x)
1559 1632
1560void canvas_print(t_canvas *x, t_symbol *s) 1633void canvas_print(t_canvas *x, t_symbol *s)
1561{ 1634{
1635#ifdef ROCKBOX
1636 (void) x;
1637 (void) s;
1638#else /* ROCKBOX */
1562 if (*s->s_name) sys_vgui(".x%x.c postscript -file %s\n", x, s->s_name); 1639 if (*s->s_name) sys_vgui(".x%x.c postscript -file %s\n", x, s->s_name);
1563 else sys_vgui(".x%x.c postscript -file x.ps\n", x); 1640 else sys_vgui(".x%x.c postscript -file x.ps\n", x);
1641#endif /* ROCKBOX */
1564} 1642}
1565 1643
1566void canvas_menuclose(t_canvas *x, t_floatarg force) 1644void canvas_menuclose(t_canvas *x, t_floatarg force)
@@ -1569,18 +1647,24 @@ void canvas_menuclose(t_canvas *x, t_floatarg force)
1569 canvas_vis(x, 0); 1647 canvas_vis(x, 0);
1570 else if ((force != 0) || (!x->gl_dirty)) 1648 else if ((force != 0) || (!x->gl_dirty))
1571 pd_free(&x->gl_pd); 1649 pd_free(&x->gl_pd);
1650#ifndef ROCKBOX
1572 else sys_vgui("pdtk_check {This window has been modified. Close anyway?}\ 1651 else sys_vgui("pdtk_check {This window has been modified. Close anyway?}\
1573 {.x%x menuclose 1;\n}\n", x); 1652 {.x%x menuclose 1;\n}\n", x);
1653#endif
1574} 1654}
1575 1655
1576 /* put up a dialog which may call canvas_font back to do the work */ 1656 /* put up a dialog which may call canvas_font back to do the work */
1577static void canvas_menufont(t_canvas *x) 1657static void canvas_menufont(t_canvas *x)
1578{ 1658{
1659#ifdef ROCKBOX
1660 (void) x;
1661#else /* ROCKBOX */
1579 char buf[80]; 1662 char buf[80];
1580 t_canvas *x2 = canvas_getrootfor(x); 1663 t_canvas *x2 = canvas_getrootfor(x);
1581 gfxstub_deleteforkey(x2); 1664 gfxstub_deleteforkey(x2);
1582 sprintf(buf, "pdtk_canvas_dofont %%s %d\n", x2->gl_font); 1665 sprintf(buf, "pdtk_canvas_dofont %%s %d\n", x2->gl_font);
1583 gfxstub_new(&x2->gl_pd, &x2->gl_pd, buf); 1666 gfxstub_new(&x2->gl_pd, &x2->gl_pd, buf);
1667#endif /* ROCKBOX */
1584} 1668}
1585 1669
1586static int canvas_find_index1, canvas_find_index2; 1670static int canvas_find_index1, canvas_find_index2;
@@ -1598,13 +1682,13 @@ static int canvas_dofind(t_canvas *x, int *myindex1p)
1598 y = y->g_next, myindex2++) 1682 y = y->g_next, myindex2++)
1599 { 1683 {
1600 t_object *ob = 0; 1684 t_object *ob = 0;
1601 if (ob = pd_checkobject(&y->g_pd)) 1685 if((ob = pd_checkobject(&y->g_pd)))
1602 { 1686 {
1603 if (binbuf_match(ob->ob_binbuf, canvas_findbuf)) 1687 if (binbuf_match(ob->ob_binbuf, canvas_findbuf))
1604 { 1688 {
1605 if (myindex1 > canvas_find_index1 || 1689 if (myindex1 > canvas_find_index1 ||
1606 myindex1 == canvas_find_index1 && 1690 (myindex1 == canvas_find_index1 &&
1607 myindex2 > canvas_find_index2) 1691 myindex2 > canvas_find_index2))
1608 { 1692 {
1609 canvas_find_index1 = myindex1; 1693 canvas_find_index1 = myindex1;
1610 canvas_find_index2 = myindex2; 1694 canvas_find_index2 = myindex2;
@@ -1633,6 +1717,9 @@ static int canvas_dofind(t_canvas *x, int *myindex1p)
1633static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av) 1717static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av)
1634{ 1718{
1635 int myindex1 = 0, i; 1719 int myindex1 = 0, i;
1720#ifdef ROCKBOX
1721 (void) s;
1722#endif
1636 for (i = 0; i < ac; i++) 1723 for (i = 0; i < ac; i++)
1637 { 1724 {
1638 if (av[i].a_type == A_SYMBOL) 1725 if (av[i].a_type == A_SYMBOL)
@@ -1660,6 +1747,9 @@ static void canvas_find(t_canvas *x, t_symbol *s, int ac, t_atom *av)
1660static void canvas_find_again(t_canvas *x) 1747static void canvas_find_again(t_canvas *x)
1661{ 1748{
1662 int myindex1 = 0; 1749 int myindex1 = 0;
1750#ifdef ROCKBOX
1751 (void) x;
1752#endif
1663 if (!canvas_findbuf || !canvas_whichfind) 1753 if (!canvas_findbuf || !canvas_whichfind)
1664 return; 1754 return;
1665 if (!canvas_dofind(canvas_whichfind, &myindex1)) 1755 if (!canvas_dofind(canvas_whichfind, &myindex1))
@@ -1756,7 +1846,7 @@ void canvas_stowconnections(t_canvas *x)
1756 /* add connections to binbuf */ 1846 /* add connections to binbuf */
1757 binbuf_clear(x->gl_editor->e_connectbuf); 1847 binbuf_clear(x->gl_editor->e_connectbuf);
1758 linetraverser_start(&t, x); 1848 linetraverser_start(&t, x);
1759 while (oc = linetraverser_next(&t)) 1849 while((oc = linetraverser_next(&t)))
1760 { 1850 {
1761 int s1 = glist_isselected(x, &t.tr_ob->ob_g); 1851 int s1 = glist_isselected(x, &t.tr_ob->ob_g);
1762 int s2 = glist_isselected(x, &t.tr_ob2->ob_g); 1852 int s2 = glist_isselected(x, &t.tr_ob2->ob_g);
@@ -1787,7 +1877,7 @@ static t_binbuf *canvas_docopy(t_canvas *x)
1787 gobj_save(y, b); 1877 gobj_save(y, b);
1788 } 1878 }
1789 linetraverser_start(&t, x); 1879 linetraverser_start(&t, x);
1790 while (oc = linetraverser_next(&t)) 1880 while((oc = linetraverser_next(&t)))
1791 { 1881 {
1792 if (glist_isselected(x, &t.tr_ob->ob_g) 1882 if (glist_isselected(x, &t.tr_ob->ob_g)
1793 && glist_isselected(x, &t.tr_ob2->ob_g)) 1883 && glist_isselected(x, &t.tr_ob2->ob_g))
@@ -1912,7 +2002,11 @@ static void glist_donewloadbangs(t_glist *x)
1912 2002
1913static void canvas_dopaste(t_canvas *x, t_binbuf *b) 2003static void canvas_dopaste(t_canvas *x, t_binbuf *b)
1914{ 2004{
2005#ifdef ROCKBOX
2006 t_gobj *g2;
2007#else /* ROCKBOX */
1915 t_gobj *newgobj, *last, *g2; 2008 t_gobj *newgobj, *last, *g2;
2009#endif /* ROCKBOX */
1916 int dspstate = canvas_suspend_dsp(), nbox, count; 2010 int dspstate = canvas_suspend_dsp(), nbox, count;
1917 2011
1918 canvas_editmode(x, 1.); 2012 canvas_editmode(x, 1.);
@@ -1987,9 +2081,11 @@ void canvas_connect(t_canvas *x, t_floatarg fwhoout, t_floatarg foutno,
1987 if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad; 2081 if (!(oc = obj_connect(objsrc, outno, objsink, inno))) goto bad;
1988 if (glist_isvisible(x)) 2082 if (glist_isvisible(x))
1989 { 2083 {
2084#ifndef ROCKBOX
1990 sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n", 2085 sys_vgui(".x%x.c create line %d %d %d %d -width %d -tags l%x\n",
1991 glist_getcanvas(x), 0, 0, 0, 0, 2086 glist_getcanvas(x), 0, 0, 0, 0,
1992 (obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc); 2087 (obj_issignaloutlet(objsrc, outno) ? 2 : 1),oc);
2088#endif
1993 canvas_fixlinesfor(x, objsrc); 2089 canvas_fixlinesfor(x, objsrc);
1994 } 2090 }
1995 return; 2091 return;
@@ -2008,7 +2104,11 @@ bad:
2008 /* LATER might have to speed this up */ 2104 /* LATER might have to speed this up */
2009static void canvas_tidy(t_canvas *x) 2105static void canvas_tidy(t_canvas *x)
2010{ 2106{
2107#ifdef ROCKBOX
2108 t_gobj *y, *y2;
2109#else /* ROCKBOX */
2011 t_gobj *y, *y2, *y3; 2110 t_gobj *y, *y2, *y3;
2111#endif /* ROCKBOX */
2012 int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2; 2112 int ax1, ay1, ax2, ay2, bx1, by1, bx2, by2;
2013 int histogram[NHIST], *ip, i, besthist, bestdist; 2113 int histogram[NHIST], *ip, i, besthist, bestdist;
2014 /* if nobody is selected, this means do it to all boxes; 2114 /* if nobody is selected, this means do it to all boxes;
@@ -2114,15 +2214,19 @@ static void canvas_texteditor(t_canvas *x)
2114 t_rtext *foo; 2214 t_rtext *foo;
2115 char *buf; 2215 char *buf;
2116 int bufsize; 2216 int bufsize;
2117 if (foo = x->gl_editor->e_textedfor) 2217 if((foo = x->gl_editor->e_textedfor))
2118 rtext_gettext(foo, &buf, &bufsize); 2218 rtext_gettext(foo, &buf, &bufsize);
2119 else buf = "", bufsize = 0; 2219 else buf = "", bufsize = 0;
2220#ifndef ROCKBOX
2120 sys_vgui("pdtk_pd_texteditor {%.*s}\n", bufsize, buf); 2221 sys_vgui("pdtk_pd_texteditor {%.*s}\n", bufsize, buf);
2121 2222#endif
2122} 2223}
2123 2224
2124void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av) 2225void glob_key(void *dummy, t_symbol *s, int ac, t_atom *av)
2125{ 2226{
2227#ifdef ROCKBOX
2228 (void) dummy;
2229#endif
2126 /* canvas_editing can be zero; canvas_key checks for that */ 2230 /* canvas_editing can be zero; canvas_key checks for that */
2127 canvas_key(canvas_editing, s, ac, av); 2231 canvas_key(canvas_editing, s, ac, av);
2128} 2232}
@@ -2141,8 +2245,10 @@ void canvas_editmode(t_canvas *x, t_floatarg fyesplease)
2141 if (glist_isvisible(x) && glist_istoplevel(x)) 2245 if (glist_isvisible(x) && glist_istoplevel(x))
2142 canvas_setcursor(x, CURSOR_RUNMODE_NOTHING); 2246 canvas_setcursor(x, CURSOR_RUNMODE_NOTHING);
2143 } 2247 }
2248#ifndef ROCKBOX
2144 sys_vgui("pdtk_canvas_editval .x%x %d\n", 2249 sys_vgui("pdtk_canvas_editval .x%x %d\n",
2145 glist_getcanvas(x), x->gl_edit); 2250 glist_getcanvas(x), x->gl_edit);
2251#endif
2146} 2252}
2147 2253
2148 /* called by canvas_font below */ 2254 /* called by canvas_font below */
@@ -2188,7 +2294,9 @@ static void canvas_font(t_canvas *x, t_floatarg font, t_floatarg resize,
2188 if (whichresize != 3) realresx = realresize; 2294 if (whichresize != 3) realresx = realresize;
2189 if (whichresize != 2) realresy = realresize; 2295 if (whichresize != 2) realresy = realresize;
2190 canvas_dofont(x2, font, realresx, realresy); 2296 canvas_dofont(x2, font, realresx, realresy);
2297#ifndef ROCKBOX
2191 sys_defaultfont = font; 2298 sys_defaultfont = font;
2299#endif
2192} 2300}
2193 2301
2194static t_glist *canvas_last_glist; 2302static t_glist *canvas_last_glist;