blob: d23867eae8676b382595b5c43c9d14d3e7522b84 (
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
|
/** \file
* \brief Timer for the Motif Driver.
*
* See Copyright Notice in "iup.h"
*/
#include <stdio.h>
#include <stdlib.h>
#include <Xm/Xm.h>
#include "iup.h"
#include "iupcbs.h"
#include "iup_object.h"
#include "iup_attrib.h"
#include "iup_str.h"
#include "iup_assert.h"
#include "iup_timer.h"
#include "iupmot_drv.h"
static void motTimerProc(XtPointer client_data, XtIntervalId *id)
{
Ihandle *ih = (Ihandle*)client_data;
Icallback cb;
(void)id;
if (!iupObjectCheck(ih)) /* control could be destroyed before timer callback */
return;
ih->serial = -1;
/* we have to restart the timer everytime */
iupdrvTimerRun(ih);
cb = IupGetCallback(ih, "ACTION_CB");
if (cb)
{
if (cb(ih)==IUP_CLOSE)
IupExitLoop();
}
}
void iupdrvTimerRun(Ihandle *ih)
{
unsigned int time_ms;
if (ih->serial > 0) /* timer already started */
return;
time_ms = iupAttribGetInt(ih, "TIME");
if (time_ms > 0)
ih->serial = XtAppAddTimeOut(iupmot_appcontext, time_ms, motTimerProc, (XtPointer)ih);
}
void iupdrvTimerStop(Ihandle* ih)
{
if (ih->serial > 0)
{
XtRemoveTimeOut(ih->serial);
ih->serial = -1;
}
}
void iupdrvTimerInitClass(Iclass* ic)
{
(void)ic;
}
|