summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_rtext.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_rtext.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_rtext.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_rtext.c b/apps/plugins/pdbox/PDa/src/g_rtext.c
index 05c31a9ea7..03aea97e9b 100644
--- a/apps/plugins/pdbox/PDa/src/g_rtext.c
+++ b/apps/plugins/pdbox/PDa/src/g_rtext.c
@@ -6,6 +6,14 @@
6/* have to insert gui-objects into editor-list */ 6/* have to insert gui-objects into editor-list */
7/* all changes are labeled with iemlib */ 7/* all changes are labeled with iemlib */
8 8
9#ifdef ROCKBOX
10#include "plugin.h"
11#include "ctype.h"
12#include "pdbox.h"
13#include "m_pd.h"
14#include "g_canvas.h"
15#define snprintf rb->snprintf
16#else /* ROCKBOX */
9#include <stdlib.h> 17#include <stdlib.h>
10#include <string.h> 18#include <string.h>
11#include <stdio.h> 19#include <stdio.h>
@@ -14,6 +22,7 @@
14#include "s_stuff.h" 22#include "s_stuff.h"
15#include "g_canvas.h" 23#include "g_canvas.h"
16#include "t_tk.h" 24#include "t_tk.h"
25#endif /* ROCKBOX */
17 26
18#define LMARGIN 1 27#define LMARGIN 1
19#define RMARGIN 1 28#define RMARGIN 1
@@ -44,7 +53,9 @@ struct _rtext
44t_rtext *rtext_new(t_glist *glist, t_text *who) 53t_rtext *rtext_new(t_glist *glist, t_text *who)
45{ 54{
46 t_rtext *x = (t_rtext *)getbytes(sizeof *x); 55 t_rtext *x = (t_rtext *)getbytes(sizeof *x);
56#ifndef ROCKBOX
47 int w = 0, h = 0, indx; 57 int w = 0, h = 0, indx;
58#endif
48 x->x_height = -1; 59 x->x_height = -1;
49 x->x_text = who; 60 x->x_text = who;
50 x->x_glist = glist; 61 x->x_glist = glist;
@@ -53,8 +64,13 @@ t_rtext *rtext_new(t_glist *glist, t_text *who)
53 x->x_drawnwidth = x->x_drawnheight = 0; 64 x->x_drawnwidth = x->x_drawnheight = 0;
54 binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize); 65 binbuf_gettext(who->te_binbuf, &x->x_buf, &x->x_bufsize);
55 glist->gl_editor->e_rtext = x; 66 glist->gl_editor->e_rtext = x;
67#ifdef ROCKBOX
68 snprintf(x->x_tag, strlen(x->x_tag),
69 ".x%x.t%x", (t_int)glist_getcanvas(x->x_glist), (t_int)x);
70#else /* ROCKBOX */
56 sprintf(x->x_tag, ".x%x.t%x", (t_int)glist_getcanvas(x->x_glist), 71 sprintf(x->x_tag, ".x%x.t%x", (t_int)glist_getcanvas(x->x_glist),
57 (t_int)x); 72 (t_int)x);
73#endif /* ROCKBOX */
58 return (x); 74 return (x);
59} 75}
60 76
@@ -149,12 +165,18 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
149 char tempbuf[UPBUFSIZE], *tp = tempbuf, *bp = x->x_buf; 165 char tempbuf[UPBUFSIZE], *tp = tempbuf, *bp = x->x_buf;
150 int outchars, inchars = x->x_bufsize, nlines = 0, ncolumns = 0, 166 int outchars, inchars = x->x_bufsize, nlines = 0, ncolumns = 0,
151 pixwide, pixhigh; 167 pixwide, pixhigh;
168#ifdef ROCKBOX
169 int fontwidth = 8, fontheight = 10;
170#else
152 int font = glist_getfont(x->x_glist); 171 int font = glist_getfont(x->x_glist);
153 int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font); 172 int fontwidth = sys_fontwidth(font), fontheight = sys_fontheight(font);
173#endif
154 int findx = (*widthp + (fontwidth/2)) / fontwidth, 174 int findx = (*widthp + (fontwidth/2)) / fontwidth,
155 findy = *heightp / fontheight; 175 findy = *heightp / fontheight;
156 int reportedindex = 0; 176 int reportedindex = 0;
177#ifndef ROCKBOX
157 t_canvas *canvas = glist_getcanvas(x->x_glist); 178 t_canvas *canvas = glist_getcanvas(x->x_glist);
179#endif
158 int widthspec = x->x_text->te_width; 180 int widthspec = x->x_text->te_width;
159 int widthlimit = (widthspec ? widthspec : BOXWIDTH); 181 int widthlimit = (widthspec ? widthspec : BOXWIDTH);
160 while (inchars) 182 while (inchars)
@@ -214,16 +236,22 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
214 pixhigh = nlines * fontheight + (TMARGIN + BMARGIN); 236 pixhigh = nlines * fontheight + (TMARGIN + BMARGIN);
215 237
216 if (action == SEND_FIRST) 238 if (action == SEND_FIRST)
239#ifdef ROCKBOX
240 ;
241#else /* ROCKBOX */
217 sys_vgui("pdtk_text_new .x%x.c %s %f %f {%.*s} %d %s\n", 242 sys_vgui("pdtk_text_new .x%x.c %s %f %f {%.*s} %d %s\n",
218 canvas, x->x_tag, 243 canvas, x->x_tag,
219 dispx + LMARGIN, dispy + TMARGIN, 244 dispx + LMARGIN, dispy + TMARGIN,
220 outchars, tempbuf, sys_hostfontsize(font), 245 outchars, tempbuf, sys_hostfontsize(font),
221 (glist_isselected(x->x_glist, 246 (glist_isselected(x->x_glist,
222 &x->x_glist->gl_gobj)? "blue" : "black")); 247 &x->x_glist->gl_gobj)? "blue" : "black"));
248#endif /* ROCKBOX */
223 else if (action == SEND_UPDATE) 249 else if (action == SEND_UPDATE)
224 { 250 {
251#ifndef ROCKBOX
225 sys_vgui("pdtk_text_set .x%x.c %s {%.*s}\n", 252 sys_vgui("pdtk_text_set .x%x.c %s {%.*s}\n",
226 canvas, x->x_tag, outchars, tempbuf); 253 canvas, x->x_tag, outchars, tempbuf);
254#endif
227 if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight) 255 if (pixwide != x->x_drawnwidth || pixhigh != x->x_drawnheight)
228 text_drawborder(x->x_text, x->x_glist, x->x_tag, 256 text_drawborder(x->x_text, x->x_glist, x->x_tag,
229 pixwide, pixhigh, 0); 257 pixwide, pixhigh, 0);
@@ -231,18 +259,22 @@ static void rtext_senditup(t_rtext *x, int action, int *widthp, int *heightp,
231 { 259 {
232 if (x->x_selend > x->x_selstart) 260 if (x->x_selend > x->x_selstart)
233 { 261 {
262#ifndef ROCKBOX
234 sys_vgui(".x%x.c select from %s %d\n", canvas, 263 sys_vgui(".x%x.c select from %s %d\n", canvas,
235 x->x_tag, x->x_selstart); 264 x->x_tag, x->x_selstart);
236 sys_vgui(".x%x.c select to %s %d\n", canvas, 265 sys_vgui(".x%x.c select to %s %d\n", canvas,
237 x->x_tag, x->x_selend + (sys_oldtclversion ? 0 : -1)); 266 x->x_tag, x->x_selend + (sys_oldtclversion ? 0 : -1));
238 sys_vgui(".x%x.c focus \"\"\n", canvas); 267 sys_vgui(".x%x.c focus \"\"\n", canvas);
268#endif
239 } 269 }
240 else 270 else
241 { 271 {
272#ifndef ROCKBOX
242 sys_vgui(".x%x.c select clear\n", canvas); 273 sys_vgui(".x%x.c select clear\n", canvas);
243 sys_vgui(".x%x.c icursor %s %d\n", canvas, x->x_tag, 274 sys_vgui(".x%x.c icursor %s %d\n", canvas, x->x_tag,
244 x->x_selstart); 275 x->x_selstart);
245 sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag); 276 sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag);
277#endif
246 } 278 }
247 } 279 }
248 } 280 }
@@ -273,7 +305,9 @@ void rtext_retext(t_rtext *x)
273 int wantreduce = bufsize - text->te_width; 305 int wantreduce = bufsize - text->te_width;
274 char *decimal = 0, *nextchar, *ebuf = x->x_buf + bufsize, 306 char *decimal = 0, *nextchar, *ebuf = x->x_buf + bufsize,
275 *s1, *s2; 307 *s1, *s2;
308#ifndef ROCKBOX
276 int ndecimals; 309 int ndecimals;
310#endif
277 for (decimal = x->x_buf; decimal < ebuf; decimal++) 311 for (decimal = x->x_buf; decimal < ebuf; decimal++)
278 if (*decimal == '.') 312 if (*decimal == '.')
279 break; 313 break;
@@ -339,21 +373,35 @@ void rtext_draw(t_rtext *x)
339 373
340void rtext_erase(t_rtext *x) 374void rtext_erase(t_rtext *x)
341{ 375{
376#ifdef ROCKBOX
377 (void) x;
378#else
342 sys_vgui(".x%x.c delete %s\n", glist_getcanvas(x->x_glist), x->x_tag); 379 sys_vgui(".x%x.c delete %s\n", glist_getcanvas(x->x_glist), x->x_tag);
380#endif
343} 381}
344 382
345void rtext_displace(t_rtext *x, int dx, int dy) 383void rtext_displace(t_rtext *x, int dx, int dy)
346{ 384{
385#ifdef ROCKBOX
386 (void) x;
387 (void) dx;
388 (void) dy;
389#else /* ROCKBOX */
347 sys_vgui(".x%x.c move %s %d %d\n", glist_getcanvas(x->x_glist), 390 sys_vgui(".x%x.c move %s %d %d\n", glist_getcanvas(x->x_glist),
348 x->x_tag, dx, dy); 391 x->x_tag, dx, dy);
392#endif /* ROCKBOX */
349} 393}
350 394
351void rtext_select(t_rtext *x, int state) 395void rtext_select(t_rtext *x, int state)
352{ 396{
353 t_glist *glist = x->x_glist; 397 t_glist *glist = x->x_glist;
354 t_canvas *canvas = glist_getcanvas(glist); 398 t_canvas *canvas = glist_getcanvas(glist);
399#ifdef ROCKBOX
400 (void) state;
401#else /* ROCKBOX */
355 sys_vgui(".x%x.c itemconfigure %s -fill %s\n", canvas, 402 sys_vgui(".x%x.c itemconfigure %s -fill %s\n", canvas,
356 x->x_tag, (state? "blue" : "black")); 403 x->x_tag, (state? "blue" : "black"));
404#endif /* ROCKBOX */
357 canvas_editing = canvas; 405 canvas_editing = canvas;
358} 406}
359 407
@@ -361,10 +409,14 @@ void rtext_activate(t_rtext *x, int state)
361{ 409{
362 int w = 0, h = 0, indx; 410 int w = 0, h = 0, indx;
363 t_glist *glist = x->x_glist; 411 t_glist *glist = x->x_glist;
412#ifndef ROCKBOX
364 t_canvas *canvas = glist_getcanvas(glist); 413 t_canvas *canvas = glist_getcanvas(glist);
414#endif
365 if (state) 415 if (state)
366 { 416 {
417#ifndef ROCKBOX
367 sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag); 418 sys_vgui(".x%x.c focus %s\n", canvas, x->x_tag);
419#endif
368 glist->gl_editor->e_textedfor = x; 420 glist->gl_editor->e_textedfor = x;
369 glist->gl_editor->e_textdirty = 0; 421 glist->gl_editor->e_textdirty = 0;
370 x->x_dragfrom = x->x_selstart = 0; 422 x->x_dragfrom = x->x_selstart = 0;
@@ -373,8 +425,10 @@ void rtext_activate(t_rtext *x, int state)
373 } 425 }
374 else 426 else
375 { 427 {
428#ifndef ROCKBOX
376 sys_vgui("selection clear .x%x.c\n", canvas); 429 sys_vgui("selection clear .x%x.c\n", canvas);
377 sys_vgui(".x%x.c focus \"\"\n", canvas); 430 sys_vgui(".x%x.c focus \"\"\n", canvas);
431#endif
378 if (glist->gl_editor->e_textedfor == x) 432 if (glist->gl_editor->e_textedfor == x)
379 glist->gl_editor->e_textedfor = 0; 433 glist->gl_editor->e_textedfor = 0;
380 x->x_active = 0; 434 x->x_active = 0;
@@ -385,7 +439,9 @@ void rtext_activate(t_rtext *x, int state)
385void rtext_key(t_rtext *x, int keynum, t_symbol *keysym) 439void rtext_key(t_rtext *x, int keynum, t_symbol *keysym)
386{ 440{
387 int w = 0, h = 0, indx, i, newsize, ndel; 441 int w = 0, h = 0, indx, i, newsize, ndel;
442#ifndef ROCKBOX
388 char *s1, *s2; 443 char *s1, *s2;
444#endif
389 if (keynum) 445 if (keynum)
390 { 446 {
391 int n = keynum; 447 int n = keynum;