浏览代码

Implemented the types for ElementFormControlDataSelect/Input/TextArea.

Nate Starkey 13 年之前
父节点
当前提交
9663a4b184

+ 24 - 0
Build/RocketLua.vcproj

@@ -199,6 +199,22 @@
 					RelativePath="..\Source\Controls\Lua\ElementFormControl.h"
 					>
 				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlDataSelect.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlDataSelect.h"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlInput.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlInput.h"
+					>
+				</File>
 				<File
 					RelativePath="..\Source\Controls\Lua\ElementFormControlSelect.cpp"
 					>
@@ -207,6 +223,14 @@
 					RelativePath="..\Source\Controls\Lua\ElementFormControlSelect.h"
 					>
 				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlTextArea.cpp"
+					>
+				</File>
+				<File
+					RelativePath="..\Source\Controls\Lua\ElementFormControlTextArea.h"
+					>
+				</File>
 			</Filter>
 		</Filter>
 		<Filter

+ 51 - 0
Source/Controls/Lua/ElementFormControlDataSelect.cpp

@@ -0,0 +1,51 @@
+#include "precompiled.h"
+#include "ElementFormControlDataSelect.h"
+#include <Rocket/Controls/ElementFormControlSelect.h>
+
+using Rocket::Controls::ElementFormControlSelect;
+namespace Rocket {
+namespace Core {
+namespace Lua {
+//inherits from ElementFormControl which inherits from Element
+template<> void LuaType<ElementFormControlDataSelect>::extra_init(lua_State* L, int metatable_index)
+{
+    //do whatever ElementFormControlSelect did as far as inheritance
+    LuaType<ElementFormControlSelect>::extra_init(L,metatable_index);
+    //then inherit from ElementFromControlSelect
+    LuaType<ElementFormControlSelect>::_regfunctions(L,metatable_index,metatable_index-1);
+}
+
+//method
+int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDataSelect* obj)
+{
+    LUACHECKOBJ(obj);
+    const char* source = luaL_checkstring(L,1);
+    obj->SetDataSource(source);
+    return 0;
+}
+
+RegType<ElementFormControlDataSelect> ElementFormControlDataSelectMethods[] =
+{
+    LUAMETHOD(ElementFormControlDataSelect,SetDataSource)
+    { NULL, NULL },
+};
+
+luaL_reg ElementFormControlDataSelectGetters[] =
+{
+    { NULL, NULL },
+};
+
+luaL_reg ElementFormControlDataSelectSetters[] =
+{
+    { NULL, NULL },
+};
+
+
+template<> const char* GetTClassName<ElementFormControlDataSelect>() { return "ElementFormControlDataSelect"; }
+template<> RegType<ElementFormControlDataSelect>* GetMethodTable<ElementFormControlDataSelect>() { return ElementFormControlDataSelectMethods; }
+template<> luaL_reg* GetAttrTable<ElementFormControlDataSelect>() { return ElementFormControlDataSelectGetters; }
+template<> luaL_reg* SetAttrTable<ElementFormControlDataSelect>() { return ElementFormControlDataSelectSetters; }
+
+}
+}
+}

+ 38 - 0
Source/Controls/Lua/ElementFormControlDataSelect.h

@@ -0,0 +1,38 @@
+#pragma once
+/*
+    This defines the ElementFormControlDataSelect type in the Lua global namespace. I think it is the longest
+    type name.
+
+    It inherits from ElementFormControlSelect, which inherits from ElementFormControl, which inherits from Element
+
+    //method
+    noreturn ElementFormControlDataSelect:SetDataSource(string source)
+*/
+
+
+#include <Rocket/Core/Lua/lua.hpp>
+#include <Rocket/Core/Lua/LuaType.h>
+#include <Rocket/Controls/ElementFormControlDataSelect.h>
+
+using Rocket::Controls::ElementFormControlDataSelect;
+namespace Rocket {
+namespace Core {
+namespace Lua {
+//inherits from ElementFormControl which inherits from Element
+template<> void LuaType<ElementFormControlDataSelect>::extra_init(lua_State* L, int metatable_index);
+
+//method
+int ElementFormControlDataSelectSetDataSource(lua_State* L, ElementFormControlDataSelect* obj);
+
+RegType<ElementFormControlDataSelect> ElementFormControlDataSelectMethods[];
+luaL_reg ElementFormControlDataSelectGetters[];
+luaL_reg ElementFormControlDataSelectSetters[];
+
+template<> const char* GetTClassName<ElementFormControlDataSelect>();
+template<> RegType<ElementFormControlDataSelect>* GetMethodTable<ElementFormControlDataSelect>();
+template<> luaL_reg* GetAttrTable<ElementFormControlDataSelect>();
+template<> luaL_reg* SetAttrTable<ElementFormControlDataSelect>();
+
+}
+}
+}

+ 160 - 0
Source/Controls/Lua/ElementFormControlInput.cpp

@@ -0,0 +1,160 @@
+#include "precompiled.h"
+#include "ElementFormControlInput.h"
+#include <Rocket/Controls/ElementFormControl.h>
+
+using Rocket::Controls::ElementFormControl;
+namespace Rocket {
+namespace Core {
+namespace Lua {
+//inherits from ElementFormControl which inherits from Element
+template<> void LuaType<ElementFormControlInput>::extra_init(lua_State* L, int metatable_index)
+{
+    LuaType<ElementFormControl>::extra_init(L,metatable_index);
+    LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
+}
+
+//getters
+int ElementFormControlInputGetAttrchecked(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushboolean(L,obj->HasAttribute("checked"));
+    return 1;
+}
+
+int ElementFormControlInputGetAttrmaxlength(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetAttribute<int>("maxlength",-1));
+    return 1;
+}
+
+int ElementFormControlInputGetAttrsize(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetAttribute<int>("size",20));
+    return 1;
+}
+
+int ElementFormControlInputGetAttrmax(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetAttribute<int>("max",100));
+    return 1;
+}
+
+int ElementFormControlInputGetAttrmin(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetAttribute<int>("min",0));
+    return 1;
+}
+
+int ElementFormControlInputGetAttrstep(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetAttribute<int>("step",1));
+    return 1;
+}
+
+
+//setters
+int ElementFormControlInputSetAttrchecked(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    bool checked = CHECK_BOOL(L,2);
+    if(checked)
+        obj->SetAttribute("checked",true);
+    else
+        obj->RemoveAttribute("checked");
+    return 0;
+}
+
+int ElementFormControlInputSetAttrmaxlength(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    int maxlength = luaL_checkint(L,2);
+    obj->SetAttribute("maxlength",maxlength);
+    return 0;
+}
+
+int ElementFormControlInputSetAttrsize(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    int size = luaL_checkint(L,2);
+    obj->SetAttribute("size",size);
+    return 0;
+}
+
+int ElementFormControlInputSetAttrmax(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    int max = luaL_checkint(L,2);
+    obj->SetAttribute("max",max);
+    return 0;
+}
+
+int ElementFormControlInputSetAttrmin(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    int min = luaL_checkint(L,2);
+    obj->SetAttribute("min",min);
+    return 0;
+}
+
+int ElementFormControlInputSetAttrstep(lua_State* L)
+{
+    ElementFormControlInput* obj = LuaType<ElementFormControlInput>::check(L,1);
+    LUACHECKOBJ(obj);
+    int step = luaL_checkint(L,2);
+    obj->SetAttribute("step",step);
+    return 0;
+}
+
+
+RegType<ElementFormControlInput> ElementFormControlInputMethods[] = 
+{
+    {NULL,NULL},
+};
+
+luaL_reg ElementFormControlInputGetters[] = 
+{
+    LUAGETTER(ElementFormControlInput,checked)
+    LUAGETTER(ElementFormControlInput,maxlength)
+    LUAGETTER(ElementFormControlInput,size)
+    LUAGETTER(ElementFormControlInput,max)
+    LUAGETTER(ElementFormControlInput,min)
+    LUAGETTER(ElementFormControlInput,step)
+    {NULL,NULL},
+};
+
+luaL_reg ElementFormControlInputSetters[] = 
+{
+    LUASETTER(ElementFormControlInput,checked)
+    LUASETTER(ElementFormControlInput,maxlength)
+    LUASETTER(ElementFormControlInput,size)
+    LUASETTER(ElementFormControlInput,max)
+    LUASETTER(ElementFormControlInput,min)
+    LUASETTER(ElementFormControlInput,step)
+    {NULL,NULL},
+};
+
+
+template<> const char* GetTClassName<ElementFormControlInput>() { return "ElementFormControlInput"; }
+template<> RegType<ElementFormControlInput>* GetMethodTable<ElementFormControlInput>() { return ElementFormControlInputMethods; }
+template<> luaL_reg* GetAttrTable<ElementFormControlInput>() { return ElementFormControlInputGetters; }
+template<> luaL_reg* SetAttrTable<ElementFormControlInput>() { return ElementFormControlInputSetters; }
+
+}
+}
+}

+ 54 - 0
Source/Controls/Lua/ElementFormControlInput.h

@@ -0,0 +1,54 @@
+#pragma once
+/*
+    This defines the type ElementFormControlInput in the Lua globla namespace, refered to in this documentation by EFCInput
+
+    It inherits from ELementFormControl which inherits from Element
+
+    all of the properties are read and write
+    bool EFCInput.checked
+    int EFCInput.maxlength
+    int EFCInput.size
+    int EFCInput.max
+    int EFCInput.min
+    int EFCInput.step
+    
+*/
+#include <Rocket/Core/Lua/lua.hpp>
+#include <Rocket/Core/Lua/LuaType.h>
+#include <Rocket/Controls/ElementFormControlInput.h>
+
+using Rocket::Controls::ElementFormControlInput;
+namespace Rocket {
+namespace Core {
+namespace Lua {
+//inherits from ElementFormControl which inherits from Element
+template<> void LuaType<ElementFormControlInput>::extra_init(lua_State* L, int metatable_index);
+
+//getters
+int ElementFormControlInputGetAttrchecked(lua_State* L);
+int ElementFormControlInputGetAttrmaxlength(lua_State* L);
+int ElementFormControlInputGetAttrsize(lua_State* L);
+int ElementFormControlInputGetAttrmax(lua_State* L);
+int ElementFormControlInputGetAttrmin(lua_State* L);
+int ElementFormControlInputGetAttrstep(lua_State* L);
+
+//setters
+int ElementFormControlInputSetAttrchecked(lua_State* L);
+int ElementFormControlInputSetAttrmaxlength(lua_State* L);
+int ElementFormControlInputSetAttrsize(lua_State* L);
+int ElementFormControlInputSetAttrmax(lua_State* L);
+int ElementFormControlInputSetAttrmin(lua_State* L);
+int ElementFormControlInputSetAttrstep(lua_State* L);
+
+RegType<ElementFormControlInput> ElementFormControlInputMethods[];
+luaL_reg ElementFormControlInputGetters[];
+luaL_reg ElementFormControlInputSetters[];
+
+template<> const char* GetTClassName<ElementFormControlInput>();
+template<> RegType<ElementFormControlInput>* GetMethodTable<ElementFormControlInput>();
+template<> luaL_reg* GetAttrTable<ElementFormControlInput>();
+template<> luaL_reg* SetAttrTable<ElementFormControlInput>();
+
+}
+}
+}

+ 119 - 0
Source/Controls/Lua/ElementFormControlTextArea.cpp

@@ -0,0 +1,119 @@
+#include "precompiled.h"
+#include "ElementFormControlTextArea.h"
+#include <Rocket/Controls/ElementFormControl.h>
+
+using Rocket::Controls::ElementFormControl;
+namespace Rocket {
+namespace Core {
+namespace Lua {
+//inherits from ElementFormControl which inherits from Element
+template<> void LuaType<ElementFormControlTextArea>::extra_init(lua_State* L, int metatable_index)
+{
+    LuaType<ElementFormControl>::extra_init(L,metatable_index);
+    LuaType<ElementFormControl>::_regfunctions(L,metatable_index,metatable_index-1);
+}
+
+//getters
+int ElementFormControlTextAreaGetAttrcols(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetNumColumns());
+    return 1;
+}
+
+int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetMaxLength());
+    return 1;
+}
+
+int ElementFormControlTextAreaGetAttrrows(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushinteger(L,obj->GetNumRows());
+    return 1;
+}
+
+int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    lua_pushboolean(L,obj->GetWordWrap());
+    return 1;
+}
+
+
+//setters
+int ElementFormControlTextAreaSetAttrcols(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    int cols = luaL_checkint(L,2);
+    obj->SetNumColumns(cols);
+    return 0;
+}
+
+int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    int ml = luaL_checkint(L,2);
+    obj->SetMaxLength(ml);
+    return 0;
+}
+
+int ElementFormControlTextAreaSetAttrrows(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    int rows = luaL_checkint(L,2);
+    obj->SetNumRows(rows);
+    return 0;
+}
+
+int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L)
+{
+    ElementFormControlTextArea* obj = LuaType<ElementFormControlTextArea>::check(L,1);
+    LUACHECKOBJ(obj);
+    bool ww = CHECK_BOOL(L,2);
+    obj->SetWordWrap(ww);
+    return 0;
+}
+
+
+RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[] =
+{
+    { NULL, NULL },
+};
+
+luaL_reg ElementFormControlTextAreaGetters[] =
+{
+    LUAGETTER(ElementFormControlTextArea,cols)
+    LUAGETTER(ElementFormControlTextArea,maxlength)
+    LUAGETTER(ElementFormControlTextArea,rows)
+    LUAGETTER(ElementFormControlTextArea,wordwrap)
+    { NULL, NULL },
+};
+
+luaL_reg ElementFormControlTextAreaSetters[] =
+{
+    LUASETTER(ElementFormControlTextArea,cols)
+    LUASETTER(ElementFormControlTextArea,maxlength)
+    LUASETTER(ElementFormControlTextArea,rows)
+    LUASETTER(ElementFormControlTextArea,wordwrap)
+    { NULL, NULL },
+};
+
+
+template<> const char* GetTClassName<ElementFormControlTextArea>() { return "ElementFormControlTextArea"; }
+template<> RegType<ElementFormControlTextArea>* GetMethodTable<ElementFormControlTextArea>() { return ElementFormControlTextAreaMethods; }
+template<> luaL_reg* GetAttrTable<ElementFormControlTextArea>() { return ElementFormControlTextAreaGetters; }
+template<> luaL_reg* SetAttrTable<ElementFormControlTextArea>() { return ElementFormControlTextAreaSetters; }
+
+}
+}
+}

+ 47 - 0
Source/Controls/Lua/ElementFormControlTextArea.h

@@ -0,0 +1,47 @@
+#pragma once
+/*
+    This defines the ElementFormControlTextArea type in the Lua global namespace, refered in this documentation by EFCTextArea
+
+    It inherits from ElementFormControl,which inherits from Element
+
+    All properties are read/write
+    int EFCTextArea.cols
+    int EFCTextArea.maxlength
+    int EFCTextArea.rows
+    bool EFCTextArea.wordwrap
+*/
+#include <Rocket/Core/Lua/lua.hpp>
+#include <Rocket/Core/Lua/LuaType.h>
+#include <Rocket/Controls/ElementFormControlTextArea.h>
+
+using Rocket::Controls::ElementFormControlTextArea;
+namespace Rocket {
+namespace Core {
+namespace Lua {
+//inherits from ElementFormControl which inherits from Element
+template<> void LuaType<ElementFormControlTextArea>::extra_init(lua_State* L, int metatable_index);
+
+//getters
+int ElementFormControlTextAreaGetAttrcols(lua_State* L);
+int ElementFormControlTextAreaGetAttrmaxlength(lua_State* L);
+int ElementFormControlTextAreaGetAttrrows(lua_State* L);
+int ElementFormControlTextAreaGetAttrwordwrap(lua_State* L);
+
+//setters
+int ElementFormControlTextAreaSetAttrcols(lua_State* L);
+int ElementFormControlTextAreaSetAttrmaxlength(lua_State* L);
+int ElementFormControlTextAreaSetAttrrows(lua_State* L);
+int ElementFormControlTextAreaSetAttrwordwrap(lua_State* L);
+
+RegType<ElementFormControlTextArea> ElementFormControlTextAreaMethods[];
+luaL_reg ElementFormControlTextAreaGetters[];
+luaL_reg ElementFormControlTextAreaSetters[];
+
+template<> const char* GetTClassName<ElementFormControlTextArea>();
+template<> RegType<ElementFormControlTextArea>* GetMethodTable<ElementFormControlTextArea>();
+template<> luaL_reg* GetAttrTable<ElementFormControlTextArea>();
+template<> luaL_reg* SetAttrTable<ElementFormControlTextArea>();
+
+}
+}
+}