>
> It can't be used currently. I have wondered if it's really worth it.
> The idea is that you can optimize the drawing with a list, but in a
> scripting language the creation of the list itself may negate any
> benefits.
>
The list should be a lua table for optimization and then
could be something like:
static int LUACALL wxLua_wxDC_DrawPolygon1(lua_State *L)
{
// get number of arguments
int argCount = lua_gettop(L);
// wxPolygonFillMode fill_style = wxODDEVEN_RULE
wxPolygonFillMode fill_style = (argCount >= 5 ?
(wxPolygonFillMode)wxlua_getenumtype(L, 5) : wxODDEVEN_RULE);
// wxCoord yoffset = 0
wxCoord yoffset = (argCount >= 4 ? (wxCoord)wxlua_getnumbertype(L, 4) :
0);
// wxCoord xoffset = 0
wxCoord xoffset = (argCount >= 3 ? (wxCoord)wxlua_getnumbertype(L, 3) :
0);
// const wxList points
luaL_checktype(L, 2, LUA_TTABLE);
int n = lua_objlen(L, 2); /* get size of table */
double x,y;
wxList<wxPoint> pointList;
for (int i = 1; i <= n; i++) {
lua_rawgeti(L, 2, i); /* get next point as {x,y} */
luaL_checktype(L, -1, LUA_TTABLE);
lua_rawgeti(L,-1,1);
if (!lua_isnumber(L, -1))
luaL_error(L, "coordinate x not a number");
x = lua_tonumber(L ,-1)
lua_pop(L,1);
lua_rawgeti(L,-1,2);
if (!lua_isnumber(L, -1))
luaL_error(L, "coordinate Y not a number");
y = lua_tonumber(L ,-1)
lua_pop(L,1);
lua_pop(L,1);
pointList:Append(wxPoint(x,y));
}
//const wxList * points = (const wxList *)wxluaT_getuserdatatype(L, 2,
wxluatype_wxList);
// get this
wxDC * self = (wxDC *)wxluaT_getuserdatatype(L, 1, wxluatype_wxDC);
// call DrawPolygon
self->DrawPolygon(&pointList, xoffset, yoffset, fill_style);
return 0;
}
It is called as paintDC:DrawLines({{0,0},{20,40},{50,50}})
Similar for DrawLines. I dont know how to insert it in wxLua code and how
you control function overloadings. Also perhaps you use something different
than luaL_error.
Best Regards
Victor Bombi
------------------------------------------------------------------------------
Live Security Virtual Conference
Exclusive live event will cover all the ways today's security and
threat landscape has changed and how IT managers can respond. Discussions
will include endpoint security, mobile security and the latest in malware
threats. http://www.accelacomm.com/jaw/sfrnl04242012/114/50122263/
_______________________________________________
wxlua-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/wxlua-users