diff options
author | Alexander Lantsev <aunsane@gmail.com> | 2015-07-10 18:20:29 +0000 |
---|---|---|
committer | Alexander Lantsev <aunsane@gmail.com> | 2015-07-10 18:20:29 +0000 |
commit | dc22e5647a7a650b1eccb376d886cfbaa36e26ca (patch) | |
tree | c7df1ac4cfc86048efd7ae78c07b6e393c0a72f8 /plugins/MirLua/src/m_popup.cpp | |
parent | 2329457a8658926ceae20cf6ff883b24965e052f (diff) |
MirLua: added PopupData support in m_popup
git-svn-id: http://svn.miranda-ng.org/main/trunk@14526 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c
Diffstat (limited to 'plugins/MirLua/src/m_popup.cpp')
-rw-r--r-- | plugins/MirLua/src/m_popup.cpp | 47 |
1 files changed, 43 insertions, 4 deletions
diff --git a/plugins/MirLua/src/m_popup.cpp b/plugins/MirLua/src/m_popup.cpp index c064d34ef3..3458ec3a73 100644 --- a/plugins/MirLua/src/m_popup.cpp +++ b/plugins/MirLua/src/m_popup.cpp @@ -1,6 +1,44 @@ #include "stdafx.h"
-static POPUPDATA2* MakePopupData(lua_State *L)
+static POPUPDATAT* MakePopupData(lua_State *L)
+{
+ POPUPDATAT *ppd = (POPUPDATAT*)mir_calloc(sizeof(POPUPDATAT));
+
+ lua_pushstring(L, "ContactName");
+ lua_gettable(L, -2);
+ mir_tstrcpy(ppd->lptzContactName, mir_utf8decodeT(lua_tostring(L, -1)));
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "Text");
+ lua_gettable(L, -2);
+ mir_tstrcpy(ppd->lptzText, mir_utf8decodeT(luaL_checkstring(L, -1)));
+ lua_pop(L, 1);
+
+ lua_pushstring(L, "hContact");
+ lua_gettable(L, -2);
+ ppd->lchContact = lua_tointeger(L, -1);
+ lua_pop(L, 1);
+
+ return ppd;
+}
+
+static int lua_AddPopup(lua_State *L)
+{
+ if (lua_type(L, 1) != LUA_TTABLE)
+ {
+ lua_pushlightuserdata(L, 0);
+ return 1;
+ }
+
+ mir_ptr<POPUPDATAT> ppd(MakePopupData(L));
+
+ INT_PTR res = ::CallService(MS_POPUP_ADDPOPUPT, (WPARAM)ppd, 0);
+ lua_pushinteger(L, res);
+
+ return 1;
+}
+
+static POPUPDATA2* MakePopupData2(lua_State *L)
{
POPUPDATA2 *ppd = (POPUPDATA2*)mir_calloc(sizeof(POPUPDATA2));
ppd->cbSize = sizeof(POPUPDATA2);
@@ -46,7 +84,7 @@ static POPUPDATA2* MakePopupData(lua_State *L) return ppd;
}
-static int lua_AddPoput(lua_State *L)
+static int lua_AddPopup2(lua_State *L)
{
if (lua_type(L, 1) != LUA_TTABLE)
{
@@ -54,7 +92,7 @@ static int lua_AddPoput(lua_State *L) return 1;
}
- mir_ptr<POPUPDATA2> ppd(MakePopupData(L));
+ mir_ptr<POPUPDATA2> ppd(MakePopupData2(L));
INT_PTR res = ::CallService(MS_POPUP_ADDPOPUP2, (WPARAM)ppd, 0);
lua_pushinteger(L, res);
@@ -67,7 +105,8 @@ static int lua_AddPoput(lua_State *L) static luaL_Reg popupApi[] =
{
- { "AddPopup", lua_AddPoput },
+ { "AddPopup", lua_AddPopup },
+ { "AddPopup2", lua_AddPopup2 },
{ NULL, NULL }
};
|