From 9177d9cf2fdb9b666dd41da09abef78d06d9dd80 Mon Sep 17 00:00:00 2001 From: Giel van Schijndel Date: Tue, 9 Sep 2008 11:17:38 +0000 Subject: [PATCH] * Register widgetGetTime() as betawidget.getTime() in Lua * In the Lua test app use betawidget.getTime() to determine the *true* amount of time passed since registering of the timer event git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@5979 4a71c877-e1ca-e34f-864e-861f7616d084 --- lib/betawidget/betawidget.i | 3 +++ lib/betawidget/tools/sdl-testapp.lua | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/betawidget/betawidget.i b/lib/betawidget/betawidget.i index bbccc216a..173a4a91d 100644 --- a/lib/betawidget/betawidget.i +++ b/lib/betawidget/betawidget.i @@ -74,6 +74,9 @@ static bool callbackDestructor(widget* const self, const event* const evt, int c } %} +%rename (getTime) widgetGetTime; +int widgetGetTime(void); + %rename (getClipboardText) widgetGetClipboardText; %rename (setClipboardText) widgetSetClipboardText; %typemap (newfree) char * "free($1);"; diff --git a/lib/betawidget/tools/sdl-testapp.lua b/lib/betawidget/tools/sdl-testapp.lua index 38f7f310a..a7ac60819 100644 --- a/lib/betawidget/tools/sdl-testapp.lua +++ b/lib/betawidget/tools/sdl-testapp.lua @@ -1,3 +1,5 @@ +-- vim:set et sts=2 sw=2: + wnd = betawidget.window("myWindow", 400, 400) wnd:reposition(400, 50) wnd:show() @@ -19,10 +21,9 @@ wnd:addEventHandler(betawidget.EVT_MOUSE_CLICK, ) wnd:addTimerEventHandler(betawidget.EVT_TIMER_PERSISTENT, 1000, (function () - local time = 0 + local starttime = betawidget.getTime() return function (self, evt, handlerId) - time = time + 1 - print(string.format("%d seconds passed", time)) + print(string.format("%f seconds passed", (betawidget.getTime() - starttime) / 1000)) end end)() )