diff options
Diffstat (limited to 'apps/plugins/pdbox/PDa/src/g_toggle.c')
-rw-r--r-- | apps/plugins/pdbox/PDa/src/g_toggle.c | 473 |
1 files changed, 0 insertions, 473 deletions
diff --git a/apps/plugins/pdbox/PDa/src/g_toggle.c b/apps/plugins/pdbox/PDa/src/g_toggle.c index b6bb9f3daf..5a3401ffa8 100644 --- a/apps/plugins/pdbox/PDa/src/g_toggle.c +++ b/apps/plugins/pdbox/PDa/src/g_toggle.c | |||
@@ -472,477 +472,4 @@ void g_toggle_setup(void) | |||
472 | class_setsavefn(toggle_class, toggle_save); | 472 | class_setsavefn(toggle_class, toggle_save); |
473 | class_setpropertiesfn(toggle_class, toggle_properties); | 473 | class_setpropertiesfn(toggle_class, toggle_properties); |
474 | } | 474 | } |
475 | /* Copyright (c) 1997-1999 Miller Puckette. | ||
476 | * For information on usage and redistribution, and for a DISCLAIMER OF ALL | ||
477 | * WARRANTIES, see the file, "LICENSE.txt," in this distribution. */ | ||
478 | |||
479 | /* g_7_guis.c written by Thomas Musil (c) IEM KUG Graz Austria 2000-2001 */ | ||
480 | /* thanks to Miller Puckette, Guenther Geiger and Krzystof Czaja */ | ||
481 | |||
482 | |||
483 | #include <stdlib.h> | ||
484 | #include <string.h> | ||
485 | #include <stdio.h> | ||
486 | #include <ctype.h> | ||
487 | #include "m_pd.h" | ||
488 | #include "g_canvas.h" | ||
489 | #include "t_tk.h" | ||
490 | #include "g_all_guis.h" | ||
491 | #include <math.h> | ||
492 | |||
493 | #ifdef MSW | ||
494 | #include <io.h> | ||
495 | #else | ||
496 | #include <unistd.h> | ||
497 | #endif | ||
498 | |||
499 | /* --------------- tgl gui-toggle ------------------------- */ | ||
500 | |||
501 | t_widgetbehavior toggle_widgetbehavior; | ||
502 | static t_class *toggle_class; | ||
503 | |||
504 | /* widget helper functions */ | ||
505 | 475 | ||
506 | void toggle_draw_update(t_toggle *x, t_glist *glist) | ||
507 | { | ||
508 | if(glist_isvisible(glist)) | ||
509 | { | ||
510 | t_canvas *canvas=glist_getcanvas(glist); | ||
511 | |||
512 | sys_vgui(".x%x.c itemconfigure %xX1 -fill #%6.6x\n", canvas, x, | ||
513 | (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
514 | sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x, | ||
515 | (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
516 | } | ||
517 | } | ||
518 | |||
519 | void toggle_draw_new(t_toggle *x, t_glist *glist) | ||
520 | { | ||
521 | t_canvas *canvas=glist_getcanvas(glist); | ||
522 | int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); | ||
523 | |||
524 | if(x->x_gui.x_w >= 30) | ||
525 | w = 2; | ||
526 | if(x->x_gui.x_w >= 60) | ||
527 | w = 3; | ||
528 | sys_vgui(".x%x.c create rectangle %d %d %d %d -fill #%6.6x -tags %xBASE\n", | ||
529 | canvas, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h, | ||
530 | x->x_gui.x_bcol, x); | ||
531 | sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xX1\n", | ||
532 | canvas, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w, w, | ||
533 | (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x); | ||
534 | sys_vgui(".x%x.c create line %d %d %d %d -width %d -fill #%6.6x -tags %xX2\n", | ||
535 | canvas, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w, w, | ||
536 | (x->x_on!=0.0)?x->x_gui.x_fcol:x->x_gui.x_bcol, x); | ||
537 | sys_vgui(".x%x.c create text %d %d -text {%s} -anchor w \ | ||
538 | -font {%s %d bold} -fill #%6.6x -tags %xLABEL\n", | ||
539 | canvas, xx+x->x_gui.x_ldx, | ||
540 | yy+x->x_gui.x_ldy, | ||
541 | strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:"", | ||
542 | x->x_gui.x_font, x->x_gui.x_fontsize, x->x_gui.x_lcol, x); | ||
543 | if(!x->x_gui.x_fsf.x_snd_able) | ||
544 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", | ||
545 | canvas, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h, x, 0); | ||
546 | if(!x->x_gui.x_fsf.x_rcv_able) | ||
547 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xIN%d\n", | ||
548 | canvas, xx, yy, xx + IOWIDTH, yy+1, x, 0); | ||
549 | } | ||
550 | |||
551 | void toggle_draw_move(t_toggle *x, t_glist *glist) | ||
552 | { | ||
553 | t_canvas *canvas=glist_getcanvas(glist); | ||
554 | int w=1, xx=text_xpix(&x->x_gui.x_obj, glist), yy=text_ypix(&x->x_gui.x_obj, glist); | ||
555 | |||
556 | if(x->x_gui.x_w >= 30) | ||
557 | w = 2; | ||
558 | |||
559 | if(x->x_gui.x_w >= 60) | ||
560 | w = 3; | ||
561 | sys_vgui(".x%x.c coords %xBASE %d %d %d %d\n", | ||
562 | canvas, x, xx, yy, xx + x->x_gui.x_w, yy + x->x_gui.x_h); | ||
563 | sys_vgui(".x%x.c itemconfigure %xX1 -width %d\n", canvas, x, w); | ||
564 | sys_vgui(".x%x.c coords %xX1 %d %d %d %d\n", | ||
565 | canvas, x, xx+w+1, yy+w+1, xx + x->x_gui.x_w-w, yy + x->x_gui.x_h-w); | ||
566 | sys_vgui(".x%x.c itemconfigure %xX2 -width %d\n", canvas, x, w); | ||
567 | sys_vgui(".x%x.c coords %xX2 %d %d %d %d\n", | ||
568 | canvas, x, xx+w+1, yy + x->x_gui.x_h-w-1, xx + x->x_gui.x_w-w, yy+w); | ||
569 | sys_vgui(".x%x.c coords %xLABEL %d %d\n", | ||
570 | canvas, x, xx+x->x_gui.x_ldx, yy+x->x_gui.x_ldy); | ||
571 | if(!x->x_gui.x_fsf.x_snd_able) | ||
572 | sys_vgui(".x%x.c coords %xOUT%d %d %d %d %d\n", | ||
573 | canvas, x, 0, xx, yy + x->x_gui.x_h-1, xx + IOWIDTH, yy + x->x_gui.x_h); | ||
574 | if(!x->x_gui.x_fsf.x_rcv_able) | ||
575 | sys_vgui(".x%x.c coords %xIN%d %d %d %d %d\n", | ||
576 | canvas, x, 0, xx, yy, xx + IOWIDTH, yy+1); | ||
577 | } | ||
578 | |||
579 | void toggle_draw_erase(t_toggle* x, t_glist* glist) | ||
580 | { | ||
581 | t_canvas *canvas=glist_getcanvas(glist); | ||
582 | |||
583 | sys_vgui(".x%x.c delete %xBASE\n", canvas, x); | ||
584 | sys_vgui(".x%x.c delete %xX1\n", canvas, x); | ||
585 | sys_vgui(".x%x.c delete %xX2\n", canvas, x); | ||
586 | sys_vgui(".x%x.c delete %xLABEL\n", canvas, x); | ||
587 | if(!x->x_gui.x_fsf.x_snd_able) | ||
588 | sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); | ||
589 | if(!x->x_gui.x_fsf.x_rcv_able) | ||
590 | sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); | ||
591 | } | ||
592 | |||
593 | void toggle_draw_config(t_toggle* x, t_glist* glist) | ||
594 | { | ||
595 | t_canvas *canvas=glist_getcanvas(glist); | ||
596 | |||
597 | sys_vgui(".x%x.c itemconfigure %xLABEL -font {%s %d bold} -fill #%6.6x -text {%s} \n", | ||
598 | canvas, x, x->x_gui.x_font, x->x_gui.x_fontsize, | ||
599 | x->x_gui.x_fsf.x_selected?IEM_GUI_COLOR_SELECTED:x->x_gui.x_lcol, | ||
600 | strcmp(x->x_gui.x_lab->s_name, "empty")?x->x_gui.x_lab->s_name:""); | ||
601 | sys_vgui(".x%x.c itemconfigure %xBASE -fill #%6.6x\n", canvas, x, | ||
602 | x->x_gui.x_bcol); | ||
603 | sys_vgui(".x%x.c itemconfigure %xX1 -fill #%6.6x\n", canvas, x, | ||
604 | x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
605 | sys_vgui(".x%x.c itemconfigure %xX2 -fill #%6.6x\n", canvas, x, | ||
606 | x->x_on?x->x_gui.x_fcol:x->x_gui.x_bcol); | ||
607 | } | ||
608 | |||
609 | void toggle_draw_io(t_toggle* x, t_glist* glist, int old_snd_rcv_flags) | ||
610 | { | ||
611 | int xpos=text_xpix(&x->x_gui.x_obj, glist); | ||
612 | int ypos=text_ypix(&x->x_gui.x_obj, glist); | ||
613 | t_canvas *canvas=glist_getcanvas(glist); | ||
614 | |||
615 | if((old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && !x->x_gui.x_fsf.x_snd_able) | ||
616 | sys_vgui(".x%x.c create rectangle %d %d %d %d -tags %xOUT%d\n", | ||
617 | canvas, xpos, | ||
618 | ypos + x->x_gui.x_h-1, xpos + IOWIDTH, | ||
619 | ypos + x->x_gui.x_h, x, 0); | ||
620 | if(!(old_snd_rcv_flags & IEM_GUI_OLD_SND_FLAG) && x->x_gui.x_fsf.x_snd_able) | ||
621 | sys_vgui(".x%x.c delete %xOUT%d\n", canvas, x, 0); | ||
622 | if((old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && !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 | if(!(old_snd_rcv_flags & IEM_GUI_OLD_RCV_FLAG) && x->x_gui.x_fsf.x_rcv_able) | ||
627 | sys_vgui(".x%x.c delete %xIN%d\n", canvas, x, 0); | ||
628 | } | ||
629 | |||
630 | void toggle_draw_select(t_toggle* x, t_glist* glist) | ||
631 | { | ||
632 | t_canvas *canvas=glist_getcanvas(glist); | ||
633 | |||
634 | if(x->x_gui.x_fsf.x_selected) | ||
635 | { | ||
636 | sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); | ||
637 | sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, IEM_GUI_COLOR_SELECTED); | ||
638 | } | ||
639 | else | ||
640 | { | ||
641 | sys_vgui(".x%x.c itemconfigure %xBASE -outline #%6.6x\n", canvas, x, IEM_GUI_COLOR_NORMAL); | ||
642 | sys_vgui(".x%x.c itemconfigure %xLABEL -fill #%6.6x\n", canvas, x, x->x_gui.x_lcol); | ||
643 | } | ||
644 | } | ||
645 | |||
646 | void toggle_draw(t_toggle *x, t_glist *glist, int mode) | ||
647 | { | ||
648 | if(mode == IEM_GUI_DRAW_MODE_UPDATE) | ||
649 | toggle_draw_update(x, glist); | ||
650 | else if(mode == IEM_GUI_DRAW_MODE_MOVE) | ||
651 | toggle_draw_move(x, glist); | ||
652 | else if(mode == IEM_GUI_DRAW_MODE_NEW) | ||
653 | toggle_draw_new(x, glist); | ||
654 | else if(mode == IEM_GUI_DRAW_MODE_SELECT) | ||
655 | toggle_draw_select(x, glist); | ||
656 | else if(mode == IEM_GUI_DRAW_MODE_ERASE) | ||
657 | toggle_draw_erase(x, glist); | ||
658 | else if(mode == IEM_GUI_DRAW_MODE_CONFIG) | ||
659 | toggle_draw_config(x, glist); | ||
660 | else if(mode >= IEM_GUI_DRAW_MODE_IO) | ||
661 | toggle_draw_io(x, glist, mode - IEM_GUI_DRAW_MODE_IO); | ||
662 | } | ||
663 | |||
664 | /* ------------------------ tgl widgetbehaviour----------------------------- */ | ||
665 | |||
666 | static void toggle_getrect(t_gobj *z, t_glist *glist, int *xp1, int *yp1, int *xp2, int *yp2) | ||
667 | { | ||
668 | t_toggle *x = (t_toggle *)z; | ||
669 | |||
670 | *xp1 = text_xpix(&x->x_gui.x_obj, glist); | ||
671 | *yp1 = text_ypix(&x->x_gui.x_obj, glist); | ||
672 | *xp2 = *xp1 + x->x_gui.x_w; | ||
673 | *yp2 = *yp1 + x->x_gui.x_h; | ||
674 | } | ||
675 | |||
676 | static void toggle_save(t_gobj *z, t_binbuf *b) | ||
677 | { | ||
678 | t_toggle *x = (t_toggle *)z; | ||
679 | int bflcol[3]; | ||
680 | t_symbol *srl[3]; | ||
681 | |||
682 | iemgui_save(&x->x_gui, srl, bflcol); | ||
683 | binbuf_addv(b, "ssiisiisssiiiiiiiff", gensym("#X"),gensym("obj"), | ||
684 | (t_int)x->x_gui.x_obj.te_xpix, | ||
685 | (t_int)x->x_gui.x_obj.te_ypix, | ||
686 | gensym("tgl"), x->x_gui.x_w, | ||
687 | iem_symargstoint(&x->x_gui.x_isa), | ||
688 | srl[0], srl[1], srl[2], | ||
689 | x->x_gui.x_ldx, x->x_gui.x_ldy, | ||
690 | iem_fstyletoint(&x->x_gui.x_fsf), x->x_gui.x_fontsize, | ||
691 | bflcol[0], bflcol[1], bflcol[2], x->x_on, x->x_nonzero); | ||
692 | binbuf_addv(b, ";"); | ||
693 | } | ||
694 | |||
695 | static void toggle_properties(t_gobj *z, t_glist *owner) | ||
696 | { | ||
697 | t_toggle *x = (t_toggle *)z; | ||
698 | char buf[800]; | ||
699 | t_symbol *srl[3]; | ||
700 | |||
701 | iemgui_properties(&x->x_gui, srl); | ||
702 | sprintf(buf, "pdtk_iemgui_dialog %%s TOGGLE \ | ||
703 | ----------dimensions(pix):----------- %d %d size: 0 0 empty \ | ||
704 | -----------non-zero-value:----------- %g value: 0.0 empty %g \ | ||
705 | -1 lin log %d %d empty %d \ | ||
706 | %s %s \ | ||
707 | %s %d %d \ | ||
708 | %d %d \ | ||
709 | %d %d %d\n", | ||
710 | x->x_gui.x_w, IEM_GUI_MINSIZE, | ||
711 | x->x_nonzero, 1.0,/*non_zero-schedule*/ | ||
712 | x->x_gui.x_isa.x_loadinit, -1, -1,/*no multi*/ | ||
713 | srl[0]->s_name, srl[1]->s_name, | ||
714 | srl[2]->s_name, x->x_gui.x_ldx, x->x_gui.x_ldy, | ||
715 | x->x_gui.x_fsf.x_font_style, x->x_gui.x_fontsize, | ||
716 | 0xffffff & x->x_gui.x_bcol, 0xffffff & x->x_gui.x_fcol, 0xffffff & x->x_gui.x_lcol); | ||
717 | gfxstub_new(&x->x_gui.x_obj.ob_pd, x, buf); | ||
718 | } | ||
719 | |||
720 | static void toggle_bang(t_toggle *x) | ||
721 | { | ||
722 | x->x_on = (x->x_on==0.0)?x->x_nonzero:0.0; | ||
723 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); | ||
724 | outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); | ||
725 | if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) | ||
726 | pd_float(x->x_gui.x_snd->s_thing, x->x_on); | ||
727 | } | ||
728 | |||
729 | static void toggle_dialog(t_toggle *x, t_symbol *s, int argc, t_atom *argv) | ||
730 | { | ||
731 | t_symbol *srl[3]; | ||
732 | int a = (int)atom_getintarg(0, argc, argv); | ||
733 | float nonzero = (float)atom_getfloatarg(2, argc, argv); | ||
734 | int sr_flags; | ||
735 | |||
736 | if(nonzero == 0.0) | ||
737 | nonzero = 1.0; | ||
738 | x->x_nonzero = nonzero; | ||
739 | if(x->x_on != 0.0) | ||
740 | x->x_on = x->x_nonzero; | ||
741 | sr_flags = iemgui_dialog(&x->x_gui, srl, argc, argv); | ||
742 | x->x_gui.x_w = iemgui_clip_size(a); | ||
743 | x->x_gui.x_h = x->x_gui.x_w; | ||
744 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_CONFIG); | ||
745 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_IO + sr_flags); | ||
746 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_MOVE); | ||
747 | canvas_fixlinesfor(glist_getcanvas(x->x_gui.x_glist), (t_text*)x); | ||
748 | } | ||
749 | |||
750 | static void toggle_click(t_toggle *x, t_floatarg xpos, t_floatarg ypos, t_floatarg shift, t_floatarg ctrl, t_floatarg alt) | ||
751 | {toggle_bang(x);} | ||
752 | |||
753 | static int toggle_newclick(t_gobj *z, struct _glist *glist, int xpix, int ypix, int shift, int alt, int dbl, int doit) | ||
754 | { | ||
755 | if(doit) | ||
756 | toggle_click((t_toggle *)z, (t_floatarg)xpix, (t_floatarg)ypix, (t_floatarg)shift, 0, (t_floatarg)alt); | ||
757 | return (1); | ||
758 | } | ||
759 | |||
760 | static void toggle_set(t_toggle *x, t_floatarg f) | ||
761 | { | ||
762 | x->x_on = f; | ||
763 | if(f != 0.0) | ||
764 | x->x_nonzero = f; | ||
765 | (*x->x_gui.x_draw)(x, x->x_gui.x_glist, IEM_GUI_DRAW_MODE_UPDATE); | ||
766 | } | ||
767 | |||
768 | static void toggle_float(t_toggle *x, t_floatarg f) | ||
769 | { | ||
770 | toggle_set(x, f); | ||
771 | if(x->x_gui.x_fsf.x_put_in2out) | ||
772 | { | ||
773 | outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); | ||
774 | if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) | ||
775 | pd_float(x->x_gui.x_snd->s_thing, x->x_on); | ||
776 | } | ||
777 | } | ||
778 | |||
779 | static void toggle_fout(t_toggle *x, t_floatarg f) | ||
780 | { | ||
781 | toggle_set(x, f); | ||
782 | outlet_float(x->x_gui.x_obj.ob_outlet, x->x_on); | ||
783 | if(x->x_gui.x_fsf.x_snd_able && x->x_gui.x_snd->s_thing) | ||
784 | pd_float(x->x_gui.x_snd->s_thing, x->x_on); | ||
785 | } | ||
786 | |||
787 | static void toggle_loadbang(t_toggle *x) | ||
788 | { | ||
789 | if(!sys_noloadbang && x->x_gui.x_isa.x_loadinit) | ||
790 | toggle_fout(x, (float)x->x_on); | ||
791 | } | ||
792 | |||
793 | static void toggle_size(t_toggle *x, t_symbol *s, int ac, t_atom *av) | ||
794 | { | ||
795 | x->x_gui.x_w = iemgui_clip_size((int)atom_getintarg(0, ac, av)); | ||
796 | x->x_gui.x_h = x->x_gui.x_w; | ||
797 | iemgui_size((void *)x, &x->x_gui); | ||
798 | } | ||
799 | |||
800 | static void toggle_delta(t_toggle *x, t_symbol *s, int ac, t_atom *av) | ||
801 | {iemgui_delta((void *)x, &x->x_gui, s, ac, av);} | ||
802 | |||
803 | static void toggle_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av) | ||
804 | {iemgui_pos((void *)x, &x->x_gui, s, ac, av);} | ||
805 | |||
806 | static void toggle_color(t_toggle *x, t_symbol *s, int ac, t_atom *av) | ||
807 | {iemgui_color((void *)x, &x->x_gui, s, ac, av);} | ||
808 | |||
809 | static void toggle_send(t_toggle *x, t_symbol *s) | ||
810 | {iemgui_send(x, &x->x_gui, s);} | ||
811 | |||
812 | static void toggle_receive(t_toggle *x, t_symbol *s) | ||
813 | {iemgui_receive(x, &x->x_gui, s);} | ||
814 | |||
815 | static void toggle_label(t_toggle *x, t_symbol *s) | ||
816 | {iemgui_label((void *)x, &x->x_gui, s);} | ||
817 | |||
818 | static void toggle_label_font(t_toggle *x, t_symbol *s, int ac, t_atom *av) | ||
819 | {iemgui_label_font((void *)x, &x->x_gui, s, ac, av);} | ||
820 | |||
821 | static void toggle_label_pos(t_toggle *x, t_symbol *s, int ac, t_atom *av) | ||
822 | {iemgui_label_pos((void *)x, &x->x_gui, s, ac, av);} | ||
823 | |||
824 | static void toggle_init(t_toggle *x, t_floatarg f) | ||
825 | { | ||
826 | x->x_gui.x_isa.x_loadinit = (f==0.0)?0:1; | ||
827 | } | ||
828 | |||
829 | static void toggle_nonzero(t_toggle *x, t_floatarg f) | ||
830 | { | ||
831 | if(f != 0.0) | ||
832 | x->x_nonzero = f; | ||
833 | } | ||
834 | |||
835 | static void *toggle_new(t_symbol *s, int argc, t_atom *argv) | ||
836 | { | ||
837 | t_toggle *x = (t_toggle *)pd_new(toggle_class); | ||
838 | int bflcol[]={-262144, -1, -1}; | ||
839 | int a=IEM_GUI_DEFAULTSIZE, f=0; | ||
840 | int ldx=0, ldy=-6; | ||
841 | int fs=8; | ||
842 | float on=0.0, nonzero=1.0; | ||
843 | char str[144]; | ||
844 | |||
845 | iem_inttosymargs(&x->x_gui.x_isa, 0); | ||
846 | iem_inttofstyle(&x->x_gui.x_fsf, 0); | ||
847 | |||
848 | if(((argc == 13)||(argc == 14))&&IS_A_FLOAT(argv,0) | ||
849 | &&IS_A_FLOAT(argv,1) | ||
850 | &&(IS_A_SYMBOL(argv,2)||IS_A_FLOAT(argv,2)) | ||
851 | &&(IS_A_SYMBOL(argv,3)||IS_A_FLOAT(argv,3)) | ||
852 | &&(IS_A_SYMBOL(argv,4)||IS_A_FLOAT(argv,4)) | ||
853 | &&IS_A_FLOAT(argv,5)&&IS_A_FLOAT(argv,6) | ||
854 | &&IS_A_FLOAT(argv,7)&&IS_A_FLOAT(argv,8)&&IS_A_FLOAT(argv,9) | ||
855 | &&IS_A_FLOAT(argv,10)&&IS_A_FLOAT(argv,11)&&IS_A_FLOAT(argv,12)) | ||
856 | { | ||
857 | a = (int)atom_getintarg(0, argc, argv); | ||
858 | iem_inttosymargs(&x->x_gui.x_isa, atom_getintarg(1, argc, argv)); | ||
859 | iemgui_new_getnames(&x->x_gui, 2, argv); | ||
860 | ldx = (int)atom_getintarg(5, argc, argv); | ||
861 | ldy = (int)atom_getintarg(6, argc, argv); | ||
862 | iem_inttofstyle(&x->x_gui.x_fsf, atom_getintarg(7, argc, argv)); | ||
863 | fs = (int)atom_getintarg(8, argc, argv); | ||
864 | bflcol[0] = (int)atom_getintarg(9, argc, argv); | ||
865 | bflcol[1] = (int)atom_getintarg(10, argc, argv); | ||
866 | bflcol[2] = (int)atom_getintarg(11, argc, argv); | ||
867 | on = (float)atom_getfloatarg(12, argc, argv); | ||
868 | } | ||
869 | else iemgui_new_getnames(&x->x_gui, 2, 0); | ||
870 | if((argc == 14)&&IS_A_FLOAT(argv,13)) | ||
871 | nonzero = (float)atom_getfloatarg(13, argc, argv); | ||
872 | x->x_gui.x_draw = (t_iemfunptr)toggle_draw; | ||
873 | |||
874 | x->x_gui.x_fsf.x_snd_able = 1; | ||
875 | x->x_gui.x_fsf.x_rcv_able = 1; | ||
876 | x->x_gui.x_glist = (t_glist *)canvas_getcurrent(); | ||
877 | if (!strcmp(x->x_gui.x_snd->s_name, "empty")) | ||
878 | x->x_gui.x_fsf.x_snd_able = 0; | ||
879 | if (!strcmp(x->x_gui.x_rcv->s_name, "empty")) | ||
880 | x->x_gui.x_fsf.x_rcv_able = 0; | ||
881 | if(x->x_gui.x_fsf.x_font_style == 1) strcpy(x->x_gui.x_font, "helvetica"); | ||
882 | else if(x->x_gui.x_fsf.x_font_style == 2) strcpy(x->x_gui.x_font, "times"); | ||
883 | else { x->x_gui.x_fsf.x_font_style = 0; | ||
884 | strcpy(x->x_gui.x_font, "courier"); } | ||
885 | x->x_nonzero = (nonzero!=0.0)?nonzero:1.0; | ||
886 | if(x->x_gui.x_isa.x_loadinit) | ||
887 | x->x_on = (on!=0.0)?nonzero:0.0; | ||
888 | else | ||
889 | x->x_on = 0.0; | ||
890 | if (x->x_gui.x_fsf.x_rcv_able) | ||
891 | pd_bind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); | ||
892 | x->x_gui.x_ldx = ldx; | ||
893 | x->x_gui.x_ldy = ldy; | ||
894 | |||
895 | if(fs < 4) | ||
896 | fs = 4; | ||
897 | x->x_gui.x_fontsize = fs; | ||
898 | x->x_gui.x_w = iemgui_clip_size(a); | ||
899 | x->x_gui.x_h = x->x_gui.x_w; | ||
900 | iemgui_all_colfromload(&x->x_gui, bflcol); | ||
901 | iemgui_verify_snd_ne_rcv(&x->x_gui); | ||
902 | outlet_new(&x->x_gui.x_obj, &s_float); | ||
903 | return (x); | ||
904 | } | ||
905 | |||
906 | static void toggle_ff(t_toggle *x) | ||
907 | { | ||
908 | if(x->x_gui.x_fsf.x_rcv_able) | ||
909 | pd_unbind(&x->x_gui.x_obj.ob_pd, x->x_gui.x_rcv); | ||
910 | gfxstub_deleteforkey(x); | ||
911 | } | ||
912 | |||
913 | void g_toggle_setup(void) | ||
914 | { | ||
915 | toggle_class = class_new(gensym("tgl"), (t_newmethod)toggle_new, | ||
916 | (t_method)toggle_ff, sizeof(t_toggle), 0, A_GIMME, 0); | ||
917 | class_addcreator((t_newmethod)toggle_new, gensym("toggle"), A_GIMME, 0); | ||
918 | class_addbang(toggle_class, toggle_bang); | ||
919 | class_addfloat(toggle_class, toggle_float); | ||
920 | class_addmethod(toggle_class, (t_method)toggle_click, gensym("click"), | ||
921 | A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, A_FLOAT, 0); | ||
922 | class_addmethod(toggle_class, (t_method)toggle_dialog, gensym("dialog"), | ||
923 | A_GIMME, 0); | ||
924 | class_addmethod(toggle_class, (t_method)toggle_loadbang, gensym("loadbang"), 0); | ||
925 | class_addmethod(toggle_class, (t_method)toggle_set, gensym("set"), A_FLOAT, 0); | ||
926 | class_addmethod(toggle_class, (t_method)toggle_size, gensym("size"), A_GIMME, 0); | ||
927 | class_addmethod(toggle_class, (t_method)toggle_delta, gensym("delta"), A_GIMME, 0); | ||
928 | class_addmethod(toggle_class, (t_method)toggle_pos, gensym("pos"), A_GIMME, 0); | ||
929 | class_addmethod(toggle_class, (t_method)toggle_color, gensym("color"), A_GIMME, 0); | ||
930 | class_addmethod(toggle_class, (t_method)toggle_send, gensym("send"), A_DEFSYM, 0); | ||
931 | class_addmethod(toggle_class, (t_method)toggle_receive, gensym("receive"), A_DEFSYM, 0); | ||
932 | class_addmethod(toggle_class, (t_method)toggle_label, gensym("label"), A_DEFSYM, 0); | ||
933 | class_addmethod(toggle_class, (t_method)toggle_label_pos, gensym("label_pos"), A_GIMME, 0); | ||
934 | class_addmethod(toggle_class, (t_method)toggle_label_font, gensym("label_font"), A_GIMME, 0); | ||
935 | class_addmethod(toggle_class, (t_method)toggle_init, gensym("init"), A_FLOAT, 0); | ||
936 | class_addmethod(toggle_class, (t_method)toggle_nonzero, gensym("nonzero"), A_FLOAT, 0); | ||
937 | toggle_widgetbehavior.w_getrectfn = toggle_getrect; | ||
938 | toggle_widgetbehavior.w_displacefn = iemgui_displace; | ||
939 | toggle_widgetbehavior.w_selectfn = iemgui_select; | ||
940 | toggle_widgetbehavior.w_activatefn = NULL; | ||
941 | toggle_widgetbehavior.w_deletefn = iemgui_delete; | ||
942 | toggle_widgetbehavior.w_visfn = iemgui_vis; | ||
943 | toggle_widgetbehavior.w_clickfn = toggle_newclick; | ||
944 | class_setwidget(toggle_class, &toggle_widgetbehavior); | ||
945 | class_sethelpsymbol(toggle_class, gensym("toggle")); | ||
946 | class_setsavefn(toggle_class, toggle_save); | ||
947 | class_setpropertiesfn(toggle_class, toggle_properties); | ||
948 | } | ||