wxruby3 1.3.0 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (139) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +16 -12
  3. data/README.md +4 -3
  4. data/ext/wxruby3/include/wxRubyApp.h +9 -9
  5. data/ext/wxruby3/swig/custom/director.swg +11 -3
  6. data/ext/wxruby3/swig/custom/rubyapi.swg +15 -1
  7. data/ext/wxruby3/swig/mark_free_impl.i +47 -11
  8. data/ext/wxruby3/swig/wx.i +30 -12
  9. data/lib/wx/aui/auifloatframe.rb +1 -1
  10. data/lib/wx/aui/auimanager.rb +50 -14
  11. data/lib/wx/aui/auinotebook.rb +1 -1
  12. data/lib/wx/aui/require.rb +0 -2
  13. data/lib/wx/core/acceleratortable.rb +1 -1
  14. data/lib/wx/core/animation.rb +2 -2
  15. data/lib/wx/core/app.rb +1 -1
  16. data/lib/wx/core/array_ext.rb +1 -0
  17. data/lib/wx/core/artprovider.rb +4 -4
  18. data/lib/wx/core/bitmap.rb +1 -1
  19. data/lib/wx/core/bitmap_combobox.rb +2 -2
  20. data/lib/wx/core/brush.rb +8 -0
  21. data/lib/wx/core/clientdc.rb +1 -1
  22. data/lib/wx/core/clipboard.rb +4 -4
  23. data/lib/wx/core/colour.rb +1 -1
  24. data/lib/wx/core/combobox.rb +1 -1
  25. data/lib/wx/core/config.rb +7 -7
  26. data/lib/wx/core/controlwithitems.rb +3 -3
  27. data/lib/wx/core/data_object.rb +4 -4
  28. data/lib/wx/core/dataformat.rb +9 -3
  29. data/lib/wx/core/defs.rb +49 -0
  30. data/lib/wx/core/dialog.rb +3 -2
  31. data/lib/wx/core/enum.rb +16 -3
  32. data/lib/wx/core/event.rb +3 -3
  33. data/lib/wx/core/evthandler.rb +317 -289
  34. data/lib/wx/core/file_dialog.rb +1 -1
  35. data/lib/wx/core/find_replace_dialog.rb +2 -2
  36. data/lib/wx/core/font.rb +14 -0
  37. data/lib/wx/core/functions.rb +1 -1
  38. data/lib/wx/core/genericdirctrl.rb +1 -1
  39. data/lib/wx/core/geometry.rb +2 -2
  40. data/lib/wx/core/graphics_pen_info.rb +1 -1
  41. data/lib/wx/core/hboxsizer.rb +24 -4
  42. data/lib/wx/core/helpprovider.rb +1 -1
  43. data/lib/wx/core/icon.rb +1 -1
  44. data/lib/wx/core/image.rb +2 -2
  45. data/lib/wx/core/imagelist.rb +1 -1
  46. data/lib/wx/core/locale.rb +5 -5
  47. data/lib/wx/core/log.rb +8 -8
  48. data/lib/wx/core/menu.rb +3 -3
  49. data/lib/wx/core/module_ext.rb +16 -0
  50. data/lib/wx/core/owner_drawn_combobox.rb +3 -3
  51. data/lib/wx/core/pen.rb +20 -0
  52. data/lib/wx/core/pen_info.rb +1 -1
  53. data/lib/wx/core/persistence_manager.rb +2 -2
  54. data/lib/wx/core/real_point.rb +1 -0
  55. data/lib/wx/core/rect.rb +1 -1
  56. data/lib/wx/core/secret_store.rb +1 -1
  57. data/lib/wx/core/simplehelpprovider.rb +1 -1
  58. data/lib/wx/core/sizer.rb +166 -39
  59. data/lib/wx/core/splash_screen.rb +1 -1
  60. data/lib/wx/core/standard_paths.rb +1 -1
  61. data/lib/wx/core/task_bar_button.rb +1 -1
  62. data/lib/wx/core/text_entry.rb +1 -1
  63. data/lib/wx/core/textctrl.rb +2 -2
  64. data/lib/wx/core/timer.rb +2 -2
  65. data/lib/wx/core/tree_ctrl.rb +1 -1
  66. data/lib/wx/core/v_list_box.rb +1 -1
  67. data/lib/wx/core/validator.rb +2 -2
  68. data/lib/wx/core/variant.rb +2 -2
  69. data/lib/wx/core/vboxsizer.rb +24 -4
  70. data/lib/wx/core/window.rb +48 -2
  71. data/lib/wx/core/xmlresource.rb +4 -4
  72. data/lib/wx/core.rb +2 -0
  73. data/lib/wx/doc/array_ext.rb +1 -0
  74. data/lib/wx/doc/aui/auimanager.rb +2 -0
  75. data/lib/wx/doc/enum.rb +26 -0
  76. data/lib/wx/doc/evthandler.rb +1 -0
  77. data/lib/wx/doc/gdi_common.rb +1 -0
  78. data/lib/wx/doc/tip_window.rb +22 -0
  79. data/lib/wx/grid/grid.rb +3 -3
  80. data/lib/wx/grid/require.rb +0 -2
  81. data/lib/wx/html/htmlhelpcontroller.rb +1 -1
  82. data/lib/wx/html/htmlwindow.rb +1 -1
  83. data/lib/wx/html/require.rb +0 -2
  84. data/lib/wx/html/simple_html_listbox.rb +3 -3
  85. data/lib/wx/keyword_ctors.rb +14 -7
  86. data/lib/wx/keyword_defs.rb +7 -7
  87. data/lib/wx/pg/pg_properties.rb +1 -1
  88. data/lib/wx/pg/pg_property.rb +3 -3
  89. data/lib/wx/pg/property_grid.rb +2 -2
  90. data/lib/wx/pg/property_grid_interface.rb +2 -2
  91. data/lib/wx/pg/require.rb +0 -2
  92. data/lib/wx/prt/previewframe.rb +1 -1
  93. data/lib/wx/prt/require.rb +0 -2
  94. data/lib/wx/rbn/ribbon_control.rb +1 -1
  95. data/lib/wx/rbn/ribbon_page.rb +1 -1
  96. data/lib/wx/rbn/ribbon_panel.rb +1 -1
  97. data/lib/wx/rtc/require.rb +0 -2
  98. data/lib/wx/rtc/rich_text_composite_object.rb +1 -1
  99. data/lib/wx/rtc/rich_text_ctrl.rb +1 -1
  100. data/lib/wx/rtc/rich_text_paragraph.rb +1 -1
  101. data/lib/wx/rtc/richtext_buffer.rb +3 -3
  102. data/lib/wx/rtc/richtext_formatting_dialog.rb +2 -2
  103. data/lib/wx/rtc/richtext_style_organiser_dialog.rb +1 -1
  104. data/lib/wx/rtc/symbol_picker_dialog.rb +1 -1
  105. data/lib/wx/stc/require.rb +0 -2
  106. data/lib/wx/stc/styled_text_ctrl.rb +1 -1
  107. data/lib/wx/version.rb +1 -1
  108. data/lib/wx/wxruby/base.rb +8 -2
  109. data/lib/wx/wxruby/cmd/setup.rb +61 -37
  110. data/rakelib/gem.rb +8 -4
  111. data/rakelib/lib/config/mingw.rb +1 -1
  112. data/rakelib/lib/core/include/swigrubyrun.inc +2 -2
  113. data/rakelib/lib/director/about_dialog_info.rb +1 -0
  114. data/rakelib/lib/director/aui_manager.rb +124 -3
  115. data/rakelib/lib/director/aui_notebook.rb +7 -0
  116. data/rakelib/lib/director/colour.rb +1 -1
  117. data/rakelib/lib/director/data_format.rb +1 -1
  118. data/rakelib/lib/director/dialog.rb +4 -2
  119. data/rakelib/lib/director/event.rb +1 -0
  120. data/rakelib/lib/director/event_handler.rb +82 -46
  121. data/rakelib/lib/director/functions.rb +0 -3
  122. data/rakelib/lib/director/list_ctrl.rb +14 -10
  123. data/rakelib/lib/director/locale.rb +2 -0
  124. data/rakelib/lib/director/num_validator.rb +7 -0
  125. data/rakelib/lib/director/pgproperties.rb +2 -2
  126. data/rakelib/lib/director/property_grid_interface.rb +4 -3
  127. data/rakelib/lib/director/textctrl.rb +7 -0
  128. data/rakelib/lib/director/tip_window.rb +34 -0
  129. data/rakelib/lib/director/variant.rb +2 -2
  130. data/rakelib/lib/director/window.rb +9 -1
  131. data/rakelib/lib/director.rb +0 -1
  132. data/rakelib/lib/extractor/function.rb +5 -0
  133. data/rakelib/lib/generate/doc/evt_handler.yaml +31 -12
  134. data/rakelib/lib/specs/interfaces.rb +1 -0
  135. data/rakelib/lib/typemap/common.rb +2 -2
  136. data/samples/dialogs/dialogs.rb +1 -1
  137. data/tests/test_combo_ctrl.rb +1 -0
  138. data/tests/test_event_handling.rb +158 -31
  139. metadata +7 -5
@@ -29,45 +29,21 @@ module WXRuby3
29
29
  # have TryBefore and TryAfter to handle this much cleaner
30
30
  spec.no_proxy 'wxEvtHandler::ProcessEvent'
31
31
  spec.regard('wxEvtHandler::ProcessEvent', regard_doc: false) # we provide customized docs
32
+ # Do not see much use for allowing overrides for these either as wxWidgets do not either
33
+ spec.no_proxy 'wxEvtHandler::QueueEvent',
34
+ 'wxEvtHandler::AddPendingEvent'
35
+ # Do not see much point in allowing/supporting these to be overridden
36
+ spec.no_proxy 'wxEvtHandler::SetNextHandler',
37
+ 'wxEvtHandler::SetPreviousHandler'
38
+ # no doc for set_previous_handler
39
+ spec.regard('wxEvtHandler::SetPreviousHandler', regard_doc: false)
32
40
  # make SWIG aware of these
33
41
  spec.regard 'wxEvtHandler::TryBefore', 'wxEvtHandler::TryAfter'
34
42
  # Special type mapping for wxEvtHandler::QueueEvent which assumes ownership of the C++ event.
35
- # We need to create a shallow copy of the Ruby event instance (copying it's Ruby members if any),
36
- # pass linkage of the C++ event to the copy and remove it from the original (input) Ruby
37
- # instance (so it can not delete/or reference it anymore); also start tracking the copy
38
- # (which effectively removes the tracking for the original).
39
- # Queued (pending) events are cleaned up (deleted) by wxWidgets after (failing) handling
40
- # which will automatically unlink and un-track them releasing the Ruby instance to be GC-ed.
41
- spec.map 'wxEvent *event' => 'Wx::Event' do
42
- map_in code: <<~__CODE
43
- // get the wrapped wxEvent*
44
- wxEvent *wx_ev = (wxEvent*)DATA_PTR($input);
45
- // check if this a user defined event
46
- if ( wx_ev->GetEventType() > wxEVT_USER_FIRST )
47
- {
48
- // we need to preserve the Ruby state
49
- // create a shallow copy of the Ruby object
50
- VALUE r_evt_copy = rb_obj_clone($input);
51
- // pass the wxEvent* over to the copy
52
- DATA_PTR(r_evt_copy) = wx_ev;
53
- // unlink the input
54
- DATA_PTR($input) = 0;
55
- // track the copy (this overwrites the record for the
56
- // original, effectively untracking it)
57
- wxRuby_AddTracking( (void*)wx_ev, r_evt_copy);
58
- }
59
- else
60
- {
61
- // std wx event; no need to preserve the Ruby state
62
- // simply untrack and unlink the input
63
- wxRuby_RemoveTracking( (void*)wx_ev);
64
- DATA_PTR($input) = 0;
65
- // and just pass on the C++ event
66
- }
67
- // Queue the C++ event
68
- $1 = wx_ev;
69
- __CODE
70
- end
43
+ # We need to disown Ruby with respect to the C++ event object but remain tracking the pair to keep
44
+ # the Ruby event object alive.
45
+ spec.disown 'wxEvent *event'
46
+
71
47
  # add special mapping for event filters so we can accept the app instance as well
72
48
  # although Wx::App is not derived from Wx::EventFilter in wxRuby (no multiple inheritance)
73
49
  spec.map 'wxEventFilter*' => 'Wx::EventFilter,Wx::App' do
@@ -225,6 +201,10 @@ module WXRuby3
225
201
  }
226
202
  __HEREDOC
227
203
  spec.add_header_code <<~__HEREDOC
204
+ static VALUE WxRuby_GetAsyncProcCallEvent_Class();
205
+ static void GC_mark_AsyncMethodCallEvent(void *ptr);
206
+ static void free_AsyncMethodCallEvent(void *ptr);
207
+
228
208
  class RbAsyncProcCallEvent : public wxAsyncMethodCallEvent
229
209
  {
230
210
  public:
@@ -245,7 +225,14 @@ module WXRuby3
245
225
 
246
226
  virtual wxEvent *Clone() const wxOVERRIDE
247
227
  {
248
- return new RbAsyncProcCallEvent(*this);
228
+ RbAsyncProcCallEvent* wx_ev = new RbAsyncProcCallEvent(*this);
229
+ // Create a new Ruby event object (owned)
230
+ VALUE rb_evt = Data_Wrap_Struct(WxRuby_GetAsyncProcCallEvent_Class(),
231
+ VOIDFUNC(GC_mark_AsyncMethodCallEvent),
232
+ VOIDFUNC(free_AsyncMethodCallEvent),
233
+ wx_ev);
234
+ wxRuby_AddTracking( (void*)wx_ev, rb_evt);
235
+ return wx_ev;
249
236
  }
250
237
 
251
238
  virtual void Execute() wxOVERRIDE
@@ -257,12 +244,22 @@ module WXRuby3
257
244
  if (TYPE(m_rb_call) == T_ARRAY)
258
245
  {
259
246
  VALUE proc = rb_ary_entry(m_rb_call, 0);
260
- VALUE args = rb_ary_subseq(m_rb_call, 1, RARRAY_LEN(m_rb_call)-1);
261
- rc = wxRuby_Funcall(ex_caught, proc, call_id(), args);
247
+ if (RARRAY_LEN(m_rb_call) > 1)
248
+ {
249
+ VALUE args = rb_ary_subseq(m_rb_call, 1, RARRAY_LEN(m_rb_call)-1);
250
+ rc = wxRuby_Funcall(ex_caught, proc, call_id(), args);
251
+ }
252
+ else
253
+ {
254
+ rc = wxRuby_Funcall(ex_caught, proc, call_id(), (int)0);
255
+ }
262
256
  }
263
257
  else
264
258
  {
265
- rc = wxRuby_Funcall(ex_caught, m_rb_call, call_id(), (int)0);
259
+ // should never happen
260
+ VALUE ex = rb_eval_string("x = RuntimeError.new('UNEXPECTED ERROR: Asynchronous Proc Event has invalid call spec!'); x.set_backtrace(caller); x");
261
+ wxRuby_PrintException(ex);
262
+ exit(1);
266
263
  }
267
264
  if (ex_caught)
268
265
  {
@@ -276,9 +273,39 @@ module WXRuby3
276
273
  }
277
274
  }
278
275
 
276
+ void GC_Mark()
277
+ {
278
+ rb_gc_mark(m_rb_call);
279
+ }
280
+
279
281
  private:
280
282
  VALUE m_rb_call;
281
283
  };
284
+
285
+ static void GC_mark_AsyncMethodCallEvent(void *ptr)
286
+ {
287
+ if (ptr)
288
+ {
289
+ RbAsyncProcCallEvent* evt = (RbAsyncProcCallEvent*)ptr;
290
+ evt->GC_Mark();
291
+ }
292
+ }
293
+
294
+ static void free_AsyncMethodCallEvent(void *ptr)
295
+ {
296
+ RbAsyncProcCallEvent *wx_evt = (RbAsyncProcCallEvent *)ptr;
297
+ delete wx_evt;
298
+ }
299
+
300
+ static VALUE WxRuby_GetAsyncProcCallEvent_Class()
301
+ {
302
+ static VALUE WxRuby_cAsyncProcCallEvent = Qnil;
303
+ if (WxRuby_cAsyncProcCallEvent == Qnil)
304
+ {
305
+ WxRuby_cAsyncProcCallEvent = rb_eval_string("Wx::AsyncProcCallEvent");
306
+ }
307
+ return WxRuby_cAsyncProcCallEvent;
308
+ }
282
309
  __HEREDOC
283
310
  spec.add_extend_code 'wxEvtHandler', <<~__HEREDOC
284
311
  // This provides the public Ruby 'connect' method
@@ -333,18 +360,23 @@ module WXRuby3
333
360
  void call_after(VALUE call)
334
361
  {
335
362
  // valid call object?
336
- VALUE proc;
337
- if (TYPE(call) == T_ARRAY &&
338
- (rb_obj_is_kind_of(proc = rb_ary_entry(call, 0), rb_cProc)
363
+ VALUE proc = TYPE(call) == T_ARRAY ? rb_ary_entry(call, 0) : Qnil;
364
+ if (!NIL_P(proc) &&
365
+ (rb_obj_is_kind_of(proc, rb_cProc)
339
366
  ||
340
367
  rb_obj_is_kind_of(proc, rb_cMethod)))
341
368
  {
342
369
  // create C++ event
343
370
  RbAsyncProcCallEvent * evt = new RbAsyncProcCallEvent(self, call);
371
+ // Create a new Ruby event object (leave ownership to wxWidgets C++)
372
+ VALUE rb_evt = Data_Wrap_Struct(WxRuby_GetAsyncProcCallEvent_Class(),
373
+ VOIDFUNC(GC_mark_AsyncMethodCallEvent),
374
+ 0,
375
+ evt);
344
376
  // track it and the call object
345
- wxRuby_AddTracking( (void*)evt, call);
346
- // queue it
347
- self->QueueEvent(evt);
377
+ wxRuby_AddTracking( (void*)evt, rb_evt);
378
+ // queue it (wxWidgets takes ownership of C++ event object)
379
+ self->wxEvtHandler::QueueEvent(evt);
348
380
  }
349
381
  }
350
382
  __HEREDOC
@@ -371,6 +403,10 @@ module WXRuby3
371
403
  def_item = defmod.find_item(citem)
372
404
  if Extractor::ClassDef === def_item && spec.is_derived_from?(def_item, 'wxEvtHandler')
373
405
  spec.no_proxy "#{spec.class_name(citem)}::ProcessEvent"
406
+ spec.no_proxy "#{spec.class_name(citem)}::QueueEvent"
407
+ spec.no_proxy "#{spec.class_name(citem)}::AddPendingEvent"
408
+ spec.no_proxy "#{spec.class_name(citem)}::SetNextHandler"
409
+ spec.no_proxy "#{spec.class_name(citem)}::SetPreviousHandler"
374
410
  is_evt_handler = true
375
411
  end
376
412
  end
@@ -204,9 +204,6 @@ module WXRuby3
204
204
  spec.add_interface_code <<~__HEREDOC
205
205
  bool wxSafeYield(wxWindow* win = NULL, bool onlyIfNeeded = false);
206
206
 
207
- // Mouse / keyboard information
208
- wxWindow * wxGetActiveWindow();
209
-
210
207
  // Dialog shortcuts
211
208
  wxString wxFileSelector (const wxString &message,
212
209
  const wxString &default_path=wxEmptyString,
@@ -148,7 +148,7 @@ module WXRuby3
148
148
 
149
149
  wxListCtrl* wx_lc = (wxListCtrl*) ptr;
150
150
 
151
- // First check if there's ImageLists and mark if found
151
+ // First check if there are ImageLists and mark if found
152
152
  wxImageList* img_list;
153
153
  img_list= wx_lc->GetImageList(wxIMAGE_LIST_NORMAL);
154
154
  if ( img_list ) rb_gc_mark(SWIG_RubyInstanceFor(img_list));
@@ -161,18 +161,22 @@ module WXRuby3
161
161
  if ( wx_lc->GetWindowStyle() & wxLC_VIRTUAL )
162
162
  return;
163
163
 
164
- int count = wx_lc->GetItemCount();
165
- if ( count == 0 ) return;
166
-
167
- for (int i = 0; i < count; ++i)
164
+ // only mark items if window fully created
165
+ if (wx_lc->GetId() != wxID_ANY)
168
166
  {
169
- wxUIntPtr data = wx_lc->GetItemData(i);
170
- VALUE object = reinterpret_cast<VALUE> (data);
171
- if ( object && object != Qnil )
167
+ int count = wx_lc->GetItemCount();
168
+ if ( count == 0 ) return;
169
+
170
+ for (int i = 0; i < count; ++i)
172
171
  {
173
- rb_gc_mark(object);
172
+ wxUIntPtr data = wx_lc->GetItemData(i);
173
+ VALUE object = reinterpret_cast<VALUE> (data);
174
+ if ( object && object != Qnil )
175
+ {
176
+ rb_gc_mark(object);
177
+ }
174
178
  }
175
- }
179
+ }
176
180
  }
177
181
  __HEREDOC
178
182
  spec.add_extend_code 'wxListCtrl', <<~__HEREDOC
@@ -29,6 +29,8 @@ module WXRuby3
29
29
  wxLanguageInfo::LayoutDirection
30
30
  ]
31
31
  spec.ignore_unless('WXMSW', 'wxLanguageInfo::WinLang', 'wxLanguageInfo::WinSublang')
32
+ # implemented in Ruby
33
+ spec.ignore 'wxLocale::GetSystemEncodingName'
32
34
  end
33
35
  end # class Locale
34
36
 
@@ -370,6 +370,13 @@ module WXRuby3
370
370
  spec.new_object 'WXIntegerValidator::Clone',
371
371
  'WXUnsignedValidator::Clone',
372
372
  'WXFloatValidator::Clone'
373
+ %w[WXIntegerValidator WXUnsignedValidator WXFloatValidator].each do |klass|
374
+ spec.no_proxy "#{klass}::ProcessEvent"
375
+ spec.no_proxy "#{klass}::QueueEvent"
376
+ spec.no_proxy "#{klass}::AddPendingEvent"
377
+ spec.no_proxy "#{klass}::SetNextHandler"
378
+ spec.no_proxy "#{klass}::SetPreviousHandler"
379
+ end
373
380
  spec.suppress_warning(473,
374
381
  'WXIntegerValidator::Clone',
375
382
  'WXUnsignedValidator::Clone',
@@ -141,7 +141,7 @@ module WXRuby3
141
141
  spec.map_apply 'int * OUTPUT' => 'int* pIndex'
142
142
  end
143
143
  # for UIntProperty and IntProperty
144
- if Config.instance.features_set?('USE_LONGLONG')
144
+ if Config.instance.features_set?('USE_LONGLONG') || Config.instance.wx_version >= '3.3.0'
145
145
  # wxLongLong mapping to be considered before considering 'long' (see typecheck precedence)
146
146
  spec.map 'const wxLongLong&' => 'Integer' do
147
147
  map_in temp: 'wxLongLong tmp', code: <<~__CODE
@@ -162,7 +162,7 @@ module WXRuby3
162
162
  end
163
163
  else
164
164
  spec.ignore 'wxUIntProperty::wxUIntProperty(const wxString &, const wxString &, const wxULongLong &)',
165
- 'wxIntProperty::wxUIntProperty(const wxString &, const wxString &, const wxLongLong &)'
165
+ 'wxIntProperty::wxIntProperty(const wxString &, const wxString &, const wxLongLong &)'
166
166
  end
167
167
  spec.new_object 'wxArrayStringProperty::CreateEditorDialog'
168
168
  spec.suppress_warning(473, 'wxArrayStringProperty::CreateEditorDialog')
@@ -39,9 +39,10 @@ module WXRuby3
39
39
  spec.extend_interface 'wxPropertyGridInterface',
40
40
  'void SetPropertyValues(const wxVariant &list, const wxPGPropArgCls& defaultCategory = 0)'
41
41
  # optionals
42
- spec.ignore_unless 'USE_LONGLONG',
43
- 'wxPropertyGridInterface::GetPropertyValueAsLongLong',
44
- 'wxPropertyGridInterface::GetPropertyValueAsULongLong'
42
+ unless Config.instance.features_set?('USE_LONGLONG') || Config.instance.wx_version >= '3.3.0'
43
+ spec.ignore_unless 'wxPropertyGridInterface::GetPropertyValueAsLongLong',
44
+ 'wxPropertyGridInterface::GetPropertyValueAsULongLong'
45
+ end
45
46
  spec.ignore_unless 'USE_DATETIME', 'wxPropertyGridInterface::GetPropertyValueAsDateTime'
46
47
  spec.ignore_unless 'USE_VALIDATORS', 'wxPropertyGridInterface::GetPropertyValidator'
47
48
  # fix incorrect XML documentation
@@ -24,6 +24,13 @@ module WXRuby3
24
24
  spec.ignore 'wxTextCtrl::GTKGetTextBuffer',
25
25
  'wxTextCtrl::GTKGetEditable'
26
26
  end
27
+ if Config.instance.wx_version >= '3.3.0' && Config.instance.wx_port == :wxmsw
28
+ spec.items << 'wxTextSearch' << 'wxTextSearchResult'
29
+ spec.regard 'wxTextSearchResult::m_start', 'wxTextSearchResult::m_end'
30
+ spec.make_readonly 'wxTextSearchResult::m_start', 'wxTextSearchResult::m_end'
31
+ spec.rename_for_ruby 'start' => 'wxTextSearchResult::m_start',
32
+ 'end' => 'wxTextSearchResult::m_end'
33
+ end
27
34
  if Config.instance.wx_port == :wxqt
28
35
  # not implemented
29
36
  spec.ignore 'wxTextCtrl::OnDropFiles'
@@ -0,0 +1,34 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 wxWidgets interface director
7
+ ###
8
+
9
+ require_relative './window'
10
+
11
+ module WXRuby3
12
+
13
+ class Director
14
+
15
+ class TipWindow < Window
16
+
17
+ def setup
18
+ super
19
+ spec.disable_proxies
20
+ spec.ignore 'wxTipWindow::SetTipWindowPtr'
21
+ spec.ignore 'wxTipWindow::wxTipWindow'
22
+ spec.add_extend_code 'wxTipWindow', <<~__HEREDOC
23
+ wxTipWindow(wxWindow* parent, const wxString& text, wxCoord maxLength = 100)
24
+ {
25
+ return new wxTipWindow(parent, text, maxLength);
26
+ }
27
+ __HEREDOC
28
+ end
29
+
30
+ end
31
+
32
+ end
33
+
34
+ end
@@ -142,7 +142,7 @@ module WXRuby3
142
142
  {
143
143
  return wxVariant(TYPE(rbval) == T_TRUE);
144
144
  }
145
- #ifdef wxUSE_LONGLONG
145
+ #if !defined(wxUSE_LONGLONG) || (wxUSE_LONGLONG == 1)
146
146
  if ((sizeof(long) < 8) && (TYPE(rbval) == T_BIGNUM) && (rb_big_sign(rbval) == 0))
147
147
  {
148
148
  wxLongLong_t ll = rb_big2ll(rbval);
@@ -227,7 +227,7 @@ module WXRuby3
227
227
  $1 = rb_obj_is_kind_of($input, rb_const_get(mWxPG, var_ColourPropertyValue_id()));
228
228
  __CODE
229
229
  end
230
- if Config.instance.features_set?('USE_LONGLONG')
230
+ if Config.instance.features_set?('USE_LONGLONG') || Config.instance.wx_version >= '3.3.0'
231
231
  # wxLongLong mapping to be considered before considering 'long' (see typecheck precedence)
232
232
  spec.map 'wxLongLong' => 'Integer' do
233
233
  map_in code: <<~__CODE
@@ -66,7 +66,6 @@ module WXRuby3
66
66
  __CODE
67
67
  end
68
68
  spec.ignore [
69
- 'wxWindow::PopEventHandler',
70
69
  'wxWindow::SetConstraints',
71
70
  'wxWindow::GetHandle',
72
71
  'wxWindow::GetSize(int *,int *) const', # no need; prefer the wxSize version
@@ -83,6 +82,15 @@ module WXRuby3
83
82
  'wxWindow::Raise',
84
83
  'wxWindow::Lower'
85
84
  ]
85
+
86
+ # Event handler chaining methods; pushed handlers always remain owned by Ruby
87
+ # wxRuby3 will automatically pop any remaining handlers when windows get deleted
88
+ # also ignore this
89
+ spec.ignore 'wxWindow::PopEventHandler', ignore_doc: false
90
+ # and instead add an argument-less version (will use default argument of C++ impl)
91
+ # as we do want C++ side to delete any popped handler
92
+ spec.extend_interface 'wxWindow', 'wxEvtHandler *PopEventHandler()'
93
+
86
94
  # no real docs and can't find actual examples of usage; ignore
87
95
  spec.ignore 'wxWindow::GetConstraints', 'wxWindow::SetConstraints'
88
96
  # redefine these so a nil parent is accepted
@@ -6,7 +6,6 @@
6
6
  # wxRuby3 interface Director class
7
7
  ###
8
8
 
9
- require 'ostruct'
10
9
  require 'set'
11
10
  require 'pathname'
12
11
  require 'tempfile'
@@ -49,6 +49,9 @@ module WXRuby3
49
49
  @template_params << txt
50
50
  end
51
51
  @args_string = element.at_xpath('argsstring').text
52
+ # transform unified initializers to ctor form (SWIG does not like unified initializers)
53
+ # (also see ParamDef#extract)
54
+ @args_string.gsub!(/(\w+(::\w+)*)\s*{([^}]*)}/) { |_| "#{$1}(#{$3})"}
52
55
  check_deprecated
53
56
  element.xpath('param').each do |node|
54
57
  p = ParamDef.new(node)
@@ -370,6 +373,8 @@ module WXRuby3
370
373
  end
371
374
  if element.at_xpath('defval')
372
375
  @default = BaseDef.flatten_node(element.at_xpath('defval'))
376
+ # transform unified initializers to ctor form (SWIG does not like unified initializers)
377
+ @default.sub!(/(\w+(::\w+)*)\s*{([^}]*)}/) { |_| "#{$1}(#{$3})"}
373
378
  end
374
379
  end
375
380
  rescue Exception
@@ -6,23 +6,42 @@
6
6
  - :pattern: !ruby/regexp /.*/
7
7
  :replace: ''
8
8
  :post:
9
- - :pattern: !ruby/regexp /This\s+implies\s+that\s+the\s+event\s+should\s+be\s+allocated\s+on\s+the\s+heap\s+and/
10
- :subst: 'This implies'
11
- - :pattern: !ruby/regexp /\{Wx::EvtHandler#queue_event\}.*For\s+example:/
9
+ - :pattern: !ruby/regexp /\,\s+i\.e\.\s+it\s+will\s+delete\s+it\s+itself/
12
10
  :subst: ''
13
- - :pattern: !ruby/regexp /Note.*problem:/
11
+ - :pattern: !ruby/regexp /This\s+implies\s+that\s+the\s+event\s+should\s+be\s+allocated.*deleted\s+at\s+any\s+moment\)/
12
+ :subst: "This implies that the event (or any of it's member objects) should not be used/changed after the function returns (as it can be handled and subsequently discarded at any moment)"
13
+ - :pattern: !ruby/regexp /\{Wx::EvtHandler#queue_event\}.*not\s+used\s+by\s+the\s+calling\s+thread\s+any\s+more\./
14
+ :subst: ''
15
+ - :pattern: !ruby/regexp /Care\s+should\s+still\s+be\s+taken\s+to\s+avoid\s+that\s+some\s+fields.*/
16
+ :subst: ''
17
+ - :pattern: !ruby/regexp /Example:/
18
+ :subst: ''
19
+ - :pattern: !ruby/regexp /Note\s+that\s+if\s+you\s+want\s+to\s+pass\s+more\s+data.*/
20
+ :subst: ''
21
+ - :pattern: !ruby/regexp /Reimplemented\s+in.*/
22
+ :subst: ''
23
+ :wxEvtHandler.AddPendingEvent:
24
+ :detail:
25
+ :post:
26
+ - :pattern: !ruby/regexp /This\s+function\s+is\s+similar\s+to\s+\{Wx::EvtHandler#queue_event\}.*/
27
+ :subst: 'This function is similar to {Wx::EvtHandler#queue_event}.'
28
+ - :pattern: !ruby/regexp /A\s+copy\s+of\s+event\s+is\s+made\s+by\s+the\s+function,.*/
29
+ :subst: 'Other than {Wx::EvtHandler#queue_event} this method creates a (shallow) copy of event before queueing the copied event. In case (user defined) event classes require deep copying of Ruby member object these classes should override the #initialize_clone method (**NOT** #clone as wxRuby3 does not currently support overriding event class #clone methods).'
30
+ - :pattern: !ruby/regexp /Reimplemented\s+in.*/
14
31
  :subst: ''
15
32
  :wxEvtHandler.SetNextHandler:
33
+ :brief:
34
+ :post:
35
+ - :pattern: !ruby/regexp /Sets\s+the\s+pointer\s+to\s+the\s+next\s+handler\./
36
+ :subst: 'Inserts the given handler as the next handler in the chain.'
16
37
  :detail:
17
38
  :pre:
18
- :programlisting:
19
- - :pattern: !ruby/regexp /.*/
20
- :replace: |
21
-
22
- ```ruby
23
- handlerA.set_next_handler(handlerB)
24
- handlerB.set_previous_handler(handlerA)
25
- ```
39
+ :para:
40
+ - :pattern: !ruby/regexp /See.*ProcessEvent\(\)/
41
+ :replace: |
42
+ In wxRuby this fully handles double linking, i.e. wxRuby will take care of pointing the handler given
43
+ back to this handler as well. There is no need to call set_previous_handler so this method is not supported
44
+ in wxRuby3.
26
45
  :wxEvtHandler.TryBefore:
27
46
  :detail:
28
47
  :pre:
@@ -201,6 +201,7 @@ module WXRuby3
201
201
  Director.Spec(pkg, 'wxDragDrop', requirements: %w[USE_DRAG_AND_DROP])
202
202
  Director.Spec(pkg, 'wxContextHelpButton', requirements: %w[USE_HELP])
203
203
  Director.Spec(pkg, 'wxHelpProvider', requirements: %w[USE_HELP])
204
+ Director.Spec(pkg, 'wxTipWindow', requirements: %w[USE_HELP])
204
205
  Director.Spec(pkg, 'wxHelpController', requirements: %w[USE_HELP])
205
206
  Director.Spec(pkg, 'wxExtHelpController', director: Director::HelpController, requirements: %w[USE_HELP])
206
207
  Director.Spec(pkg, 'wxTaskBarIconEvent', director: Director::Event, requirements: %w[USE_TASKBARICON])
@@ -364,7 +364,7 @@ module WXRuby3
364
364
  }
365
365
  __CODE
366
366
  map_directorout code: <<~__CODE
367
- if (TYPE($input) != T_ARRAY)
367
+ if (TYPE($input) == T_ARRAY)
368
368
  {
369
369
  for (int i = 0; i < RARRAY_LEN($input); i++)
370
370
  {
@@ -398,7 +398,7 @@ module WXRuby3
398
398
  }
399
399
  __CODE
400
400
  map_directorout code: <<~__CODE
401
- if (TYPE($input) != T_ARRAY)
401
+ if (TYPE($input) == T_ARRAY)
402
402
  {
403
403
  for (int i = 0; i < RARRAY_LEN($input); i++)
404
404
  {
@@ -167,7 +167,7 @@ module Dialogs
167
167
  end
168
168
 
169
169
  create(parent, -1, "Preferences")
170
- create_buttons(Wx::ID_OK|Wx::ID_CANCEL)
170
+ create_buttons(Wx::OK|Wx::CANCEL)
171
171
  book_ctrl.set_images(imgs)
172
172
  book_ctrl.add_page(file_panel(book_ctrl), "File", false, img_id1)
173
173
  book_ctrl.add_page(cdrom_panel(book_ctrl), "CD ROM", false, img_id2)
@@ -23,6 +23,7 @@ class ComboCtrlCtrlTests < WxRuby::Test::GUITests
23
23
  end
24
24
 
25
25
  def create(parent)
26
+ GC.start
26
27
  # need to finish creating the list view here
27
28
  # as calling super here would just call Wx::ComboPopup#create and not Wx::ListView#create
28
29
  # we need to use Ruby magic