/* Popup menu widget for PD * * Based on button from GGEE by Guenter Geiger * * Copyright Ben Bogart 2004 ben@ekran.org * * This program is distributed under the terms of the GNU General Public * * License * * popup 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. * * popup 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. */ #include #include #include #include #ifdef _MSC_VER #pragma warning( disable : 4244 ) #pragma warning( disable : 4305 ) #endif #ifndef IOWIDTH #define IOWIDTH 4 #endif #define MAX_OPTIONS 100 typedef struct _popup { t_object x_obj; t_glist * x_glist; t_outlet* out2; int x_rect_width; int x_rect_height; t_symbol* x_sym; int x_height; int x_width; int current_selection; int x_num_options; t_symbol* x_colour; t_symbol* x_name; t_symbol** x_options; int x_maxoptions; /* IDs for Tk widgets */ char *canvas_id; int initialized; /* 1 when we are allowed to draw, 0 otherwise */ int x_disabled; /* when disabled, graphical chosing is prohibited */ } t_popup; /* widget helper functions */ /* Append " x " to the following line to show debugging messages */ #define DEBUG(x) /* widget helper functions */ static void set_tk_widget_ids(t_popup *x, t_canvas *canvas) { char buf[MAXPDSTRING]; /* Tk ID for the current canvas that this object is drawn in */ sprintf(buf,".x%lx.c", (long unsigned int) canvas); x->canvas_id = getbytes(strlen(buf) + 1); strcpy(x->canvas_id, buf); } static void bind_button_events(t_popup *x) { /* mouse buttons */ sys_vgui("bind %s.s%lx