From: John L. <jr...@us...> - 2006-09-20 04:07:42
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv10976/wxLua/samples Modified Files: calculator.wx.lua choices.wx.lua coroutine.wx.lua dialog.wx.lua editor.wx.lua fldemo.wx.lua grid.wx.lua htmlwin.wx.lua mdi.wx.lua minimal.wx.lua printing.wx.lua scribble.wx.lua tree.wx.lua wxluasudoku.wx.lua Log Message: add wxVERSION and WXLUA_XXX_VERSION bindings and use them in the About dialog for the samples Cleanup samples for readability Index: mdi.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/mdi.wx.lua,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** mdi.wx.lua 25 May 2006 03:55:23 -0000 1.9 --- mdi.wx.lua 20 Sep 2006 04:07:38 -0000 1.10 *************** *** 34,76 **** end - function main() ! frame = wx.wxMDIParentFrame( wx.wxNull, wx.wxID_ANY, "wxLua MDI Demo", ! wx.wxDefaultPosition, wx.wxSize(450, 450), ! wx.wxDEFAULT_FRAME_STYLE ) ! local fileMenu = wx.wxMenu() ! fileMenu:Append(wx.wxID_NEW, "&New", "Create a new child window") ! fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program") ! local helpMenu = wx.wxMenu() ! helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua MDI Application") ! local menuBar = wx.wxMenuBar() ! menuBar:Append(fileMenu, "&File") ! menuBar:Append(helpMenu, "&Help") ! frame:SetMenuBar(menuBar) ! frame:CreateStatusBar(1) ! frame:SetStatusText("Welcome to wxLua.") ! frame:Connect(wx.wxID_NEW, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) CreateChild() end ) ! frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) frame:Close() end ) ! frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! wx.wxMessageBox('This is the "About" dialog of the MDI wxLua sample.', ! "About wxLua", ! wx.wxOK + wx.wxICON_INFORMATION, ! frame ) ! end ) ! frame:Show(true) ! end - main() --- 34,74 ---- end ! frame = wx.wxMDIParentFrame( wx.wxNull, wx.wxID_ANY, "wxLua MDI Demo", ! wx.wxDefaultPosition, wx.wxSize(450, 450), ! wx.wxDEFAULT_FRAME_STYLE ) ! local fileMenu = wx.wxMenu() ! fileMenu:Append(wx.wxID_NEW, "&New", "Create a new child window") ! fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program") ! local helpMenu = wx.wxMenu() ! helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua MDI Application") ! local menuBar = wx.wxMenuBar() ! menuBar:Append(fileMenu, "&File") ! menuBar:Append(helpMenu, "&Help") ! frame:SetMenuBar(menuBar) ! frame:CreateStatusBar(1) ! frame:SetStatusText("Welcome to wxLua.") ! frame:Connect(wx.wxID_NEW, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) CreateChild() end ) ! frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) frame:Close() end ) ! frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! wx.wxMessageBox('This is the "About" dialog of the MDI wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, ! "About wxLua", ! wx.wxOK + wx.wxICON_INFORMATION, ! frame ) ! end ) ! frame:Show(true) Index: fldemo.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/fldemo.wx.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** fldemo.wx.lua 25 May 2006 03:55:23 -0000 1.4 --- fldemo.wx.lua 20 Sep 2006 04:07:38 -0000 1.5 *************** *** 9,12 **** --- 9,20 ---- ----------------------------------------------------------------------------- + -- --------------------------------------------------------------------------- + -- THIS SAMPLE DOES NOT WORK! + -- + -- NOTE: The FL library is a docking library contrib for wxWidgets, however + -- it is no longer maintained and is not currently wrapped by wxLua. + -- --------------------------------------------------------------------------- + + frame = nil *************** *** 126,130 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox( 'This is the "About" dialog of the FL Demo wxLua sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, --- 134,139 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox( 'This is the "About" dialog of the FL Demo wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, Index: choices.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/choices.wx.lua,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** choices.wx.lua 25 May 2006 03:55:23 -0000 1.8 --- choices.wx.lua 20 Sep 2006 04:07:38 -0000 1.9 *************** *** 11,17 **** function HandleEvents(event) ! -- Note: event.GetEventObject() return a wxObject, but we know that all ! -- events sent to this function will be from wxWindow deriveds ! -- classes, whose base class is a wxObject. -- Use DynamicCast to call functions from the wxWindow base class. local name = event:GetEventObject():DynamicCast("wxWindow"):GetName() --- 11,17 ---- function HandleEvents(event) ! -- Note: event.GetEventObject() returns a wxObject, but we know that all ! -- events sent to this function will be from wxWindow derived ! -- class, whose base class is a wxObject. -- Use DynamicCast to call functions from the wxWindow base class. local name = event:GetEventObject():DynamicCast("wxWindow"):GetName() *************** *** 24,28 **** wx.wxPoint(20, 20), wx.wxSize(450, 350)) frame:CreateStatusBar(1) ! frame:SetStatusText("wxEvents from contols will be displayed here", 0) local notebook = wx.wxNotebook(frame, wx.wxID_ANY, --- 24,28 ---- wx.wxPoint(20, 20), wx.wxSize(450, 350)) frame:CreateStatusBar(1) ! frame:SetStatusText("wxEvents from controls will be displayed here", 0) local notebook = wx.wxNotebook(frame, wx.wxID_ANY, *************** *** 83,86 **** --- 83,88 ---- notebook:GetBestSize():GetHeight()) + -- typically you will give a control a specific window id and connect an + -- event handler for that id, in this case respond to any id frame:Connect(wx.wxID_ANY, wx.wxEVT_COMMAND_NOTEBOOK_PAGE_CHANGED, HandleEvents) Index: minimal.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/minimal.wx.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** minimal.wx.lua 25 May 2006 03:55:23 -0000 1.6 --- minimal.wx.lua 20 Sep 2006 04:07:38 -0000 1.7 *************** *** 73,77 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Minimal wxLua sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, --- 73,78 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Minimal wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, Index: wxluasudoku.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/wxluasudoku.wx.lua,v retrieving revision 1.55 retrieving revision 1.56 diff -C2 -d -r1.55 -r1.56 *** wxluasudoku.wx.lua 6 Jun 2006 05:14:32 -0000 1.55 --- wxluasudoku.wx.lua 20 Sep 2006 04:07:38 -0000 1.56 *************** *** 4733,4737 **** sudokuGUI.MenuId[sudokuGUI.ID_ABOUT] = function (event) ! wx.wxMessageBox("Welcome to wxLuaSudoku!\nWritten by John Labenski\nCopyright 2006.", "About wxLuaSudoku", wx.wxOK + wx.wxICON_INFORMATION, --- 4733,4738 ---- sudokuGUI.MenuId[sudokuGUI.ID_ABOUT] = function (event) ! wx.wxMessageBox("Welcome to wxLuaSudoku!\nWritten by John Labenski\nCopyright 2006.\n".. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLuaSudoku", wx.wxOK + wx.wxICON_INFORMATION, Index: tree.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/tree.wx.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** tree.wx.lua 25 May 2006 03:55:23 -0000 1.6 --- tree.wx.lua 20 Sep 2006 04:07:38 -0000 1.7 *************** *** 45,49 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the wxLua wxTreeCtrl sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, --- 45,50 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the wxLua wxTreeCtrl sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, Index: htmlwin.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/htmlwin.wx.lua,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** htmlwin.wx.lua 25 May 2006 03:55:23 -0000 1.9 --- htmlwin.wx.lua 20 Sep 2006 04:07:38 -0000 1.10 *************** *** 14,18 **** [[<html> <head> ! <title>Bound Widget demonstration</title> </head> <body> --- 14,18 ---- [[<html> <head> ! <title>wxLua Bound Widget demonstration</title> </head> <body> *************** *** 33,118 **** </html>]] - function main() - - -- create the frame window - frame = wx.wxFrame( wx.wxNull, wx.wxID_ANY, "wxLua HtmlWindow Demo", - wx.wxDefaultPosition, wx.wxSize(450, 450), - wx.wxDEFAULT_FRAME_STYLE ) - - - -- create a simple file menu - local fileMenu = wx.wxMenu() - fileMenu:Append(wx.wxID_PREVIEW, "Print Pre&view", "Preview the HTML document") - fileMenu:Append(wx.wxID_PRINT, "&Print", "Print the HTML document") - fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program") - - -- create a simple help menu - local helpMenu = wx.wxMenu() - helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua wxHtmlWindow sample") - - -- create a menu bar and append the file and help menus - local menuBar = wx.wxMenuBar() - menuBar:Append(fileMenu, "&File") - menuBar:Append(helpMenu, "&Help") - - -- insert the menu bar into the frame - frame.MenuBar = menuBar - - -- create a simple status bar - frame:CreateStatusBar(2) - frame:SetStatusText("Welcome to wxLua.") - - frame:Connect(wx.wxID_PREVIEW, wx.wxEVT_COMMAND_MENU_SELECTED, - function (event) - local printing = wx.wxHtmlEasyPrinting("HtmlWindow.wx.lua", frame) - printing:PreviewText(htmlTextPage) - end ) - - frame:Connect(wx.wxID_PRINT, wx.wxEVT_COMMAND_MENU_SELECTED, - function (event) - local printing = wx.wxHtmlEasyPrinting("HtmlWindow.wx.lua", frame) - printing:PrintText(htmlTextPage) - end ) - - -- connect the selection event of the exit menu item to an - -- event handler that closes the window - frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, - function (event) - frame:Close(true) - end ) - - -- connect the selection event of the about menu item - frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, - function (event) - wx.wxMessageBox('This is the "About" dialog of the wxHtmlWindow wxLua sample.', - "About wxLua", - wx.wxOK + wx.wxICON_INFORMATION, - frame ) - end) - - -- create the html window - html = wx.wxLuaHtmlWindow(frame) - - html.OnSetTitle = function(self, title) - frame.Title = frame.Title.." - "..title - end - - -- when a lua custom tag is parsed in the html, this event handler - -- will be invoked - wx.wxGetApp():Connect(wx.wxID_ANY, wx.wxEVT_HTML_TAG_HANDLER, - function (event) CreateBoundWindow(event) end) - - -- set the frame window and status bar - html:SetRelatedFrame(frame, "wxHtmlWindow wxLua Sample : %s") - html:SetRelatedStatusBar(1) - -- load the document - html:SetPage(htmlTextPage) - -- html:LoadPage("testpage.html") - - -- show the frame window - wx.wxGetApp().TopWindow = frame - frame:Show(true) - end - function CreateBoundWindow(event) local ax, ay --- 33,36 ---- *************** *** 129,133 **** -- create the control to embed ! local parent = event.HtmlParser.Window if parent then local wnd = wx.wxTextCtrl( parent, wx.wxID_ANY, --- 47,57 ---- -- create the control to embed ! local parent = nil ! if wx.wxCHECK_VERSION(2,7,0) then ! parent = event:GetHtmlParser():GetWindowInterface():GetHTMLWindow() ! else ! parent = event.HtmlParser.Window ! end ! if parent then local wnd = wx.wxTextCtrl( parent, wx.wxID_ANY, *************** *** 147,150 **** end ! main() --- 71,154 ---- end ! ! -- create the frame window ! frame = wx.wxFrame( wx.wxNull, wx.wxID_ANY, "wxLua HtmlWindow Demo", ! wx.wxDefaultPosition, wx.wxSize(450, 450), ! wx.wxDEFAULT_FRAME_STYLE ) ! ! ! -- create a simple file menu ! local fileMenu = wx.wxMenu() ! fileMenu:Append(wx.wxID_PREVIEW, "Print Pre&view", "Preview the HTML document") ! fileMenu:Append(wx.wxID_PRINT, "&Print", "Print the HTML document") ! fileMenu:Append(wx.wxID_EXIT, "E&xit", "Quit the program") ! ! -- create a simple help menu ! local helpMenu = wx.wxMenu() ! helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua wxHtmlWindow sample") ! ! -- create a menu bar and append the file and help menus ! local menuBar = wx.wxMenuBar() ! menuBar:Append(fileMenu, "&File") ! menuBar:Append(helpMenu, "&Help") ! ! -- insert the menu bar into the frame ! frame.MenuBar = menuBar ! ! -- create a simple status bar ! frame:CreateStatusBar(2) ! frame:SetStatusText("Welcome to wxLua.") ! ! frame:Connect(wx.wxID_PREVIEW, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! local printing = wx.wxHtmlEasyPrinting("HtmlWindow.wx.lua", frame) ! printing:PreviewText(htmlTextPage) ! end ) ! ! frame:Connect(wx.wxID_PRINT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! local printing = wx.wxHtmlEasyPrinting("HtmlWindow.wx.lua", frame) ! printing:PrintText(htmlTextPage) ! end ) ! ! -- connect the selection event of the exit menu item to an ! -- event handler that closes the window ! frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! frame:Close(true) ! end ) ! ! -- connect the selection event of the about menu item ! frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! wx.wxMessageBox('This is the "About" dialog of the wxHtmlWindow wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, ! "About wxLua", ! wx.wxOK + wx.wxICON_INFORMATION, ! frame ) ! end) ! ! -- create the html window ! html = wx.wxLuaHtmlWindow(frame) ! ! html.OnSetTitle = function(self, title) ! frame.Title = frame.Title.." - "..title ! end ! ! -- when a lua custom tag is parsed in the html, this event handler ! -- will be invoked ! wx.wxGetApp():Connect(wx.wxID_ANY, wx.wxEVT_HTML_TAG_HANDLER, ! function (event) CreateBoundWindow(event) end) ! ! -- set the frame window and status bar ! html:SetRelatedFrame(frame, "wxHtmlWindow wxLua Sample : %s") ! html:SetRelatedStatusBar(1) ! -- load the document ! html:SetPage(htmlTextPage) ! -- html:LoadPage("testpage.html") ! ! -- show the frame window ! wx.wxGetApp().TopWindow = frame ! frame:Show(true) ! Index: dialog.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/dialog.wx.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** dialog.wx.lua 25 May 2006 03:55:23 -0000 1.6 --- dialog.wx.lua 20 Sep 2006 04:07:38 -0000 1.7 *************** *** 61,66 **** dialog:Connect(ID_CELSIUS_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) ! local celsiusString = celsiusTextCtrl:GetValue() ! if celsiusString == "" then wx.wxMessageBox("The Celsius entry is invalid, enter a number.", "Error!", --- 61,66 ---- dialog:Connect(ID_CELSIUS_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) ! local celsiusValue = tonumber(celsiusTextCtrl:GetValue()) ! if celsiusValue == nil then wx.wxMessageBox("The Celsius entry is invalid, enter a number.", "Error!", *************** *** 68,72 **** dialog) else ! local fahrenheitValue = (tonumber(celsiusString) * 9 / 5) + 32 fahrenheitTextCtrl:SetValue(fahrenheitValue) end --- 68,72 ---- dialog) else ! local fahrenheitValue = (celsiusValue * 9 / 5) + 32 fahrenheitTextCtrl:SetValue(fahrenheitValue) end *************** *** 76,81 **** dialog:Connect(ID_FAHRENHEIT_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) ! local fahrenheitString = fahrenheitTextCtrl:GetValue() ! if fahrenheitString == "" then wx.wxMessageBox("The Fahrenheit entry is invalid, enter a number.", "Error!", --- 76,81 ---- dialog:Connect(ID_FAHRENHEIT_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) ! local fahrenheitValue = tonumber(fahrenheitTextCtrl:GetValue()) ! if fahrenheitValue == nil then wx.wxMessageBox("The Fahrenheit entry is invalid, enter a number.", "Error!", *************** *** 83,87 **** dialog) else ! local celsiusValue = (tonumber(fahrenheitString) - 32) * 5 / 9 celsiusTextCtrl:SetValue(celsiusValue) end --- 83,87 ---- dialog) else ! local celsiusValue = (fahrenheitValue - 32) * 5 / 9 celsiusTextCtrl:SetValue(celsiusValue) end *************** *** 101,106 **** dialog:Connect(ID_ABOUT_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) ! wx.wxMessageBox("Based on the C++ version by Marco Ghislanzoni", ! "Temperature converter", wx.wxOK + wx.wxICON_INFORMATION, dialog) --- 101,107 ---- dialog:Connect(ID_ABOUT_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) ! wx.wxMessageBox("Based on the C++ version by Marco Ghislanzoni.\n".. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, ! "About wxLua Temperature Converter", wx.wxOK + wx.wxICON_INFORMATION, dialog) Index: editor.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/editor.wx.lua,v retrieving revision 1.21 retrieving revision 1.22 diff -C2 -d -r1.21 -r1.22 *** editor.wx.lua 19 Sep 2006 05:01:45 -0000 1.21 --- editor.wx.lua 20 Sep 2006 04:07:38 -0000 1.22 *************** *** 1884,1888 **** <center> <font size = +2 color = "#FFFFFF"> ! <b><br>wxLua Version 2.7<br></b> </font> </center> --- 1884,1890 ---- <center> <font size = +2 color = "#FFFFFF"> ! <b><br>]].. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING.. ! [[<br></b> </font> </center> Index: grid.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/grid.wx.lua,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** grid.wx.lua 25 May 2006 03:55:23 -0000 1.6 --- grid.wx.lua 20 Sep 2006 04:07:38 -0000 1.7 *************** *** 8,58 **** ----------------------------------------------------------------------------- - function main() ! local frame = wx.wxFrame(wx.wxNull, wx.wxID_ANY, "wxLua wxGrid Sample", ! wx.wxPoint(25, 25), wx.wxSize(350, 250)) ! local fileMenu = wx.wxMenu("", wxMENU_TEAROFF) ! fileMenu:Append(wx.wxID_EXIT, "E&xit\tCtrl-X", "Quit the program") ! local helpMenu = wx.wxMenu("", wxMENU_TEAROFF) ! helpMenu:Append(wx.wxID_ABOUT, "&About\tCtrl-A", "About the Grid wxLua Application") ! local menuBar = wx.wxMenuBar() ! menuBar:Append(fileMenu, "&File") ! menuBar:Append(helpMenu, "&Help") ! frame:SetMenuBar(menuBar) ! frame:CreateStatusBar(1) ! frame:SetStatusText("Welcome to wxLua.") ! frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! frame:Close() ! end ) ! frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! wx.wxMessageBox('This is the "About" dialog of the Grid wxLua sample.', ! "About wxLua", ! wx.wxOK + wx.wxICON_INFORMATION, ! frame ) ! end ) ! local grid = wx.wxGrid(frame, wx.wxID_ANY) ! grid:CreateGrid(10, 8) ! grid:SetColSize(3, 200) ! grid:SetRowSize(4, 45) ! grid:SetCellValue(0, 0, "First cell") ! grid:SetCellValue(1, 1, "Another cell") ! grid:SetCellValue(2, 2, "Yet another cell") ! grid:SetCellFont(0, 0, wx.wxFont(10, wx.wxROMAN, wx.wxITALIC, wx.wxNORMAL)) ! grid:SetCellTextColour(1, 1, wx.wxRED) ! grid:SetCellBackgroundColour(2, 2, wx.wxCYAN) ! frame:Show(true) ! end - main() --- 8,56 ---- ----------------------------------------------------------------------------- ! local frame = wx.wxFrame(wx.wxNull, wx.wxID_ANY, "wxLua wxGrid Sample", ! wx.wxPoint(25, 25), wx.wxSize(350, 250)) ! local fileMenu = wx.wxMenu("", wxMENU_TEAROFF) ! fileMenu:Append(wx.wxID_EXIT, "E&xit\tCtrl-X", "Quit the program") ! local helpMenu = wx.wxMenu("", wxMENU_TEAROFF) ! helpMenu:Append(wx.wxID_ABOUT, "&About\tCtrl-A", "About the Grid wxLua Application") ! local menuBar = wx.wxMenuBar() ! menuBar:Append(fileMenu, "&File") ! menuBar:Append(helpMenu, "&Help") ! frame:SetMenuBar(menuBar) ! frame:CreateStatusBar(1) ! frame:SetStatusText("Welcome to wxLua.") ! frame:Connect(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! frame:Close() ! end ) ! frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, ! function (event) ! wx.wxMessageBox('This is the "About" dialog of the wxGrid wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, ! "About wxLua", ! wx.wxOK + wx.wxICON_INFORMATION, ! frame ) ! end ) ! grid = wx.wxGrid(frame, wx.wxID_ANY) ! grid:CreateGrid(10, 8) ! grid:SetColSize(3, 200) ! grid:SetRowSize(4, 45) ! grid:SetCellValue(0, 0, "First cell") ! grid:SetCellValue(1, 1, "Another cell") ! grid:SetCellValue(2, 2, "Yet another cell") ! grid:SetCellFont(0, 0, wx.wxFont(10, wx.wxROMAN, wx.wxITALIC, wx.wxNORMAL)) ! grid:SetCellTextColour(1, 1, wx.wxRED) ! grid:SetCellBackgroundColour(2, 2, wx.wxCYAN) ! frame:Show(true) Index: coroutine.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/coroutine.wx.lua,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** coroutine.wx.lua 6 Jun 2006 21:03:54 -0000 1.2 --- coroutine.wx.lua 20 Sep 2006 04:07:38 -0000 1.3 *************** *** 20,24 **** } - -- The constructor. 'parent' is the parent window. 'workCoroutine' is the -- coroutine used to process whatever is desired. 'caption' is the caption to be --- 20,23 ---- *************** *** 28,31 **** --- 27,31 ---- -- simple little sanity test to ensure that we can call binding functions + -- it will fail on r:SetX if wx bindings aren't set for the coroutine local r = wx.wxRect(1,2,3,4) r:SetX(1) *************** *** 54,69 **** -- Handle idle events: run the coroutine's next "step" o.dialog:Connect (wx.wxEVT_IDLE, ! function (event) ! if coroutine.status (workCoroutine) ~= "dead" then ! local s, msg = coroutine.resume (workCoroutine) ! if not msg then ! o.dialog:Close() ! else ! o:setStatus (msg) ! end ! event:RequestMore() ! event:Skip() ! end ! end) -- Voilà --- 54,69 ---- -- Handle idle events: run the coroutine's next "step" o.dialog:Connect (wx.wxEVT_IDLE, ! function (event) ! if coroutine.status (workCoroutine) ~= "dead" then ! local s, msg = coroutine.resume (workCoroutine) ! if not msg then ! o.dialog:Close() ! else ! o:setStatus (msg) ! end ! event:RequestMore() ! event:Skip() ! end ! end) -- Voilà *************** *** 113,117 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Coroutine wxLua sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, --- 113,118 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Coroutine wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, *************** *** 125,146 **** frame:Connect (ID_THE_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, ! function (event) ! local function workFunc() ! for i = 1, 10 do ! coroutine.yield ("Performing step "..tostring(i).."/10") ! wx.wxSleep(1) ! end end ! local workCoroutine = coroutine.create (workFunc) ! local wndProgress = ! ProgressWindow:new (frame, workCoroutine, ! "Performing some long operation", ! "Performing step 1/many") ! wndProgress.dialog:ShowModal (true) ! wndProgress.dialog:Destroy() ! end) --- 126,147 ---- frame:Connect (ID_THE_BUTTON, wx.wxEVT_COMMAND_BUTTON_CLICKED, ! function (event) ! local function workFunc() ! for i = 1, 10 do ! coroutine.yield ("Performing step "..tostring(i).."/10") ! wx.wxSleep(1) end + end ! local workCoroutine = coroutine.create (workFunc) ! local wndProgress = ! ProgressWindow:new (frame, workCoroutine, ! "Performing some long operation", ! "Performing step 1/many") ! wndProgress.dialog:ShowModal (true) ! wndProgress.dialog:Destroy() ! end) Index: printing.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/printing.wx.lua,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** printing.wx.lua 25 May 2006 03:55:23 -0000 1.10 --- printing.wx.lua 20 Sep 2006 04:07:38 -0000 1.11 *************** *** 276,280 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Printing wxLua sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, --- 276,281 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Printing wxLua sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, Index: scribble.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/scribble.wx.lua,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** scribble.wx.lua 25 May 2006 03:55:23 -0000 1.9 --- scribble.wx.lua 20 Sep 2006 04:07:38 -0000 1.10 *************** *** 316,320 **** frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Scribble wxLua Sample.', "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, --- 316,321 ---- frame:Connect(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) ! wx.wxMessageBox('This is the "About" dialog of the Scribble wxLua Sample.\n'.. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, "About wxLua", wx.wxOK + wx.wxICON_INFORMATION, Index: calculator.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/calculator.wx.lua,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** calculator.wx.lua 25 May 2006 03:55:23 -0000 1.5 --- calculator.wx.lua 20 Sep 2006 04:07:38 -0000 1.6 *************** *** 10,16 **** -------------------------------------------------------------------------=--- ! dialog = nil ! res = nil ! txtDisplay = nil local xpmdata = --- 10,21 ---- -------------------------------------------------------------------------=--- ! -- --------------------------------------------------------------------------- ! -- Global variables ! dialog = nil -- the wxDialog main toplevel window ! xmlResource = nil -- the XML resource handle ! txtDisplay = nil -- statictext window for the display ! clearDisplay = nil ! lastNumber = 0 -- the last number pressed, 0 - 9 ! lastOperationId = nil -- the window id of last operation button pressed local xpmdata = *************** *** 39,42 **** --- 44,48 ---- } + -- --------------------------------------------------------------------------- -- This is a little awkward, but it's how it's done in C++ too bitmap = wx.wxBitmapFromXPMData(xpmdata) *************** *** 44,50 **** icon:CopyFromBitmap(bitmap) -- return the path part of the currently executing file ! local strAt = string.byte('@') ! function getPath() function findLast(filePath) --- 50,56 ---- icon:CopyFromBitmap(bitmap) + -- --------------------------------------------------------------------------- -- return the path part of the currently executing file ! function GetPath() function findLast(filePath) *************** *** 69,73 **** local filePath = debug.getinfo(1, "S").source ! if string.byte(filePath) == strAt then local offset = findLast(filePath) if offset ~= nil then --- 75,79 ---- local filePath = debug.getinfo(1, "S").source ! if string.byte(filePath) == string.byte('@') then local offset = findLast(filePath) if offset ~= nil then *************** *** 83,99 **** end -- Handle the clear button event function OnClear(event) txtDisplay:SetLabel("0") ! lastNumber = 0 ! lastOperation = ID_PLUS end -- Handle all number button events function OnNumber(event) ! local number = event:GetId() local displayString = txtDisplay:GetLabel() ! if displayString == "0" or clearDisplay then displayString = "" end --- 89,107 ---- end + -- --------------------------------------------------------------------------- -- Handle the clear button event function OnClear(event) txtDisplay:SetLabel("0") ! lastNumber = 0 ! lastOperationId = ID_PLUS end + -- --------------------------------------------------------------------------- -- Handle all number button events function OnNumber(event) ! local numberId = event:GetId() local displayString = txtDisplay:GetLabel() ! if (displayString == "0") or (tonumber(displayString) == nil) or clearDisplay then displayString = "" end *************** *** 102,106 **** -- Limit string length to 12 chars if string.len(displayString) < 12 then ! if number == ID_DECIMAL then -- If the first pressed char is "." then we want "0." if string.len(displayString) == 0 then --- 110,114 ---- -- Limit string length to 12 chars if string.len(displayString) < 12 then ! if numberId == ID_DECIMAL then -- If the first pressed char is "." then we want "0." if string.len(displayString) == 0 then *************** *** 110,125 **** end else ! local num = 0 ! if number == ID_0 then num = 0 ! elseif number == ID_1 then num = 1 ! elseif number == ID_2 then num = 2 ! elseif number == ID_3 then num = 3 ! elseif number == ID_4 then num = 4 ! elseif number == ID_5 then num = 5 ! elseif number == ID_6 then num = 6 ! elseif number == ID_7 then num = 7 ! elseif number == ID_8 then num = 8 ! elseif number == ID_9 then num = 9 ! end -- If first character entered is 0 we reject it --- 118,126 ---- end else ! local idTable = { [ID_0] = 0, [ID_1] = 1, [ID_2] = 2, [ID_3] = 3, ! [ID_4] = 4, [ID_5] = 5, [ID_6] = 6, [ID_7] = 7, ! [ID_8] = 8, [ID_9] = 9 } ! ! local num = idTable[numberId] -- If first character entered is 0 we reject it *************** *** 133,152 **** end ! txtDisplay:SetLabel(displayString) end end -- Calculate the operation ! function DoOperation(a, b, operation) local result = a ! if operation == ID_PLUS then result = b + a ! elseif operation == ID_MINUS then result = b - a ! elseif operation == ID_MULTIPLY then result = b * a ! elseif operation == ID_DIVIDE then if a == 0 then ! result = "Error" else result = b / a --- 134,154 ---- end ! txtDisplay:SetLabel(tostring(displayString)) end end + -- --------------------------------------------------------------------------- -- Calculate the operation ! function DoOperation(a, b, operationId) local result = a ! if operationId == ID_PLUS then result = b + a ! elseif operationId == ID_MINUS then result = b - a ! elseif operationId == ID_MULTIPLY then result = b * a ! elseif operationId == ID_DIVIDE then if a == 0 then ! result = "Divide by zero error" else result = b / a *************** *** 156,182 **** end -- Handle all operation button events function OnOperator(event) -- Get display content ! local displayString = txtDisplay:GetLabel() ! local currentOperation = tonumber(displayString) ! -- Get the required lastOperation ! local operation = event:GetId() ! displayString = DoOperation(currentOperation, lastNumber, lastOperation) lastNumber = tonumber(displayString) ! if (lastOperation ~= ID_EQUALS) or (operation == ID_EQUALS) then txtDisplay:SetLabel(displayString) end clearDisplay = 1 ! lastOperation = operation end function OnQuit(event) event:Skip() ! wx.wxMessageBox("wxLua calculator sample based on the calc sample written by Marco Ghislanzoni", ! "Calculator", wx.wxOK + wx.wxICON_INFORMATION, dialog) --- 158,194 ---- end + -- --------------------------------------------------------------------------- -- Handle all operation button events function OnOperator(event) -- Get display content ! local displayString = txtDisplay:GetLabel() ! local currentNumber = tonumber(displayString) ! -- if error message was shown, zero output and ignore operator ! if ((currentNumber == nil) or (lastNumber == nil)) then ! lastNumber = 0 ! return ! end ! -- Get the required lastOperationId ! local operationId = event:GetId() ! ! displayString = DoOperation(currentNumber, lastNumber, lastOperationId) lastNumber = tonumber(displayString) ! if (lastOperationId ~= ID_EQUALS) or (operationId == ID_EQUALS) then txtDisplay:SetLabel(displayString) end clearDisplay = 1 ! lastOperationId = operationId end + -- --------------------------------------------------------------------------- + -- Handle the quit button event function OnQuit(event) event:Skip() ! wx.wxMessageBox("wxLua calculator sample based on the calc sample written by Marco Ghislanzoni.\n".. ! wx.WXLUA_VERSION_STRING.." built with "..wx.wxVERSION_STRING, ! "wxLua Calculator", wx.wxOK + wx.wxICON_INFORMATION, dialog) *************** *** 185,195 **** end ! function main() -- xml style resources (if present) ! res = wx.wxXmlResourceGetDefault() ! res:InitAllHandlers() ! local xrcFilename = getPath().."/calculator.xrc" ! while not res:Load(xrcFilename) do wx.wxMessageBox("Error loading xrc resources, please choose the path to 'calculator.xrc'.", "Calculator", --- 197,210 ---- end ! -- --------------------------------------------------------------------------- ! -- The main program as a function (makes it easy to exit on error) function main() -- xml style resources (if present) ! xmlResource = wx.wxXmlResourceGetDefault() ! xmlResource:InitAllHandlers() ! local xrcFilename = GetPath().."/calculator.xrc" ! ! -- try to load the resource and ask for path to it if not found ! while not xmlResource:Load(xrcFilename) do wx.wxMessageBox("Error loading xrc resources, please choose the path to 'calculator.xrc'.", "Calculator", *************** *** 211,215 **** dialog = wx.wxEmptyDialog() ! if not res:LoadDialogCreate(dialog, wx.wxNull, "Calculator") then wx.wxMessageBox("Error loading xrc resources!", "Calculator", --- 226,230 ---- dialog = wx.wxEmptyDialog() ! if not xmlResource:LoadDialogCreate(dialog, wx.wxNull, "Calculator") then wx.wxMessageBox("Error loading xrc resources!", "Calculator", *************** *** 226,230 **** -- initialize the txtDisplay and verify that it's ok ! txtDisplay = dialog:FindWindow(res:GetXRCID("ID_TEXT")) if not txtDisplay then wx.wxError([[Unable to find window "ID_TEXT" in the dialog]]) --- 241,245 ---- -- initialize the txtDisplay and verify that it's ok ! txtDisplay = dialog:FindWindow(xmlResource:GetXRCID("ID_TEXT")) if not txtDisplay then wx.wxError([[Unable to find window "ID_TEXT" in the dialog]]) *************** *** 235,261 **** txtDisplay:SetLabel("0") ! -- init wxWindow ID values ! ID_0 = res:GetXRCID("ID_0") ! ID_1 = res:GetXRCID("ID_1") ! ID_2 = res:GetXRCID("ID_2") ! ID_3 = res:GetXRCID("ID_3") ! ID_4 = res:GetXRCID("ID_4") ! ID_5 = res:GetXRCID("ID_5") ! ID_6 = res:GetXRCID("ID_6") ! ID_7 = res:GetXRCID("ID_7") ! ID_8 = res:GetXRCID("ID_8") ! ID_9 = res:GetXRCID("ID_9") ! ID_DECIMAL = res:GetXRCID("ID_DECIMAL") ! ID_EQUALS = res:GetXRCID("ID_EQUALS") ! ID_PLUS = res:GetXRCID("ID_PLUS") ! ID_MINUS = res:GetXRCID("ID_MINUS") ! ID_MULTIPLY = res:GetXRCID("ID_MULTIPLY") ! ID_DIVIDE = res:GetXRCID("ID_DIVIDE") ! ID_OFF = res:GetXRCID("ID_OFF") ! ID_CLEAR = res:GetXRCID("ID_CLEAR") ! lastNumber = 0 ! lastOperation = ID_PLUS ! clearDisplay = nil dialog:Connect(ID_0, wx.wxEVT_COMMAND_BUTTON_CLICKED, OnNumber) --- 250,274 ---- txtDisplay:SetLabel("0") ! -- init global wxWindow ID values ! ID_0 = xmlResource:GetXRCID("ID_0") ! ID_1 = xmlResource:GetXRCID("ID_1") ! ID_2 = xmlResource:GetXRCID("ID_2") ! ID_3 = xmlResource:GetXRCID("ID_3") ! ID_4 = xmlResource:GetXRCID("ID_4") ! ID_5 = xmlResource:GetXRCID("ID_5") ! ID_6 = xmlResource:GetXRCID("ID_6") ! ID_7 = xmlResource:GetXRCID("ID_7") ! ID_8 = xmlResource:GetXRCID("ID_8") ! ID_9 = xmlResource:GetXRCID("ID_9") ! ID_DECIMAL = xmlResource:GetXRCID("ID_DECIMAL") ! ID_EQUALS = xmlResource:GetXRCID("ID_EQUALS") ! ID_PLUS = xmlResource:GetXRCID("ID_PLUS") ! ID_MINUS = xmlResource:GetXRCID("ID_MINUS") ! ID_MULTIPLY = xmlResource:GetXRCID("ID_MULTIPLY") ! ID_DIVIDE = xmlResource:GetXRCID("ID_DIVIDE") ! ID_OFF = xmlResource:GetXRCID("ID_OFF") ! ID_CLEAR = xmlResource:GetXRCID("ID_CLEAR") ! lastOperationId = ID_PLUS dialog:Connect(ID_0, wx.wxEVT_COMMAND_BUTTON_CLICKED, OnNumber) *************** *** 282,303 **** accelTable = wx.wxAcceleratorTable({ { wx.wxACCEL_NORMAL, string.byte('0'), ID_0 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD0, ID_0 }, { wx.wxACCEL_NORMAL, string.byte('1'), ID_1 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD1, ID_1 }, { wx.wxACCEL_NORMAL, string.byte('2'), ID_2 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD2, ID_2 }, { wx.wxACCEL_NORMAL, string.byte('3'), ID_3 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD3, ID_3 }, { wx.wxACCEL_NORMAL, string.byte('4'), ID_4 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD4, ID_4 }, { wx.wxACCEL_NORMAL, string.byte('5'), ID_5 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD5, ID_5 }, { wx.wxACCEL_NORMAL, string.byte('6'), ID_6 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD6, ID_6 }, { wx.wxACCEL_NORMAL, string.byte('7'), ID_7 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD7, ID_7 }, { wx.wxACCEL_NORMAL, string.byte('8'), ID_8 }, - { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD8, ID_8 }, { wx.wxACCEL_NORMAL, string.byte('9'), ID_9 }, { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD9, ID_9 }, { wx.wxACCEL_NORMAL, string.byte('.'), ID_DECIMAL }, --- 295,316 ---- accelTable = wx.wxAcceleratorTable({ { wx.wxACCEL_NORMAL, string.byte('0'), ID_0 }, { wx.wxACCEL_NORMAL, string.byte('1'), ID_1 }, { wx.wxACCEL_NORMAL, string.byte('2'), ID_2 }, { wx.wxACCEL_NORMAL, string.byte('3'), ID_3 }, { wx.wxACCEL_NORMAL, string.byte('4'), ID_4 }, { wx.wxACCEL_NORMAL, string.byte('5'), ID_5 }, { wx.wxACCEL_NORMAL, string.byte('6'), ID_6 }, { wx.wxACCEL_NORMAL, string.byte('7'), ID_7 }, { wx.wxACCEL_NORMAL, string.byte('8'), ID_8 }, { wx.wxACCEL_NORMAL, string.byte('9'), ID_9 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD0, ID_0 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD1, ID_1 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD2, ID_2 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD3, ID_3 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD4, ID_4 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD5, ID_5 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD6, ID_6 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD7, ID_7 }, + { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD8, ID_8 }, { wx.wxACCEL_NORMAL, wx.VXK_NUMPAD9, ID_9 }, { wx.wxACCEL_NORMAL, string.byte('.'), ID_DECIMAL }, |