summaryrefslogtreecommitdiff
path: root/apps/plugins/pdbox/PDa/src/g_vslider.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_vslider.c')
-rw-r--r--apps/plugins/pdbox/PDa/src/g_vslider.c626
1 files changed, 0 insertions, 626 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_vslider.c b/apps/plugins/pdbox/PDa/src/g_vslider.c
index 8e2e326f30..ee02236769 100644
--- a/apps/plugins/pdbox/PDa/src/g_vslider.c
+++ b/apps/plugins/pdbox/PDa/src/g_vslider.c
@@ -625,630 +625,4 @@ void g_vslider_setup(void)
625 class_setsavefn(vslider_class, vslider_save); 625 class_setsavefn(vslider_class, vslider_save);
626 class_setpropertiesfn(vslider_class, vslider_properties); 626 class_setpropertiesfn(vslider_class, vslider_properties);
627} 627}
628/* Copyright (c) 1997-1999 Miller Puckette.
629 * For information on usage and redistribution, and for a DISCLAIMER OF ALL
630 * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */
631
632/* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */
633/* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */
634
635
636#include <stdlib.h>
637#include <string.h>
638#include <stdio.h>
639#include <ctype.h>
640#include "m_pd.h"
641#include "g_canvas.h"
642#include "t_tk.h"
643#include "g_all_guis.h"
644#include <math.h>
645
646#ifdef MSW
647#include <io.h>
648#else
649#include <unistd.h>
650#endif
651
652
653/* ------------ vsl gui-vertical slider ----------------------- */
654
655t_widgetbehavior vslider_widgetbehavior;
656static t_class *vslider_class;
657
658/* widget helper functions */
659
660static void vslider_draw_update(t_vslider *x, t_glist *glist)
661{
662 if (glist_isvisible(glist))
663 {
664 int r = text_ypix(&x->x_gui.x_obj, glist) + x->x_gui.x_h - (x->x_val + 50)/100;
665 int xpos=text_xpix(&x->x_gui.x_obj, glist);
666
667 sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
668 glist_getcanvas(glist), x, xpos+1, r,
669 xpos + x->x_gui.x_w, r);
670 }
671}
672
673static void vslider_draw_new(t_vslider *x, t_glist *glist)
674{
675 int xpos=text_xpix(&x->x_gui.x_obj, glist);
676 int ypos=text_ypix(&x->x_gui.x_obj, glist);
677 int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
678 t_canvas *canvas=glist_getcanvas(glist);
679
680 sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n",
681 canvas, xpos, ypos-2,
682 xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3,
683 x->x_gui.x_bcol, x);
684 sys_vgui(".x%x.c create line %d %d %d %d -width 3 -fill #%6.6x -tags %xKNOB\n",
685 canvas, xpos+1, r,
686 xpos + x->x_gui.x_w, r, x->x_gui.x_fcol, x);
687 sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \
688 -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n",
689 canvas, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy,
690 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"",
691 x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x);
692 if(!x->x_gui.x_fsf.x_snd_able)
693 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
694 canvas,
695 xpos, ypos + x->x_gui.x_h+2,
696 xpos+7, ypos + x->x_gui.x_h+3,
697 x, 0);
698 if(!x->x_gui.x_fsf.x_rcv_able)
699 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
700 canvas,
701 xpos, ypos-2,
702 xpos+7, ypos-1,
703 x, 0);
704}
705
706static void vslider_draw_move(t_vslider *x, t_glist *glist)
707{
708 int xpos=text_xpix(&x->x_gui.x_obj, glist);
709 int ypos=text_ypix(&x->x_gui.x_obj, glist);
710 int r = ypos + x->x_gui.x_h - (x->x_val + 50)/100;
711 t_canvas *canvas=glist_getcanvas(glist);
712
713 sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n",
714 canvas, x,
715 xpos, ypos-2,
716 xpos + x->x_gui.x_w, ypos + x->x_gui.x_h+3);
717 sys_vgui(".x%x.c coords %xKNOB %d %d %d %d\n",
718 canvas, x, xpos+1, r,
719 xpos + x->x_gui.x_w, r);
720 sys_vgui(".x%x.c coords %xLABEL %d %d\n",
721 canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy);
722 if(!x->x_gui.x_fsf.x_snd_able)
723 sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n",
724 canvas, x, 0,
725 xpos, ypos + x->x_gui.x_h+2,
726 xpos+7, ypos + x->x_gui.x_h+3);
727 if(!x->x_gui.x_fsf.x_rcv_able)
728 sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n",
729 canvas, x, 0,
730 xpos, ypos-2,
731 xpos+7, ypos-1);
732}
733
734static void vslider_draw_erase(t_vslider* x,t_glist* glist)
735{
736 t_canvas *canvas=glist_getcanvas(glist);
737
738 sys_vgui(".x%x.c delete %xBASE\n", canvas, x);
739 sys_vgui(".x%x.c delete %xKNOB\n", canvas, x);
740 sys_vgui(".x%x.c delete %xLABEL\n", canvas, x);
741 if(!x->x_gui.x_fsf.x_snd_able)
742 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
743 if(!x->x_gui.x_fsf.x_rcv_able)
744 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
745}
746
747static void vslider_draw_config(t_vslider* x,t_glist* glist)
748{
749 t_canvas *canvas=glist_getcanvas(glist);
750
751 sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n",
752 canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize,
753 x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol,
754 strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"");
755 sys_vgui(".x%x.c itemconfigure %xKNOB -fill #%6.6x\n", canvas,
756 x, x->x_gui.x_fcol);
757 sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas,
758 x, x->x_gui.x_bcol);
759}
760
761static void vslider_draw_io(t_vslider* x,t_glist* glist, int old_snd_rcv_flags)
762{
763 int xpos=text_xpix(&x->x_gui.x_obj, glist);
764 int ypos=text_ypix(&x->x_gui.x_obj, glist);
765 t_canvas *canvas=glist_getcanvas(glist);
766
767 if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able)
768 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n",
769 canvas,
770 xpos, ypos + x->x_gui.x_h+2,
771 xpos+7, ypos + x->x_gui.x_h+3,
772 x, 0);
773 if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able)
774 sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0);
775 if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able)
776 sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n",
777 canvas,
778 xpos, ypos-2,
779 xpos+7, ypos-1,
780 x, 0);
781 if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able)
782 sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0);
783}
784
785static void vslider_draw_select(t_vslider *x, t_glist *glist)
786{
787 t_canvas *canvas=glist_getcanvas(glist);
788
789 if(x->x_gui.x_fsf.x_selected)
790 {
791 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
792 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED);
793 }
794 else
795 {
796 sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL);
797 sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol);
798 }
799}
800
801void vslider_draw(t_vslider *x, t_glist *glist, int mode)
802{
803 if(mode == IEM_GUI_DRAW_MODE_UPDATE)
804 vslider_draw_update(x, glist);
805 else if(mode == IEM_GUI_DRAW_MODE_MOVE)
806 vslider_draw_move(x, glist);
807 else if(mode == IEM_GUI_DRAW_MODE_NEW)
808 vslider_draw_new(x, glist);
809 else if(mode == IEM_GUI_DRAW_MODE_SELECT)
810 vslider_draw_select(x, glist);
811 else if(mode == IEM_GUI_DRAW_MODE_ERASE)
812 vslider_draw_erase(x, glist);
813 else if(mode == IEM_GUI_DRAW_MODE_CONFIG)
814 vslider_draw_config(x, glist);
815 else if(mode >= IEM_GUI_DRAW_MODE_IO)
816 vslider_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO);
817}
818
819/* ------------------------ vsl widgetbehaviour----------------------------- */
820
821
822static void vslider_getrect(t_gobj *z, t_glist *glist,
823 int *xp1, int *yp1, int *xp2, int *yp2)
824{
825 t_vslider* x = (t_vslider*)z;
826
827 *xp1 = text_xpix(&x->x_gui.x_obj, glist);
828 *yp1 = text_ypix(&x->x_gui.x_obj, glist) - 2;
829 *xp2 = *xp1 + x->x_gui.x_w;
830 *yp2 = *yp1 + x->x_gui.x_h + 5;
831}
832
833static void vslider_save(t_gobj *z, t_binbuf *b)
834{
835 t_vslider *x = (t_vslider *)z;
836 int bflcol[3];
837 t_symbol *srl[3];
838
839 iemgui_save(&x->x_gui, srl, bflcol);
840 binbuf_addv(b, "ssiisiiffiisssiiiiiiiii", gensym("#X"),gensym("obj"),
841 (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix,
842 gensym("vsl"), x->x_gui.x_w, x->x_gui.x_h,
843 (float)x->x_min, (float)x->x_max,
844 x->x_lin0_log1, iem_symargstoint(&x->x_gui.x_isa),
845 srl[0], srl[1], srl[2],
846 x->x_gui.x_ldx, x->x_gui.x_ldy,
847 iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize,
848 bflcol[0], bflcol[1], bflcol[2],
849 x->x_val, x->x_steady);
850 binbuf_addv(b, ";");
851}
852
853void vslider_check_height(t_vslider *x, int h)
854{
855 if(h < IEM_SL_MINSIZE)
856 h = IEM_SL_MINSIZE;
857 x->x_gui.x_h = h;
858 if(x->x_val > (x->x_gui.x_h*100 - 100))
859 {
860 x->x_pos = x->x_gui.x_h*100 - 100;
861 x->x_val = x->x_pos;
862 }
863 if(x->x_lin0_log1)
864 x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1);
865 else
866 x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
867}
868
869void vslider_check_minmax(t_vslider *x, double min, double max)
870{
871 if(x->x_lin0_log1)
872 {
873 if((min == 0.0)&&(max == 0.0))
874 max = 1.0;
875 if(max > 0.0)
876 {
877 if(min <= 0.0)
878 min = 0.01*max;
879 }
880 else
881 {
882 if(min > 0.0)
883 max = 0.01*min;
884 }
885 }
886 x->x_min = min;
887 x->x_max = max;
888 if(x->x_min > x->x_max) /* bugfix */
889 x->x_gui.x_isa.x_reverse = 1;
890 else
891 x->x_gui.x_isa.x_reverse = 0;
892 if(x->x_lin0_log1)
893 x->x_k = log(x->x_max/x->x_min)/(double)(x->x_gui.x_h - 1);
894 else
895 x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
896}
897
898static void vslider_properties(t_gobj *z, t_glist *owner)
899{
900 t_vslider *x = (t_vslider *)z;
901 char buf[800];
902 t_symbol *srl[3];
903
904 iemgui_properties(&x->x_gui, srl);
905
906 sprintf(buf, "pdtk_iemgui_dialog %%s VSLIDER \
907 --------dimensions(pix)(pix):-------- %d %d width: %d %d height: \
908 -----------output-range:----------- %g bottom: %g top: %d \
909 %d lin log %d %d empty %d \
910 %s %s \
911 %s %d %d \
912 %d %d \
913 %d %d %d\n",
914 x->x_gui.x_w, IEM_GUI_MINSIZE, x->x_gui.x_h, IEM_SL_MINSIZE,
915 x->x_min, x->x_max, 0,/*no_schedule*/
916 x->x_lin0_log1, x->x_gui.x_isa.x_loadinit, x->x_steady, -1,/*no multi, but iem-characteristic*/
917 srl[0]->s_name, srl[1]->s_name,
918 srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy,
919 x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize,
920 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol);
921 gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf);
922}
923
924static void vslider_bang(t_vslider *x)
925{
926 double out;
927
928 if(x->x_lin0_log1)
929 out = x->x_min*exp(x->x_k*(double)(x->x_val)*0.01);
930 else
931 out = (double)(x->x_val)*0.01*x->x_k + x->x_min;
932 if((out < 1.0e-10)&&(out > -1.0e-10))
933 out = 0.0;
934
935 outlet_float(x->x_gui.x_obj.ob_outlet, out);
936 if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing)
937 pd_float(x->x_gui.x_snd->s_thing, out);
938}
939
940static void vslider_dialog(t_vslider *x, t_symbol *s, int argc, t_atom *argv)
941{
942 t_symbol *srl[3];
943 int w = (int)atom_getintarg(0, argc, argv);
944 int h = (int)atom_getintarg(1, argc, argv);
945 double min = (double)atom_getfloatarg(2, argc, argv);
946 double max = (double)atom_getfloatarg(3, argc, argv);
947 int lilo = (int)atom_getintarg(4, argc, argv);
948 int steady = (int)atom_getintarg(17, argc, argv);
949 int sr_flags;
950
951 if(lilo != 0) lilo = 1;
952 x->x_lin0_log1 = lilo;
953 if(steady)
954 x->x_steady = 1;
955 else
956 x->x_steady = 0;
957 sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv);
958 x->x_gui.x_w = iemgui_clip_size(w);
959 vslider_check_height(x, h);
960 vslider_check_minmax(x, min, max);
961 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG);
962 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags);
963 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE);
964 canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x);
965}
966 628
967static void vslider_motion(t_vslider *x, t_floatarg dx, t_floatarg dy)
968{
969 int old = x->x_val;
970
971 if(x->x_gui.x_fsf.x_finemoved)
972 x->x_pos -= (int)dy;
973 else
974 x->x_pos -= 100*(int)dy;
975 x->x_val = x->x_pos;
976 if(x->x_val > (100*x->x_gui.x_h - 100))
977 {
978 x->x_val = 100*x->x_gui.x_h - 100;
979 x->x_pos += 50;
980 x->x_pos -= x->x_pos%100;
981 }
982 if(x->x_val < 0)
983 {
984 x->x_val = 0;
985 x->x_pos -= 50;
986 x->x_pos -= x->x_pos%100;
987 }
988 if(old != x->x_val)
989 {
990 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
991 vslider_bang(x);
992 }
993}
994
995static void vslider_click(t_vslider *x, t_floatarg xpos, t_floatarg ypos,
996 t_floatarg shift, t_floatarg ctrl, t_floatarg alt)
997{
998 if(!x->x_steady)
999 x->x_val = (int)(100.0 * (x->x_gui.x_h + text_ypix(&x->x_gui.x_obj, x->x_gui.x_glist) - ypos));
1000 if(x->x_val > (100*x->x_gui.x_h - 100))
1001 x->x_val = 100*x->x_gui.x_h - 100;
1002 if(x->x_val < 0)
1003 x->x_val = 0;
1004 x->x_pos = x->x_val;
1005 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1006 vslider_bang(x);
1007 glist_grab(x->x_gui.x_glist, &x->x_gui.x_obj.te_g,
1008 (t_glistmotionfn)vslider_motion, 0, xpos, ypos);
1009}
1010
1011static int vslider_newclick(t_gobj *z, struct _glist *glist,
1012 int xpix, int ypix, int shift, int alt, int dbl, int doit)
1013{
1014 t_vslider* x = (t_vslider *)z;
1015
1016 if(doit)
1017 {
1018 vslider_click( x, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift,
1019 0, (t_floatarg)alt);
1020 if(shift)
1021 x->x_gui.x_fsf.x_finemoved = 1;
1022 else
1023 x->x_gui.x_fsf.x_finemoved = 0;
1024 }
1025 return (1);
1026}
1027
1028static void vslider_set(t_vslider *x, t_floatarg f)
1029{
1030 double g;
1031
1032 if(x->x_gui.x_isa.x_reverse) /* bugfix */
1033 {
1034 if(f > x->x_min)
1035 f = x->x_min;
1036 if(f < x->x_max)
1037 f = x->x_max;
1038 }
1039 else
1040 {
1041 if(f > x->x_max)
1042 f = x->x_max;
1043 if(f < x->x_min)
1044 f = x->x_min;
1045 }
1046 if(x->x_lin0_log1)
1047 g = log(f/x->x_min)/x->x_k;
1048 else
1049 g = (f - x->x_min) / x->x_k;
1050 x->x_val = (int)(100.0*g + 0.49999);
1051 x->x_pos = x->x_val;
1052 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1053}
1054
1055static void vslider_float(t_vslider *x, t_floatarg f)
1056{
1057 vslider_set(x, f);
1058 if(x->x_gui.x_fsf.x_put_in2out)
1059 vslider_bang(x);
1060}
1061
1062static void vslider_size(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1063{
1064 x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av));
1065 if(ac > 1)
1066 vslider_check_height(x, (int)atom_getintarg(1, ac, av));
1067 iemgui_size((void *)x, &x->x_gui);
1068}
1069
1070static void vslider_delta(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1071{iemgui_delta((void *)x, &x->x_gui, s, ac, av);}
1072
1073static void vslider_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1074{iemgui_pos((void *)x, &x->x_gui, s, ac, av);}
1075
1076static void vslider_range(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1077{
1078 vslider_check_minmax(x, (double)atom_getfloatarg(0, ac, av),
1079 (double)atom_getfloatarg(1, ac, av));
1080}
1081
1082static void vslider_color(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1083{iemgui_color((void *)x, &x->x_gui, s, ac, av);}
1084
1085static void vslider_send(t_vslider *x, t_symbol *s)
1086{iemgui_send(x, &x->x_gui, s);}
1087
1088static void vslider_receive(t_vslider *x, t_symbol *s)
1089{iemgui_receive(x, &x->x_gui, s);}
1090
1091static void vslider_label(t_vslider *x, t_symbol *s)
1092{iemgui_label((void *)x, &x->x_gui, s);}
1093
1094static void vslider_label_pos(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1095{iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);}
1096
1097static void vslider_label_font(t_vslider *x, t_symbol *s, int ac, t_atom *av)
1098{iemgui_label_font((void *)x, &x->x_gui, s, ac, av);}
1099
1100static void vslider_log(t_vslider *x)
1101{
1102 x->x_lin0_log1 = 1;
1103 vslider_check_minmax(x, x->x_min, x->x_max);
1104}
1105
1106static void vslider_lin(t_vslider *x)
1107{
1108 x->x_lin0_log1 = 0;
1109 x->x_k = (x->x_max - x->x_min)/(double)(x->x_gui.x_h - 1);
1110}
1111
1112static void vslider_init(t_vslider *x, t_floatarg f)
1113{
1114 x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1;
1115}
1116
1117static void vslider_steady(t_vslider *x, t_floatarg f)
1118{
1119 x->x_steady = (f==0.0)?0:1;
1120}
1121
1122static void vslider_loadbang(t_vslider *x)
1123{
1124 if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit)
1125 {
1126 (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE);
1127 vslider_bang(x);
1128 }
1129}
1130
1131static void *vslider_new(t_symbol *s, int argc, t_atom *argv)
1132{
1133 t_vslider *x = (t_vslider *)pd_new(vslider_class);
1134 int bflcol[]={-262144, -1, -1};
1135 int w=IEM_GUI_DEFAULTSIZE, h=IEM_SL_DEFAULTSIZE;
1136 int lilo=0, f=0, ldx=0, ldy=-8;
1137 int fs=8, v=0, steady=1;
1138 double min=0.0, max=(double)(IEM_SL_DEFAULTSIZE-1);
1139 char str[144];
1140
1141 iem_inttosymargs(&x->x_gui.x_isa, 0);
1142 iem_inttofstyle(&x->x_gui.x_fsf, 0);
1143
1144 if(((argc == 17)||(argc == 18))&&IS_A_FLOAT(argv,0)&&IS_A_FLOAT(argv,1)
1145 &&IS_A_FLOAT(argv,2)&&IS_A_FLOAT(argv,3)
1146 &&IS_A_FLOAT(argv,4)&&IS_A_FLOAT(argv,5)
1147 &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6))
1148 &&(IS_A_SYMBOL(argv,7)||IS_A_FLOAT(argv,7))
1149 &&(IS_A_SYMBOL(argv,8)||IS_A_FLOAT(argv,8))
1150 &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)
1151 &&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)
1152 &&IS_A_FLOAT(argv,14)&&IS_A_FLOAT(argv,15)&&IS_A_FLOAT(argv,16))
1153 {
1154 w = (int)atom_getintarg(0, argc, argv);
1155 h = (int)atom_getintarg(1, argc, argv);
1156 min = (double)atom_getfloatarg(2, argc, argv);
1157 max = (double)atom_getfloatarg(3, argc, argv);
1158 lilo = (int)atom_getintarg(4, argc, argv);
1159 iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(5, argc, argv));
1160 iemgui_new_getnames(&x->x_gui, 6, argv);
1161 ldx = (int)atom_getintarg(9, argc, argv);
1162 ldy = (int)atom_getintarg(10, argc, argv);
1163 iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(11, argc, argv));
1164 fs = (int)atom_getintarg(12, argc, argv);
1165 bflcol[0] = (int)atom_getintarg(13, argc, argv);
1166 bflcol[1] = (int)atom_getintarg(14, argc, argv);
1167 bflcol[2] = (int)atom_getintarg(15, argc, argv);
1168 v = (int)atom_getintarg(16, argc, argv);
1169 }
1170 else iemgui_new_getnames(&x->x_gui, 6, 0);
1171 if((argc == 18)&&IS_A_FLOAT(argv,17))
1172 steady = (int)atom_getintarg(17, argc, argv);
1173 x->x_gui.x_draw = (t_iemfunptr)vslider_draw;
1174 x->x_gui.x_fsf.x_snd_able = 1;
1175 x->x_gui.x_fsf.x_rcv_able = 1;
1176 x->x_gui.x_glist = (t_glist *)canvas_getcurrent();
1177 if(x->x_gui.x_isa.x_loadinit)
1178 x->x_val = v;
1179 else
1180 x->x_val = 0;
1181 x->x_pos = x->x_val;
1182 if(lilo != 0) lilo = 1;
1183 x->x_lin0_log1 = lilo;
1184 if(steady != 0) steady = 1;
1185 x->x_steady = steady;
1186 if(!strcmp(x->x_gui.x_snd->s_name, "empty")) x->x_gui.x_fsf.x_snd_able = 0;
1187 if(!strcmp(x->x_gui.x_rcv->s_name, "empty")) x->x_gui.x_fsf.x_rcv_able = 0;
1188 if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica");
1189 else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times");
1190 else { x->x_gui.x_fsf.x_font_style = 0;
1191 strcpy(x->x_gui.x_font, "courier"); }
1192 if(x->x_gui.x_fsf.x_rcv_able) pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1193 x->x_gui.x_ldx = ldx;
1194 x->x_gui.x_ldy = ldy;
1195 if(fs < 4)
1196 fs = 4;
1197 x->x_gui.x_fontsize = fs;
1198 x->x_gui.x_w = iemgui_clip_size(w);
1199 vslider_check_height(x, h);
1200 vslider_check_minmax(x, min, max);
1201 iemgui_all_colfromload(&x->x_gui, bflcol);
1202 iemgui_verify_snd_ne_rcv(&x->x_gui);
1203 outlet_new(&x->x_gui.x_obj, &s_float);
1204 return (x);
1205}
1206
1207static void vslider_free(t_vslider *x)
1208{
1209 if(x->x_gui.x_fsf.x_rcv_able)
1210 pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv);
1211 gfxstub_deleteforkey(x);
1212}
1213
1214void g_vslider_setup(void)
1215{
1216 vslider_class = class_new(gensym("vsl"), (t_newmethod)vslider_new,
1217 (t_method)vslider_free, sizeof(t_vslider), 0, A_GIMME, 0);
1218 class_addcreator((t_newmethod)vslider_new, gensym("vslider"), A_GIMME, 0);
1219 class_addbang(vslider_class,vslider_bang);
1220 class_addfloat(vslider_class,vslider_float);
1221 class_addmethod(vslider_class, (t_method)vslider_click, gensym("click"),
1222 A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0);
1223 class_addmethod(vslider_class, (t_method)vslider_motion, gensym("motion"),
1224 A_FLOAT, A_FLOAT, 0);
1225 class_addmethod(vslider_class, (t_method)vslider_dialog, gensym("dialog"),
1226 A_GIMME, 0);
1227 class_addmethod(vslider_class, (t_method)vslider_loadbang, gensym("loadbang"), 0);
1228 class_addmethod(vslider_class, (t_method)vslider_set, gensym("set"), A_FLOAT, 0);
1229 class_addmethod(vslider_class, (t_method)vslider_size, gensym("size"), A_GIMME, 0);
1230 class_addmethod(vslider_class, (t_method)vslider_delta, gensym("delta"), A_GIMME, 0);
1231 class_addmethod(vslider_class, (t_method)vslider_pos, gensym("pos"), A_GIMME, 0);
1232 class_addmethod(vslider_class, (t_method)vslider_range, gensym("range"), A_GIMME, 0);
1233 class_addmethod(vslider_class, (t_method)vslider_color, gensym("color"), A_GIMME, 0);
1234 class_addmethod(vslider_class, (t_method)vslider_send, gensym("send"), A_DEFSYM, 0);
1235 class_addmethod(vslider_class, (t_method)vslider_receive, gensym("receive"), A_DEFSYM, 0);
1236 class_addmethod(vslider_class, (t_method)vslider_label, gensym("label"), A_DEFSYM, 0);
1237 class_addmethod(vslider_class, (t_method)vslider_label_pos, gensym("label_pos"), A_GIMME, 0);
1238 class_addmethod(vslider_class, (t_method)vslider_label_font, gensym("label_font"), A_GIMME, 0);
1239 class_addmethod(vslider_class, (t_method)vslider_log, gensym("log"), 0);
1240 class_addmethod(vslider_class, (t_method)vslider_lin, gensym("lin"), 0);
1241 class_addmethod(vslider_class, (t_method)vslider_init, gensym("init"), A_FLOAT, 0);
1242 class_addmethod(vslider_class, (t_method)vslider_steady, gensym("steady"), A_FLOAT, 0);
1243 vslider_widgetbehavior.w_getrectfn = vslider_getrect;
1244 vslider_widgetbehavior.w_displacefn = iemgui_displace;
1245 vslider_widgetbehavior.w_selectfn = iemgui_select;
1246 vslider_widgetbehavior.w_activatefn = NULL;
1247 vslider_widgetbehavior.w_deletefn = iemgui_delete;
1248 vslider_widgetbehavior.w_visfn = iemgui_vis;
1249 vslider_widgetbehavior.w_clickfn = vslider_newclick;
1250 class_setwidget(vslider_class, &vslider_widgetbehavior);
1251 class_sethelpsymbol(vslider_class, gensym("vslider"));
1252 class_setsavefn(vslider_class, vslider_save);
1253 class_setpropertiesfn(vslider_class, vslider_properties);
1254}