summaryrefslogtreecommitdiff
path: root/iup/srclua3/il_colorbar.c
blob: 28c912e1d4eb117ad02564ddd9a9fd52e7f2d68b (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
/** \file
 * \brief Bindig of iupcb to Lua 3.
 *
 * See Copyright Notice in "iup.h"
 */
 
#include <stdlib.h>

#include "iup.h"
#include "iupcontrols.h"

#include <lua.h>

#include "iuplua.h"
#include "il.h"
#include "il_controls.h"


static char* COLORBAR_cell_cb(Ihandle *handle, int cell)
{
  iuplua_call_start(handle, "cellcb");
  lua_pushnumber(cell);
  return iuplua_call_rs();
}

static int COLORBAR_select_cb(Ihandle *handle, int cell, int type)
{
  iuplua_call_start(handle, "selectcb");
  lua_pushnumber(cell);
  lua_pushnumber(type);
  return iuplua_call();
}

static int COLORBAR_switch_cb(Ihandle *handle, int prim_cell, int sec_cell)
{
  iuplua_call_start(handle, "switchcb");
  lua_pushnumber(prim_cell);
  lua_pushnumber(sec_cell);
  return iuplua_call();
}

static int COLORBAR_extended_cb(Ihandle *handle, int cell)
{
  iuplua_call_start(handle, "extendedcb");
  lua_pushnumber(cell);
  return iuplua_call();
}

static void CreateColorbar(void) 
{
  int tag = (int)lua_getnumber(lua_getglobal("iuplua_tag"));
  lua_pushusertag(IupColorbar(), tag);
}

int colorbarlua_open(void) 
{
  struct AssocList {
    char *name;
    lua_CFunction func;
  } COLORBARAssocList [] = {
    {"iup_colorbar_cell_cb",   (lua_CFunction)COLORBAR_cell_cb},
    {"iup_colorbar_select_cb", (lua_CFunction)COLORBAR_select_cb},
    {"iup_colorbar_switch_cb", (lua_CFunction)COLORBAR_switch_cb},
    {"iup_colorbar_extended_cb", (lua_CFunction)COLORBAR_extended_cb}
  };
  int SizeCOLORBARAssocList = (sizeof(COLORBARAssocList)/sizeof(struct AssocList));
  int i;

  lua_register("iupCreateColorbar", CreateColorbar);

  for (i = 0; i < SizeCOLORBARAssocList; i++)
    lua_register(COLORBARAssocList[i].name, COLORBARAssocList[i].func);

#ifdef IUPLUA_USELOH
#ifdef TEC_BIGENDIAN
#ifdef TEC_64
#include "loh/colorbar_be64.loh"
#else
#include "loh/colorbar_be32.loh"
#endif  
#else
#ifdef TEC_64
#ifdef WIN64
#include "loh/colorbar_le64w.loh"
#else
#include "loh/colorbar_le64.loh"
#endif  
#else
#include "loh/colorbar.loh"
#endif  
#endif  
#else
  iuplua_dofile("luacolorbar.lua");
#endif

  return 1;
}