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_bang.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_bang.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/g_bang.c | 553 |
1 files changed, 0 insertions, 553 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_bang.c b/apps/plugins/pdbox/PDa/src/g_bang.c index c676bf8675..6556f7019a 100644 --- a/apps/plugins/pdbox/PDa/src/g_bang.c +++ b/apps/plugins/pdbox/PDa/src/g_bang.c | |||
@@ -552,557 +552,4 @@ void g_bang_setup(void) | |||
552 | class_setsavefn(bng_class, bng_save); | 552 | class_setsavefn(bng_class, bng_save); |
553 | class_setpropertiesfn(bng_class, bng_properties); | 553 | class_setpropertiesfn(bng_class, bng_properties); |
554 | } | 554 | } |
555 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
556 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
557 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
558 | |||
559 | /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ | ||
560 | /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ | ||
561 | |||
562 | |||
563 | #include <stdlib.h> | ||
564 | #include <string.h> | ||
565 | #include <stdio.h> | ||
566 | #include <ctype.h> | ||
567 | #include "m_pd.h" | ||
568 | #include "g_canvas.h" | ||
569 | #include "t_tk.h" | ||
570 | #include "g_all_guis.h" | ||
571 | #include <math.h> | ||
572 | |||
573 | #ifdef MSW | ||
574 | #include <io.h> | ||
575 | #else | ||
576 | #include <unistd.h> | ||
577 | #endif | ||
578 | |||
579 | |||
580 | /* --------------- bng gui-bang ------------------------- */ | ||
581 | |||
582 | t_widgetbehavior bng_widgetbehavior; | ||
583 | static t_class *bng_class; | ||
584 | |||
585 | /* widget helper functions */ | ||
586 | |||
587 | |||
588 | void bng_draw_update(t_bng *x, t_glist *glist) | ||
589 | { | ||
590 | if(glist_isvisible(glist)) | ||
591 | { | ||
592 | sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", glist_getcanvas(glist), x, | ||
593 | x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
594 | } | ||
595 | } | ||
596 | |||
597 | void bng_draw_new(t_bng *x, t_glist *glist) | ||
598 | { | ||
599 | int xpos=text_xpix(&x->x_gui.x_obj, glist); | ||
600 | int ypos=text_ypix(&x->x_gui.x_obj, glist); | ||
601 | t_canvas *canvas=glist_getcanvas(glist); | ||
602 | 555 | ||
603 | sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n", | ||
604 | canvas, xpos, ypos, | ||
605 | xpos + x->x_gui.x_w, ypos + x->x_gui.x_h, | ||
606 | x->x_gui.x_bcol, x); | ||
607 | sys_vgui(".x%x.c create oval %d %d %d %d -fill #%6.6x -tags %xBUT\n", | ||
608 | canvas, xpos+1, ypos+1, | ||
609 | xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1, | ||
610 | x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol, x); | ||
611 | sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \ | ||
612 | -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n", | ||
613 | canvas, xpos+x->x_gui.x_ldx, | ||
614 | ypos+x->x_gui.x_ldy, | ||
615 | strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", | ||
616 | x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x); | ||
617 | if(!x->x_gui.x_fsf.x_snd_able) | ||
618 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", | ||
619 | canvas, xpos, | ||
620 | ypos + x->x_gui.x_h-1, xpos + IOWIDTH, | ||
621 | ypos + x->x_gui.x_h, x, 0); | ||
622 | if(!x->x_gui.x_fsf.x_rcv_able) | ||
623 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", | ||
624 | canvas, xpos, ypos, | ||
625 | xpos + IOWIDTH, ypos+1, x, 0); | ||
626 | } | ||
627 | |||
628 | void bng_draw_move(t_bng *x, t_glist *glist) | ||
629 | { | ||
630 | int xpos=text_xpix(&x->x_gui.x_obj, glist); | ||
631 | int ypos=text_ypix(&x->x_gui.x_obj, glist); | ||
632 | t_canvas *canvas=glist_getcanvas(glist); | ||
633 | |||
634 | sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n", | ||
635 | canvas, x, xpos, ypos, | ||
636 | xpos + x->x_gui.x_w, ypos + x->x_gui.x_h); | ||
637 | sys_vgui(".x%x.c coords %xBUT %d %d %d %d\n", | ||
638 | canvas, x, xpos+1,ypos+1, | ||
639 | xpos + x->x_gui.x_w-1, ypos + x->x_gui.x_h-1); | ||
640 | sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x, | ||
641 | x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
642 | sys_vgui(".x%x.c coords %xLABEL %d %d\n", | ||
643 | canvas, x, xpos+x->x_gui.x_ldx, ypos+x->x_gui.x_ldy); | ||
644 | if(!x->x_gui.x_fsf.x_snd_able) | ||
645 | sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n", | ||
646 | canvas, x, 0, xpos, | ||
647 | ypos + x->x_gui.x_h-1, xpos + IOWIDTH, | ||
648 | ypos + x->x_gui.x_h); | ||
649 | if(!x->x_gui.x_fsf.x_rcv_able) | ||
650 | sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", | ||
651 | canvas, x, 0, xpos, ypos, | ||
652 | xpos + IOWIDTH, ypos+1); | ||
653 | } | ||
654 | |||
655 | void bng_draw_erase(t_bng* x, t_glist* glist) | ||
656 | { | ||
657 | t_canvas *canvas=glist_getcanvas(glist); | ||
658 | |||
659 | sys_vgui(".x%x.c delete %xBASE\n", canvas, x); | ||
660 | sys_vgui(".x%x.c delete %xBUT\n", canvas, x); | ||
661 | sys_vgui(".x%x.c delete %xLABEL\n", canvas, x); | ||
662 | if(!x->x_gui.x_fsf.x_snd_able) | ||
663 | sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); | ||
664 | if(!x->x_gui.x_fsf.x_rcv_able) | ||
665 | sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); | ||
666 | } | ||
667 | |||
668 | void bng_draw_config(t_bng* x, t_glist* glist) | ||
669 | { | ||
670 | t_canvas *canvas=glist_getcanvas(glist); | ||
671 | |||
672 | sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", | ||
673 | canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, | ||
674 | x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol, | ||
675 | strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); | ||
676 | sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, x->x_gui.x_bcol); | ||
677 | sys_vgui(".x%x.c itemconfigure %xBUT -fill #%6.6x\n", canvas, x, | ||
678 | x->x_flashed?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
679 | } | ||
680 | |||
681 | void bng_draw_io(t_bng* x, t_glist* glist, int old_snd_rcv_flags) | ||
682 | { | ||
683 | int xpos=text_xpix(&x->x_gui.x_obj, glist); | ||
684 | int ypos=text_ypix(&x->x_gui.x_obj, glist); | ||
685 | t_canvas *canvas=glist_getcanvas(glist); | ||
686 | |||
687 | if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) | ||
688 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", | ||
689 | canvas, xpos, | ||
690 | ypos + x->x_gui.x_h-1, xpos + IOWIDTH, | ||
691 | ypos + x->x_gui.x_h, x, 0); | ||
692 | if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) | ||
693 | sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); | ||
694 | if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !x->x_gui.x_fsf.x_rcv_able) | ||
695 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", | ||
696 | canvas, xpos, ypos, | ||
697 | xpos + IOWIDTH, ypos+1, x, 0); | ||
698 | if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) | ||
699 | sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); | ||
700 | } | ||
701 | |||
702 | void bng_draw_select(t_bng* x, t_glist* glist) | ||
703 | { | ||
704 | t_canvas *canvas=glist_getcanvas(glist); | ||
705 | |||
706 | if(x->x_gui.x_fsf.x_selected) | ||
707 | { | ||
708 | sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); | ||
709 | sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); | ||
710 | sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); | ||
711 | } | ||
712 | else | ||
713 | { | ||
714 | sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); | ||
715 | sys_vgui(".x%x.c itemconfigure %xBUT -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); | ||
716 | sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); | ||
717 | } | ||
718 | } | ||
719 | |||
720 | void bng_draw(t_bng *x, t_glist *glist, int mode) | ||
721 | { | ||
722 | if(mode == IEM_GUI_DRAW_MODE_UPDATE) | ||
723 | bng_draw_update(x, glist); | ||
724 | else if(mode == IEM_GUI_DRAW_MODE_MOVE) | ||
725 | bng_draw_move(x, glist); | ||
726 | else if(mode == IEM_GUI_DRAW_MODE_NEW) | ||
727 | bng_draw_new(x, glist); | ||
728 | else if(mode == IEM_GUI_DRAW_MODE_SELECT) | ||
729 | bng_draw_select(x, glist); | ||
730 | else if(mode == IEM_GUI_DRAW_MODE_ERASE) | ||
731 | bng_draw_erase(x, glist); | ||
732 | else if(mode == IEM_GUI_DRAW_MODE_CONFIG) | ||
733 | bng_draw_config(x, glist); | ||
734 | else if(mode >= IEM_GUI_DRAW_MODE_IO) | ||
735 | bng_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); | ||
736 | } | ||
737 | |||
738 | /* ------------------------ bng widgetbehaviour----------------------------- */ | ||
739 | |||
740 | static void bng_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) | ||
741 | { | ||
742 | t_bng *x = (t_bng *)z; | ||
743 | |||
744 | *xp1 = text_xpix(&x->x_gui.x_obj, glist); | ||
745 | *yp1 = text_ypix(&x->x_gui.x_obj, glist); | ||
746 | *xp2 = *xp1 + x->x_gui.x_w; | ||
747 | *yp2 = *yp1 + x->x_gui.x_h; | ||
748 | } | ||
749 | |||
750 | static void bng_save(t_gobj *z, t_binbuf *b) | ||
751 | { | ||
752 | t_bng *x = (t_bng *)z; | ||
753 | int bflcol[3]; | ||
754 | t_symbol *srl[3]; | ||
755 | |||
756 | iemgui_save(&x->x_gui, srl, bflcol); | ||
757 | binbuf_addv(b, "ssiisiiiisssiiiiiii", gensym("#X"),gensym("obj"), | ||
758 | (t_int)x->x_gui.x_obj.te_xpix, (t_int)x->x_gui.x_obj.te_ypix, | ||
759 | gensym("bng"), x->x_gui.x_w, | ||
760 | x->x_flashtime_hold, x->x_flashtime_break, | ||
761 | iem_symargstoint(&x->x_gui.x_isa), | ||
762 | srl[0], srl[1], srl[2], | ||
763 | x->x_gui.x_ldx, x->x_gui.x_ldy, | ||
764 | iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, | ||
765 | bflcol[0], bflcol[1], bflcol[2]); | ||
766 | binbuf_addv(b, ";"); | ||
767 | } | ||
768 | |||
769 | void bng_check_minmax(t_bng *x, int ftbreak, int fthold) | ||
770 | { | ||
771 | if(ftbreak > fthold) | ||
772 | { | ||
773 | int h; | ||
774 | |||
775 | h = ftbreak; | ||
776 | ftbreak = fthold; | ||
777 | fthold = h; | ||
778 | } | ||
779 | if(ftbreak < IEM_BNG_MINBREAKFLASHTIME) | ||
780 | ftbreak = IEM_BNG_MINBREAKFLASHTIME; | ||
781 | if(fthold < IEM_BNG_MINHOLDFLASHTIME) | ||
782 | fthold = IEM_BNG_MINHOLDFLASHTIME; | ||
783 | x->x_flashtime_break = ftbreak; | ||
784 | x->x_flashtime_hold = fthold; | ||
785 | } | ||
786 | |||
787 | static void bng_properties(t_gobj *z, t_glist *owner) | ||
788 | { | ||
789 | t_bng *x = (t_bng *)z; | ||
790 | char buf[800]; | ||
791 | t_symbol *srl[3]; | ||
792 | |||
793 | iemgui_properties(&x->x_gui, srl); | ||
794 | sprintf(buf, "pdtk_iemgui_dialog %%s BANG \ | ||
795 | ----------dimensions(pix):----------- %d %d size: 0 0 empty \ | ||
796 | --------flash-time(ms)(ms):--------- %d intrrpt: %d hold: %d \ | ||
797 | %d empty empty %d %d empty %d \ | ||
798 | %s %s \ | ||
799 | %s %d %d \ | ||
800 | %d %d \ | ||
801 | %d %d %d\n", | ||
802 | x->x_gui.x_w, IEM_GUI_MINSIZE, | ||
803 | x->x_flashtime_break, x->x_flashtime_hold, 2,/*min_max_schedule+clip*/ | ||
804 | -1, x->x_gui.x_isa.x_loadinit, -1, -1,/*no linlog, no multi*/ | ||
805 | srl[0]->s_name, srl[1]->s_name, | ||
806 | srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, | ||
807 | x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, | ||
808 | 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); | ||
809 | gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); | ||
810 | } | ||
811 | |||
812 | static void bng_set(t_bng *x) | ||
813 | { | ||
814 | if(x->x_flashed) | ||
815 | { | ||
816 | x->x_flashed = 0; | ||
817 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); | ||
818 | clock_delay(x->x_clock_brk, x->x_flashtime_break); | ||
819 | x->x_flashed = 1; | ||
820 | } | ||
821 | else | ||
822 | { | ||
823 | x->x_flashed = 1; | ||
824 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); | ||
825 | } | ||
826 | clock_delay(x->x_clock_hld, x->x_flashtime_hold); | ||
827 | } | ||
828 | |||
829 | static void bng_bout1(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/ | ||
830 | { | ||
831 | if(!x->x_gui.x_fsf.x_put_in2out) | ||
832 | { | ||
833 | x->x_gui.x_isa.x_locked = 1; | ||
834 | clock_delay(x->x_clock_lck, 2); | ||
835 | } | ||
836 | outlet_bang(x->x_gui.x_obj.ob_outlet); | ||
837 | if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing && x->x_gui.x_fsf.x_put_in2out) | ||
838 | pd_bang(x->x_gui.x_snd->s_thing); | ||
839 | } | ||
840 | |||
841 | static void bng_bout2(t_bng *x)/*wird immer gesendet, wenn moeglich*/ | ||
842 | { | ||
843 | if(!x->x_gui.x_fsf.x_put_in2out) | ||
844 | { | ||
845 | x->x_gui.x_isa.x_locked = 1; | ||
846 | clock_delay(x->x_clock_lck, 2); | ||
847 | } | ||
848 | outlet_bang(x->x_gui.x_obj.ob_outlet); | ||
849 | if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) | ||
850 | pd_bang(x->x_gui.x_snd->s_thing); | ||
851 | } | ||
852 | |||
853 | static void bng_bang(t_bng *x)/*wird nur mehr gesendet, wenn snd != rcv*/ | ||
854 | { | ||
855 | if(!x->x_gui.x_isa.x_locked) | ||
856 | { | ||
857 | bng_set(x); | ||
858 | bng_bout1(x); | ||
859 | } | ||
860 | } | ||
861 | |||
862 | static void bng_bang2(t_bng *x)/*wird immer gesendet, wenn moeglich*/ | ||
863 | { | ||
864 | if(!x->x_gui.x_isa.x_locked) | ||
865 | { | ||
866 | bng_set(x); | ||
867 | bng_bout2(x); | ||
868 | } | ||
869 | } | ||
870 | |||
871 | static void bng_dialog(t_bng *x, t_symbol *s, int argc, t_atom *argv) | ||
872 | { | ||
873 | t_symbol *srl[3]; | ||
874 | int a = (int)atom_getintarg(0, argc, argv); | ||
875 | int fthold = (int)atom_getintarg(2, argc, argv); | ||
876 | int ftbreak = (int)atom_getintarg(3, argc, argv); | ||
877 | int sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); | ||
878 | |||
879 | x->x_gui.x_w = iemgui_clip_size(a); | ||
880 | x->x_gui.x_h = x->x_gui.x_w; | ||
881 | bng_check_minmax(x, ftbreak, fthold); | ||
882 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); | ||
883 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); | ||
884 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); | ||
885 | canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); | ||
886 | } | ||
887 | |||
888 | static void bng_click(t_bng *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) | ||
889 | { | ||
890 | bng_set(x); | ||
891 | bng_bout2(x); | ||
892 | } | ||
893 | |||
894 | static int bng_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) | ||
895 | { | ||
896 | if(doit) | ||
897 | bng_click((t_bng *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); | ||
898 | return (1); | ||
899 | } | ||
900 | |||
901 | static void bng_float(t_bng *x, t_floatarg f) | ||
902 | {bng_bang2(x);} | ||
903 | |||
904 | static void bng_symbol(t_bng *x, t_symbol *s) | ||
905 | {bng_bang2(x);} | ||
906 | |||
907 | static void bng_pointer(t_bng *x, t_gpointer *gp) | ||
908 | {bng_bang2(x);} | ||
909 | |||
910 | static void bng_list(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
911 | { | ||
912 | bng_bang2(x); | ||
913 | } | ||
914 | |||
915 | static void bng_anything(t_bng *x, t_symbol *s, int argc, t_atom *argv) | ||
916 | {bng_bang2(x);} | ||
917 | |||
918 | static void bng_loadbang(t_bng *x) | ||
919 | { | ||
920 | if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) | ||
921 | { | ||
922 | bng_set(x); | ||
923 | bng_bout2(x); | ||
924 | } | ||
925 | } | ||
926 | |||
927 | static void bng_size(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
928 | { | ||
929 | x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); | ||
930 | x->x_gui.x_h = x->x_gui.x_w; | ||
931 | iemgui_size((void *)x, &x->x_gui); | ||
932 | } | ||
933 | |||
934 | static void bng_delta(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
935 | {iemgui_delta((void *)x, &x->x_gui, s, ac, av);} | ||
936 | |||
937 | static void bng_pos(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
938 | {iemgui_pos((void *)x, &x->x_gui, s, ac, av);} | ||
939 | |||
940 | static void bng_flashtime(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
941 | { | ||
942 | bng_check_minmax(x, (int)atom_getintarg(0, ac, av), | ||
943 | (int)atom_getintarg(1, ac, av)); | ||
944 | } | ||
945 | |||
946 | static void bng_color(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
947 | {iemgui_color((void *)x, &x->x_gui, s, ac, av);} | ||
948 | |||
949 | static void bng_send(t_bng *x, t_symbol *s) | ||
950 | {iemgui_send(x, &x->x_gui, s);} | ||
951 | |||
952 | static void bng_receive(t_bng *x, t_symbol *s) | ||
953 | {iemgui_receive(x, &x->x_gui, s);} | ||
954 | |||
955 | static void bng_label(t_bng *x, t_symbol *s) | ||
956 | {iemgui_label((void *)x, &x->x_gui, s);} | ||
957 | |||
958 | static void bng_label_pos(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
959 | {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} | ||
960 | |||
961 | static void bng_label_font(t_bng *x, t_symbol *s, int ac, t_atom *av) | ||
962 | {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} | ||
963 | |||
964 | static void bng_init(t_bng *x, t_floatarg f) | ||
965 | { | ||
966 | x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; | ||
967 | } | ||
968 | |||
969 | static void bng_tick_hld(t_bng *x) | ||
970 | { | ||
971 | x->x_flashed = 0; | ||
972 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); | ||
973 | } | ||
974 | |||
975 | static void bng_tick_brk(t_bng *x) | ||
976 | { | ||
977 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); | ||
978 | } | ||
979 | |||
980 | static void bng_tick_lck(t_bng *x) | ||
981 | { | ||
982 | x->x_gui.x_isa.x_locked = 0; | ||
983 | } | ||
984 | |||
985 | static void *bng_new(t_symbol *s, int argc, t_atom *argv) | ||
986 | { | ||
987 | t_bng *x = (t_bng *)pd_new(bng_class); | ||
988 | int bflcol[]={-262144, -1, -1}; | ||
989 | int a=IEM_GUI_DEFAULTSIZE; | ||
990 | int ldx=0, ldy=-6; | ||
991 | int fs=8; | ||
992 | int ftbreak=IEM_BNG_DEFAULTBREAKFLASHTIME, | ||
993 | fthold=IEM_BNG_DEFAULTHOLDFLASHTIME; | ||
994 | char str[144]; | ||
995 | |||
996 | iem_inttosymargs(&x->x_gui.x_isa, 0); | ||
997 | iem_inttofstyle(&x->x_gui.x_fsf, 0); | ||
998 | |||
999 | if((argc == 14)&&IS_A_FLOAT(argv,0) | ||
1000 | &&IS_A_FLOAT(argv,1)&&IS_A_FLOAT(argv,2) | ||
1001 | &&IS_A_FLOAT(argv,3) | ||
1002 | &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4)) | ||
1003 | &&(IS_A_SYMBOL(argv,5)||IS_A_FLOAT(argv,5)) | ||
1004 | &&(IS_A_SYMBOL(argv,6)||IS_A_FLOAT(argv,6)) | ||
1005 | &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8) | ||
1006 | &&IS_A_FLOAT(argv,9)&&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11) | ||
1007 | &&IS_A_FLOAT(argv,12)&&IS_A_FLOAT(argv,13)) | ||
1008 | { | ||
1009 | |||
1010 | a = (int)atom_getintarg(0, argc, argv); | ||
1011 | fthold = (int)atom_getintarg(1, argc, argv); | ||
1012 | ftbreak = (int)atom_getintarg(2, argc, argv); | ||
1013 | iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(3, argc, argv)); | ||
1014 | iemgui_new_getnames(&x->x_gui, 4, argv); | ||
1015 | ldx = (int)atom_getintarg(7, argc, argv); | ||
1016 | ldy = (int)atom_getintarg(8, argc, argv); | ||
1017 | iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(9, argc, argv)); | ||
1018 | fs = (int)atom_getintarg(10, argc, argv); | ||
1019 | bflcol[0] = (int)atom_getintarg(11, argc, argv); | ||
1020 | bflcol[1] = (int)atom_getintarg(12, argc, argv); | ||
1021 | bflcol[2] = (int)atom_getintarg(13, argc, argv); | ||
1022 | } | ||
1023 | else iemgui_new_getnames(&x->x_gui, 4, 0); | ||
1024 | |||
1025 | x->x_gui.x_draw = (t_iemfunptr)bng_draw; | ||
1026 | |||
1027 | x->x_gui.x_fsf.x_snd_able = 1; | ||
1028 | x->x_gui.x_fsf.x_rcv_able = 1; | ||
1029 | x->x_flashed = 0; | ||
1030 | x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); | ||
1031 | if (!strcmp(x->x_gui.x_snd->s_name, "empty")) | ||
1032 | x->x_gui.x_fsf.x_snd_able = 0; | ||
1033 | if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) | ||
1034 | x->x_gui.x_fsf.x_rcv_able = 0; | ||
1035 | if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); | ||
1036 | else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); | ||
1037 | else { x->x_gui.x_fsf.x_font_style = 0; | ||
1038 | strcpy(x->x_gui.x_font, "courier"); } | ||
1039 | |||
1040 | if (x->x_gui.x_fsf.x_rcv_able) | ||
1041 | pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); | ||
1042 | x->x_gui.x_ldx = ldx; | ||
1043 | x->x_gui.x_ldy = ldy; | ||
1044 | |||
1045 | if(fs < 4) | ||
1046 | fs = 4; | ||
1047 | x->x_gui.x_fontsize = fs; | ||
1048 | x->x_gui.x_w = iemgui_clip_size(a); | ||
1049 | x->x_gui.x_h = x->x_gui.x_w; | ||
1050 | bng_check_minmax(x, ftbreak, fthold); | ||
1051 | iemgui_all_colfromload(&x->x_gui, bflcol); | ||
1052 | x->x_gui.x_isa.x_locked = 0; | ||
1053 | iemgui_verify_snd_ne_rcv(&x->x_gui); | ||
1054 | x->x_clock_hld = clock_new(x, (t_method)bng_tick_hld); | ||
1055 | x->x_clock_brk = clock_new(x, (t_method)bng_tick_brk); | ||
1056 | x->x_clock_lck = clock_new(x, (t_method)bng_tick_lck); | ||
1057 | outlet_new(&x->x_gui.x_obj, &s_bang); | ||
1058 | return (x); | ||
1059 | } | ||
1060 | |||
1061 | static void bng_ff(t_bng *x) | ||
1062 | { | ||
1063 | if(x->x_gui.x_fsf.x_rcv_able) | ||
1064 | pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); | ||
1065 | clock_free(x->x_clock_lck); | ||
1066 | clock_free(x->x_clock_brk); | ||
1067 | clock_free(x->x_clock_hld); | ||
1068 | gfxstub_deleteforkey(x); | ||
1069 | } | ||
1070 | |||
1071 | void g_bang_setup(void) | ||
1072 | { | ||
1073 | bng_class = class_new(gensym("bng"), (t_newmethod)bng_new, | ||
1074 | (t_method)bng_ff, sizeof(t_bng), 0, A_GIMME, 0); | ||
1075 | class_addbang(bng_class, bng_bang); | ||
1076 | class_addfloat(bng_class, bng_float); | ||
1077 | class_addsymbol(bng_class, bng_symbol); | ||
1078 | class_addpointer(bng_class, bng_pointer); | ||
1079 | class_addlist(bng_class, bng_list); | ||
1080 | class_addanything(bng_class, bng_anything); | ||
1081 | class_addmethod(bng_class, (t_method)bng_click, gensym("click"), | ||
1082 | A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); | ||
1083 | class_addmethod(bng_class, (t_method)bng_dialog, gensym("dialog"), | ||
1084 | A_GIMME, 0); | ||
1085 | class_addmethod(bng_class, (t_method)bng_loadbang, gensym("loadbang"), 0); | ||
1086 | class_addmethod(bng_class, (t_method)bng_size, gensym("size"), A_GIMME, 0); | ||
1087 | class_addmethod(bng_class, (t_method)bng_delta, gensym("delta"), A_GIMME, 0); | ||
1088 | class_addmethod(bng_class, (t_method)bng_pos, gensym("pos"), A_GIMME, 0); | ||
1089 | class_addmethod(bng_class, (t_method)bng_flashtime, gensym("flashtime"), A_GIMME, 0); | ||
1090 | class_addmethod(bng_class, (t_method)bng_color, gensym("color"), A_GIMME, 0); | ||
1091 | class_addmethod(bng_class, (t_method)bng_send, gensym("send"), A_DEFSYM, 0); | ||
1092 | class_addmethod(bng_class, (t_method)bng_receive, gensym("receive"), A_DEFSYM, 0); | ||
1093 | class_addmethod(bng_class, (t_method)bng_label, gensym("label"), A_DEFSYM, 0); | ||
1094 | class_addmethod(bng_class, (t_method)bng_label_pos, gensym("label_pos"), A_GIMME, 0); | ||
1095 | class_addmethod(bng_class, (t_method)bng_label_font, gensym("label_font"), A_GIMME, 0); | ||
1096 | class_addmethod(bng_class, (t_method)bng_init, gensym("init"), A_FLOAT, 0); | ||
1097 | bng_widgetbehavior.w_getrectfn = bng_getrect; | ||
1098 | bng_widgetbehavior.w_displacefn = iemgui_displace; | ||
1099 | bng_widgetbehavior.w_selectfn = iemgui_select; | ||
1100 | bng_widgetbehavior.w_activatefn = NULL; | ||
1101 | bng_widgetbehavior.w_deletefn = iemgui_delete; | ||
1102 | bng_widgetbehavior.w_visfn = iemgui_vis; | ||
1103 | bng_widgetbehavior.w_clickfn = bng_newclick; | ||
1104 | class_setwidget(bng_class, &bng_widgetbehavior); | ||
1105 | class_sethelpsymbol(bng_class, gensym("bng")); | ||
1106 | class_setsavefn(bng_class, bng_save); | ||
1107 | class_setpropertiesfn(bng_class, bng_properties); | ||
1108 | } | ||