From: John L. <jr...@us...> - 2005-06-18 20:53:51
|
Update of /cvsroot/wxlua/wxLua/modules/wxbind/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6010/wxLua/modules/wxbind/src Added Files: wxlhtmlwin.cpp wxlprint.cpp wxluabind_wx26.dsp Log Message: Converted to wxIDE's wrapper files --- NEW FILE: wxlprint.cpp --- ///////////////////////////////////////////////////////////////////////////// // Name: wxLuaPrinting.cpp // Purpose: Provide an interface to wxPrintout for wxLua. // Author: J. Winwood. // Created: July 2002. // Copyright: (c) 2002 Lomtick Software. All rights reserved. // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "wxlprint.h" #endif #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/datetime.h" #include "wxlua/include/callback.h" #include "wxlua/include/internal.h" #include "wxbind/include/wxlprint.h" // forward reference class wxLuaObject; // This lua tag is defined in wxLuaWrap.cpp extern int s_wxLuaPrintout; // ---------------------------------------------------------------------------- // wxLuaPrintout // ---------------------------------------------------------------------------- IMPLEMENT_CLASS(wxLuaPrintout, wxPrintout) wxLuaPrintout::wxLuaPrintout(const wxString& title, wxLuaObject *pObject) : wxPrintout(title), m_pObject(pObject), m_minPage(0), m_maxPage(0), m_pageFrom(0), m_pageTo(0) { } void wxLuaPrintout::SetPageInfo(int minPage, int maxPage, int pageFrom, int pageTo) { m_minPage = minPage; m_maxPage = maxPage; m_pageFrom = pageFrom; m_pageTo = pageTo; } void wxLuaPrintout::GetPageInfo(int *minPage, int *maxPage, int *pageFrom, int *pageTo) { lua_State *luaState = getDerivedMethod(this, "GetPageInfo"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); LuaCall(luaState, 1, false); *minPage = (int) lua_tonumber(luaState, -4); *maxPage = (int) lua_tonumber(luaState, -3); *pageFrom = (int) lua_tonumber(luaState, -2); *pageTo = (int) lua_tonumber(luaState, -1); lua_settop(luaState, nOldTop); } else { *minPage = m_minPage; *maxPage = m_maxPage; *pageFrom = m_pageFrom; *pageTo = m_pageTo; } } bool wxLuaPrintout::HasPage(int pageNum) { bool fResult = false; lua_State *luaState = getDerivedMethod(this, "HasPage"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); lua_pushnumber(luaState, pageNum); LuaCall(luaState, 2, false); fResult = (lua_toboolean(luaState, -1) != false); lua_settop(luaState, nOldTop); } else fResult = wxPrintout::HasPage(pageNum); return fResult; } bool wxLuaPrintout::OnBeginDocument(int startPage, int endPage) { bool fResult = true; lua_State *luaState = getDerivedMethod(this, "OnBeginDocument"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); lua_pushnumber(luaState, startPage); lua_pushnumber(luaState, endPage); LuaCall(luaState, 3, false); fResult = (lua_toboolean(luaState, -1) != false); lua_pop(luaState, 1); lua_settop(luaState, nOldTop); } else fResult = wxPrintout::OnBeginDocument(startPage, endPage); return fResult; } void wxLuaPrintout::OnEndDocument() { lua_State *luaState = getDerivedMethod(this, "OnEndDocument"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); LuaCall(luaState, 1, true); lua_settop(luaState, nOldTop); } else wxPrintout::OnEndDocument(); } void wxLuaPrintout::OnBeginPrinting() { lua_State *luaState = getDerivedMethod(this, "OnBeginPrinting"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); LuaCall(luaState, 1, true); lua_settop(luaState, nOldTop); } else wxPrintout::OnBeginPrinting(); } void wxLuaPrintout::OnEndPrinting() { lua_State *luaState = getDerivedMethod(this, "OnEndPrinting"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); LuaCall(luaState, 1, true); lua_settop(luaState, nOldTop); } else wxPrintout::OnEndPrinting(); } void wxLuaPrintout::OnPreparePrinting() { lua_State *luaState = getDerivedMethod(this, "OnPreparePrinting"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); LuaCall(luaState, 1, true); lua_settop(luaState, nOldTop); } else wxPrintout::OnPreparePrinting(); } bool wxLuaPrintout::OnPrintPage(int pageNum) { bool fResult = false; lua_State *luaState = getDerivedMethod(this, "OnPrintPage"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaPrintout); lua_pushnumber(luaState, pageNum); LuaCall(luaState, 2, false); fResult = (lua_toboolean(luaState, -1) != false); lua_settop(luaState, nOldTop); } return fResult; } --- NEW FILE: wxluabind_wx26.dsp --- # Microsoft Developer Studio Project File - Name="wxLuaBindLib_wx26" - Package Owner=<4> # Microsoft Developer Studio Generated Build File, Format Version 6.00 # ** DO NOT EDIT ** # TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 # TARGTYPE "Win32 (x86) Static Library" 0x0104 CFG=wxLuaBindLib_wx26 - Win32 Debug !MESSAGE This is not a valid makefile. To build this project using NMAKE, !MESSAGE use the Export Makefile command and run !MESSAGE !MESSAGE NMAKE /f "wxLuaBindLib_wx26.mak". !MESSAGE !MESSAGE You can specify a configuration when running NMAKE !MESSAGE by defining the macro CFG on the command line. For example: !MESSAGE !MESSAGE NMAKE /f "wxLuaBindLib_wx26.mak" CFG="wxLuaBindLib_wx26 - Win32 Debug" !MESSAGE !MESSAGE Possible choices for configuration are: !MESSAGE !MESSAGE "wxLuaBindLib_wx26 - Win32 Release" (based on "Win32 (x86) Static Library") !MESSAGE "wxLuaBindLib_wx26 - Win32 Debug" (based on "Win32 (x86) Static Library") !MESSAGE # Begin Project # PROP AllowPerConfigDependencies 0 # PROP Scc_ProjName "" # PROP Scc_LocalPath "" CPP=cl.exe RSC=rc.exe !IF "$(CFG)" == "wxLuaBindLib_wx26 - Win32 Release" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 0 # PROP BASE Output_Dir "vc_msw_wx26" # PROP BASE Intermediate_Dir "vc_msw_wx26" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 0 # PROP Output_Dir "vc_msw_wx26" # PROP Intermediate_Dir "vc_msw_wx26" # PROP Target_Dir "" # ADD BASE CPP /nologo /FD /GR /GX /MD /O1 /GR /GX /W4 /Fdvc_msw_wx26\wxluabind_wx26.pdb /D "WIN32" /D "_LIB" /D "__WXMSW__" /D "__WX__" /c # ADD CPP /nologo /FD /GR /GX /MD /O1 /GR /GX /I "$(WXWIN)\include" /I "$(WXWIN)\lib\vc_lib\msw" /I "../../" /I "$(WXWIN)\contrib\include" /W4 /Fdvc_msw_wx26\wxluabind_wx26.pdb /D "WIN32" /D "_LIB" /D "__WXMSW__" /D "__WX__" /c # ADD BASE RSC /l 0x405 # ADD RSC /l 0x405 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo /out:"..\..\..\lib\wxluabind_wx26.lib" # ADD LIB32 /nologo /out:"..\..\..\lib\wxluabind_wx26.lib" !ELSEIF "$(CFG)" == "wxLuaBindLib_wx26 - Win32 Debug" # PROP BASE Use_MFC 0 # PROP BASE Use_Debug_Libraries 1 # PROP BASE Output_Dir "vc_mswd_wx26" # PROP BASE Intermediate_Dir "vc_mswd_wx26" # PROP BASE Target_Dir "" # PROP Use_MFC 0 # PROP Use_Debug_Libraries 1 # PROP Output_Dir "vc_mswd_wx26" # PROP Intermediate_Dir "vc_mswd_wx26" # PROP Target_Dir "" # ADD BASE CPP /nologo /FD /GR /GX /MDd /Od /GR /GX /W4 /Zi /Gm /GZ /Fdvc_mswd_wx26\wxluabindd_wx26.pdb /D "WIN32" /D "_LIB" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "__WX__" /c # ADD CPP /nologo /FD /GR /GX /MDd /Od /GR /GX /I "$(WXWIN)\include" /I "$(WXWIN)\lib\vc_lib\mswd" /I "../../" /I "$(WXWIN)\contrib\include" /W4 /Zi /Gm /GZ /Fdvc_mswd_wx26\wxluabindd_wx26.pdb /D "WIN32" /D "_LIB" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "__WX__" /c # ADD BASE RSC /l 0x405 # ADD RSC /l 0x405 BSC32=bscmake.exe # ADD BASE BSC32 /nologo # ADD BSC32 /nologo LIB32=link.exe -lib # ADD BASE LIB32 /nologo /out:"..\..\..\lib\wxluabindd_wx26.lib" # ADD LIB32 /nologo /out:"..\..\..\lib\wxluabindd_wx26.lib" !ENDIF # Begin Target # Name "wxLuaBindLib_wx26 - Win32 Release" # Name "wxLuaBindLib_wx26 - Win32 Debug" # PROP Default_Filter "" # Begin Source File SOURCE=..\include\wxlprint.h # End Source File # Begin Source File SOURCE=..\include\wxlhtmlwin.h # End Source File # Begin Source File SOURCE=.\wxlprint.cpp # End Source File # Begin Source File SOURCE=.\wxlhtmlwin.cpp # End Source File # Begin Source File SOURCE=..\include\wxbind.h # End Source File # Begin Source File SOURCE=.\appframe.cpp # End Source File # Begin Source File SOURCE=.\clipdrag.cpp # End Source File # Begin Source File SOURCE=.\config.cpp # End Source File # Begin Source File SOURCE=.\controls.cpp # End Source File # Begin Source File SOURCE=.\data.cpp # End Source File # Begin Source File SOURCE=.\datetime.cpp # End Source File # Begin Source File SOURCE=.\defsutil.cpp # End Source File # Begin Source File SOURCE=.\dialogs.cpp # End Source File # Begin Source File SOURCE=.\event.cpp # End Source File # Begin Source File SOURCE=.\file.cpp # End Source File # Begin Source File SOURCE=.\fl.cpp # End Source File # Begin Source File SOURCE=.\gdi.cpp # End Source File # Begin Source File SOURCE=.\geometry.cpp # End Source File # Begin Source File SOURCE=.\grid.cpp # End Source File # Begin Source File SOURCE=.\help.cpp # End Source File # Begin Source File SOURCE=.\html.cpp # End Source File # Begin Source File SOURCE=.\image.cpp # End Source File # Begin Source File SOURCE=.\mdi.cpp # End Source File # Begin Source File SOURCE=.\menutool.cpp # End Source File # Begin Source File SOURCE=.\plot.cpp # End Source File # Begin Source File SOURCE=.\print.cpp # End Source File # Begin Source File SOURCE=.\regex.cpp # End Source File # Begin Source File SOURCE=.\sizer.cpp # End Source File # Begin Source File SOURCE=.\socket.cpp # End Source File # Begin Source File SOURCE=.\stc.cpp # End Source File # Begin Source File SOURCE=.\thread.cpp # End Source File # Begin Source File SOURCE=.\wave.cpp # End Source File # Begin Source File SOURCE=.\windows.cpp # End Source File # Begin Source File SOURCE=.\wx_class.cpp # End Source File # Begin Source File SOURCE=.\wx_define.cpp # End Source File # Begin Source File SOURCE=.\wx_event.cpp # End Source File # Begin Source File SOURCE=.\wx_object.cpp # End Source File # Begin Source File SOURCE=.\wxlua.cpp # End Source File # Begin Source File SOURCE=.\xml.cpp # End Source File # End Target # End Project --- NEW FILE: wxlhtmlwin.cpp --- ///////////////////////////////////////////////////////////////////////////// // Name: wxLuaHtmlWindow.cpp // Purpose: Provide an interface to wxHtmlWindow for wxLua. // Author: J. Winwood. // Created: June 2002. // Copyright: (c) 2002 Lomtick Software. All rights reserved. // Licence: wxWidgets licence ///////////////////////////////////////////////////////////////////////////// #if defined(__GNUG__) && !defined(NO_GCC_PRAGMA) #pragma implementation "wxlhtmlwin.h" #endif #include "wx/wxprec.h" #ifdef __BORLANDC__ #pragma hdrstop #endif #ifndef WX_PRECOMP #include "wx/wx.h" #endif #include "wx/datetime.h" #include "wxbind/include/wxlhtmlwin.h" #include "wxlua/include/callback.h" #include "wxlua/include/internal.h" // These are the wxLua tags defined in wxLuaWrap.cpp extern int s_wxLuaHtmlWindow; extern int s_wxHtmlCell; extern int s_wxMouseEvent; extern int s_wxHtmlLinkInfo; DEFINE_EVENT_TYPE(wxEVT_HTML_TAG_HANDLER) // ---------------------------------------------------------------------------- // wxLuaHtmlWindow // ---------------------------------------------------------------------------- IMPLEMENT_CLASS(wxLuaHtmlWindow, wxHtmlWindow) BEGIN_EVENT_TABLE(wxLuaHtmlWindow, wxHtmlWindow) END_EVENT_TABLE() wxLuaHtmlWindow::wxLuaHtmlWindow() : wxHtmlWindow() { } wxLuaHtmlWindow::~wxLuaHtmlWindow() { } wxLuaHtmlWindow::wxLuaHtmlWindow(wxWindow *parent, wxWindowID id, const wxPoint& pos, const wxSize& size, long style, const wxString& name) : wxHtmlWindow(parent, id, pos, size, style, name) { } void wxLuaHtmlWindow::OnCellClicked(wxHtmlCell *cell, wxCoord x, wxCoord y, const wxMouseEvent& event) { bool fResult = false; lua_State *luaState = getDerivedMethod(this, "OnCellClicked"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaHtmlWindow); tpushusertag(luaState, cell, s_wxHtmlCell); lua_pushnumber(luaState, x); lua_pushnumber(luaState, y); tpushusertag(luaState, (void *) &event, s_wxMouseEvent); LuaCall(luaState, 5, false); fResult = (lua_tonumber(luaState, -1) != 0); lua_settop(luaState, nOldTop); if (fResult) wxHtmlWindow::OnCellClicked(cell, x, y, event); } else wxHtmlWindow::OnCellClicked(cell, x, y, event); } void wxLuaHtmlWindow::OnCellMouseHover(wxHtmlCell *cell, wxCoord x, wxCoord y) { lua_State *luaState = getDerivedMethod(this, "OnCellMouseHover"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaHtmlWindow); tpushusertag(luaState, cell, s_wxHtmlCell); lua_pushnumber(luaState, x); lua_pushnumber(luaState, y); LuaCall(luaState, 4, true); lua_settop(luaState, nOldTop); } else wxHtmlWindow::OnCellMouseHover(cell, x, y); } void wxLuaHtmlWindow::OnLinkClicked(const wxHtmlLinkInfo& link) { lua_State *luaState = getDerivedMethod(this, "OnLinkClicked"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaHtmlWindow); tpushusertag(luaState, (void *) &link, s_wxHtmlLinkInfo); LuaCall(luaState, 2, true); lua_settop(luaState, nOldTop); } else wxHtmlWindow::OnLinkClicked(link); } void wxLuaHtmlWindow::OnSetTitle(const wxString& title) { lua_State *luaState = getDerivedMethod(this, "OnSetTitle"); if (luaState != NULL) { int nOldTop = lua_gettop(luaState); tpushusertag(luaState, this, s_wxLuaHtmlWindow); lua_pushstring(luaState, wx2lua(title)); LuaCall(luaState, 2, true); lua_settop(luaState, nOldTop); } else wxHtmlWindow::OnSetTitle(title); } // ---------------------------------------------------------------------------- // wxLuaHtmlWinTagHandler // ---------------------------------------------------------------------------- class wxLuaHtmlWinTagHandler : public wxHtmlWinTagHandler { public: wxLuaHtmlWinTagHandler() { } wxString GetSupportedTags() { return wxString(wxT("LUA")); } bool HandleTag(const wxHtmlTag& tag) { wxLuaHtmlWinTagEvent htmlEvent(wxEVT_HTML_TAG_HANDLER); htmlEvent.SetTagInfo(&tag, m_WParser); if (wxTheApp->ProcessEvent(htmlEvent)) return htmlEvent.GetParseInnerCalled(); return FALSE; } }; class wxLuaHtmlTagsModule : public wxHtmlTagsModule { DECLARE_DYNAMIC_CLASS(wxLuaHtmlTagsModule) public: void FillHandlersTable(wxHtmlWinParser *parser) { parser->AddTagHandler(new wxLuaHtmlWinTagHandler); } }; IMPLEMENT_DYNAMIC_CLASS(wxLuaHtmlTagsModule, wxHtmlTagsModule) // ---------------------------------------------------------------------------- // wxLuaHtmlWinTagEvent // ---------------------------------------------------------------------------- IMPLEMENT_DYNAMIC_CLASS(wxLuaHtmlWinTagEvent, wxEvent) wxLuaHtmlWinTagEvent::wxLuaHtmlWinTagEvent() : m_pHtmlTag(NULL), m_pHtmlParser(NULL), m_fParseInnerCalled(false) { } wxLuaHtmlWinTagEvent::wxLuaHtmlWinTagEvent(int eventType) : m_pHtmlTag(NULL), m_pHtmlParser(NULL), m_fParseInnerCalled(false) { SetEventType(eventType); } wxLuaHtmlWinTagEvent::~wxLuaHtmlWinTagEvent() { } void wxLuaHtmlWinTagEvent::SetTagInfo(const wxHtmlTag *pHtmlTag, wxHtmlWinParser *pParser) { m_pHtmlTag = pHtmlTag; m_pHtmlParser = pParser; } wxEvent* wxLuaHtmlWinTagEvent::Clone() const { wxLuaHtmlWinTagEvent *pEvent = new wxLuaHtmlWinTagEvent(GetEventType()); if (pEvent != NULL) { pEvent->m_pHtmlTag = m_pHtmlTag; pEvent->m_pHtmlParser = m_pHtmlParser; pEvent->m_fParseInnerCalled = m_fParseInnerCalled; } return pEvent; } const wxHtmlTag *wxLuaHtmlWinTagEvent::GetHtmlTag() const { return m_pHtmlTag; } wxHtmlWinParser *wxLuaHtmlWinTagEvent::GetHtmlParser() const { return m_pHtmlParser; } bool wxLuaHtmlWinTagEvent::GetParseInnerCalled() const { return m_fParseInnerCalled; } void wxLuaHtmlWinTagEvent::SetParseInnerCalled(bool fParseInnerCalled) { m_fParseInnerCalled = fParseInnerCalled; } |