From: John L. <jr...@us...> - 2011-04-22 02:49:20
|
Update of /cvsroot/wxlua/wxLua/bindings/wxwidgets In directory vz-cvs-4.sog:/tmp/cvs-serv5863/bindings/wxwidgets Modified Files: wx_datatypes.lua wxcore_controls.i wxcore_override.hpp Log Message: Added wxTreeCtrl methods, use wxLuaTreeItemData and allow it to take any Lua object. Add WXLUA_TPOINTER as as type that lua_topointer() could return. Index: wx_datatypes.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxwidgets/wx_datatypes.lua,v retrieving revision 1.105 retrieving revision 1.106 diff -C2 -d -r1.105 -r1.106 *** wx_datatypes.lua 12 Aug 2010 23:41:09 -0000 1.105 --- wx_datatypes.lua 22 Apr 2011 02:49:17 -0000 1.106 *************** *** 20,23 **** --- 20,24 ---- wxTextCoord = "long", wxTraceMask = "unsigned long", + wxTreeItemIdValue = "double", } *************** *** 58,61 **** --- 59,67 ---- ValueType = "number", }, + any = { + IsNumber = true, + Name = "any", + ValueType = "special", + }, bool = { IsNumber = true, *************** *** 4702,4709 **** }, wxTreeItemIdValue = { - Condition = "wxLUA_USE_wxTreeCtrl && wxUSE_TREECTRL", IsNumber = true, Name = "wxTreeItemIdValue", ! ValueType = "enum", }, wxTreebook = { --- 4708,4714 ---- }, wxTreeItemIdValue = { IsNumber = true, Name = "wxTreeItemIdValue", ! ValueType = "number", }, wxTreebook = { Index: wxcore_override.hpp =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxwidgets/wxcore_override.hpp,v retrieving revision 1.22 retrieving revision 1.23 diff -C2 -d -r1.22 -r1.23 *** wxcore_override.hpp 3 Dec 2010 04:39:43 -0000 1.22 --- wxcore_override.hpp 22 Apr 2011 02:49:18 -0000 1.23 *************** *** 525,537 **** %override wxLua_wxTreeCtrl_GetFirstChild ! // wxTreeItemId GetFirstChild(const wxTreeItemId& item, long& cookie) const static int LUACALL wxLua_wxTreeCtrl_GetFirstChild(lua_State *L) { - #if wxCHECK_VERSION(2, 5, 0) wxTreeItemIdValue cookie = 0; ! #else ! // long& cookie ! long cookie = 0; ! #endif // const wxTreeItemId& item const wxTreeItemId *item = (wxTreeItemId *)wxluaT_getuserdatatype(L, 2, wxluatype_wxTreeItemId); --- 525,533 ---- %override wxLua_wxTreeCtrl_GetFirstChild ! // wxTreeItemId GetFirstChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const static int LUACALL wxLua_wxTreeCtrl_GetFirstChild(lua_State *L) { wxTreeItemIdValue cookie = 0; ! // const wxTreeItemId& item const wxTreeItemId *item = (wxTreeItemId *)wxluaT_getuserdatatype(L, 2, wxluatype_wxTreeItemId); *************** *** 545,554 **** // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_wxTreeItemId); - #if wxCHECK_VERSION(2, 5, 0) - lua_pushnumber(L, (long)cookie); // wxTreeItemIdValue is void* - #else // push the cookie ! lua_pushnumber(L, cookie); ! #endif // return the number of parameters return 2; --- 541,546 ---- // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_wxTreeItemId); // push the cookie ! lua_pushlightuserdata(L, cookie); // wxTreeItemIdValue is void* // return the number of parameters return 2; *************** *** 557,569 **** %override wxLua_wxTreeCtrl_GetNextChild ! // wxTreeItemId GetNextChild(const wxTreeItemId& item, long& cookie) const static int LUACALL wxLua_wxTreeCtrl_GetNextChild(lua_State *L) { ! #if wxCHECK_VERSION(2, 5, 0) ! wxTreeItemIdValue cookie = (wxTreeItemIdValue)(long)wxlua_getintegertype(L, 3); ! #else ! // long& cookie ! long cookie = (long)lua_tonumber(L, 3); ! #endif // const wxTreeItemId& item const wxTreeItemId *item = (wxTreeItemId *)wxluaT_getuserdatatype(L, 2, wxluatype_wxTreeItemId); --- 549,557 ---- %override wxLua_wxTreeCtrl_GetNextChild ! // wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const static int LUACALL wxLua_wxTreeCtrl_GetNextChild(lua_State *L) { ! wxTreeItemIdValue cookie = (wxTreeItemIdValue)wxlua_getpointertype(L, 3); ! // const wxTreeItemId& item const wxTreeItemId *item = (wxTreeItemId *)wxluaT_getuserdatatype(L, 2, wxluatype_wxTreeItemId); *************** *** 577,586 **** // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_wxTreeItemId); - #if wxCHECK_VERSION(2, 5, 0) - lua_pushnumber(L, (long)cookie); - #else // push the cookie ! lua_pushnumber(L, cookie); ! #endif // return the number of parameters return 2; --- 565,570 ---- // push the result datatype wxluaT_pushuserdatatype(L, returns, wxluatype_wxTreeItemId); // push the cookie ! lua_pushlightuserdata(L, cookie); // wxTreeItemIdValue is void* // return the number of parameters return 2; *************** *** 637,640 **** --- 621,678 ---- %end + %override wxLua_wxLuaTreeItemData_GetData + // wxLuaObject* GetData() const; + static int LUACALL wxLua_wxLuaTreeItemData_GetData(lua_State *L) + { + // get this + wxLuaTreeItemData * self = (wxLuaTreeItemData *)wxluaT_getuserdatatype(L, 1, wxluatype_wxLuaTreeItemData); + // call GetData + wxLuaObject* returns = (wxLuaObject*)self->GetData(); + // push the result datatype + if ((returns == NULL) || !returns->GetObject(L)) + lua_pushnil(L); + + return 1; + } + %end + + %override wxLua_wxLuaTreeItemData_SetData + // void SetData(%ungc wxLuaObject* obj); // obj is deleted when tree item data is deleted + static int LUACALL wxLua_wxLuaTreeItemData_SetData(lua_State *L) + { + // wxLuaObject obj + //wxLuaObject * obj = (wxLuaObject *)wxluaT_getuserdatatype(L, 2, wxluatype_wxLuaObject); + //if (wxluaO_isgcobject(L, obj)) wxluaO_undeletegcobject(L, obj); + wxLuaObject* obj = new wxLuaObject(L, 2); + + // get this + wxLuaTreeItemData * self = (wxLuaTreeItemData *)wxluaT_getuserdatatype(L, 1, wxluatype_wxLuaTreeItemData); + // call SetData + self->SetData(obj); + + return 0; + } + %end + + %override wxLua_wxLuaTreeItemData_constructor1 + // wxLuaTreeItemData(%ungc wxLuaObject* obj) // obj is deleted when tree item data is deleted + static int LUACALL wxLua_wxLuaTreeItemData_constructor1(lua_State *L) + { + // wxLuaObject obj + //wxLuaObject * obj = (wxLuaObject *)wxluaT_getuserdatatype(L, 1, wxluatype_wxLuaObject); + //if (wxluaO_isgcobject(L, obj)) wxluaO_undeletegcobject(L, obj); + wxLuaObject* obj = new wxLuaObject(L, 1); + + // call constructor + wxLuaTreeItemData* returns = new wxLuaTreeItemData(obj); + // add to tracked memory list + wxluaO_addgcobject(L, returns, wxluatype_wxLuaTreeItemData); + // push the constructed class pointer + wxluaT_pushuserdatatype(L, returns, wxluatype_wxLuaTreeItemData); + + return 1; + } + %end + %override wxLua_wxTextValidator_constructor Index: wxcore_controls.i =================================================================== RCS file: /cvsroot/wxlua/wxLua/bindings/wxwidgets/wxcore_controls.i,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** wxcore_controls.i 1 Oct 2009 04:21:00 -0000 1.10 --- wxcore_controls.i 22 Apr 2011 02:49:18 -0000 1.11 *************** *** 1071,1080 **** bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "wxTreeCtrl") ! wxTreeItemId AddRoot(const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL) ! wxTreeItemId AppendItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL) //void AssignButtonsImageList(wxImageList* imageList) void AssignImageList(%ungc wxImageList* imageList) void AssignStateImageList(%ungc wxImageList* imageList) void Collapse(const wxTreeItemId& item) void CollapseAndReset(const wxTreeItemId& item) void Delete(const wxTreeItemId& item) --- 1071,1082 ---- bool Create(wxWindow* parent, wxWindowID id, const wxPoint& pos = wxDefaultPosition, const wxSize& size = wxDefaultSize, long style = wxTR_HAS_BUTTONS, const wxValidator& validator = wxDefaultValidator, const wxString& name = "wxTreeCtrl") ! wxTreeItemId AddRoot(const wxString& text, int image = -1, int selImage = -1, %ungc wxLuaTreeItemData* data = NULL) ! wxTreeItemId AppendItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, %ungc wxLuaTreeItemData* data = NULL) //void AssignButtonsImageList(wxImageList* imageList) void AssignImageList(%ungc wxImageList* imageList) void AssignStateImageList(%ungc wxImageList* imageList) void Collapse(const wxTreeItemId& item) + void CollapseAll() + void CollapseAllChildren(const wxTreeItemId& item) void CollapseAndReset(const wxTreeItemId& item) void Delete(const wxTreeItemId& item) *************** *** 1085,1093 **** void EnsureVisible(const wxTreeItemId& item) void Expand(const wxTreeItemId& item) bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly = false) const //wxImageList* GetButtonsImageList() const size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true) const int GetCount() const ! //wxTextCtrl* GetEditControl() const // %override [wxTreeItemId, wxTreeItemIdValue cookie] wxTreeCtrl::GetFirstChild(const wxTreeItemId& item) --- 1087,1097 ---- void EnsureVisible(const wxTreeItemId& item) void Expand(const wxTreeItemId& item) + void ExpandAll() + void ExpandAllChildren(const wxTreeItemId& item) bool GetBoundingRect(const wxTreeItemId& item, wxRect& rect, bool textOnly = false) const //wxImageList* GetButtonsImageList() const size_t GetChildrenCount(const wxTreeItemId& item, bool recursively = true) const int GetCount() const ! //wxTextCtrl* GetEditControl() const // MSW only // %override [wxTreeItemId, wxTreeItemIdValue cookie] wxTreeCtrl::GetFirstChild(const wxTreeItemId& item) *************** *** 1099,1103 **** int GetIndent() const wxColour GetItemBackgroundColour(const wxTreeItemId& item) const ! wxTreeItemData* GetItemData(const wxTreeItemId& item) const wxFont GetItemFont(const wxTreeItemId& item) const int GetItemImage(const wxTreeItemId& item, wxTreeItemIcon which = wxTreeItemIcon_Normal) const --- 1103,1107 ---- int GetIndent() const wxColour GetItemBackgroundColour(const wxTreeItemId& item) const ! wxLuaTreeItemData* GetItemData(const wxTreeItemId& item) const wxFont GetItemFont(const wxTreeItemId& item) const int GetItemImage(const wxTreeItemId& item, wxTreeItemIcon which = wxTreeItemIcon_Normal) const *************** *** 1108,1112 **** // %override [wxTreeItemId, wxTreeItemIdValue cookie] wxTreeCtrl::GetNextChild(const wxTreeItemId& item, long cookie) // C++ Func: wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const ! wxTreeItemId GetNextChild(const wxTreeItemId& item, long cookie) const wxTreeItemId GetNextSibling(const wxTreeItemId& item) const --- 1112,1116 ---- // %override [wxTreeItemId, wxTreeItemIdValue cookie] wxTreeCtrl::GetNextChild(const wxTreeItemId& item, long cookie) // C++ Func: wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const ! wxTreeItemId GetNextChild(const wxTreeItemId& item, wxTreeItemIdValue& cookie) const wxTreeItemId GetNextSibling(const wxTreeItemId& item) const *************** *** 1116,1120 **** wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const wxTreeItemId GetRootItem() const ! //!%wxchkver_2_6|%wxcompat_2_4 int GetItemSelectedImage(const wxTreeItemId& item) const wxTreeItemId GetSelection() const --- 1120,1125 ---- wxTreeItemId GetPrevVisible(const wxTreeItemId& item) const wxTreeItemId GetRootItem() const ! bool GetQuickBestSize() const ! //!%wxchkver_2_6|%wxcompat_2_4 int GetItemSelectedImage(const wxTreeItemId& item) const // obsolete function wxTreeItemId GetSelection() const *************** *** 1129,1135 **** wxTreeItemId HitTest(const wxPoint& point) ! wxTreeItemId InsertItem(const wxTreeItemId& parent, const wxTreeItemId& previous, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL) ! wxTreeItemId InsertItem(const wxTreeItemId& parent, size_t before, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL) bool IsBold(const wxTreeItemId& item) const bool IsExpanded(const wxTreeItemId& item) const bool IsSelected(const wxTreeItemId& item) const --- 1134,1141 ---- wxTreeItemId HitTest(const wxPoint& point) ! wxTreeItemId InsertItem(const wxTreeItemId& parent, const wxTreeItemId& previous, const wxString& text, int image = -1, int selImage = -1, %ungc wxLuaTreeItemData* data = NULL) ! wxTreeItemId InsertItem(const wxTreeItemId& parent, size_t before, const wxString& text, int image = -1, int selImage = -1, %ungc wxLuaTreeItemData* data = NULL) bool IsBold(const wxTreeItemId& item) const + bool IsEmpty() const bool IsExpanded(const wxTreeItemId& item) const bool IsSelected(const wxTreeItemId& item) const *************** *** 1137,1141 **** bool ItemHasChildren(const wxTreeItemId& item) const //int OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2) ! wxTreeItemId PrependItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, wxTreeItemData* data = NULL) void ScrollTo(const wxTreeItemId& item) void SelectItem(const wxTreeItemId& item, bool select = true) --- 1143,1147 ---- bool ItemHasChildren(const wxTreeItemId& item) const //int OnCompareItems(const wxTreeItemId& item1, const wxTreeItemId& item2) ! wxTreeItemId PrependItem(const wxTreeItemId& parent, const wxString& text, int image = -1, int selImage = -1, %ungc wxLuaTreeItemData* data = NULL) void ScrollTo(const wxTreeItemId& item) void SelectItem(const wxTreeItemId& item, bool select = true) *************** *** 1145,1156 **** void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col) void SetItemBold(const wxTreeItemId& item, bool bold = true) ! void SetItemData(const wxTreeItemId& item, wxTreeItemData* data) void SetItemDropHighlight(const wxTreeItemId& item, boolhighlight = true) void SetItemFont(const wxTreeItemId& item, const wxFont& font) void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = true) void SetItemImage(const wxTreeItemId& item, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal) ! //!%wxchkver_2_6|%wxcompat_2_4 void SetItemSelectedImage(const wxTreeItemId& item, int selImage) void SetItemText(const wxTreeItemId& item, const wxString& text) void SetItemTextColour(const wxTreeItemId& item, const wxColour& col) void SetStateImageList(wxImageList* imageList) // void SetWindowStyle(long styles) - see wxWindow --- 1151,1163 ---- void SetItemBackgroundColour(const wxTreeItemId& item, const wxColour& col) void SetItemBold(const wxTreeItemId& item, bool bold = true) ! void SetItemData(const wxTreeItemId& item, %ungc wxLuaTreeItemData* data) void SetItemDropHighlight(const wxTreeItemId& item, boolhighlight = true) void SetItemFont(const wxTreeItemId& item, const wxFont& font) void SetItemHasChildren(const wxTreeItemId& item, bool hasChildren = true) void SetItemImage(const wxTreeItemId& item, int image, wxTreeItemIcon which = wxTreeItemIcon_Normal) ! //!%wxchkver_2_6|%wxcompat_2_4 void SetItemSelectedImage(const wxTreeItemId& item, int selImage) // obsolete function void SetItemText(const wxTreeItemId& item, const wxString& text) void SetItemTextColour(const wxTreeItemId& item, const wxColour& col) + void SetQuickBestSize(bool quickBestSize) void SetStateImageList(wxImageList* imageList) // void SetWindowStyle(long styles) - see wxWindow *************** *** 1186,1202 **** // wxTreeItemIdValue - wxTreeCtrl ! //%if %wxchkver_2_6 ! //%class wxTreeItemIdValue ! //%endclass ! //%endif // --------------------------------------------------------------------------- // wxTreeItemId - wxTreeCtrl - %enum wxTreeItemIdValue - // FAKE enum, actually typedef void* wxTreeItemIdValue - // but Lua only uses double. This gets around compiler errors/warnings - %endenum - %class %delete wxTreeItemId wxTreeItemId() --- 1193,1203 ---- // wxTreeItemIdValue - wxTreeCtrl ! // FAKE typedef, actually typedef void* wxTreeItemIdValue ! // Since we override the functions that use it we handle it as a pointer. ! %typedef double wxTreeItemIdValue // --------------------------------------------------------------------------- // wxTreeItemId - wxTreeCtrl %class %delete wxTreeItemId wxTreeItemId() *************** *** 1243,1250 **** // wxTreeItemData - wxTreeCtrl, see also wxLuaTreeItemData // ! // No %delete since the wxTreeCtrl should do it and you should only create one ! // of these if you're going to attach it to a wxTreeCtrl to avoid memory leaks. ! %class wxTreeItemData, wxClientData wxTreeItemData() --- 1244,1251 ---- // wxTreeItemData - wxTreeCtrl, see also wxLuaTreeItemData // ! // No %delete since the wxTreeCtrl will delete it when set as the data for an item. ! // Only create a wxTreeItemData if you're going to attach it to a wxTreeCtrl item to avoid memory leaks. ! %class %delete wxTreeItemData, wxClientData wxTreeItemData() *************** *** 1254,1269 **** // --------------------------------------------------------------------------- ! // wxLuaTreeItemData // ! // No %delete since the wxTreeCtrl should do it and you should only create one ! // of these if you're going to attach it to a wxTreeCtrl to avoid memory leaks. %include "wxbind/include/wxcore_wxlcore.h" ! %class wxLuaTreeItemData, wxTreeItemData ! wxLuaTreeItemData(double value = 0) ! double GetValue() const; ! void SetValue(double value); %endclass --- 1255,1278 ---- // --------------------------------------------------------------------------- ! // wxLuaTreeItemData - // ! // No %delete since the wxTreeCtrl will delete it when set as the data for an item. ! // Only create a wxLuaTreeItemData if you're going to attach it to a wxTreeCtrl item to avoid memory leaks. %include "wxbind/include/wxcore_wxlcore.h" ! %class %delete wxLuaTreeItemData, wxTreeItemData ! wxLuaTreeItemData() ! // %override wxLuaTreeItemData(any) ! // C++ Func: wxLuaTreeItemData(wxLuaObject* obj) ! wxLuaTreeItemData(any) ! ! // %override any wxLuaTreeItemData::GetData() const ! // C++ Func: wxLuaObject* GetData() const ! any GetData() const; ! // %override void wxLuaTreeItemData::SetData(any) ! // C++ Func: void SetData(wxLuaObject* obj) ! void SetData(any); %endclass |