Skip to content

Commit

Permalink
Merge pull request #220 from mcorino/develop
Browse files Browse the repository at this point in the history
major validator improvements and extensions
  • Loading branch information
mcorino authored Nov 20, 2023
2 parents fcc0600 + abb40a1 commit 1849303
Show file tree
Hide file tree
Showing 25 changed files with 2,737 additions and 62 deletions.
39 changes: 39 additions & 0 deletions ext/wxruby3/include/wxruby-Validator.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright (c) 2023 M.J.N. Corino, The Netherlands
//
// This software is released under the MIT license.

/*
* WxRuby3 wxRubyValidator class
*/

#ifndef _WXRUBY_VALIDATOR_H
#define _WXRUBY_VALIDATOR_H

#include "wxruby-ValidatorBinding.h"

class WXRUBY_EXPORT wxRubyValidator : public wxValidator, public wxRubyValidatorBinding
{
public:
wxRubyValidator ();
wxRubyValidator (const wxRubyValidator&);
virtual ~wxRubyValidator ();

virtual wxObject* Clone() const override;

virtual void SetWindow(wxWindow *win) override;

virtual bool TransferFromWindow () override;
virtual bool TransferToWindow () override;

protected:
static WxRuby_ID do_transfer_from_window_id;
static WxRuby_ID do_transfer_to_window_id;
static WxRuby_ID clone_id;

virtual VALUE DoTransferFromWindow();
virtual bool DoTransferToWindow(VALUE data);

virtual VALUE get_self() override;
};

#endif /* _WXRUBY_VALIDATOR_HASH_H */
64 changes: 64 additions & 0 deletions ext/wxruby3/include/wxruby-ValidatorBinding.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
// Copyright (c) 2023 M.J.N. Corino, The Netherlands
//
// This software is released under the MIT license.

/*
* WxRuby3 wxRubyValidatorBinding class
*/

#ifndef _WXRUBY_VALIDATOR_BINDING_H
#define _WXRUBY_VALIDATOR_BINDING_H

class WXRUBY_EXPORT wxRubyValidatorBinding
{
public:
wxRubyValidatorBinding ()
: self_(Qnil)
, on_transfer_from_win_proc_(Qnil)
, on_transfer_to_win_proc_(Qnil)
{}

void SetOnTransferFromWindow(VALUE proc)
{
this->on_transfer_from_win_proc_ = proc;
}
void SetOnTransferToWindow(VALUE proc)
{
this->on_transfer_to_win_proc_ = proc;
}

VALUE DoOnTransferToWindow();
bool DoOnTransferFromWindow(VALUE data);

bool OnTransferFromWindow(VALUE data);
VALUE OnTransferToWindow();

void GC_Mark()
{
rb_gc_mark(this->on_transfer_from_win_proc_);
rb_gc_mark(this->on_transfer_to_win_proc_);
}

protected:
static WxRuby_ID do_on_transfer_from_window_id;
static WxRuby_ID do_on_transfer_to_window_id;
static WxRuby_ID call_id;

wxRubyValidatorBinding (const wxRubyValidatorBinding& vb)
: self_(Qnil)
, on_transfer_from_win_proc_(vb.on_transfer_from_win_proc_)
, on_transfer_to_win_proc_(vb.on_transfer_to_win_proc_)
{}

void CopyBindings(const wxRubyValidatorBinding* val_bind);

virtual VALUE get_self() = 0;

VALUE self_;

private:
VALUE on_transfer_from_win_proc_;
VALUE on_transfer_to_win_proc_;
};

#endif /* #define _WXRUBY_VALIDATOR_BINDING_H */
8 changes: 8 additions & 0 deletions ext/wxruby3/swig/custom/director.swg
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,14 @@ namespace Swig {
}
};

/* wxRuby customization */
class WXRUBY_EXPORT DirectorRubyException : public DirectorException
{
public:
DirectorRubyException(VALUE error, VALUE rcvr, ID fn_id);

};

/* Simple thread abstraction for pthreads on win32 */
#ifdef __THREAD__
# define __PTHREAD__
Expand Down
4 changes: 2 additions & 2 deletions lib/wx/core/evthandler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ def acquire_handler(meth, block)
# check arity <= 1
if h_meth.arity>1
Kernel.raise ArgumentError,
"Event handler should not accept more than at most a single argument"
"Event handler should not accept more than at most a single argument",
caller
end
# wrap method without any argument in anonymous proc to prevent strict argument checking
Expand All @@ -193,7 +193,7 @@ def acquire_handler(meth, block)
end
else
Kernel.raise ArgumentError,
"Specify event handler with a method, name, proc OR block"
"Specify event handler with a method, name, proc OR block",
caller
end
end
Expand Down
Loading

0 comments on commit 1849303

Please sign in to comment.