diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-06-12 10:42:43 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-06-12 10:42:43 +0000 |
commit | 297a4ecf64fd16ac6b6616e6938ca86554f46c42 (patch) | |
tree | cb5a12e4901ff6aba2077a05862ff61c51ff4fe8 /plugins/MirLua/src/mlua.cpp | |
parent | 6d73d5c2980507e6823bb629aa2ce8d410989b8a (diff) |
MirLua: added toptoolbar module
git-svn-id: http://svn.miranda-ng.org/main/trunk@14132 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/mlua.cpp')
-rw-r--r-- | plugins/MirLua/src/mlua.cpp | 62 |
1 files changed, 62 insertions, 0 deletions
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 |