Exemplo n.º 1
0
void iuplua_pushihandle(lua_State *L, Ihandle *ih)
{
  if (ih) 
  {
    char* sref = IupGetAttribute(ih, "_IUPLUA_WIDGET_TABLE_REF");
    if (!sref)
    {
      /* was not created in Lua */

      iuplua_plugstate(L, ih);

      /* push iup.RegisterHandle */
      iuplua_push_name(L, "RegisterHandle");
      iuplua_pushihandle_raw(L, ih);
      lua_pushstring(L, IupGetClassName(ih));
      lua_call(L, 2, 1);  /* iup.RegisterHandle(ih, type) */
    }
    else
    {
      /* already created in Lua */
      iuplua_pushihandle_raw(L, ih);

      /* TODO: luaL_getmetatable(L, "iupHandle"); */
      lua_pushstring(L, "iupHandle");
      lua_gettable(L, LUA_REGISTRYINDEX);  /* t = registry["iupHandle"] */

      lua_setmetatable(L, -2);    /* metatable(ih) = t */
    }
  } 
  else 
    lua_pushnil(L);
}
Exemplo n.º 2
0
static int ProgressBar(lua_State *L)
{
  Ihandle *ih = IupProgressBar();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 3
0
static int Expander(lua_State *L)
{
  Ihandle *ih = IupExpander(iuplua_checkihandleornil(L, 1));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 4
0
static int Normalizer(lua_State *L)
{
  Ihandle *ih = IupNormalizer(NULL);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 5
0
static int Submenu(lua_State *L)
{
  Ihandle *ih = IupSubmenu((char *) luaL_optstring(L, 1, NULL), iuplua_checkihandle(L, 2));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 6
0
static int Colorbar(lua_State *L)
{
  Ihandle *ih = IupColorbar();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 7
0
static int GLSeparator(lua_State *L)
{
  Ihandle *ih = IupGLSeparator();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 8
0
static int Spin(lua_State *L)
{
  Ihandle *ih = IupSpin();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 9
0
static int Clipboard(lua_State *L)
{
  Ihandle *ih = IupClipboard();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 10
0
static int Dialog(lua_State *L)
{
  Ihandle *ih = IupDialog(iuplua_checkihandleornil(L, 1));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 11
0
static int Cells(lua_State *L)
{
  Ihandle *ih = IupCells();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 12
0
static int OleControl(lua_State *L)
{
  Ihandle *ih = IupOleControl((char *) luaL_checkstring(L, 1));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 13
0
static int Split(lua_State *L)
{
  Ihandle *ih = IupSplit(iuplua_checkihandleornil(L, 1), iuplua_checkihandleornil(L, 2));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 14
0
static int Sbox(lua_State *L)
{
  Ihandle *ih = IupSbox(iuplua_checkihandle(L, 1));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 15
0
static int MultiLine(lua_State *L)
{
  Ihandle *ih = IupMultiLine(NULL);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 16
0
static int Button(lua_State *L)
{
  Ihandle *ih = IupButton((char *)luaL_optstring(L, 1, NULL), NULL);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 17
0
static int List(lua_State *L)
{
  Ihandle *ih = IupList(NULL);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 18
0
static int Fill(lua_State *L)
{
  Ihandle *ih = IupFill();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 19
0
static int FlatScrollBox(lua_State *L)
{
  Ihandle *ih = IupFlatScrollBox(iuplua_checkihandleornil(L, 1));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 20
0
static int Matrix(lua_State *L)
{
  Ihandle *ih = IupMatrix(NULL);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 21
0
static int Dial(lua_State *L)
{
  Ihandle *ih = IupDial((char *)luaL_optstring(L, 1, NULL));
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 22
0
static int Tree(lua_State *L)
{
  Ihandle *ih = IupTree();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 23
0
static int PPlot(lua_State *L)
{
    Ihandle *ih = IupPPlot();
    iuplua_plugstate(L, ih);
    iuplua_pushihandle_raw(L, ih);
    return 1;
}
Exemplo n.º 24
0
static int DatePick(lua_State *L)
{
  Ihandle *ih = IupDatePick();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 25
0
static int WebBrowser(lua_State *L)
{
  Ihandle *ih = IupWebBrowser();
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 26
0
static int GLCanvas(lua_State *L)
{
  Ihandle *ih = IupGLCanvas(NULL);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}
Exemplo n.º 27
0
static int Tabsv(lua_State *L)
{
  Ihandle **hlist = iuplua_checkihandle_array(L, 1);
  Ihandle *h = IupTabsv(hlist);
  iuplua_plugstate(L, h);
  iuplua_pushihandle_raw(L, h);
  free(hlist);
  return 1;
}
Exemplo n.º 28
0
static int ImageRGBA(lua_State *L)
{
  int w = luaL_checkint(L, 1);
  int h = luaL_checkint(L, 2);
  unsigned char *pixels = iuplua_checkuchar_array(L, 3, w*h*4);
  Ihandle *ih = IupImageRGBA(w, h, pixels);
  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  free(pixels);
  return 1;
}
Exemplo n.º 29
0
static int Image (lua_State * L)
{
  int w, h, c, num_colors;
  unsigned char *pixels;
  Ihandle* ih;
  char str[20];

  if (lua_istable(L, 1))
  {
    int i, j;

    /* get the number of lines */
    h = iuplua_getn(L, 1);  

    /* get the number of columns of the first line */
    lua_pushinteger(L, 1);
    lua_gettable(L, 1);
    w = iuplua_getn(L, -1);  
    lua_pop(L, 1);
    
    pixels = (unsigned char *) malloc (h*w);

    for (i=1; i<=h; i++)
    {
      lua_pushinteger(L, i);
      lua_gettable(L, 1);
      for (j=1; j<=w; j++)
      {
        int idx = (i-1)*w+(j-1);
        lua_pushinteger(L, j);
        lua_gettable(L, -2);
        pixels[idx] = (unsigned char)lua_tointeger(L, -1);
        lua_pop(L, 1);
      }
      lua_pop(L, 1);
    }
    
    ih = IupImage(w,h,pixels);  
    free(pixels);

    num_colors = iuplua_getn(L, 2);
    num_colors = num_colors>255? 255: num_colors;
    for(c=1; c<=num_colors; c++)
    {
      lua_rawgeti(L, 2, c);
      sprintf(str, "%d", c);
      IupStoreAttribute(ih, str, lua_tostring(L,-1));
      lua_pop(L, 1);
    }
  }
  else
  {
    w = (int)luaL_checkinteger(L, 1);
    h = (int)luaL_checkinteger(L, 2);
    pixels = iuplua_checkuchar_array(L, 3, w*h);
    ih = IupImage(w, h, pixels);
    free(pixels);

    num_colors = iuplua_getn(L, 4);
    num_colors = num_colors>256? 256: num_colors;
    for(c=1; c<=num_colors; c++)
    {
      lua_rawgeti(L, 4, c);
      sprintf(str, "%d", c-1);
      IupStoreAttribute(ih, str, lua_tostring(L,-1));
      lua_pop(L, 1);
    }
  }

  iuplua_plugstate(L, ih);
  iuplua_pushihandle_raw(L, ih);
  return 1;
}