summaryrefslogtreecommitdiff
path: root/iup/test/idle.c
blob: f9681baeb337dbce80126f7f57029dcd031f0199 (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
#include <stdlib.h>
#include <stdio.h>
#include "iup.h"

static int idle_count = 0;

static int idle(void)
{
  printf("IDLE_ACTION(count = %d)\n", idle_count);
  idle_count++;

//  if (idle_count == 10000)
//    return IUP_IGNORE;

  return IUP_DEFAULT;
}

static int motion_cb(Ihandle* ih)
{
  printf("MOTION_CB()\n");
  if (idle_count > 30000)
    IupSetFunction ("IDLE_ACTION", NULL);
  return IUP_DEFAULT;
}

void IdleTest(void)
{
  Ihandle* dlg, *canvas;

  canvas = IupCanvas(NULL);
  IupSetCallback(canvas, "MOTION_CB", motion_cb);
 
  dlg = IupDialog(canvas);
  IupSetAttribute(dlg, "TITLE", "Idle Test");
  IupSetAttribute(dlg, "RASTERSIZE", "500x500");

  IupShowXY(dlg, IUP_CENTER, IUP_CENTER);

  IupSetFunction ("IDLE_ACTION", (Icallback)idle);
}

#ifndef BIG_TEST
int main(int argc, char* argv[])
{
  IupOpen(&argc, &argv);

  IdleTest();

  IupMainLoop();

  IupClose();

  return EXIT_SUCCESS;
}
#endif