wxruby3 1.8.1 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +20 -10
  3. data/README.md +3 -3
  4. data/ext/wxruby3/include/wxRubyApp.h +49 -3
  5. data/ext/wxruby3/include/wxruby-ComboPopup.h +17 -32
  6. data/ext/wxruby3/include/wxruby-Config.h +34 -11
  7. data/ext/wxruby3/include/wxruby-GCTracking.h +23 -5
  8. data/ext/wxruby3/include/wxruby-SharedEventHandler.h +7 -7
  9. data/ext/wxruby3/include/wxruby-runtime.h +65 -0
  10. data/ext/wxruby3/swig/common.i +6 -0
  11. data/ext/wxruby3/swig/custom/typed_data/rubyhead.swg +220 -0
  12. data/ext/wxruby3/swig/custom/typed_data/rubyprimtypes.swg +265 -0
  13. data/ext/wxruby3/swig/custom/typed_data/rubyrun.swg +243 -0
  14. data/ext/wxruby3/swig/custom/typed_data/swigrun.swg +689 -0
  15. data/ext/wxruby3/swig/custom/{rubyprimtypes.swg → untyped_data/rubyprimtypes.swg} +8 -0
  16. data/ext/wxruby3/swig/mark_free_impl.i +2 -2
  17. data/ext/wxruby3/swig/memory_management.i +1 -0
  18. data/ext/wxruby3/swig/wx.i +19 -6
  19. data/lib/wx/core/file_dialog.rb +3 -10
  20. data/lib/wx/doc/rbn/events.rb +32 -0
  21. data/lib/wx/doc/rbn/ribbon_backstage_mrulist.rb +25 -0
  22. data/lib/wx/keyword_ctors.rb +3 -13
  23. data/lib/wx/rbn/events.rb +18 -0
  24. data/lib/wx/rbn/require.rb +1 -0
  25. data/lib/wx/rbn/ribbon_backstage_mrulist.rb +39 -0
  26. data/lib/wx/version.rb +1 -1
  27. data/rakelib/lib/config.rb +3 -3
  28. data/rakelib/lib/core/include/typed_data/swigrubyrun.inc +629 -0
  29. data/rakelib/lib/core/include/typed_data/swigrun.inc +870 -0
  30. data/rakelib/lib/core/package.rb +2 -2
  31. data/rakelib/lib/director/app.rb +16 -0
  32. data/rakelib/lib/director/art_provider.rb +3 -3
  33. data/rakelib/lib/director/aui_mdi_child_frame.rb +24 -0
  34. data/rakelib/lib/director/aui_mdi_parent_frame.rb +0 -2
  35. data/rakelib/lib/director/aui_tab_ctrl.rb +3 -3
  36. data/rakelib/lib/director/comboctrl.rb +35 -2
  37. data/rakelib/lib/director/config_base.rb +79 -33
  38. data/rakelib/lib/director/data_object.rb +1 -1
  39. data/rakelib/lib/director/date_event.rb +10 -3
  40. data/rakelib/lib/director/event.rb +16 -7
  41. data/rakelib/lib/director/event_handler.rb +48 -10
  42. data/rakelib/lib/director/events.rb +4 -2
  43. data/rakelib/lib/director/file_history.rb +46 -0
  44. data/rakelib/lib/director/frame.rb +29 -0
  45. data/rakelib/lib/director/fs_file.rb +2 -4
  46. data/rakelib/lib/director/functions.rb +2 -2
  47. data/rakelib/lib/director/graphics_context.rb +6 -6
  48. data/rakelib/lib/director/grid_cell_editor.rb +1 -1
  49. data/rakelib/lib/director/grid_cell_renderer.rb +1 -1
  50. data/rakelib/lib/director/grid_ctrl.rb +39 -12
  51. data/rakelib/lib/director/help_controller.rb +17 -0
  52. data/rakelib/lib/director/html_help_data.rb +20 -2
  53. data/rakelib/lib/director/icon.rb +3 -0
  54. data/rakelib/lib/director/log.rb +25 -1
  55. data/rakelib/lib/director/menu.rb +38 -106
  56. data/rakelib/lib/director/menu_bar.rb +36 -70
  57. data/rakelib/lib/director/num_validator.rb +3 -3
  58. data/rakelib/lib/director/numeric_property_validator.rb +1 -1
  59. data/rakelib/lib/director/page_setup_dialog.rb +18 -1
  60. data/rakelib/lib/director/pgeditor.rb +1 -1
  61. data/rakelib/lib/director/pgvalidation_info.rb +1 -0
  62. data/rakelib/lib/director/popup_window.rb +7 -0
  63. data/rakelib/lib/director/preview_frame.rb +8 -1
  64. data/rakelib/lib/director/print_dialog.rb +17 -0
  65. data/rakelib/lib/director/printer.rb +1 -1
  66. data/rakelib/lib/director/property_grid_page.rb +2 -0
  67. data/rakelib/lib/director/region_iterator.rb +1 -1
  68. data/rakelib/lib/director/ribbon_backstage.rb +28 -0
  69. data/rakelib/lib/director/ribbon_backstage_button.rb +25 -0
  70. data/rakelib/lib/director/ribbon_backstage_callout.rb +26 -0
  71. data/rakelib/lib/director/ribbon_backstage_heading.rb +26 -0
  72. data/rakelib/lib/director/ribbon_backstage_itemlist.rb +27 -0
  73. data/rakelib/lib/director/ribbon_backstage_mrulist.rb +112 -0
  74. data/rakelib/lib/director/ribbon_bar.rb +14 -0
  75. data/rakelib/lib/director/ribbon_gallery.rb +6 -2
  76. data/rakelib/lib/director/ribbon_tool_bar.rb +6 -4
  77. data/rakelib/lib/director/richtext_composite_object.rb +4 -4
  78. data/rakelib/lib/director/richtext_paragraph_layout_box.rb +1 -1
  79. data/rakelib/lib/director/scrolled_t.rb +1 -1
  80. data/rakelib/lib/director/sizer.rb +7 -0
  81. data/rakelib/lib/director/sizer_item.rb +4 -1
  82. data/rakelib/lib/director/splitter_event.rb +2 -2
  83. data/rakelib/lib/director/task_bar_icon.rb +4 -1
  84. data/rakelib/lib/director/text_validator.rb +1 -1
  85. data/rakelib/lib/director/tree_event.rb +3 -3
  86. data/rakelib/lib/director/validator.rb +1 -1
  87. data/rakelib/lib/director/variant.rb +2 -2
  88. data/rakelib/lib/director/window.rb +27 -5
  89. data/rakelib/lib/director/window_disabler.rb +1 -1
  90. data/rakelib/lib/director/xml_resource.rb +33 -8
  91. data/rakelib/lib/extractor/class.rb +2 -1
  92. data/rakelib/lib/extractor.rb +3 -2
  93. data/rakelib/lib/generate/interface.rb +2 -3
  94. data/rakelib/lib/specs/interfaces.rb +7 -0
  95. data/rakelib/lib/swig_runner.rb +14 -3
  96. data/rakelib/lib/typemap/common.rb +2 -36
  97. data/rakelib/lib/typemap/config.rb +22 -0
  98. data/samples/ribbon/ribbon.rb +277 -20
  99. data/tests/test_shared_event_handler.rb +3 -3
  100. metadata +32 -16
  101. /data/ext/wxruby3/swig/custom/{director.swg → common/director.swg} +0 -0
  102. /data/ext/wxruby3/swig/custom/{rubyapi.swg → common/rubyapi.swg} +0 -0
  103. /data/ext/wxruby3/swig/custom/{rubyerrors.swg → common/rubyerrors.swg} +0 -0
  104. /data/ext/wxruby3/swig/custom/{rubytracking.swg → common/rubytracking.swg} +0 -0
  105. /data/ext/wxruby3/swig/custom/{swiglabels.swg → common/swiglabels.swg} +0 -0
  106. /data/ext/wxruby3/swig/custom/{typemaps → common/typemaps}/swigtypemaps.swg +0 -0
  107. /data/ext/wxruby3/swig/custom/{wx_ruby_shared_ptr.i → common/wx_ruby_shared_ptr.i} +0 -0
  108. /data/ext/wxruby3/swig/custom/{wx_shared_ptr.i → common/wx_shared_ptr.i} +0 -0
  109. /data/ext/wxruby3/swig/custom/{rubyhead.swg → untyped_data/rubyhead.swg} +0 -0
  110. /data/ext/wxruby3/swig/custom/{rubyrun.swg → untyped_data/rubyrun.swg} +0 -0
  111. /data/ext/wxruby3/swig/custom/{swigrun.swg → untyped_data/swigrun.swg} +0 -0
  112. /data/rakelib/lib/core/include/{swigrubyrun.inc → untyped_data/swigrubyrun.inc} +0 -0
  113. /data/rakelib/lib/core/include/{swigrun.inc → untyped_data/swigrun.inc} +0 -0
@@ -41,7 +41,7 @@ module WXRuby3
41
41
  bool rc = $self->RemoveChild(wx_child, deleteChild);
42
42
  if (rc && !deleteChild)
43
43
  {
44
- RDATA(rb_child)->dfree = GC_RichTextObjectFreeFunc; // make sure Ruby owns
44
+ WXRUBY_WRAPPER_DATA_DFREE_SET(rb_child, GC_RichTextObjectFreeFunc); // make sure Ruby owns
45
45
  }
46
46
  return rc;
47
47
  }
@@ -92,10 +92,10 @@ module WXRuby3
92
92
 
93
93
  static const rb_data_type_t __wxRichTextFloatCollector_type = {
94
94
  "RichTextFloatCollector",
95
- #if RUBY_API_VERSION_MAJOR >= 3
96
- { NULL, NULL, __wxRichTextFloatCollector_size, 0, {}},
95
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
96
+ { NULL, NULL, __wxRichTextFloatCollector_size, 0, 0, {}},
97
97
  #else
98
- { NULL, NULL, __wxRichTextFloatCollector_size, {}},
98
+ { NULL, NULL, __wxRichTextFloatCollector_size, 0, {}},
99
99
  #endif
100
100
  NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
101
101
  };
@@ -46,7 +46,7 @@ module WXRuby3
46
46
  static void wxRuby_MakeRichTextStyleDefinitionOwned(VALUE rb_rtsd)
47
47
  {
48
48
  swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(CLASS_OF(rb_rtsd));
49
- RDATA(rb_rtsd)->dfree = ((swig_class *) swig_type->clientdata)->destroy; // make sure Ruby owns
49
+ WXRUBY_WRAPPER_DATA_DFREE_SET(rb_rtsd, ((swig_class *) swig_type->clientdata)->destroy); // make sure Ruby owns
50
50
  }
51
51
 
52
52
  extern VALUE wxRuby_RichTextStyleDefinition2Ruby(const wxRichTextStyleDefinition *wx_rtsd, int own)
@@ -61,7 +61,7 @@ module WXRuby3
61
61
  end
62
62
  spec.ignore 'wxScrolled::OnDraw'
63
63
  spec.ignore 'wxScrolled::GetViewStart(int *,int *)'
64
- if Config.instance.wx_version_check('3.3.2') >= 0
64
+ if Config.instance.wx_version_check('3.3.2') >= 0 && Config.instance.wx_version_check('3.3.4') <= 0
65
65
  spec.ignore 'wxScrolled::GetViewStartPixels(int *,int *) const'
66
66
  end
67
67
  spec.map_apply 'int * OUTPUT' => 'int *'
@@ -96,6 +96,9 @@ module WXRuby3
96
96
  return rc;
97
97
  }
98
98
  __HEREDOC
99
+ if Config.instance.wx_version_check('3.3.3') >= 0
100
+ spec.new_object 'wxSizer::DetachItem(size_t)'
101
+ end
99
102
  # Typemap for GetChildren - convert to array of Sizer items
100
103
  spec.map 'wxSizerItemList&' => 'Array<Wx::SizerItem>' do
101
104
  map_out code: <<~__CODE
@@ -171,6 +174,10 @@ module WXRuby3
171
174
  #{spec.module_name}::Layout
172
175
  ])
173
176
  spec.no_proxy "#{spec.module_name}::AddSpacer"
177
+ if Config.instance.wx_version_check('3.3.3') >= 0
178
+ spec.suppress_warning(473, 'wxSizer::DetachItem')
179
+ spec.no_proxy 'wxSizer::DetachItem'
180
+ end
174
181
  super
175
182
  end
176
183
 
@@ -33,7 +33,10 @@ module WXRuby3
33
33
  spec.map 'wxObject*' => 'Object', swig: false do
34
34
  map_out code: ''
35
35
  end
36
- spec.ignore(%w[wxSizerItem::SetSizer wxSizerItem::SetSpacer wxSizerItem::SetWindow])
36
+ spec.ignore('wxSizerItem::SetSizer')
37
+ if Config.instance.wx_version_check('3.3.4') < 0
38
+ spec.ignore(%w[wxSizerItem::SetSpacer wxSizerItem::SetWindow])
39
+ end
37
40
  # need to adjust sizer arg name to apply disown specs
38
41
  spec.ignore 'wxSizerItem::AssignSizer(wxSizer *)', ignore_doc: false
39
42
  spec.extend_interface 'wxSizerItem',
@@ -16,8 +16,8 @@ module WXRuby3
16
16
 
17
17
  def setup
18
18
  super
19
- # because of error in XML docs
20
- spec.ignore('wxSplitterEvent::GetOldSize', ignore_doc: false)
19
+ # because of error in XML docs in older wxWidgets
20
+ spec.ignore('wxSplitterEvent::GetOldSize', 'wxSplitterEvent::GetNewSize' , ignore_doc: false)
21
21
  # add these by hand here
22
22
  spec.extend_interface('wxSplitterEvent',
23
23
  'int GetOldSize() const',
@@ -48,6 +48,9 @@ module WXRuby3
48
48
  # It also handles the special case where +nil+ is returned, to signal to Wx that no menu is to
49
49
  # be shown.
50
50
  spec.map 'wxMenu *' do
51
+ add_header_code <<~__CODE
52
+ WXRUBY_EXPORT void wxRuby_RegisterWxMenu(wxMenu* wx_menu, VALUE rb_menu);
53
+ __CODE
51
54
  map_directorout code: <<~__CODE
52
55
  static const std::string create_popup_menu("CreatePopupMenu");
53
56
  bool disown = (std::string("$symname") == create_popup_menu);
@@ -59,7 +62,7 @@ module WXRuby3
59
62
  else
60
63
  {
61
64
  void * ptr;
62
- int swig_res = SWIG_ConvertPtr(result, &ptr, $1_descriptor, disown ? SWIG_POINTER_DISOWN : 0);
65
+ int swig_res = SWIG_ConvertPtr(result, &ptr, $1_descriptor, disown ? SWIG_POINTER_RELEASE : 0);
63
66
  if (!SWIG_IsOK(swig_res))
64
67
  {
65
68
  Swig::DirectorTypeMismatchException::raise(swig_get_self(), "$symname", rb_eTypeError,
@@ -56,7 +56,7 @@ module WXRuby3
56
56
  this->wxTextValidator::SetWindow(win);
57
57
  VALUE self = this->get_self();
58
58
  // make sure Ruby does not own this validator instance anymore
59
- RDATA(self)->dfree = SWIG_RubyRemoveTracking;
59
+ WXRUBY_WRAPPER_DATA_DFREE_SET(self, SWIG_RubyRemoveTracking);
60
60
  }
61
61
 
62
62
  virtual bool TransferFromWindow () override
@@ -54,10 +54,10 @@ module WXRuby3
54
54
 
55
55
  static const rb_data_type_t __wxTreeItemId_type = {
56
56
  "TreeItemId",
57
- #if RUBY_API_VERSION_MAJOR >= 3
58
- { NULL, NULL, __wxTreeItemId_size, 0, {}},
57
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
58
+ { NULL, NULL, __wxTreeItemId_size, 0, 0, {}},
59
59
  #else
60
- { NULL, NULL, __wxTreeItemId_size, {}},
60
+ { NULL, NULL, __wxTreeItemId_size, 0, {}},
61
61
  #endif
62
62
  NULL, NULL, RUBY_TYPED_FREE_IMMEDIATELY
63
63
  };
@@ -69,7 +69,7 @@ module WXRuby3
69
69
  this->wxValidator::SetWindow(win);
70
70
  VALUE self = this->get_self();
71
71
  // make sure Ruby does not own this validator instance anymore
72
- RDATA(self)->dfree = SWIG_RubyRemoveTracking;
72
+ WXRUBY_WRAPPER_DATA_DFREE_SET(self, SWIG_RubyRemoveTracking);
73
73
  }
74
74
 
75
75
  bool wxRubyValidator::TransferFromWindow()
@@ -402,7 +402,7 @@ module WXRuby3
402
402
  VALUE obj = ti.second;
403
403
 
404
404
  WXRUBY_TRACE_IF(WxRubyTraceGCMarkVariant, 2)
405
- WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(obj) == T_DATA ? DATA_PTR(obj) : 0))
405
+ WXRUBY_TRACE_WITH(void *c_ptr = (WXRUBY_HAS_WRAPPED_DATA(obj) ? WXRUBY_WRAPPER_DATA_PTR(obj) : 0))
406
406
  WXRUBY_TRACE("| GC_mark_RbValueVariants : " << ti.first << "|" << (void*)c_ptr)
407
407
  WXRUBY_TRACE_END
408
408
 
@@ -419,7 +419,7 @@ module WXRuby3
419
419
  static bool is_marker_registered = false;
420
420
 
421
421
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackVariant, 2)
422
- WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(rbval) == T_DATA ? DATA_PTR(rbval) : 0))
422
+ WXRUBY_TRACE_WITH(void *c_ptr = (WXRUBY_HAS_WRAPPED_DATA(rbval) ? WXRUBY_WRAPPER_DATA_PTR(rbval) : 0))
423
423
  WXRUBY_TRACE("> wxRuby_RegisterValueVariantData : " << ptr << "|" << (void*)c_ptr)
424
424
  WXRUBY_TRACE_END
425
425
 
@@ -82,6 +82,9 @@ module WXRuby3
82
82
  'wxWindow::Raise',
83
83
  'wxWindow::Lower'
84
84
  ]
85
+ if Config.instance.wx_version_check('3.3.4') > 0
86
+ spec.ignore 'wxWindow::GetViewStartPixels(int *,int *) const'
87
+ end
85
88
 
86
89
  # Event handler chaining methods; pushed handlers always remain owned by Ruby
87
90
  # wxRuby3 will automatically pop any remaining handlers when windows get deleted
@@ -236,10 +239,6 @@ module WXRuby3
236
239
  spec.override_events 'wxWindow', 'EVT_ACTIVATE' => ['EVT_ACTIVATE', 0, 'wxActivateEvent']
237
240
  when 'wxNonOwnedWindow'
238
241
  spec.no_proxy('wxNonOwnedWindow')
239
- if Config.instance.features_set?('WXOSX')
240
- spec.extend_interface('wxNonOwnedWindow',
241
- 'virtual bool Destroy() override')
242
- end
243
242
  when 'wxControl'
244
243
  # add these to the generated interface to be parsed by SWIG
245
244
  # the wxWidgets docs are flawed in this respect that several reimplemented
@@ -345,6 +344,9 @@ module WXRuby3
345
344
  "#{spec.class_name(citem)}::AdjustForLayoutDirection",
346
345
  "#{spec.class_name(citem)}::IsTransparentBackgroundSupported",
347
346
  "#{spec.class_name(citem)}::Reparent")
347
+ if Config.instance.wx_version_check('3.3.4') > 0
348
+ spec.no_proxy("#{spec.class_name(citem)}::GetViewStartPixels")
349
+ end
348
350
  if Config.instance.features_set?('USE_ACCESSIBILITY')
349
351
  if Config.instance.wx_version_check('3.2.4') > 0
350
352
  spec.no_proxy "#{spec.class_name(citem)}::CreateAccessible"
@@ -387,15 +389,33 @@ module WXRuby3
387
389
  # true for dialogs which are not cleaned up by wxWidgets but rather garbage collected by Ruby).
388
390
  class UpdateWindow < Processor
389
391
 
392
+ def collect_window_classes
393
+ def_items.select { |def_item| Extractor::ClassDef === def_item && (def_item == 'wxWindow' || is_derived_from?(def_item, 'wxWindow')) }.collect { |def_item| rb_wx_name(def_item.name) }
394
+ end
395
+
390
396
  def run
397
+ swig_ruby_type_data = SwigRunner.swig_ruby_type == 'typed_data'
398
+ at_init_method = false
391
399
  at_director_method = false
392
400
  director_wx_class = nil
393
401
  director_method_line = 0
394
402
 
403
+ window_classes = collect_window_classes if swig_ruby_type_data
404
+
405
+ core_name = name
406
+ core_name = 'ruby3' if /\Awx\Z/i =~ core_name
407
+
395
408
  prev_line = nil
396
409
 
397
410
  update_source(at_end: ->(){ prev_line }) do |line|
398
- if at_director_method
411
+ if at_init_method
412
+ if /SwigClassWx(\S+)\.cext_type.function.dfree\s+=\s+SWIG_Ruby_free_swig_type;/ =~ line
413
+ class_name = $1
414
+ if window_classes.include?(class_name)
415
+ line = "SwigClassWx#{class_name}.cext_type.function.dfree = WxRuby_Ruby_free_swig_window_type;"
416
+ end
417
+ end
418
+ elsif at_director_method
399
419
  director_method_line += 1 # update line counter
400
420
  if director_method_line == 2 && line.strip.empty? # are we at the right spot?
401
421
  code = <<~__CODE # insert the code update
@@ -413,6 +433,8 @@ module WXRuby3
413
433
  director_wx_class = $1
414
434
  at_director_method = true # we're at a director method to be updated
415
435
  director_method_line = 0 # keep track of the method lines
436
+ elsif swig_ruby_type_data && /void\s+Init_(wx|Wx)#{core_name}\(/ =~ line
437
+ at_init_method = true
416
438
  end
417
439
 
418
440
  result = prev_line
@@ -31,7 +31,7 @@ module WXRuby3
31
31
  return ;
32
32
  }
33
33
  __HEREDOC
34
- spec.do_not_generate(:variables, :enums, :defines, :functions)
34
+ spec.do_not_generate(:variables, :enums, :defines, :functions, :typedefs)
35
35
  end
36
36
  end # class WindowDisabler
37
37
 
@@ -57,12 +57,12 @@ module WXRuby3
57
57
  static void AddSubclassFactory(VALUE factory)
58
58
  {
59
59
  void *pfactory = 0;
60
- if (TYPE(factory) != T_DATA || !rb_obj_is_kind_of(factory, WxRuby_XmlSubclassFactory_klass))
60
+ if (!WXRUBY_HAS_WRAPPED_DATA(factory) || !rb_obj_is_kind_of(factory, WxRuby_XmlSubclassFactory_klass))
61
61
  {
62
62
  rb_raise(rb_eArgError, "expected Wx::XmlSubclassFactory for argument 1"); return;
63
63
  }
64
- RDATA(factory)->dfree = 0; // wxWidgets will take over management
65
- Data_Get_Struct(factory, void, pfactory);
64
+ WXRUBY_WRAPPER_DATA_DFREE_RESET(factory); // wxWidgets will take over management
65
+ pfactory = WXRUBY_WRAPPER_DATA_PTR(factory);
66
66
  wxXmlResource::AddSubclassFactory(reinterpret_cast< wxXmlSubclassFactory * >(pfactory));
67
67
  }
68
68
  __HEREDOC
@@ -94,12 +94,12 @@ module WXRuby3
94
94
  result = rb_funcall(this->self_, create_id(), 1, rb_classname);
95
95
  if (result != Qnil)
96
96
  {
97
- if (TYPE(result) != T_DATA || !rb_obj_is_kind_of(result, ((swig_class *) (SWIGTYPE_p_wxObject->clientdata))->klass))
97
+ if (!WXRUBY_HAS_WRAPPED_DATA(result) || !rb_obj_is_kind_of(result, ((swig_class *) (SWIGTYPE_p_wxObject->clientdata))->klass))
98
98
  {
99
99
  Swig::DirectorTypeMismatchException::raise(rb_eTypeError, "in output value of type '""wxObject *""'");
100
100
  }
101
- Data_Get_Struct(result, void, result_ptr);
102
- RDATA(result)->dfree = 0; // disown
101
+ result_ptr = WXRUBY_WRAPPER_DATA_PTR(result);
102
+ WXRUBY_WRAPPER_DATA_DFREE_RESET(result); // disown
103
103
  // the returned wxObject's should be Window objects which are always managed by wxWidgets after creation
104
104
  // so no need to own anything anymore
105
105
  c_result = reinterpret_cast< wxObject * >(result_ptr);
@@ -111,7 +111,7 @@ module WXRuby3
111
111
 
112
112
  WxRuby_XmlSubclassFactory::~WxRuby_XmlSubclassFactory()
113
113
  {
114
- DATA_PTR(this->self_) = 0; // unlink
114
+ WXRUBY_WRAPPER_DATA_PTR_RESET(this->self_); // unlink
115
115
  }
116
116
 
117
117
  SWIGINTERN void
@@ -121,6 +121,23 @@ module WXRuby3
121
121
  delete arg1;
122
122
  }
123
123
 
124
+ #ifdef WXRUBY_SWIG_TYPED_DATA
125
+
126
+ static const rb_data_type_t wxruby_subclass_factory_data_type = {
127
+ "C++ WxRuby_XmlSubclassFactory",
128
+ #if RUBY_API_VERSION_MAJOR > 4 || (RUBY_API_VERSION_MAJOR == 4 && RUBY_API_VERSION_MINOR >= 1)
129
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, 0, {}},
130
+ #else
131
+ { SWIG_Ruby_mark_swig_type, SWIG_Ruby_free_swig_type, 0, 0, {}},
132
+ #endif
133
+ 0, 0
134
+ #ifdef RUBY_TYPED_FREE_IMMEDIATELY
135
+ , SWIG_RUBY_TYPED_DATA_FLAGS
136
+ #endif
137
+ };
138
+
139
+ #endif
140
+
124
141
  SWIGINTERN VALUE
125
142
  #ifdef HAVE_RB_DEFINE_ALLOC_FUNC
126
143
  WxRuby_XmlSubclassFactory_allocate(VALUE self)
@@ -129,9 +146,17 @@ module WXRuby3
129
146
  #endif
130
147
  {
131
148
  VALUE obj;
149
+ #ifdef WXRUBY_SWIG_UNTYPED_DATA
132
150
  obj = Data_Wrap_Struct(self, 0, WxRuby_XmlSubclassFactory_free, 0);
151
+ #else
152
+ struct swig_ruby_wrapped_object *wrobj;
153
+ obj = TypedData_Make_Struct(self, struct swig_ruby_wrapped_object, &wxruby_subclass_factory_data_type, wrobj);
154
+ wrobj->data = 0;
155
+ wrobj->dfree = WxRuby_XmlSubclassFactory_free;
156
+ #endif
157
+ rb_iv_set(obj, "@__swigtype__", rb_str_new2("XmlSubclassFactory"));
133
158
  WxRuby_XmlSubclassFactory *pfactory = new WxRuby_XmlSubclassFactory(obj);
134
- DATA_PTR(obj) = pfactory;
159
+ WXRUBY_WRAPPER_DATA_PTR_SET(obj, pfactory);
135
160
  #ifndef HAVE_RB_DEFINE_ALLOC_FUNC
136
161
  rb_obj_call_init(obj, argc, argv);
137
162
  #endif
@@ -215,7 +215,8 @@ module WXRuby3
215
215
  else
216
216
  nil
217
217
  end
218
- evt_paras[1].xpath('.//listitem').each do |li|
218
+ evt_list_para = evt_paras.detect { |para| !para.xpath('.//listitem').empty? }
219
+ (evt_list_para ? evt_list_para.xpath('.//listitem') : []).each do |li|
219
220
  if li.text =~ /(EVT_\w+)\((.*)\)/
220
221
  evt_handler = $1
221
222
  args = $2.split(',').collect {|a| a.strip }
@@ -82,8 +82,9 @@ module WXRuby3
82
82
  attempts << pathname
83
83
  unless File.exist?(pathname)
84
84
  msg = "Unable to find xml file for ITEM: %s" % class_or_filename
85
- puts(msg)
86
- puts("Tried: %s" % (attempts.join("\n ")))
85
+ STDERR.puts(msg)
86
+ STDERR.puts("Tried: %s" % (attempts.join("\n ")))
87
+ STDERR.puts("Matches: %s" % (Dir[File.join(xml_dir,'*defs.*.*')].join("\n ")))
87
88
  raise DoxyXMLError.new(msg)
88
89
  end
89
90
  end
@@ -68,7 +68,7 @@ module WXRuby3
68
68
  return SWIG_ERROR;
69
69
  }
70
70
 
71
- if (TYPE(obj) != T_DATA)
71
+ if (!WXRUBY_HAS_WRAPPED_DATA(obj))
72
72
  {
73
73
  VALUE msg = rb_inspect(obj);
74
74
  rb_raise(rb_eArgError,
@@ -82,9 +82,8 @@ module WXRuby3
82
82
  swig_class* cls_info = static_cast<swig_class*> (it->first);
83
83
  if (rb_obj_is_kind_of(obj, cls_info->klass))
84
84
  {
85
- void *vptr = 0;
86
85
  /* Grab the pointer */
87
- Data_Get_Struct(obj, void, vptr);
86
+ void *vptr = WXRUBY_WRAPPER_DATA_GET(obj, void);
88
87
  wx_#{underscore(rb_name)}_convert_fn fn_cvt = it->second;
89
88
  *ptr = (*fn_cvt)(vptr);
90
89
  if (!ptr)
@@ -253,6 +253,7 @@ module WXRuby3
253
253
  Director.Spec(pkg, 'wxCredentialEntryDialog', director: Director::Dialog, requirements: %w[USE_CREDENTIALDLG])
254
254
  Director.Spec(pkg, 'wxGenericAboutDialog', director: Director::Dialog, requirements: %w[USE_ABOUTDLG])
255
255
  Director.Spec(pkg, 'wxMBConv')
256
+ Director.Spec(pkg, 'wxFileHistory', requirements: %w[USE_FILE_HISTORY])
256
257
  }
257
258
 
258
259
  Director.Package('Wx::RT', 'USE_THREADS') do |pkg|
@@ -392,6 +393,12 @@ module WXRuby3
392
393
  Director.Spec(pkg, 'wxRibbonPanel')
393
394
  Director.Spec(pkg, 'wxRibbonToolBar')
394
395
  Director.Spec(pkg, 'wxRibbonButtonBar')
396
+ Director.Spec(pkg, 'wxBackstage') if Config.instance.wx_version_check('3.3.4') >= 0
397
+ Director.Spec(pkg, 'wxBackstageButton') if Config.instance.wx_version_check('3.3.4') >= 0
398
+ Director.Spec(pkg, 'wxBackstageHeading', requirements: %w[USE_STATTEXT]) if Config.instance.wx_version_check('3.3.4') >= 0
399
+ Director.Spec(pkg, 'wxBackstageCallout') if Config.instance.wx_version_check('3.3.4') >= 0
400
+ Director.Spec(pkg, 'wxBackstageItemList') if Config.instance.wx_version_check('3.3.4') >= 0
401
+ Director.Spec(pkg, 'wxBackstageMRUList') if Config.instance.wx_version_check('3.3.4') >= 0
395
402
  }
396
403
 
397
404
  Director.Package('Wx::WEB', 'USE_WEBVIEW') { |pkg|
@@ -27,11 +27,19 @@ module WXRuby3
27
27
  swig_version.first
28
28
  end
29
29
 
30
+ def swig_minor
31
+ swig_version[1]
32
+ end
33
+
30
34
  def swig_version
31
35
  check_swig unless swig_state
32
36
  @swig_version
33
37
  end
34
38
 
39
+ def swig_ruby_type
40
+ ((swig_major == 4 && swig_minor >= 5) || swig_major >= 5) ? 'typed_data' : 'untyped_data'
41
+ end
42
+
35
43
  private
36
44
 
37
45
  def config
@@ -67,10 +75,13 @@ module WXRuby3
67
75
  @swig_state = true
68
76
  end
69
77
 
78
+ def swig_custom_dir
79
+ File.join(config.swig_dir, 'custom')
80
+ end
81
+
70
82
  def run_swig(source, target)
71
83
  check_swig unless swig_state
72
- inc_paths = "-I#{config.wxruby_dir} -I#{config.swig_dir}/custom"
73
- inc_paths << " -I#{config.swig_dir}/custom/swig#{swig_major}"
84
+ inc_paths = "-I#{config.wxruby_dir} -I#{swig_custom_dir} -I#{File.join(swig_custom_dir, 'common')} -I#{File.join(swig_custom_dir, swig_ruby_type)}"
74
85
  WXRuby3.config.sh "#{config.get_config('swig')} #{config.wx_cppflags.join(' ')} " +
75
86
  "#{config.extra_cppflags.join(' ')} #{config.verbose_flag} #{inc_paths} " +
76
87
  #"-w401 -w801 -w515 -c++ -ruby " +
@@ -539,7 +550,7 @@ module WXRuby3
539
550
  if found_alloc # inside 'xxx_allocate' wrapper?
540
551
  if line =~ /\A(\s*)return\s+vresult;/
541
552
  # insert an override for the free method to disown the new instance
542
- line = "#{$1}RDATA(vresult)->dfree = #{track_table[cpp_class]};\n#{line}"
553
+ line = "#{$1}WXRUBY_WRAPPER_DATA_DFREE_SET(vresult, #{track_table[cpp_class]});\n#{line}"
543
554
  elsif /\A}/ =~ line # end of wrapper function?
544
555
  # stop matching
545
556
  found_alloc = false
@@ -557,7 +557,7 @@ module WXRuby3
557
557
 
558
558
  # Thin and trusting wrapping to bypass SWIG's normal mechanisms; we
559
559
  # don't want SWIG changing ownership or typechecking these.
560
- map_in code: '$1 = (wxEvent*)DATA_PTR($input);'
560
+ map_in code: '$1 = (wxEvent*)WXRUBY_WRAPPER_DATA_PTR($input);'
561
561
  end
562
562
 
563
563
  # For wxWindow::DoUpdateUIEvent
@@ -605,39 +605,6 @@ module WXRuby3
605
605
  __CODE
606
606
  end
607
607
 
608
- # Menu bars need to be wrapped / unwrapped correctly
609
- map 'wxMenuBar*' => 'Wx::MenuBar' do
610
- add_header_code <<~__CODE
611
- WXRUBY_EXPORT VALUE wxRuby_WrapWxMenuBarInRuby(wxMenuBar *wx_menubar);
612
- WXRUBY_EXPORT void wxRuby_RegisterWxMenuBar(wxMenuBar* wx_menubar, VALUE rb_menubar);
613
- __CODE
614
- map_check code: <<~__CODE
615
- wxRuby_RegisterWxMenuBar($1, argv[$argnum-2]);
616
- __CODE
617
- map_out code: <<~__CODE
618
- $result = wxRuby_WrapWxMenuBarInRuby($1);
619
- __CODE
620
- map_directorin code: <<~__CODE
621
- $input = wxRuby_WrapWxMenuBarInRuby($1);
622
- __CODE
623
- end
624
- # As do menus
625
- map 'wxMenu*' => 'Wx::Menu' do
626
- add_header_code <<~__CODE
627
- WXRUBY_EXPORT VALUE wxRuby_WrapWxMenuInRuby(wxMenu *wx_menu);
628
- WXRUBY_EXPORT void wxRuby_RegisterWxMenu(wxMenu* wx_menu, VALUE rb_menu);
629
- __CODE
630
- map_check code: <<~__CODE
631
- wxRuby_RegisterWxMenu($1, argv[$argnum-2]);
632
- __CODE
633
- map_out code: <<~__CODE
634
- $result = wxRuby_WrapWxMenuInRuby($1);
635
- __CODE
636
- map_directorin code: <<~__CODE
637
- $input = wxRuby_WrapWxMenuInRuby($1);
638
- __CODE
639
- end
640
-
641
608
  # typemap to allow String or Symbol for wxColour in args
642
609
  map 'const wxColour&', 'const wxColour*', as: 'Wx::Colour,String,Symbol' do
643
610
  map_in temp: 'wxColour tmpcol', code: <<~__CODE
@@ -692,8 +659,7 @@ module WXRuby3
692
659
  bool ok = false;
693
660
  if (TYPE($input) == T_DATA)
694
661
  {
695
- void *ptr;
696
- Data_Get_Struct($input, void, ptr);
662
+ void *ptr = WXRUBY_WRAPPER_DATA_GET($input, void);
697
663
  if (ptr)
698
664
  {
699
665
  ok = true;
@@ -54,6 +54,28 @@ module WXRuby3
54
54
 
55
55
  end
56
56
 
57
+ map 'wxConfigBase&' => 'Wx::ConfigBase' do
58
+
59
+ map_in code: <<~__CODE
60
+ $1 = nullptr;
61
+ if (!NIL_P($input))
62
+ {
63
+ $1 = wxRuby_Ruby2ConfigBase($input);
64
+ if ($1 == nullptr)
65
+ {
66
+ VALUE msg = rb_inspect($input);
67
+ rb_raise(rb_eArgError, "Expected Wx::ConfigBase or Hash for %d but got %s",
68
+ $argnum-1, StringValuePtr(msg));
69
+ }
70
+ }
71
+ __CODE
72
+
73
+ map_directorin code: <<~__CODE
74
+ $input = wxRuby_ConfigBase2Ruby(&const_cast<wxConfigBase&> ($1));
75
+ __CODE
76
+
77
+ end
78
+
57
79
  end
58
80
 
59
81
  end