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
|
/*
Copyright (C) 2000 Stefan Westerfeld
[email protected]
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include "artsgui.h"
#include <connect.h>
#include <qiomanager.h>
#include <tqpushbutton.h>
#include <tdeapplication.h>
#include <objectmanager.h>
using namespace Arts;
int main(int argc, char **argv)
{
QIOManager iomanager;
Dispatcher dispatcher(&iomanager);
TDEApplication application(argc, argv, "testgui", true);
ObjectManager::the()->provideCapability("kdegui");
Widget w;
w.width(500); w.height(350); w.show();
Button b;
b.parent(w);
b.x(10);
b.y(10);
b.width(100);
b.height(20);
b.text("Hello World");
b.show();
Button b2;
b2.parent(w);
b2.x(10);
b2.y(30);
b2.width(100);
b2.height(20);
b2.text("More World");
b2.show();
Poti p;
p.parent(w);
p.x(150);
p.y(10);
p.caption("delay (ms)");
p.color("red");
p.min(10);
p.max(100);
p.value(90);
p.show();
Poti q;
q.parent(w);
q.x(250);
q.y(10);
q.caption("delay (ms)");
q.color("blue");
q.min(10);
q.max(100);
q.value(90);
q.show();
Graph g;
g.parent(w);
g.x(50);
g.y(70);
g.width(400);
g.height(230);
g.caption("a graph");
g.minx(0.0);
g.maxx(1.0);
g.miny(0.0);
g.maxy(1.0);
g.show();
GraphLine gline;
gline.graph(g);
std::vector<GraphPoint> points;
points.push_back(GraphPoint(0, 1.0));
points.push_back(GraphPoint(0.5, 1.0));
points.push_back(GraphPoint(0.501, 0.0));
points.push_back(GraphPoint(1.0, 0.0));
gline.points(points);
gline.color("red");
gline.editable(true);
/* moves q if p is moved */
connect(p,"value_changed",q,"value");
/*
connect(q,"value_changed",p,"value");
With the current assumptions that change notifications make, it is not
possible to connect p to q and q to p.
The reason is that the notification will only be delivered some time
in the future (due to the requirement that they are asynchronous, i.e.
do not cause the sender to block) - but this means that two different
change notifications (i.e. changed to 1.0, changed to 2.0) may move
in a cycle between the two objects p and q, if p and q are cross
connected. So don't cross connect ;).
*/
return application.exec();
}
|