summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/extra/image.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/extra/image.c')
-rw-r--r--apps/plugins/pdbox/PDa/extra/image.c217
1 files changed, 0 insertions, 217 deletions
diff --git a/apps/plugins/pdbox/PDa/extra/image.c b/apps/plugins/pdbox/PDa/extra/image.c
index 6de48ef8fb..946a363986 100644
--- a/apps/plugins/pdbox/PDa/extra/image.c
+++ b/apps/plugins/pdbox/PDa/extra/image.c
@@ -215,220 +215,3 @@ void image_setup(void)
215} 215}
216 216
217 217
218#include "m_pd.h"
219#include "g_canvas.h"
220
221#ifdef NT
222#pragma warning( disable : 4244 )
223#pragma warning( disable : 4305 )
224#endif
225
226/* ------------------------ image ----------------------------- */
227
228static t_class *image_class;
229
230typedef struct _image
231{
232 t_object x_obj;
233 t_glist * x_glist;
234 int x_width;
235 int x_height;
236 t_symbol* x_fname;
237} t_image;
238
239/* widget helper functions */
240
241void image_drawme(t_image *x, t_glist *glist, int firsttime)
242{
243 if (firsttime) {
244 char fname[MAXPDSTRING];
245 canvas_makefilename(glist_getcanvas(x->x_glist), x->x_fname->s_name,
246 fname, MAXPDSTRING);
247
248 sys_vgui("image create photo img%x -file %s\n",x,fname);
249 sys_vgui(".x%x.c create image %d %d -image img%x -tags %xS\n",
250 glist_getcanvas(glist),text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x,x);
251
252 /* TODO callback from gui
253 sys_vgui("image_size logo");
254 */
255 }
256 else {
257 sys_vgui(".x%x.c coords %xS \
258%d %d\n",
259 glist_getcanvas(glist), x,
260 text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
261 }
262
263}
264
265
266void image_erase(t_image* x,t_glist* glist)
267{
268 int n;
269 sys_vgui(".x%x.c delete %xS\n",
270 glist_getcanvas(glist), x);
271
272}
273
274
275
276/* ------------------------ image widgetbehaviour----------------------------- */
277
278
279static void image_getrect(t_gobj *z, t_glist *glist,
280 int *xp1, int *yp1, int *xp2, int *yp2)
281{
282 int width, height;
283 t_image* x = (t_image*)z;
284
285
286 width = x->x_width;
287 height = x->x_height;
288 *xp1 = text_xpix(&x->x_obj, glist);
289 *yp1 = text_ypix(&x->x_obj, glist);
290 *xp2 = text_xpix(&x->x_obj, glist) + width;
291 *yp2 = text_ypix(&x->x_obj, glist) + height;
292}
293
294static void image_displace(t_gobj *z, t_glist *glist,
295 int dx, int dy)
296{
297 t_image *x = (t_image *)z;
298 x->x_obj.te_xpix += dx;
299 x->x_obj.te_ypix += dy;
300 sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
301 glist_getcanvas(glist), x,
302 text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
303 text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height);
304
305 image_drawme(x, glist, 0);
306 canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
307}
308
309static void image_select(t_gobj *z, t_glist *glist, int state)
310{
311 t_image *x = (t_image *)z;
312 if (state) {
313 sys_vgui(".x%x.c create rectangle \
314%d %d %d %d -tags %xSEL -outline blue\n",
315 glist_getcanvas(glist),
316 text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
317 text_xpix(&x->x_obj, glist) + x->x_width, text_ypix(&x->x_obj, glist) + x->x_height,
318 x);
319 }
320 else {
321 sys_vgui(".x%x.c delete %xSEL\n",
322 glist_getcanvas(glist), x);
323 }
324
325
326
327}
328
329
330static void image_activate(t_gobj *z, t_glist *glist, int state)
331{
332/* t_text *x = (t_text *)z;
333 t_rtext *y = glist_findrtext(glist, x);
334 if (z->g_pd != gatom_class) rtext_activate(y, state);*/
335}
336
337static void image_delete(t_gobj *z, t_glist *glist)
338{
339 t_text *x = (t_text *)z;
340 canvas_deletelinesfor(glist_getcanvas(glist), x);
341}
342
343
344static void image_vis(t_gobj *z, t_glist *glist, int vis)
345{
346 t_image* s = (t_image*)z;
347 if (vis)
348 image_drawme(s, glist, 1);
349 else
350 image_erase(s,glist);
351}
352
353/* can we use the normal text save function ?? */
354
355static void image_save(t_gobj *z, t_binbuf *b)
356{
357 t_image *x = (t_image *)z;
358 binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"),
359 x->x_obj.te_xpix, x->x_obj.te_ypix,
360 gensym("image"),x->x_fname);
361 binbuf_addv(b, ";");
362}
363
364
365t_widgetbehavior image_widgetbehavior;
366
367void image_size(t_image* x,t_floatarg w,t_floatarg h) {
368 x->x_width = w;
369 x->x_height = h;
370}
371
372void image_color(t_image* x,t_symbol* col)
373{
374/* outlet_bang(x->x_obj.ob_outlet); only bang if there was a bang ..
375 so color black does the same as bang, but doesn't forward the bang
376*/
377}
378
379static void image_setwidget(void)
380{
381 image_widgetbehavior.w_getrectfn = image_getrect;
382 image_widgetbehavior.w_displacefn = image_displace;
383 image_widgetbehavior.w_selectfn = image_select;
384 image_widgetbehavior.w_activatefn = image_activate;
385 image_widgetbehavior.w_deletefn = image_delete;
386 image_widgetbehavior.w_visfn = image_vis;
387#if (PD_VERSION_MINOR > 31)
388 image_widgetbehavior.w_clickfn = NULL;
389 image_widgetbehavior.w_propertiesfn = NULL;
390#endif
391#if PD_MINOR_VERSION < 37
392 image_widgetbehavior.w_savefn = image_save;
393#endif
394}
395
396
397static void *image_new(t_symbol* fname)
398{
399 t_image *x = (t_image *)pd_new(image_class);
400
401 x->x_glist = (t_glist*) canvas_getcurrent();
402
403 x->x_width = 15;
404 x->x_height = 15;
405
406 x->x_fname = fname;
407 outlet_new(&x->x_obj, &s_float);
408 return (x);
409}
410
411void image_setup(void)
412{
413 image_class = class_new(gensym("image"), (t_newmethod)image_new, 0,
414 sizeof(t_image),0, A_DEFSYM,0);
415
416/*
417 class_addmethod(image_class, (t_method)image_size, gensym("size"),
418 A_FLOAT, A_FLOAT, 0);
419
420 class_addmethod(image_class, (t_method)image_color, gensym("color"),
421 A_SYMBOL, 0);
422*/
423/*
424 class_addmethod(image_class, (t_method)image_open, gensym("open"),
425 A_SYMBOL, 0);
426*/
427 image_setwidget();
428 class_setwidget(image_class,&image_widgetbehavior);
429#if PD_MINOR_VERSION >= 37
430 class_setsavefn(image_class,&image_save);
431#endif
432}
433
434