> Please find attached a set of patches and swig files to implement
> Wizards for wxruby. Also a brief sample.
Have not tried it yet, but a very cool feature to add.
> Quick q - the C declarations of evt_xxx_xxx methods and their attaching
> to Ruby classes seems to be duplicated across Events.i and EvtHandler.i
> - is one of these the right place to be adding them? or both?
That code is pretty messy right now and if I recall pieces from both
locations are used. In the TODO file the following item is listed.
- Eliminate massive duplication between swig/Events.i and
swig/classes/EvtHandler.i (probably by deleting what''s in Event.i).
Probably also should rename Events.i to avoid confusion with
swig/classes/Event.i.
I brought up this same question when I have to mess around with adding events.
Sean
> Thanks
> alex
>
>
> Index: wxruby2/swig/Events.i
> ==================================================================> RCS
file: /var/cvs/wxruby/wxruby2/swig/Events.i,v
> retrieving revision 1.7
> diff -b -u -r1.7 Events.i
> --- wxruby2/swig/Events.i 4 Sep 2005 16:47:54 -0000 1.7
> +++ wxruby2/swig/Events.i 25 Jul 2006 19:17:10 -0000
> @@ -559,6 +559,31 @@
> return internal_evt_with_id(argc, argv, self,
wxEVT_GRID_EDITOR_CREATED);
> }
>
> +static VALUE evt_wizard_page_changed(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self,
wxEVT_WIZARD_PAGE_CHANGED);
> +}
> +
> +static VALUE evt_wizard_page_changing(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self,
wxEVT_WIZARD_PAGE_CHANGING);
> +}
> +
> +static VALUE evt_wizard_cancel(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self, wxEVT_WIZARD_CANCEL);
> +}
> +
> +static VALUE evt_wizard_help(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self, wxEVT_WIZARD_HELP);
> +}
> +
> +static VALUE evt_wizard_finished(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self, wxEVT_WIZARD_FINISHED);
> +}
> +
> %}
>
>
> @@ -665,6 +690,11 @@
> rb_define_method(cWxEvtHandler.klass,
"evt_grid_cmd_range_select", VALUEFUNC(evt_grid_cmd_range_select),
-1);
> rb_define_method(cWxEvtHandler.klass,
"evt_grid_editor_created", VALUEFUNC(evt_grid_editor_created), -1);
> rb_define_method(cWxEvtHandler.klass,
"evt_grid_cmd_editor_created", VALUEFUNC(evt_grid_cmd_editor_created),
-1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_page_changed", VALUEFUNC(evt_wizard_page_changed), -1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_page_changing", VALUEFUNC(evt_wizard_page_changing), -1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_cancel", VALUEFUNC(evt_wizard_cancel), -1);
> + rb_define_method(cWxEvtHandler.klass, "evt_wizard_help",
VALUEFUNC(evt_wizard_help), -1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_finished", VALUEFUNC(evt_wizard_finished), -1);
> %}
>
>
>
> Index: wxruby2/swig/classes/EvtHandler.i
> ==================================================================> RCS
file: /var/cvs/wxruby/wxruby2/swig/classes/EvtHandler.i,v
> retrieving revision 1.20
> diff -b -u -r1.20 EvtHandler.i
> --- wxruby2/swig/classes/EvtHandler.i 29 Apr 2006 21:25:37 -0000
1.20
> +++ wxruby2/swig/classes/EvtHandler.i 25 Jul 2006 19:17:33 -0000
> @@ -14,6 +14,7 @@
> #include <wx/treectrl.h>
> #include <wx/splitter.h>
> #include <wx/listctrl.h>
> +#include <wx/wizard.h>
> %}
>
> %module(directors="1") wxEvtHandler
> @@ -52,6 +53,7 @@
> extern swig_class cWxSplitterEvent;
> extern swig_class cWxMoveEvent;
> extern swig_class cWxListEvent;
> +extern swig_class cWxWizardEvent;
>
> static const wxEventType *calendarEvents[] > {
> @@ -229,6 +231,16 @@
> (const wxEventType *)0
> };
>
> +static const wxEventType *wizardEvents[] > +{
> + &wxEVT_WIZARD_PAGE_CHANGED,
> + &wxEVT_WIZARD_PAGE_CHANGING,
> + &wxEVT_WIZARD_CANCEL,
> + &wxEVT_WIZARD_HELP,
> + &wxEVT_WIZARD_FINISHED,
> + (const wxEventType *)0
> +};
> +
> //IMPLEMENT_ABSTRACT_CLASS(wxRbCallback, wxObject);
>
> class wxRbCallback : public wxObject
> @@ -287,6 +299,8 @@
> cEvent = cWxMoveEvent.klass;
> else if(event.IsKindOf(CLASSINFO(wxListEvent)))
> cEvent = cWxListEvent.klass;
> + else if(event.IsKindOf(CLASSINFO(wxWizardEvent)))
> + cEvent = cWxWizardEvent.klass;
> else if(event.IsKindOf(CLASSINFO(wxCommandEvent)))
> cEvent = cWxCommandEvent.klass;
>
> @@ -878,6 +892,30 @@
> return internal_evt_with_id(argc, argv, self,
wxEVT_GRID_EDITOR_CREATED);
> }
>
> +static VALUE evt_wizard_page_changed(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self,
wxEVT_WIZARD_PAGE_CHANGED);
> +}
> +
> +static VALUE evt_wizard_page_changing(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self,
wxEVT_WIZARD_PAGE_CHANGING);
> +}
> +
> +static VALUE evt_wizard_cancel(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self, wxEVT_WIZARD_CANCEL);
> +}
> +
> +static VALUE evt_wizard_help(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self, wxEVT_WIZARD_HELP);
> +}
> +
> +static VALUE evt_wizard_finished(int argc, VALUE *argv, VALUE self)
> +{
> + return internal_evt_with_id(argc, argv, self, wxEVT_WIZARD_FINISHED);
> +}
> // TODO: Add for ListEvent types? Is this needed?
>
> %}
> @@ -986,6 +1024,12 @@
> rb_define_method(cWxEvtHandler.klass,
"evt_grid_cmd_range_select", VALUEFUNC(evt_grid_cmd_range_select),
-1);
> rb_define_method(cWxEvtHandler.klass,
"evt_grid_editor_created", VALUEFUNC(evt_grid_editor_created), -1);
> rb_define_method(cWxEvtHandler.klass,
"evt_grid_cmd_editor_created", VALUEFUNC(evt_grid_cmd_editor_created),
-1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_page_changed", VALUEFUNC(evt_wizard_page_changed), -1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_page_changing", VALUEFUNC(evt_wizard_page_changing), -1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_cancel", VALUEFUNC(evt_wizard_cancel), -1);
> + rb_define_method(cWxEvtHandler.klass, "evt_wizard_help",
VALUEFUNC(evt_wizard_help), -1);
> + rb_define_method(cWxEvtHandler.klass,
"evt_wizard_finished", VALUEFUNC(evt_wizard_finished), -1);
> +
> %}
>
> #endif
>
> Index: wxruby2/swig/fixevents.rb
> ==================================================================> RCS
file: /var/cvs/wxruby/wxruby2/swig/fixevents.rb,v
> retrieving revision 1.5
> diff -b -u -r1.5 fixevents.rb
> --- wxruby2/swig/fixevents.rb 13 Sep 2005 01:36:31 -0000 1.5
> +++ wxruby2/swig/fixevents.rb 25 Jul 2006 19:16:51 -0000
> @@ -16,8 +16,7 @@
> ''EVT_DIALUP'',
> ''EVT_SASH'',
> ''EVT_TASKBAR'',
> - ''EVT_TOGGLEBUTTON'',
> - ''EVT_WIZARD'',
> + ''EVT_TOGGLEBUTTON''
> ]
>
> File.open(ARGV[0], "a") do | out |
>
> # Copyright 2004-2005 by Kevin Smith
> # released under the MIT-style wxruby2 license
>
> %include "../common.i"
>
> %module(directors="1") wxWizardPage
>
> %{
> #include <wx/wizard.h>
> %}
>
> // no ctor b/c of abstract methods
> %ignore wxWizardPage::wxWizardPage(wxWizard* parent , const wxBitmap&
bitmap = wxNullBitmap, const wxChar *resource = NULL);
>
>
>
> %import "include/wxObject.h"
> %import "include/wxEvtHandler.h"
> %import "include/wxWindow.h"
> %import "include/wxPanel.h"
>
> %include "include/wxWizardPage.h"
>
>
> # Copyright 2004-2005 by Kevin Smith
> # released under the MIT-style wxruby2 license
>
> %include "../common.i"
>
> %module(directors="1") wxWizardEvent
>
> %{
> #include <wx/wizard.h>
> %}
>
> %import "include/wxObject.h"
> %import "include/wxEvent.h"
> %import "include/wxCommandEvent.h"
> %import "include/wxNotifyEvent.h"
>
> %include "include/wxWizardEvent.h"
>
> # Copyright 2004-2005 by Kevin Smith
> # released under the MIT-style wxruby2 license
>
> %include "../common.i"
>
> %module(directors="1") wxWizard
>
> %{
> #include <wx/wizard.h>
> %}
>
> %import "include/wxObject.h"
> %import "include/wxEvtHandler.h"
> %import "include/wxWindow.h"
> %import "include/wxPanel.h"
> %import "include/wxDialog.h"
>
> %include "include/wxWizard.h"
>
> # Copyright 2004-2005 by Kevin Smith
> # released under the MIT-style wxruby2 license
>
> %include "../common.i"
>
> %module(directors="1") wxWizardPageSimple
>
> %{
> #include <wx/wizard.h>
> %}
>
> %import "include/wxObject.h"
> %import "include/wxEvtHandler.h"
> %import "include/wxWindow.h"
> %import "include/wxPanel.h"
> %import "include/wxWizardPage.h"
>
> %include "include/wxWizardPageSimple.h"
>
> require ''wx''
>
> class MyFrame < Wx::Frame
> def initialize(title, pos, size, style = Wx::DEFAULT_FRAME_STYLE)
> super(nil, -1, title, pos, size, style)
>
>
> menuFile = Wx::Menu.new()
> helpMenu = Wx::Menu.new()
> helpMenu.append(Wx::ID_ABOUT, "&About...\tF1", "Show
about dialog")
> menuFile.append(Wx::ID_EXIT, "E&xit\tAlt-X", "Quit
this program")
> menuBar = Wx::MenuBar.new()
> menuBar.append(menuFile, "&File")
> menuBar.append(helpMenu, "&Help")
> set_menu_bar(menuBar)
>
> create_status_bar(2)
> set_status_text("Welcome to wxRuby!")
> s = Wx::StaticText.new(self, -1, ''The Wizard has
completed'')
>
>
> evt_menu(Wx::ID_EXIT) { onQuit }
> evt_menu(Wx::ID_ABOUT) { onAbout }
> w = Wx::Wizard.new(self, -1, ''The WxRuby Wizard'')
> p1 = Wx::WizardPageSimple.new(w)
> s = Wx::StaticText.new(p1, -1, ''This is the first
page'')
> p2 = Wx::WizardPageSimple.new(w, p1)
> p1.set_next(p2)
> s = Wx::StaticText.new(p2, -1, ''This is the second
page'')
> p3 = Wx::WizardPageSimple.new(w, p2)
> p2.set_next(p3)
> s = Wx::StaticText.new(p3, -1, ''This is the final
page'')
>
> evt_wizard_page_changed(w.get_id) { p "page changed" }
> evt_wizard_page_changing(w.get_id) { p "page changing" }
> evt_wizard_help(w.get_id) { p "wizard help" }
> evt_wizard_cancel(w.get_id) { p "wizard cancelled" }
> evt_wizard_finished(w.get_id) { p "wizard finished" }
>
>
> w.run_wizard(p1)
> end
>
> def onQuit
> close(Wx::TRUE)
> end
>
> def onAbout
> msg = sprintf("This is the About dialog of the wizard
sample.\n" \
> "Welcome to %s", Wx::VERSION_STRING)
> message_box(msg, "About Wizard", Wx::OK|Wx::ICON_INFORMATION,
self)
> end
> end
>
> class RbApp < Wx::App
> def on_init
> frame = MyFrame.new("Wizard wxRuby App",
> Wx::Point.new(50, 50),
> Wx::Size.new(450, 340))
>
> frame.show(TRUE)
>
> end
> end
>
> app = RbApp.new
> app.main_loop()
>
>
> _______________________________________________
> wxruby-users mailing list
> wxruby-users at rubyforge.org
> http://rubyforge.org/mailman/listinfo/wxruby-users
>
>