-
Notifications
You must be signed in to change notification settings - Fork 24
/
Main.m3
147 lines (105 loc) · 2.73 KB
/
Main.m3
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
MODULE Main;
IMPORT IO,Thread,RTCollector;
IMPORT QtLabel;
IMPORT QtCheckBox;
FROM QtDateTime IMPORT QDate;
IMPORT QtCalendarWidget;
IMPORT QtMainWindow;
IMPORT QtApplication;
IMPORT QtDynamic;
VAR
ret : BOOLEAN;
appret : INTEGER;
argc : INTEGER;
argv : ARRAY[0..0] OF TEXT;
mainWin : QtMainWindow.T;
label : QtLabel.T;
app : QtApplication.T;
cb : QtCheckBox.T;
cal : QtCalendarWidget.T;
dyn1,dyn2,dyn3 : QtDynamic.DynamicQObject;
PROCEDURE Callback1(obj : ROOT; args : ADDRESS) =
VAR
i : INTEGER;
BEGIN
IO.Put("In M3 callback ");
i := QtDynamic.ConvertInt(args,1);
IO.PutInt(i);
IO.Put("\n");
END Callback1;
PROCEDURE Callback2(obj : ROOT; args : ADDRESS) =
VAR
month,year : INTEGER;
BEGIN
IO.Put("In M3 callback2 ");
year := QtDynamic.ConvertInt(args,1);
month := QtDynamic.ConvertInt(args,2);
IO.PutInt(month); IO.Put(" "); IO.PutInt(year);
IO.Put("\n");
END Callback2;
PROCEDURE Callback3(obj : ROOT; args : ADDRESS) =
VAR
date := NEW(QDate);
doy : INTEGER;
BEGIN
IO.Put("In M3 callback3 ");
(*
test new conversion rtns dont work th cxxobj is a function of it being a class not
that it descends from qobject !!!
*)
date.cxxObj := QtDynamic.ConvertObj(args,1);
doy := date.dayOfYear();
IO.Put ("day of year ");
IO.PutInt(doy);
IO.Put("\n");
END Callback3;
BEGIN
(*
RTCollector.Disable();
*)
(* RTCollector.DisableMotion();*)
argc := 1;
argv[0] := "./test window";
app := NEW(QtApplication.T).init_1(argc,argv);
mainWin := NEW(QtMainWindow.T).init_2();
label := NEW(QtLabel.T).init_4("Hello Modula 3",mainWin);
cb := NEW(QtCheckBox.T).init_2("Click Me",mainWin);
cb.move(40,40);
cal := NEW(QtCalendarWidget.T).init_0(mainWin);
cal.move(100,100);
cal.resize(220,200);
dyn1 := NEW(QtDynamic.DynamicQObject).init_0(Callback1,NIL);
dyn2 := NEW(QtDynamic.DynamicQObject).init_0(Callback2,NIL);
dyn3 := NEW(QtDynamic.DynamicQObject).init_0(Callback3,NIL);
ret := dyn1.connectDynamicSlot(cb, "clicked(bool)", "slot1()");
IF ret THEN
IO.Put("Slot1 connected\n");
ELSE
IO.Put("Slot1 not connected\n");
END;
ret := dyn2.connectDynamicSlot(cal, "currentPageChanged(int,int)", "slot2()");
IF ret THEN
IO.Put("Slot2 connected\n");
ELSE
IO.Put("Slot2 not connected\n");
END;
ret := dyn3.connectDynamicSlot(cal, "clicked(QDate)", "slot3()");
IF ret THEN
IO.Put("Slot3 connected\n");
ELSE
IO.Put("Slot3 not connected\n");
END;
mainWin.setObjectName("mainwin");
mainWin.resize(400,300);
mainWin.show();
IO.Put("before exec\n");
appret := QtApplication.Exec();
IO.Put("pausing for 1 secs\n");
Thread.Pause(1.0D0);
(*
RTCollector.EnableMotion();
RTCollector.Collect();*)
(*
RTCollector.Enable();
*)
END Main.