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