aboutsummaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rw-r--r--test/homea.gifbin2315 -> 0 bytes
-rw-r--r--test/homeb.gifbin2336 -> 0 bytes
-rw-r--r--test/imagebang-help.pd49
-rw-r--r--test/imagebang.c382
-rw-r--r--test/panda.gifbin25576 -> 0 bytes
-rw-r--r--test/pandb.gifbin20679 -> 0 bytes
-rw-r--r--test/pmenu-help.pd66
-rw-r--r--test/pmenu.c436
-rw-r--r--test/pmenu_w.h91
9 files changed, 0 insertions, 1024 deletions
diff --git a/test/homea.gif b/test/homea.gif
deleted file mode 100644
index c216f13..0000000
--- a/test/homea.gif
+++ /dev/null
Binary files differ
diff --git a/test/homeb.gif b/test/homeb.gif
deleted file mode 100644
index be83f9d..0000000
--- a/test/homeb.gif
+++ /dev/null
Binary files differ
diff --git a/test/imagebang-help.pd b/test/imagebang-help.pd
deleted file mode 100644
index 30341ef..0000000
--- a/test/imagebang-help.pd
+++ /dev/null
@@ -1,49 +0,0 @@
-#N canvas 162 41 658 621 10;
-#X obj 45 338 print;
-#X text 27 17 tags: ui;
-#X text 26 3 description: a bang with an image;
-#X obj 45 152 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
--1;
-#X text 27 49 [imagebang] only works with gifs;
-#X text 351 116 1) image for the normal state;
-#X text 350 133 2) image for the clicked state;
-#X text 350 150 3) send name;
-#X text 351 165 4) receive name;
-#X text 327 192 The first two arguments are required.;
-#X text 314 97 Arguments:;
-#X obj 45 177 tof/imagebang panda.gif pandb.gif \$0pandas \$0pandar
-;
-#X text 253 277 <- This [imagebang] was created with the following:
-;
-#X obj 204 129 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X obj 203 150 s \$0pandar;
-#X obj 209 338 r \$0pandas;
-#X obj 212 364 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X obj 42 436 tof/imagebang homea.gif homeb.gif \$0homes \$0homer;
-#X obj 42 411 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
--1;
-#X obj 42 502 print;
-#X obj 48 559 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144 -1
--1;
-#X obj 47 532 r \$0homes;
-#X obj 122 408 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X obj 121 429 s \$0homer;
-#X text 112 458 <- This [imagebang] was created with the following:
-;
-#X text 258 299 [tof/imagebang panda.gif pandb.gif \$0pandas \$0pandar]
-;
-#X text 118 480 [tof/imagebang homea.gif homeb.gif \$0homes \$0homer]
-;
-#X text 27 31 contact: mrtoftrash@gmail.com;
-#X text 28 69 based on [image] by ggee and moonlib;
-#X connect 3 0 11 0;
-#X connect 11 0 0 0;
-#X connect 13 0 14 0;
-#X connect 15 0 16 0;
-#X connect 17 0 19 0;
-#X connect 18 0 17 0;
-#X connect 21 0 20 0;
-#X connect 22 0 23 0;
diff --git a/test/imagebang.c b/test/imagebang.c
deleted file mode 100644
index b140cfe..0000000
--- a/test/imagebang.c
+++ /dev/null
@@ -1,382 +0,0 @@
-#include <m_pd.h>
-#include <g_canvas.h>
-#include <unistd.h>
-#include <string.h>
-#include <stdio.h>
-
-#ifdef _MSC_VER
-#pragma warning( disable : 4244 )
-#pragma warning( disable : 4305 )
-#endif
-
-/* Append " x " to the following line to show debugging messages */
-#define DEBUG(x)
-
-
-
-/* ------------------------ imagebang ----------------------------- */
-
-static t_class *imagebang_class;
-t_widgetbehavior imagebang_widgetbehavior;
-
-
-typedef struct _imagebang
-{
- t_object x_obj;
- t_glist * glist;
- int width;
- int height;
- t_symbol* image_a;
- t_symbol* image_b;
- t_symbol* receive;
- t_symbol* send;
- t_clock* clock_flash;
- t_clock* clock_brk;
- int flashing;
- t_outlet* outlet;
-} t_imagebang;
-
-
-static void imagebang_bang(t_imagebang *x)
-{
-
- t_glist* glist = glist_getcanvas(x->glist);
- if(x->flashing) {
- sys_vgui(".x%x.c itemconfigure %ximage -image %x_imagebang \n", glist, x,x->image_a);
- clock_delay(x->clock_brk, 50);
- //x->flashed = 1;
- } else {
- sys_vgui(".x%x.c itemconfigure %ximage -image %x_imagebang \n", glist, x,x->image_b);
- x->flashing = 1;
-
- }
- clock_delay(x->clock_flash, 250);
-
-
- outlet_bang(x->outlet);
-
- if(x->send && x->send->s_thing ) pd_bang(x->send->s_thing);
-
-}
-
-static void imagebang_flash_timeout(t_imagebang *x)
-{
- t_glist* glist = glist_getcanvas(x->glist);
- x->flashing = 0;
- sys_vgui(".x%x.c itemconfigure %ximage -image %x_imagebang \n", glist, x,x->image_a);
-
-}
-
-static void imagebang_brk_timeout(t_imagebang *x)
-{
- t_glist* glist = glist_getcanvas(x->glist);
- x->flashing = 1;
- sys_vgui(".x%x.c itemconfigure %ximage -image %x_imagebang \n", glist, x,x->image_b);
-
-}
-
-
-/* widget helper functions */
-
-static const char* imagebang_get_filename(t_imagebang *x,char *file) {
- static char fname[MAXPDSTRING];
- char *bufptr;
- int fd;
-
- fd=open_via_path(canvas_getdir(glist_getcanvas(x->glist))->s_name,
- file, "",fname, &bufptr, MAXPDSTRING, 1);
- if(fd>0){
- fname[strlen(fname)]='/';
- DEBUG(post("image file: %s",fname);)
- close(fd);
- return fname;
- } else {
- return 0;
- }
-}
-
-static int imagebang_click(t_imagebang *x, struct _glist *glist,
- int xpos, int ypos, int shift, int alt, int dbl, int doit) {
- //DEBUG(post("x:%i y:%i dbl:%i doit:%i",xpos,ypos,dbl,doit);)
- if ( doit) imagebang_bang(x) ;
-
- return (1);
- }
-
-
-
-
-static void imagebang_drawme(t_imagebang *x, t_glist *glist, int firsttime) {
- if (firsttime) {
-
- DEBUG(post("Rendering: \n %x_imagebang:%s \n %x_imagebang:%s",x->image_a,x->image_a->s_name,x->image_b,x->image_b->s_name);)
-
- sys_vgui(".x%x.c create image %d %d -anchor nw -image %x_imagebang -disabledimage %x_imagebang -tags %ximage\n",
- glist_getcanvas(glist),
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x->image_a,x->image_b,x);
-
-
- sys_vgui("pd [concat %s _imagesize [image width %x_imagebang] [image height %x_imagebang] \\;]\n",x->receive->s_name,x->image_a,x->image_a);
-
-
- } else {
- sys_vgui(".x%x.c coords %ximage %d %d\n",
- glist_getcanvas(glist), x,
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist));
- }
-
-}
-
-
-void imagebang_erase(t_imagebang* x,t_glist* glist)
-{
- int n;
- sys_vgui(".x%x.c delete %ximage\n",
- glist_getcanvas(glist), x);
-
-}
-
-
-
-/* ------------------------ image widgetbehaviour----------------------------- */
-
-
-static void imagebang_getrect(t_gobj *z, t_glist *glist,
- int *xp1, int *yp1, int *xp2, int *yp2)
-{
- int width, height;
- t_imagebang* x = (t_imagebang*)z;
-
-
- width = x->width;
- height = x->height;
- *xp1 = text_xpix(&x->x_obj, glist);
- *yp1 = text_ypix(&x->x_obj, glist);
- *xp2 = text_xpix(&x->x_obj, glist) + width;
- *yp2 = text_ypix(&x->x_obj, glist) + height;
-}
-
-static void imagebang_displace(t_gobj *z, t_glist *glist,
- int dx, int dy)
-{
- t_imagebang *x = (t_imagebang *)z;
- x->x_obj.te_xpix += dx;
- x->x_obj.te_ypix += dy;
- sys_vgui(".x%x.c coords %xSEL %d %d %d %d\n",
- glist_getcanvas(glist), x,
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
- text_xpix(&x->x_obj, glist) + x->width, text_ypix(&x->x_obj, glist) + x->height);
-
- imagebang_drawme(x, glist, 0);
- canvas_fixlinesfor(glist_getcanvas(glist),(t_text*) x);
-}
-
-static void imagebang_select(t_gobj *z, t_glist *glist, int state)
-{
- t_imagebang *x = (t_imagebang *)z;
- if (state) {
- sys_vgui(".x%x.c create rectangle \
-%d %d %d %d -tags %xSEL -outline blue\n",
- glist_getcanvas(glist),
- text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),
- text_xpix(&x->x_obj, glist) + x->width, text_ypix(&x->x_obj, glist) + x->height,
- x);
- }
- else {
- sys_vgui(".x%x.c delete %xSEL\n",
- glist_getcanvas(glist), x);
- }
-
-
-
-}
-
-
-static void imagebang_activate(t_gobj *z, t_glist *glist, int state)
-{
-/* t_text *x = (t_text *)z;
- t_rtext *y = glist_findrtext(glist, x);
- if (z->g_pd != gatom_class) rtext_activate(y, state);*/
-}
-
-static void imagebang_delete(t_gobj *z, t_glist *glist)
-{
- t_text *x = (t_text *)z;
- //canvas_deletelinesfor(glist_getcanvas(glist), x);
- canvas_deletelinesfor(glist, x);
-}
-
-
-static void imagebang_vis(t_gobj *z, t_glist *glist, int vis)
-{
- t_imagebang* s = (t_imagebang*)z;
- if (vis)
- imagebang_drawme(s, glist, 1);
- else
- imagebang_erase(s,glist);
-}
-
-
-
-
-static void imagebang_size(t_imagebang* x,t_floatarg w,t_floatarg h) {
- x->width = w;
- x->height = h;
-}
-
-
-
-
-static void imagebang_imagesize_callback(t_imagebang *x, t_float w, t_float h) {
- DEBUG(post("received w %f h %f",w,h);)
- x->width = w;
- x->height = h;
- canvas_fixlinesfor(glist_getcanvas(x->glist),(t_text*) x);
-}
-
-
-static void imagebang_free(t_imagebang *x) {
-
- // check first if variable has been unset and image is unused
- // then delete image and unset variable
- DEBUG(sys_vgui("pd [concat DEBUG b in use [image inuse %x_imagebang] \\;]\n",x->image_b);)
- DEBUG(sys_vgui("pd [concat DEBUG a in use [image inuse %x_imagebang] \\;]\n",x->image_a);)
-
- sys_vgui("if { [info exists %x_imagebang] == 1 && [image inuse %x_imagebang] == 0} { image delete %x_imagebang \n unset %x_imagebang\n} \n",x->image_b,x->image_b,x->image_b,x->image_b);
- sys_vgui("if { [info exists %x_imagebang] == 1 && [image inuse %x_imagebang] == 0} { image delete %x_imagebang \n unset %x_imagebang\n} \n",x->image_a,x->image_a,x->image_a,x->image_a);
-
- DEBUG(sys_vgui("pd [concat DEBUG b exists [info exists %x_imagebang] \\;]\n",x->image_b);)
- DEBUG(sys_vgui("pd [concat DEBUG a exists [info exists %x_imagebang] \\;]\n",x->image_a);)
-
- if (x->receive) {
- pd_unbind(&x->x_obj.ob_pd,x->receive);
- }
- clock_free(x->clock_flash);
- clock_free(x->clock_brk);
-
-}
-
-
-static void *imagebang_new(t_symbol *s, int argc, t_atom *argv)
-{
- t_imagebang *x = (t_imagebang *)pd_new(imagebang_class);
-
- x->glist = (t_glist*) canvas_getcurrent();
-
- // Set up a callback to get the size
- x->width = 10;
- x->height = 10;
-
- x->flashing = 0;
-
- x->image_a = NULL;
- x->image_b = NULL;
-
- t_symbol* image_a = NULL;
- t_symbol* image_b = NULL;
-
- const char *fname;
-
- // CREATE IMAGES
- // images are only created if they have not been created yet
- // we use the symbol pointer to distinguish between image files
-
-
- if ( argc && (argv)->a_type == A_SYMBOL ) {
- image_a= atom_getsymbol(argv);
- fname = imagebang_get_filename(x,image_a->s_name); // Get image file path
- if (fname) {
- x->image_a = gensym(fname);
- //sys_vgui("set %x_a \"%s\" \n",x,fname);
- // Create the image only if the class has not already loaded the same image (with the same symbolic path name)
- sys_vgui("if { [info exists %x_imagebang] == 0 } { image create photo %x_imagebang -file \"%s\"\n set %x_imagebang 1\n} \n",x->image_a,x->image_a,fname,x->image_a);
- //sys_vgui("pd [concat test %x_imagebang \\;]\n",x->image_a);
- } else {
- post("Oups... [imagebang] could not find \"%s\"",image_a->s_name);
- }
- }
-
-
-
- if ( argc > 1 && (argv+1)->a_type == A_SYMBOL ) {
- image_b= atom_getsymbol(argv+1);
- fname = imagebang_get_filename(x,image_b->s_name); // Get image file path
- if (fname) {
- x->image_b = gensym(fname);
- //sys_vgui("set %x_b \"%s\" \n",x,fname);
- sys_vgui("if { [info exists %x_imagebang] == 0} { image create photo %x_imagebang -file \"%s\"\n set %x_imagebang 1\n} \n",x->image_b,x->image_b,fname,x->image_b);
- //sys_vgui("pd [concat test %x_imagebang \\;]\n",x->image_b);
- } else {
- post("Oups... [imagebang] could not find \"%s\"",image_b->s_name);
- }
- }
-
- // Stop if no images
- if (x->image_a == NULL || x->image_b == NULL) {
- post("Could not create [imagebang]... either no gif images defined or found!");
- return NULL;
- }
-
- x->send = NULL;
- if ( argc > 2 && (argv+2)->a_type == A_SYMBOL ) {
- x->send = atom_getsymbol(argv+2);
- }
-
- if ( argc > 3 && (argv+3)->a_type == A_SYMBOL ) {
- x->receive = atom_getsymbol(argv+3);
- } else {
- // Create default receiver if none set
- char buf[MAXPDSTRING];
- sprintf(buf, "#%lx", (long)x);
- x->receive = gensym(buf);
- }
-
- pd_bind(&x->x_obj.ob_pd, x->receive );
-
- x->clock_flash = clock_new(x, (t_method)imagebang_flash_timeout);
- x->clock_brk = clock_new(x, (t_method)imagebang_brk_timeout);
-
-
- x->outlet = outlet_new(&x->x_obj, &s_float);
-
-
- return (x);
-
-}
-
-void imagebang_setup(void)
-{
-
-
- imagebang_class = class_new(gensym("imagebang"), (t_newmethod)imagebang_new, (t_method)imagebang_free,
- sizeof(t_imagebang),0, A_GIMME,0);
-
- class_addmethod(imagebang_class, (t_method)imagebang_imagesize_callback,\
- gensym("_imagesize"), A_DEFFLOAT, A_DEFFLOAT, 0);
-
- class_addbang(imagebang_class,(t_method)imagebang_bang);
-
- imagebang_widgetbehavior.w_getrectfn = imagebang_getrect;
- imagebang_widgetbehavior.w_displacefn = imagebang_displace;
- imagebang_widgetbehavior.w_selectfn = imagebang_select;
- imagebang_widgetbehavior.w_activatefn = imagebang_activate;
- imagebang_widgetbehavior.w_deletefn = imagebang_delete;
- imagebang_widgetbehavior.w_visfn = imagebang_vis;
-
- imagebang_widgetbehavior.w_clickfn = (t_clickfn)imagebang_click;
-
-
-#if PD_MINOR_VERSION < 37
- imagebang_widgetbehavior.w_propertiesfn = NULL;
- //imagebang_widgetbehavior.w_savefn = imagebang_save;
-#endif
-
-
- class_setwidget(imagebang_class,&imagebang_widgetbehavior);
-#if PD_MINOR_VERSION >= 37
- // class_setsavefn(imagebang_class,&imagebang_save);
-#endif
-
-}
-
-
diff --git a/test/panda.gif b/test/panda.gif
deleted file mode 100644
index 17f52e2..0000000
--- a/test/panda.gif
+++ /dev/null
Binary files differ
diff --git a/test/pandb.gif b/test/pandb.gif
deleted file mode 100644
index 2a0ee9b..0000000
--- a/test/pandb.gif
+++ /dev/null
Binary files differ
diff --git a/test/pmenu-help.pd b/test/pmenu-help.pd
deleted file mode 100644
index 323ca23..0000000
--- a/test/pmenu-help.pd
+++ /dev/null
@@ -1,66 +0,0 @@
-#N canvas 120 25 756 631 10;
-#X obj 221 187 key;
-#X msg 126 222 clear;
-#X obj 221 213 sel 65;
-#X text 267 213 <- Shift+A will open the menu;
-#X msg 47 63 add a bb ccc dddd eeeee;
-#X obj 45 498 print;
-#X msg 230 320 2;
-#X msg 261 321 3;
-#X text 201 62 add items;
-#X obj 265 417 r \$0pmenu;
-#X obj 332 422 bng 15 250 50 0 \$0pmenu empty empty 17 7 0 10 -262144
--1 -1;
-#X text 353 420 <- you can pop the menu from any gui by sending a bang
-to \$0pemenu;
-#X msg 291 320 -1;
-#X msg 224 287 colors green purple grey;
-#X obj 45 459 tof/pmenu 1 1 black white red;
-#X text 298 536 3: background color (#000000 html or tk colors);
-#X text 296 551 4: foreground color (#000000 hmtl or tk colors);
-#X text 298 566 5: highlight color (#000000 html or tk colors);
-#X text 222 257 values can be tk colors(red \, blue \, etc) or html
-colors (#ffffff);
-#X text 221 241 colors: background foreground highlight;
-#X text 297 507 2: focus the item that was last selected when the menu
-pops. On (1) by default.;
-#X text 296 476 1: display the indicator (the little bullet next to
-item that was last selected). On (1) by default.;
-#X obj 38 18 cnv 15 400 30 empty empty empty 20 12 0 14 -261234 -66577
-0;
-#X text 40 31 tags: ui;
-#X text 38 18 description: pops a menu;
-#X obj 300 458 cnv 15 400 15 empty empty empty 20 12 0 14 -257985 -66577
-0;
-#X text 303 456 Creation arguments:;
-#X msg 87 153 add \$1;
-#X obj 87 130 cyclone/tosymbol;
-#X msg 87 107 with spaces;
-#X text 84 87 Adding items with spaces;
-#X obj 113 180 bng 15 250 50 0 empty empty empty 17 7 0 10 -262144
--1 -1;
-#X text 132 176 Pop the menu;
-#X text 249 179 You can assign any key to pop the menu (Shift+A) in
-this case.;
-#X text 322 319 Select and output a menu item by index;
-#X msg 276 349 set a;
-#X msg 290 371 symbol a;
-#X text 346 370 Select an item by name and output it;
-#X text 320 349 Select an item by name without outputing it;
-#X text 85 501 Output: index name;
-#X connect 0 0 2 0;
-#X connect 1 0 14 0;
-#X connect 2 0 14 0;
-#X connect 4 0 14 0;
-#X connect 6 0 14 0;
-#X connect 7 0 14 0;
-#X connect 9 0 14 0;
-#X connect 12 0 14 0;
-#X connect 13 0 14 0;
-#X connect 14 0 5 0;
-#X connect 27 0 14 0;
-#X connect 28 0 27 0;
-#X connect 29 0 28 0;
-#X connect 31 0 14 0;
-#X connect 35 0 14 0;
-#X connect 36 0 14 0;
diff --git a/test/pmenu.c b/test/pmenu.c
deleted file mode 100644
index 458a0b6..0000000
--- a/test/pmenu.c
+++ /dev/null
@@ -1,436 +0,0 @@
-/* pmenu widget for PD *
- * Based on:
- * pmenu by Ben Bogart
- * and button from GGEE by Guenter Geiger *
-
- * This program is distributed under the terms of the GNU General Public *
- * License *
-
- * pmenu is free software; you can redistribute it and/or modify *
- * it under the terms of the GNU General Public License as published by *
- * the Free Software Foundation; either version 2 of the License, or *
- * (at your option) any later version. *
-
- * pmenu is distributed in the hope that it will be useful, *
- * but WITHOUT ANY WARRANTY; without even the implied warranty of *
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
- * GNU General Public License for more details. */
-
-
-
-
-/* Append " x " to the following line to show debugging messages */
-#define DEBUG(x)
-
-
-#include <m_pd.h>
-#include <g_canvas.h>
-#include <stdio.h>
-#include <string.h>
-
-
-
-
-
-typedef struct _pmenu
-{
- t_object x_obj;
-
- t_glist * x_glist;
-
- t_symbol* callback;
-
- int current_selection;
- int x_num_options;
- t_symbol* bg_color;
- t_symbol* fg_color;
- t_symbol* hi_color;
- t_symbol* co_color;
-
- t_symbol** x_options;
- int x_maxoptions;
-
- int indicator;
- int focusing;
-
-} t_pmenu;
-
-#include "pmenu_w.h"
-
-static void pmenu_output(t_pmenu* x)
-{
-
-
-
- t_atom atoms[2];
- SETFLOAT(atoms,x->current_selection);
- SETSYMBOL(atoms+1,x->x_options[x->current_selection]);
- outlet_list(x->x_obj.ob_outlet, &s_list, 2, atoms);
- //if ( x->send != x->s_empty && x->send->s_thing) pd_forwardmess(x->send->s_thing, 2,atoms);
-
-}
-
-
-static void pmenu_callback(t_pmenu* x, t_floatarg f)
-{
- //DEBUG(post("output start");)
- x->current_selection= (int)f;
- //pmenu_w_text(x,x->x_options[x->current_selection]);
- pmenu_output(x);
-
-}
-/*
-static void pmenu_save(t_gobj *z, t_binbuf *b)
-{
- DEBUG(post("save start");)
-
-
- t_pmenu *x = (t_pmenu *)z;
-
- t_atom* creation = binbuf_getvec(x->x_obj.te_binbuf);
-
-
- t_symbol* send = x->s_empty;
- t_symbol* receive = x->s_empty;
- char buf[80];
- if ( x->send_set ) {
- atom_string(creation + 3, buf, 80);
- send = gensym(buf);
- }
-
- if ( x->receive_set ) {
- atom_string(creation + 4, buf, 80);
- receive = gensym(buf);
- }
-
- DEBUG(post("send: %s receive: %s",send->s_name,receive->s_name);)
-
- binbuf_addv(b, "ssiisiississss", gensym("#X"), gensym("obj"),
- x->x_obj.te_xpix, x->x_obj.te_ypix ,
- atom_getsymbol(creation),
- x->x_width, x->x_height, send,receive,x->saveitems,
- x->bg_color, x->fg_color,x->hi_color,x->co_color);
-
- // Loop for menu items
- int i;
- if ( x->saveitems) {
- for(i=0 ; i<x->x_num_options ; i++)
- {
- DEBUG(post("saving option: %s",x->x_options[i]->s_name);)
- binbuf_addv(b, "s", x->x_options[i]);
- }
- }
- binbuf_addv(b, ";");
-
- DEBUG(post("save end");)
-}
-*/
-
-static void pmenu_clear(t_pmenu* x) {
-
- x->x_num_options = 0;
- x->current_selection = -1;
- pmenu_w_clear(x);
-
-}
-
-/*
-static void pmenu_size(t_pmenu* x,t_symbol *s, int argc, t_atom *argv) {
-
- if (argc>2) argc =2;
- switch (argc) {
- case 2: if ( (argv+1)->a_type == A_FLOAT) x->x_height = atom_getfloat(argv+1);
- case 1: if ( argv->a_type == A_FLOAT) x->x_width = atom_getfloat(argv);
- break;
- }
-
- if ( x->x_width < 10) x->x_width = 10;
- if ( x->x_height < 10) x->x_height = 10;
-
- if ( pmenu_w_is_visible(x) ) {
- pmenu_w_resize(x);
- }
-}
-*/
-
-
-static void pmenu_add(t_pmenu* x, t_symbol *s, int argc, t_atom *argv) {
-
-
-
- // resize the options-array if it is too small
- if((argc + x->x_num_options) > x->x_maxoptions){
-
- x->x_options = resizebytes( x->x_options, x->x_maxoptions*sizeof(*(x->x_options)),
- (argc + x->x_num_options+10)*sizeof(*(x->x_options)));
- x->x_maxoptions=argc + x->x_num_options+10;
- }
-
- int i;
- t_symbol* label;
- for ( i=0;i<argc;i++) {
- if ((argv+i)->a_type==A_SYMBOL) {
-
- label = atom_getsymbol(argv+i);
- DEBUG(post("adding option: %s",label->s_name);)
- x->x_options[x->x_num_options] = label;
-
- pmenu_w_additem( x,label,x->x_num_options);
-
- x->x_num_options = x->x_num_options + 1;
- }
-
- }
-
-
-}
-
-
-
-// function to change the colors
-
-static void pmenu_colors(t_pmenu* x, t_symbol* s, int argc, t_atom* argv)
-{
-
- DEBUG(post("bgcolour start");)
-
- if ( argc && argv->a_type==A_SYMBOL && atom_getsymbol(argv)==gensym("default")) {
- x->bg_color = gensym("grey90");
- x->fg_color = gensym("black");
- x->hi_color = gensym("grey95");
- x->co_color = gensym("black");
- } else {
-
- if (argc > 4) argc = 4;
- switch (argc) {
- case 4: if ((argv+3)->a_type==A_SYMBOL) x->co_color = atom_getsymbol(argv+3);
- case 3: if ((argv+2)->a_type==A_SYMBOL) x->hi_color = atom_getsymbol(argv+2);
- case 2: if ((argv+1)->a_type==A_SYMBOL) x->fg_color = atom_getsymbol(argv+1);
- case 1: if ((argv)->a_type==A_SYMBOL) x->bg_color = atom_getsymbol(argv);
- break;
- }
- }
-
- pmenu_w_apply_colors(x);
-
-}
-
-
-static int pmenu_set_float(t_pmenu* x, t_floatarg item) {
-
-
- int i=(int)item;
- if( (i < x->x_num_options) && (i >= 0)) {
- x->current_selection = i;
- //if(pmenu_w_is_visible(x)) pmenu_w_text(x,x->x_options[x->current_selection]);
- pmenu_w_activate(x);
- return 1;
- } else {
- x->current_selection = -1;
- pmenu_w_activate(x);
- return 0;
- }
-
-}
-
-/* Function to select a menu option by inlet */
-static void pmenu_float(t_pmenu* x, t_floatarg item)
-{
- DEBUG(post("iselect start");)
-
- if ( pmenu_set_float(x,item) ) {
- pmenu_output(x);
- } else {
-
- //pd_error(x,"pmenu: expecting value between 0 and %i",x->x_num_options);
- }
-
- DEBUG(post("iselect end");)
-}
-
-static int pmenu_set_symbol(t_pmenu* x, t_symbol *s) {
-
-
- int i;
-
- /* Compare inlet symbol to each option */
- for(i=0; i < x->x_num_options; i++) {
- if(x->x_options[i]->s_name == s->s_name) {
- x->current_selection = i;
- //if(pmenu_w_is_visible(x)) pmenu_w_text(x,s);
- pmenu_w_activate(x);
- return 1;
- }
- }
- x->current_selection = -1;
- pmenu_w_activate(x);
- return 0;
-}
-
-
-/* Function to choose value via symbol name */
-static void pmenu_symbol(t_pmenu* x, t_symbol *s)
-{
- if(pmenu_set_symbol(x,s)) {
- pmenu_output(x);
- } else {
- post("pmenu: '%s' is not an available option.", s->s_name);
- }
-
-}
-
-/* Function to choose value via name/index but without outputting it*/
-static void pmenu_set(t_pmenu* x, t_symbol *S, int argc, t_atom*argv)
-{
- if(!argc)return;
-
- if(argv->a_type==A_FLOAT) {
- pmenu_set_float(x,atom_getfloat(argv));
- } else if(argv->a_type==A_SYMBOL) {
- pmenu_set_symbol(x,atom_getsymbol(argv));
- } else {
- pd_error(x, "pmenu: can only 'set' symbols or floats");
- }
-}
-
-
-
-
-
-
-static t_class *pmenu_class;
-
-/*
-static void pmenu_receive(t_pmenu* x, t_symbol* s) {
- if ( x->receive != x->s_empty ) pd_unbind(&x->x_obj.ob_pd, x->receive);
- if ( s == x->s_empty || s == x->s_) {
- x->receive = x->s_empty;
- } else {
- x->receive = s;
- pd_bind(&x->x_obj.ob_pd, x->receive);
- }
-
-}
-
-static void pmenu_send(t_pmenu* x, t_symbol* s) {
-
- if ( s == x->s_empty || s == x->s_ ) {
- x->send = x->s_empty;
- } else {
- x->send = s;
- }
-
-
-
-}
-*/
-
-static void pmenu_free(t_pmenu*x)
-{
- pmenu_w_menu(x,DESTROY);
-
-
- if(x->x_options)freebytes(x->x_options, sizeof(t_symbol*)*x->x_maxoptions);
- pd_unbind(&x->x_obj.ob_pd, x->callback);
-
- //if ( x->receive != x->s_empty ) pd_unbind(&x->x_obj.ob_pd, x->receive);
-}
-/*
-static void pmenu_saveitems( t_pmenu* x, t_float f) {
- x->saveitems = (f != 0);
-}
-*/
-
-static void *pmenu_new(t_symbol *s, int argc, t_atom *argv)
-{
- DEBUG(post("pmenu new start");)
-
- t_pmenu *x = (t_pmenu *)pd_new(pmenu_class);
- int i;
- char buf[256];
-
-
- x->current_selection = -1;
-
- x->x_maxoptions=10;
- x->x_options=(t_symbol**)getbytes(sizeof(t_symbol*)*x->x_maxoptions);
-
- x->x_num_options = 0 ;
-
- x->indicator = 1;
- x->focusing = 1;
-
-
- // These should match the default colors in pmenu_colors
- x->bg_color = gensym("grey90");
- x->fg_color = gensym("black");
- x->hi_color = gensym("grey95");
- x->co_color = gensym("black");
-
-
- if (argc > 6) argc = 6;
- switch(argc){
- case 6: if ((argv+5)->a_type==A_SYMBOL) x->co_color = atom_getsymbol(argv+5);
- case 5: if ((argv+4)->a_type==A_SYMBOL) x->hi_color = atom_getsymbol(argv+4);
- case 4: if ((argv+3)->a_type==A_SYMBOL) x->fg_color = atom_getsymbol(argv+3);
- case 3: if ((argv+2)->a_type==A_SYMBOL) x->bg_color = atom_getsymbol(argv+2);
- case 2: if ((argv+1)->a_type==A_FLOAT) x->focusing = atom_getfloat(argv+1);
- case 1: if ((argv)->a_type==A_FLOAT) x->indicator = atom_getfloat(argv);
- break;
- }
-
- /* Bind the recieve "pmenu%p" to the widget outlet*/
- sprintf(buf,"pmenu%p",x);
- x->callback = gensym(buf);
- pd_bind(&x->x_obj.ob_pd, x->callback);
-
- /* define proc in tcl/tk where "pmenu%p" is the receive, "callback" is the method, and "$index" is an argument. */
- sys_vgui("proc select%x {index} {\n pd [concat pmenu%p callback $index \\;]\n }\n",x,x);
-
-
- outlet_new(&x->x_obj, &s_symbol);
-
- pmenu_w_menu(x,CREATE);
- pmenu_w_apply_colors(x);
- //if (argc > 5) pmenu_add(x,&s_list,argc-5,argv+5);
-
-
-DEBUG(post("pmenu new end");)
-
- return (x);
-}
-
-void pmenu_setup(void) {
-
- DEBUG(post("setup start");)
-
- pmenu_class = class_new(gensym("pmenu"), (t_newmethod)pmenu_new, (t_method)pmenu_free,
- sizeof(t_pmenu),0,A_GIMME,0);
-
- class_addbang(pmenu_class, (t_method)pmenu_w_pop);
-
- class_addmethod(pmenu_class, (t_method)pmenu_callback,
- gensym("callback"),A_DEFFLOAT,0);
-
- class_addmethod(pmenu_class, (t_method)pmenu_add,
- gensym("add"), A_GIMME,0);
-
- class_addmethod(pmenu_class, (t_method)pmenu_clear,
- gensym("clear"), 0);
-
- class_addmethod(pmenu_class, (t_method)pmenu_colors,
- gensym("colors"),A_GIMME,0);
-
- class_addmethod(pmenu_class, (t_method)pmenu_set,
- gensym("set"),A_GIMME,0);
-
- class_addsymbol(pmenu_class, (t_method)pmenu_symbol);
-
- class_addfloat(pmenu_class, (t_method)pmenu_float);
-
-
-
- post("pmenu v0.02 by tof");
-}
-
-
diff --git a/test/pmenu_w.h b/test/pmenu_w.h
deleted file mode 100644
index b1ff496..0000000
--- a/test/pmenu_w.h
+++ /dev/null
@@ -1,91 +0,0 @@
-
-#define UPDATE 0
-#define CREATE 1
-#define DESTROY 2
-
-#define COLUMNBREAK 30
-
-static void pmenu_w_activate(t_pmenu* x){
- //sys_vgui("$%xw activate %i\n", x,x->current_selection);
- //if ( x->indicator) {
- sys_vgui("set %xradio %i\n",x,x->current_selection);
- //} else {
-
- // sys_vgui("set %xradio %i\n",x,-1);
- //}
-}
-
-
-static void pmenu_w_clear(t_pmenu* x){
- sys_vgui("$%xw delete 0 end \n", x);
- //sys_vgui("set %xradio %i\n",x,-1);
- x->current_selection = -1;
- pmenu_w_activate(x);
-}
-
-static void pmenu_w_additem(t_pmenu* x, t_symbol *label, int i) {
- if ( x->indicator) {
- sys_vgui("$%xw add radiobutton -label \"%s\" -command {select%x \"%d\"} -variable %xradio -value %d \n",
- x, label->s_name, x, i,x,i);
-
- } else {
- sys_vgui("$%xw add command -label \"%s\" -command {select%x \"%d\"} \n",
- x, label->s_name, x, i,x,i);
- }
- if ( i == COLUMNBREAK ) sys_vgui("$%xw entryconfigure %i -columnbreak true \n",x,i);
-
-}
-
-static void pmenu_w_apply_colors(t_pmenu* x) {
-
- sys_vgui("$%xw configure -background \"%s\" -foreground \"%s\" -activeforeground \"%s\" -activebackground \"%s\" -selectcolor \"%s\"\n", x,
- x->bg_color->s_name,x->fg_color->s_name,x->fg_color->s_name,x->hi_color->s_name,x->fg_color->s_name);
-
-
-}
-
-
-static void pmenu_w_menu(t_pmenu *x, int draw)
-{
- DEBUG(post("menu start");)
-
- if ( draw == CREATE ) {
- //x->created = 1;
- // Create menu
- //sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -justify left
- // Create a variable to store a pointer to the menu, create the menu, create a variable to store the selected item
- sys_vgui("set %xw .%x ; menu $%xw -relief solid -tearoff 0; set %xradio -1 \n",x,x,x);
- int i;
- for(i=0 ; i<x->x_num_options ; i++)
- {
- // Add menu itmes
- pmenu_w_additem(x,x->x_options[i],i);
- }
- } else if ( draw == DESTROY) {
- //x->created = 0;
-
-
- sys_vgui("destroy $%xw \n",x);
-
- }
-
- //DEBUG(post("id: .x%x.c.s%x", glist, x);)
- DEBUG(post("menu end");)
-}
-
-
-static void pmenu_w_pop(t_pmenu *x) {
-
- if (x->x_num_options > 0) {
- //if ( x->created == 0 ) pmenu_w_menu(x, glist, CREATE);
- if ( x->current_selection != -1 && x->focusing) {
- sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] %i\n",x,x->current_selection);
- } else {
- sys_vgui("tk_popup $%xw [winfo pointerx .] [winfo pointery .] \n",x);
- }
- }
-
-}
-
-
-