aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--popup/README.build.txt11
-rw-r--r--popup/README.txt37
-rw-r--r--popup/gop-test.pd2
-rw-r--r--popup/popup-help.pd20
-rw-r--r--popup/popup.c37
5 files changed, 68 insertions, 39 deletions
diff --git a/popup/README.build.txt b/popup/README.build.txt
new file mode 100644
index 0000000..b8d31db
--- /dev/null
+++ b/popup/README.build.txt
@@ -0,0 +1,11 @@
+These objects where developed under OSX and have been tested
+under OSX and Linux.
+
+To build (under linux):
+
+ make pd_linux
+
+To build (under OSX):
+
+ make pd_darwin
+
diff --git a/popup/README.txt b/popup/README.txt
new file mode 100644
index 0000000..5cd0983
--- /dev/null
+++ b/popup/README.txt
@@ -0,0 +1,37 @@
+This is the readme for "popup" a popup menu for PD.
+
+popup is Copyright Ben Bogart 2003
+
+If you have any questions/comments you can reach the author at ben@ekran.org.
+
+This program is distributed under the terms of the GNU General Public
+License
+
+PSO 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.
+
+PSO 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.
+
+You should have received a copy of the GNU General Public License
+along with PSO; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+USAGE:
+
+PD: Put it in your extra folder.
+
+Arguments: [pixel width] [background colour] [name] [opt1] [opt2] [...]
+
+Methods:
+
+ float Select index value
+ name [name] Popup's name
+ bgcolour [colour] Background Colour (white, green, #5500ff)
+ options [opt1] [...] List of the popup options
+
+Have Fun.
diff --git a/popup/gop-test.pd b/popup/gop-test.pd
index 21865e3..68c2a1a 100644
--- a/popup/gop-test.pd
+++ b/popup/gop-test.pd
@@ -1,5 +1,5 @@
#N canvas 441 293 131 47 10;
-#X obj 0 5 popup 10 grey90 1024x512 opt1;
+#X obj 0 5 popup 124 grey90 1024x512 opt1;
#X obj 0 0 cnv 15 128 40 empty empty empty 20 12 0 14 -233017 -66577
0;
#X obj 16 46 outlet;
diff --git a/popup/popup-help.pd b/popup/popup-help.pd
index 9be7ed8..9ed1397 100644
--- a/popup/popup-help.pd
+++ b/popup/popup-help.pd
@@ -1,20 +1,18 @@
-#N canvas 154 131 623 309 10;
-#X obj 78 188 popup 10 white duh! one two three four five six seven
+#N canvas 154 131 631 317 10;
+#X obj 78 188 popup 124 white duh! one two three four five six seven
eight nine ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21
i22 i23 i24 i25 i26 i26 i27 i28 i29 i30;
-#X msg 129 111 bgcolour white;
#X obj 79 233 print index;
-#X msg 99 81 name popup;
-#X msg 56 53 width 10;
+#X msg 91 68 name popup;
#X obj 181 234 print symbol;
#X floatatom 33 32 5 0 0 0 - - -;
-#X msg 146 137 options one two three four five six seven eight nine
+#X msg 138 124 options one two three four five six seven eight nine
ten eleven twelve thirteen i14 i15 i16 i17 i18 i19 i20 i21 i22 i23
i24 i25 i26 i26 i27 i28 i29 i30;
-#X connect 0 0 2 0;
-#X connect 0 1 5 0;
-#X connect 1 0 0 0;
-#X connect 3 0 0 0;
+#X msg 121 98 bgcolour black;
+#X connect 0 0 1 0;
+#X connect 0 1 3 0;
+#X connect 2 0 0 0;
#X connect 4 0 0 0;
+#X connect 5 0 0 0;
#X connect 6 0 0 0;
-#X connect 7 0 0 0;
diff --git a/popup/popup.c b/popup/popup.c
index 092e198..9e0db8b 100644
--- a/popup/popup.c
+++ b/popup/popup.c
@@ -38,7 +38,6 @@ typedef struct _popup
int x_height;
int x_width;
- int x_char_width;
int x_num_options;
t_symbol* x_colour;
t_symbol* x_name;
@@ -118,12 +117,12 @@ static void create_widget(t_popup *x, t_glist *glist)
char text[MAXPDSTRING];
int len,i;
t_canvas *canvas=glist_getcanvas(glist);
- x->x_rect_width = x->x_width+10;
- x->x_rect_height = x->x_height*20+9;
+ x->x_rect_width = x->x_width;
+ x->x_rect_height = x->x_height+2;
/* Create menubutton and empty menu widget -- maybe the menu should be created elseware?*/
- sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -relief raised -width \"%d\" -background \"%s\" -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -tearoff 0\n",
- x,canvas,x,x,x->x_char_width,x->x_colour->s_name,x->x_name->s_name,x,x);
+ sys_vgui("set %xw .x%x.c.s%x ; menubutton $%xw -relief raised -background \"%s\" -text \"%s\" -direction flush -menu $%xw.menu ; menu $%xw.menu -tearoff 0\n",
+ x,canvas,x,x,x->x_colour->s_name,x->x_name->s_name,x,x);
for(i=0 ; i<x->x_num_options ; i++)
{
@@ -142,8 +141,8 @@ static void popup_drawme(t_popup *x, t_glist *glist, int firsttime)
DEBUG(post("glist %x canvas %x",x->x_glist,canvas);)
create_widget(x,glist);
x->x_glist = canvas;
- sys_vgui(".x%x.c create window %d %d -anchor nw -window .x%x.c.s%x -tags %xS\n",
- canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist),x->x_glist,x,x);
+ sys_vgui(".x%x.c create window %d %d -width %d -height 25 -anchor nw -window .x%x.c.s%x -tags %xS\n",
+ canvas,text_xpix(&x->x_obj, glist), text_ypix(&x->x_obj, glist), x->x_width, x->x_glist,x,x);
}
else {
@@ -297,7 +296,7 @@ static void popup_save(t_gobj *z, t_binbuf *b)
binbuf_addv(b, "ssiisiss", gensym("#X"),gensym("obj"),
x->x_obj.te_xpix, x->x_obj.te_ypix ,
- gensym("popup"), x->x_char_width, x->x_colour, x->x_name);
+ gensym("popup"), x->x_width, x->x_colour, x->x_name);
/* Loop for menu items */
for(i=0 ; i<x->x_num_options ; i++)
{
@@ -324,13 +323,6 @@ void popup_options(t_popup* x, t_symbol *s, int argc, t_atom *argv)
}
}
-/* function to change width of popup */
-void popup_width(t_popup* x, t_floatarg w)
-{
- x->x_char_width = (int)w;
- sys_vgui(".x%x.c.s%x configure -width %d\n", x->x_glist, x, x->x_char_width);
-}
-
/* function to change colour of popup background */
void popup_bgcolour(t_popup* x, t_symbol* col)
{
@@ -370,12 +362,12 @@ static void *popup_new(t_symbol *s, int argc, t_atom *argv)
x->x_glist = (t_glist*)NULL;
- x->x_height = 1;
+ x->x_height = 25;
if (argc < 4)
{
post("popup: You must enter at least 4 arguments. Default values used.");
- x->x_char_width = 10;
+ x->x_width = 124;
x->x_num_options = 1;
x->x_colour = gensym("#ffffff");
x->x_name = gensym("popup");
@@ -384,7 +376,7 @@ static void *popup_new(t_symbol *s, int argc, t_atom *argv)
} else {
/* Copy args into structure */
- x->x_char_width = atom_getint(argv);
+ x->x_width = atom_getint(argv);
x->x_colour = atom_getsymbol(argv+1);
x->x_name = atom_getsymbol(argv+2);
@@ -396,10 +388,6 @@ static void *popup_new(t_symbol *s, int argc, t_atom *argv)
}
}
- /* TODO .. ask the popup for its width -- "[canvas] itemcget [tags] -width" -- but how to pass the data back?*/
- /* x->x_width = x->x_char_width*10; tuned for OSX */
- x->x_width = x->x_char_width*7; /* tuned for Linux */
-
/* Bind the recieve "popup%p" to the widget outlet*/
sprintf(buf,"popup%p",x);
x->x_sym = gensym(buf);
@@ -422,11 +410,6 @@ void popup_setup(void) {
A_DEFFLOAT,
0);
- class_addmethod(popup_class, (t_method)popup_width,
- gensym("width"),
- A_DEFFLOAT,
- 0);
-
class_addmethod(popup_class, (t_method)popup_name,
gensym("name"),
A_DEFSYMBOL,