From b84ccf92049f602e6a18e4d4677454bdc9752f2f Mon Sep 17 00:00:00 2001 From: Hans-Christoph Steiner Date: Tue, 14 Sep 2010 04:38:22 +0000 Subject: ported to slightly modified template Makefile svn path=/trunk/externals/tkwidgets/; revision=14135 --- Makefile | 307 +++++++++++++++++++++++++++++++++++++++++++++++++++-- checkbutton.c | 2 +- photo.c | 2 +- shared/tkwidgets.c | 287 ------------------------------------------------- shared/tkwidgets.h | 109 ------------------- text.c | 10 +- tkwidgets-meta.pd | 6 ++ tkwidgets.c | 287 +++++++++++++++++++++++++++++++++++++++++++++++++ tkwidgets.h | 109 +++++++++++++++++++ 9 files changed, 705 insertions(+), 414 deletions(-) delete mode 100644 shared/tkwidgets.c delete mode 100644 shared/tkwidgets.h create mode 100644 tkwidgets-meta.pd create mode 100644 tkwidgets.c create mode 100644 tkwidgets.h diff --git a/Makefile b/Makefile index d5d1e08..229ab1c 100644 --- a/Makefile +++ b/Makefile @@ -1,18 +1,303 @@ -TARGET := $(shell pwd | sed 's|.*/\(.*\)$$|\1|') -EXTERNALS_ROOT := $(shell pwd | sed 's|^\(/.*externals\).*|\1|') +## Pd library template version 1.0.4 +# For instructions on how to use this template, see: +# http://puredata.info/docs/developer/MakefileTemplate +LIBRARY_NAME = tkwidgets -default: - make -C $(EXTERNALS_ROOT) $(TARGET) +# add your .c source files, one object per file, to the SOURCES +# variable, help files will be included automatically +SOURCES = checkbutton.c photo.c text.c + +# list all pd objects (i.e. myobject.pd) files here, and their helpfiles will +# be included automatically +PDOBJECTS = + +# example patches and related files, in the 'examples' subfolder +EXAMPLES = + +# manuals and related files, in the 'manual' subfolder +MANUAL = + +# if you want to include any other files in the source and binary tarballs, +# list them here. This can be anything from header files, test patches, +# documentation, etc. README.txt and LICENSE.txt are required and therefore +# automatically included +EXTRA_DIST = tkwidgets.h tkwidgets.c + + + +#------------------------------------------------------------------------------# +# +# things you might need to edit if you are using other C libraries +# +#------------------------------------------------------------------------------# + +CFLAGS = -DPD -I"$(PD_INCLUDE)/pd" -Wall -W -g +LDFLAGS = +LIBS = + +#------------------------------------------------------------------------------# +# +# you shouldn't need to edit anything below here, if we did it right :) +# +#------------------------------------------------------------------------------# + +# get library version from meta file +LIBRARY_VERSION = $(shell sed -n 's|^\#X text [0-9][0-9]* [0-9][0-9]* VERSION \(.*\);|\1|p' $(LIBRARY_NAME)-meta.pd) + +CFLAGS += -DVERSION='"$(LIBRARY_VERSION)"' + +PD_INCLUDE = $(PD_PATH)/include +# where to install the library, overridden below depending on platform +prefix = /usr/local +libdir = $(prefix)/lib +pkglibdir = $(libdir)/pd-externals +objectsdir = $(pkglibdir) + +INSTALL = install +INSTALL_PROGRAM = $(INSTALL) -p -m 644 +INSTALL_DATA = $(INSTALL) -p -m 644 +INSTALL_DIR = $(INSTALL) -p -m 755 -d + +ALLSOURCES := $(SOURCES) $(SOURCES_android) $(SOURCES_cygwin) $(SOURCES_macosx) \ + $(SOURCES_iphoneos) $(SOURCES_linux) $(SOURCES_windows) + +DISTDIR=$(LIBRARY_NAME)-$(LIBRARY_VERSION) +ORIGDIR=pd-$(LIBRARY_NAME:~=)_$(LIBRARY_VERSION) + +UNAME := $(shell uname -s) +ifeq ($(UNAME),Darwin) + CPU := $(shell uname -p) + ifeq ($(CPU),arm) # iPhone/iPod Touch + SOURCES += $(SOURCES_iphoneos) + EXTENSION = pd_darwin + OS = iphoneos + PD_PATH = /Applications/Pd-extended.app/Contents/Resources + IPHONE_BASE=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin + CC=$(IPHONE_BASE)/gcc + CPP=$(IPHONE_BASE)/cpp + CXX=$(IPHONE_BASE)/g++ + ISYSROOT = -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.0.sdk + IPHONE_CFLAGS = -miphoneos-version-min=3.0 $(ISYSROOT) -arch armv6 + OPT_CFLAGS = -fast -funroll-loops -fomit-frame-pointer + CFLAGS := $(IPHONE_CFLAGS) $(OPT_CFLAGS) $(CFLAGS) + LDFLAGS += -arch armv6 -bundle -undefined dynamic_lookup $(ISYSROOT) + LIBS += -lc + STRIP = strip -x + DISTBINDIR=$(DISTDIR)-$(OS) + else # Mac OS X + SOURCES += $(SOURCES_macosx) + EXTENSION = pd_darwin + OS = macosx + PD_PATH = /Applications/Pd-extended.app/Contents/Resources + OPT_CFLAGS = -ftree-vectorize -ftree-vectorizer-verbose=2 -fast +# build universal 32-bit on 10.4 and 32/64 on newer + ifeq ($(shell uname -r | sed 's|\([0-9][0-9]*\)\.[0-9][0-9]*\.[0-9][0-9]*|\1|'), 8) + FAT_FLAGS = -arch ppc -arch i386 -mmacosx-version-min=10.4 + else + FAT_FLAGS = -arch ppc -arch i386 -arch x86_64 -mmacosx-version-min=10.4 + SOURCES += $(SOURCES_iphoneos) + endif + CFLAGS += $(FAT_FLAGS) -fPIC -I/sw/include + LDFLAGS += $(FAT_FLAGS) -bundle -undefined dynamic_lookup -L/sw/lib + # if the 'pd' binary exists, check the linking against it to aid with stripping + LDFLAGS += $(shell test -e $(PD_PATH)/bin/pd && echo -bundle_loader $(PD_PATH)/bin/pd) + LIBS += -lc + STRIP = strip -x + DISTBINDIR=$(DISTDIR)-$(OS) +# install into ~/Library/Pd on Mac OS X since /usr/local isn't used much + pkglibdir=$(HOME)/Library/Pd + endif +endif +ifeq ($(UNAME),Linux) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_linux) + EXTENSION = pd_linux + OS = linux + PD_PATH = /usr + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += -fPIC + LDFLAGS += -Wl,--export-dynamic -shared -fPIC + LIBS += -lc + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS)-$(shell uname -m) +endif +ifeq (CYGWIN,$(findstring CYGWIN,$(UNAME))) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_cygwin) + EXTENSION = dll + OS = cygwin + PD_PATH = $(cygpath $(PROGRAMFILES))/pd + OPT_CFLAGS = -O6 -funroll-loops -fomit-frame-pointer + CFLAGS += + LDFLAGS += -Wl,--export-dynamic -shared -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" + LIBS += -lc -lpd + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS) +endif +ifeq (MINGW,$(findstring MINGW,$(UNAME))) + CPU := $(shell uname -m) + SOURCES += $(SOURCES_windows) + EXTENSION = dll + OS = windows + PD_PATH = $(shell cd "$(PROGRAMFILES)"/pd && pwd) + OPT_CFLAGS = -O3 -funroll-loops -fomit-frame-pointer -march=i686 -mtune=pentium4 + CFLAGS += -mms-bitfields + LDFLAGS += -s -shared -Wl,--enable-auto-import + LIBS += -L"$(PD_PATH)/src" -L"$(PD_PATH)/bin" -L"$(PD_PATH)/obj" -lpd -lwsock32 -lkernel32 -luser32 -lgdi32 + STRIP = strip --strip-unneeded -R .note -R .comment + DISTBINDIR=$(DISTDIR)-$(OS) +endif + +# in case somebody manually set the HELPPATCHES above +HELPPATCHES ?= $(SOURCES:.c=-help.pd) $(PDOBJECTS:.c=-help.pd) + +CFLAGS += $(OPT_CFLAGS) + + +.PHONY = install libdir_install single_install install-doc install-exec install-examples install-manual clean dist etags $(LIBRARY_NAME) + +all: $(SOURCES:.c=.$(EXTENSION)) + +%.o: %.c + $(CC) $(CFLAGS) -o "$*.o" -c "$*.c" + +%.$(EXTENSION): %.o tkwidgets.o + $(CC) $(LDFLAGS) -o "$*.$(EXTENSION)" "$*.o" tkwidgets.o $(LIBS) + chmod a-x "$*.$(EXTENSION)" + +# this links everything into a single binary file +$(LIBRARY_NAME): $(SOURCES:.c=.o) $(LIBRARY_NAME).o + $(CC) $(LDFLAGS) -o $(LIBRARY_NAME).$(EXTENSION) $(SOURCES:.c=.o) $(LIBRARY_NAME).o $(LIBS) + chmod a-x $(LIBRARY_NAME).$(EXTENSION) + +install: libdir_install + +# The meta and help files are explicitly installed to make sure they are +# actually there. Those files are not optional, then need to be there. +libdir_install: $(SOURCES:.c=.$(EXTENSION)) install-doc install-examples install-manual + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(SOURCES))" || (\ + $(INSTALL_PROGRAM) $(SOURCES:.c=.$(EXTENSION)) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) && \ + $(STRIP) $(addprefix $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/,$(SOURCES:.c=.$(EXTENSION)))) + test -z "$(strip $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(PDOBJECTS) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + +# install library linked as single binary +single_install: $(LIBRARY_NAME) install-doc install-exec + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_PROGRAM) $(LIBRARY_NAME).$(EXTENSION) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(STRIP) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/$(LIBRARY_NAME).$(EXTENSION) + +install-doc: + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + test -z "$(strip $(SOURCES) $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(HELPPATCHES) \ + $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME) + $(INSTALL_DATA) README.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/README.txt + $(INSTALL_DATA) LICENSE.txt $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/LICENSE.txt + +install-examples: + test -z "$(strip $(EXAMPLES))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples && \ + for file in $(EXAMPLES); do \ + $(INSTALL_DATA) examples/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/examples; \ + done + +install-manual: + test -z "$(strip $(MANUAL))" || \ + $(INSTALL_DIR) $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual && \ + for file in $(MANUAL); do \ + $(INSTALL_DATA) manual/$$file $(DESTDIR)$(objectsdir)/$(LIBRARY_NAME)/manual; \ + done -install: - make -C $(EXTERNALS_ROOT) $(TARGET)_install clean: - make -C $(EXTERNALS_ROOT) $(TARGET)_clean + -rm -f -- $(SOURCES:.c=.o) $(SOURCES_LIB:.c=.o) + -rm -f -- $(SOURCES:.c=.$(EXTENSION)) + -rm -f -- $(LIBRARY_NAME).o + -rm -f -- $(LIBRARY_NAME).$(EXTENSION) + +distclean: clean + -rm -f -- $(DISTBINDIR).tar.gz + -rm -rf -- $(DISTBINDIR) + -rm -f -- $(DISTDIR).tar.gz + -rm -rf -- $(DISTDIR) + -rm -f -- $(ORIGDIR).tar.gz + -rm -rf -- $(ORIGDIR) + + +$(DISTBINDIR): + $(INSTALL_DIR) $(DISTBINDIR) + +libdir: all $(DISTBINDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTBINDIR) + $(INSTALL_DATA) $(SOURCES) $(DISTBINDIR) + $(INSTALL_DATA) $(HELPPATCHES) $(DISTBINDIR) + test -z "$(strip $(EXTRA_DIST))" || \ + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTBINDIR) +# tar --exclude-vcs -czpf $(DISTBINDIR).tar.gz $(DISTBINDIR) -test_locations: - make -C $(EXTERNALS_ROOT) test_locations +$(DISTDIR): + $(INSTALL_DIR) $(DISTDIR) + +$(ORIGDIR): + $(INSTALL_DIR) $(ORIGDIR) + +dist: $(DISTDIR) + $(INSTALL_DATA) Makefile $(DISTDIR) + $(INSTALL_DATA) README.txt $(DISTDIR) + $(INSTALL_DATA) LICENSE.txt $(DISTDIR) + $(INSTALL_DATA) $(LIBRARY_NAME)-meta.pd $(DISTDIR) + test -z "$(strip $(ALLSOURCES))" || \ + $(INSTALL_DATA) $(ALLSOURCES) $(DISTDIR) + test -z "$(strip $(PDOBJECTS))" || \ + $(INSTALL_DATA) $(PDOBJECTS) $(DISTDIR) + test -z "$(strip $(HELPPATCHES))" || \ + $(INSTALL_DATA) $(HELPPATCHES) $(DISTDIR) + test -z "$(strip $(EXTRA_DIST))" || \ + $(INSTALL_DATA) $(EXTRA_DIST) $(DISTDIR) + test -z "$(strip $(EXAMPLES))" || \ + $(INSTALL_DIR) $(DISTDIR)/examples && \ + for file in $(EXAMPLES); do \ + $(INSTALL_DATA) examples/$$file $(DISTDIR)/examples; \ + done + test -z "$(strip $(MANUAL))" || \ + $(INSTALL_DIR) $(DISTDIR)/manual && \ + for file in $(MANUAL); do \ + $(INSTALL_DATA) manual/$$file $(DISTDIR)/manual; \ + done + tar --exclude-vcs -czpf $(DISTDIR).tar.gz $(DISTDIR) + +# make a Debian source package +dpkg-source: + debclean + make distclean dist + mv $(DISTDIR) $(ORIGDIR) + tar --exclude-vcs -czpf ../$(ORIGDIR).orig.tar.gz $(ORIGDIR) + rm -f -- $(DISTDIR).tar.gz + rm -rf -- $(DISTDIR) $(ORIGDIR) + cd .. && dpkg-source -b $(LIBRARY_NAME) etags: - etags *.[ch] ../../pd/src/*.[ch] /usr/include/*.h /usr/include/sys/*.h \ - shared/*.[ch] + etags *.h $(SOURCES) ../../pd/src/*.[ch] /usr/include/*.h /usr/include/*/*.h + +showsetup: + @echo "CFLAGS: $(CFLAGS)" + @echo "LDFLAGS: $(LDFLAGS)" + @echo "LIBS: $(LIBS)" + @echo "PD_INCLUDE: $(PD_INCLUDE)" + @echo "PD_PATH: $(PD_PATH)" + @echo "objectsdir: $(objectsdir)" + @echo "LIBRARY_NAME: $(LIBRARY_NAME)" + @echo "LIBRARY_VERSION: $(LIBRARY_VERSION)" + @echo "SOURCES: $(SOURCES)" + @echo "PDOBJECTS: $(PDOBJECTS)" + @echo "ALLSOURCES: $(ALLSOURCES)" + @echo "UNAME: $(UNAME)" + @echo "CPU: $(CPU)" + @echo "pkglibdir: $(pkglibdir)" + @echo "DISTDIR: $(DISTDIR)" + @echo "ORIGDIR: $(ORIGDIR)" diff --git a/checkbutton.c b/checkbutton.c index 1ad0bb5..00f752b 100644 --- a/checkbutton.c +++ b/checkbutton.c @@ -24,7 +24,7 @@ /* TODO bind to so that things are redrawn when the label changes */ /* TODO add float method to set state based on == 0 and everything else */ -#include "shared/tkwidgets.h" +#include "tkwidgets.h" #define DEBUG(x) x diff --git a/photo.c b/photo.c index 09e542e..258d101 100644 --- a/photo.c +++ b/photo.c @@ -21,7 +21,7 @@ */ -#include "shared/tkwidgets.h" +#include "tkwidgets.h" /* ------------------------ photo ----------------------------- */ diff --git a/shared/tkwidgets.c b/shared/tkwidgets.c deleted file mode 100644 index b37e03f..0000000 --- a/shared/tkwidgets.c +++ /dev/null @@ -1,287 +0,0 @@ -/* - Copyright (C) 2007 Free Software Foundation - written by Hans-Christoph Steiner - - This program 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. - - This program 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 this program; if not, write to the Free Software - Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - - This is the shared library for the tkwidgets library for Pd. - -*/ - -/* TODO apply store logic to query so query doesn't send blank options */ - -#include "tkwidgets.h" -#include -#include - -#define DEBUG(x) -//#define DEBUG(x) x - -/* -------------------- options handling ------------------------------------ */ - -void tkwidgets_query_options(t_symbol *receive_name, t_symbol *widget_id, - int argc, char** argv) -{ - int i; - for(i = 0; i < argc; i++) - sys_vgui("pd [concat %s query_callback %s [%s cget -%s] \\;]\n", - receive_name->s_name, argv[i], widget_id->s_name, argv[i]); -} - -/* this queries the widget for each option listed in the tk_options struct, - * builts a list in Tcl-space, then send that list to the store_callback */ -void tkwidgets_store_options(t_symbol *receive_name, t_symbol *tcl_namespace, - t_symbol *widget_id, int argc, char **argv) -{ - int i; - for(i = 0; i < argc; i++) - { - sys_vgui("set ::%s::tmp [%s cget -%s]\n", - tcl_namespace->s_name, widget_id->s_name, argv[i]); - sys_vgui("if {[string length $::%s::tmp] > 0} {\n", - tcl_namespace->s_name); - sys_vgui("lappend ::%s::list -%s; lappend ::%s::list $::%s::tmp}\n", - tcl_namespace->s_name, argv[i], - tcl_namespace->s_name, tcl_namespace->s_name); - } - sys_vgui("pd [concat %s store_callback $::%s::list \\;]\n", - receive_name->s_name, tcl_namespace->s_name); - sys_vgui("unset ::%s::list \n", tcl_namespace->s_name); -} - -void tkwidgets_restore_options(t_symbol *widget_id, t_binbuf *options_binbuf) -{ - int length; - char *options; - binbuf_gettext(options_binbuf, &options, &length); - options[length] = 0; //binbuf_gettext() doesn't put a null, so we do - sys_vgui("%s configure %s\n", widget_id->s_name, options); -} - -/* output a list of available options for this widget */ -void tkwidgets_list_options(t_outlet *status_outlet, int argc, char** argv) -{ - int i; - t_binbuf *bb = binbuf_new(); - for(i = 0; i < argc; ++i) - { - binbuf_addv(bb, "s", gensym(argv[i])); - } - outlet_anything(status_outlet, gensym("options"), - binbuf_getnatom(bb), binbuf_getvec(bb)); -} - - -/* -------------------- generate names for various elements ----------------- */ - -t_symbol* tkwidgets_gen_tcl_namespace(t_object* x, t_symbol* widget_name) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"%s%lx", widget_name->s_name, (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_callback_name(t_symbol* tcl_namespace) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"#%s", tcl_namespace->s_name); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_canvas_id(t_canvas* canvas) -{ - char buf[MAXPDSTRING]; - sprintf(buf,".x%lx.c", (long unsigned int) canvas); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_frame_id(t_object* x, t_symbol* canvas_id) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"%s.frame%lx", canvas_id->s_name, (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_widget_id(t_object* x, t_symbol* parent_id) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"%s.widget%lx", parent_id->s_name, (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_handle_id(t_object *x, t_symbol* canvas_id) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"%s.handle%lx", canvas_id->s_name, (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_scrollbar_id(t_object *x, t_symbol* frame_id) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"%s.scrollbar%lx", frame_id->s_name, (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_window_tag(t_object* x, t_symbol* canvas_id) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"%s.window%lx", canvas_id->s_name, (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_iolets_tag(t_object* x) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"iolets%lx", (long unsigned int)x); - return gensym(buf); -} - -t_symbol* tkwidgets_gen_all_tag(t_object *x) -{ - char buf[MAXPDSTRING]; - sprintf(buf,"all%lx", (long unsigned int)x); - return gensym(buf); -} - -/* -------------------- inlets/outlets -------------------------------------- */ - -static int calculate_onset(int x_location, int width, - int current_iolet, int total_iolets) -{ - DEBUG(post("calculate_onset");); - return(x_location + (width - IOWIDTH) \ - * current_iolet / (total_iolets == 1 ? 1 : total_iolets - 1)); -} - -/* standard method for drawing inlets and outlets. Currently, the number of - * inlets and outlets is set in tkwidgets.h since I think all of the - * objectclasses will have the same ones. If that needs to change, then this - * function can use obj_ninlets() and obj_noutlets() */ -void tkwidgets_draw_iolets(t_object *x, t_glist *glist, t_symbol *canvas_id, - t_symbol *iolets_tag, t_symbol *all_tag, - int width, int height) -{ - int i, onset; - int x_location = text_xpix(x, glist); - int y_location = text_ypix(x, glist); - -/* TODO: make inlets draw on top of widget */ - for (i = 0; i < TOTAL_INLETS; i++) /* inlets */ - { - onset = calculate_onset(x_location, width, i, TOTAL_INLETS); - sys_vgui("%s create rectangle %d %d %d %d -tags {%s %s}\n", - canvas_id->s_name, onset, y_location - 2, - onset + IOWIDTH, y_location, - iolets_tag->s_name, all_tag->s_name); - sys_vgui("%s raise %s\n", canvas_id->s_name, iolets_tag->s_name); - } - for (i = 0; i < TOTAL_OUTLETS; i++) /* outlets */ - { - onset = calculate_onset(x_location, width, i, TOTAL_OUTLETS); - sys_vgui("%s create rectangle %d %d %d %d -tags {%s %s}\n", - canvas_id->s_name, onset, y_location + height, - onset + IOWIDTH, y_location + height + 2, - iolets_tag->s_name, all_tag->s_name); - sys_vgui("%s raise %s\n", canvas_id->s_name, iolets_tag->s_name); - } -} - -void tkwidgets_erase_iolets(t_symbol* canvas_id, t_symbol* iolets_tag) -{ - sys_vgui("%s delete %s\n", canvas_id->s_name, iolets_tag->s_name); -} - -/* -------------------- scrollbars ------------------------------------------ */ - -void tkwidgets_draw_y_scrollbar(t_symbol *widget_id, t_symbol *scrollbar_id) -{ - sys_vgui("scrollbar %s -orient vertical -command {%s yview}\n", - scrollbar_id->s_name, widget_id->s_name); - sys_vgui("pack %s -side right -fill y -before %s \n", - scrollbar_id->s_name, widget_id->s_name); - sys_vgui("%s configure -yscrollcommand {%s set}\n", - widget_id->s_name, scrollbar_id->s_name); -} - -void tkwidgets_erase_y_scrollbar(t_symbol *widget_id, t_symbol *scrollbar_id) -{ - sys_vgui("%s configure -yscrollcommand {}\n", widget_id->s_name); - sys_vgui("pack forget %s \n", scrollbar_id->s_name); - sys_vgui("destroy %s \n", scrollbar_id->s_name); -} - -/* -------------------- bind to keys and mouse events ----------------------- */ - -void tkwidgets_bind_key_events(t_symbol *canvas_id, t_symbol *widget_id) -{ -#ifdef __APPLE__ - sys_vgui("bind %s {pdtk_canvas_ctrlkey %s %%K 0}\n", - widget_id->s_name, canvas_id->s_name); - sys_vgui("bind %s {pdtk_canvas_ctrlkey %s %%K 1}\n", - widget_id->s_name, canvas_id->s_name); -#else - sys_vgui("bind %s {pdtk_canvas_ctrlkey %s %%K 0}\n", - widget_id->s_name, canvas_id->s_name); - sys_vgui("bind %s {pdtk_canvas_ctrlkey %s %%K 1}\n", - widget_id->s_name, canvas_id->s_name); -#endif -} - -void tkwidgets_bind_mouse_events(t_symbol *canvas_id, t_symbol *widget_id) -{ - /* mouse buttons */ - sys_vgui("bind %s