wxruby3 0.9.0 → 0.9.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (74) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxruby3/include/wxruby-runtime.h +3 -0
  3. data/ext/wxruby3/swig/common.i +22 -0
  4. data/ext/wxruby3/swig/custom/director.swg +296 -0
  5. data/ext/wxruby3/swig/custom/rubyapi.swg +19 -0
  6. data/ext/wxruby3/swig/custom/rubyerrors.swg +45 -0
  7. data/ext/wxruby3/swig/custom/rubyhead.swg +192 -0
  8. data/ext/wxruby3/swig/custom/rubyrun.swg +187 -0
  9. data/ext/wxruby3/swig/custom/swigrun.swg +363 -0
  10. data/ext/wxruby3/swig/custom/typemaps/swigtypemaps.swg +173 -0
  11. data/ext/wxruby3/swig/wx.i +50 -30
  12. data/lib/wx/core/const.rb +83 -0
  13. data/lib/wx/doc/const.rb +66 -66
  14. data/lib/wx/doc/event.rb +0 -6
  15. data/lib/wx/doc/functions.rb +9 -9
  16. data/lib/wx/doc/window.rb +5 -0
  17. data/lib/wx/keyword_defs.rb +43 -6
  18. data/lib/wx/version.rb +1 -1
  19. data/rakelib/lib/config/macosx.rb +1 -1
  20. data/rakelib/lib/core/include/funcall.inc +33 -14
  21. data/rakelib/lib/core/include/swigdirector.inc +384 -0
  22. data/rakelib/lib/core/include/swigrubyerrors.inc +161 -0
  23. data/{ext/wxruby3/swig/custom/swig4/rubyrun.swg → rakelib/lib/core/include/swigrubyrun.inc} +245 -120
  24. data/rakelib/lib/core/include/swigrun.inc +700 -0
  25. data/rakelib/lib/core/package.rb +5 -2
  26. data/rakelib/lib/core/parameter.rb +3 -0
  27. data/rakelib/lib/director/accelerator.rb +1 -1
  28. data/rakelib/lib/director/animation.rb +1 -1
  29. data/rakelib/lib/director/animation_ctrl.rb +20 -0
  30. data/rakelib/lib/director/app.rb +23 -5
  31. data/rakelib/lib/director/art_provider.rb +1 -1
  32. data/rakelib/lib/director/data_object_simple_base.rb +1 -2
  33. data/rakelib/lib/director/dialog.rb +5 -0
  34. data/rakelib/lib/director/dialup_event.rb +44 -0
  35. data/rakelib/lib/director/dialup_manager.rb +45 -0
  36. data/rakelib/lib/director/event.rb +20 -2
  37. data/rakelib/lib/director/file_ctrl.rb +35 -0
  38. data/rakelib/lib/director/file_ctrl_event.rb +26 -0
  39. data/rakelib/lib/director/gdicommon.rb +19 -1
  40. data/rakelib/lib/director/grid_cell_editor.rb +6 -6
  41. data/rakelib/lib/director/help_controller.rb +1 -1
  42. data/rakelib/lib/director/pgarray_editor_dialog.rb +0 -6
  43. data/rakelib/lib/director/pgeditor.rb +2 -2
  44. data/rakelib/lib/director/pgproperties.rb +2 -2
  45. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  46. data/rakelib/lib/director/richtext_ctrl.rb +1 -1
  47. data/rakelib/lib/director/sash_event.rb +42 -0
  48. data/rakelib/lib/director/sizer.rb +64 -1
  49. data/rakelib/lib/director/sizer_item.rb +22 -0
  50. data/rakelib/lib/director/task_bar_icon.rb +1 -1
  51. data/rakelib/lib/director/tree_ctrl.rb +19 -44
  52. data/rakelib/lib/generate/doc/animation_ctrl.yaml +15 -0
  53. data/rakelib/lib/generate/doc/events.yaml +10 -4
  54. data/rakelib/lib/generate/doc/static_box.yaml +8 -0
  55. data/rakelib/lib/generate/doc/xml_resource.yaml +3 -0
  56. data/rakelib/lib/generate/doc.rb +14 -3
  57. data/rakelib/lib/generate/interface.rb +4 -3
  58. data/rakelib/lib/specs/interfaces.rb +5 -1
  59. data/rakelib/lib/swig_runner.rb +4 -50
  60. data/rakelib/lib/typemap/common.rb +24 -9
  61. data/rakelib/lib/typemap/data_format.rb +1 -1
  62. data/rakelib/lib/typemap/data_object_data.rb +2 -2
  63. data/rakelib/lib/typemap/pgprop_arg.rb +7 -2
  64. data/rakelib/lib/typemap/points_list.rb +5 -7
  65. data/rakelib/lib/util/string.rb +10 -8
  66. data/samples/text/richtext.rb +0 -30
  67. data/tests/test_app_exit_exception.rb +36 -0
  68. data/tests/test_app_init_exception.rb +20 -0
  69. data/tests/test_book_controls.rb +29 -0
  70. data/tests/test_exceptions.rb +41 -0
  71. data/tests/test_sizer.rb +43 -0
  72. data/tests/test_std_controls.rb +36 -0
  73. metadata +25 -4
  74. data/ext/wxruby3/swig/custom/swig3/rubyrun.swg +0 -456
@@ -54,7 +54,7 @@ module WXRuby3
54
54
  int swig_res = SWIG_ConvertPtr(result, &ptr, $1_descriptor, 0 | SWIG_POINTER_DISOWN);
55
55
  if (!SWIG_IsOK(swig_res))
56
56
  {
57
- Swig::DirectorTypeMismatchException::raise(rb_eTypeError,
57
+ Swig::DirectorTypeMismatchException::raise(swig_get_self(), "$symname", rb_eTypeError,
58
58
  "create_popup_menu must return a Wx::Menu, or nil");
59
59
  }
60
60
  $result = reinterpret_cast < wxMenu * > (ptr);
@@ -17,13 +17,31 @@ module WXRuby3
17
17
  include Typemap::TreeItemId
18
18
 
19
19
  def setup
20
- spec.post_processors << :fixtreectrl
21
20
  spec.items.replace %w[wxTreeCtrl treebase.h]
22
21
  spec.override_inheritance_chain('wxTreeCtrl', %w[wxControl wxWindow wxEvtHandler wxObject])
23
22
  # mixin WithImages
24
23
  spec.include_mixin 'wxTreeCtrl', 'Wx::WithImages'
25
24
  spec.ignore('operator!=', 'operator==')
26
25
  spec.include 'wx/dirctrl.h'
26
+ # Use a custom interface class to work around the wxTreeCtrl::SortItems/OnCompareItems issue
27
+ # without having to patch the SWIG director class
28
+ spec.add_header_code <<~__HEREDOC
29
+ class WxRubyTreeCtrl : public wxTreeCtrl
30
+ {
31
+ public:
32
+ WxRubyTreeCtrl() : wxTreeCtrl() {}
33
+ WxRubyTreeCtrl(wxWindow* parent, wxWindowID id = wxID_ANY, const wxPoint& pos = wxDefaultPosition,
34
+ const wxSize& size = wxDefaultSize, long style = wxTR_DEFAULT_STYLE,
35
+ const wxValidator& validator = wxDefaultValidator, const wxString& name = wxTreeCtrlNameStr)
36
+ : wxTreeCtrl(parent, id, pos, size, style, validator, name)
37
+ {}
38
+ virtual ~WxRubyTreeCtrl() {}
39
+ private:
40
+ DECLARE_DYNAMIC_CLASS(WxRubyTreeCtrl);
41
+ };
42
+ IMPLEMENT_DYNAMIC_CLASS(WxRubyTreeCtrl, wxTreeCtrl);
43
+ __HEREDOC
44
+ spec.use_class_implementation('wxTreeCtrl', 'WxRubyTreeCtrl')
27
45
  # These only differ from SetXXXList in the way memory ownership is
28
46
  # transferred. So only support the version that won't leak on wxRuby.
29
47
  spec.ignore %w[
@@ -371,47 +389,4 @@ module WXRuby3
371
389
 
372
390
  end # class Director
373
391
 
374
- module SwigRunner
375
- class Processor
376
-
377
- # special post-processor for TreeCtrl
378
- class Fixtreectrl < Processor
379
-
380
- def run
381
- director_found = false
382
- update_source do |line|
383
- # Ugly: special fixes for TreeCtrl - these macros and extra funcs
384
- # are needed to allow user-defined sorting to work
385
- # default ctor needed for Swig::Director
386
- if line["Director(VALUE self) : swig_self(self), swig_disown_flag(false)"]
387
- line = " Director() { } // added by fixmodule.rb \n" + line
388
- end
389
- if line["SwigDirector_wxTreeCtrl::SwigDirector_wxTreeCtrl(VALUE self)"]
390
- line = "IMPLEMENT_DYNAMIC_CLASS(SwigDirector_wxTreeCtrl, wxTreeCtrl);\n" + line
391
- director_found = true
392
- end
393
-
394
- line
395
- end
396
- if director_found
397
- # We also need to tweak the header file
398
- update_header do |line|
399
- if line.strip == 'public:'
400
- line << "\nSwigDirector_wxTreeCtrl() {};"
401
- elsif /\A};/ =~ line
402
- line = <<~__HEREDOC
403
- private:
404
- DECLARE_DYNAMIC_CLASS(SwigDirector_wxTreeCtrl);
405
- };
406
- __HEREDOC
407
- end
408
- line
409
- end
410
- end
411
- end
412
- end # class Fixtreectrl
413
-
414
- end
415
- end
416
-
417
392
  end # module WXRuby3
@@ -0,0 +1,15 @@
1
+ ---
2
+ :wxAnimationBundle:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ animationCtrl = Wx::AnimationCtrl.new(parent, Wx::ID_ANY)
11
+ animations = Wx::AnimationBundle.new
12
+ animations.add("throbber.gif")
13
+ animations.add("throbber_2x.gif")
14
+ animationCtrl.play if animationCtrl.set_animation(animations)
15
+ ```
@@ -57,6 +57,16 @@
57
57
  if event.get_modifiers == Wx::KeyModifier::MOD_CONTROL
58
58
  # ... handle Ctrl-XXX ...
59
59
  ```
60
+ :wxKeyEvent.GetRawKeyCode:
61
+ :detail:
62
+ :post:
63
+ - :pattern: !ruby/regexp /,\s+use\s+\#ifdef\s+\{Wx::HAS_RAW_KEY_CODES\}.*available\./
64
+ :subst: '.'
65
+ :wxKeyEvent.GetRawKeyFlags:
66
+ :detail:
67
+ :post:
68
+ - :pattern: !ruby/regexp /,\s+use\s+\#ifdef\s+\{Wx::HAS_RAW_KEY_CODES\}.*available\./
69
+ :subst: '.'
60
70
  :wxMouseEvent.GetModifiers:
61
71
  :detail:
62
72
  :pre:
@@ -114,10 +124,6 @@
114
124
  vb_pt = get_view_start # Top left corner of client
115
125
 
116
126
  Wx::RegionIterator.for_region(get_update_region) do |region_it|
117
-
118
- int vX,vY,vW,vH
119
- wxRegionIterator upd(GetUpdateRegion()) # get the update rect list
120
-
121
127
  region_it.each do |rct|
122
128
  # rct == Dimensions of client area to repaint in pixels
123
129
 
@@ -18,6 +18,14 @@
18
18
 
19
19
  end
20
20
  ```
21
+ :post:
22
+ - :pattern: !ruby/regexp /,\s+use\s+\{Wx::HAS_WINDOW_LABEL_IN_STATIC_BOX\}.*compile-time\./
23
+ :subst: '.'
24
+ :wxStaticBox.Create:
25
+ :detail:
26
+ :post:
27
+ - :pattern: !ruby/regexp /,\s+use\s+\{Wx::HAS_WINDOW_LABEL_IN_STATIC_BOX\}.*compile-time\./
28
+ :subst: '.'
21
29
  :wxStaticBox.Enable:
22
30
  :detail:
23
31
  :pre:
@@ -11,6 +11,9 @@
11
11
  Wx.log_error("Couldn't load resources!")
12
12
  end
13
13
  ```
14
+ :post:
15
+ - :pattern: !ruby/regexp /If\s+\{Wx::USE_FILESYS\}.*\)\./
16
+ :subst: 'If {Wx::Setup::USE_FILESYSTEM} is enabled, this method understands {Wx::FileSystem} URLs.'
14
17
  :wxXmlResource.LoadDialog:
15
18
  :detail:
16
19
  :pre:
@@ -172,7 +172,7 @@ module WXRuby3
172
172
  end
173
173
  end
174
174
  end
175
- text.gsub!(/WX(K_[A-Z]+)/) { "{Wx::#{$1}}"}
175
+ text.gsub!(/WX(K_[A-Z]+)/) { "{Wx::KeyCode::#{$1}}"}
176
176
  end
177
177
  if event_section?
178
178
  case text
@@ -280,7 +280,7 @@ module WXRuby3
280
280
 
281
281
  def _ident_str_to_doc(s, ref_scope = nil)
282
282
  return s if no_idents?
283
- return s if %w[wxRuby wxMSW wxOSX wxGTK wxX11].any? { |w| s.start_with?(w) }
283
+ return s if %w[wxRuby wxMSW wxOSX wxGTK wxX11 wxMac].any? { |w| s.start_with?(w) }
284
284
  nmlist = s.split('::')
285
285
  nm_str = nmlist.shift.to_s
286
286
  constnm = rb_wx_name(nm_str)
@@ -343,6 +343,7 @@ module WXRuby3
343
343
  mtd = $1
344
344
  args = _arglist_to_doc($2)
345
345
  end
346
+ # transform the scope prefix
346
347
  if DocGenerator.constants_xref_db.has_key?(constnm)
347
348
  constnm = "#{DocGenerator.constants_xref_db[constnm]['mod']}::#{constnm}"
348
349
  elsif DocGenerator.constants_xref_db.has_key?(rb_constant_name(nm_str))
@@ -355,8 +356,18 @@ module WXRuby3
355
356
  known = false
356
357
  constnm = "Wx::#{constnm}"
357
358
  end
359
+ # transform and append the element id
358
360
  if mtd.nil?
359
- if DocGenerator.constants_xref_db.has_key?(rb_wx_name(itmnm)) || !_is_method?(itmnm, nm_str)
361
+ if DocGenerator.constants_xref_db.has_key?(rb_wx_name(itmnm))
362
+ itmnm = rb_wx_name(itmnm)
363
+ # in case of enum constants the documented scope most likely omits the enum class
364
+ # which we want for correct linking for wxRuby
365
+ if DocGenerator.constants_xref_db[itmnm]['mod'].start_with?("#{constnm}::")
366
+ ["#{DocGenerator.constants_xref_db[itmnm]['mod']}::#{rb_wx_name(itmnm)}", known]
367
+ else
368
+ ["#{constnm}::#{rb_wx_name(itmnm)}", known]
369
+ end
370
+ elsif !_is_method?(itmnm, nm_str)
360
371
  ["#{constnm}::#{rb_wx_name(itmnm)}", known]
361
372
  else
362
373
  sep = _is_static_method?(nm_str, itmnm) ? '.' : '#'
@@ -590,19 +590,20 @@ module WXRuby3
590
590
  fout.puts "%constant char* #{item.name} = #{$2};"
591
591
  elsif item.value =~ /wx(Size|Point)(\(.*\))/
592
592
  frbext = init_rb_ext_file unless frbext
593
- frbext.indent { frbext.puts "#{rb_wx_name(item.name)} = Wx::#{$1}.new#{$2}" }
593
+ frbext.indent { frbext.puts "#{rb_constant_name(item.name)} = Wx::#{$1}.new#{$2}" }
594
594
  frbext.puts
595
595
  elsif item.value =~ /wx(Colour|Font)(\(.*\))/
596
596
  frbext = init_rb_ext_file unless frbext
597
597
  frbext.indent do
598
- frbext.puts "Wx.add_delayed_constant(self, :#{rb_wx_name(item.name)}) { Wx::#{$1}.new#{$2} }"
598
+ frbext.puts "Wx.add_delayed_constant(self, :#{rb_constant_name(item.name)}) { Wx::#{$1}.new#{$2} }"
599
599
  end
600
600
  frbext.puts
601
601
  elsif item.value =~ /wxSystemSettings::(\w+)\((.*)\)/
602
602
  frbext = init_rb_ext_file unless frbext
603
+ setting_mtd = $1
603
604
  args = $2.split(',').collect {|a| rb_constant_value(a) }.join(', ')
604
605
  frbext.indent do
605
- frbext.puts "Wx.add_delayed_constant(self, :#{rb_wx_name(item.name)}) { Wx::SystemSettings.#{rb_method_name($1)}(#{args}) }"
606
+ frbext.puts "Wx.add_delayed_constant(self, :#{rb_constant_name(item.name)}) { Wx::SystemSettings.#{rb_method_name(setting_mtd)}(#{args}) }"
606
607
  end
607
608
  frbext.puts
608
609
  else
@@ -153,6 +153,8 @@ module WXRuby3
153
153
  Director.Spec(pkg, 'wxFileDirPickerEvent', director: Director::Event, requirements: Director.AnyOf(%w[wxUSE_DIRDLG wxUSE_DIRPICKERCTRL], %w[wxUSE_FILEDLG wxUSE_FILEPICKERCTRL]))
154
154
  Director.Spec(pkg, 'wxDirPickerCtrl', requirements: %w[wxUSE_DIRDLG wxUSE_DIRPICKERCTRL])
155
155
  Director.Spec(pkg, 'wxFilePickerCtrl', requirements: %w[wxUSE_FILEDLG wxUSE_FILEPICKERCTRL])
156
+ Director.Spec(pkg, 'wxFileCtrl', requirements: %w[wxUSE_FILECTRL])
157
+ Director.Spec(pkg, 'wxFileCtrlEvent', requirements: %w[wxUSE_FILECTRL])
156
158
  Director.Spec(pkg, 'wxProgressDialog', director: Director::Dialog)
157
159
  Director.Spec(pkg, 'wxWindowDisabler')
158
160
  Director.Spec(pkg, 'wxBusyInfo', requirements: %w[wxUSE_BUSYINFO])
@@ -176,7 +178,7 @@ module WXRuby3
176
178
  Director.Spec(pkg, 'wxTimePickerCtrl', requirements: %w[wxUSE_TIMEPICKCTRL])
177
179
  Director.Spec(pkg, 'wxTimerEvent', director: Director::Event, requirements: %w[wxUSE_TIMER])
178
180
  Director.Spec(pkg, 'wxTimer', requirements: %w[wxUSE_TIMER])
179
- Director.Spec(pkg, 'wxSashEvent', director: Director::Event, requirements: %w[wxUSE_SASH])
181
+ Director.Spec(pkg, 'wxSashEvent', requirements: %w[wxUSE_SASH])
180
182
  Director.Spec(pkg, 'wxSashWindow', requirements: %w[wxUSE_SASH])
181
183
  Director.Spec(pkg, 'wxSashLayoutWindow', requirements: %w[wxUSE_SASH])
182
184
  Director.Spec(pkg, 'wxQueryLayoutInfoEvent', director: Director::SashLayoutEvent)
@@ -223,6 +225,8 @@ module WXRuby3
223
225
  Director.Spec(pkg, 'wxBannerWindow', requirements: %w[wxUSE_BANNERWINDOW])
224
226
  Director.Spec(pkg, 'wxInfoBar', requirements: %w[wxUSE_INFOBAR])
225
227
  Director.Spec(pkg, 'wxFileSystem', requirements: %w[wxUSE_FILESYSTEM])
228
+ Director.Spec(pkg, 'wxDialUpManager', requirements: %w[wxUSE_DIALUP_MANAGER])
229
+ Director.Spec(pkg, 'wxDialUpEvent', requirements: %w[wxUSE_DIALUP_MANAGER])
226
230
  }
227
231
 
228
232
  Director.Package('Wx::PRT', 'wxUSE_PRINTING_ARCHITECTURE') do |pkg|
@@ -224,6 +224,10 @@ module WXRuby3
224
224
  name = $1
225
225
  line['rb_funcall'] = 'wxRuby_Funcall'
226
226
  line[name] = '"%s"' % rb_method_name(name[1..-2])
227
+ # director output exceptions
228
+ when /Swig::DirectorTypeMismatchException::raise\(swig_get_self\(\),\s+\"(\w+)\"/
229
+ name = $1
230
+ line[%Q{"#{name}"}] = %Q{"#{rb_method_name(name)}"}
227
231
  # defined alias methods (original method name)
228
232
  when /rb_define_alias\s*\(.*"[_a-zA-Z0-9]+[=\?]?".*("[_a-zA-Z0-9]*[=\?\!]?")/
229
233
  name = $1
@@ -275,9 +279,6 @@ module WXRuby3
275
279
  core_name = name
276
280
  core_name = 'ruby3' if /\Awx\Z/i =~ core_name
277
281
 
278
- skip_entire_method = false
279
- brace_level = 0
280
-
281
282
  fix_enum = false
282
283
  enum_item = nil
283
284
 
@@ -288,45 +289,12 @@ module WXRuby3
288
289
  # all following fixes are applicable only before we reached the
289
290
  # Init_ function
290
291
 
291
- # comment out swig_up because it is defined global in every module
292
- if (line.index("bool Swig::Director::swig_up"))
293
- line = "//" + line
294
- end
295
-
296
- if line =~ /char\* type_name = (RSTRING\(value\)->ptr|RSTRING_PTR\(value\));/
297
- line = ""
298
- end
299
- # Patch submitted for SWIG 1.3.30
300
- if (line.index("if (strcmp(type->name, type_name) == 0) {"))
301
- line = " if ( value != Qnil && rb_obj_is_kind_of(obj, sklass->klass) ) {"
302
- end
303
- #TODO 1.3.30
304
- # end
305
-
306
292
  # Fix the class names used to determine derived/non-derived in 'initialize' ('new')
307
293
  # wrappers
308
294
  if line =~ /const\s+char\s+\*classname\s+SWIGUNUSED\s+=\s+"Wx#{core_name}::wx(\w+)";/
309
295
  line.sub!(/\"Wx#{core_name}::wx#{$1}/, "\"#{package.fullname}::#{$1}")
310
296
  end
311
297
 
312
- # remove the UnknownExceptionHandler::handler method
313
- if line.index('void UnknownExceptionHandler::handler()')
314
- skip_entire_method = true
315
- end
316
-
317
- if (skip_entire_method)
318
- line = "//#{line}"
319
- if (line.index('{'))
320
- brace_level += 1
321
- end
322
- if (line.index('}'))
323
- brace_level -= 1
324
- end
325
- if (brace_level == 0)
326
- skip_entire_method = false
327
- end
328
- end
329
-
330
298
  # at the top of our Init_ function, make sure we only initialize
331
299
  # ourselves once
332
300
  if /void\s+Init_(wx|Wx)#{core_name}\(/ =~ line
@@ -358,20 +326,6 @@ module WXRuby3
358
326
  line << "\n wxRuby_SetSwigTypeForClass(#{$2}.klass, #{$1});"
359
327
  end
360
328
 
361
- # TODO : can we improve this?
362
- # Fix for Event.i - because it is implemented with a custom Ruby
363
- # subclass, need to make this subclass SWIG info available under
364
- # the normal name "SWIGTYPE_p_wxEvent" as it's referenced by many
365
- # other classes.
366
- if core_name == 'Event' or core_name == 'CommandEvent'
367
- if line[/SWIG_TypeClientData\(SWIGTYPE_p_wxRuby(Command)?Event/]
368
- line = line +
369
- " // Inserted by fixmodule.rb\n" +
370
- line.sub(/SWIGTYPE_p_wxRuby(Command)?Event/,
371
- "SWIGTYPE_p_wx\\1Event")
372
- end
373
- end
374
-
375
329
  # check for known enumerator constants
376
330
  if (md = /rb_define_const\s*\(([^,]+),\s*"([_a-zA-Z0-9]*)"(.*)/.match(line)) # constant definition?
377
331
  if !fix_enum # not fixing one yet
@@ -215,7 +215,7 @@ module WXRuby3
215
215
  if ( TYPE($input) == T_DATA )
216
216
  {
217
217
  void* argp$argnum;
218
- SWIG_ConvertPtr($input, &argp$argnum, $1_descriptor, 1 );
218
+ SWIG_ConvertPtr($input, &argp$argnum, $1_descriptor, 0);
219
219
  $1 = reinterpret_cast< $1_basetype * >(argp$argnum);
220
220
  }
221
221
  else if ( TYPE($input) == T_ARRAY )
@@ -240,6 +240,28 @@ module WXRuby3
240
240
  __CODE
241
241
  end
242
242
 
243
+ map 'wxSize' => 'Array(Integer, Integer), Wx::Size',
244
+ 'wxPoint' => 'Array(Integer, Integer), Wx::Point' do
245
+
246
+ map_directorout code: <<~__CODE
247
+ if (TYPE($input) == T_ARRAY && RARRAY_LEN($input) == 2)
248
+ {
249
+ $result = $1_basetype(NUM2INT( rb_ary_entry($input, 0)),
250
+ NUM2INT( rb_ary_entry($input, 1)));
251
+ }
252
+ else
253
+ {
254
+ void *ptr;
255
+ int res = SWIG_ConvertPtr($input, &ptr, $&1_descriptor, SWIG_POINTER_NO_NULL);
256
+ if (!SWIG_IsOK(res)) {
257
+ Swig::DirectorTypeMismatchException::raise(swig_get_self(), "$symname", SWIG_ErrorType(SWIG_ArgError(res)), "in output value of type '""$1_type""'");
258
+ }
259
+ $result = *(reinterpret_cast< $1_type * >(ptr));
260
+ }
261
+ __CODE
262
+
263
+ end
264
+
243
265
  # Integer <> wxItemKind type mappings
244
266
 
245
267
  map 'wxItemKind' => 'Integer' do
@@ -456,12 +478,10 @@ module WXRuby3
456
478
  end
457
479
 
458
480
 
459
- # Validators must be cast to correct subclass, but internal validator
460
- # is a clone, and should not be freed, so disown after wrapping.
481
+ # Validators must be cast to correct subclass, but not owned
461
482
  map 'wxValidator*' => 'Wx::Validator' do
462
483
  map_out code: <<~__CODE
463
484
  $result = wxRuby_WrapWxObjectInRuby($1);
464
- if (!NIL_P($result)) RDATA($result)->dfree = SWIG_RubyRemoveTracking;
465
485
  __CODE
466
486
  end
467
487
 
@@ -633,11 +653,6 @@ module WXRuby3
633
653
  end
634
654
  end
635
655
 
636
- # special case bc SWIG causes trouble in Window.cpp
637
- map 'const wxRegion&', 'const wxRegion*', as: 'Wx::Region' do
638
- map_out code: '$result = wxRuby_WrapWxObjectInRuby(new wxRegion(*static_cast<const wxRegion*> ($1)));'
639
- end
640
-
641
656
  # add type mapping for wxVariant input args
642
657
  intypes = 'nil,String,Integer,Float,Time,Wx::Font,Wx::Colour,Wx::Variant,Array<WxVariant>,Array<String>,Object'
643
658
  if Config.instance.features_set?('wxUSE_PROPGRID')
@@ -63,7 +63,7 @@ module WXRuby3
63
63
  void* tmp;
64
64
  SWIG_ConvertPtr(rb_ary_entry(result, i),
65
65
  &tmp,
66
- SWIGTYPE_p_wxDataFormat, 0);
66
+ SWIGTYPE_p_wxDataFormat, 0);
67
67
  wxDataFormat* fmt = reinterpret_cast< wxDataFormat* >(tmp);
68
68
  $1[i] = *fmt;
69
69
  }
@@ -30,7 +30,7 @@ module WXRuby3
30
30
  void* argp$argnum = NULL;
31
31
  if ( TYPE($input) == T_DATA )
32
32
  {
33
- if (SWIG_IsOK(SWIG_ConvertPtr($input, &argp$argnum, $1_descriptor, $argnum-1)) && argp$argnum)
33
+ if (SWIG_IsOK(SWIG_ConvertPtr($input, &argp$argnum, $1_descriptor, 0)) && argp$argnum)
34
34
  {
35
35
  $1 = reinterpret_cast< $1_basetype * >(argp$argnum);
36
36
  }
@@ -69,7 +69,7 @@ module WXRuby3
69
69
  }
70
70
  else
71
71
  {
72
- Swig::DirectorTypeMismatchException::raise(rb_eTypeError,
72
+ Swig::DirectorTypeMismatchException::raise(swig_get_self(), "$symname", rb_eTypeError,
73
73
  "get_data_here should return a string, or nil on failure");
74
74
  }
75
75
  }
@@ -20,6 +20,11 @@ module WXRuby3
20
20
  define do
21
21
 
22
22
  map 'const wxPGPropArgCls&' => 'String,Wx::PG::PGProperty' do
23
+
24
+ add_header_code <<~__CODE
25
+ static WxRuby_ID s_pg_property_id("PGProperty");
26
+ __CODE
27
+
23
28
  map_in temp: 'wxPGPropArgCls temp = (wxPGProperty *)0', code: <<~__CODE
24
29
  if (!NIL_P($input))
25
30
  {
@@ -29,12 +34,12 @@ module WXRuby3
29
34
  }
30
35
  else if (TYPE($input) == T_DATA)
31
36
  {
32
- VALUE rb_klass = rb_const_get(mWxPG, rb_intern("PGProperty"));
37
+ VALUE rb_klass = rb_const_get(mWxPG, s_pg_property_id());
33
38
  if (rb_obj_is_kind_of($input, rb_klass))
34
39
  {
35
40
  swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(rb_klass);
36
41
  wxPGProperty *pgprop = (wxPGProperty *)0;
37
- SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&pgprop), swig_type, SWIG_POINTER_DISOWN);
42
+ SWIG_ConvertPtr($input, SWIG_as_voidptrptr(&pgprop), swig_type, 0);
38
43
  temp = wxPGPropArgCls(pgprop);
39
44
  }
40
45
  else
@@ -29,28 +29,26 @@ module WXRuby3
29
29
  add_header_code <<~__CODE
30
30
  static void wxRuby_PointArrayRubyToC(VALUE rb_arr, wxPoint wx_arr[])
31
31
  {
32
- wxPoint *wx_point;
33
32
  VALUE rb_item;
34
33
  for (int i = 0; i < RARRAY_LEN(rb_arr); i++)
35
34
  {
36
35
  rb_item = rb_ary_entry (rb_arr, i);
37
36
  if (TYPE(rb_item) == T_DATA)
38
37
  {
38
+ wxPoint *wx_point;
39
39
  SWIG_ConvertPtr (rb_item, (void **) &wx_point,
40
- SWIGTYPE_p_wxPoint, 1);
40
+ SWIGTYPE_p_wxPoint, 0);
41
+ wx_arr[i] = *wx_point;
41
42
  }
42
43
  else if (TYPE(rb_item) == T_ARRAY && RARRAY_LEN(rb_item) == 2)
43
44
  {
44
- wx_point = new wxPoint (NUM2INT( rb_ary_entry(rb_item, 0)),
45
- NUM2INT(rb_ary_entry (rb_item, 1)));
46
- // Create a ruby object so the C++ obj is freed when GC runs
47
- SWIG_NewPointerObj (wx_point, SWIGTYPE_p_wxPoint, 1);
45
+ wx_arr[i] = wxPoint (NUM2INT( rb_ary_entry(rb_item, 0)),
46
+ NUM2INT(rb_ary_entry (rb_item, 1)));
48
47
  }
49
48
  else
50
49
  {
51
50
  rb_raise(rb_eTypeError, "Wrong type for wxPoint parameter %i", i);
52
51
  }
53
- wx_arr[i] = *wx_point;
54
52
  }
55
53
  }
56
54
  __CODE
@@ -91,14 +91,18 @@ module WXRuby3
91
91
  end
92
92
 
93
93
  def rb_constant_value(name)
94
- val = name.sub(/\Awx/, 'Wx::')
95
- case val
96
- when /NULL|nullptr/
94
+ name = name.strip
95
+ case name
96
+ when /\A(null|nullptr)\Z/i
97
97
  'nil'
98
+ when /\A(true|false)\Z/i
99
+ name.downcase
98
100
  when /EmptyString/
99
101
  %q['']
102
+ when /\A\"/
103
+ name
100
104
  else
101
- val
105
+ "#{name.start_with?('wx') ? 'Wx::' : ''}#{rb_constant_name(name)}"
102
106
  end
103
107
  end
104
108
 
@@ -110,7 +114,7 @@ module WXRuby3
110
114
  ids = idstr.split('::')
111
115
  if ids.size > 1
112
116
  is_scoped = true
113
- scoped_name = rb_constant_value(ids.shift)
117
+ scoped_name = rb_wx_name(ids.shift)
114
118
  while ids.size > 1
115
119
  scoped_name << '::' << ids.shift
116
120
  end
@@ -127,7 +131,7 @@ module WXRuby3
127
131
  when 'wxString'
128
132
  '('
129
133
  else
130
- "#{rb_constant_value(idstr)}.new("
134
+ "#{idstr.start_with?('wx') ? 'Wx::' : ''}#{rb_wx_name(idstr)}.new("
131
135
  end
132
136
  end
133
137
  else
@@ -143,8 +147,6 @@ module WXRuby3
143
147
  # constant
144
148
  if /[\-\+\.\d]+/ =~ idstr
145
149
  idstr # numeric constant
146
- elsif /\A(true|false|NULL|nullptr)/ =~ idstr
147
- ($1 == 'NULL' || $1 == 'nullptr') ? 'nil' : $1
148
150
  else
149
151
  if const_xref.has_key?(rb_constant_name(idstr))
150
152
  "#{const_xref[rb_constant_name(idstr)]['mod']}::#{rb_constant_name(idstr)}"
@@ -1432,36 +1432,6 @@ class MyFrame < Wx::Frame
1432
1432
 
1433
1433
  end
1434
1434
 
1435
- # Forward command events to the current rich text control, if any
1436
- def try_before(event)
1437
- if event.is_command_event && !event.is_a?(Wx::ChildFocusEvent)
1438
- # Problem: we can get infinite recursion because the events
1439
- # climb back up to this frame, and repeat.
1440
- # Assume that command events don't cause another command event
1441
- # to be called, so we can rely on inCommand not being overwritten
1442
-
1443
- if MyFrame.win_id != event.id && MyFrame.event_type != event.event_type
1444
- MyFrame.event_type = event.event_type
1445
- MyFrame.win_id = event.id
1446
- focusWin = Wx.find_focus_descendant(self)
1447
- focusWin = @richTextCtrl unless focusWin
1448
-
1449
- if focusWin && focusWin.get_event_handler.process_event(event)
1450
- MyFrame.event_type = 0
1451
- MyFrame.win_id = 0
1452
- return true
1453
- end
1454
-
1455
- MyFrame.event_type = 0
1456
- MyFrame.win_id = 0
1457
- else
1458
- return false
1459
- end
1460
- end
1461
-
1462
- false
1463
- end
1464
-
1465
1435
  # Write text
1466
1436
  def write_initial_text
1467
1437
  r = @richTextCtrl
@@ -0,0 +1,36 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require 'test/unit'
6
+ require 'wx'
7
+
8
+ class TestApp < Test::Unit::TestCase
9
+
10
+ class TestFrame < Wx::Frame
11
+ def initialize
12
+ super(nil, -1, '')
13
+ evt_paint { on_paint }
14
+ end
15
+
16
+ def on_paint
17
+ paint {}
18
+ close
19
+ end
20
+ end
21
+
22
+ class TestApp < Wx::App
23
+ def on_init
24
+ TestFrame.new.show
25
+ end
26
+
27
+ def on_exit
28
+ raise RuntimeError, 'on_exit exception'
29
+ end
30
+ end
31
+
32
+ def test_self_closing_frame
33
+ assert_raise_kind_of(RuntimeError) { TestApp.run }
34
+ end
35
+
36
+ end
@@ -0,0 +1,20 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require 'test/unit'
6
+ require 'wx'
7
+
8
+ class AppInitExitExceptions < Test::Unit::TestCase
9
+
10
+ class TestApp < Wx::App
11
+ def on_init
12
+ raise RuntimeError, 'on_init exception'
13
+ end
14
+ end
15
+
16
+ def test_on_init_exception
17
+ assert_raise_kind_of(RuntimeError) { TestApp.run }
18
+ end
19
+
20
+ end