aboutsummaryrefslogtreecommitdiff
path: root/gui/ticker.c
blob: 74fa3252bcbe7820592dd93087dfeb894b928b5d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
#include <m_pd.h>
#include "g_canvas.h"

#ifdef NT
#pragma warning( disable : 4244 )
#pragma warning( disable : 4305 )
#endif

#include <stdio.h>
#include "fatom.h"

/* can we use the normal text save function ?? */

static t_class *ticker_class;

static void ticker_save(t_gobj *z, t_binbuf *b)
{

    t_fatom *x = (t_fatom *)z;

    binbuf_addv(b, "ssiiss", gensym("#X"),gensym("obj"),
		x->x_obj.te_xpix, x->x_obj.te_ypix ,  
		gensym("ticker"),x->x_text);
    binbuf_addv(b, ";");
}

static void ticker_bang(t_fatom* x)
{
  x->x_val = !x->x_val;
  fatom_float(x,x->x_val);
}

static void *ticker_new(t_symbol* t)
{
    t_fatom *x = (t_fatom *)pd_new(ticker_class);
    x->x_type = gensym("checkbutton");
    return fatom_new(x,10,0,0,t);
}


t_widgetbehavior   ticker_widgetbehavior;


void ticker_setup() {
    ticker_class = class_new(gensym("ticker"), (t_newmethod)ticker_new, 0,
				sizeof(t_fatom),0,A_DEFSYMBOL,0);

    class_addbang(ticker_class,ticker_bang);
    fatom_setup_common(ticker_class);
    class_addbang(ticker_class, (t_method)ticker_bang);

    ticker_widgetbehavior.w_getrectfn=  fatom_getrect;
    ticker_widgetbehavior.w_displacefn= fatom_displace;
    ticker_widgetbehavior.w_selectfn=  fatom_select;
    ticker_widgetbehavior.w_activatefn= fatom_activate;
    ticker_widgetbehavior.w_deletefn=   fatom_delete;
    ticker_widgetbehavior.w_visfn=     fatom_vis;
#if PD_MINOR_VERSION < 37
    ticker_widgetbehavior.w_savefn=    ticker_save;
    ticker_widgetbehavior.w_propertiesfn= NULL;
#endif
    ticker_widgetbehavior.w_clickfn=   NULL;


	class_setwidget(ticker_class,&ticker_widgetbehavior);
#if PD_MINOR_VERSION >= 37
    class_setsavefn(ticker_class,&ticker_save);
#endif
}