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
@@ -0,0 +1,166 @@
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 WebView < Window
16
+
17
+ include Typemap::IOStreams
18
+ include Typemap::DateTime
19
+
20
+ def setup
21
+ spec.items << 'wxWebViewHistoryItem'
22
+ if Config.instance.wx_version_check('3.3.0') >= 0
23
+ spec.items << 'wxWebViewConfiguration'
24
+ end
25
+ super
26
+ if Config.instance.wx_version_check('3.3.0') >= 0
27
+ spec.gc_as_object 'wxWebViewConfiguration'
28
+ spec.no_proxy 'wxWebViewConfiguration'
29
+ spec.extend_interface 'wxWebViewConfiguration', 'wxWebViewConfiguration()', visibility: 'protected'
30
+ spec.make_abstract 'wxWebViewConfiguration'
31
+ # not useful in wxRuby
32
+ spec.ignore 'wxWebViewConfiguration::GetNativeConfiguration'
33
+ end
34
+ spec.gc_as_untracked 'wxWebViewHistoryItem'
35
+
36
+ spec.no_proxy 'wxWebView'
37
+ spec.ignore 'wxWebView::RegisterFactory'
38
+ spec.ignore 'wxWebView::GetNativeBackend'
39
+ if Config.instance.features_set?('WXMSW', 'USE_WEBVIEW_IE')
40
+ spec.include 'wx/msw/webview_ie.h', 'wx/msw/registry.h'
41
+ spec.add_extend_code 'wxWebView', <<~__CODE
42
+ // Have to add our own version here as wxw gets the execution module name wrong.
43
+ static bool msw_set_ie_emulation_level(wxWebViewIE_EmulationLevel level = wxWEBVIEWIE_EMU_IE11)
44
+ {
45
+ // Registry key where emulation level for programs are set
46
+ static const wxChar* IE_EMULATION_KEY =
47
+ wxT("SOFTWARE\\\\Microsoft\\\\Internet Explorer\\\\Main")
48
+ wxT("\\\\FeatureControl\\\\FEATURE_BROWSER_EMULATION");
49
+
50
+ wxRegKey key(wxRegKey::HKCU, IE_EMULATION_KEY);
51
+ // Check the existence of the key and create it if it does not exist
52
+ if ( !key.Exists() && !key.Create() )
53
+ {
54
+ wxLogWarning(_("Failed to find web view emulation level in the registry"));
55
+ return false;
56
+ }
57
+
58
+ const wxString programName = wxT("ruby.exe");
59
+ if ( level != wxWEBVIEWIE_EMU_DEFAULT )
60
+ {
61
+ if ( !key.SetValue(programName, level) )
62
+ {
63
+ wxLogWarning(_("Failed to set web view to modern emulation level"));
64
+ return false;
65
+ }
66
+ }
67
+ else
68
+ {
69
+ if ( !key.DeleteValue(programName) )
70
+ {
71
+ wxLogWarning(_("Failed to reset web view to standard emulation level"));
72
+ return false;
73
+ }
74
+ }
75
+
76
+ return true;
77
+ }
78
+ __CODE
79
+ else
80
+ spec.ignore 'wxWebViewIE_EmulationLevel'
81
+ end
82
+ if Config.instance.wx_version_check('3.1.1') >= 0
83
+ spec.map 'wxString *output' => 'String,nil' do
84
+ map_in ignore: true, temp: 'wxString tmp', code: '$1 = &tmp;'
85
+ map_out ignore: 'bool'
86
+ map_argout code: <<~__CODE
87
+ if (result)
88
+ {
89
+ $result = WXSTR_TO_RSTR(tmp$argnum);
90
+ }
91
+ else
92
+ {
93
+ $result = Qnil;
94
+ }
95
+ __CODE
96
+ end
97
+ end
98
+ if Config.instance.wx_version_check('3.1.6') >= 0
99
+ # do not support inherently unsafe 'void* clientData'
100
+ spec.ignore 'wxWebView::RunScriptAsync', ignore_doc: false
101
+ spec.add_extend_code 'wxWebView', <<~__CODE
102
+ void RunScriptAsync(const wxString& javascript)
103
+ {
104
+ $self->RunScriptAsync(javascript, nullptr);
105
+ }
106
+ __CODE
107
+ spec.map 'void* clientData', swig: false do
108
+ map_in ignore: true, code: ''
109
+ end
110
+ end
111
+
112
+ spec.add_swig_code <<~__CODE
113
+ %include <wx_ruby_shared_ptr.i>
114
+ %wx_ruby_shared_ptr(wxWebViewHandler, wxWebViewHandler);
115
+ %wx_ruby_shared_ptr(wxWebViewArchiveHandler, wxWebViewHandler);
116
+ %wx_ruby_shared_ptr(wxWebViewFSHandler, wxWebViewHandler);
117
+
118
+ %include <wx_shared_ptr.i>
119
+ %wx_shared_ptr(wxWebViewHistoryItem);
120
+ __CODE
121
+
122
+ spec.map 'wxSharedPtr<wxWebViewHandler>' => 'Wx::WebViewHandler>' do
123
+ map_in code: <<~__CODE
124
+ void* argp$argnum;
125
+ int res$argnum = SWIG_ConvertPtr($input, &argp$argnum, SWIGTYPE_p_WxRubySharedPtrT_wxWebViewHandler_wxWebViewHandler_t, 0 );
126
+ if (!SWIG_IsOK(res$argnum)) {
127
+ SWIG_exception_fail(SWIG_ArgError(res2), Ruby_Format_TypeError( "", "WxRubySharedPtr< wxWebViewHandler, wxWebViewHandler >","RegisterHandler", 2, argv[0] ));
128
+ }
129
+ if (!argp2) {
130
+ SWIG_exception_fail(SWIG_NullReferenceError, Ruby_Format_TypeError("invalid null reference ", "WxRubySharedPtr< wxWebViewHandler, wxWebViewHandler >","RegisterHandler", 2, argv[0]));
131
+ } else {
132
+ arg2 = *(reinterpret_cast< WxRubySharedPtr< wxWebViewHandler, wxWebViewHandler > * >(argp2));
133
+ }
134
+ __CODE
135
+ end
136
+
137
+ spec.map 'wxVector< wxSharedPtr<wxWebViewHistoryItem> >' => 'Array<Wx::WEB::WebViewHistoryItem>' do
138
+ map_out code: <<~__CODE
139
+ $result = rb_ary_new();
140
+ wxVector< wxSharedPtr<wxWebViewHistoryItem> > *history = (wxVector< wxSharedPtr<wxWebViewHistoryItem> > *)&$1;
141
+ for (wxSharedPtr<wxWebViewHistoryItem>& hist_item : *history)
142
+ {
143
+ VALUE r_hist = SWIG_NewPointerObj(new wxSharedPtr<wxWebViewHistoryItem>(SWIG_STD_MOVE(hist_item)), SWIGTYPE_p_wxSharedPtrT_wxWebViewHistoryItem_t, SWIG_POINTER_OWN);
144
+ rb_ary_push($result, r_hist);
145
+ }
146
+ __CODE
147
+ end
148
+
149
+ spec.map 'wxSharedPtr<wxWebViewHistoryItem>' => 'Wx::WEB::WebViewHistoryItem', swig: false do
150
+ map_in code: ''
151
+ end
152
+
153
+ # fix event definitions
154
+ if Config.instance.wx_version_check('3.3.0') >= 0
155
+ # completely missing up and until 3.3.2 but should be there
156
+ if Config.instance.wx_version_check('3.3.2') <= 0
157
+ spec.add_swig_code %Q{%constant wxEventType wxEVT_WEBVIEW_BROWSING_DATA_CLEARED = wxEVT_WEBVIEW_BROWSING_DATA_CLEARED;}
158
+ end
159
+ end
160
+ end
161
+
162
+ end # class WebView
163
+
164
+ end # class Director
165
+
166
+ end # module WXRuby3
@@ -0,0 +1,37 @@
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 './event'
10
+
11
+ module WXRuby3
12
+
13
+ class Director
14
+
15
+ class WebViewEvent < Event
16
+
17
+ def setup
18
+ super
19
+ spec.override_inheritance_chain('wxWebViewEvent',
20
+ {'wxNotifyEvent' => 'wxEvents'}, {'wxCommandEvent' => 'wxEvent'}, 'wxEvent', 'wxObject')
21
+ if Config.instance.wx_version_check('3.3.0') >= 0
22
+ spec.items << 'wxWebViewWindowFeatures'
23
+ spec.gc_as_untracked 'wxWebViewWindowFeatures'
24
+ spec.no_proxy 'wxWebViewWindowFeatures'
25
+ spec.make_abstract 'wxWebViewWindowFeatures'
26
+ spec.extend_interface 'wxWebViewWindowFeatures',
27
+ 'virtual wxWebViewWindowFeatures()',
28
+ visibility: 'protected'
29
+
30
+ end
31
+ spec.do_not_generate(:variables, :defines, :enums, :functions)
32
+ end
33
+ end # class WebViewEvent
34
+
35
+ end # class Director
36
+
37
+ end # module WXRuby3
@@ -0,0 +1,63 @@
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 WebViewHandler < Director
14
+
15
+ include Typemap::IOStreams
16
+ include Typemap::MBConv
17
+
18
+ def setup
19
+ spec.items.concat %w[wxWebViewArchiveHandler wxWebViewFSHandler]
20
+ if Config.instance.wx_version_check('3.3.0') >= 0
21
+ spec.items.concat %w[wxWebViewHandlerRequest wxWebViewHandlerResponse wxWebViewHandlerResponseData]
22
+ end
23
+ super
24
+ spec.gc_as_untracked 'wxWebViewHandler', 'wxWebViewArchiveHandler', 'wxWebViewFSHandler'
25
+ spec.make_abstract 'wxWebViewHandler'
26
+ spec.add_swig_code <<~__CODE
27
+ %include <wx_ruby_shared_ptr.i>
28
+ %wx_ruby_shared_ptr(wxWebViewHandler, wxWebViewHandler);
29
+ %wx_ruby_shared_ptr(wxWebViewArchiveHandler, wxWebViewHandler);
30
+ %wx_ruby_shared_ptr(wxWebViewFSHandler, wxWebViewHandler);
31
+ __CODE
32
+ if Config.instance.wx_version_check('3.3.0') >= 0
33
+ spec.gc_as_untracked 'wxWebViewHandlerRequest', 'wxWebViewHandlerResponse', 'wxWebViewHandlerResponseData'
34
+ spec.no_proxy 'wxWebViewHandlerRequest', 'wxWebViewHandlerResponse'
35
+ spec.make_abstract 'wxWebViewHandlerRequest'
36
+ spec.make_abstract 'wxWebViewHandlerResponse'
37
+ spec.make_abstract 'wxWebViewHandlerResponseData'
38
+ spec.add_swig_code <<~__CODE
39
+ %include <wx_shared_ptr.i>
40
+ %wx_shared_ptr(wxWebViewHandlerResponse);
41
+ %wx_shared_ptr(wxWebViewHandlerResponseData);
42
+ __CODE
43
+ spec.map 'wxSharedPtr<wxWebViewHandlerResponse>' => 'Wx::WEB::WebViewHandlerResponse', swig: false do
44
+ map_in code: ''
45
+ end
46
+ spec.map 'wxSharedPtr<wxWebViewHandlerResponseData>' => 'Wx::WEB::WebViewHandlerResponseData', swig: false do
47
+ map_in code: ''
48
+ end
49
+ spec.suppress_warning(473,
50
+ 'wxWebViewHandlerResponseData::GetStream')
51
+ end
52
+ spec.suppress_warning(473,
53
+ 'wxWebViewHandler::GetFile',
54
+ 'wxWebViewArchiveHandler::GetFile',
55
+ 'wxWebViewFSHandler::GetFile')
56
+ spec.do_not_generate(:variables, :defines, :enums, :functions)
57
+ end
58
+
59
+ end # class WebViewHandler
60
+
61
+ end # class Director
62
+
63
+ end # module WXRuby3
@@ -0,0 +1,20 @@
1
+ ---
2
+ :wxThreadEvent:
3
+ :detail:
4
+ :pre:
5
+ :detaileddescription:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ This event is not natively emitted by any control/class: it is just a helper class for the user.
10
+ Its most important feature is the {Wx::RT::ThreadEvent#get_event_category} implementation which allows
11
+ thread events <b>NOT</b> to be processed by {Wx::GUIEventLoop#yield_for} calls (unless the
12
+ {Wx::EventCategory::EVT_CATEGORY_THREAD} is specified - which is never in wx code).
13
+
14
+ In wxRuby user defined classes can be derived from this class but it is important to note that when used
15
+ with {Wx::RT::SharedEvtHandler#queue_message} (the only imaginable use for thread events) no Ruby state
16
+ will <b>ever</b> persist and adding instance variables is therefor not useful.
17
+ The real benefit of being able to derive from this class is that it provides for the registration and use of
18
+ user defined event types for the derived classes allowing to differentiate in event handling.
19
+ @see Wx::GUIEventLoop#yield_for
20
+ @see Wx::RT::SharedEvtHandler
@@ -0,0 +1,135 @@
1
+ ---
2
+ :wxWebView:
3
+ :detail:
4
+ :pre:
5
+ :detaileddescription:
6
+ - :pattern: !ruby/regexp /wxWEBVIEW_BACKEND_IE\s+\(MSW\)/
7
+ :subst: 'Wx::WEB::WEBVIEW_BACKEND_IE (MSW)'
8
+ - :pattern: !ruby/regexp /Internet\s+Explorer\s+7/
9
+ :subst: 'Internet Explorer 11'
10
+ - :pattern: !ruby/regexp /wxWebViewIE::MSWSetEmulationLevel/
11
+ :subst: 'wxWebView::msw_set_ie_emulation_level'
12
+ - :pattern: !ruby/regexp /wxWebViewBackendIE/m
13
+ :global: true
14
+ :subst: 'wxWEBVIEW_BACKEND_IE'
15
+ - :pattern: !ruby/regexp /wxWEBVIEW_BACKEND_EDGE/m
16
+ :global: true
17
+ :subst: 'Wx::WEB::WEBVIEW_BACKEND_EDGE'
18
+ - :pattern: !ruby/regexp /wxWebViewBackendEdge/m
19
+ :global: true
20
+ :subst: 'wxWEBVIEW_BACKEND_EDGE'
21
+ - :pattern: !ruby/regexp /This\s+backend.*using\s+CMake.\s+To\s+build.*steps:/
22
+ :subst: 'This backend is enabled by default for WXMSW.'
23
+ - :pattern: !ruby/regexp /wxWebViewBackendWebKit/m
24
+ :global: true
25
+ :subst: 'wxWEBVIEW_BACKEND_WEBKIT'
26
+ - :pattern: !ruby/regexp /wxWEBVIEW_WEBKIT/m
27
+ :global: true
28
+ :subst: 'Wx::WEB::WEBVIEW_BACKEND_WEBKIT'
29
+ - :pattern: !ruby/regexp /wxWEBVIEW_CHROMIUM/m
30
+ :global: true
31
+ :subst: 'Wx::WEB::WEBVIEW_BACKEND_CHROMIUM'
32
+ - :pattern: !ruby/regexp /wxWebViewBackendChromium/m
33
+ :global: true
34
+ :subst: 'wxWEBVIEW_BACKEND_CHROMIUM'
35
+ :programlisting:
36
+ - :pattern: !ruby/regexp /wxSetEnv/
37
+ :replace: |
38
+
39
+
40
+ ```ruby
41
+ ENV['WEBKIT_DISABLE_DMABUF_RENDERER'] = '1'
42
+ ```
43
+
44
+ :post:
45
+ - :pattern: !ruby/regexp /-\s+When\s+not\s+using\s+CMake:.*remove\s+the dependency\s+on\s+WebView2Loader\.dll\s+at runtime./m
46
+ :subst: ''
47
+ - :pattern: !ruby/regexp /If.*fixed\s+version.*WebView2.*Edge\s+backend\./
48
+ :subst: ''
49
+ - :pattern: !ruby/regexp /see\s+\{Wx::WebViewChromium\}.*build\s+instructions./
50
+ :subst: |
51
+ see the wxWidgets documentation for wxWebViewChromium for additional usage and build instructions.
52
+ This backend can not be automatically build by the wxRuby3 build scripts but requires a custom wxWidgets installation.
53
+ See the wxRuby3 INSTALL documentation for details on how to build with a custom wxWidgets setup.
54
+ :wxWebView.RunScript:
55
+ :detail:
56
+ :pre:
57
+ :programlisting:
58
+ - :pattern: !ruby/regexp /document\.write/
59
+ :replace: |
60
+
61
+
62
+ ```ruby
63
+ webview.run_script('document.write('Hello from wxWidgets!')')
64
+ ```
65
+
66
+ - :pattern: !ruby/regexp /document\.getElementById/
67
+ :replace: |
68
+
69
+
70
+ ```ruby
71
+ if (result = webview.run_script('document.getElementById('some_id').innerHTML'))
72
+ #... result contains the contents of the given element ...
73
+ # else: the element with this ID probably doesn't exist.
74
+ end
75
+ ```
76
+
77
+ :post:
78
+ - :pattern: !ruby/regexp /return\s+false/m
79
+ :global: true
80
+ :subst: 'return nil'
81
+ - :pattern: !ruby/regexp /MSWSetEmulationLevel\(\)/
82
+ :subst: 'Wx::WEB::WebView::msw_set_ie_emulation_level'
83
+ - :pattern: !ruby/regexp /If.*output.*success/m
84
+ :subst: 'This method returns the result of executing this code on success (or nil if no result or on failure)'
85
+ - :pattern: !ruby/regexp /true\s+if\s+there\s+is.*error./m
86
+ :subst: ''
87
+ :wxWebView.AddScriptMessageHandler:
88
+ :detail:
89
+ :pre:
90
+ :programlisting:
91
+ - :pattern: !ruby/regexp /AddScriptMessageHandler/
92
+ :replace: |
93
+
94
+
95
+ ```ruby
96
+ # Install message handler with the name wx_msg
97
+ @webView.add_script_message_handler("wx_msg")
98
+ # Bind handler
99
+ @webView.evt_webview_script_message_received(Wx::ID_ANY) { |evt|
100
+ Wx.log_message("Script message received; value = %s, handler = %s", evt.get_string, evt.get_message_handler)
101
+ }
102
+ ```
103
+
104
+ :post:
105
+ - :pattern: !ruby/regexp /Sample\s+C\+\+\s+code\s+/
106
+ :subst: 'Sample code '
107
+ :wxWebView.SetProxy:
108
+ :detail:
109
+ :pre:
110
+ :programlisting:
111
+ - :pattern: !ruby/regexp /.*/
112
+ :replace: |
113
+
114
+
115
+ ```ruby
116
+ webview = Wx::WEB::WebView.new
117
+ unless webview.set_proxy("http://127.0.0.1:8080")
118
+ Wx.log_warning("Setting proxy failed!")
119
+ end
120
+ webview.create(parent, Wx::ID_ANY)
121
+ ```
122
+
123
+ :wxWebView.IsBackendAvailable:
124
+ :detail:
125
+ :pre:
126
+ :programlisting:
127
+ - :pattern: !ruby/regexp /.*/
128
+ :replace: |
129
+
130
+
131
+ ```ruby
132
+ if Wx::WEB::WebView::is_backend_available(Wx::WEB::WEBVIEW_BACKEND_EDGE)
133
+ #... enable some extra functionality not available with the IE backend ...
134
+ end
135
+ ```
@@ -0,0 +1,38 @@
1
+ ---
2
+ :wxWebViewWindowFeatures:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /wxEVT_WEBVIEW_NEWWINDOW/
7
+ :replace: |
8
+
9
+
10
+ ```ruby
11
+ # Bind new window handler
12
+ @webView.evt_webview_newwindow(Wx::ID_ANY) { |evt|
13
+ if evt.get_url == "http://badwebsite.com"
14
+ evt.veto # Disallow new window for badwebsite.com
15
+ else
16
+ evt.skip # Allow new window for all other websites
17
+ end
18
+ }
19
+
20
+ # Bind new window features handler
21
+ @webView.evt_webview_newwindow_features(Wx::ID_ANY) { |evt|
22
+ # Get target window features
23
+ features = evt.get_target_window_features
24
+ # Create a top level window for the child web view
25
+ win = Wx::Frame.new(nil, Wx::ID_ANY, features.get_position, features.get_size)
26
+ sizer = Wx::VBoxSizer.new
27
+ win.set_sizer(sizer)
28
+ # Get the child web view
29
+ childWebView = features.get_child_web_view
30
+ # Place the child web view into the window
31
+ childWebView.create(win, Wx::ID_ANY)
32
+ sizer.add(childWebView, Wx::SizerFlags.new.proportion(1).expand)
33
+ }
34
+ ```
35
+
36
+ :post:
37
+ - :pattern: !ruby/regexp /Sample\s+C\+\+\s+code\s+/
38
+ :subst: 'Sample code '
@@ -0,0 +1,58 @@
1
+ ---
2
+ :wxWebViewHandler.SetVirtualHost:
3
+ :detail:
4
+ :post:
5
+ - :pattern: !ruby/regexp /name\.\{Wx::site\}/
6
+ :subst: '<code>name.wxsite</code>'
7
+ :wxWebViewHandler.StartRequest:
8
+ :detail:
9
+ :pre:
10
+ :programlisting:
11
+ - :pattern: !ruby/regexp /.*/
12
+ :replace: |
13
+
14
+ ```ruby
15
+ def start_request(request, response)
16
+ # Set common headers allowing access from XMLHTTPRequests()
17
+ response.set_header("Access-Control-Allow-Origin", "*")
18
+ response.set_header("Access-Control-Allow-Headers", "*")
19
+
20
+ # Handle options request
21
+ if request.get_method.casecmp("options") == 0
22
+ response.finish("")
23
+ return
24
+ end
25
+
26
+ # Check the post data type
27
+ unless request.get_header("Content-Type").start_with?("application/json")
28
+ response.finish_with_error
29
+ return;
30
+ end
31
+
32
+ # Process input data
33
+ postData = request.get_data_string
34
+
35
+ #...
36
+
37
+ # Send result
38
+ response.set_content_type("application/json")
39
+ response.finish("{ result: true }")
40
+ end
41
+ ```
42
+ :wxWebViewHandlerResponse.Finish:
43
+ :detail:
44
+ :pre:
45
+ :detaileddescription:
46
+ - :pattern: !ruby/regexp /simplesect.*kind.*see.*Finish.*wxMBConv/
47
+ :replace: |
48
+ @see finish(text, conv)
49
+ - :pattern: !ruby/regexp /simplesect.*kind.*see.*Finish.*wxWebViewHandlerResponseData/
50
+ :replace: |
51
+ @see find(data)
52
+ :wxWebViewHandlerResponseData:
53
+ :detail:
54
+ :pre:
55
+ :detaileddescription:
56
+ - :pattern: !ruby/regexp /simplesect.*kind.*see.*Finish.*wxWebViewHandlerResponseData/
57
+ :replace: |
58
+ @see Wx::WEB::WebViewHandlerResponse#finish(data)
@@ -252,8 +252,14 @@ module WXRuby3
252
252
  Director.Spec(pkg, 'wxAffineMatrix2D', requirements: %w[USE_GEOMETRY])
253
253
  Director.Spec(pkg, 'wxCredentialEntryDialog', director: Director::Dialog, requirements: %w[USE_CREDENTIALDLG])
254
254
  Director.Spec(pkg, 'wxGenericAboutDialog', director: Director::Dialog, requirements: %w[USE_ABOUTDLG])
255
+ Director.Spec(pkg, 'wxMBConv')
255
256
  }
256
257
 
258
+ Director.Package('Wx::RT', 'USE_THREADS') do |pkg|
259
+ Director.Spec(pkg, 'wxSharedEvtHandler')
260
+ Director.Spec(pkg, 'wxThreadEvent')
261
+ end
262
+
257
263
  Director.Package('Wx::PRT', 'USE_PRINTING_ARCHITECTURE') do |pkg|
258
264
  Director.Spec(pkg, 'wxPrinterDC', director: Director::DerivedDC, requirements: Director.AnyOf(*%w[WXMSW WXOSX USE_GTKPRINT]))
259
265
  Director.Spec(pkg, 'wxPostScriptDC', director: Director::DerivedDC)
@@ -387,4 +393,10 @@ module WXRuby3
387
393
  Director.Spec(pkg, 'wxRibbonToolBar')
388
394
  Director.Spec(pkg, 'wxRibbonButtonBar')
389
395
  }
396
+
397
+ Director.Package('Wx::WEB', 'USE_WEBVIEW') { |pkg|
398
+ Director.Spec(pkg, 'wxWebViewHandler')
399
+ Director.Spec(pkg, 'wxWebView')
400
+ Director.Spec(pkg, 'wxWebViewEvent')
401
+ }
390
402
  end # module WXRuby3
@@ -532,7 +532,7 @@ module WXRuby3
532
532
 
533
533
  # window/sizer object wrapping
534
534
 
535
- map 'wxWindow*' => 'Wx::Window', 'wxSizer*' => 'Wx::Sizer' do
535
+ map 'wxWindow*' => 'Wx::Window', 'wxControl*' => 'Wx::Control', 'wxSizer*' => 'Wx::Sizer' do
536
536
  map_out code: '$result = wxRuby_WrapWxObjectInRuby($1);'
537
537
  end
538
538
 
@@ -605,6 +605,39 @@ module WXRuby3
605
605
  __CODE
606
606
  end
607
607
 
608
+ # Menu bars need to be wrapped / unwrapped correctly
609
+ map 'wxMenuBar*' => 'Wx::MenuBar' do
610
+ add_header_code <<~__CODE
611
+ WXRUBY_EXPORT VALUE wxRuby_WrapWxMenuBarInRuby(wxMenuBar *wx_menubar);
612
+ WXRUBY_EXPORT void wxRuby_RegisterWxMenuBar(wxMenuBar* wx_menubar, VALUE rb_menubar);
613
+ __CODE
614
+ map_check code: <<~__CODE
615
+ wxRuby_RegisterWxMenuBar($1, argv[$argnum-2]);
616
+ __CODE
617
+ map_out code: <<~__CODE
618
+ $result = wxRuby_WrapWxMenuBarInRuby($1);
619
+ __CODE
620
+ map_directorin code: <<~__CODE
621
+ $input = wxRuby_WrapWxMenuBarInRuby($1);
622
+ __CODE
623
+ end
624
+ # As do menus
625
+ map 'wxMenu*' => 'Wx::Menu' do
626
+ add_header_code <<~__CODE
627
+ WXRUBY_EXPORT VALUE wxRuby_WrapWxMenuInRuby(wxMenu *wx_menu);
628
+ WXRUBY_EXPORT void wxRuby_RegisterWxMenu(wxMenu* wx_menu, VALUE rb_menu);
629
+ __CODE
630
+ map_check code: <<~__CODE
631
+ wxRuby_RegisterWxMenu($1, argv[$argnum-2]);
632
+ __CODE
633
+ map_out code: <<~__CODE
634
+ $result = wxRuby_WrapWxMenuInRuby($1);
635
+ __CODE
636
+ map_directorin code: <<~__CODE
637
+ $input = wxRuby_WrapWxMenuInRuby($1);
638
+ __CODE
639
+ end
640
+
608
641
  # typemap to allow String or Symbol for wxColour in args
609
642
  map 'const wxColour&', 'const wxColour*', as: 'Wx::Colour,String,Symbol' do
610
643
  map_in temp: 'wxColour tmpcol', code: <<~__CODE
@@ -0,0 +1,58 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 Common typemap definitions
7
+ ###
8
+
9
+ require_relative '../core/mapping'
10
+
11
+ module WXRuby3
12
+
13
+ module Typemap
14
+
15
+ module MBConv
16
+
17
+ include Typemap::Module
18
+
19
+ # wxMBConv classes are used for string text encoding conversion.
20
+ # We do not want to map these in wxRuby3 though as that serves little purpose there.
21
+ # So there are wxRuby3 specific versions implemented that get mapped to the actual
22
+ # wxw instances by the type mappings below.
23
+
24
+ define do
25
+
26
+ map 'const wxMBConv&' => 'Wx::MBConv' do
27
+
28
+ add_header_code <<~__CODE
29
+ WXRUBY_EXPORT std::unique_ptr<wxMBConv> wxRuby_MBConv2wxMBConv(VALUE rb_val);
30
+ __CODE
31
+
32
+ map_in temp: 'std::unique_ptr<wxMBConv> tmp_mbc',
33
+ code: <<~__CODE
34
+ tmp_mbc = wxRuby_MBConv2wxMBConv($input);
35
+ if (!tmp_mbc)
36
+ {
37
+ rb_raise(rb_eArgError, "Invalid MBConv value for %i", $argnum-1);
38
+ }
39
+ else
40
+ {
41
+ $1 = tmp_mbc.get();
42
+ }
43
+ __CODE
44
+
45
+ map_typecheck precedence: 'POINTER', code: <<~__CODE
46
+ std::unique_ptr<wxMBConv> mbc = wxRuby_MBConv2wxMBConv($input);
47
+ $1 = mbc ? true : false;
48
+ __CODE
49
+
50
+ end
51
+
52
+ end
53
+
54
+ end
55
+
56
+ end
57
+
58
+ end