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 | |
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')
-rw-r--r-- | plugins/MirLua/docs/examples/popup.lua | 13 | ||||
-rw-r--r-- | plugins/MirLua/src/m_popup.cpp | 47 | ||||
-rw-r--r-- | plugins/MirLua/src/stdafx.h | 2 | ||||
-rw-r--r-- | plugins/MirLua/src/version.h | 2 |
4 files changed, 58 insertions, 6 deletions
diff --git a/plugins/MirLua/docs/examples/popup.lua b/plugins/MirLua/docs/examples/popup.lua index 7195962d47..172b98ea59 100644 --- a/plugins/MirLua/docs/examples/popup.lua +++ b/plugins/MirLua/docs/examples/popup.lua @@ -6,12 +6,23 @@ local clist = require('m_clist') m.CreateServiceFunction('MirLua/ShowPopup', function() local popupData = { + ContactName = 'Contact', + Text = 'Popup content', + hContact = 0 + } + popup.AddPopup(popupData) +end) + +m.CreateServiceFunction('MirLua/ShowPopup2', function() + local popupData = + { Title = 'Title', Text = 'Popup content', hContact = 0, Flags = 1 } - popup.AddPopup(popupData) + popup.AddPopup2(popupData) end) clist.AddMainMenuItem({ Name = "Show lua popup", Service = 'MirLua/ShowPopup' }) +clist.AddMainMenuItem({ Name = "Show lua popup2", Service = 'MirLua/ShowPopup2' }) 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 }
};
diff --git a/plugins/MirLua/src/stdafx.h b/plugins/MirLua/src/stdafx.h index d871d739ea..9e9c1cb55f 100644 --- a/plugins/MirLua/src/stdafx.h +++ b/plugins/MirLua/src/stdafx.h @@ -35,6 +35,8 @@ extern "C" #include "resource.h"
#include "mlua.h"
+#include "mlua_module.h"
+#include "mlua_m_clist.h"
#include "mlua_module_loader.h"
#include "mlua_script_loader.h"
#include "mlua_options.h"
diff --git a/plugins/MirLua/src/version.h b/plugins/MirLua/src/version.h index 5f118b7f7c..3a3afa1b3c 100644 --- a/plugins/MirLua/src/version.h +++ b/plugins/MirLua/src/version.h @@ -1,7 +1,7 @@ #define __MAJOR_VERSION 0
#define __MINOR_VERSION 11
#define __RELEASE_NUM 3
-#define __BUILD_NUM 1
+#define __BUILD_NUM 2
#include <stdver.h>
|