Example #1
0
int iuplua_open(lua_State * L)
{
  int ret;

  struct luaL_Reg funcs[] = {
    {"key_open", iupkey_open},
    {"Open", il_open},
    {"Close", iuplua_close},
    {"SetIdle", SetIdle},
    {"GetFromC", GetFromC},
    {"GetWidget", GetWidget},
    {"SetWidget", SetWidget},
    {"NewClass", NewClass},
    {"SetClass", SetClass},
    {"GetClass", GetClass},
    {"IsContainer", IsContainer},
    {"SetMethod", SetMethod},
    {"SetCallback", SetCallback},
    {"SetFunction", SetFunction},
    {"ihandle_compare", ihandle_compare},
    {"ihandle_tostring", ihandle_tostring},
    {"_ERRORMESSAGE", il_error_message},
    {"dostring", il_dostring},
    {"dofile", il_dofile},
    { "StringCompare", StringCompare },

    { NULL, NULL },
  };

  if (!il_open(L))
    return 0;

  ret = (int)lua_tointeger(L, -1); /* retrieve IupOpen return value */
  lua_pop(L, -1);

  /* Registers functions in iup namespace */
  iuplua_register_lib(L, funcs);  /* leave global table at the top of the stack */
  iupluaapi_open(L);

  /* set version info */
  setinfo(L);

  /* register if IupOpen was called here or from outside IupLua */
  /* iup._IUPOPEN_CALL = EXTERNAL|INTERNAL                      */
  if (ret == IUP_OPENED) 
    lua_pushliteral (L, "EXTERNAL");
  else                   
    lua_pushliteral (L, "INTERNAL");
  lua_setfield(L, -2, "_IUPOPEN_CALL");

  /* used by Idle in Lua */
  IupSetGlobal("_IUP_LUA_DEFAULT_STATE", (char *) L);  

#ifdef IUPLUA_USELOH        
#include "iuplua.loh"
#include "constants.loh"
#else
#ifdef IUPLUA_USELH
#include "iuplua.lh"
#include "constants.lh"
#else
  iuplua_dofile(L, "iuplua.lua");
  iuplua_dofile(L, "constants.lua");
#endif
#endif

  /* Register the common callbacks */
  iuplua_register_cb(L, "HELP_CB", (lua_CFunction)help_cb, NULL);
  iuplua_register_cb(L, "GETFOCUS_CB", (lua_CFunction)getfocus_cb, NULL);
  iuplua_register_cb(L, "K_ANY", (lua_CFunction)k_any, NULL);
  iuplua_register_cb(L, "KILLFOCUS_CB", (lua_CFunction)killfocus_cb, NULL);
  iuplua_register_cb(L, "MULTITOUCH_CB", (lua_CFunction)multitouch_cb, NULL);

  /* Register global callbacks */
  iuplua_register_cb(L, "GLOBALWHEEL_CB", (lua_CFunction)globalwheel_cb, NULL);
  iuplua_register_cb(L, "GLOBALBUTTON_CB", (lua_CFunction)globalbutton_cb, NULL);
  iuplua_register_cb(L, "GLOBALMOTION_CB", (lua_CFunction)globalmotion_cb, NULL);
  iuplua_register_cb(L, "GLOBALKEYPRESS_CB", (lua_CFunction)globalkeypress_cb, NULL);
  iuplua_register_cb(L, "GLOBALCTRLFUNC_CB", (lua_CFunction)globalctrlfunc_cb, NULL);
  iuplua_register_cb(L, "IDLE_ACTION", (lua_CFunction)globalidle_cb, NULL);

  /* Register Keys */
  iupKeyForEach(register_key, (void*)L);

  /* Iup Modules initialization */
  iupbuttonlua_open(L);
  iupluadraw_open(L);  /* must be before canvas */
  iupcanvaslua_open(L);
  iupdialoglua_open(L);
  iupfilllua_open(L);
  iupframelua_open(L);
  iupfiledlglua_open(L);
  iuphboxlua_open(L);
  iupitemlua_open(L);
  iupimagelua_open(L);
  iuplabellua_open(L);
  iuplistlua_open(L);
  iupmenulua_open(L);
  iupmultilinelua_open(L);
  iupradiolua_open(L);
  iupseparatorlua_open(L);
  iupsubmenulua_open(L);
  iuptextlua_open(L);
  iuptogglelua_open(L);
  iupvboxlua_open(L);
  iupzboxlua_open(L);
  iuptimerlua_open(L);
  iupsboxlua_open(L);
  iupsplitlua_open(L);
  iupspinlua_open(L);
  iupspinboxlua_open(L);
  iupscrollboxlua_open(L);
  iupgridboxlua_open(L);
  iupmultiboxlua_open(L);
  iupexpanderlua_open(L);
  iuplinklua_open(L);
  iupcboxlua_open(L);
  iupdetachboxlua_open(L);
  iupbackgroundboxlua_open(L);
  iupgclua_open(L);
  iupgetparamlua_open(L);
  iupvallua_open(L);
  iuptabslua_open(L);
  iupfontdlglua_open(L);
  iupmessagedlglua_open(L);
  iupcolordlglua_open(L);
  iupimagergbalua_open(L);
  iupimagergblua_open(L);
  iupprogressbarlua_open(L);
  iupnormalizerlua_open(L);
  iupuserlua_open(L);
  iuptreelua_open(L);
  iupclipboardlua_open(L);
  iupprogressdlglua_open(L);
  iupflatlabellua_open(L);
  iupflatbuttonlua_open(L);
  iupflattogglelua_open(L);
  iupdropbuttonlua_open(L);
  iupflatframelua_open(L);
  iupflatseparatorlua_open(L);
  iupspacelua_open(L);
  iupconfiglua_open(L);
  iupanimatedlabellua_open(L);
  iupcalendarlua_open(L);
  iupdatepicklua_open(L);
  iupflattabslua_open(L);
  iupflatscrollboxlua_open(L);
  iupgaugelua_open(L);
  iupdiallua_open(L);
  iupcolorbarlua_open(L);
  iupcolorbrowserlua_open(L);

  return 0; /* nothing in stack */
}
Example #2
0
int iuplua_open(void)
{
  struct FuncList {
    char *name;
    lua_CFunction func;
  } FuncList[] = {
    { "IupSetIdle", IupSetIdle },
  };
  int SizeFuncList = (sizeof(FuncList)/sizeof(struct FuncList));
  int i;

  iuplua_tag = lua_newtag();
  lua_pushnumber(iuplua_tag);
  lua_setglobal("iuplua_tag");

  iuplua_namespace = lua_createtable();
  lua_pushobject(iuplua_namespace); lua_setglobal ("iup");

  setinfo();

  for (i = 0; i < SizeFuncList; i++)
    iuplua_register(FuncList[i].name, FuncList[i].func);

  lua_register("iup_gettable", iuplua_gettable);
  lua_register("iup_settable", iuplua_settable);
  lua_register("iup_index", iuplua_index);
  lua_register("iupSetCallback", iuplua_set_callback);

  iupKeyForEach(register_key, NULL);

  iupluaapi_open();

#ifdef IUPLUA_USELOH
#ifdef TEC_BIGENDIAN
#ifdef TEC_64
#include "loh/iuplua_be64.loh"
#include "loh/constants_be64.loh"
#else
#include "loh/iuplua_be32.loh"
#include "loh/constants_be32.loh"
#endif  
#else
#ifdef TEC_64
#ifdef WIN64
#include "loh/iuplua_le64w.loh"
#include "loh/constants_le64w.loh"
#else
#include "loh/iuplua_le64.loh"
#include "loh/constants_le64.loh"
#endif  
#else
#include "loh/iuplua.loh"
#include "loh/constants.loh"
#endif  
#endif  
#else
  iuplua_dofile("iuplua.lua");
  iuplua_dofile("constants.lua");
#endif

  iupluawidgets_open(iuplua_tag);

  sboxlua_open();
  spinlua_open();
  cboxlua_open();
  vallua_open();
  tabslua_open();
  gclua_open();
  getparamlua_open();
  treelua_open();

  return 1;
}