From: John L. <jr...@us...> - 2007-05-01 14:23:40
|
Update of /cvsroot/wxlua/wxLua/samples In directory sc8-pr-cvs9.sourceforge.net:/tmp/cvs-serv7927/wxLua/samples Modified Files: coroutine.wx.lua dialog.wx.lua htmlwin.wx.lua tree.wx.lua Log Message: updated docs to say how to run the samples and added an index cleaned up some of the modules wxLua.dsw - wxbind must be built before wxluasocket in the wxlua module shared library since the wxluasocket bindings depend on the wxWindow tag. Index: htmlwin.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/htmlwin.wx.lua,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** htmlwin.wx.lua 21 Dec 2006 20:14:20 -0000 1.11 --- htmlwin.wx.lua 1 May 2007 14:23:35 -0000 1.12 *************** *** 8,13 **** -------------------------------------------------------------------------=--- ! frame = nil ! html = nil htmlTextPage = --- 8,13 ---- -------------------------------------------------------------------------=--- ! frame = nil -- the main frame of the program ! html = nil -- the wxLuaHtmlWindow child of the frame (subclassed wxHtmlWindow) htmlTextPage = *************** *** 49,53 **** local parent = nil if wx.wxCHECK_VERSION(2,7,0) then ! parent = event:GetHtmlParser():GetWindowInterface():GetHTMLWindow() else parent = event.HtmlParser.Window --- 49,62 ---- local parent = nil if wx.wxCHECK_VERSION(2,7,0) then ! if event:GetHtmlParser() and event:GetHtmlParser():GetWindowInterface() ! and event:GetHtmlParser():GetWindowInterface():GetHTMLWindow() then ! ! parent = event:GetHtmlParser():GetWindowInterface():GetHTMLWindow() ! else ! print("FIXME: wxWidgets does not provide the html window for print previews?") ! print("1:", event:GetHtmlParser()) ! print("2:", event:GetHtmlParser():GetWindowInterface()) ! print("3:", event:GetHtmlParser():GetWindowInterface():GetHTMLWindow()) ! end else parent = event.HtmlParser.Window *************** *** 62,66 **** wnd:Show(true) - print(wnd, type(fl)) -- create the container widget cell local widget = wx.wxHtmlWidgetCell(wnd, fl) --- 71,74 ---- *************** *** 74,78 **** -- 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 ) --- 82,86 ---- -- create the frame window ! frame = wx.wxFrame( wx.wxNull, wx.wxID_ANY, "wxLuaHtmlWindow Demo", wx.wxDefaultPosition, wx.wxSize(450, 450), wx.wxDEFAULT_FRAME_STYLE ) *************** *** 94,98 **** menuBar:Append(helpMenu, "&Help") ! -- insert the menu bar into the frame frame.MenuBar = menuBar --- 102,106 ---- menuBar:Append(helpMenu, "&Help") ! -- insert the menu bar into the frame using the %property binding tag (eg. SetMenubar function) frame.MenuBar = menuBar *************** *** 133,136 **** --- 141,146 ---- html = wx.wxLuaHtmlWindow(frame) + -- Override the virtual function + -- virtual void wxLuaHtmlWindow::OnSetTitle(const wxString& title) html.OnSetTitle = function(self, title) frame.Title = frame.Title.." - "..title *************** *** 140,144 **** -- 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 --- 150,154 ---- -- 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 *************** *** 152,155 **** wx.wxGetApp().TopWindow = frame frame:Show(true) - - --- 162,163 ---- Index: dialog.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/dialog.wx.lua,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** dialog.wx.lua 8 Mar 2007 20:34:04 -0000 1.10 --- dialog.wx.lua 1 May 2007 14:23:35 -0000 1.11 *************** *** 46,50 **** flexGridSizer:AddWindow( staticText, 0, wx.wxALIGN_CENTER_VERTICAL+wx.wxALL, 5 ) flexGridSizer:AddWindow( textCtrl, 0, wx.wxGROW+wx.wxALIGN_CENTER+wx.wxALL, 5 ) ! flexGridSizer:AddWindow( button, 0, wx.wxALIGN_CENTER+wx.wxALL, 5 ) return textCtrl --- 46,50 ---- flexGridSizer:AddWindow( staticText, 0, wx.wxALIGN_CENTER_VERTICAL+wx.wxALL, 5 ) flexGridSizer:AddWindow( textCtrl, 0, wx.wxGROW+wx.wxALIGN_CENTER+wx.wxALL, 5 ) ! flexGridSizer:AddWindow( button, 0, wx.wxGROW+wx.wxALIGN_CENTER+wx.wxALL, 5 ) return textCtrl *************** *** 112,117 **** -- NOTE: Since we Connect() the about and close buttons after this they will be -- called first and unless we call event:Skip() in their handlers the ! -- events will never reach this function. Therefore we don't bother to ! -- check that the ids are only from temp conversion buttons. dialog:Connect(wx.wxID_ANY, wx.wxEVT_COMMAND_BUTTON_CLICKED, --- 112,117 ---- -- NOTE: Since we Connect() the about and close buttons after this they will be -- called first and unless we call event:Skip() in their handlers the ! -- events will never reach this function. Therefore we don't need to ! -- check that the ids are only from temp conversion buttons. dialog:Connect(wx.wxID_ANY, wx.wxEVT_COMMAND_BUTTON_CLICKED, *************** *** 137,144 **** local Tc, Tk, Tf, Tr = TempCase[event:GetId()]() ! celsiusTextCtrl:SetValue(string.format("%.3f", Tc)) ! kelvinTextCtrl:SetValue(string.format("%.3f", Tk)) fahrenheitTextCtrl:SetValue(string.format("%.3f", Tf)) ! rankineTextCtrl:SetValue(string.format("%.3f", Tr)) end end) --- 137,144 ---- local Tc, Tk, Tf, Tr = TempCase[event:GetId()]() ! celsiusTextCtrl:SetValue( string.format("%.3f", Tc)) ! kelvinTextCtrl:SetValue( string.format("%.3f", Tk)) fahrenheitTextCtrl:SetValue(string.format("%.3f", Tf)) ! rankineTextCtrl:SetValue( string.format("%.3f", Tr)) end end) Index: tree.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/tree.wx.lua,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** tree.wx.lua 21 Dec 2006 20:14:21 -0000 1.8 --- tree.wx.lua 1 May 2007 14:23:35 -0000 1.9 *************** *** 54,58 **** -- create our treectrl tree = wx.wxTreeCtrl( frame, wx.wxID_ANY, ! wx.wxDefaultPosition, wx.wxDefaultSize, wx.wxTR_LINES_AT_ROOT + wx.wxTR_HAS_BUTTONS ) --- 54,58 ---- -- create our treectrl tree = wx.wxTreeCtrl( frame, wx.wxID_ANY, ! wx.wxDefaultPosition, wx.wxSize(-1, 200), wx.wxTR_LINES_AT_ROOT + wx.wxTR_HAS_BUTTONS ) Index: coroutine.wx.lua =================================================================== RCS file: /cvsroot/wxlua/wxLua/samples/coroutine.wx.lua,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** coroutine.wx.lua 21 Dec 2006 20:14:20 -0000 1.4 --- coroutine.wx.lua 1 May 2007 14:23:35 -0000 1.5 *************** *** 13,42 **** ProgressWindow = { ! -- The 'wxDialog' being encapsulated by this class. dialog = nil, ! -- The label telling what's going on ("Processing thing 7/88...") label = nil, } ! -- The constructor. 'parent' is the parent window. 'workCoroutine' is the ! -- coroutine used to process whatever is desired. 'caption' is the caption to be ! -- used for this window. 'initialLabel' is the string that will be initially ! -- shown in the window. ! function ProgressWindow:new (parent, workCoroutine, caption, initialLabel) -- 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) local o = { } ! setmetatable (o, self) self.__index = self ! -- Check parameters ! assert (type (workCoroutine) == "thread") ! assert (type (caption) == "string") ! assert (type (initialLabel) == "string") -- Create dialog --- 13,43 ---- ProgressWindow = { ! -- The 'wxDialog' being encapsulated by this "class". dialog = nil, ! -- The label telling what's going on ("Processing 7/10...") label = nil, } ! -- The constructor for the progress dialog. ! -- 'parent' is the parent window. ! -- 'workCoroutine' is the coroutine used to process whatever is desired. ! -- 'caption' is the caption to be used for this window. ! -- 'initialLabel' is the string that will be initially shown in the window. ! function ProgressWindow:new(parent, workCoroutine, caption, initialLabel) -- simple little sanity test to ensure that we can call binding functions ! -- fails on r:SetX if wx bindings aren't installed correctly for the coroutine local r = wx.wxRect(1,2,3,4) r:SetX(1) local o = { } ! setmetatable(o, self) self.__index = self ! -- Check input parameters ! assert(type(workCoroutine) == "thread") ! assert(type(caption) == "string") ! assert(type(initialLabel) == "string") -- Create dialog *************** *** 45,51 **** wx.wxDEFAULT_DIALOG_STYLE) ! o.label = wx.wxTextCtrl (o.dialog, wx.wxID_ANY, "", ! wx.wxDefaultPosition, wx.wxDefaultSize, ! wx.wxTE_MULTILINE + wx.wxTE_READONLY) local mainSizer = wx.wxBoxSizer(wx.wxVERTICAL) mainSizer:AddWindow(o.label, 1, wx.wxGROW) --- 46,52 ---- wx.wxDEFAULT_DIALOG_STYLE) ! o.label = wx.wxTextCtrl(o.dialog, wx.wxID_ANY, "", ! wx.wxDefaultPosition, wx.wxDefaultSize, ! wx.wxTE_MULTILINE + wx.wxTE_READONLY) local mainSizer = wx.wxBoxSizer(wx.wxVERTICAL) mainSizer:AddWindow(o.label, 1, wx.wxGROW) *************** *** 53,64 **** -- 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() --- 54,65 ---- -- 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() *************** *** 74,79 **** -- Sets the ProgressWindow's "status". For now, this means "change the text" -- being displayed in the window (usually something like "Doing this thing"). ! function ProgressWindow:setStatus (label) ! self.label:AppendText ("\n"..label) end --- 75,80 ---- -- Sets the ProgressWindow's "status". For now, this means "change the text" -- being displayed in the window (usually something like "Doing this thing"). ! function ProgressWindow:setStatus(label) ! self.label:AppendText("\n"..label) end *************** *** 85,89 **** local ID_THE_BUTTON = wx.wxID_HIGHEST + 100 ! frame = wx.wxFrame (wx.wxNull, wx.wxID_ANY, "wxLua Idle Events and Coroutines") --- 86,90 ---- local ID_THE_BUTTON = wx.wxID_HIGHEST + 100 ! frame = wx.wxFrame(wx.wxNull, wx.wxID_ANY, "wxLua Idle Events and Coroutines") *************** *** 123,144 **** panel = wx.wxPanel(frame, wx.wxID_ANY) ! button = wx.wxButton (panel, ID_THE_BUTTON, "Perform some long operation") ! 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() --- 124,145 ---- panel = wx.wxPanel(frame, wx.wxID_ANY) ! button = wx.wxButton(panel, ID_THE_BUTTON, "Perform some long operation") ! 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() *************** *** 147,149 **** -- Show the main frame ! frame:Show (true) --- 148,150 ---- -- Show the main frame ! frame:Show(true) |