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
data/rakelib/install.rb CHANGED
@@ -24,6 +24,7 @@ module WXRuby3
24
24
  def wxwin_shlibs
25
25
  unless @wxwin_shlibs
26
26
  @wxwin_shlibs = Rake::FileList.new
27
+ @wxwin_plugin_libs = {}
27
28
  # include wxWidgets shared libraries we linked with
28
29
  WXRuby3.config.wx_libs.select { |s| s.start_with?('-L') }.each do |libdir|
29
30
  libdir = libdir[2..libdir.size]
@@ -49,46 +50,72 @@ module WXRuby3
49
50
  end
50
51
  end
51
52
  end
53
+ if WXRuby3.config.linux? && WXRuby3.config.wx_port == :wxgtk && WXRuby3.config.features_set?('USE_WEBVIEW')
54
+ # look for 'webkit_ext*.so' or 'webkit2_ext*.so' in standard plugin subdir 'wx/<wx version>/web-extensions'
55
+ plugin_sub_dir = File.join(WXRuby3.config.wx_plugin_path, 'web-extensions')
56
+ Dir.glob(File.join(libdir, plugin_sub_dir, "webkit?_ext*.#{WXRuby3.config.dll_mask}")).each do |lib|
57
+ @wxwin_plugin_libs[File.join(plugin_sub_dir, File.basename(lib))] = lib
58
+ end
59
+ end
52
60
  end
53
61
  @wxwin_shlibs = ::Set.new(@wxwin_shlibs.to_a)
54
62
  end
55
63
  @wxwin_shlibs
56
64
  end
57
65
 
66
+ def wxwin_plugin_libs
67
+ @wxwin_plugin_libs || {}
68
+ end
69
+
58
70
  def install_wxwin_shlibs
59
71
  if WXRuby3.config.get_config('with-wxwin')
60
72
  $stdout.print "Installing wxRuby3 extensions..." if WXRuby3.config.run_silent?
61
- # prepare required wxWidgets shared libs
62
- wxwin_inshlibs = []
63
- WXRuby3::Install.wxwin_shlibs.each do |shlib|
64
- if File.symlink?(shlib)
65
- src_shlib = shlib
66
- src_shlib = File.join(File.dirname(shlib), File.basename(File.readlink(src_shlib))) while File.symlink?(src_shlib)
67
- FileUtils.ln_s(File.join('.', File.basename(src_shlib)), File.join('ext', File.basename(shlib)))
68
- else
69
- FileUtils.cp(shlib, inshlib = File.join('ext', File.basename(shlib)))
70
- unless WXRuby3.config.update_shlib_loadpaths(inshlib)
73
+ begin
74
+ # make sure directory exists
75
+ FileUtils.mkdir_p(File.join('ext', 'lib'))
76
+ # prepare required wxWidgets shared libs
77
+ wxwin_inshlibs = []
78
+ WXRuby3::Install.wxwin_shlibs.each do |shlib|
79
+ if File.symlink?(shlib)
80
+ src_shlib = shlib
81
+ src_shlib = File.join(File.dirname(shlib), File.basename(File.readlink(src_shlib))) while File.symlink?(src_shlib)
82
+ FileUtils.ln_s(File.join('.', File.basename(src_shlib)), File.join('ext', 'lib', File.basename(shlib)))
83
+ else
84
+ FileUtils.cp(shlib, inshlib = File.join('ext', 'lib', File.basename(shlib)))
85
+ unless WXRuby3.config.update_shlib_loadpaths(inshlib)
86
+ # cleanup and exit
87
+ remove_wxwin_shlibs
88
+ exit(1)
89
+ end
90
+ wxwin_inshlibs << File.expand_path(inshlib)
91
+ end
92
+ end
93
+ WXRuby3::Install.wxwin_plugin_libs.each do |lib, lib_path|
94
+ FileUtils.mkdir_p(File.join('ext', 'lib', File.dirname(lib)))
95
+ FileUtils.cp(lib_path, inshlib = File.join('ext', 'lib', lib))
96
+ end
97
+ if WXRuby3.config.windows? && WXRuby3.config.wx_port == :wxmsw && WXRuby3.config.features_set?('USE_WEBVIEW_EDGE')
98
+ # copy the WebView2 loader dll that should be installed
99
+ FileUtils.cp(File.join('ext', 'wxWidgets', WXRuby3::Config.instance.class::WEBVIEW2_LOADER), File.join('ext', 'lib'))
100
+ end
101
+ # prepare wxRuby shared libs
102
+ Dir["lib/*.#{WXRuby3.config.dll_mask}"].each do |shlib|
103
+ unless WXRuby3.config.update_shlib_loadpaths(shlib) && WXRuby3.config.update_shlib_ruby_libpath(shlib)
71
104
  # cleanup and exit
72
- FileUtils.rm_f(Dir["ext/*.#{WXRuby3.config.dll_mask}"])
105
+ remove_wxwin_shlibs
73
106
  exit(1)
74
107
  end
75
- wxwin_inshlibs << File.expand_path(inshlib)
76
- end
77
- end
78
- # prepare wxRuby shared libs
79
- Dir["lib/*.#{WXRuby3.config.dll_mask}"].each do |shlib|
80
- unless WXRuby3.config.update_shlib_loadpaths(shlib) && WXRuby3.config.update_shlib_ruby_libpath(shlib)
81
- # cleanup and exit
82
- FileUtils.rm_f(Dir["ext/*.#{WXRuby3.config.dll_mask}"])
83
- exit(1)
84
108
  end
85
- end
86
- (wxwin_inshlibs + Dir["lib/*.#{WXRuby3.config.dll_mask}"]).each do |shlib|
87
- unless WXRuby3.config.update_shlib_wxwin_libpaths(shlib, WXRuby3::Install.wxwin_shlibs)
88
- # cleanup and exit
89
- FileUtils.rm_f(Dir["ext/*.#{WXRuby3.config.dll_mask}"])
90
- exit(1)
109
+ (wxwin_inshlibs + Dir["lib/*.#{WXRuby3.config.dll_mask}"]).each do |shlib|
110
+ unless WXRuby3.config.update_shlib_wxwin_libpaths(shlib, WXRuby3::Install.wxwin_shlibs)
111
+ # cleanup and exit
112
+ remove_wxwin_shlibs
113
+ exit(1)
114
+ end
91
115
  end
116
+ rescue
117
+ remove_wxwin_shlibs
118
+ raise
92
119
  end
93
120
  $stdout.puts 'done!' if WXRuby3.config.run_silent?
94
121
  end
@@ -96,7 +123,7 @@ module WXRuby3
96
123
 
97
124
  def remove_wxwin_shlibs
98
125
  if WXRuby3.config.get_config('with-wxwin')
99
- WXRuby3::Install.wxwin_shlibs.each { |shlib| FileUtils.rm_f(File.join('ext', File.basename(shlib))) }
126
+ FileUtils.rm_rf(File.join('ext', 'lib'))
100
127
  end
101
128
  end
102
129
 
@@ -194,13 +194,15 @@ module WXRuby3
194
194
  if WXRuby3.config.sysinfo.os.release >= '15' && (wxw_ver.nil? || wxw_ver <= '3.2.6')
195
195
  # circumvent compilation problems on MacOS 15 or higher with older wxWidgets releases
196
196
  bash("./configure " +
197
- "--disable-optimise --disable-sys-libs --without-liblzma --without-regex " +
198
- "--prefix=`pwd`/install --disable-tests --without-subdirs --disable-debug_info " +
197
+ "--disable-optimise --disable-sys-libs --without-liblzma --without-regex " \
198
+ "--prefix=`pwd`/install --disable-tests --without-subdirs --disable-debug_info " \
199
+ "#{wx_with_webview? ? '--enable-webview' : '--disable-webview'} " \
199
200
  "CFLAGS=\"-Wno-unused-but-set-variable\"")
200
201
  else
201
- bash("./configure --with-macosx-version-min=#{WXRuby3.config.sysinfo.os.release}.0 " +
202
- "--disable-optimise --disable-sys-libs --without-liblzma --without-regex " +
203
- "--prefix=`pwd`/install --disable-tests --without-subdirs --disable-debug_info " +
202
+ bash("./configure --with-macosx-version-min=#{WXRuby3.config.sysinfo.os.release}.0 " \
203
+ "--disable-optimise --disable-sys-libs --without-liblzma --without-regex " \
204
+ "--prefix=`pwd`/install --disable-tests --without-subdirs --disable-debug_info " \
205
+ "#{wx_with_webview? ? '--enable-webview' : '--disable-webview'} " \
204
206
  "CFLAGS=\"-Wno-unused-but-set-variable\"")
205
207
  end
206
208
  end
@@ -1,4 +1,4 @@
1
- # Copyright (c) 2023 M.J.N. Corino, The Netherlands
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
2
  #
3
3
  # This software is released under the MIT license.
4
4
 
@@ -10,6 +10,7 @@ require_relative './unixish'
10
10
  require_relative 'pkgman/mingw'
11
11
 
12
12
  require 'uri'
13
+ require 'digest/sha2'
13
14
 
14
15
 
15
16
  if ENV['RI_DEVKIT'].nil?
@@ -31,6 +32,12 @@ module WXRuby3
31
32
  base.class_eval do
32
33
  include Config::UnixLike
33
34
 
35
+ const_set(:WEBVIEW2_VERSION, '1.0.3485.44')
36
+ const_set(:WEBVIEW2_URL, "https://www.nuget.org/api/v2/package/Microsoft.Web.WebView2/#{const_get(:WEBVIEW2_VERSION)}")
37
+ const_set(:WEBVIEW2_INCLUDE, File.join('3rdparty','webview2','build','native','include','WebView2.h'))
38
+ const_set(:WEBVIEW2_LOADER, File.join('3rdparty','webview2','build','native',(RB_CONFIG["arch"] =~ /x64/ ? 'x64' : 'x86'),'WebView2Loader.dll'))
39
+ const_set(:WEBVIEW2_SHA256, 'BC09150B179246AC90189649B13BE8E6B11B3AC200E817E18DF106E1F3CF489E')
40
+
34
41
  attr_reader :rescomp
35
42
 
36
43
  alias :base_ldflags :ldflags
@@ -39,7 +46,7 @@ module WXRuby3
39
46
  end
40
47
 
41
48
  def debug_command(*args)
42
- args.unshift(nix_path(FileUtils::RUBY))
49
+ args.unshift(FileUtils::RUBY)
43
50
  args.unshift('--args')
44
51
  args.unshift('gdb')
45
52
  args.join(' ')
@@ -80,7 +87,7 @@ module WXRuby3
80
87
  def install_prerequisites
81
88
  pkg_deps = super
82
89
  PkgManager.install(pkg_deps)
83
- []
90
+ pkg_deps
84
91
  end
85
92
 
86
93
  def expand(cmd)
@@ -97,12 +104,66 @@ module WXRuby3
97
104
 
98
105
  private
99
106
 
107
+ def wx_checkout
108
+ super
109
+ # do we need to build an embedded wxWidgets?
110
+ if get_config('with-wxwin') && get_cfg_string('wxwin').empty?
111
+ # then check webview requirements
112
+ if wx_with_webview_backend?('edge')
113
+ # download and install Edge WebView2 SDK
114
+ chdir(File.join(ext_path, 'wxWidgets')) do
115
+ FileUtils.mkdir_p(File.join('3rdparty', 'webview2'))
116
+ if download_file(self.class::WEBVIEW2_URL, File.join('3rdparty', 'webview2', 'webview2_sdk.zip'))
117
+ chdir(File.join('3rdparty', 'webview2')) do
118
+ # check digest
119
+ File.open('webview2_sdk.zip', 'r', binmode: true) do |fin|
120
+ # check digest signature
121
+ digest = Digest::SHA256.new
122
+ while (data = fin.read(1024*1024))
123
+ digest << data
124
+ end
125
+ if self.class::WEBVIEW2_SHA256 != digest.hexdigest!.upcase
126
+ $stderr.puts 'ERROR: WebView2 SDK package digest signature does NOT match.'
127
+ exit(1)
128
+ end
129
+ end
130
+ unless sh("unzip webview2_sdk.zip")
131
+ STDERR.puts 'ERROR: Failed to unpack required WebView2 SDK.'
132
+ exit(1)
133
+ end
134
+ end
135
+ unless File.exist?(self.class::WEBVIEW2_INCLUDE)
136
+ STDERR.puts 'ERROR: Error in required WebView2 SDK.'
137
+ exit(1)
138
+ end
139
+ else
140
+ STDERR.puts 'ERROR: Failed to download required WebView2 SDK.'
141
+ exit(1)
142
+ end
143
+ end
144
+ end
145
+ end
146
+ end
147
+
100
148
  def wx_configure
101
- bash('./configure --prefix=`pwd`/install --disable-tests --without-subdirs --without-regex --without-libcurl --with-expat=builtin --with-zlib=builtin --disable-debug_info')
149
+ bash("./configure --prefix=`pwd`/install --disable-tests --without-subdirs " \
150
+ "--without-regex --without-libcurl --with-expat=builtin --with-zlib=builtin " \
151
+ "--disable-debug_info #{wx_with_webview? ? '--enable-webview' : '--disable-webview'} " \
152
+ "#{wx_with_webview_backend?('edge') ? '--enable-webviewedge ' : '--disable-webviewedge '} " \
153
+ "#{!get_config('with-webview').nil? && wx_with_webview_backend?('ie') ? '--enable-webviewie ' : '--disable-webviewie'} ")
102
154
  end
103
155
 
104
156
  def wx_make
105
- bash('make && make install')
157
+ if bash('make && make install')
158
+ # in case of an embedded wxWidgets with WebView SDK backend
159
+ if get_config('with-wxwin') && get_cfg_string('wxwin').empty? && wx_with_webview_backend?('edge')
160
+ # we need to copy the WebView2 loader dll to the install bin folder
161
+ FileUtils.cp(self.class::WEBVIEW2_LOADER, File.join('install', 'bin'))
162
+ end
163
+ true
164
+ else
165
+ false
166
+ end
106
167
  end
107
168
 
108
169
  def wx_generate_xml
@@ -14,7 +14,7 @@ module WXRuby3
14
14
 
15
15
  module PkgManager
16
16
 
17
- XTRA_PLATFORM_DEPS = %w[python]
17
+ XTRA_PLATFORM_DEPS = %w[python unzip curl]
18
18
 
19
19
  class << self
20
20
 
@@ -70,7 +70,7 @@ module WXRuby3
70
70
 
71
71
  # add deployment lookup paths for wxruby shared libraries
72
72
  def update_shlib_loadpaths(shlib)
73
- WXRuby3.config.patch_rpath(shlib, WXRuby3.config.get_rpath_origin, "#{WXRuby3.config.get_rpath_origin}/../ext")
73
+ WXRuby3.config.patch_rpath(shlib, WXRuby3.config.get_rpath_origin, "#{WXRuby3.config.get_rpath_origin}/../ext/lib")
74
74
  end
75
75
 
76
76
  def expand(cmd)
@@ -110,7 +110,9 @@ module WXRuby3
110
110
  end
111
111
 
112
112
  def wx_configure
113
- bash('./configure --prefix=`pwd`/install --disable-tests --without-subdirs --without-regex --disable-debug_info')
113
+ bash("./configure --prefix=`pwd`/install --disable-tests " \
114
+ "--without-subdirs --without-regex --disable-debug_info " \
115
+ "#{wx_with_webview? ? '--enable-webview' : '--disable-webview'}")
114
116
  end
115
117
 
116
118
  def wx_make
@@ -116,6 +116,12 @@ module WXRuby3
116
116
 
117
117
  WXWIN_MINIMUM = '3.2.0'
118
118
 
119
+ WX_WEBVIEW_BACKENDS = {
120
+ macosx: ['webkit'],
121
+ linux: ['webkit'],
122
+ mingw: ['ie', 'edge']
123
+ }
124
+
119
125
  module Config
120
126
 
121
127
  def self.command_to_s(*cmd)
@@ -361,7 +367,7 @@ module WXRuby3
361
367
  test = File.join(Config.instance.test_dir, test)
362
368
  test = Dir.glob(test+'.rb').shift || test unless File.exist?(test)
363
369
  end
364
- Rake.sh(Config.instance.exec_env.merge({'RUBYLIB'=>rb_lib_path}), FileUtils::RUBY, test) { |ok,status| errors << File.basename(test, '.rb') unless ok }
370
+ Rake.sh(exec_env, *make_ruby_cmd(*(ENV['TESTOPTS'] ? [test, ENV['TESTOPTS']] : [test]), verbose: verbose?)) { |ok,_| errors << File.basename(test, '.rb') unless ok }
365
371
  end
366
372
  end
367
373
  fail "ERRORS: ##{errors.size} test scripts failed.\n\t#{errors.join("\n\t")}" unless errors.empty?
@@ -444,6 +450,14 @@ module WXRuby3
444
450
  Config.clear_config(key)
445
451
  end
446
452
 
453
+ def wx_with_webview?
454
+ Config.wx_with_webview?
455
+ end
456
+
457
+ def wx_with_webview_backend?(backend)
458
+ Config.wx_with_webview_backend?(backend)
459
+ end
460
+
447
461
  def dll_mask
448
462
  "#{dll_ext}*"
449
463
  end
@@ -733,10 +747,21 @@ module WXRuby3
733
747
  @wx_version || ''
734
748
  end
735
749
 
736
- def wx_version_check(ver)
750
+ def wx_version_list
737
751
  @wx_version_list ||= (@wx_version || '0.0.0').split('.').collect {|s| s.to_i }
752
+ end
753
+
754
+ def wx_version_check(ver)
738
755
  ver = ver.split('.').collect {|s| s.to_i } unless ::Array === ver
739
- @wx_version_list <=> ver
756
+ wx_version_list <=> ver
757
+ end
758
+
759
+ def wx_plugin_path
760
+ @wx_plugin_path ||= if (wx_version_list[1] % 2) == 0
761
+ File.join('wx', "#{wx_version_list[0]}.#{wx_version_list[1]}")
762
+ else
763
+ File.join('wx', wx_version)
764
+ end
740
765
  end
741
766
 
742
767
  def mingw?
@@ -909,6 +934,15 @@ module WXRuby3
909
934
  WXRuby3::CONFIG.delete(key.to_s)
910
935
  end
911
936
 
937
+ def wx_with_webview?
938
+ get_config('with-webview') != false
939
+ end
940
+
941
+ def wx_with_webview_backend?(backend)
942
+ v = get_config('with-webview')
943
+ v.nil? || v == true || (v.is_a?(Array) && v.include?(backend))
944
+ end
945
+
912
946
  def is_configured?
913
947
  instance.is_configured?
914
948
  end
@@ -6,21 +6,53 @@
6
6
  #define WXRUBY_EXPORT WXRB_EXPORT_FLAG
7
7
  #endif
8
8
 
9
+ #include "wxruby-runtime.h"
9
10
  #include "wxruby-ClientData.h"
10
11
 
11
12
  #include <set>
12
13
 
13
- static std::set<wxRubyClientData*> __s_WxRubyClientDataSet;
14
- static std::set<wxRubyUserData*> __s_WxRubyUserDataSet;
14
+ static bool __s_RubyClientDataMarker_Registered = false;
15
+ static bool __s_RubyUserDataMarker_Registered = false;
16
+
17
+ static const std::string WXRUBY_CLIENT_DATA = { "WXRUBY_CLIENT_DATA" };
18
+ static const std::string WXRUBY_USER_DATA = { "WXRUBY_USER_DATA" };
19
+
20
+ static void wxRuby_GC_mark_ClientData(const TGCTrackingValueMap& values)
21
+ {
22
+ for (const auto& ti : values)
23
+ {
24
+ wxRubyClientData* pcd = static_cast<wxRubyClientData*> (ti.first);
25
+ rb_gc_mark(pcd->GetData());
26
+ }
27
+ }
28
+
29
+ static void wxRuby_GC_mark_UserData(const TGCTrackingValueMap& values)
30
+ {
31
+ for (const auto& ti : values)
32
+ {
33
+ wxRubyUserData* pud = static_cast<wxRubyUserData*> (ti.first);
34
+ rb_gc_mark(pud->GetData());
35
+ }
36
+ }
15
37
 
16
38
  WXRB_EXPORT_FLAG void wxRuby_RegisterClientData(wxRubyClientData* pcd)
17
39
  {
18
- __s_WxRubyClientDataSet.insert(pcd);
40
+ if (!__s_RubyClientDataMarker_Registered)
41
+ {
42
+ wxRuby_RegisterTrackingCategory(WXRUBY_CLIENT_DATA, wxRuby_GC_mark_ClientData, true);
43
+ __s_RubyClientDataMarker_Registered = true;
44
+ }
45
+ wxRuby_RegisterCategoryValue(WXRUBY_CLIENT_DATA, pcd, Qnil);
19
46
  }
20
47
 
21
48
  WXRB_EXPORT_FLAG void wxRuby_RegisterUserData(wxRubyUserData* pud)
22
49
  {
23
- __s_WxRubyUserDataSet.insert(pud);
50
+ if (!__s_RubyUserDataMarker_Registered)
51
+ {
52
+ wxRuby_RegisterTrackingCategory(WXRUBY_USER_DATA, wxRuby_GC_mark_UserData, true);
53
+ __s_RubyUserDataMarker_Registered = true;
54
+ }
55
+ wxRuby_RegisterCategoryValue(WXRUBY_USER_DATA, pud, Qnil);
24
56
  }
25
57
 
26
58
  static ID client_data_unlinked_id()
@@ -36,7 +68,7 @@ static ID client_data_unlinked_id()
36
68
  WXRB_EXPORT_FLAG void wxRuby_UnregisterClientData(wxRubyClientData* pcd)
37
69
  {
38
70
  VALUE rbcd = pcd->GetData();
39
- __s_WxRubyClientDataSet.erase(pcd);
71
+ wxRuby_UnregisterCategoryValue(WXRUBY_CLIENT_DATA, pcd);
40
72
  if (!NIL_P(rbcd) && rb_respond_to(rbcd, client_data_unlinked_id()))
41
73
  {
42
74
  wxRuby_Funcall(rbcd, client_data_unlinked_id(), 0);
@@ -46,20 +78,9 @@ WXRB_EXPORT_FLAG void wxRuby_UnregisterClientData(wxRubyClientData* pcd)
46
78
  WXRB_EXPORT_FLAG void wxRuby_UnregisterUserData(wxRubyUserData* pud)
47
79
  {
48
80
  VALUE rbud = pud->GetData();
49
- __s_WxRubyUserDataSet.erase(pud);
81
+ wxRuby_UnregisterCategoryValue(WXRUBY_USER_DATA, pud);
50
82
  if (!NIL_P(rbud) && rb_respond_to(rbud, client_data_unlinked_id()))
51
83
  {
52
84
  wxRuby_Funcall(rbud, client_data_unlinked_id(), 0);
53
85
  }
54
86
  }
55
-
56
- static void wxRuby_GC_mark_ClientData()
57
- {
58
- for (wxRubyClientData* pcd : __s_WxRubyClientDataSet)
59
- rb_gc_mark(pcd->GetData());
60
- for (wxRubyUserData* pud : __s_WxRubyUserDataSet)
61
- rb_gc_mark(pud->GetData());
62
- }
63
-
64
- typedef void (*WXRBMarkFunction)();
65
- WXRUBY_EXPORT void wxRuby_AppendMarker(WXRBMarkFunction marker);
@@ -78,7 +78,7 @@ protected:
78
78
  // handle exception
79
79
  VALUE rexc = this->get_exception ();
80
80
  wxRuby_PrintException(rexc);
81
- ::exit(255);
81
+ ::exit(127);
82
82
  }
83
83
  else
84
84
  {
@@ -220,19 +220,19 @@ namespace Swig
220
220
  void DirectorTypeMismatchException::raise(VALUE error, const char *msg)
221
221
  {
222
222
  print(DirectorTypeMismatchException(error, msg));
223
- ::exit(254);
223
+ ::exit(126);
224
224
  }
225
225
 
226
226
  void DirectorTypeMismatchException::raise(const char *msg)
227
227
  {
228
228
  print(DirectorTypeMismatchException(msg));
229
- ::exit(254);
229
+ ::exit(126);
230
230
  }
231
231
 
232
232
  void DirectorTypeMismatchException::raise(VALUE self, const char* method, VALUE error, const char *msg)
233
233
  {
234
234
  print(DirectorTypeMismatchException(self, method, error, msg));
235
- ::exit(254);
235
+ ::exit(126);
236
236
  }
237
237
 
238
238
  /* Any Ruby exception that occurs during a director method call */
@@ -10,44 +10,32 @@
10
10
  extern "C" {
11
11
  #endif
12
12
  // Shared custom swig tracking functions
13
+ WXRB_EXPORT_FLAG void wxRuby_InitializeTracking();
13
14
  WXRB_EXPORT_FLAG void wxRuby_AddTracking(void* ptr, VALUE object);
14
15
  WXRB_EXPORT_FLAG VALUE wxRuby_FindTracking(void* ptr);
15
16
  WXRB_EXPORT_FLAG void wxRuby_RemoveTracking(void* ptr);
16
- WXRB_EXPORT_FLAG void wxRuby_IterateTracking( void(*meth)(void* ptr, VALUE obj) );
17
- /* Setup a Ruby hash table to store Trackings - mostly done in wx.i */
18
- SWIGRUNTIMEINLINE void SWIG_RubyInitializeTrackings(void)
19
- {
20
- // no-op
21
- }
17
+ WXRB_EXPORT_FLAG void wxRuby_UnlinkObject(void* ptr);
18
+
19
+ /* Setup a Ruby hash table to store Trackings */
20
+ #define SWIG_RubyInitializeTrackings()
21
+
22
22
  /* Add a Tracking from a C/C++ struct to a Ruby object */
23
- SWIGRUNTIMEINLINE void SWIG_RubyAddTracking(void* ptr, VALUE object)
24
- {
25
- wxRuby_AddTracking(ptr, object);
26
- }
23
+ #define SWIG_RubyAddTracking wxRuby_AddTracking
24
+
27
25
  /* Get the Ruby object that owns the specified C/C++ struct */
28
- SWIGRUNTIMEINLINE VALUE SWIG_RubyInstanceFor(void* ptr)
29
- {
30
- return wxRuby_FindTracking(ptr);
31
- }
26
+ #define SWIG_RubyInstanceFor wxRuby_FindTracking
27
+
32
28
  /* Remove a Tracking from a C/C++ struct to a Ruby object. It
33
29
  is very important to remove objects once they are destroyed
34
30
  since the same memory address may be reused later to create
35
31
  a new object. */
36
- SWIGRUNTIMEINLINE void SWIG_RubyRemoveTracking(void* ptr)
37
- {
38
- wxRuby_RemoveTracking(ptr);
39
- }
32
+ #define SWIG_RubyRemoveTracking wxRuby_RemoveTracking
33
+
40
34
  /* This is a helper method that unlinks a Ruby object from its
41
35
  underlying C++ object. This is needed if the lifetime of the
42
36
  Ruby object is longer than the C++ object */
43
- SWIGRUNTIMEINLINE void SWIG_RubyUnlinkObjects(void* ptr)
44
- {
45
- VALUE object = SWIG_RubyInstanceFor(ptr);
46
- if (object != Qnil)
47
- {
48
- DATA_PTR(object) = 0;
49
- }
50
- }
37
+ #define SWIG_RubyUnlinkObjects wxRuby_UnlinkObject
38
+
51
39
  #ifdef __cplusplus
52
40
  }
53
41
  #endif
@@ -418,8 +418,6 @@ module WXRuby3
418
418
  fsrc.puts %Q{rb_define_const(mWxSetup, "#{feature}", Q#{val});}
419
419
  end
420
420
  fsrc.puts
421
- # install wxRubyClientData marker
422
- fsrc.puts %Q{wxRuby_AppendMarker(wxRuby_GC_mark_ClientData);}
423
421
  else
424
422
  fsrc.puts %Q{#{module_variable} = rb_define_module_under(wxRuby_Core(), "#{name}");}
425
423
  # record package submodule in main module's list
@@ -152,20 +152,13 @@ module WXRuby3
152
152
  // Prevents the App being destroyed prematurely when Ruby exits down with
153
153
  // an exception. Otherwise GC destroys the C++ object, which can still
154
154
  // be needed for final WxWidgets events.
155
- %markfunc wxApp "wxRubyApp::mark_wxRubyApp";
155
+ %markfunc wxApp "wxRubyApp::GC_mark_wxRubyApp";
156
156
  __HEREDOC
157
157
  spec.add_header_code <<~__HEREDOC
158
158
  extern void GC_SetWindowDeleted(void*);
159
159
  extern "C" void Init_wxRubyStockObjects();
160
160
  extern void wxRuby_MarkProtectedEvtHandlerProcs();
161
161
 
162
- static wxVector<WXRBMarkFunction> WXRuby_Mark_List;
163
-
164
- WXRUBY_EXPORT void wxRuby_AppendMarker(WXRBMarkFunction marker)
165
- {
166
- WXRuby_Mark_List.push_back(marker);
167
- }
168
-
169
162
  #include "wxRubyApp.h"
170
163
 
171
164
  WXRUBY_EXPORT bool wxRuby_IsAppRunning()
@@ -29,10 +29,14 @@ module WXRuby3
29
29
  typedef wxString wxArtID;
30
30
  typedef wxString wxArtClient;
31
31
 
32
- // Missing from docs
33
- %constant const char* wxART_STOP = wxART_STOP;
34
- %constant const char* wxART_REFRESH = wxART_REFRESH;
35
32
  __HEREDOC
33
+ if Config.instance.wx_version_check('3.3.2') <= 0
34
+ spec.add_swig_code <<~__HEREDOC
35
+ // Missing from docs
36
+ %constant const char* wxART_STOP = wxART_STOP;
37
+ %constant const char* wxART_REFRESH = wxART_REFRESH;
38
+ __HEREDOC
39
+ end
36
40
  spec.map *%w[wxArtID wxArtClient], as: 'String', swig: false do
37
41
  map_in
38
42
  map_out
@@ -82,11 +82,6 @@ module WXRuby3
82
82
  }
83
83
  return rb_cpp;
84
84
  }
85
-
86
- static void wxRuby_markComboPopups()
87
- {
88
- WxRubyComboPopup::GC_mark_combo_popups();
89
- }
90
85
  __HEREDOC
91
86
  # ignore these
92
87
  spec.ignore 'wxComboCtrl::SetPopupControl',
@@ -110,8 +105,6 @@ module WXRuby3
110
105
  }
111
106
  __HEREDOC
112
107
  spec.add_init_code <<~__HEREDOC
113
- wxRuby_AppendMarker(wxRuby_markComboPopups);
114
-
115
108
  g_rb_mWxComboPopup = rb_define_module_under(mWxCore, "ComboPopup");
116
109
  rb_define_method(g_rb_mWxComboPopup, "get_combo_ctrl", VALUEFUNC(wx_combo_popup_get_combo_ctrl), -1);
117
110
 
@@ -16,8 +16,41 @@ module WXRuby3
16
16
 
17
17
  def setup
18
18
  super
19
- spec.items << 'wxContextHelp'
20
- spec.no_proxy 'wxContextHelp'
19
+ # add custom implementation of ContextHelp as module function (not a class)
20
+ spec.add_header_code <<~__CODE
21
+ SWIGINTERN int SWIG_AsVal_bool (VALUE obj, bool *val); // forward decl
22
+
23
+ static VALUE wxruby_ContextHelp(int argc, VALUE *argv, VALUE self)
24
+ {
25
+ if (argc > 1)
26
+ {
27
+ rb_raise(rb_eArgError, "wrong # of arguments %d for 1", argc);
28
+ return Qnil;
29
+ }
30
+
31
+ void *ptr = nullptr;
32
+ wxWindow *window = nullptr;
33
+ int res = 0;
34
+
35
+ if (argc > 0)
36
+ {
37
+ res = SWIG_ConvertPtr(argv[0], &ptr, SWIGTYPE_p_wxWindow, 0);
38
+ if (!SWIG_IsOK(res))
39
+ {
40
+ VALUE msg = rb_inspect(argv[0]);
41
+ rb_raise(rb_eTypeError, "expected wxWindow* for 1 but got %s", StringValuePtr(msg));
42
+ return Qnil;
43
+ }
44
+ window = reinterpret_cast< wxWindow * >(ptr);
45
+ }
46
+
47
+ wxContextHelp(window, true);
48
+ return Qnil;
49
+ }
50
+ __CODE
51
+ spec.add_init_code <<~__CODE__
52
+ rb_define_module_function(mWxCore, "ContextHelp", VALUEFUNC(wxruby_ContextHelp), -1);
53
+ __CODE__
21
54
  end
22
55
  end # class ContextHelpButton
23
56