diff options
author | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:56:41 -0800 |
---|---|---|
committer | Pixel <pixel@nobis-crew.org> | 2009-11-04 11:59:33 -0800 |
commit | d577d991b97ae2b5ee1af23641bcffc3f83af5b2 (patch) | |
tree | 590639d50205d1bcfaff2a7d2dc6ebf3f373c7ed /iup/src/mot/iupmot_timer.c |
Initial import. Contains the im, cd and iup librairies, and a "working" Makefile for them under linux.
Diffstat (limited to 'iup/src/mot/iupmot_timer.c')
-rwxr-xr-x | iup/src/mot/iupmot_timer.c | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/iup/src/mot/iupmot_timer.c b/iup/src/mot/iupmot_timer.c new file mode 100755 index 0000000..d23867e --- /dev/null +++ b/iup/src/mot/iupmot_timer.c @@ -0,0 +1,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; +} |