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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
|
#include "flgui.h"
#include "flguiobj.h"
#include <stdlib.h>
/*
#include <stdio.h>
#include <string.h>
#include <stdarg.h>
*/
#if !defined(FLEXT_VERSION) || (FLEXT_VERSION < 303)
#error You need at least flext version 0.3.3
#endif
#define V void
#define I int
#define C char
#define BL bool
#define L long
#define UL unsigned long
class guitest:
public flext_gui,virtual public flext_base
{
FLEXT_HEADER(guitest,flext_gui)
public:
guitest(I argc,t_atom *argv);
~guitest();
virtual void m_bang()
{
post("%s - bang!",thisName());
}
protected:
virtual void g_Create();
virtual void g_Edit(bool selected);
static bool g_Motion(flext_gui &g,GuiSingle &obj,const CBParams &p);
static bool g_MouseKey(flext_gui &g,GuiSingle &obj,const CBParams &p);
static bool g_Key(flext_gui &g,GuiSingle &obj,const CBParams &p);
virtual void g_Properties();
virtual void g_Save(t_binbuf *b);
private:
FLEXT_CALLBACK(m_bang);
};
FLEXT_NEW_V("guitest",guitest)
void guitest::g_Create()
{
GuiSingle *frame = Group().Add_Box(0,0,XSize(),YSize(),-1,0xE0E0E0);
frame->Symbol("rect1");
GuiSingle *wave = Group().Add_Box(8,10,XSize()-16,YSize()-11,0,0x4040FF);
Group().Add_Text(1,1,"Hula",-1);
I n = XSize()-16;
Pnt *p = new Pnt[n];
for(int i = 0; i < n; ++i) {
p[i](8+i,10+rand()%(YSize()-11));
}
Group().Add_Poly(n,p,-1,0xC0C0C0);
delete[] p;
if(!BindEvent(*frame,g_Motion,evMotion)) post("Motion not supported");
if(!BindEvent(*wave,g_MouseKey,evMouseDown)) post("MouseDown not supported");
if(!BindEvent(*wave,g_MouseKey,evKeyDown)) post("KeyDown not supported");
if(!BindEvent(*wave,g_MouseKey,evKeyUp)) post("KeyUp not supported");
}
void guitest::g_Properties()
{
post("properties");
}
void guitest::g_Save(t_binbuf *b)
{
post("save");
#if FLEXT_SYS == FLEXT_SYS_PD
binbuf_addv(b, "ssiis;", gensym("#X"),gensym("obj"),
(t_int)XLo(), (t_int)YLo(),MakeSymbol(thisName())
// here the arguments
);
#else
#endif
}
void guitest::g_Edit(bool selected)
{
post("select is=%d", selected);
GuiSingle *obj = Group().Find(MakeSymbol("rect1"));
if(obj)
obj->Outline(selected?0xFF0000:0x000000);
else
post("obj not found");
}
bool guitest::g_Motion(flext_gui &g,GuiSingle &obj,const CBParams &p)
{
if(p.kind == evMotion) {
post("Motion %s x:%i y:%i mod:%i",GetString(obj.Id()),p.pMotion.x,p.pMotion.y,p.pMotion.mod);
}
else
post("Motion");
return true;
}
bool guitest::g_MouseKey(flext_gui &g,GuiSingle &obj,const CBParams &p)
{
if(p.kind == evMouseDown) {
post("MouseDown %s x:%i y:%i b:%i mod:%i",GetString(obj.Id()),p.pMouseKey.x,p.pMouseKey.y,p.pMouseKey.b,p.pMouseKey.mod);
}
else if(p.kind == evKeyDown) {
post("KeyDown %s asc:%i key:%i mod:%i",GetString(obj.Id()),p.pKey.a,p.pKey.k,p.pKey.mod);
}
else if(p.kind == evKeyUp) {
post("KeyUp %s asc:%i key:%i mod:%i",GetString(obj.Id()),p.pKey.a,p.pKey.k,p.pKey.mod);
}
return true;
}
bool guitest::g_Key(flext_gui &g,GuiSingle &obj,const CBParams &p)
{
post("Key");
return true;
}
guitest::guitest(I argc,t_atom *argv):
flext_gui(400,100)
{
AddInAnything();
AddOutInt(2);
FLEXT_ADDBANG(0,m_bang);
}
guitest::~guitest()
{
}
|