wxruby3 1.7.0 → 1.8.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 (220) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +27 -2
  3. data/README.md +15 -15
  4. data/ext/wxruby3/include/wxRubyApp.h +145 -46
  5. data/ext/wxruby3/include/wxruby-ComboPopup.h +25 -8
  6. data/ext/wxruby3/include/wxruby-GCTracking.h +262 -0
  7. data/ext/wxruby3/include/wxruby-MBConv.h +190 -0
  8. data/ext/wxruby3/include/wxruby-SharedEventHandler.h +183 -0
  9. data/ext/wxruby3/include/wxruby-SharedPtr.h +104 -0
  10. data/ext/wxruby3/include/wxruby-runtime.h +29 -0
  11. data/ext/wxruby3/swig/custom/rubytracking.swg +8 -22
  12. data/ext/wxruby3/swig/custom/wx_ruby_shared_ptr.i +434 -0
  13. data/ext/wxruby3/swig/custom/wx_shared_ptr.i +431 -0
  14. data/ext/wxruby3/swig/mark_free_impl.i +7 -132
  15. data/ext/wxruby3/swig/memory_management.i +8 -44
  16. data/ext/wxruby3/swig/wx.i +46 -73
  17. data/lib/wx/core/const.rb +0 -1
  18. data/lib/wx/core/context_help.rb +17 -0
  19. data/lib/wx/core/cursor.rb +1 -0
  20. data/lib/wx/core/helpcontrollerhelpprovider.rb +10 -2
  21. data/lib/wx/core/mbconv.rb +11 -0
  22. data/lib/wx/core/media_ctrl.rb +31 -0
  23. data/lib/wx/core/top_level_window.rb +7 -0
  24. data/lib/wx/core.rb +6 -0
  25. data/lib/wx/doc/art_provider.rb +17 -0
  26. data/lib/wx/doc/context_help.rb +42 -0
  27. data/lib/wx/doc/core.rb +0 -5
  28. data/lib/wx/doc/functions.rb +10 -0
  29. data/lib/wx/doc/gen/affine_matrix2d.rb +2 -0
  30. data/lib/wx/doc/gen/art_provider.rb +12 -0
  31. data/lib/wx/doc/gen/aui/aui_notebook_event.rb +15 -15
  32. data/lib/wx/doc/gen/aui/aui_pane_info.rb +8 -8
  33. data/lib/wx/doc/gen/aui/aui_tool_bar_event.rb +5 -5
  34. data/lib/wx/doc/gen/book_ctrl_base.rb +2 -1
  35. data/lib/wx/doc/gen/calendar_event.rb +5 -5
  36. data/lib/wx/doc/gen/choicebook.rb +2 -2
  37. data/lib/wx/doc/gen/collapsible_pane.rb +1 -1
  38. data/lib/wx/doc/gen/colour_dialog.rb +1 -1
  39. data/lib/wx/doc/gen/colour_picker_event.rb +3 -3
  40. data/lib/wx/doc/gen/context_help_button.rb +0 -53
  41. data/lib/wx/doc/gen/core.rb +4 -4
  42. data/lib/wx/doc/gen/credential_entry_dialog.rb +2 -2
  43. data/lib/wx/doc/gen/date_event.rb +2 -2
  44. data/lib/wx/doc/gen/dial_up_event.rb +2 -2
  45. data/lib/wx/doc/gen/dir_filter_list_ctrl.rb +2 -2
  46. data/lib/wx/doc/gen/event.rb +58 -58
  47. data/lib/wx/doc/gen/ext_help_controller.rb +62 -16
  48. data/lib/wx/doc/gen/file_ctrl.rb +4 -4
  49. data/lib/wx/doc/gen/file_dir_picker_event.rb +2 -2
  50. data/lib/wx/doc/gen/file_system.rb +1 -1
  51. data/lib/wx/doc/gen/find_dialog_event.rb +5 -5
  52. data/lib/wx/doc/gen/font_picker_event.rb +1 -1
  53. data/lib/wx/doc/gen/grid/grid_ctrl.rb +67 -32
  54. data/lib/wx/doc/gen/header_ctrl_event.rb +13 -13
  55. data/lib/wx/doc/gen/help_controller.rb +45 -2
  56. data/lib/wx/doc/gen/html/html_help_controller.rb +74 -32
  57. data/lib/wx/doc/gen/html/html_help_window.rb +3 -3
  58. data/lib/wx/doc/gen/html/html_window.rb +4 -4
  59. data/lib/wx/doc/gen/hyperlink_ctrl.rb +1 -1
  60. data/lib/wx/doc/gen/list_ctrl.rb +22 -22
  61. data/lib/wx/doc/gen/listbook.rb +2 -2
  62. data/lib/wx/doc/gen/mb_conv.rb +10 -0
  63. data/lib/wx/doc/gen/media_event.rb +6 -6
  64. data/lib/wx/doc/gen/notebook.rb +2 -2
  65. data/lib/wx/doc/gen/pg/pg_validation_info.rb +14 -14
  66. data/lib/wx/doc/gen/pg/property_grid_interface.rb +2 -2
  67. data/lib/wx/doc/gen/rbn/ribbon_art_provider.rb +19 -9
  68. data/lib/wx/doc/gen/rbn/ribbon_button_bar.rb +2 -2
  69. data/lib/wx/doc/gen/rbn/ribbon_gallery.rb +3 -3
  70. data/lib/wx/doc/gen/rbn/ribbon_panel.rb +2 -2
  71. data/lib/wx/doc/gen/rbn/ribbon_tool_bar.rb +2 -2
  72. data/lib/wx/doc/gen/rt/event_list.rb +17 -0
  73. data/lib/wx/doc/gen/rt/shared_evt_handler.rb +14 -0
  74. data/lib/wx/doc/gen/rt/thread_event.rb +71 -0
  75. data/lib/wx/doc/gen/rtc/rich_text_ctrl.rb +19 -19
  76. data/lib/wx/doc/gen/sash_event.rb +2 -2
  77. data/lib/wx/doc/gen/sash_layout_window.rb +2 -2
  78. data/lib/wx/doc/gen/search_ctrl.rb +2 -2
  79. data/lib/wx/doc/gen/spin_ctrl.rb +2 -2
  80. data/lib/wx/doc/gen/splitter_window.rb +6 -6
  81. data/lib/wx/doc/gen/stc/styled_text_event.rb +34 -34
  82. data/lib/wx/doc/gen/task_bar_icon_event.rb +10 -10
  83. data/lib/wx/doc/gen/text_ctrl.rb +4 -4
  84. data/lib/wx/doc/gen/toggle_button.rb +1 -1
  85. data/lib/wx/doc/gen/toolbook.rb +2 -2
  86. data/lib/wx/doc/gen/top_level_window.rb +19 -0
  87. data/lib/wx/doc/gen/tree_ctrl.rb +21 -21
  88. data/lib/wx/doc/gen/treebook.rb +4 -4
  89. data/lib/wx/doc/gen/utils.rb +2 -2
  90. data/lib/wx/doc/gen/web/event_list.rb +95 -0
  91. data/lib/wx/doc/gen/web/web_view.rb +1136 -0
  92. data/lib/wx/doc/gen/web/web_view_event.rb +210 -0
  93. data/lib/wx/doc/gen/web/web_view_handler.rb +318 -0
  94. data/lib/wx/doc/gen/window.rb +1 -1
  95. data/lib/wx/doc/gen/wizard_event.rb +7 -7
  96. data/lib/wx/doc/html/html_help_controller.rb +23 -1
  97. data/lib/wx/doc/mbconv.rb +108 -0
  98. data/lib/wx/doc/rt/shared_event_handler.rb +49 -0
  99. data/lib/wx/doc/rt/thread_event.rb +28 -0
  100. data/lib/wx/doc/webview.rb +40 -0
  101. data/lib/wx/helpers.rb +1 -1
  102. data/lib/wx/html/htmlhelpcontroller.rb +10 -0
  103. data/lib/wx/keyword_defs.rb +11 -0
  104. data/lib/wx/rt/events/evt_list.rb +8 -0
  105. data/lib/wx/rt/require.rb +8 -0
  106. data/lib/wx/rt/thread_event.rb +14 -0
  107. data/lib/wx/rt.rb +16 -0
  108. data/lib/wx/version.rb +1 -1
  109. data/lib/wx/web/events/evt_list.rb +74 -0
  110. data/lib/wx/web/require.rb +8 -0
  111. data/lib/wx/web/webview.rb +106 -0
  112. data/lib/wx/web.rb +17 -0
  113. data/lib/wx/wxruby/cmd/setup.rb +15 -0
  114. data/lib/wx.rb +2 -0
  115. data/rakelib/configure.rb +24 -0
  116. data/rakelib/gem.rb +3 -2
  117. data/rakelib/install.rb +54 -27
  118. data/rakelib/lib/config/macosx.rb +7 -5
  119. data/rakelib/lib/config/mingw.rb +66 -5
  120. data/rakelib/lib/config/pkgman/mingw.rb +1 -1
  121. data/rakelib/lib/config/unixish.rb +4 -2
  122. data/rakelib/lib/config.rb +37 -3
  123. data/rakelib/lib/core/include/client_data.inc +38 -17
  124. data/rakelib/lib/core/include/funcall.inc +1 -1
  125. data/rakelib/lib/core/include/swigdirector.inc +3 -3
  126. data/rakelib/lib/core/include/swigrubyrun.inc +14 -26
  127. data/rakelib/lib/core/package.rb +0 -2
  128. data/rakelib/lib/director/app.rb +1 -8
  129. data/rakelib/lib/director/art_provider.rb +7 -3
  130. data/rakelib/lib/director/comboctrl.rb +0 -7
  131. data/rakelib/lib/director/context_help_button.rb +35 -2
  132. data/rakelib/lib/director/event_handler.rb +32 -28
  133. data/rakelib/lib/director/fs_file.rb +15 -10
  134. data/rakelib/lib/director/functions.rb +8 -0
  135. data/rakelib/lib/director/grid_cell_attr.rb +1 -3
  136. data/rakelib/lib/director/grid_cell_editor.rb +14 -12
  137. data/rakelib/lib/director/grid_cell_renderer.rb +11 -8
  138. data/rakelib/lib/director/grid_ctrl.rb +140 -121
  139. data/rakelib/lib/director/help_controller.rb +70 -2
  140. data/rakelib/lib/director/mb_conv.rb +30 -0
  141. data/rakelib/lib/director/menu.rb +92 -42
  142. data/rakelib/lib/director/menu_bar.rb +84 -45
  143. data/rakelib/lib/director/menu_item.rb +2 -2
  144. data/rakelib/lib/director/persistence_manager.rb +3 -2
  145. data/rakelib/lib/director/preview_frame.rb +2 -2
  146. data/rakelib/lib/director/richtext_buffer.rb +5 -2
  147. data/rakelib/lib/director/shared_evt_handler.rb +30 -0
  148. data/rakelib/lib/director/sizer.rb +8 -17
  149. data/rakelib/lib/director/sizer_item.rb +3 -4
  150. data/rakelib/lib/director/task_bar_icon.rb +7 -7
  151. data/rakelib/lib/director/thread_event.rb +33 -0
  152. data/rakelib/lib/director/validator.rb +3 -1
  153. data/rakelib/lib/director/variant.rb +16 -12
  154. data/rakelib/lib/director/webview.rb +166 -0
  155. data/rakelib/lib/director/webview_event.rb +37 -0
  156. data/rakelib/lib/director/webview_handler.rb +63 -0
  157. data/rakelib/lib/generate/doc/thread_event.yaml +20 -0
  158. data/rakelib/lib/generate/doc/web_view.yaml +135 -0
  159. data/rakelib/lib/generate/doc/web_view_event.yaml +38 -0
  160. data/rakelib/lib/generate/doc/web_view_handler.yaml +58 -0
  161. data/rakelib/lib/specs/interfaces.rb +12 -0
  162. data/rakelib/lib/typemap/common.rb +34 -1
  163. data/rakelib/lib/typemap/mb_conv.rb +58 -0
  164. data/rakelib/prepost.rake +23 -31
  165. data/rakelib/prepost.rb +20 -0
  166. data/samples/event/threaded.rb +295 -42
  167. data/samples/event/tn_threaded.png +0 -0
  168. data/samples/help/doc/back.gif +0 -0
  169. data/samples/help/doc/contents.gif +0 -0
  170. data/samples/help/doc/cshelp.txt +9 -0
  171. data/samples/help/doc/doc.chm +0 -0
  172. data/samples/help/doc/doc.cnt +8 -0
  173. data/samples/help/doc/doc.h +7 -0
  174. data/samples/help/doc/doc.hhc +40 -0
  175. data/samples/help/doc/doc.hhk +31 -0
  176. data/samples/help/doc/doc.hhp +33 -0
  177. data/samples/help/doc/doc.hpj +21 -0
  178. data/samples/help/doc/doc.htm +27 -0
  179. data/samples/help/doc/doc1.htm +24 -0
  180. data/samples/help/doc/doc2.htm +12 -0
  181. data/samples/help/doc/doc3.htm +12 -0
  182. data/samples/help/doc/doc4.htm +12 -0
  183. data/samples/help/doc/doc5.htm +14 -0
  184. data/samples/help/doc/forward.gif +0 -0
  185. data/samples/help/doc/up.gif +0 -0
  186. data/samples/help/doc.chm +0 -0
  187. data/samples/help/doc.chw +0 -0
  188. data/samples/help/doc.zip +0 -0
  189. data/samples/help/help.rb +352 -0
  190. data/samples/help/tn_help.png +0 -0
  191. data/samples/webview/handler_advanced.html +55 -0
  192. data/samples/webview/tn_webview.png +0 -0
  193. data/samples/webview/webview.rb +1264 -0
  194. data/tests/assets/handler_advanced.html +55 -0
  195. data/tests/assets/test.css +1 -0
  196. data/tests/assets/test.html +9 -0
  197. data/tests/assets/test.zip +0 -0
  198. data/tests/lib/text_entry_tests.rb +2 -2
  199. data/tests/lib/wxapp_runner.rb +40 -0
  200. data/tests/lib/wxframe_runner.rb +17 -2
  201. data/tests/test_art.rb +8 -8
  202. data/tests/test_clipboard.rb +4 -4
  203. data/tests/test_config.rb +6 -6
  204. data/tests/test_exceptions.rb +8 -6
  205. data/tests/test_ext_controls.rb +3 -3
  206. data/tests/test_file_dialog.rb +5 -5
  207. data/tests/test_font.rb +7 -7
  208. data/tests/test_grid_ctrl.rb +133 -0
  209. data/tests/test_help.rb +88 -0
  210. data/tests/test_intl.rb +1 -1
  211. data/tests/test_media_ctrl.rb +14 -6
  212. data/tests/test_menu.rb +94 -86
  213. data/tests/test_persistence.rb +1 -1
  214. data/tests/test_proof_check.rb +5 -5
  215. data/tests/test_propgrid.rb +1 -1
  216. data/tests/test_shared_event_handler.rb +141 -0
  217. data/tests/test_std_controls.rb +5 -5
  218. data/tests/test_webview.rb +492 -0
  219. data/tests/test_window.rb +3 -3
  220. metadata +78 -2
@@ -44,6 +44,12 @@ module WXRuby3
44
44
  spec.ignore 'wxGrid::SetCellValue(const wxString &,int,int)'
45
45
  spec.ignore 'wxGrid::SetTable' # there is wxGrid::AssignTable now that always takes ownership
46
46
 
47
+ spec.regard 'wxGrid::CanHaveAttributes',
48
+ 'wxGrid::GetColMinimalWidth',
49
+ 'wxGrid::GetColRight',
50
+ 'wxGrid::GetColLeft',
51
+ 'wxGrid::GetRowMinimalHeight'
52
+
47
53
  spec.regard 'wxGridSizesInfo::m_sizeDefault',
48
54
  'wxGridSizesInfo::m_customSizes'
49
55
  spec.rename_for_ruby 'size_default' => 'wxGridSizesInfo::m_sizeDefault',
@@ -303,11 +309,6 @@ module WXRuby3
303
309
  spec.add_header_code <<~__HEREDOC
304
310
  #include <wx/clntdata.h>
305
311
 
306
- // declare the global table for grid cell attributes
307
- WX_DECLARE_VOIDPTR_HASH_MAP(VALUE,
308
- WXRBGridCellAttrValueHash);
309
- static WXRBGridCellAttrValueHash Grid_Cell_Attr_Value_Map;
310
-
311
312
  WXRUBY_TRACE_GUARD(WxRubyTraceGCMarkGridCellAttr, "GC_MARK_GRID_CELL_ATTR")
312
313
  WXRUBY_TRACE_GUARD(WxRubyTraceGCTrackGridCellAttr, "GC_TRACK_GRID_CELL_ATTR")
313
314
  WXRUBY_TRACE_GUARD(WxRubyTraceGCMarkGridCellEditor, "GC_MARK_GRID_CELL_EDITOR")
@@ -315,22 +316,41 @@ module WXRuby3
315
316
  WXRUBY_TRACE_GUARD(WxRubyTraceGCMarkGridCellRenderer, "GC_MARK_GRID_CELL_RENDERER")
316
317
  WXRUBY_TRACE_GUARD(WxRubyTraceGCTrackGridCellRenderer, "GC_TRACK_GRID_CELL_RENDERER")
317
318
 
318
- static void wxRuby_UnregisterGridCellAttr(wxGridCellAttr* wx_attr)
319
+ static const std::string WXRUBY_GRID_CELL_ATTR = { "WXRUBY_GRID_CELL_ATTR" };
320
+
321
+ // define the grid cell attribute marker
322
+ static void wxRuby_markGridCellAttr(const TGCTrackingValueMap& values)
319
323
  {
320
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellAttr, 2)
321
- WXRUBY_TRACE("> wxRuby_UnregisterGridCellAttr : " << wx_attr << " -> " << Grid_Cell_Attr_Value_Map[wx_attr])
324
+ WXRUBY_TRACE_IF(WxRubyTraceGCMarkGridCellAttr, 2)
325
+ WXRUBY_TRACE("> wxRuby_markGridCellAttr")
322
326
  WXRUBY_TRACE_END
323
327
 
324
- if (Grid_Cell_Attr_Value_Map.count(wx_attr) != 0)
328
+ for(const auto& ti : values)
325
329
  {
326
- VALUE object = Grid_Cell_Attr_Value_Map[wx_attr];
327
- if (object && !NIL_P(object))
328
- {
329
- DATA_PTR(object) = 0; // unlink
330
- }
331
- Grid_Cell_Attr_Value_Map.erase(wx_attr);
330
+ VALUE obj = ti.second;
331
+
332
+ WXRUBY_TRACE_IF(WxRubyTraceGCMarkGridCellAttr, 2)
333
+ WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(obj) == T_DATA ? DATA_PTR(obj) : 0))
334
+ WXRUBY_TRACE("| wxRuby_markGridCellAttr : " << ti.first << "|" << (void*)c_ptr)
335
+ WXRUBY_TRACE_END
336
+
337
+ rb_gc_mark(obj);
332
338
  }
333
339
 
340
+ WXRUBY_TRACE_IF(WxRubyTraceGCMarkGridCellAttr, 2)
341
+ WXRUBY_TRACE("< wxRuby_markGridCellAttr")
342
+ WXRUBY_TRACE_END
343
+ }
344
+
345
+ static void wxRuby_UnregisterGridCellAttr(wxGridCellAttr* wx_attr)
346
+ {
347
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellAttr, 2)
348
+ WXRUBY_TRACE("> wxRuby_UnregisterGridCellAttr : " << wx_attr << " -> " << wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_ATTR, wx_attr))
349
+ WXRUBY_TRACE_END
350
+
351
+ wxRuby_UnlinkCategoryValue(WXRUBY_GRID_CELL_ATTR, wx_attr);
352
+ wxRuby_UnregisterCategoryValue(WXRUBY_GRID_CELL_ATTR, wx_attr);
353
+
334
354
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellAttr, 2)
335
355
  WXRUBY_TRACE("< wxRuby_UnregisterGridCellAttr : " << wx_attr)
336
356
  WXRUBY_TRACE_END
@@ -338,10 +358,7 @@ module WXRuby3
338
358
 
339
359
  extern VALUE wxRuby_GridCellAttrInstance(wxGridCellAttr* wx_attr)
340
360
  {
341
- if (Grid_Cell_Attr_Value_Map.count(wx_attr) == 0)
342
- return Qnil;
343
- else
344
- return Grid_Cell_Attr_Value_Map[wx_attr];
361
+ return wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_ATTR, wx_attr);
345
362
  }
346
363
 
347
364
  // specialized client data class
@@ -350,7 +367,7 @@ module WXRuby3
350
367
  public:
351
368
  WXRBGridCellAttrMonitor() : wx_attr(0), rb_attr(Qnil) {}
352
369
  WXRBGridCellAttrMonitor(wxGridCellAttr* a, VALUE v) : wx_attr(a), rb_attr(v)
353
- { Grid_Cell_Attr_Value_Map[wx_attr] = rb_attr; }
370
+ { wxRuby_RegisterCategoryValue(WXRUBY_GRID_CELL_ATTR, wx_attr, rb_attr); }
354
371
  virtual ~WXRBGridCellAttrMonitor()
355
372
  { wxRuby_UnregisterGridCellAttr(wx_attr); }
356
373
  private:
@@ -361,22 +378,38 @@ module WXRuby3
361
378
  // and it's associated registration/de-registration functions
362
379
  extern void wxRuby_RegisterGridCellAttr(wxGridCellAttr* wx_attr, VALUE rb_attr)
363
380
  {
381
+ static bool is_marker_registered = false;
382
+
364
383
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellAttr, 2)
365
384
  WXRUBY_TRACE("> wxRuby_RegisterGridCellAttr : " << wx_attr << " -> " << rb_attr)
366
385
  WXRUBY_TRACE_END
367
386
 
368
387
  if (wx_attr && !NIL_P(rb_attr))
369
388
  {
370
- // always (keep) disown(ed); wxWidgets takes over ownership
371
- RDATA(rb_attr)->dfree = 0;
372
- if (Grid_Cell_Attr_Value_Map.count(wx_attr) == 0)
389
+ if (!is_marker_registered)
390
+ {
391
+ wxRuby_RegisterTrackingCategory(WXRUBY_GRID_CELL_ATTR, wxRuby_markGridCellAttr, true);
392
+ is_marker_registered = true;
393
+ }
394
+
395
+ // see if this attr is already tracked
396
+ if (wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_ATTR, wx_attr) == Qnil)
373
397
  {
374
398
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellAttr, 2)
375
399
  WXRUBY_TRACE("| wxRuby_RegisterGridCellAttr : installing monitor")
376
400
  WXRUBY_TRACE_END
377
401
 
402
+ // either a new Ruby created instance or an unwrapped C++ created instance
403
+ // always disown; wxWidgets takes over or keeps ownership of reference count
404
+ RDATA(rb_attr)->dfree = 0;
405
+
378
406
  wx_attr->SetClientObject(new WXRBGridCellAttrMonitor(wx_attr, rb_attr));
379
407
  }
408
+ else // already registered; will be disowned already
409
+ {
410
+ // increase the reference count for C++ to take over
411
+ wx_attr->IncRef();
412
+ }
380
413
  }
381
414
 
382
415
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellAttr, 2)
@@ -384,51 +417,40 @@ module WXRuby3
384
417
  WXRUBY_TRACE_END
385
418
  }
386
419
 
387
- // define the grid cell attribute marker
388
- static void wxRuby_markGridCellAttr()
420
+ static const std::string WXRUBY_GRID_CELL_EDITOR = { "WXRUBY_GRID_CELL_EDITOR" };
421
+
422
+ // define the grid cell editor marker
423
+ static void wxRuby_markGridCellEditor(const TGCTrackingValueMap& values)
389
424
  {
390
- WXRUBY_TRACE_IF(WxRubyTraceGCMarkGridCellAttr, 2)
391
- WXRUBY_TRACE("> wxRuby_markGridCellAttr")
425
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
426
+ WXRUBY_TRACE("> wxRuby_markGridCellEditor")
392
427
  WXRUBY_TRACE_END
393
428
 
394
- WXRBGridCellAttrValueHash::iterator it;
395
- for( it = Grid_Cell_Attr_Value_Map.begin(); it != Grid_Cell_Attr_Value_Map.end(); ++it )
429
+ for(const auto& ti : values)
396
430
  {
397
- VALUE obj = it->second;
431
+ VALUE obj = ti.second;
398
432
 
399
- WXRUBY_TRACE_IF(WxRubyTraceGCMarkGridCellAttr, 2)
433
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
400
434
  WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(obj) == T_DATA ? DATA_PTR(obj) : 0))
401
- WXRUBY_TRACE("| wxRuby_markGridCellAttr : " << it->first << "|" << (void*)c_ptr)
435
+ WXRUBY_TRACE("| wxRuby_markGridCellEditor : " << ti.first << "|" << (void*)c_ptr)
402
436
  WXRUBY_TRACE_END
403
437
 
404
438
  rb_gc_mark(obj);
405
439
  }
406
440
 
407
- WXRUBY_TRACE_IF(WxRubyTraceGCMarkGridCellAttr, 2)
408
- WXRUBY_TRACE("< wxRuby_markGridCellAttr")
441
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
442
+ WXRUBY_TRACE("< wxRuby_markGridCellEditor")
409
443
  WXRUBY_TRACE_END
410
444
  }
411
445
 
412
- // declare the global table for grid cell editors
413
- WX_DECLARE_VOIDPTR_HASH_MAP(VALUE,
414
- WXRBGridCellEditorValueHash);
415
- static WXRBGridCellEditorValueHash Grid_Cell_Editor_Value_Map;
416
-
417
446
  static void wxRuby_UnregisterGridCellEditor(wxGridCellEditor* wx_edt)
418
447
  {
419
448
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
420
- WXRUBY_TRACE("> wxRuby_UnregisterGridCellEditor : " << wx_edt << " -> " << Grid_Cell_Editor_Value_Map[wx_edt])
449
+ WXRUBY_TRACE("> wxRuby_UnregisterGridCellEditor : " << wx_edt << " -> " << wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_EDITOR, wx_edt))
421
450
  WXRUBY_TRACE_END
422
451
 
423
- if (Grid_Cell_Editor_Value_Map.count(wx_edt) != 0)
424
- {
425
- VALUE object = Grid_Cell_Editor_Value_Map[wx_edt];
426
- if (object && !NIL_P(object))
427
- {
428
- DATA_PTR(object) = 0; // unlink
429
- }
430
- Grid_Cell_Editor_Value_Map.erase(wx_edt);
431
- }
452
+ wxRuby_UnlinkCategoryValue(WXRUBY_GRID_CELL_EDITOR, wx_edt);
453
+ wxRuby_UnregisterCategoryValue(WXRUBY_GRID_CELL_EDITOR, wx_edt);
432
454
 
433
455
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
434
456
  WXRUBY_TRACE("< wxRuby_UnregisterGridCellEditor : " << wx_edt)
@@ -437,10 +459,7 @@ module WXRuby3
437
459
 
438
460
  extern VALUE wxRuby_GridCellEditorInstance(wxGridCellEditor* wx_edt)
439
461
  {
440
- if (Grid_Cell_Editor_Value_Map.count(wx_edt) == 0)
441
- return Qnil;
442
- else
443
- return Grid_Cell_Editor_Value_Map[wx_edt];
462
+ return wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_EDITOR, wx_edt);
444
463
  }
445
464
 
446
465
  // specialized client data class
@@ -449,7 +468,7 @@ module WXRuby3
449
468
  public:
450
469
  WXRBGridCellEditorMonitor() : wx_edt(0), rb_edt(Qnil) {}
451
470
  WXRBGridCellEditorMonitor(wxGridCellEditor* a, VALUE v) : wx_edt(a), rb_edt(v)
452
- { Grid_Cell_Editor_Value_Map[wx_edt] = rb_edt; }
471
+ { wxRuby_RegisterCategoryValue(WXRUBY_GRID_CELL_EDITOR, wx_edt, rb_edt); }
453
472
  virtual ~WXRBGridCellEditorMonitor()
454
473
  { wxRuby_UnregisterGridCellEditor(wx_edt); }
455
474
  private:
@@ -460,22 +479,38 @@ module WXRuby3
460
479
  // and it's associated registration function
461
480
  extern void wxRuby_RegisterGridCellEditor(wxGridCellEditor* wx_edt, VALUE rb_edt)
462
481
  {
482
+ static bool is_marker_registered = false;
483
+
463
484
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
464
485
  WXRUBY_TRACE("> wxRuby_RegisterGridCellEditor : " << wx_edt << " -> " << rb_edt)
465
486
  WXRUBY_TRACE_END
466
487
 
467
488
  if (wx_edt && !NIL_P(rb_edt))
468
489
  {
469
- // always (keep) disown(ed); wxWidgets takes over ownership
470
- RDATA(rb_edt)->dfree = 0;
471
- if (Grid_Cell_Editor_Value_Map.count(wx_edt) == 0)
490
+ if (!is_marker_registered)
491
+ {
492
+ wxRuby_RegisterTrackingCategory(WXRUBY_GRID_CELL_EDITOR, wxRuby_markGridCellEditor, true);
493
+ is_marker_registered = true;
494
+ }
495
+
496
+ // see if this renderer is already tracked
497
+ if (wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_EDITOR, wx_edt) == Qnil)
472
498
  {
473
499
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
474
500
  WXRUBY_TRACE("| wxRuby_RegisterGridCellEditor : installing monitor")
475
501
  WXRUBY_TRACE_END
476
502
 
503
+ // either a new Ruby created instance or an unwrapped C++ created instance
504
+ // always disown; wxWidgets takes over or keeps ownership of reference count
505
+ RDATA(rb_edt)->dfree = 0;
506
+
477
507
  wx_edt->SetClientObject(new WXRBGridCellEditorMonitor(wx_edt, rb_edt));
478
508
  }
509
+ else // already registered; will be disowned already
510
+ {
511
+ // increase the reference count for C++ to take over
512
+ wx_edt->IncRef();
513
+ }
479
514
  }
480
515
 
481
516
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
@@ -483,51 +518,40 @@ module WXRuby3
483
518
  WXRUBY_TRACE_END
484
519
  }
485
520
 
486
- // define the grid cell editor marker
487
- static void wxRuby_markGridCellEditor()
521
+ static const std::string WXRUBY_GRID_CELL_RENDERER = { "WXRUBY_GRID_CELL_RENDERER" };
522
+
523
+ // define the grid cell renderer marker
524
+ static void wxRuby_markGridCellRenderer(const TGCTrackingValueMap& values)
488
525
  {
489
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
490
- WXRUBY_TRACE("> wxRuby_markGridCellEditor")
526
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
527
+ WXRUBY_TRACE("> wxRuby_markGridCellRenderer")
491
528
  WXRUBY_TRACE_END
492
529
 
493
- WXRBGridCellEditorValueHash::iterator it;
494
- for( it = Grid_Cell_Editor_Value_Map.begin(); it != Grid_Cell_Editor_Value_Map.end(); ++it )
530
+ for(const auto& ti : values)
495
531
  {
496
- VALUE obj = it->second;
532
+ VALUE obj = ti.second;
497
533
 
498
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
534
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
499
535
  WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(obj) == T_DATA ? DATA_PTR(obj) : 0))
500
- WXRUBY_TRACE("| wxRuby_markGridCellEditor : " << it->first << "|" << (void*)c_ptr)
536
+ WXRUBY_TRACE("| wxRuby_markGridCellRenderer : " << ti.first << "|" << (void*)c_ptr)
501
537
  WXRUBY_TRACE_END
502
538
 
503
539
  rb_gc_mark(obj);
504
540
  }
505
541
 
506
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellEditor, 2)
507
- WXRUBY_TRACE("< wxRuby_markGridCellEditor")
542
+ WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
543
+ WXRUBY_TRACE("< wxRuby_markGridCellRenderer")
508
544
  WXRUBY_TRACE_END
509
545
  }
510
546
 
511
- // declare the global table for grid cell renderer
512
- WX_DECLARE_VOIDPTR_HASH_MAP(VALUE,
513
- WXRBGridCellRendererValueHash);
514
- static WXRBGridCellRendererValueHash Grid_Cell_Renderer_Value_Map;
515
-
516
547
  static void wxRuby_UnregisterGridCellRenderer(wxGridCellRenderer* wx_rnd)
517
548
  {
518
549
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
519
- WXRUBY_TRACE("> wxRuby_UnregisterGridCellRenderer : " << wx_rnd << " -> " << Grid_Cell_Renderer_Value_Map[wx_rnd])
550
+ WXRUBY_TRACE("> wxRuby_UnregisterGridCellRenderer : " << wx_rnd << " -> " << wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_RENDERER, wx_rnd))
520
551
  WXRUBY_TRACE_END
521
552
 
522
- if (Grid_Cell_Renderer_Value_Map.count(wx_rnd) != 0)
523
- {
524
- VALUE object = Grid_Cell_Renderer_Value_Map[wx_rnd];
525
- if (object && !NIL_P(object))
526
- {
527
- DATA_PTR(object) = 0; // unlink
528
- }
529
- Grid_Cell_Renderer_Value_Map.erase(wx_rnd);
530
- }
553
+ wxRuby_UnlinkCategoryValue(WXRUBY_GRID_CELL_RENDERER, wx_rnd);
554
+ wxRuby_UnregisterCategoryValue(WXRUBY_GRID_CELL_RENDERER, wx_rnd);
531
555
 
532
556
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
533
557
  WXRUBY_TRACE("< wxRuby_UnregisterGridCellRenderer : " << wx_rnd)
@@ -536,9 +560,7 @@ module WXRuby3
536
560
 
537
561
  extern VALUE wxRuby_GridCellRendererInstance(wxGridCellRenderer* wx_rnd)
538
562
  {
539
- if (Grid_Cell_Renderer_Value_Map.count(wx_rnd) == 0)
540
- return Qnil;
541
- return Grid_Cell_Renderer_Value_Map[wx_rnd];
563
+ return wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_RENDERER, wx_rnd);
542
564
  }
543
565
 
544
566
  // specialized client data class
@@ -547,7 +569,7 @@ module WXRuby3
547
569
  public:
548
570
  WXRBGridCellRendererMonitor() : wx_rnd(0), rb_rnd(Qnil) {}
549
571
  WXRBGridCellRendererMonitor(wxGridCellRenderer* a, VALUE v) : wx_rnd(a), rb_rnd(v)
550
- { Grid_Cell_Renderer_Value_Map[wx_rnd] = rb_rnd; }
572
+ { wxRuby_RegisterCategoryValue(WXRUBY_GRID_CELL_RENDERER, wx_rnd, rb_rnd); }
551
573
  virtual ~WXRBGridCellRendererMonitor()
552
574
  { wxRuby_UnregisterGridCellRenderer(wx_rnd); }
553
575
  private:
@@ -558,22 +580,38 @@ module WXRuby3
558
580
  // and it's associated registration/de-registration functions
559
581
  extern void wxRuby_RegisterGridCellRenderer(wxGridCellRenderer* wx_rnd, VALUE rb_rnd)
560
582
  {
583
+ static bool is_marker_registered = false;
584
+
561
585
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
562
586
  WXRUBY_TRACE("> wxRuby_RegisterGridCellRenderer : " << wx_rnd << " -> " << rb_rnd)
563
587
  WXRUBY_TRACE_END
564
588
 
565
589
  if (wx_rnd && !NIL_P(rb_rnd))
566
590
  {
567
- // always (keep) disowned(ed); wxWidgets takes over ownership
568
- RDATA(rb_rnd)->dfree = 0;
569
- if (Grid_Cell_Renderer_Value_Map.count(wx_rnd) == 0)
591
+ if (!is_marker_registered)
592
+ {
593
+ wxRuby_RegisterTrackingCategory(WXRUBY_GRID_CELL_RENDERER, wxRuby_markGridCellRenderer, true);
594
+ is_marker_registered = true;
595
+ }
596
+
597
+ // see if this renderer is already tracked
598
+ if (wxRuby_FindCategoryValue(WXRUBY_GRID_CELL_RENDERER, wx_rnd) == Qnil)
570
599
  {
571
600
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
572
601
  WXRUBY_TRACE("| wxRuby_RegisterGridCellRenderer : installing monitor")
573
602
  WXRUBY_TRACE_END
574
603
 
604
+ // either a new Ruby created instance or an unwrapped C++ created instance
605
+ // always disown; wxWidgets takes over or keeps ownership of reference count
606
+ RDATA(rb_rnd)->dfree = 0;
607
+
575
608
  wx_rnd->SetClientObject(new WXRBGridCellRendererMonitor(wx_rnd, rb_rnd));
576
609
  }
610
+ else // already registered; will be disowned already
611
+ {
612
+ // increase the reference count for C++ to take over
613
+ wx_rnd->IncRef();
614
+ }
577
615
  }
578
616
 
579
617
  WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
@@ -581,36 +619,7 @@ module WXRuby3
581
619
  WXRUBY_TRACE_END
582
620
  }
583
621
 
584
- // define the grid cell renderer marker
585
- static void wxRuby_markGridCellRenderer()
586
- {
587
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
588
- WXRUBY_TRACE("> wxRuby_markGridCellRenderer")
589
- WXRUBY_TRACE_END
590
-
591
- WXRBGridCellRendererValueHash::iterator it;
592
- for( it = Grid_Cell_Renderer_Value_Map.begin(); it != Grid_Cell_Renderer_Value_Map.end(); ++it )
593
- {
594
- VALUE obj = it->second;
595
-
596
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
597
- WXRUBY_TRACE_WITH(void *c_ptr = (TYPE(obj) == T_DATA ? DATA_PTR(obj) : 0))
598
- WXRUBY_TRACE("| wxRuby_markGridCellRenderer : " << it->first << "|" << (void*)c_ptr)
599
- WXRUBY_TRACE_END
600
-
601
- rb_gc_mark(obj);
602
- }
603
-
604
- WXRUBY_TRACE_IF(WxRubyTraceGCTrackGridCellRenderer, 2)
605
- WXRUBY_TRACE("< wxRuby_markGridCellRenderer")
606
- WXRUBY_TRACE_END
607
- }
608
-
609
622
  __HEREDOC
610
- # register the markers at module initialization
611
- spec.add_init_code 'wxRuby_AppendMarker(wxRuby_markGridCellAttr);',
612
- 'wxRuby_AppendMarker(wxRuby_markGridCellEditor);',
613
- 'wxRuby_AppendMarker(wxRuby_markGridCellRenderer);'
614
623
  # add type mappings to handle registration
615
624
  # first declare 'normal' type mapping for const pointer (for DrawCellHighlight)
616
625
  spec.map 'const wxGridCellAttr *' => 'Wx::GRID::GridCellAttr' do
@@ -622,10 +631,20 @@ module WXRuby3
622
631
  $result = wxRuby_GridCellAttrInstance($1); // check for already registered instance
623
632
  if (NIL_P($result))
624
633
  {
625
- // created by wxWidgets itself
626
- // convert and register
634
+ // As this editor was created in C++ it seems we have no registration yet
635
+ // but the reference counter will be at least 2 now (1 for C++ owner and 1
636
+ // increment for returning to us).
637
+ // We will now register a new Ruby object, keep it disowned and decrement
638
+ // for now. If passing to C++ again we will increment there.
627
639
  $result = SWIG_NewPointerObj(SWIG_as_voidptr($1), SWIGTYPE_p_wxGridCellAttr, 0);
628
640
  wxRuby_RegisterGridCellAttr($1, $result);
641
+ $1->DecRef();
642
+ }
643
+ else
644
+ {
645
+ // as this cell attr got passed from C++ it wll have incremented it's reference counter
646
+ // decrease that here; if we pass it back to C++ we will increase there
647
+ $1->DecRef();
629
648
  }
630
649
  __CODE
631
650
  map_check code: 'wxRuby_RegisterGridCellAttr($1, argv[$argnum-2]);'
@@ -21,15 +21,20 @@ module WXRuby3
21
21
  spec.rename_for_ruby('Init' => "#{spec.module_name}::Initialize")
22
22
  # ignore these (pure virtual) decls
23
23
  spec.ignore %w[
24
+ wxHelpControllerBase::DisplayContents
24
25
  wxHelpControllerBase::DisplayBlock
25
26
  wxHelpControllerBase::DisplaySection
27
+ wxHelpControllerBase::KeywordSearch
26
28
  wxHelpControllerBase::LoadFile
27
29
  wxHelpControllerBase::Quit
28
- ]
30
+ ], ignore_doc: false
29
31
  # and add them as the implemented overrides they are
30
32
  spec.extend_interface spec.module_name,
33
+ 'virtual bool DisplayContents()',
31
34
  'virtual bool DisplayBlock(long blockNo)',
32
35
  'virtual bool DisplaySection(int sectionNo)',
36
+ 'virtual bool DisplaySection(const wxString &section)',
37
+ 'virtual bool KeywordSearch(const wxString &keyWord, wxHelpSearchMode mode=wxHELP_SEARCH_ALL)',
33
38
  'virtual bool LoadFile(const wxString &file=wxEmptyString)',
34
39
  'virtual bool Quit()'
35
40
  # ignore this problematic method
@@ -62,11 +67,74 @@ module WXRuby3
62
67
  spec.ignore 'wxHtmlHelpController::CreateHelpFrame',
63
68
  'wxHtmlHelpController::CreateHelpDialog',
64
69
  'wxHtmlHelpController::GetFrame',
65
- 'wxHtmlHelpController::GetDialog'
70
+ 'wxHtmlHelpController::GetDialog',
71
+ 'wxHtmlHelpController::DisplayContents',
72
+ 'wxHtmlHelpController::KeywordSearch'
73
+ # add custom implementation of HtmlModalHelp as module function (not a class)
74
+ spec.add_header_code <<~__CODE
75
+ static VALUE wxruby_HtmlModalHelp(int argc, VALUE *argv, VALUE self)
76
+ {
77
+ if (argc < 2 || argc > 4)
78
+ {
79
+ rb_raise(rb_eArgError, "wrong # of arguments %d for 2 (max 4)", argc);
80
+ return Qnil;
81
+ }
82
+
83
+ void *ptr = nullptr;
84
+ wxWindow *parent = nullptr;
85
+ wxString help_file;
86
+ wxString topic = wxEmptyString;
87
+ int style = wxHF_DEFAULT_STYLE;
88
+ int res = 0;
89
+
90
+ res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_wxWindow, 0);
91
+ if (!SWIG_IsOK(res))
92
+ {
93
+ VALUE msg = rb_inspect(argv[0]);
94
+ rb_raise(rb_eTypeError, "expected wxWindow* for 1 but got %s", StringValuePtr(msg));
95
+ return Qnil;
96
+ }
97
+ parent = reinterpret_cast< wxWindow * >(ptr);
98
+ if (TYPE(argv[1]) != T_STRING)
99
+ {
100
+ VALUE msg = rb_inspect(argv[1]);
101
+ rb_raise(rb_eTypeError, "expected String for 2 but got %s", StringValuePtr(msg));
102
+ return Qnil;
103
+ }
104
+ help_file = RSTR_TO_WXSTR(argv[1]);
105
+ if (argc > 2)
106
+ {
107
+ if (TYPE(argv[2]) != T_STRING)
108
+ {
109
+ VALUE msg = rb_inspect(argv[2]);
110
+ rb_raise(rb_eTypeError, "expected String for 3 but got %s", StringValuePtr(msg));
111
+ return Qnil;
112
+ }
113
+ topic = RSTR_TO_WXSTR(argv[2]);
114
+ }
115
+ if (argc > 3)
116
+ {
117
+ if (TYPE(argv[3]) != T_FIXNUM)
118
+ {
119
+ VALUE msg = rb_inspect(argv[3]);
120
+ rb_raise(rb_eTypeError, "expected Integer for 4 but got %s", StringValuePtr(msg));
121
+ return Qnil;
122
+ }
123
+ style = NUM2INT(argv[3]);
124
+ }
125
+ wxHtmlModalHelp(parent, help_file, topic, style);
126
+ return Qnil;
127
+ }
128
+ __CODE
129
+ spec.add_init_code <<~__CODE__
130
+ rb_define_module_function(mWxHtmlHelpController, "HtmlModalHelp", VALUEFUNC(wxruby_HtmlModalHelp), -1);
131
+ __CODE__
66
132
  elsif spec.module_name == 'wxExtHelpController'
67
133
  spec.ignore %w[
134
+ wxExtHelpController::DisplayContents
68
135
  wxExtHelpController::DisplayBlock
69
136
  wxExtHelpController::DisplaySection
137
+ wxExtHelpController::KeywordSearch
70
138
  wxExtHelpController::LoadFile
71
139
  wxExtHelpController::Quit
72
140
  wxExtHelpController::GetFrameParameters
@@ -0,0 +1,30 @@
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
+ module WXRuby3
10
+
11
+ class Director
12
+
13
+ class MBConv < Director
14
+
15
+ def setup
16
+ super
17
+ spec.items.clear
18
+ spec.add_header_code <<~__HEREDOC
19
+ #include "wxruby-MBConv.h"
20
+ __HEREDOC
21
+ spec.add_init_code <<~__HEREDOC
22
+ wx_setup_MBConv();
23
+ __HEREDOC
24
+ end
25
+
26
+ end
27
+
28
+ end
29
+
30
+ end