-
Notifications
You must be signed in to change notification settings - Fork 13
/
ucall.cpp
125 lines (109 loc) · 3.58 KB
/
ucall.cpp
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
/************************************************************************
*
* ucall.cpp: Callback Object
* Ubit GUI Toolkit - Version 6
* (C) 2009 | Eric Lecolinet | TELECOM ParisTech | http://www.enst.fr/~elc/ubit
*
* ***********************************************************************
* COPYRIGHT NOTICE :
* THIS PROGRAM IS DISTRIBUTED WITHOUT ANY WARRANTY AND WITHOUT EVEN THE
* IMPLIED WARRANTY OF MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.
* YOU CAN REDISTRIBUTE IT AND/OR MODIFY IT UNDER THE TERMS OF THE GNU
* GENERAL PUBLIC LICENSE AS PUBLISHED BY THE FREE SOFTWARE FOUNDATION;
* EITHER VERSION 2 OF THE LICENSE, OR (AT YOUR OPTION) ANY LATER VERSION.
* SEE FILES 'COPYRIGHT' AND 'COPYING' FOR MORE DETAILS.
* ***********************************************************************/
#include <ubit/ubit_features.h>
#include <ubit/ucall.hpp>
#include <ubit/uon.hpp>
#include <ubit/ubox.hpp>
#include <ubit/uevent.hpp>
#include <ubit/uwin.hpp>
#include <ubit/uview.hpp>
#include <ubit/umenu.hpp>
#include <ubit/utimer.hpp>
#include <iostream>
using namespace std;
#define NAMESPACE_UBIT namespace ubit {
NAMESPACE_UBIT
void UCall::wrongEventType(const char* evname, const char* callname) {
error("operator",
" - this callback requires an event of type: %s \n"
" - but the type of the actual event is: %s \n"
"To solve this problem, put a breakpoint in ubit::UCall::wrongEventType()", evname, callname);
}
void UCall::addingTo(UChild& child, UElem& parent) {
// sert a specifier la condition par defaut
if (!child.getCond()) child.setCond(UOn::action);
UNode::addingTo(child, parent);
}
/*
void UCall::removingFrom(UChild *selflink, UElem *parent) {
// ne PAS faire " par->setCmodes(on, false) " car il peut y avoir
// plusieurs callbacks avec la meme condition
// (et de toute facon ce n'est pas une erreur, juste un peu plus long)
UNode::removingFrom(selflink, parent);
}
*/
UCall& ucloseWin(int stat) {return ucall(stat, &UElem::closeWin);}
/* TEST
template <class A, class R>
class Truc_F1 {
const UCond& cond;
R (*fun)(A);
public:
Truc_F1(const UCond& c, R(*f)(A)) : cond(c), fun(f) {}
UChild operator()(A a) {return UChild(new UCall_F1<A,R>(fun,a), cond);}
};
template <class A, class R, class E>
class Truc_F1E {
const UCond& cond;
R (*fun)(E&,A);
public:
Truc_F1E(const UCond& c, R(*f)(E&,A)) : cond(c), fun(f) {}
UChild operator()(A a) {return UChild(new UCall_F1E<A,R,E>(fun,a), cond);}
};
- - - - - -
template <class A1, class A2, class R>
class Truc_F2 {
const UCond& cond;
R (*fun)(A1,A2);
public:
Truc_F2(const UCond& c, R(*f)(A1,A2)) : cond(c), fun(f) {}
UChild operator()(A1 a1, A2 a2)
{return UChild(new UCall_F2<A1,A2,R>(fun,a1,a2), cond);}
};
template <class A1, class A2, class R, class E>
class Truc_F2E {
const UCond& cond;
R (*fun)(E&,A1,A2);
public:
Truc_F2E(const UCond& c, R(*f)(E&,A1,A2)) : cond(c), fun(f) {}
UChild operator()(A1 a1, A2 a2)
{return UChild(new UCall_F2E<A1,A2,R,E>(fun,a1,a2), cond);}
};
TEST */
/*
//UCall& ucompactEvents(UCall& c) {return c;}
UCompactEvents::UCompactEvents(UCall& c) :
postponed_event(*new UEvent(UEvent::timer, null, null, null)),
timer(*new UTimer()),
pcall(c),
delay(0) {
timer.onAction(ucall(this, &UCompactEvents::timeout));
}
UCompactEvents::~UCompactEvents() {
delete &timer;
delete &postponed_event;
}
void UCompactEvents::operator()(UEvent& e) {
//postponed_event.copy(e);
postponed_event = e;
timer.start(delay,1,false);
}
void UCompactEvents::timeout() {
//postponed_event.setTime(e.getTime());
(*pcall)(postponed_event);
}
*/
}