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,55 @@
1
+ <head>
2
+ <title>Advanced Handler Sample</title>
3
+
4
+ <style>
5
+ .mono {
6
+ font-family: monospace;
7
+ }
8
+ </style>
9
+
10
+ <script>
11
+ function sendRequest() {
12
+ let url = document.getElementById("request_url").value;
13
+ let request_content_type = document.getElementById("request_content_type").value;
14
+ let request_data = document.getElementById("request_data").value;
15
+ console.log("clicked");
16
+
17
+ const req = new XMLHttpRequest();
18
+ req.addEventListener("load", (ev) => {
19
+ document.getElementById("response_response").value = req.responseText;
20
+ });
21
+ req.open("POST", url);
22
+ req.setRequestHeader("Content-Type", "application/json;charset=UTF-8");
23
+ req.send(request_data);
24
+ }
25
+ </script>
26
+ </head>
27
+
28
+ <body>
29
+ <p>
30
+ This sample demonstrates how to use <i>Wx::WebViewHandler::start_request()</i>
31
+ to enable advanced requests from html and javascript in the web view.
32
+ </p>
33
+
34
+ Request URL<br />
35
+ <input id="request_url" size="40" value=""><br />
36
+ Request content type<br />
37
+ <input id="request_content_type" size="40" value="application/json"><br />
38
+ Request Data<br />
39
+ <textarea class="mono" cols="60" rows="8" id="request_data">{ param1: "wxwidgets", param2: "webview" }</textarea>
40
+ <br />
41
+ <button onclick="sendRequest()">Start request</button><br />
42
+ Response Data<br />
43
+ <textarea class="mono" cols="60" rows="8" id="response_response"></textarea>
44
+
45
+ <script>
46
+ // init request_url
47
+ let postURL;
48
+ if (navigator.userAgent.indexOf("Edg") > 0)
49
+ postURL = "https://wxpost.wxsite//main/test/1";
50
+ else
51
+ postURL = "wxpost://main/test/1";
52
+
53
+ document.getElementById("request_url").value = postURL;
54
+ </script>
55
+ </body>
@@ -0,0 +1 @@
1
+ h1 {color: red;}
@@ -0,0 +1,9 @@
1
+ <html>
2
+ <head>
3
+ <title>File System Example</title>
4
+ <link rel='stylesheet' type='text/css' href='test.css'>
5
+ </head>
6
+ <body><h1>ZIP Embedded Page</h1>
7
+ <p>This page was retrieved from a ZIP file.</p>
8
+ </body>
9
+ </html>
Binary file
@@ -25,7 +25,7 @@ module TextEntryTests
25
25
  updates = count_events(text_entry, :evt_text) do |c_upd|
26
26
 
27
27
  # WXQT only sends event when text changes
28
- unless Wx::PLATFORM == 'WXQT'
28
+ unless is_qt?
29
29
  text_entry.value = ''
30
30
  assert_equal(1, c_upd.count)
31
31
  c_upd.count = 0
@@ -36,7 +36,7 @@ module TextEntryTests
36
36
  c_upd.count = 0
37
37
 
38
38
  # WXQT only sends event when text changes
39
- unless Wx::PLATFORM == 'WXQT'
39
+ unless is_qt?
40
40
  text_entry.value = 'foo'
41
41
  assert_equal(1, c_upd.count)
42
42
  c_upd.count = 0
@@ -32,6 +32,38 @@ module WxRuby
32
32
 
33
33
  class Unit < Minitest::Test
34
34
 
35
+ def self.is_macos?
36
+ Wx::PLATFORM == 'WXOSX'
37
+ end
38
+
39
+ def is_macos?
40
+ Unit.is_macos?
41
+ end
42
+
43
+ def self.is_msw?
44
+ Wx::PLATFORM == 'WXMSW'
45
+ end
46
+
47
+ def is_msw?
48
+ Unit.is_msw?
49
+ end
50
+
51
+ def self.is_gtk?
52
+ Wx::PLATFORM == 'WXGTK'
53
+ end
54
+
55
+ def is_gtk?
56
+ Unit.is_gtk?
57
+ end
58
+
59
+ def self.is_qt?
60
+ Wx::PLATFORM == 'WXQT'
61
+ end
62
+
63
+ def is_qt?
64
+ Unit.is_qt?
65
+ end
66
+
35
67
  def self.is_ci_build?
36
68
  (ENV['GITHUB_ACTION'] || ENV['CI'])
37
69
  end
@@ -40,6 +72,14 @@ module WxRuby
40
72
  Unit.is_ci_build?
41
73
  end
42
74
 
75
+ def self.is_cirrus_ci_build?
76
+ (ENV['CIRRUS_CI'] || ENV['CI'])
77
+ end
78
+
79
+ def is_cirrus_ci_build?
80
+ Unit.is_cirrus_ci_build?
81
+ end
82
+
43
83
  def self.uses_wayland?
44
84
  Wx.has_feature?('HAVE_WAYLAND_CLIENT')
45
85
  end
@@ -75,11 +75,11 @@ module WxRuby
75
75
  class GUITests < Test::Unit
76
76
 
77
77
  def after_setup
78
- 10.times { Wx.get_app.yield }
78
+ yield_for_a_while(100)
79
79
  end
80
80
 
81
81
  def after_teardown
82
- 10.times { Wx.get_app.yield }
82
+ yield_for_a_while(100)
83
83
  GC.start
84
84
  end
85
85
 
@@ -177,6 +177,7 @@ module WxRuby
177
177
  start = ::Time.now
178
178
  while (Time.now - start) < timeout
179
179
  Wx.get_app.yield
180
+ sleep(0.01) if is_msw? # it seems on windows things may suffer from tight loops so give some breathing room
180
181
  end
181
182
  end
182
183
 
@@ -184,6 +185,20 @@ module WxRuby
184
185
  GUITests.yield_for_a_while(msec)
185
186
  end
186
187
 
188
+ def self.yield_and_wait_for_test(msec, &block)
189
+ timeout = msec / 1000.0 # sec float
190
+ start = ::Time.now
191
+ while (Time.now - start) < timeout
192
+ Wx.get_app.yield
193
+ return if block.call
194
+ sleep(0.01) if is_msw? # it seems on windows things may suffer from tight loops so give some breathing room
195
+ end
196
+ end
197
+
198
+ def yield_and_wait_for_test(msec, &block)
199
+ GUITests.yield_and_wait_for_test(msec, &block)
200
+ end
201
+
187
202
  def self.has_ui_simulator?
188
203
  Wx.has_feature?(:USE_UIACTIONSIMULATOR) && (Wx::PLATFORM != 'WXGTK' || !uses_wayland?) && (Wx::PLATFORM != 'WXOSX' || Wx::WXWIDGETS_VERSION >= '3.3')
189
204
  end
data/tests/test_art.rb CHANGED
@@ -59,16 +59,16 @@ class TestArt < WxRuby::Test::Unit
59
59
  assert_instance_of(Wx::Bitmap, bundle.get_bitmap([256,256]))
60
60
  end
61
61
 
62
- if Wx::PLATFORM == 'WXMSW'
62
+ if is_msw?
63
63
 
64
- def test_cursors
65
- cursor = nil
66
- assert_nothing_raised do
67
- cursor = Wx.Cursor(:wxruby)
64
+ def test_cursors
65
+ cursor = nil
66
+ assert_nothing_raised do
67
+ cursor = Wx.Cursor(:wxruby)
68
+ end
69
+ assert_instance_of(Wx::Cursor, cursor)
70
+ assert(cursor.ok?)
68
71
  end
69
- assert_instance_of(Wx::Cursor, cursor)
70
- assert(cursor.ok?)
71
- end
72
72
 
73
73
  end
74
74
 
@@ -142,7 +142,7 @@ class TestDataObjectComposite < WxRuby::Test::Unit
142
142
  bmp = Wx::Bitmap.new(File.join(__dir__, '../samples/minimal/mondrian.png'))
143
143
 
144
144
  d_obj.add( Wx::BitmapDataObject.new )
145
- if Wx::PLATFORM == 'WXMSW'
145
+ if is_msw?
146
146
  assert_equal( 1, d_txt.get_format_count(Wx::DataObject::Direction::Get) )
147
147
  assert_equal( 2, d_obj.get_format_count(Wx::DataObject::Direction::Get) )
148
148
  else
@@ -170,7 +170,7 @@ class TestDataObjectComposite < WxRuby::Test::Unit
170
170
 
171
171
  GC.start
172
172
 
173
- if Wx::PLATFORM == 'WXMSW'
173
+ if is_msw?
174
174
  assert_equal d_obj.received_format.get_type, Wx::DF_DIB.get_type
175
175
  d_bmp = d_obj.get_object(Wx::DF_DIB)
176
176
  else
@@ -206,7 +206,7 @@ class TestDataObjectComposite < WxRuby::Test::Unit
206
206
  GC.start
207
207
 
208
208
  assert_equal d_obj_2.received_format.get_type, d_txt.get_preferred_format(Wx::DataObject::Direction::Set).get_type
209
- if Wx::PLATFORM == 'WXMSW'
209
+ if is_msw?
210
210
  d_txt = d_obj_2.get_object(Wx::DF_UNICODETEXT)
211
211
  else
212
212
  d_txt = d_obj_2.get_object(Wx::DF_TEXT)
@@ -218,7 +218,7 @@ class TestDataObjectComposite < WxRuby::Test::Unit
218
218
  d_obj_2 = Wx::DataObjectComposite.new
219
219
  d_obj_2.add Wx::TextDataObject.new
220
220
  d_obj_2.add MySimpleIntArrayObject.new([1,2,3,4,5])
221
- if Wx::PLATFORM == 'WXMSW'
221
+ if is_msw?
222
222
  assert_equal( 2, d_obj_2.get_format_count(Wx::DataObject::Direction::Get) )
223
223
  else
224
224
  assert_equal( 3, d_obj_2.get_format_count(Wx::DataObject::Direction::Get) )
data/tests/test_config.rb CHANGED
@@ -204,15 +204,15 @@ class TestConfig < WxRuby::Test::Unit
204
204
  # by default expansion is on
205
205
 
206
206
  # Cirrus CI Linux builds run in privileged container without proper user env
207
- has_user = Wx::PLATFORM == 'WXMSW' || ENV['USER']
207
+ has_user = is_msw? || ENV['USER']
208
208
 
209
209
  # add a number of entries for env var in new group 'Environment'
210
210
  cfg['/Environment/HOME'] = '$HOME'
211
- cfg['Environment'].USER = Wx::PLATFORM == 'WXMSW' ? '%USERNAME%' : '${USER}' if has_user
211
+ cfg['Environment'].USER = is_msw? ? '%USERNAME%' : '${USER}' if has_user
212
212
  cfg['/Environment/PATH'] = '$(PATH)'
213
213
 
214
214
  assert_equal(ENV['HOME'], cfg.Environment['HOME'])
215
- assert_equal(ENV[Wx::PLATFORM == 'WXMSW' ? 'USERNAME' : 'USER'], cfg['/Environment/USER']) if has_user
215
+ assert_equal(ENV[is_msw? ? 'USERNAME' : 'USER'], cfg['/Environment/USER']) if has_user
216
216
  assert_equal(ENV['PATH'], cfg.Environment.PATH)
217
217
 
218
218
  # test escaping
@@ -228,9 +228,9 @@ class TestConfig < WxRuby::Test::Unit
228
228
 
229
229
  assert_equal('${NonExistingLongNonsenseVariable}', cfg.Environment['NONSENSE'])
230
230
 
231
- cfg['/Environment/MULTIPLE'] = "$HOME / #{Wx::PLATFORM == 'WXMSW' ? '%USERNAME%' : '${USER}'}" if has_user
231
+ cfg['/Environment/MULTIPLE'] = "$HOME / #{is_msw? ? '%USERNAME%' : '${USER}'}" if has_user
232
232
 
233
- assert_equal("#{ENV['HOME']} / #{Wx::PLATFORM == 'WXMSW' ? ENV['USERNAME'] : ENV['USER']}", cfg.Environment['MULTIPLE']) if has_user
233
+ assert_equal("#{ENV['HOME']} / #{is_msw? ? ENV['USERNAME'] : ENV['USER']}", cfg.Environment['MULTIPLE']) if has_user
234
234
 
235
235
  # disable env var expansion
236
236
  cfg.expand_env_vars = false
@@ -272,7 +272,7 @@ class TestConfig < WxRuby::Test::Unit
272
272
  end
273
273
 
274
274
  # default registry based config does not seem to do well in CI build env
275
- unless is_ci_build? && Wx::PLATFORM == 'WXMSW'
275
+ unless is_ci_build? && is_msw?
276
276
 
277
277
  def test_default_wx
278
278
  Wx::ConfigBase.set(nil) # reset global instance
@@ -14,27 +14,29 @@ class DirectorExceptionTests < Minitest::Test
14
14
  RbConfig::CONFIG["ruby_install_name"] + RbConfig::CONFIG["EXEEXT"]).
15
15
  sub(/.*\s.*/m, '"\&"')
16
16
 
17
+ INC_DIR = File.realpath(File.join(__dir__, '..', 'lib'))
18
+
17
19
  OPTS = {
18
20
  :err => (Plat4m.current.windows? ? 'NULL' : '/dev/null'), :out => (Plat4m.current.windows? ? 'NULL' : '/dev/null'),
19
21
  }
20
22
 
21
23
  def test_invalid_overload_type
22
- assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/overload_type_exception_test.rb'), **OPTS))
23
- assert_equal(254, $?.exitstatus)
24
+ assert_false(Kernel.system(RUBY, '-I', INC_DIR, File.join(__dir__, 'lib/overload_type_exception_test.rb'), **OPTS))
25
+ assert_equal(126, $?.exitstatus)
24
26
  end
25
27
 
26
28
  def test_leaked_exception_in_overload
27
- assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/leaked_overload_exception_test.rb'), **OPTS))
28
- assert_equal(255, $?.exitstatus)
29
+ assert_false(Kernel.system(RUBY, '-I', INC_DIR, File.join(__dir__, 'lib/leaked_overload_exception_test.rb'), **OPTS))
30
+ assert_equal(127, $?.exitstatus)
29
31
  end
30
32
 
31
33
  def test_leaked_process_event_handling_exception
32
- assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/leaked_process_event_exception_test.rb'), **OPTS))
34
+ assert_false(Kernel.system(RUBY, '-I', INC_DIR, File.join(__dir__, 'lib/leaked_process_event_exception_test.rb'), **OPTS))
33
35
  assert_equal(1, $?.exitstatus)
34
36
  end
35
37
 
36
38
  def test_leaked_queued_event_handling_exception
37
- assert_false(Kernel.system(RUBY, File.join(__dir__, 'lib/leaked_queued_event_exception_test.rb'), **OPTS))
39
+ assert_false(Kernel.system(RUBY, '-I', INC_DIR, File.join(__dir__, 'lib/leaked_queued_event_exception_test.rb'), **OPTS))
38
40
  assert_equal(1, $?.exitstatus)
39
41
  end
40
42
 
@@ -158,7 +158,7 @@ class CommandLinkButtonTests < WxRuby::Test::GUITests
158
158
  end
159
159
 
160
160
  # intermittent failures in OSX CI builds
161
- unless Wx::PLATFORM == 'WXOSX' && is_ci_build?
161
+ unless is_macos? && is_ci_build?
162
162
  assert_equal(1, count)
163
163
  end
164
164
  end
@@ -213,7 +213,7 @@ class SpinCtrlTests < WxRuby::Test::GUITests
213
213
  sim.key_down(Wx::KeyCode::K_UP)
214
214
  sim.key_up(Wx::KeyCode::K_UP)
215
215
  end
216
- unless Wx::PLATFORM == 'WXOSX' && is_ci_build?
216
+ unless is_macos? && is_ci_build?
217
217
  assert_equal(1, count)
218
218
  assert_equal(1, spin.value)
219
219
  end
@@ -257,7 +257,7 @@ class SpinCtrlDoubleTests < WxRuby::Test::GUITests
257
257
  sim.key_down(Wx::KeyCode::K_UP)
258
258
  sim.key_up(Wx::KeyCode::K_UP)
259
259
  end
260
- unless Wx::PLATFORM == 'WXOSX' && is_ci_build?
260
+ unless is_macos? && is_ci_build?
261
261
  assert_equal(1, count)
262
262
  assert_equal(1.0, spin.value)
263
263
  end
@@ -7,7 +7,7 @@ require_relative './lib/wxapp_runner'
7
7
  class FileDialogTests < WxRuby::Test::Unit
8
8
 
9
9
  def dialog_tester(dlg, rc=Wx::ID_OK)
10
- if Wx::PLATFORM == 'WXGTK'
10
+ if is_gtk?
11
11
  timer = Wx::Timer.new(dlg)
12
12
  dlg.evt_timer(timer) { dlg.end_modal(rc) }
13
13
  timer.start_once(2000)
@@ -28,9 +28,9 @@ class FileDialogTests < WxRuby::Test::Unit
28
28
 
29
29
  class FileDialogTestCustomization < Wx::FileDialogCustomizeHook
30
30
 
31
- def initialize
32
- super
33
- @hooked = Wx::PLATFORM != 'WXGTK'
31
+ def initialize(hooked)
32
+ super()
33
+ @hooked = hooked
34
34
  end
35
35
 
36
36
  attr_reader :hooked
@@ -44,7 +44,7 @@ class FileDialogTests < WxRuby::Test::Unit
44
44
 
45
45
  def test_customized_file_dialog
46
46
  dlg = Wx::FileDialog.new(nil, 'Select file')
47
- hook = FileDialogTestCustomization.new
47
+ hook = FileDialogTestCustomization.new(!is_gtk?)
48
48
  dlg.set_customize_hook(hook)
49
49
  GC.start
50
50
  assert_equal(Wx::ID_OK, dialog_tester(dlg))
data/tests/test_font.rb CHANGED
@@ -66,7 +66,7 @@ class FontTests < WxRuby::Test::Unit
66
66
  font = Wx::Font.new
67
67
  font.set_numeric_weight(123)
68
68
 
69
- assert_equal(123, font.get_numeric_weight) unless Wx::PLATFORM == 'WXOSX'
69
+ assert_equal(123, font.get_numeric_weight) unless is_macos?
70
70
 
71
71
  assert_equal(Wx::FontWeight::FONTWEIGHT_THIN, font.get_weight)
72
72
 
@@ -87,7 +87,7 @@ class FontTests < WxRuby::Test::Unit
87
87
 
88
88
  # if the call to set_face_name() below fails on your system/port,
89
89
  # consider adding another branch to this if
90
- known_good_face_name = if Wx::PLATFORM == 'WXMSW' || Wx::PLATFORM == 'WXOSX'
90
+ known_good_face_name = if is_msw? || is_macos?
91
91
  "Arial"
92
92
  else
93
93
  "Monospace"
@@ -138,7 +138,7 @@ class FontTests < WxRuby::Test::Unit
138
138
  # on wxMSW Wx::FONTSTYLE_SLANT==Wx::FONTSTYLE_ITALIC, so accept the latter
139
139
  # as a valid value too.
140
140
  if ( test.get_style != Wx::FONTSTYLE_SLANT )
141
- assert( Wx::PLATFORM == 'WXMSW' && Wx::FONTSTYLE_ITALIC == test.get_style )
141
+ assert( is_msw? && Wx::FONTSTYLE_ITALIC == test.get_style )
142
142
  end
143
143
 
144
144
  # test get/set_underlined()
@@ -184,7 +184,7 @@ class FontTests < WxRuby::Test::Unit
184
184
  puts("original font user description: #{test.get_native_font_info_user_desc}") unless is_ci_build?
185
185
  puts("the other font description: #{temp.get_native_font_info_user_desc}") unless is_ci_build?
186
186
 
187
- assert_equal( temp, test ) unless Wx::PLATFORM == 'WXOSX'
187
+ assert_equal( temp, test ) unless is_macos?
188
188
  end
189
189
 
190
190
  # test that clearly invalid font info strings do not work
@@ -202,17 +202,17 @@ class FontTests < WxRuby::Test::Unit
202
202
  font.set_underlined(true)
203
203
  font.set_strikethrough(true)
204
204
  assert(font == Wx::Font.new(font))
205
- assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless Wx::PLATFORM == 'WXOSX'
205
+ assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless is_macos?
206
206
  assert(Wx::Font.new(font.get_native_font_info_desc).get_underlined)
207
207
  assert(Wx::Font.new(font.get_native_font_info_desc).get_strikethrough)
208
208
  font.set_underlined(false)
209
209
  assert(font == Wx::Font.new(font))
210
- assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless Wx::PLATFORM == 'WXOSX'
210
+ assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless is_macos?
211
211
  assert(!Wx::Font.new(font.get_native_font_info_desc).get_underlined)
212
212
  font.set_underlined(true)
213
213
  font.set_strikethrough(false)
214
214
  assert(font == Wx::Font.new(font))
215
- assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless Wx::PLATFORM == 'WXOSX'
215
+ assert(font == Wx::Font.new(font.get_native_font_info_desc)) unless is_macos?
216
216
  assert(Wx::Font.new(font.get_native_font_info_desc).get_underlined)
217
217
  assert(!Wx::Font.new(font.get_native_font_info_desc).get_strikethrough)
218
218
  end
@@ -0,0 +1,133 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './lib/wxframe_runner'
6
+
7
+ class GridCtrlTests < WxRuby::Test::GUITests
8
+
9
+
10
+ class MyTextCellEditor < Wx::GRID::GridCellTextEditor
11
+ def apply_edit(row, col, grid)
12
+ grid.set_cell_value(row, col, "'#{get_value}'" )
13
+ end
14
+ end
15
+
16
+ def setup
17
+ super
18
+ sizer = Wx::BoxSizer.new(Wx::VERTICAL)
19
+ make_grid(frame_win)
20
+ sizer.add(@grid, 1, Wx::ALL|Wx::GROW, 4)
21
+ frame_win.set_sizer(sizer)
22
+
23
+ end
24
+
25
+ def teardown
26
+ frame_win.sizer.remove(0)
27
+ @grid.destroy
28
+ super
29
+ end
30
+
31
+ attr_reader :grid
32
+
33
+ # Create a wxGrid object
34
+ def make_grid(panel)
35
+ @grid = Wx::GRID::Grid.new(panel, -1)
36
+
37
+ # Then we call CreateGrid to set the dimensions of the grid
38
+ # (11 rows and 12 columns in this example)
39
+ @grid.create_grid( 20, 12 )
40
+ @grid.set_default_cell_background_colour(Wx::WHITE)
41
+ @grid.set_default_cell_text_colour(Wx::BLACK)
42
+ # We can set the sizes of individual rows and columns
43
+ # in pixels, and the label value string
44
+ @grid.set_row_size( 0, 60 )
45
+ @grid.set_row_label_value( 0, "Row1" )
46
+ @grid.set_row_label_alignment(Wx::ALIGN_CENTRE, Wx::ALIGN_CENTRE)
47
+
48
+ @grid.set_col_size( 0, 120 )
49
+ @grid.set_col_label_value( 0, "Col1" )
50
+ @grid.set_col_label_alignment(Wx::ALIGN_CENTRE, Wx::ALIGN_CENTRE)
51
+
52
+ # And set grid cell contents as strings
53
+ @grid.set_cell_value( 0, 0, "wxGrid is good" )
54
+
55
+ # We can specify that some cells are read-only
56
+ @grid.set_cell_value( 0, 2, "Read-only" )
57
+ @grid.set_read_only( 0, 2 )
58
+
59
+ cell_attr = Wx::GRID::GridCellAttr.new
60
+ cell_attr.editor = MyTextCellEditor.new
61
+ @grid.set_row_attr(1, cell_attr)
62
+ cell_attr2 = Wx::GRID::GridCellAttr.new
63
+ cell_attr2.editor = cell_attr.editor(@grid, 1, 1)
64
+ @grid.set_row_attr(2, cell_attr2)
65
+
66
+ # Colours can be specified for grid cell contents
67
+ @grid.set_cell_value(1, 1, "white on red")
68
+ @grid.set_cell_text_colour(1, 1, Wx::WHITE)
69
+ @grid.set_cell_background_colour(1, 1, Wx::RED)
70
+
71
+ # We can specify the some cells will store numeric
72
+ # values rather than strings. Here we set grid column 6
73
+ # to hold floating point values displayed with width
74
+ # of 2 and precision of 2. The column is highlighted in light grey
75
+ @grid.set_col_format_float(5, 2, 2)
76
+ cell_attr = Wx::GRID::GridCellAttr.new
77
+ cell_attr.set_background_colour( Wx::LIGHT_GREY )
78
+
79
+ @grid.set_col_attr(5, cell_attr)
80
+ @grid.set_cell_value(0, 5, "3.1415")
81
+ @grid.set_cell_value(0, 6,
82
+ "The whole column to the left uses float format")
83
+
84
+ # Custom Editors Can be used
85
+ editor = Wx::GRID::GridCellNumberEditor.new(5, 20)
86
+ @grid.set_cell_value(3, 1, 'Number editor below')
87
+ @grid.set_cell_editor(4, 1, editor)
88
+
89
+ editor = Wx::GRID::GridCellFloatEditor.new(4, 2)
90
+ @grid.set_cell_value(3, 2, 'Float editor below')
91
+ @grid.set_cell_editor(4, 2, editor)
92
+
93
+ editor = Wx::GRID::GridCellChoiceEditor.new(['foo', 'bar', 'baz'])
94
+ @grid.set_cell_value(3, 3, 'Choice editor below')
95
+ @grid.set_cell_editor(4, 3, editor)
96
+
97
+ @grid.auto_size_row(3, true)
98
+
99
+ # Display of cells can be customised
100
+ @grid.set_cell_editor(6, 0, Wx::GRID::GridCellBoolEditor.new)
101
+ @grid.set_cell_renderer(6, 0, Wx::GRID::GridCellBoolRenderer.new)
102
+ @grid.set_cell_value(6, 1, 'Cell to the left displayed as boolean')
103
+ end
104
+
105
+ def test_grid
106
+ grid.set_grid_cursor([0, 2])
107
+ assert_true(grid.is_current_cell_read_only)
108
+
109
+ grid.set_grid_cursor([1, 1])
110
+ grid.enable_cell_edit_control
111
+ grid.get_cell_editor(*[1,1]).get_control.set_value('hello world')
112
+ grid.save_edit_control_value
113
+ grid.disable_cell_edit_control
114
+ assert_equal("'hello world'", grid.get_cell_value(1, 1))
115
+
116
+ unless is_ci_build? && is_macos?
117
+ grid.set_grid_cursor([4, 3])
118
+ grid.enable_cell_edit_control
119
+ grid.get_cell_editor(4, 3).get_control.set_selection(1)
120
+ grid.save_edit_control_value
121
+ grid.disable_cell_edit_control
122
+ assert_equal('bar', grid.get_cell_value(4, 3))
123
+ end
124
+
125
+ grid.set_grid_cursor([6, 0])
126
+ grid.enable_cell_edit_control
127
+ grid.get_cell_editor(6, 0).get_control.set_value(true)
128
+ grid.save_edit_control_value
129
+ grid.disable_cell_edit_control
130
+ assert_equal('1', grid.get_cell_value(6, 0))
131
+ end
132
+
133
+ end
@@ -0,0 +1,88 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './lib/wxframe_runner'
6
+
7
+ if Wx.has_feature?(:USE_HELP)
8
+
9
+
10
+ class TestHelp < WxRuby::Test::GUITests
11
+
12
+
13
+ class << self
14
+ def hlp_initialised
15
+ @hlp_initialized ||= false
16
+ end
17
+ def hlp_initialized=(init)
18
+ @hlp_initialized = init
19
+ end
20
+ end
21
+
22
+ def before_setup
23
+ super
24
+ unless self.class.hlp_initialised
25
+ Wx::HelpProvider.set(Wx::HelpControllerHelpProvider.new)
26
+
27
+ @hlp_controller = Wx::HelpController.new
28
+
29
+ Wx::HelpProvider.get.set_help_controller(@hlp_controller)
30
+
31
+ assert_true(@hlp_controller.init(File.join(__dir__, '..', 'samples', 'help', 'doc')))
32
+
33
+ self.class.hlp_initialized = true
34
+ end
35
+ end
36
+
37
+ def setup
38
+ super
39
+ @button = Wx::Button.new(frame_win, label: 'Button')
40
+ @text = Wx::TextCtrl.new(frame_win, name: 'Text')
41
+ @check = Wx::CheckBox.new(frame_win, label: 'Check Box')
42
+ Wx::HelpProvider.get.add_help(frame_win, 'Frame help')
43
+ Wx::HelpProvider.get.add_help(@button, 'Button help')
44
+ Wx::HelpProvider.get.add_help(@text, 'Text help')
45
+ end
46
+
47
+ def teardown
48
+ super
49
+ @button.destroy
50
+ @text.destroy
51
+ @check.destroy
52
+ end
53
+
54
+ attr_reader :button, :text, :check
55
+
56
+ def test_get_help
57
+ assert_equal('Frame help', Wx::HelpProvider.get.get_help(frame_win))
58
+ assert_equal('Button help', Wx::HelpProvider.get.get_help(button))
59
+ assert_equal('Text help', Wx::HelpProvider.get.get_help(text))
60
+ assert_empty(Wx::HelpProvider.get.get_help(check))
61
+ end
62
+
63
+ def test_show_help
64
+ assert_true(Wx::HelpProvider.get.show_help(frame_win))
65
+ assert_true(Wx::HelpProvider.get.show_help(button))
66
+ assert_true(Wx::HelpProvider.get.show_help(text))
67
+ assert_false(Wx::HelpProvider.get.show_help(check))
68
+ end
69
+
70
+ def test_remove_help
71
+ assert_true(Wx::HelpProvider.get.show_help(button))
72
+ Wx::HelpProvider.get.remove_help(button)
73
+ assert_false(Wx::HelpProvider.get.show_help(button))
74
+ assert_empty(Wx::HelpProvider.get.get_help(button))
75
+ end
76
+
77
+ unless is_cirrus_ci_build?
78
+ def test_help_controller
79
+ assert_true(Wx::HelpProvider.get.get_help_controller.display_contents)
80
+ assert_true(Wx::HelpProvider.get.get_help_controller.quit) unless is_msw?
81
+ assert_true(Wx::HelpProvider.get.get_help_controller.display_section('Introduction'))
82
+ assert_true(Wx::HelpProvider.get.get_help_controller.quit) unless is_msw?
83
+ end
84
+ end
85
+
86
+ end
87
+
88
+ end
data/tests/test_intl.rb CHANGED
@@ -91,7 +91,7 @@ class TestInternationalisation < WxRuby::Test::Unit
91
91
  assert_raises(ArgumentError) { Wx::Locale.set_locale('bad') }
92
92
  # this causes problems on MacOSX if the language / region combination is unusual
93
93
  # like on my system (US English language / NL region)
94
- unless Wx::PLATFORM == 'WXOSX'
94
+ unless is_macos?
95
95
  locale = Wx::Locale.new(Wx::LANGUAGE_DEFAULT)
96
96
  end
97
97
  end