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
|
/** \file
* \brief Timer Control.
*
* See Copyright Notice in "iup.h"
*/
#include <stdio.h>
#include <stdlib.h>
#include "iup.h"
#include "iupcbs.h"
#include "iup_object.h"
#include "iup_str.h"
#include "iup_stdcontrols.h"
#include "iup_timer.h"
static int iTimerSetRunAttrib(Ihandle *ih, const char *value)
{
if (iupStrBoolean(value))
iupdrvTimerRun(ih);
else
iupdrvTimerStop(ih);
return 0;
}
static char* iTimerGetRunAttrib(Ihandle *ih)
{
if (ih->serial > 0)
return "YES";
else
return "NO";
}
static char* iTimerGetWidAttrib(Ihandle *ih)
{
char* str = iupStrGetMemory(50);
sprintf(str, "%d", ih->serial);
return str;
}
static void iTimerDestroyMethod(Ihandle* ih)
{
iupdrvTimerStop(ih);
}
/******************************************************************************/
Ihandle* IupTimer(void)
{
return IupCreate("timer");
}
Iclass* iupTimerGetClass(void)
{
Iclass* ic = iupClassNew(NULL);
ic->name = "timer";
ic->format = NULL; /* no parameters */
ic->nativetype = IUP_TYPECONTROL;
ic->childtype = IUP_CHILDNONE;
ic->is_interactive = 0;
/* Class functions */
ic->Destroy = iTimerDestroyMethod;
/* Callbacks */
iupClassRegisterCallback(ic, "ACTION_CB", "");
/* Attribute functions */
iupClassRegisterAttribute(ic, "WID", iTimerGetWidAttrib, NULL, NULL, NULL, IUPAF_READONLY|IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT|IUPAF_NO_STRING);
iupClassRegisterAttribute(ic, "RUN", iTimerGetRunAttrib, iTimerSetRunAttrib, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupClassRegisterAttribute(ic, "TIME", NULL, NULL, NULL, NULL, IUPAF_NOT_MAPPED|IUPAF_NO_INHERIT);
iupdrvTimerInitClass(ic);
return ic;
}
|