From: John L. <jr...@us...> - 2005-06-07 05:37:55
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21454/wxLua/samples Added Files: choices.wx.lua debug.wx.lua debugtest.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 sizer.wx.lua tree.wx.lua veryminimal.wx.lua Log Message: added all the single file samples --- NEW FILE: sizer.wx.lua --- ----------------------------------------------------------------------------- -- Name: Sizer.wx.lua -- Purpose: Shows using sizers in wxLua -- Author: Francis Irving -- Created: 23/01/2002 -- RCS-ID: $Id: sizer.wx.lua,v 1.1 2005/06/07 05:37:45 jrl1 Exp $ -- Copyright: (c) 2002 Creature Labs. All rights reserved. -- Licence: wxWindows licence ----------------------------------------------------------------------------- frame = wx.wxFrame(wx.wxNull, -1, "wxLua sizer test frame") -- Create two controls (note that their parents are the _frame_ (not the sizer)) textEntry = wx.wxTextCtrl(frame, -1, "Enter URL"); button = wx.wxButton(frame, -1, "test") -- Put them in a vertical sizer, with ratio 3 units for the text entry, 5 for button -- and padding of 6 pixels. sizerTop = wx.wxBoxSizer(wx.wxVERTICAL) sizerTop:AddWindow(textEntry, 3, wx.wxGROW + wx.wxALL, 6) sizerTop:AddWindow(button, 5, wx.wxGROW + wx.wxALL, 6) -- Set up the frame to use that sizer to move/resize its children controls frame:SetAutoLayout(wx.TRUE) frame:SetSizer(sizerTop) -- Optional - these will set an initial minimal size, just enough to hold the -- controls (more useful for dialogs than a frame) --sizerTop.SetSizeHints(frame) --sizerTop.Fit(frame) -- Start the application wx.wxGetBaseApp():SetTopWindow(frame) frame:Show(wx.TRUE) --- NEW FILE: debug.wx.lua --- -------------------------------------------------------------------------=--- -- Name: debug.wx.lua -- Purpose: 'Scribble' wxLua sample with debugging tests -- Author: J Winwood -- Copyright: (c) 2002 Lomtick Software. All rights reserved. -- Licence: wxWindows licence -------------------------------------------------------------------------=--- frame = nil mouseDown = nil pointsList = {} itemColour = 1 running = 1 isModified = nil redrawRequired = 1 fileName = "" local wxID_DEBUG = wx.wxID_HIGHEST + 1 local wxID_NOPROMPT = wx.wxID_HIGHEST + 2 function causeError() -- local table = {} local number = 3.1415926 local string = "string" local userdata = wx.wxObject() table["a"] = 1 table[2] = "a" table[3] = {} table[4] = table table["b"] = {} table.n = 5 -- wx.value = 1 -- check this causes a run-time error -- @fileName = 1 -- test calling derived method calling local results = {} userdata.GetClassInfo = function(self) results.refData3 = self:base_GetClassInfo() return 1 end results.refData1 = userdata:GetClassInfo() results.refData2 = userdata:base_GetClassInfo() wxLuaStackDialog() end function main() local penColours = { "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Black", "Grey" } local pens = {} local screenWidth, screenHeight = wx.wxDisplaySize() local bitmap = wx.wxEmptyBitmap(screenWidth, screenHeight) local bitmapDC = wx.wxMemoryDC() local app = wx.wxGetBaseApp() app:SetVendorName("Lomtick Software") app:SetAppName("Debug") local config = wx.wxConfigGet() config:SetRecordDefaults() for idx = 1, 8 do pens[idx] = wx.wxPenFromColourName(penColours[idx], 3, wx.wxSOLID) end bitmapDC:SelectObject( bitmap ) frame = wx.wxFrame( wx.wxNull, -1, "Scribble Demo (with debugging support)", wx.wxPoint(-1, -1), wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) function DrawPoints(drawDC) for listIndex = 1, table.getn(pointsList) do local listValue = pointsList[listIndex] local lastX, lastY local penIndex = listValue.penColour; drawDC:SetPen(pens[penIndex]) for pointsIndex = 1, table.getn(listValue) do local pointsValue = listValue[pointsIndex] if pointsIndex > 1 then drawDC:DrawLine(lastX, lastY, pointsValue.x, pointsValue.y) end lastX, lastY = pointsValue.x, pointsValue.y end drawDC:SetPen(wx.wxNullPen) end end function Paint(event) if redrawRequired then if running then bitmapDC:Clear() DrawPoints(bitmapDC) end redrawRequired = nil end local dc = wx.wxPaintDC(frame) dc:BeginDrawing() if running then dc:Blit(0, 0, screenWidth, screenHeight, bitmapDC, 0, 0) end dc:EndDrawing() dc:Delete() end frame:ConnectEvent(wx.wxEVT_PAINT, Paint) frame:ConnectEvent(wx.wxEVT_ERASE_BACKGROUND, function(event) end) function OnLeftDown(event) local pointItem = {} pointItem.penColour = itemColour frame:SetStatusText(penColours[itemColour], 1) itemColour = itemColour + 1 if penColours[itemColour] == nil then itemColour = 1 end local points = {} points.x = event:GetX() points.y = event:GetY() pointItem.n = 1 pointItem[1] = points table.insert(pointsList, pointItem) frame:CaptureMouse() mouseDown = 1 isModified = 1 redrawRequired = 1 frame:Refresh() end function OnLeftUp(event) if mouseDown then local points = {} points.x = event:GetX() points.y = event:GetY() table.insert(pointsList[table.getn(pointsList)], points) frame:ReleaseMouse() mouseDown = nil redrawRequired = 1 frame:Refresh() end end function OnMotion(event) if mouseDown then local points = {} points.x = event:GetX() points.y = event:GetY() table.insert(pointsList[table.getn(pointsList)], points) redrawRequired = 1 frame:Refresh() end end frame:ConnectEvent(-1, wx.wxEVT_LEFT_DOWN, OnLeftDown ) frame:ConnectEvent(-1, wx.wxEVT_LEFT_UP, OnLeftUp ) frame:ConnectEvent(-1, wx.wxEVT_MOTION, OnMotion ) function QuerySaveChanges() local dialog = wx.wxMessageDialog( frame, "Document has changed. Do you wish to save the changes?", "Save Changes?", wx.wxYES_NO + wx.wxCANCEL + wx.wxCENTRE + wx.wxICON_QUESTION ) local result = dialog:ShowModal() dialog:Destroy() return result end function LoadScribbles() pointsList = {} return ((pcall(dofile, fileName)) ~= nil) end -- modified from the lua sample save.lua function savevar (n, v) if v ~= nil then io.write(n, "=") if type(v) == "string" then io.write(format("%q", v)) elseif type(v) == "table" then io.write("{}\n") for r,f in v do if type(r) == 'string' then savevar(n.."."..r, f) else savevar(n.."["..r.."]", f) end end else io.write(tostring(v)) end io.write("\n") end end function SaveScribbles() io.output(fileName) savevar("pointsList", pointsList) io.output() return 1 end function Open() local result = nil local fileDialog = wx.wxFileDialog(frame, "Open file", "", "", "Scribble files(*.scribble)|*.scribble", wx.wxOPEN) if fileDialog:ShowModal() == wx.wxID_OK then fileName = fileDialog:GetPath() result = LoadScribbles() if result then frame:SetTitle("Scribble Demo - " .. fileName) end end fileDialog:Destroy() return result end function SaveAs() local fileDialog = wx.wxFileDialog(frame) fileDialog:SetMessage("Save file as") fileDialog:SetStyle(wx.wxSAVE) fileDialog:SetWildcard("Scribble files(*.scribble)|*.scribble") if fileDialog:ShowModal() == wx.wxID_OK then fileName = fileDialog:GetPath() result = SaveScribbles() if result then frame:SetTitle("Scribble Demo - " .. fileName) end end fileDialog:Destroy() return result end function SaveChanges() local isOKToContinue if fileName == "" then isOKToContinue = SaveAs() else isOKToContinue = SaveScribbles() end return isOKToContinue end local fileMenu = wx.wxMenu() fileMenu:Append(wx.wxID_NEW, "&New", "Begin a new drawing") fileMenu:Append(wx.wxID_OPEN, "&Open", "Open an existing drawing") fileMenu:Append(wx.wxID_SAVE, "&Save", "Save the drawing") fileMenu:Append(wx.wxID_SAVEAS, "Save &As", "Save the drawing to a new file") fileMenu:AppendSeparator() fileMenu:Append(wxID_DEBUG, "&Debug", "Cause Debug Event") fileMenu:AppendSeparator() fileMenu:Append(wx.wxID_EXIT, "&Exit", "Quit the program") local configMenu = wx.wxMenu() configMenu:Append(wxID_NOPROMPT, "&Config", "Toggle MessageBox") local helpMenu = wx.wxMenu() helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua Minimal Application") local menuBar = wx.wxMenuBar() menuBar:Append(fileMenu, "&File") menuBar:Append(configMenu, "&Options") menuBar:Append(helpMenu, "&Help") frame:SetMenuBar(menuBar) frame:CreateStatusBar(2) frame:SetStatusText("Welcome to wxLua.") frame:ConnectEvent(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) frame:Close(wx.TRUE) end ) frame:ConnectEvent(wx.wxID_NEW, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) local isOKToContinue = 1 if isModified then local response = QuerySaveChanges() if response == wx.wxID_YES then isOKToContinue = SaveChanges() elseif response == wx.wxID_CANCEL then isOKToContinue = nil end end if isOKToContinue then fileName = "" frame:SetTitle( "Scribble Demo") pointsList = {} redrawRequired = 1 frame:Refresh() isModified = nil end end ) frame:ConnectEvent(wx.wxID_OPEN, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) local isOKToContinue = 1 if isModified then local response = QuerySaveChanges() if response == wx.wxID_YES then isOKToContinue = SaveChanges() elseif response == wx.wxID_CANCEL then isOKToContinue = nil end end if isOKToContinue then Open() redrawRequired = 1 frame:Refresh() isModified = nil end end ) frame:ConnectEvent(wx.wxID_SAVE, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) local isSaved if fileName == "" then isSaved = SaveAs() else isSaved = SaveScribbles() end if isSaved then isModified = nil end end ) frame:ConnectEvent(wx.wxID_SAVEAS, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) local isSaved = SaveAs() if isSaved then isModified = nil end end ) frame:ConnectEvent(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, frame ) end ) frame:ConnectEvent(wxID_NOPROMPT, wx.wxEVT_UPDATE_UI, function ( event ) end) frame:ConnectEvent(wxID_NOPROMPT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) if config:ReadInt("/Controls/Check", 1) == 1 then config:WriteInt("/Controls/Check", 0) else config:WriteInt("/Controls/Check", 1) end end ) frame:ConnectEvent(wx.wxEVT_CLOSE_WINDOW, function (event) local isOkToClose = 1 if isModified then local dialog = wx.wxMessageDialog( frame, "Save changes before exiting?", "Save Changes?", wx.wxYES_NO + wx.wxCENTRE + wx.wxICON_QUESTION ) local result = dialog:ShowModal() dialog:Destroy() if result == wx.wxID_YES then isOkToClose = SaveChanges() end end if isOkToClose then -- prevent paint events using the bitmapDC after we -- have deleted them running = nil bitmapDC:SelectObject(wx.wxNullBitmap) bitmapDC:Delete() bitmap:Delete() local x, y, w, h w, h = frame:GetClientSize() x, y = frame:GetPosition() config:WriteInt("/MainFrame/x", x) config:WriteInt("/MainFrame/y", y) config:WriteInt("/MainFrame/w", w) config:WriteInt("/MainFrame/h", h) config:Set():Destroy() -- ensure the event is passed on so -- that it is handled event:Skip() end end ) frame:ConnectEvent(wxID_DEBUG, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) causeError() end) if config:ReadInt("/Controls/Check", 1) == 1 then wx.wxMessageBox([[You can disable this message box by unchecking the checkbox in the main window (of course, a real program would have a checkbox right here but we keep it simple)]], "Welcome to Debug demo", wx.wxICON_INFORMATION + wx.wxOK) end config:SetPath("/MainFrame") local x, y, w, h x = config:ReadInt("x", 50) y = config:ReadInt("y", 50) w = config:ReadInt("w", 350) h = config:ReadInt("h", 200) frame:Move(x, y) frame:SetClientSizeWH(w, h) config:SetPath("/") frame:Show(wx.TRUE) end main() --fred() --- NEW FILE: mdi.wx.lua --- ----------------------------------------------------------------------------- -- Name: mdi.wx.lua -- Purpose: 'Mdi' wxLua sample -- Author: J Winwood -- Modified by: -- Created: 16/11/2001 -- RCS-ID: $Id: mdi.wx.lua,v 1.1 2005/06/07 05:37:45 jrl1 Exp $ -- Copyright: (c) 2001 Lomtick Software. All rights reserved. -- Licence: wxWindows licence ----------------------------------------------------------------------------- childList = {} numChildren = 0 function main() local frame = wx.wxMDIParentFrame( wx.wxNull, -1, "MDI Demo", wx.wxPoint(-1, -1), wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) function CreateChild() local child = wx.wxMDIChildFrame( frame, -1, "" ) child:SetSize(330,340) childList[child:GetId()] = child numChildren = numChildren + 1 child:SetTitle("Child "..numChildren) function Paint(event) local dc = wx.wxPaintDC(childList[event:GetId()]) dc:DrawRectangle(10, 10, 300, 300); dc:DrawRoundedRectangle(20, 20, 280, 280, 20); dc:DrawEllipse(30, 30, 260, 260); dc:DrawText("A test string", 50, 150); dc:Delete() end child:ConnectEvent(wx.wxEVT_PAINT, Paint) end local fileMenu = wx.wxMenu() fileMenu:Append(wx.wxID_NEW, "&New", "Create a new child window") fileMenu:Append(wx.wxID_EXIT, "&Exit", "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:ConnectEvent(wx.wxID_NEW, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) CreateChild() end ) frame:ConnectEvent(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) frame:Close() end ) frame:ConnectEvent(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(wx.TRUE) end main() --- NEW FILE: fldemo.wx.lua --- ----------------------------------------------------------------------------- -- Name: FLDemo.wx.lua -- Purpose: 'FL' wxLua sample -- Author: J Winwood -- Modified by: -- Created: -- RCS-ID: -- Copyright: (c) 2002 J Winwood. All rights reserved. -- Licence: wxWindows licence ----------------------------------------------------------------------------- frame = nil function CreateTextCtrl(name) local textctrl = wx.wxTextCtrl(frame, -1, name, wx.wxDefaultPosition, wx.wxSize(0,0), wx.wxTE_MULTILINE) textctrl:SetBackgroundColour(wx.wxColour(192,192,192)) return textctrl end function main() -- return the path part of the currently executing file local strAt = string.byte('@') function getPath() function findLast(filePath) local lastOffset = nil local offset repeat offset = string.find(filePath, "\\") if offset == nil then offset = string.find(filePath, "/") end if offset then if not lastOffset then lastOffset = offset else lastOffset = lastOffset + offset end filePath = string.sub(filePath, offset + 1) end until not offset return lastOffset end local filePath = debug.getinfo(1, "S").source if string.byte(filePath) == strAt then local offset = findLast(filePath) if offset ~= nil then -- remove the @ at the front up to just before the path separator filePath = string.sub(filePath, 2, offset - 1) else filePath = "." end else filePath = wx.wxGetCwd().."/Examples" end return filePath end local bitmapPath = getPath().."/bitmaps/" newBitmap = wx.wxBitmapFromFile(bitmapPath.."new.bmp", wx.wxBITMAP_TYPE_BMP) openBitmap = wx.wxBitmapFromFile(bitmapPath.."open.bmp", wx.wxBITMAP_TYPE_BMP) saveBitmap = wx.wxBitmapFromFile(bitmapPath.."save.bmp", wx.wxBITMAP_TYPE_BMP) saveAllBitmap = wx.wxBitmapFromFile(bitmapPath.."saveall.bmp", wx.wxBITMAP_TYPE_BMP) cutBitmap = wx.wxBitmapFromFile(bitmapPath.."cut.bmp", wx.wxBITMAP_TYPE_BMP) copyBitmap = wx.wxBitmapFromFile(bitmapPath.."copy.bmp", wx.wxBITMAP_TYPE_BMP) pasteBitmap = wx.wxBitmapFromFile(bitmapPath.."paste.bmp", wx.wxBITMAP_TYPE_BMP) helpBitmap = wx.wxBitmapFromFile(bitmapPath.."help.bmp", wx.wxBITMAP_TYPE_BMP) -- create the frame window frame = wx.wxFrame( wx.wxNull, -1, "FL Demo", wx.wxPoint(-1, -1), wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) client = CreateTextCtrl("Client") layout = wx.wxFrameLayout(frame, client) if wx.wxPlatformGTK then local props = layout:GetPaneProperties() props:SetRealTimeUpdates(wx.FALSE) layout:SetPaneProperties(props, wx.wxALL_PANES) end layout:SetUpdatesManager(wx.cbGCUpdatesMgrDefault()) local fileMenu = wx.wxMenu() fileMenu:Append(wx.wxID_EXIT, "&Exit", "Quit the program") local helpMenu = wx.wxMenu() helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua FL Demo 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:ConnectEvent(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) frame:Close(TRUE) end ) frame:ConnectEvent( wx.wxEVT_CLOSE_WINDOW, function ( event ) event:Skip() layout:Delete() layout = nil end) frame:ConnectEvent(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, frame ) end ) layout:PushDefaultPlugins() layout:AddPlugin(wx.wxClassInfo("cbBarHintsPlugin")) layout:AddPlugin(wx.wxClassInfo("cbHintAnimationPlugin")) -- layout:AddPlugin(wx.wxClassInfo("cbRowDragPlugin")) layout:AddPlugin(wx.wxClassInfo("cbAntiflickerPlugin")) layout:AddPlugin(wx.wxClassInfo("cbSimpleCustomizationPlugin")) local sizes0 = wx.cbDimInfo(200, 45, 200, 85, 175, 35, wx.FALSE, 4, 4) local sizes1 = wx.cbDimInfo(150, 35, 150, 85, 175, 35, wx.TRUE, 4, 4) local sizes2 = wx.cbDimInfo(195, 32, 185, 32, 195, 35, wx.TRUE, 4, 4, wx.cbDynToolBarDimHandler()) toolBar = wx.wxDynamicToolBar(frame, -1) toolBar:AddTool(wx.wxID_NEW, newBitmap) toolBar:AddTool(wx.wxID_OPEN, openBitmap) toolBar:AddTool(wx.wxID_SAVE, saveBitmap) toolBar:AddSeparator() toolBar:AddTool(wx.wxID_CUT, cutBitmap) toolBar:AddTool(wx.wxID_COPY, copyBitmap) toolBar:AddTool(wx.wxID_PASTE, pasteBitmap) toolBar:AddSeparator() toolBar:AddTool(wx.wxID_ABOUT, helpBitmap) layout:AddBar(toolBar, sizes2, wx.FL_ALIGN_TOP, 0, 0, "First Toolbar", wx.FALSE) layout:AddBar(CreateTextCtrl("Third"), sizes1, wx.FL_ALIGN_TOP, 1, 0, "Second Toolbar", wx.TRUE) layout:AddBar(CreateTextCtrl("Second"), sizes0, wx.FL_ALIGN_TOP, 1, 0, "Second View", wx.TRUE) layout:AddBar(CreateTextCtrl("First"), sizes0, wx.FL_ALIGN_TOP, 1, 0, "First View", wx.TRUE) layout:EnableFloating(wx.TRUE) frame:Show(wx.TRUE) end main() --- NEW FILE: debugtest.wx.lua --- -- return the path part of the currently executing file local strAt = string.byte('@') function getPath() function findLast(filePath) local lastOffset = nil local offset repeat offset = string.find(filePath, "\\") if offset == nil then offset = string.find(filePath, "/") end if offset then if not lastOffset then lastOffset = offset else lastOffset = lastOffset + offset end filePath = string.sub(filePath, offset + 1) end until not offset return lastOffset end local filePath = debug.getinfo(1, "S").source if string.byte(filePath) == strAt then local offset = findLast(filePath) if offset ~= nil then -- remove the @ at the front up to just before the path separator filePath = string.sub(filePath, 2, offset - 1) else filePath = "." end else filePath = wx.wxGetCwd().."/Examples" end return filePath end dofile (getPath().."/Minimal.wx.lua") --- NEW FILE: veryminimal.wx.lua --- ----------------------------------------------------------------------------- -- Name: minimal.wx.lua -- Purpose: 'Minimal' wxLua sample -- Author: J Winwood -- Modified by: -- Created: 16/11/2001 -- RCS-ID: $Id: veryminimal.wx.lua,v 1.1 2005/06/07 05:37:45 jrl1 Exp $ -- Copyright: (c) 2001 J Winwood. All rights reserved. -- Licence: wxWindows licence ----------------------------------------------------------------------------- frame = nil function main() -- create the frame window frame = wx.wxFrame( wx.wxNull, -1, "Minimal Demo", wx.wxPoint(-1, -1), wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) -- show the frame window frame:Show(wx.TRUE) end main() --- NEW FILE: tree.wx.lua --- function main() frame = wx.wxFrame( wx.wxNull, -1, "Tree Demo", wx.wxDefaultPosition, wx.wxSize(450, 400), wx.wxDEFAULT_FRAME_STYLE ) tree = wx.wxTreeCtrl( frame, -1, wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxTR_LINES_AT_ROOT + wx.wxTR_HAS_BUTTONS ) local ifr = tree:AddRoot( "Root" ) print("root value", ifr:GetValue(), "\n") local ifw = tree:GetRootItem(); print("root value", ifw:GetValue(), "\n") for idx = 0, 10 do ir = tree:AppendItem( ifr, "Parent ("..idx..")" ) for jdx = 0, 5 do tree:AppendItem( ir, "Child ("..idx..", "..jdx..")" ) end if (idx == 2) or (idx == 5) then tree:Expand(ir) end end local ifw = tree:GetRootItem(); print("root value", ifw:GetValue(), "\n") tree:ConnectEvent( wx.wxEVT_COMMAND_TREE_ITEM_EXPANDING, function( event ) local selNode = event:GetItem() print("Item:", selNode:GetValue(), "\n") end ) tree:Expand(ifr) wx.wxGetBaseApp():SetTopWindow(frame) frame:Show(wx.TRUE) end main() --- NEW FILE: htmlwin.wx.lua --- -------------------------------------------------------------------------=--- -- Name: HtmlWindow.wx.lua -- Purpose: HtmlWindow wxLua sample -- Author: J Winwood -- Created: May 2002 -- Copyright: (c) 2002 Lomtick Software. All rights reserved. -- Licence: wxWindows licence -------------------------------------------------------------------------=--- frame = nil html = nil htmlTextPage = [[<html> <head> <title>Bound Widget demonstration</title> </head> <body> <h3>wxHtmlWidgetCell demonstration</h3> There are three bound widgets below. <hr> <center> <lua text="first widget" x=100 y=70> </center> <hr> <lua text="small widget" x=60 y=50> <hr> <lua text="widget with floating width" float=y x=70 y=40> </body> </html>]] function main() -- create the frame window frame = wx.wxFrame( wx.wxNull, -1, "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, "&Exit", "Quit the program") -- create a simple help menu local helpMenu = wx.wxMenu() helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua Minimal Application") -- 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:ConnectEvent(wx.wxID_PREVIEW, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) local printing = wx.wxHtmlEasyPrinting("HtmlWindow.wx.lua", frame) printing:PreviewText(htmlTextPage) end ) frame:ConnectEvent(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:ConnectEvent(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) frame:Close(TRUE) end ) -- connect the selection event of the about menu item frame:ConnectEvent(wx.wxID_ABOUT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) wx.wxMessageBox( 'This is the "About" dialog of the HtmlWindow 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.wxGetBaseApp():ConnectEvent(-1, wx.wxEVT_HTML_TAG_HANDLER, function (event) CreateBoundWindow(event) end) -- set the frame window and status bar html:SetRelatedFrame(frame, "HtmlWindow wxLua Sample : %s") html:SetRelatedStatusBar(1) -- load the document html:SetPage(htmlTextPage) -- html:LoadPage("testpage.html") -- show the frame window wx.wxGetBaseApp().TopWindow = frame frame:Show(wx.TRUE) end function CreateBoundWindow(event) local ax, ay local rc, fl = 0 -- parse the X parameter in the custom lua tag rc, ax = event.HtmlTag:GetParamAsInt("X") -- parse the Y parameter ay = event.HtmlTag:GetParam("Y") -- if there is a float tag set the float if event.HtmlTag:HasParam("FLOAT") == wx.TRUE then fl = ax end -- create the control to embed local parent = event.HtmlParser.Window if parent then local wnd = wx.wxTextCtrl( parent, -1, event.HtmlTag:GetParam("TEXT"), wx.wxPoint(0, 0), wx.wxSize(ax, ay), wx.wxTE_MULTILINE ) -- show the control wnd:Show(wx.TRUE) -- create the container widget cell local widget = wx.wxHtmlWidgetCell(wnd, fl) -- insert the cell into the document event.HtmlParser:OpenContainer():InsertCell(widget) event:SetParseInnerCalled(wx.FALSE) end end main() --- NEW FILE: dialog.wx.lua --- -------------------------------------------------------------------------=--- -- Name: Dialog.wx.lua -- Purpose: Dialog wxLua sample -- Based on the C++ version by Marco Ghislanzoni -- Author: J Winwood -- Created: March 2002 -- Copyright: (c) 2001 Lomtick Software. All rights reserved. -- Licence: wxWindows licence -------------------------------------------------------------------------=--- -- IDs of the controls in the dialog local Dialog_CelsiusToFahrenheit = 1 local Dialog_FahrenheitToCelsius = 2 local Dialog_About = 3 local Dialog_Close = 4 local Dialog_CelsiusDegrees = 5 local Dialog_FahrenheitDegrees = 6 local Dialog_CelsiusText = 7 local Dialog_FahrenheitText = 8 local Dialog_StaticBox = 9 -- Create the dialog local dialog = wx.wxDialog(wx.wxNull, -1, "Temperature Converter", wx.wxPoint(0, 0), wx.wxSize(147, 162)) -- Create the controls local statBox = wx.wxStaticBox (dialog, Dialog_StaticBox, "Convert", wx.wxPoint(5, 0), wx.wxSize(130, 100)) local celsiusText = wx.wxStaticText(dialog, Dialog_CelsiusText, "Celsius:", wx.wxPoint(10, 15)) local celsiusDegree = wx.wxTextCtrl (dialog, Dialog_CelsiusDegree, nil, wx.wxPoint(10, 30), wx.wxSize(50, 20)) local fahrenheitText = wx.wxStaticText(dialog, Dialog_FahrenheitText, "Fahrenheit:", wx.wxPoint(10, 55)) local fahrenheitDegree = wx.wxTextCtrl (dialog, Dialog_FahrenheitDegree, nil, wx.wxPoint(10, 70), wx.wxSize(50, 20)) local btnCelsiusToFahrenheit = wx.wxButton (dialog, Dialog_CelsiusToFahrenheit, "C -> F", wx.wxPoint(80, 30), wx.wxSize(50, 20)) local btnFahrenheitToCelsius = wx.wxButton (dialog, Dialog_FahrenheitToCelsius, "F -> C", wx.wxPoint(80, 70), wx.wxSize(50, 20)) local btnAbout = wx.wxButton (dialog, Dialog_About, "About", wx.wxPoint(10, 110), wx.wxSize(50, 20)) local btnClose = wx.wxButton (dialog, Dialog_Close, "Close", wx.wxPoint(80, 110), wx.wxSize(50, 20)) -- Attach an event handler to the CelsiusToFahrenheit button dialog:ConnectEvent(Dialog_CelsiusToFahrenheit, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) local celsiusString = celsiusDegree:GetValue() if celsiusString == "" then wx.wxMessageBox("The Celsius entry is invalid", "Error!", wx.wxOK + wx.wxICON_EXCLAMATION + wx.wxCENTRE, dialog) else local fahrenheitValue = (tonumber(celsiusString) * 9 / 5) + 32 fahrenheitDegree:SetValue(fahrenheitValue) end end) -- Attach an event handler to the FahrenheitToCelsius button dialog:ConnectEvent(Dialog_FahrenheitToCelsius, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) local fahrenheitString = fahrenheitDegree:GetValue() if fahrenheitString == "" then wx.wxMessageBox("The fahrenheit entry is invalid!", "Error!", wx.wxOK + wx.wxICON_EXCLAMATION + wx.wxCENTRE, dialog) else local celsiusValue = (tonumber(fahrenheitString) - 32) * 5 / 9 celsiusDegree:SetValue(celsiusValue) end end) -- Attach an event handler to the Close button dialog:ConnectEvent(Dialog_Close, wx.wxEVT_COMMAND_BUTTON_CLICKED, function(event) dialog:Destroy() end) dialog:ConnectEvent(wx.wxEVT_CLOSE_WINDOW, function (event) dialog:Destroy() event:Skip() end) -- Attach an event handler to the About button dialog:ConnectEvent(Dialog_About, 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) end) -- Centre the dialog on the screen dialog:Centre() -- Show the dialog dialog:Show(wx.TRUE) --- NEW FILE: editor.wx.lua --- -------------------------------------------------------------------------=--- -- Name: Editor.wx.lua -- Purpose: wxLua IDE -- Author: J Winwood -- Created: March 2002 -- Copyright: (c) 2002-5 Lomtick Software. All rights reserved. -- Licence: wxWindows licence -------------------------------------------------------------------------=--- local wxID_REDO = wx.wxID_HIGHEST + 1 local wxID_SELECTALL = wx.wxID_HIGHEST + 2 local wxID_FINDNEXT = wx.wxID_HIGHEST + 3 local wxID_FINDPREV = wx.wxID_HIGHEST + 4 local wxID_REPLACE = wx.wxID_HIGHEST + 5 local wxID_GOTOLINE = wx.wxID_HIGHEST + 6 local wxID_TOGGLEBREAKPOINT = wx.wxID_HIGHEST + 7 local wxID_COMPILE = wx.wxID_HIGHEST + 8 local wxID_RUN = wx.wxID_HIGHEST + 9 local wxID_ATTACH_DEBUG = wx.wxID_HIGHEST + 10 [...2039 lines suppressed...] if args then local fileLoaded programName = args[0] for index, fileName in args do if index ~= "n" and index ~= 0 then loadFile(fileName, fileName) fileLoaded = 1 end if notebook:GetPageCount() > 0 then notebook:SetSelection(0) end end if not fileLoaded then local editor = createEditor("Untitled") setupKeywords(editor, 1) end end frame:SetIcon(wxLuaEditorIcon) --- NEW FILE: grid.wx.lua --- ----------------------------------------------------------------------------- -- Name: Grid.wx.lua -- Purpose: 'Grid' wxLua sample -- Author: J Winwood -- Created: January 2002 -- Copyright: (c) 2002 Lomtick Software. All rights reserved. -- Licence: wxWindows licence ----------------------------------------------------------------------------- function main() local frame = wx.wxFrame(wx.wxNull, -1, "Testing wxGrid", wx.wxPoint(25, 25), wx.wxSize(350, 250)) local fileMenu = wx.wxMenu("", wxMENU_TEAROFF) fileMenu:Append(wx.wxID_EXIT, "&Exit\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:ConnectEvent(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) frame:Close() end ) frame:ConnectEvent(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, -1) 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(wx.TRUE) end main() --- NEW FILE: choices.wx.lua --- function main() local frame = wx.wxFrame(wx.wxNull, -1, "Choices", wx.wxPoint(20, 20), wx.wxSize(450, 350)) panel = wx.wxPanel(frame, -1) local n = wx.wxNotebook(panel, -1, wx.wxPoint(10,10), wx.wxSize(410, 300), wx.wxNB_BOTTOM ) local choices = {"one", "two", "three", "four"} local p1 = wx.wxPanel(n, -1) n:AddPage(p1, "wxRadioBox and wxListBox") local b1 = wx.wxRadioBox(p1, -1, "Choice 1", wx.wxPoint(10,10), wx.wxSize(370, 100), choices, 1, wx.wxRA_SPECIFY_ROWS) local l1 = wx.wxListBox(p1, -1, wx.wxPoint(10,120), wx.wxSize(370, 100), choices) local p2 = wx.wxPanel(n, -1) n:AddPage(p2, "wxRadioBox and wxComboBox") local b2 = wx.wxRadioBox(p2, -1, "Choice 2", wx.wxPoint(10,10), wx.wxSize(370, 100), choices, 1, wx.wxRA_SPECIFY_COLS) local l2 = wx.wxComboBox(p2, -1, "three", wx.wxPoint(10,120), wx.wxSize(370, 100), choices) local p3 = wx.wxPanel(n, -1) n:AddPage(p3, "extra") local b3 = wx.wxRadioBox(p3, -1, "Choice 1", wx.wxPoint(10,10), wx.wxSize(370, 100), choices, 1, wx.wxRA_SPECIFY_ROWS) print("b3 - metatable before destruction", getmetatable(b3)) b3:Destroy() print("b3 - metatable after destruction", getmetatable(b3)) wx.wxGetBaseApp():SetTopWindow(frame) frame:Show(wx.TRUE) end main() --- NEW FILE: printing.wx.lua --- ----------------------------------------------------------------------------- -- Name: printing.wx.lua -- Purpose: 'Printing' wxLua sample -- Author: J Winwood -- Modified by: -- Created: 4/7/2002 -- Modified -- RCS-ID: $Id: printing.wx.lua,v 1.1 2005/06/07 05:37:45 jrl1 Exp $ -- Copyright: (c) 2002 J Winwood. All rights reserved. -- Licence: wxWindows licence ----------------------------------------------------------------------------- local wxID_PRINT = wx.wxID_HIGHEST + 1 local wxID_PRINTPREVIEW = wx.wxID_HIGHEST + 2 local wxID_PRINTSETUP = wx.wxID_HIGHEST + 3 local wxID_PAGESETUP = wx.wxID_HIGHEST + 4 frame = nil printData = wx.wxPrintData() pageSetupData = wx.wxPageSetupDialogData() function DisplayFigure(dc, pageNumber) -- call some drawing functions dc:DrawRectangle(10, 10, 300, 300) dc:DrawRoundedRectangle(20, 20, 280, 280, 20) dc:DrawEllipse(30, 30, 260, 260) if pageNumber then dc:DrawText("Test page "..pageNumber, 50, 150) else dc:DrawText("A test string", 50, 150) end end function ConnectPrintEvents(printOut) printOut:SetPageInfo(1, 16, 2, 15) printOut.HasPage = function(self, pageNum) return wx.TRUE end printOut.GetPageInfo = function(self) return 1, 6, 2, 5 end printOut.OnBeginDocument = function(self, startPage, endPage) return self:base_OnBeginDocument(startPage, endPage) end printOut.OnEndDocument = function(self) end printOut.OnBeginPrinting = function(self) end printOut.OnEndPrinting = function(self) end printOut.OnPreparePrinting = function(self) end printOut.OnPrintPage = function(self, pageNum) local dc = self:GetDC() -- Marcos modified init local ppiScreenX, ppiScreenY = self:GetPPIScreen() local ppiPrinterX, ppiPrinterY = self:GetPPIPrinter() local scale = ppiPrinterX/ppiScreenX local w, h = dc:GetSize() local a ,b = self:GetPageSizeMM() local pageWidth, pageHeight = self:GetPageSizePixels() local overallScale = (scale * ( w / pageWidth)) -- print( 'dc:GetUserScale-->'..dc:GetUserScale()) -- print(string.format('ppiScreenX %s, ppiScreenY %s', ppiScreenX, ppiScreenY)) -- print(string.format("ppiPrinterX %s, ppiPrinterY %s", ppiPrinterX, ppiPrinterY)) -- print(string.format("printOut:GetPageSizeMM--> a %s, b %s dc:GetSize-->w %s, h %s, printOut:GetPageSizePixels--> pageWidth %s, pageHeight %s", a, b, w, h, pageWidth, pageHeight )) dc:SetUserScale(overallScale, overallScale) -- print('overallScale '..overallScale, 'GetUserScale '..dc:GetUserScale()) -- Marcos modified end DisplayFigure(dc, pageNum) return wx.TRUE end end function Print() local printDialogData = wx.wxPrintDialogDataFromPrintData(printData) local printer = wx.wxPrinter(printDialogData) local printout = wx.wxLuaPrintout("Test Print") ConnectPrintEvents(printout) if printer:Print(frame, printout, wx.TRUE) == wx.FALSE then if printer:GetLastError() == wx.wxPRINTER_ERROR then wx.wxMessageBox("There was a problem printing.\nPerhaps your current printer is not set correctly?", "Printing.wx.lua", wx.wxOK) else wx.wxMessageBox("You cancelled printing", "Printing.wx.lua", wx.wxOK) end else printData = printer:GetPrintDialogData():GetPrintData():Copy() end end function PrintPreview() local printerPrintout = wx.wxLuaPrintout("Test Print") ConnectPrintEvents(printerPrintout) local previewPrintout = wx.wxLuaPrintout("Test Print Preview") ConnectPrintEvents(previewPrintout) local printDialogData = wx.wxPrintDialogDataFromPrintData(printData):GetPrintData() local preview = wx.wxPrintPreview(printerPrintout, previewPrintout, printDialogData) local result = preview:Ok() if result == wx.FALSE then wx.wxMessageBox("There was a problem previewing.\nPerhaps your current printer is not set correctly?", "Printing.wx.lua", wx.wxOK) else local previewFrame = wx.wxPreviewFrame(preview, frame, "Test Print Preview", wx.wxPoint(100, 100), wx.wxSize(600, 650)) previewFrame:ConnectEvent(wx.wxEVT_CLOSE_WINDOW, function (event) previewFrame:Destroy() event:Skip() end ) previewFrame:Centre(wx.wxBOTH) previewFrame:Initialize() previewFrame:Show(wx.TRUE) end end function PrintSetup() local printDialogData = wx.wxPrintDialogDataFromPrintData(printData) local printerDialog = wx.wxPrintDialog(frame, printDialogData) printerDialog:GetPrintDialogData():SetSetupDialog(wx.TRUE) printerDialog:ShowModal() printData = printerDialog:GetPrintDialogData():GetPrintData():Copy() printerDialog:Destroy() end function PageSetup() printData = pageSetupData:GetPrintData():Copy() local pageSetupDialog = wx.wxPageSetupDialog(frame, pageSetupData) pageSetupDialog:ShowModal() printData = pageSetupDialog:GetPageSetupData():GetPrintData():Copy() pageSetupData = pageSetupDialog:GetPageSetupData():Copy() pageSetupDialog:Destroy() end function main() -- create the frame window frame = wx.wxFrame( wx.wxNull, -1, "Printing Demo", wx.wxPoint(-1, -1), wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) -- paint event handler function Paint(event) -- create the paint DC local dc = wx.wxPaintDC(frame) DisplayFigure(dc) -- the paint DC will be destroyed by the garbage collector, -- however on Windows 9x/Me this may be too late (DC's are precious resource) -- so delete it here dc:Delete() end -- connect the paint event handler with the paint event frame:ConnectEvent(wx.wxEVT_PAINT, Paint) -- create a simple file menu local fileMenu = wx.wxMenu() fileMenu:Append(wxID_PAGESETUP, "Page S&etup", "Set up the page") fileMenu:Append(wxID_PRINTSETUP, "Print &Setup", "Set up the printer") fileMenu:Append(wxID_PRINTPREVIEW, "Print Pre&view", "Preview the test print") fileMenu:Append(wxID_PRINT, "&Print", "Print the test print") fileMenu:Append(wx.wxID_EXIT, "&Exit", "Quit the program") -- create a simple help menu local helpMenu = wx.wxMenu() helpMenu:Append(wx.wxID_ABOUT, "&About", "About the wxLua Printing Application") -- 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:SetMenuBar(menuBar) -- create a simple status bar frame:CreateStatusBar(1) frame:SetStatusText("Welcome to wxLua.") frame:ConnectEvent(wxID_PAGESETUP, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) PageSetup() end ) frame:ConnectEvent(wxID_PRINTSETUP, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) PrintSetup() end ) frame:ConnectEvent(wxID_PRINTPREVIEW, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) PrintPreview() end ) frame:ConnectEvent(wxID_PRINT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) Print() end ) -- connect the selection event of the exit menu item to an -- event handler that closes the window frame:ConnectEvent(wx.wxID_EXIT, wx.wxEVT_COMMAND_MENU_SELECTED, function (event) frame:Close(TRUE) end ) -- connect the selection event of the about menu item frame:ConnectEvent(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, frame ) end ) -- show the frame window frame:Show(wx.TRUE) end main() --- NEW FILE: scribble.wx.lua --- -------------------------------------------------------------------------=--- -- Name: scribble.wx.lua -- Purpose: 'Scribble' wxLua sample -- Author: J Winwood -- Modified by: Thanks to Peter Prade and Nick Trout for fixing -- the bug in the for loop in DrawPoints() -- Created: 16/11/2001 -- RCS-ID: $Id: scribble.wx.lua,v 1.1 2005/06/07 05:37:45 jrl1 Exp $ -- Copyright: (c) 2001 J Winwood. All rights reserved. -- Licence: wxWindows licence -------------------------------------------------------------------------=--- frame = nil mouseDown = nil pointsList = {} itemColour = 1 running = 1 isModified = nil redrawRequired = 1 fileName = "" function main() local penColours = { "Red", "Orange", "Yellow", "Green", "Blue", "Purple", "Black", "Grey" } local pens = {} local screenWidth, screenHeight = wx.wxDisplaySize() local bitmap = wx.wxEmptyBitmap(screenWidth, screenHeight) for idx = 1, 8 do pens[idx] = wx.wxPenFromColourName(penColours[idx], 3, wx.wxSOLID) end frame = wx.wxFrame( wx.wxNull, -1, "Scribble Demo", wx.wxPoint(-1, -1), wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) function DrawPoints(drawDC) for listIndex = 1, table.getn(pointsList) do local listValue = pointsList[listIndex] local lastX, lastY drawDC:SetPen(pens[listValue.penColour]) for pointsIndex = 1, table.getn(listValue) do local pointsValue = listValue[pointsIndex] if pointsIndex > 1 then drawDC:DrawLine(lastX, lastY, pointsValue.x, pointsValue.y) end lastX, lastY = pointsValue.x, pointsValue.y end end drawDC:SetPen(wx.wxNullPen) end function Paint(event) local dc = wx.wxPaintDC(frame) dc:BeginDrawing() if redrawRequired then if running then local bitmapDC = wx.wxMemoryDC() bitmapDC:SelectObject( bitmap ) bitmapDC:Clear() DrawPoints(bitmapDC) bitmapDC:SelectObject(wx.wxNullBitmap) bitmapDC:Delete() end redrawRequired = nil end if running then dc:DrawBitmap(bitmap, 0, 0, false) end dc:EndDrawing() dc:Delete() end frame:ConnectEvent(wx.wxEVT_PAINT, Paint) frame:ConnectEvent(wx.wxEVT_... [truncated message content] |