summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_vdial.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_vdial.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_vdial.c715
1 files changed, 0 insertions, 715 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_vdial.c b/apps/plugins/pdbox/PDa/src/g_vdial.c
index 08b1338daf..47ac3d19bb 100644
--- a/apps/plugins/pdbox/PDa/src/g_vdial.c
+++ b/apps/plugins/pdbox/PDa/src/g_vdial.c
@@ -714,719 +714,4 @@ void g_vradio_setup(void)
714 class_setwidget(vradio_old_class, &vradio_widgetbehavior); 714 class_setwidget(vradio_old_class, &vradio_widgetbehavior);
715 class_sethelpsymbol(vradio_old_class, gensym("vradio")); 715 class_sethelpsymbol(vradio_old_class, gensym("vradio"));
716} 716}
717/* Copyright (c) 1997-1999 Miller Puckette.
718 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
719 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
720
721/* vdial.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
722
723/* name change to vradio by MSP (it's a radio button really) and changed to
724put out a "float" as in sliders, toggles, etc. */
725
726#include <stdlib.h>
727#include <string.h>
728#include <stdio.h>
729#include <ctype.h>
730#include "m_pd.h"
731#include "g_canvas.h"
732#include "t_tk.h"
733#include "g_all_guis.h"
734#include <math.h>
735
736/*------------------ global variables -------------------------*/
737
738
739/*------------------ global functions -------------------------*/
740
741
742
743
744/* ------------- vdl gui-vertical radio button ---------------------- */
745
746t_widgetbehavior vradio_widgetbehavior;
747static t_class *vradio_class, *vradio_old_class;
748
749/* widget helper functions */
750
751void vradio_draw_update(t_vradio *x, t_glist *glist)
752{
753 if(glist_isvisible(glist))
754 {
755 t_canvas *canvas=glist_getcanvas(glist);
756
757 sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n",
758 canvas, x, x->x_on_old,
759 x->x_gui.x_bcol, x->x_gui.x_bcol);
760 sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n",
761 canvas, x, x->x_on,
762 x->x_gui.x_fcol, x->x_gui.x_fcol);
763 }
764}
765
766void vradio_draw_new(t_vradio *x, t_glist *glist)
767{
768 t_canvas *canvas=glist_getcanvas(glist);
769 int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
770 int yy11b=text_ypix(&x->x_gui.x_obj, glist);
771 int yy11=yy11b, yy12=yy11+dy;
772 int yy21=yy11+s4, yy22=yy12-s4;
773 int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy;
774 int xx21=xx11+s4, xx22=xx12-s4;
775
776 for(i=0; i<n; i++)
777 {
778 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE%d\n",
779 canvas, xx11, yy11, xx12, yy12,
780 x->x_gui.x_bcol, x, i);
781 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -outline #%6.6x -tags %xBUT%d\n",
782 canvas, xx21, yy21, xx22, yy22,
783 (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
784 (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol, x, i);
785 yy11 += dy;
786 yy12 += dy;
787 yy21 += dy;
788 yy22 += dy;
789 }
790 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
791 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
792 canvas, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy,
793 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
794 x->x_gui.x_font, x->x_gui.x_fontsize,
795 x->x_gui.x_lcol, x);
796 if(!x->x_gui.x_fsf.x_snd_able)
797 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
798 canvas, xx11, yy11-1, xx11 + IOWIDTH, yy11, x, 0);
799 if(!x->x_gui.x_fsf.x_rcv_able)
800 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
801 canvas, xx11, yy11b, xx11 + IOWIDTH, yy11b+1, x, 0);
802}
803
804void vradio_draw_move(t_vradio *x, t_glist *glist)
805{
806 t_canvas *canvas=glist_getcanvas(glist);
807 int n=x->x_number, i, dy=x->x_gui.x_h, s4=dy/4;
808 int yy11b=text_ypix(&x->x_gui.x_obj, glist);
809 int yy11=yy11b, yy12=yy11+dy;
810 int yy21=yy11+s4, yy22=yy12-s4;
811 int xx11=text_xpix(&x->x_gui.x_obj, glist), xx12=xx11+dy;
812 int xx21=xx11+s4, xx22=xx12-s4;
813
814 for(i=0; i<n; i++)
815 {
816 sys_vgui(".x%x.c coords %xBASE%d %d %d %d %d\n",
817 canvas, x, i, xx11, yy11, xx12, yy12);
818 sys_vgui(".x%x.c coords %xBUT%d %d %d %d %d\n",
819 canvas, x, i, xx21, yy21, xx22, yy22);
820 yy11 += dy;
821 yy12 += dy;
822 yy21 += dy;
823 yy22 += dy;
824 }
825 sys_vgui(".x%x.c coords %xLABEL %d %d\n",
826 canvas, x, xx11+x->x_gui.x_ldx, yy11b+x->x_gui.x_ldy);
827 if(!x->x_gui.x_fsf.x_snd_able)
828 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
829 canvas, x, 0, xx11, yy11-1, xx11 + IOWIDTH, yy11);
830 if(!x->x_gui.x_fsf.x_rcv_able)
831 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
832 canvas, x, 0, xx11, yy11b, xx11 + IOWIDTH, yy11b+1);
833}
834
835void vradio_draw_erase(t_vradio* x, t_glist* glist)
836{
837 t_canvas *canvas=glist_getcanvas(glist);
838 int n=x->x_number, i;
839
840 for(i=0; i<n; i++)
841 {
842 sys_vgui(".x%x.c delete %xBASE%d\n", canvas, x, i);
843 sys_vgui(".x%x.c delete %xBUT%d\n", canvas, x, i);
844 }
845 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
846 if(!x->x_gui.x_fsf.x_snd_able)
847 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
848 if(!x->x_gui.x_fsf.x_rcv_able)
849 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
850}
851
852void vradio_draw_config(t_vradio* x, t_glist* glist)
853{
854 t_canvas *canvas=glist_getcanvas(glist);
855 int n=x->x_number, i;
856
857 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
858 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
859 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
860 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
861 for(i=0; i<n; i++)
862 {
863 sys_vgui(".x%x.c itemconfigure %xBASE%d -fill #%6.6x\n", canvas, x, i,
864 x->x_gui.x_bcol);
865 sys_vgui(".x%x.c itemconfigure %xBUT%d -fill #%6.6x -outline #%6.6x\n", canvas, x, i,
866 (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol,
867 (x->x_on==i)?x->x_gui.x_fcol:x->x_gui.x_bcol);
868 }
869}
870
871void vradio_draw_io(t_vradio* x, t_glist* glist, int old_snd_rcv_flags)
872{
873 t_canvas *canvas=glist_getcanvas(glist);
874 int xpos=text_xpix(&x->x_gui.x_obj, glist);
875 int ypos=text_ypix(&x->x_gui.x_obj, glist);
876
877 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
878 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
879 canvas, xpos,
880 ypos+(x->x_number*x->x_gui.x_h)-1,
881 xpos+ IOWIDTH,
882 ypos+(x->x_number*x->x_gui.x_h), x, 0);
883 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
884 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
885 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
886 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
887 canvas, xpos, ypos,
888 xpos+ IOWIDTH, ypos+1,
889 x, 0);
890 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
891 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
892}
893
894void vradio_draw_select(t_vradio* x, t_glist* glist)
895{
896 t_canvas *canvas=glist_getcanvas(glist);
897 int n=x->x_number, i;
898
899 if(x->x_gui.x_fsf.x_selected)
900 {
901 for(i=0; i<n; i++)
902 {
903 sys_vgui(".x%x.c itemconfigure %xBASE%d -outline #%6.6x\n", canvas, x, i,
904 IEM_GUI_COLOR_SELECTED);
905 }
906 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
907 }
908 else
909 {
910 for(i=0; i<n; i++)
911 {
912 sys_vgui(".x%x.c itemconfigure %xBASE%d -outline #%6.6x\n", canvas, x, i,
913 IEM_GUI_COLOR_NORMAL);
914 }
915 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x,
916 x->x_gui.x_lcol);
917 }
918}
919
920void vradio_draw(t_vradio *x, t_glist *glist, int mode)
921{
922 if(mode == IEM_GUI_DRAW_MODE_UPDATE)
923 vradio_draw_update(x, glist);
924 else if(mode == IEM_GUI_DRAW_MODE_MOVE)
925 vradio_draw_move(x, glist);
926 else if(mode == IEM_GUI_DRAW_MODE_NEW)
927 vradio_draw_new(x, glist);
928 else if(mode == IEM_GUI_DRAW_MODE_SELECT)
929 vradio_draw_select(x, glist);
930 else if(mode == IEM_GUI_DRAW_MODE_ERASE)
931 vradio_draw_erase(x, glist);
932 else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
933 vradio_draw_config(x, glist);
934 else if(mode >= IEM_GUI_DRAW_MODE_IO)
935 vradio_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
936}
937
938/* ------------------------ vdl widgetbehaviour----------------------------- */
939
940static void vradio_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2)
941{
942 t_vradio *x = (t_vradio *)z;
943
944 *xp1 = text_xpix(&x->x_gui.x_obj, glist);
945 *yp1 = text_ypix(&x->x_gui.x_obj, glist);
946 *xp2 = *xp1 + x->x_gui.x_w;
947 *yp2 = *yp1 + x->x_gui.x_h*x->x_number;
948}
949 717
950static void vradio_save(t_gobj *z, t_binbuf *b)
951{
952 t_vradio *x = (t_vradio *)z;
953 int bflcol[3];
954 t_symbol *srl[3];
955
956 iemgui_save(&x->x_gui, srl, bflcol);
957 binbuf_addv(b, "ssiisiiiisssiiiiiiii", gensym("#X"),gensym("obj"),
958 (t_int)x->x_gui.x_obj.te_xpix,
959 (t_int)x->x_gui.x_obj.te_ypix,
960 (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class ?
961 gensym("vdl") : gensym("vradio")),
962 x->x_gui.x_w,
963 x->x_change, iem_symargstoint(&x->x_gui.x_isa), x->x_number,
964 srl[0], srl[1], srl[2],
965 x->x_gui.x_ldx, x->x_gui.x_ldy,
966 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
967 bflcol[0], bflcol[1], bflcol[2], x->x_on);
968 binbuf_addv(b, ";");
969}
970
971static void vradio_properties(t_gobj *z, t_glist *owner)
972{
973 t_vradio *x = (t_vradio *)z;
974 char buf[800];
975 t_symbol *srl[3];
976 int hchange=-1;
977
978 iemgui_properties(&x->x_gui, srl);
979 if(pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
980 hchange = x->x_change;
981 sprintf(buf, "pdtk_iemgui_dialog %%s vradio \
982 ----------dimensions(pix):----------- %d %d size: 0 0 empty \
983 empty 0.0 empty 0.0 empty %d \
984 %d new-only new&old %d %d number: %d \
985 %s %s \
986 %s %d %d \
987 %d %d \
988 %d %d %d\n",
989 x->x_gui.x_w, IEM_GUI_MINSIZE,
990 0,/*no_schedule*/
991 hchange, x->x_gui.x_isa.x_loadinit, -1, x->x_number,
992 srl[0]->s_name, srl[1]->s_name,
993 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
994 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
995 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
996 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
997}
998
999static void vradio_dialog(t_vradio *x, t_symbol *s, int argc, t_atom *argv)
1000{
1001 t_symbol *srl[3];
1002 int a = (int)atom_getintarg(0, argc, argv);
1003 int chg = (int)atom_getintarg(4, argc, argv);
1004 int num = (int)atom_getintarg(6, argc, argv);
1005 int sr_flags;
1006
1007 if(chg != 0) chg = 1;
1008 x->x_change = chg;
1009 sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
1010 x->x_gui.x_w = iemgui_clip_size(a);
1011 x->x_gui.x_h = x->x_gui.x_w;
1012 if(x->x_number != num)
1013 {
1014 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
1015 x->x_number = num;
1016 if(x->x_on >= x->x_number)
1017 {
1018 x->x_on = x->x_number - 1;
1019 x->x_on_old = x->x_on;
1020 }
1021 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
1022 }
1023 else
1024 {
1025 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
1026 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
1027 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
1028 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
1029 }
1030}
1031
1032static void vradio_set(t_vradio *x, t_floatarg f)
1033{
1034 int i=(int)f;
1035 int old;
1036
1037 if(i < 0)
1038 i = 0;
1039 if(i >= x->x_number)
1040 i = x->x_number-1;
1041 if(x->x_on != x->x_on_old)
1042 {
1043 old = x->x_on_old;
1044 x->x_on_old = x->x_on;
1045 x->x_on = i;
1046 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1047 x->x_on_old = old;
1048 }
1049 else
1050 {
1051 x->x_on = i;
1052 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1053 }
1054}
1055
1056static void vradio_bang(t_vradio *x)
1057{
1058 /* compatibility with earlier "vdial" behavior */
1059 if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
1060 {
1061 if((x->x_change)&&(x->x_on != x->x_on_old))
1062 {
1063 SETFLOAT(x->x_at, (float)x->x_on_old);
1064 SETFLOAT(x->x_at+1, 0.0);
1065 outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
1066 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1067 pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
1068 }
1069 x->x_on_old = x->x_on;
1070 SETFLOAT(x->x_at, (float)x->x_on);
1071 SETFLOAT(x->x_at+1, 1.0);
1072 outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
1073 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1074 pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
1075 }
1076 else
1077 {
1078 outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
1079 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1080 pd_float(x->x_gui.x_snd->s_thing, x->x_on);
1081 }
1082}
1083
1084static void vradio_fout(t_vradio *x, t_floatarg f)
1085{
1086 int i=(int)f;
1087
1088 if(i < 0)
1089 i = 0;
1090 if(i >= x->x_number)
1091 i = x->x_number-1;
1092
1093 if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
1094 {
1095 /* compatibility with earlier "vdial" behavior */
1096 if((x->x_change)&&(i != x->x_on_old))
1097 {
1098 SETFLOAT(x->x_at, (float)x->x_on_old);
1099 SETFLOAT(x->x_at+1, 0.0);
1100 outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
1101 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1102 pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
1103 }
1104 if(x->x_on != x->x_on_old)
1105 x->x_on_old = x->x_on;
1106 x->x_on = i;
1107 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1108 x->x_on_old = x->x_on;
1109 SETFLOAT(x->x_at, (float)x->x_on);
1110 SETFLOAT(x->x_at+1, 1.0);
1111 outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
1112 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1113 pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
1114 }
1115 else
1116 {
1117 x->x_on_old = x->x_on;
1118 x->x_on = i;
1119 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1120 outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
1121 if (x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1122 pd_float(x->x_gui.x_snd->s_thing, x->x_on);
1123 }
1124}
1125
1126static void vradio_float(t_vradio *x, t_floatarg f)
1127{
1128 int i=(int)f;
1129
1130 if(i < 0)
1131 i = 0;
1132 if(i >= x->x_number)
1133 i = x->x_number-1;
1134
1135 if (pd_class(&x->x_gui.x_obj.ob_pd) == vradio_old_class)
1136 {
1137 /* compatibility with earlier "vdial" behavior */
1138 if((x->x_change)&&(i != x->x_on_old))
1139 {
1140 if(x->x_gui.x_fsf.x_put_in2out)
1141 {
1142 SETFLOAT(x->x_at, (float)x->x_on_old);
1143 SETFLOAT(x->x_at+1, 0.0);
1144 outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
1145 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1146 pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
1147 }
1148 }
1149 if(x->x_on != x->x_on_old)
1150 x->x_on_old = x->x_on;
1151 x->x_on = i;
1152 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1153 x->x_on_old = x->x_on;
1154 if(x->x_gui.x_fsf.x_put_in2out)
1155 {
1156 SETFLOAT(x->x_at, (float)x->x_on);
1157 SETFLOAT(x->x_at+1, 1.0);
1158 outlet_list(x->x_gui.x_obj.ob_outlet, &s_list, 2, x->x_at);
1159 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1160 pd_list(x->x_gui.x_snd->s_thing, &s_list, 2, x->x_at);
1161 }
1162 }
1163 else
1164 {
1165 x->x_on_old = x->x_on;
1166 x->x_on = i;
1167 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1168 if (x->x_gui.x_fsf.x_put_in2out)
1169 {
1170 outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on);
1171 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
1172 pd_float(x->x_gui.x_snd->s_thing, x->x_on);
1173 }
1174 }
1175}
1176
1177static void vradio_click(t_vradio *x, t_floatarg xpos, t_floatarg ypos,
1178 t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
1179{
1180 int yy = (int)ypos - text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist);
1181
1182 vradio_fout(x, (float)(yy / x->x_gui.x_h));
1183}
1184
1185static int vradio_newclick(t_gobj *z, struct _glist *glist,
1186 int xpix, int ypix, int shift, int alt, int dbl, int doit)
1187{
1188 if(doit)
1189 vradio_click((t_vradio *)z, (t_floatarg)xpix, (t_floatarg)ypix,
1190 (t_floatarg)shift, 0, (t_floatarg)alt);
1191 return (1);
1192}
1193
1194static void vradio_loadbang(t_vradio *x)
1195{
1196 if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
1197 vradio_bang(x);
1198}
1199
1200static void vradio_number(t_vradio *x, t_floatarg num)
1201{
1202 int n=(int)num;
1203
1204 if(n < 1)
1205 n = 1;
1206 if(n > IEM_RADIO_MAX)
1207 n = IEM_RADIO_MAX;
1208 if(n != x->x_number)
1209 {
1210 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_ERASE);
1211 x->x_number = n;
1212 if(x->x_on >= x->x_number)
1213 x->x_on = x->x_number - 1;
1214 x->x_on_old = x->x_on;
1215 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_NEW);
1216 }
1217}
1218
1219static void vradio_size(t_vradio *x, t_symbol *s, int ac, t_atom *av)
1220{
1221 x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
1222 x->x_gui.x_h = x->x_gui.x_w;
1223 iemgui_size((void *)x, &x->x_gui);
1224}
1225
1226static void vradio_delta(t_vradio *x, t_symbol *s, int ac, t_atom *av)
1227{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
1228
1229static void vradio_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av)
1230{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
1231
1232static void vradio_color(t_vradio *x, t_symbol *s, int ac, t_atom *av)
1233{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
1234
1235static void vradio_send(t_vradio *x, t_symbol *s)
1236{iemgui_send(x, &x->x_gui, s);}
1237
1238static void vradio_receive(t_vradio *x, t_symbol *s)
1239{iemgui_receive(x, &x->x_gui, s);}
1240
1241static void vradio_label(t_vradio *x, t_symbol *s)
1242{iemgui_label((void *)x, &x->x_gui, s);}
1243
1244static void vradio_label_pos(t_vradio *x, t_symbol *s, int ac, t_atom *av)
1245{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
1246
1247static void vradio_label_font(t_vradio *x, t_symbol *s, int ac, t_atom *av)
1248{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
1249
1250static void vradio_init(t_vradio *x, t_floatarg f)
1251{
1252 x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
1253}
1254
1255static void vradio_double_change(t_vradio *x)
1256{x->x_change = 1;}
1257
1258static void vradio_single_change(t_vradio *x)
1259{x->x_change = 0;}
1260
1261static void *vradio_donew(t_symbol *s, int argc, t_atom *argv, int old)
1262{
1263 t_vradio *x = (t_vradio *)pd_new(old? vradio_old_class : vradio_class);
1264 int bflcol[]={-262144, -1, -1};
1265 int a=IEM_GUI_DEFAULTSIZE, on=0, f=0;
1266 int ldx=0, ldy=-6, chg=1, num=8;
1267 int fs=8;
1268 int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, fthold=IEM_BNG_DEFAULTHOLDFLASHTIME;
1269 char str[144];
1270
1271 if((argc == 15)&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2)
1272 &&IS_A_FLOAT(argv,3)
1273 &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4))
1274 &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5))
1275 &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
1276 &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)
1277 &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)
1278 &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)&&IS_A_FLOAT(argv,14))
1279 {
1280 a = (int)atom_getintarg(0, argc, argv);
1281 chg = (int)atom_getintarg(1, argc, argv);
1282 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(2, argc, argv));
1283 num = (int)atom_getintarg(3, argc, argv);
1284 iemgui_new_getnames(&x->x_gui, 4, argv);
1285 ldx = (int)atom_getintarg(7, argc, argv);
1286 ldy = (int)atom_getintarg(8, argc, argv);
1287 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv));
1288 fs = (int)atom_getintarg(10, argc, argv);
1289 bflcol[0] = (int)atom_getintarg(11, argc, argv);
1290 bflcol[1] = (int)atom_getintarg(12, argc, argv);
1291 bflcol[2] = (int)atom_getintarg(13, argc, argv);
1292 on = (int)atom_getintarg(14, argc, argv);
1293 }
1294 else iemgui_new_getnames(&x->x_gui, 4, 0);
1295 x->x_gui.x_draw = (t_iemfunptr)vradio_draw;
1296 x->x_gui.x_fsf.x_snd_able = 1;
1297 x->x_gui.x_fsf.x_rcv_able = 1;
1298 x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
1299 if (!strcmp(x->x_gui.x_snd->s_name, "empty"))
1300 x->x_gui.x_fsf.x_snd_able = 0;
1301 if (!strcmp(x->x_gui.x_rcv->s_name, "empty"))
1302 x->x_gui.x_fsf.x_rcv_able = 0;
1303 if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
1304 else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
1305 else { x->x_gui.x_fsf.x_font_style = 0;
1306 strcpy(x->x_gui.x_font, "courier"); }
1307 if(num < 1)
1308 num = 1;
1309 if(num > IEM_RADIO_MAX)
1310 num = IEM_RADIO_MAX;
1311 x->x_number = num;
1312 if(on < 0)
1313 on = 0;
1314 if(on >= x->x_number)
1315 on = x->x_number - 1;
1316 if(x->x_gui.x_isa.x_loadinit)
1317 x->x_on = on;
1318 else
1319 x->x_on = 0;
1320 x->x_on_old = x->x_on;
1321 x->x_change = (chg==0)?0:1;
1322 if (x->x_gui.x_fsf.x_rcv_able)
1323 pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1324 x->x_gui.x_ldx = ldx;
1325 x->x_gui.x_ldy = ldy;
1326 if(fs < 4)
1327 fs = 4;
1328 x->x_gui.x_fontsize = fs;
1329 x->x_gui.x_w = iemgui_clip_size(a);
1330 x->x_gui.x_h = x->x_gui.x_w;
1331 iemgui_verify_snd_ne_rcv(&x->x_gui);
1332 iemgui_all_colfromload(&x->x_gui, bflcol);
1333 outlet_new(&x->x_gui.x_obj, &s_list);
1334 return (x);
1335}
1336
1337static void *vradio_new(t_symbol *s, int argc, t_atom *argv)
1338{
1339 return (vradio_donew(s, argc, argv, 0));
1340}
1341
1342static void *vdial_new(t_symbol *s, int argc, t_atom *argv)
1343{
1344 return (vradio_donew(s, argc, argv, 1));
1345}
1346
1347static void vradio_ff(t_vradio *x)
1348{
1349 if(x->x_gui.x_fsf.x_rcv_able)
1350 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1351 gfxstub_deleteforkey(x);
1352}
1353
1354void g_vradio_setup(void)
1355{
1356 vradio_class = class_new(gensym("vradio"), (t_newmethod)vradio_new,
1357 (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0);
1358 class_addbang(vradio_class, vradio_bang);
1359 class_addfloat(vradio_class, vradio_float);
1360 class_addmethod(vradio_class, (t_method)vradio_click, gensym("click"),
1361 A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
1362 class_addmethod(vradio_class, (t_method)vradio_dialog, gensym("dialog"),
1363 A_GIMME, 0);
1364 class_addmethod(vradio_class, (t_method)vradio_loadbang,
1365 gensym("loadbang"), 0);
1366 class_addmethod(vradio_class, (t_method)vradio_set,
1367 gensym("set"), A_FLOAT, 0);
1368 class_addmethod(vradio_class, (t_method)vradio_size,
1369 gensym("size"), A_GIMME, 0);
1370 class_addmethod(vradio_class, (t_method)vradio_delta,
1371 gensym("delta"), A_GIMME, 0);
1372 class_addmethod(vradio_class, (t_method)vradio_pos,
1373 gensym("pos"), A_GIMME, 0);
1374 class_addmethod(vradio_class, (t_method)vradio_color,
1375 gensym("color"), A_GIMME, 0);
1376 class_addmethod(vradio_class, (t_method)vradio_send,
1377 gensym("send"), A_DEFSYM, 0);
1378 class_addmethod(vradio_class, (t_method)vradio_receive,
1379 gensym("receive"), A_DEFSYM, 0);
1380 class_addmethod(vradio_class, (t_method)vradio_label,
1381 gensym("label"), A_DEFSYM, 0);
1382 class_addmethod(vradio_class, (t_method)vradio_label_pos,
1383 gensym("label_pos"), A_GIMME, 0);
1384 class_addmethod(vradio_class, (t_method)vradio_label_font,
1385 gensym("label_font"), A_GIMME, 0);
1386 class_addmethod(vradio_class, (t_method)vradio_init,
1387 gensym("init"), A_FLOAT, 0);
1388 class_addmethod(vradio_class, (t_method)vradio_number,
1389 gensym("number"), A_FLOAT, 0);
1390 class_addmethod(vradio_class, (t_method)vradio_single_change,
1391 gensym("single_change"), 0);
1392 class_addmethod(vradio_class, (t_method)vradio_double_change,
1393 gensym("double_change"), 0);
1394 vradio_widgetbehavior.w_getrectfn = vradio_getrect;
1395 vradio_widgetbehavior.w_displacefn = iemgui_displace;
1396 vradio_widgetbehavior.w_selectfn = iemgui_select;
1397 vradio_widgetbehavior.w_activatefn = NULL;
1398 vradio_widgetbehavior.w_deletefn = iemgui_delete;
1399 vradio_widgetbehavior.w_visfn = iemgui_vis;
1400 vradio_widgetbehavior.w_clickfn = vradio_newclick;
1401 class_setwidget(vradio_class, &vradio_widgetbehavior);
1402 class_sethelpsymbol(vradio_class, gensym("vradio"));
1403 class_setsavefn(vradio_class, vradio_save);
1404 class_setpropertiesfn(vradio_class, vradio_properties);
1405
1406 /* obsolete version (0.34-0.35) */
1407 vradio_old_class = class_new(gensym("vdl"), (t_newmethod)vdial_new,
1408 (t_method)vradio_ff, sizeof(t_vradio), 0, A_GIMME, 0);
1409 class_addbang(vradio_old_class, vradio_bang);
1410 class_addfloat(vradio_old_class, vradio_float);
1411 class_addmethod(vradio_old_class, (t_method)vradio_click, gensym("click"),
1412 A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
1413 class_addmethod(vradio_old_class, (t_method)vradio_dialog, gensym("dialog"),
1414 A_GIMME, 0);
1415 class_addmethod(vradio_old_class, (t_method)vradio_loadbang, gensym("loadbang"), 0);
1416 class_addmethod(vradio_old_class, (t_method)vradio_set, gensym("set"), A_FLOAT, 0);
1417 class_addmethod(vradio_old_class, (t_method)vradio_size, gensym("size"), A_GIMME, 0);
1418 class_addmethod(vradio_old_class, (t_method)vradio_delta, gensym("delta"), A_GIMME, 0);
1419 class_addmethod(vradio_old_class, (t_method)vradio_pos, gensym("pos"), A_GIMME, 0);
1420 class_addmethod(vradio_old_class, (t_method)vradio_color, gensym("color"), A_GIMME, 0);
1421 class_addmethod(vradio_old_class, (t_method)vradio_send, gensym("send"), A_DEFSYM, 0);
1422 class_addmethod(vradio_old_class, (t_method)vradio_receive, gensym("receive"), A_DEFSYM, 0);
1423 class_addmethod(vradio_old_class, (t_method)vradio_label, gensym("label"), A_DEFSYM, 0);
1424 class_addmethod(vradio_old_class, (t_method)vradio_label_pos, gensym("label_pos"), A_GIMME, 0);
1425 class_addmethod(vradio_old_class, (t_method)vradio_label_font, gensym("label_font"), A_GIMME, 0);
1426 class_addmethod(vradio_old_class, (t_method)vradio_init, gensym("init"), A_FLOAT, 0);
1427 class_addmethod(vradio_old_class, (t_method)vradio_number, gensym("number"), A_FLOAT, 0);
1428 class_addmethod(vradio_old_class, (t_method)vradio_single_change, gensym("single_change"), 0);
1429 class_addmethod(vradio_old_class, (t_method)vradio_double_change, gensym("double_change"), 0);
1430 class_setwidget(vradio_old_class, &vradio_widgetbehavior);
1431 class_sethelpsymbol(vradio_old_class, gensym("vradio"));
1432}