Attached is a patch and some extra files to fix our ObjectPreviouslyDeleted crasher with the paint method. As discussed, it just re-implements the method in Ruby. I created a directory lib/wx/classes as a place to hold Ruby extensions to the API. The attached app.rb and window.rb files should be added to it. When this patch is applied, files in that directory are automatically required on startup. Hopefully this provides a framework for fixes and API improvements in Ruby. As an example, I''m thinking of writing something like ConfigBase to go in here, as I think persistent app settings it''s useful to have in a GUI library, but the WxWidgets library requires some typemaps and is clunky too. The patch also fixes dialog.rb to use paint again, and removes an unnecessary global in that sample. alex -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: window_paint.patch Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20061021/e662636f/attachment.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: window.rb Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20061021/e662636f/attachment-0001.pl -------------- next part -------------- An embedded and charset-unspecified text was scrubbed... Name: app.rb Url: http://rubyforge.org/pipermail/wxruby-development/attachments/20061021/e662636f/attachment-0002.pl
> I created a directory lib/wx/classes as a place to hold Ruby extensions > to the API. The attached app.rb and window.rb files should be added to > it. When this patch is applied, files in that directory are > automatically required on startup.Sounds like a good plan to me.> As an example, I''m thinking of writing something like ConfigBase > to go in here, as I think persistent app settings it''s useful to have in > a GUI library, but the WxWidgets library requires some typemaps and is > clunky too.I think this is a very good idea as every app needs to store some kind of app settings, last window position, recent files, preferences etc. Sean
I applied the patch and added the app.rb and window.rb files. On the dialogs sample I had to change on_paint to the following to get it to work. def on_paint(event) dc = PaintDC.new(self) dc.set_text_foreground( get_app.canvas_text_colour ) dc.set_font( get_app.canvas_font ) dc.draw_text("Windows common dialogs test application", 10, 10) end Besides that change things seem to be working fine. Sean
Sean Long wrote:> I applied the patch and added the app.rb and window.rb files. > > On the dialogs sample I had to change on_paint to the following to get > it to work. >what''s the error you get with paint { ... } ? a
Alex Fenton wrote:> Attached is a patch and some extra files to fix our > ObjectPreviouslyDeleted crasher with the paint method. As discussed, it > just re-implements the method in Ruby.Cool.> > I created a directory lib/wx/classes as a place to hold Ruby extensions > to the API. The attached app.rb and window.rb files should be added to > it. When this patch is applied, files in that directory are > automatically required on startup.I like it.> Hopefully this provides a framework for fixes and API improvements in > Ruby. As an example, I''m thinking of writing something like ConfigBase > to go in here, as I think persistent app settings it''s useful to have in > a GUI library, but the WxWidgets library requires some typemaps and is > clunky too.Not sure about that. I haven''t looked, but one would hope that there is a non-GUI-specific persistent-app-setting library we could point people to, instead of inventing our own. If we do invent our own, I would encourage it to be distinct from wxruby, as it could be equally useful to curses or ruby-gtk apps. Kevin
> Not sure about that. I haven''t looked, but one would hope that there is > a non-GUI-specific persistent-app-setting library we could point people > to, instead of inventing our own. If we do invent our own, I would > encourage it to be distinct from wxruby, as it could be equally useful > to curses or ruby-gtk apps.Funnily enough, this came up on c.l.r, and seems Joel Vanderwerf wrote something for FxRuby http://redshift.sourceforge.net/preferences/ The licence isn''t clear, and it seems intended to work with objects that have symmetric (rubyish) setters and getters, which we don''t. But maybe a starting point. alex
Alex Fenton wrote:> Funnily enough, this came up on c.l.r, and seems Joel Vanderwerf wrote > something for FxRuby > > http://redshift.sourceforge.net/preferences/ > > The licence isn''t clear,The intro.txt file says it''s under the "Ruby License".> and it seems intended to work with objects that > have symmetric (rubyish) setters and getters, which we don''t. But maybe > a starting point.It might not be able to directly persist some/all standard wx classes, but it certainly seems like it would meet the needs of most apps that want to save some settings in a standard place. And it looks like it does a good job with cross-platform directories. Looks like a winner if it actually does what it says it does. Kevin
Apparently Analagous Threads
- ObjectPreviouslyDeleted when trying to paint
- [709] trunk/wxruby2/samples/dialogs/dialogs.rb: Use paint method again, remove unnecessary global (Alex Fenton)
- [739] trunk/wxruby2/samples/dialogs/dialogs.rb: Changed back to using block version of paint in on_paint method.
- update on samples
- [736] trunk/wxruby2/samples/dialogs/dialogs.rb: Fixed crashing bug in on_paint and made the code style more Ruby like.