From 297a4ecf64fd16ac6b6616e6938ca86554f46c42 Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Fri, 12 Jun 2015 10:42:43 +0000 Subject: MirLua: added toptoolbar module git-svn-id: http://svn.miranda-ng.org/main/trunk@14132 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/mlua.cpp | 62 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) (limited to 'plugins/MirLua/src/mlua.cpp') diff --git a/plugins/MirLua/src/mlua.cpp b/plugins/MirLua/src/mlua.cpp index 2b9ea1fd92..e731c151a8 100644 --- a/plugins/MirLua/src/mlua.cpp +++ b/plugins/MirLua/src/mlua.cpp @@ -18,6 +18,7 @@ CMLua::CMLua() Preload(MLUA_DATABASE, luaopen_m_database); Preload(MLUA_ICOLIB, luaopen_m_icolib); Preload(MLUA_GENMENU, luaopen_m_genmenu); + Preload(MLUA_TOPTOOLBAR, luaopen_m_toptoolbar); } CMLua::~CMLua() @@ -48,4 +49,65 @@ void CMLua::Preload(const char *name, lua_CFunction loader) lua_pushcfunction(L, loader); lua_setfield(L, -2, name); lua_pop(L, 1); +} + +WPARAM CMLua::GetWParam(lua_State *L, int idx) +{ + WPARAM wParam = NULL; + switch (lua_type(L, idx)) + { + case LUA_TBOOLEAN: + wParam = lua_toboolean(L, idx); + break; + case LUA_TNUMBER: + wParam = lua_tonumber(L, idx); + break; + case LUA_TSTRING: + wParam = (WPARAM)lua_tostring(L, idx); + break; + case LUA_TUSERDATA: + wParam = (WPARAM)lua_touserdata(L, idx); + break; + } + return wParam; +} + +LPARAM CMLua::GetLParam(lua_State *L, int idx) +{ + LPARAM lParam = NULL; + switch (lua_type(L, idx)) + { + case LUA_TBOOLEAN: + lParam = lua_toboolean(L, idx); + break; + case LUA_TNUMBER: + lParam = lua_tonumber(L, idx); + break; + case LUA_TSTRING: + lParam = (LPARAM)lua_tostring(L, idx); + break; + case LUA_TUSERDATA: + lParam = (LPARAM)lua_touserdata(L, idx); + break; + } + return lParam; +} + +int CMLua::HookEventObjParam(void *obj, WPARAM wParam, LPARAM lParam, LPARAM param) +{ + lua_State *L = (lua_State*)obj; + + int ref = param; + lua_rawgeti(L, LUA_REGISTRYINDEX, ref); + + lua_pushnumber(L, wParam); + lua_pushnumber(L, lParam); + if (lua_pcall(L, 2, 1, 0)) + printf("%s\n", lua_tostring(L, -1)); + + int res = (int)lua_tointeger(L, 1); + + //luaL_unref(L, LUA_REGISTRYINDEX, ref); + + return res; } \ No newline at end of file -- cgit v1.2.3