wxruby3 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/ext/wxruby3/include/wxRubyApp.h +338 -0
  4. data/ext/wxruby3/include/wxruby-Config.h +6 -6
  5. data/ext/wxruby3/include/wxruby-runtime.h +3 -0
  6. data/ext/wxruby3/swig/common.i +22 -0
  7. data/ext/wxruby3/swig/custom/director.swg +296 -0
  8. data/ext/wxruby3/swig/custom/rubyapi.swg +19 -0
  9. data/ext/wxruby3/swig/custom/rubyerrors.swg +45 -0
  10. data/ext/wxruby3/swig/custom/rubyhead.swg +192 -0
  11. data/ext/wxruby3/swig/custom/rubyrun.swg +187 -0
  12. data/ext/wxruby3/swig/custom/swigrun.swg +363 -0
  13. data/ext/wxruby3/swig/custom/typemaps/swigtypemaps.swg +173 -0
  14. data/ext/wxruby3/swig/wx.i +50 -30
  15. data/lib/wx/aui/aui_tab_ctrl.rb +18 -0
  16. data/lib/wx/aui/auinotebook.rb +6 -2
  17. data/lib/wx/aui/require.rb +1 -0
  18. data/lib/wx/core/app.rb +2 -2
  19. data/lib/wx/core/collapsible_pane.rb +1 -1
  20. data/lib/wx/core/const.rb +83 -0
  21. data/lib/wx/core/controlwithitems.rb +8 -6
  22. data/lib/wx/core/menu.rb +10 -0
  23. data/lib/wx/core/notebook.rb +6 -2
  24. data/lib/wx/core/sizer.rb +11 -0
  25. data/lib/wx/core/task_bar_button.rb +19 -0
  26. data/lib/wx/core/textctrl.rb +11 -1
  27. data/lib/wx/core/{treectrl.rb → tree_ctrl.rb} +31 -12
  28. data/lib/wx/core/window.rb +10 -0
  29. data/lib/wx/doc/app.rb +48 -38
  30. data/lib/wx/doc/art_locator.rb +47 -43
  31. data/lib/wx/doc/aui/auimanager.rb +16 -8
  32. data/lib/wx/doc/aui/auinotebook.rb +20 -5
  33. data/lib/wx/doc/clipboard.rb +11 -7
  34. data/lib/wx/doc/colour_dialog.rb +14 -10
  35. data/lib/wx/doc/const.rb +66 -66
  36. data/lib/wx/doc/controlwithitems.rb +17 -7
  37. data/lib/wx/doc/data_object.rb +2 -2
  38. data/lib/wx/doc/event.rb +0 -6
  39. data/lib/wx/doc/evthandler.rb +113 -108
  40. data/lib/wx/doc/font.rb +1 -0
  41. data/lib/wx/doc/functions.rb +9 -9
  42. data/lib/wx/doc/gc_dc.rb +6 -1
  43. data/lib/wx/doc/graphics_context.rb +1 -0
  44. data/lib/wx/doc/grid/grid.rb +22 -1
  45. data/lib/wx/doc/help_controller.rb +11 -7
  46. data/lib/wx/doc/html/html_help_controller.rb +12 -4
  47. data/lib/wx/doc/list_ctrl.rb +33 -29
  48. data/lib/wx/doc/menu.rb +20 -0
  49. data/lib/wx/doc/notebook.rb +21 -0
  50. data/lib/wx/doc/pg/events.rb +13 -9
  51. data/lib/wx/doc/pg/pg_property.rb +18 -0
  52. data/lib/wx/doc/progress_dialog.rb +36 -32
  53. data/lib/wx/doc/prt/page_setup_dialog.rb +20 -12
  54. data/lib/wx/doc/prt/print_data.rb +13 -5
  55. data/lib/wx/doc/prt/print_dialog.rb +31 -23
  56. data/lib/wx/doc/prt/printer.rb +20 -12
  57. data/lib/wx/doc/radio_box.rb +19 -15
  58. data/lib/wx/doc/rbn/ribbon_bar.rb +13 -5
  59. data/lib/wx/doc/rbn/ribbon_button_bar.rb +13 -5
  60. data/lib/wx/doc/rbn/ribbon_gallery.rb +13 -5
  61. data/lib/wx/doc/rbn/ribbon_tool_bar.rb +13 -5
  62. data/lib/wx/doc/region_iterator.rb +32 -28
  63. data/lib/wx/doc/rtc/rich_text_composite_object.rb +24 -0
  64. data/lib/wx/doc/rtc/rich_text_ctrl.rb +24 -0
  65. data/lib/wx/doc/rtc/rich_text_paragraph.rb +24 -0
  66. data/lib/wx/doc/rtc/richtext_buffer.rb +27 -19
  67. data/lib/wx/doc/rtc/richtext_printing.rb +17 -9
  68. data/lib/wx/doc/rtc/richtext_style_sheet.rb +17 -9
  69. data/lib/wx/doc/sizer.rb +20 -0
  70. data/lib/wx/doc/stc/styled_text_ctrl.rb +24 -0
  71. data/lib/wx/doc/stream.rb +39 -35
  72. data/lib/wx/doc/system_settings.rb +30 -26
  73. data/lib/wx/doc/text_validator.rb +12 -8
  74. data/lib/wx/doc/textctrl.rb +16 -0
  75. data/lib/wx/doc/tree_ctrl.rb +95 -0
  76. data/lib/wx/doc/treebook.rb +9 -5
  77. data/lib/wx/doc/v_list_box.rb +9 -5
  78. data/lib/wx/doc/variant.rb +164 -160
  79. data/lib/wx/doc/window.rb +57 -42
  80. data/lib/wx/doc/window_disabler.rb +10 -6
  81. data/lib/wx/grid/grid.rb +27 -4
  82. data/lib/wx/keyword_defs.rb +43 -6
  83. data/lib/wx/pg/pg_property.rb +22 -0
  84. data/lib/wx/rtc/require.rb +3 -0
  85. data/lib/wx/rtc/rich_text_composite_object.rb +25 -0
  86. data/lib/wx/rtc/rich_text_ctrl.rb +25 -0
  87. data/lib/wx/rtc/rich_text_paragraph.rb +25 -0
  88. data/lib/wx/stc/require.rb +1 -0
  89. data/lib/wx/stc/styled_text_ctrl.rb +25 -0
  90. data/lib/wx/version.rb +1 -1
  91. data/rakelib/lib/config/linux.rb +0 -3
  92. data/rakelib/lib/config/macosx.rb +1 -1
  93. data/rakelib/lib/config/mingw.rb +1 -1
  94. data/rakelib/lib/config/unixish.rb +1 -1
  95. data/rakelib/lib/config.rb +14 -4
  96. data/rakelib/lib/core/include/funcall.inc +33 -14
  97. data/rakelib/lib/core/include/swigdirector.inc +384 -0
  98. data/rakelib/lib/core/include/swigrubyerrors.inc +161 -0
  99. data/{ext/wxruby3/swig/custom/swig4/rubyrun.swg → rakelib/lib/core/include/swigrubyrun.inc} +245 -120
  100. data/rakelib/lib/core/include/swigrun.inc +700 -0
  101. data/rakelib/lib/core/package.rb +19 -9
  102. data/rakelib/lib/core/parameter.rb +3 -0
  103. data/rakelib/lib/core/spec.rb +6 -1
  104. data/rakelib/lib/director/accelerator.rb +3 -4
  105. data/rakelib/lib/director/accessible.rb +47 -0
  106. data/rakelib/lib/director/animation.rb +1 -1
  107. data/rakelib/lib/director/animation_ctrl.rb +20 -0
  108. data/rakelib/lib/director/app.rb +15 -304
  109. data/rakelib/lib/director/app_traits.rb +10 -12
  110. data/rakelib/lib/director/art_provider.rb +1 -1
  111. data/rakelib/lib/director/ctrl_with_items.rb +17 -5
  112. data/rakelib/lib/director/data_format.rb +1 -1
  113. data/rakelib/lib/director/data_object_simple_base.rb +1 -2
  114. data/rakelib/lib/director/derived_dc.rb +1 -1
  115. data/rakelib/lib/director/dialog.rb +6 -0
  116. data/rakelib/lib/director/dialup_event.rb +44 -0
  117. data/rakelib/lib/director/dialup_manager.rb +45 -0
  118. data/rakelib/lib/director/drag_image.rb +2 -3
  119. data/rakelib/lib/director/event.rb +22 -4
  120. data/rakelib/lib/director/file_ctrl.rb +35 -0
  121. data/rakelib/lib/director/file_ctrl_event.rb +26 -0
  122. data/rakelib/lib/director/frame.rb +1 -3
  123. data/rakelib/lib/director/gdicommon.rb +27 -11
  124. data/rakelib/lib/director/graphics_context.rb +2 -4
  125. data/rakelib/lib/director/grid_cell_editor.rb +6 -6
  126. data/rakelib/lib/director/grid_ctrl.rb +34 -3
  127. data/rakelib/lib/director/help_controller.rb +1 -1
  128. data/rakelib/lib/director/icon.rb +5 -2
  129. data/rakelib/lib/director/list_ctrl.rb +5 -6
  130. data/rakelib/lib/director/locale.rb +1 -3
  131. data/rakelib/lib/director/log.rb +1 -4
  132. data/rakelib/lib/director/media_ctrl.rb +54 -0
  133. data/rakelib/lib/director/menu.rb +16 -1
  134. data/rakelib/lib/director/menu_item.rb +2 -2
  135. data/rakelib/lib/director/pgarray_editor_dialog.rb +0 -6
  136. data/rakelib/lib/director/pgeditor.rb +2 -2
  137. data/rakelib/lib/director/pgproperties.rb +3 -3
  138. data/rakelib/lib/director/pgproperty.rb +24 -1
  139. data/rakelib/lib/director/property_grid_interface.rb +5 -10
  140. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  141. data/rakelib/lib/director/richtext_composite_object.rb +25 -0
  142. data/rakelib/lib/director/richtext_ctrl.rb +15 -5
  143. data/rakelib/lib/director/richtext_formatting_dialog.rb +7 -5
  144. data/rakelib/lib/director/richtext_paragraph_layout_box.rb +9 -7
  145. data/rakelib/lib/director/sash_event.rb +42 -0
  146. data/rakelib/lib/director/sizer.rb +79 -1
  147. data/rakelib/lib/director/sizer_item.rb +22 -0
  148. data/rakelib/lib/director/static_box.rb +4 -5
  149. data/rakelib/lib/director/styled_text_ctrl.rb +12 -0
  150. data/rakelib/lib/director/task_bar_button.rb +30 -0
  151. data/rakelib/lib/director/task_bar_icon.rb +6 -14
  152. data/rakelib/lib/director/textctrl.rb +12 -1
  153. data/rakelib/lib/director/tool_tip.rb +1 -1
  154. data/rakelib/lib/director/top_level_window.rb +4 -5
  155. data/rakelib/lib/director/tree_ctrl.rb +24 -50
  156. data/rakelib/lib/director/variant.rb +1 -1
  157. data/rakelib/lib/director/window.rb +24 -5
  158. data/rakelib/lib/director.rb +4 -4
  159. data/rakelib/lib/extractor/function.rb +6 -6
  160. data/rakelib/lib/extractor.rb +34 -5
  161. data/rakelib/lib/generate/analyzer.rb +8 -3
  162. data/rakelib/lib/generate/doc/animation_ctrl.yaml +15 -0
  163. data/rakelib/lib/generate/doc/busy_info.yaml +0 -2
  164. data/rakelib/lib/generate/doc/clipboard.yaml +0 -2
  165. data/rakelib/lib/generate/doc/cursor.yaml +0 -2
  166. data/rakelib/lib/generate/doc/events.yaml +10 -4
  167. data/rakelib/lib/generate/doc/panel.yaml +7 -0
  168. data/rakelib/lib/generate/doc/static_box.yaml +8 -0
  169. data/rakelib/lib/generate/doc/xml_resource.yaml +3 -0
  170. data/rakelib/lib/generate/doc.rb +89 -16
  171. data/rakelib/lib/generate/interface.rb +4 -3
  172. data/rakelib/lib/specs/interfaces.rb +161 -156
  173. data/rakelib/lib/swig_runner.rb +4 -50
  174. data/rakelib/lib/typemap/common.rb +54 -10
  175. data/rakelib/lib/typemap/data_format.rb +1 -1
  176. data/rakelib/lib/typemap/data_object_data.rb +2 -2
  177. data/rakelib/lib/typemap/pgprop_arg.rb +7 -2
  178. data/rakelib/lib/typemap/points_list.rb +5 -7
  179. data/rakelib/lib/util/string.rb +10 -8
  180. data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +74 -2
  181. data/rakelib/yard/templates/default/fulldoc/html/full_list.erb +38 -0
  182. data/rakelib/yard/templates/default/fulldoc/html/setup.rb +39 -0
  183. data/rakelib/yard/templates/default/tags/html/wxrb_require.erb +10 -0
  184. data/rakelib/yard/templates/default/tags/setup.rb +16 -0
  185. data/rakelib/yard/yard-custom-templates.rb +3 -0
  186. data/samples/text/richtext.rb +0 -30
  187. data/samples/treectrl/treectrl.rb +1 -1
  188. data/tests/media/beep_lo.wav +0 -0
  189. data/tests/test_app_exit_exception.rb +36 -0
  190. data/tests/test_app_init_exception.rb +20 -0
  191. data/tests/test_book_controls.rb +29 -0
  192. data/tests/test_exceptions.rb +41 -0
  193. data/tests/test_list_ctrl.rb +1 -1
  194. data/tests/test_media_ctrl.rb +38 -0
  195. data/tests/test_menu.rb +69 -0
  196. data/tests/test_pg.rb +27 -0
  197. data/tests/test_richtext.rb +45 -0
  198. data/tests/test_sizer.rb +59 -0
  199. data/tests/test_std_controls.rb +78 -1
  200. data/tests/test_styled_text_ctrl.rb +46 -0
  201. data/tests/test_tree_ctrl.rb +138 -0
  202. data/tests/test_window.rb +12 -0
  203. data/tests/testapp_noframe.rb +1 -1
  204. metadata +54 -5
  205. data/ext/wxruby3/swig/custom/swig3/rubyrun.swg +0 -456
@@ -105,7 +105,7 @@ module WXRuby3
105
105
  end
106
106
 
107
107
  def included_directors
108
- directors.select { |dir| !Config.instance.excluded_module?(dir.spec) }
108
+ directors.select { |dir| Package.full_docs? || !Config.instance.excluded_module?(dir.spec) }
109
109
  end
110
110
 
111
111
  def director_for_class(class_name)
@@ -248,7 +248,7 @@ module WXRuby3
248
248
  end
249
249
 
250
250
  # next initialize all modules with classes depending (bases AND mixins) on classes in any modules already
251
- # selected until there are no more modules left or none that are left depend on any selected ones
251
+ # selecteduntil there are no more modules left or none that are left depend on any selected ones
252
252
  while dir_inx = inc_dirs.find_index { |dir| !dir.spec.initialize_at_end && is_dir_with_fulfilled_deps?(dir, cls_set) }
253
253
  dir = inc_dirs[dir_inx]
254
254
  modreg = Spec.module_registry[dir.spec.module_name]
@@ -282,6 +282,7 @@ module WXRuby3
282
282
  Stream.transaction do
283
283
  fsrc = CodeStream.new(initializer_src)
284
284
  fsrc.puts '#include <ruby.h>'
285
+ fsrc.puts '#include <ruby/version.h>'
285
286
  fsrc.puts <<~__HEREDOC
286
287
  #ifndef WXRB_EXPORT_FLAG
287
288
  # if defined(_WIN32) || defined(__WIN32__) || defined(__CYGWIN__)
@@ -319,9 +320,11 @@ module WXRuby3
319
320
  fsrc.puts "VALUE #{module_variable} = 0;"
320
321
  fsrc.puts "WXRB_IMPORT_FLAG VALUE wxRuby_Core();" unless is_core?
321
322
  fsrc.puts
322
- fsrc.puts '#define VALUEFUNC(f) ((VALUE (*)(ANYARGS)) f)'
323
- fsrc.puts
324
323
  if is_core?
324
+ fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigrun.inc'))
325
+ fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigrubyerrors.inc'))
326
+ fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigrubyrun.inc'))
327
+ fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'swigdirector.inc'))
325
328
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'funcall.inc'))
326
329
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'enum.inc'))
327
330
  fsrc << File.read(File.join(File.dirname(__FILE__), 'include', 'init.inc'))
@@ -356,8 +359,7 @@ module WXRuby3
356
359
  # generate constant definitions for feature defines from setup.h
357
360
  fsrc.puts %Q{VALUE mWxSetup = rb_define_module_under(#{module_variable}, "Setup");}
358
361
  Config.instance.features.each do |feature, val|
359
- const_name = rb_wx_name(feature).gsub(/\A__|__\Z/, '')
360
- fsrc.puts %Q{rb_define_const(mWxSetup, "#{const_name}", Q#{val});}
362
+ fsrc.puts %Q{rb_define_const(mWxSetup, "#{feature}", Q#{val});}
361
363
  end
362
364
  else
363
365
  fsrc.puts %Q{#{module_variable} = rb_define_module_under(wxRuby_Core(), "#{name}");}
@@ -520,10 +522,12 @@ module WXRuby3
520
522
  # ----------------------------------------------------------------------------
521
523
 
522
524
 
523
- class Wx::EvtHandler
525
+ module Wx
524
526
 
525
- __HEREDOC
526
- fdoc.indent do
527
+ class EvtHandler
528
+
529
+ __HEREDOC
530
+ fdoc.indent(2) do
527
531
  fdoc.doc.puts "@!group #{name} Event handler methods"
528
532
  fdoc.puts
529
533
  evts_handled = ::Set.new
@@ -554,6 +558,8 @@ module WXRuby3
554
558
  fdoc.doc.puts '@!endgroup'
555
559
  end
556
560
  fdoc.puts
561
+ fdoc.puts ' end'
562
+ fdoc.puts
557
563
  fdoc.puts 'end'
558
564
  end
559
565
  end
@@ -631,6 +637,10 @@ module WXRuby3
631
637
  end
632
638
  private :generate_core_doc
633
639
 
640
+ def self.full_docs?
641
+ !!ENV['WXRUBY_FULLDOCS']
642
+ end
643
+
634
644
  def generate_docs
635
645
  # make sure all modules have been extracted from xml
636
646
  included_directors.each {|dir| dir.extract_interface(false, gendoc: true) }
@@ -16,6 +16,9 @@ module WXRuby3
16
16
  CONST_RE = /(\A|\W)const(\W|\Z)/
17
17
  MULTI_WORD_TYPES = %w[char short int long]
18
18
  def initialize(param)
19
+ # prevent unwanted splitting on whitespaces in template type decls
20
+ param = param.gsub(/\<\s+/, '<')
21
+ param.gsub!(/\s+\>/, '>')
19
22
  @array = false
20
23
  if ::Array === param
21
24
  @ctype, @name, arr = param
@@ -327,7 +327,12 @@ module WXRuby3
327
327
  end
328
328
 
329
329
  def ignore(*names, ignore_doc: true)
330
- names.flatten.each {|n| @ignores[n] = ignore_doc}
330
+ names.flatten.each { |n| @ignores[n] = {ignore: true, ignore_doc: ignore_doc} }
331
+ self
332
+ end
333
+
334
+ def ignore_unless(feature_set, *names)
335
+ names.flatten.each { |n| @ignores[n] = {ignore: feature_set} }
331
336
  self
332
337
  end
333
338
 
@@ -47,9 +47,8 @@ module WXRuby3
47
47
  (TYPE($input) == T_STRING && RSTRING_LEN($input) == 1) );
48
48
  __CODE
49
49
  end
50
- unless Config.instance.features_set?('__WXMSW__')
51
- spec.ignore('wxAcceleratorTable::wxAcceleratorTable(const wxString &)')
52
- end
50
+ spec.ignore_unless('WXMSW',
51
+ 'wxAcceleratorTable::wxAcceleratorTable(const wxString &)')
53
52
  spec.add_swig_code <<~__HEREDOC
54
53
  %warnfilter(509) wxAcceleratorTable::wxAcceleratorTable;
55
54
  __HEREDOC
@@ -69,7 +68,7 @@ module WXRuby3
69
68
  for (int i = 0; i < RARRAY_LEN($input); i++)
70
69
  {
71
70
  SWIG_ConvertPtr(rb_ary_entry($input,i), (void **) &wx_acc_ent,
72
- SWIGTYPE_p_wxAcceleratorEntry, 1);
71
+ SWIGTYPE_p_wxAcceleratorEntry, 0);
73
72
  if (wx_acc_ent == NULL)
74
73
  rb_raise(rb_eTypeError, "Reference to null wxAcceleratorEntry");
75
74
  arr[i] = *wx_acc_ent;
@@ -0,0 +1,47 @@
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 Accessible < Director
14
+
15
+ def setup
16
+ super
17
+ spec.make_abstract 'wxAccessible'
18
+ spec.map 'wxAccessible**' => 'Wx::Accessible' do
19
+ map_in ignore: true, temp: 'wxAccessible* tmp', code: '$1 = &tmp;'
20
+ map_argout code: <<~__HEREDOC
21
+ if (tmp$argnum)
22
+ {
23
+ $result = SWIG_Ruby_AppendOutput($result, SWIG_NewPointerObj(SWIG_as_voidptr(tmp$argnum), SWIGTYPE_p_wxAccessible, 0));
24
+ }
25
+ __HEREDOC
26
+
27
+ end
28
+ spec.map 'wxString *' => 'String' do
29
+ map_in ignore: true, temp: 'wxString tmp', code: '$1 = &tmp;'
30
+ map_argout code: '$result = SWIG_Ruby_AppendOutput($result, WXSTR_TO_RSTR(tmp$argnum));'
31
+ end
32
+ spec.map 'wxAccRole *' => 'Wx::AccRole' do
33
+ map_in ignore: true, temp: 'wxAccRole tmp', code: '$1 = &tmp;'
34
+ map_argout code: <<~__HEREDOC
35
+ $result = SWIG_Ruby_AppendOutput($result, wxRuby_GetEnumValueObject("AccRole", static_cast<int>(tmp$argnum)));
36
+ __HEREDOC
37
+ end
38
+ spec.map_apply 'int * OUTPUT' => ['int * childCount', 'int * childId', 'int * toId']
39
+ spec.map_apply 'long * OUTPUT' => 'long * state'
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ end
47
+
@@ -60,7 +60,7 @@ module WXRuby3
60
60
  void* ptr = 0;
61
61
  int res$argnum = SWIG_ConvertPtr($result, &ptr, SWIGTYPE_p_wxImage, 0 );
62
62
  if (!SWIG_IsOK(res$argnum)) {
63
- Swig::DirectorTypeMismatchException::raise(rb_eTypeError, "Expected Wx::Image result");
63
+ Swig::DirectorTypeMismatchException::raise(swig_get_self(), "$symname", rb_eTypeError, "Expected Wx::Image result");
64
64
  }
65
65
  *$1 = *reinterpret_cast<wxImage*> (ptr);
66
66
  __CODE
@@ -18,6 +18,26 @@ module WXRuby3
18
18
 
19
19
  def setup
20
20
  super
21
+ if Config.instance.wx_version >= '3.3.0'
22
+ spec.items << 'wxAnimationBundle'
23
+ spec.ignore 'wxAnimationBundle::GetAll', ignore_doc: false
24
+ spec.add_extend_code 'wxAnimationBundle', <<~__HEREDOC
25
+ VALUE get_all() const
26
+ {
27
+ const std::vector<wxAnimation>& ani_list = $self->GetAll();
28
+ VALUE rb_ani_list = rb_ary_new();
29
+ for (const wxAnimation& ani : ani_list)
30
+ {
31
+ VALUE rb_ani = SWIG_NewPointerObj(new wxAnimation(ani), SWIGTYPE_p_wxAnimation, SWIG_POINTER_OWN);
32
+ rb_ary_push(rb_ani_list, rb_ani);
33
+ }
34
+ return rb_ani_list;
35
+ }
36
+ __HEREDOC
37
+ spec.map 'const std::vector<wxAnimation>&' => 'Array<Wx::Animation>', swig: false do
38
+ map_out code: ''
39
+ end
40
+ end
21
41
  spec.do_not_generate :variables, :enums, :defines, :functions
22
42
  end
23
43
  end # class AnimationCtrl
@@ -16,6 +16,15 @@ module WXRuby3
16
16
 
17
17
  def setup
18
18
  spec.items << 'wxAppConsole' << 'wxEventFilter'
19
+ if Config.instance.wx_version >= '3.3.0'
20
+ spec.items << 'wxDarkModeSettings'
21
+ spec.ignore_unless('WXMSW', 'wxDarkModeSettings', 'wxMenuColour')
22
+ if Config.instance.features_set?('WXMSW')
23
+ spec.disown 'wxDarkModeSettings *settings'
24
+ # wxDarkModeSettings does has have virt dtor; it's just not documented
25
+ spec.suppress_warning(514, 'wxDarkModeSettings')
26
+ end
27
+ end
19
28
  spec.fold_bases('wxApp' => 'wxAppConsole', 'wxAppConsole' => 'wxEventFilter')
20
29
  spec.override_inheritance_chain('wxApp', %w[wxEvtHandler wxObject])
21
30
  spec.ignore %w{
@@ -134,321 +143,23 @@ module WXRuby3
134
143
  extern "C" void Init_wxRubyStockObjects();
135
144
  extern void wxRuby_MarkProtectedEvtHandlerProcs();
136
145
 
137
- #ifdef __WXMSW__
138
- extern "C"
139
- {
140
- WXDLLIMPEXP_BASE HINSTANCE wxGetInstance();
141
- }
142
- #endif
143
-
144
146
  static wxVector<WXRBMarkFunction> WXRuby_Mark_List;
145
147
 
146
148
  WXRUBY_EXPORT void wxRuby_AppendMarker(WXRBMarkFunction marker)
147
149
  {
148
150
  WXRuby_Mark_List.push_back(marker);
149
151
  }
150
-
151
- class wxRubyApp : public wxApp
152
- {
153
- private:
154
- static wxRubyApp* instance_;
155
-
156
- bool is_running_ = false;
157
- public:
158
- static wxRubyApp* GetInstance () { return instance_; }
159
-
160
- virtual ~wxRubyApp()
161
- {
162
- #ifdef __WXTRACE__
163
- std::wcout << "~wxRubyApp" << std::endl;
164
- #endif
165
- // unlink
166
- VALUE the_app = rb_const_get(#{spec.package.module_variable}, rb_intern("THE_APP"));
167
- if (the_app != Qnil)
168
- {
169
- DATA_PTR(the_app) = 0;
170
- }
171
- }
172
-
173
- // special event handler for destruction of windows which is done
174
- // automatically by wxWidgets. Tag the object as having been destroyed
175
- // by WxWidgets.
176
- void OnWindowDestroy(wxWindowDestroyEvent &event)
177
- {
178
- wxObject* wx_obj = event.GetEventObject();
179
- #ifdef __WXRB_DEBUG__
180
- if (wxRuby_TraceLevel()>0)
181
- std::wcout << "<= OnWindowDestroy [" << wx_obj << "]" << std::endl;
182
- #endif
183
- GC_SetWindowDeleted((void *)wx_obj);
184
- event.Skip();
185
- #ifdef __WXRB_DEBUG__
186
- if (wxRuby_TraceLevel()>0)
187
- std::wcout << "=> OnWindowDestroy [" << wx_obj << "]" << std::endl;
188
- #endif
189
- }
190
-
191
- bool IsRunning() const { return this->is_running_; }
192
-
193
- // When ruby's garbage collection runs, if the app is still active, it
194
- // cycles through all currently known SWIG objects and calls this
195
- // function on each to preserve still active Wx::Windows, and also
196
- // pending Wx::Events which have been queued from the Ruby side (the
197
- // only sort of events that will be in the tracking hash.
198
- static void markIterate(void* ptr, VALUE rb_obj)
199
- {
200
- // Check if it's a valid object (sometimes SWIG doesn't return what we're
201
- // expecting), a descendant of Wx::Window (but not a Dialog), and if it has not yet been
202
- // deleted by WxWidgets; if so, mark it.
203
- if ( TYPE(rb_obj) == T_DATA )
204
- {
205
- if ( rb_obj_is_kind_of(rb_obj, wxRuby_GetWindowClass()) )
206
- {
207
- rb_gc_mark(rb_obj);
208
- }
209
- else if (rb_obj_is_kind_of(rb_obj, wxRuby_GetDefaultEventClass()) )
210
- rb_gc_mark(rb_obj);
211
- }
212
- else if (TYPE(rb_obj) == T_ARRAY )
213
- {
214
- VALUE proc = rb_ary_entry(rb_obj, 0);
215
- if (rb_obj_is_kind_of(proc, rb_cProc) || rb_obj_is_kind_of(proc, rb_cMethod))
216
- {
217
- // keep the async call alive
218
- rb_gc_mark(rb_obj);
219
- }
220
- }
221
- }
222
-
223
- // Implements GC protection across wxRuby. Always called because
224
- // Wx::THE_APP is a constant so always checked in GC mark phase.
225
- static void mark_wxRubyApp(void *ptr)
226
- {
227
-
228
- #ifdef __WXRB_DEBUG__
229
- if (wxRuby_TraceLevel()>0)
230
- std::wcout << "=== Starting App GC mark phase" << std::endl;
231
- #endif
232
-
233
- // If the App has ended, the ruby object will have been unlinked from
234
- // the C++ one; this implies that all Windows have already been destroyed
235
- // so there is no point trying to mark them, and doing so may cause
236
- // errors.
237
- if ( !wxRubyApp::GetInstance() || !wxRubyApp::GetInstance()->IsRunning() )
238
- {
239
- #ifdef __WXRB_DEBUG__
240
- if (wxRuby_TraceLevel()>0)
241
- std::wcout << "=== App has ended, skipping mark phase" << std::endl;
242
- #endif
243
- return;
244
- }
245
-
246
- // Mark any active (tracked) log target
247
- wxLog* curLog = wxLog::GetActiveTarget();
248
- VALUE rb_cur_log = wxRuby_FindTracking(curLog);
249
- if (!NIL_P(rb_cur_log))
250
- {
251
- rb_gc_mark(rb_cur_log);
252
- }
253
-
254
- // Mark evt handler procs associated with live windows - see
255
- // classes/EvtHandler.i
256
- wxRuby_MarkProtectedEvtHandlerProcs();
257
-
258
- // run registered markers
259
- for (wxVector<WXRBMarkFunction>::iterator it = WXRuby_Mark_List.begin();
260
- it != WXRuby_Mark_List.end() ;++it)
261
- {
262
- (*it) ();
263
- }
264
-
265
- // To do the main marking, primarily of Windows, iterate over SWIG's
266
- // list of tracked objects
267
- wxRuby_IterateTracking(&wxRubyApp::markIterate);
268
-
269
- #ifdef __WXRB_DEBUG__
270
- if (wxRuby_TraceLevel()>0)
271
- std::wcout << "=== App GC mark phase completed" << std::endl;
272
- #endif
273
- }
274
-
275
- // This is the method run when main_loop is called in Ruby
276
- // wxEntry calls the C++ App::OnInit method
277
- int main_loop()
278
- {
279
- VALUE rb_app = SWIG_RubyInstanceFor(this);
280
- rb_define_const(#{spec.package.module_variable}, "THE_APP", rb_app);
281
- this->Connect(wxEVT_DESTROY,
282
- wxWindowDestroyEventHandler(wxRubyApp::OnWindowDestroy));
283
-
284
- #ifdef __WXRB_DEBUG__
285
- if (wxRuby_TraceLevel()>0)
286
- std::wcout << "Calling wxEntry, this=" << this << std::endl;
287
- #endif
288
-
289
- #ifdef __WXMSW__
290
- extern int wxEntry(HINSTANCE hInstance,
291
- HINSTANCE WXUNUSED(hPrevInstance),
292
- wxCmdLineArgType WXUNUSED(pCmdLine),
293
- int nCmdShow);
294
- wxEntry(wxGetInstance(),
295
- (HINSTANCE)0,
296
- (wxCmdLineArgType)"",
297
- (int)true);
298
- #else
299
- int argc = 1;
300
- const char* argv[2] = { "ruby", 0 };
301
- wxEntry(argc, const_cast<char**>(&argv[0]));
302
- #endif
303
-
304
- rb_const_remove(#{spec.package.module_variable}, rb_intern("THE_APP"));
305
-
306
- #ifdef __WXRB_DEBUG__
307
- if (wxRuby_TraceLevel()>0)
308
- std::wcout << "returned from wxEntry..." << std::endl;
309
- #endif
310
- rb_gc_start();
311
- #ifdef __WXRB_DEBUG__
312
- if (wxRuby_TraceLevel()>0)
313
- std::wcout << "survived gc" << std::endl;
314
- #endif
315
-
316
- VALUE exc = rb_iv_get(rb_app, "@exception");
317
- if (!NIL_P(exc))
318
- {
319
- rb_exc_raise(exc);
320
- }
321
- return 0;
322
- }
323
-
324
- // This method initializes the stock objects (Pens, Brushes, Fonts)
325
- // before yielding to ruby by calling the App's on_init method.
326
- // Note that as of wxWidget 2.8, the stock fonts in particular cannot
327
- // be initialized any earlier than this without crashing
328
- bool OnInit() override
329
- {
330
- #ifdef __WXRB_DEBUG__
331
- if (wxRuby_TraceLevel()>0)
332
- std::wcout << "OnInit..." << std::endl;
333
- #endif
334
- // set standard App name
335
- this->SetAppName(wxString("wxruby"));
336
- // Signal that we've started
337
- wxRubyApp::instance_ = this; // there should ALWAYS EVER be only 1 app instance running/created
338
- this->is_running_ = true;
339
- // Set up the GDI objects
340
- Init_wxRubyStockObjects();
341
- // Get the ruby representation of the App object, and call the
342
- // ruby on_init method to set up the initial window state
343
- VALUE the_app = rb_const_get(#{spec.package.module_variable}, rb_intern("THE_APP"));
344
- VALUE result = wxRuby_Funcall(the_app, rb_intern("on_ruby_init"), 0, 0);
345
-
346
- // If on_init return any (ruby) true value, signal to wxWidgets to
347
- // enter the main event loop by returning true, else return false
348
- // which will make wxWidgets exit.
349
- if ( result == Qfalse || result == Qnil )
350
- {
351
- wxRubyApp::instance_ = 0;
352
- this->is_running_ = false;
353
- return false;
354
- }
355
- else
356
- {
357
- return true;
358
- }
359
- }
360
-
361
- int OnExit() override
362
- {
363
- #ifdef __WXRB_DEBUG__
364
- if (wxRuby_TraceLevel()>0)
365
- std::wcout << "OnExit..." << std::endl;
366
- #endif
367
152
 
368
- // Get the ruby representation of the App object, and call the
369
- // ruby on_exit method (if any) for application level cleanup
370
- VALUE the_app = rb_const_get(#{spec.package.module_variable}, rb_intern("THE_APP"));
371
- ID on_exit_id = rb_intern("on_exit");
372
- if (rb_funcall(the_app, rb_intern("respond_to?"), 1, ID2SYM(on_exit_id)) == Qtrue)
373
- {
374
- wxRuby_Funcall(the_app, on_exit_id, 0, 0);
375
- }
376
-
377
- // perform wxRuby cleanup
378
- _wxRuby_Cleanup();
379
-
380
- // execute base wxWidgets functionality
381
- return this->wxApp::OnExit();
382
- }
383
-
384
- // actually implemented in ruby in classes/app.rb
385
- virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg) override
386
- {
387
- VALUE rb_app = SWIG_RubyInstanceFor(this);
388
- if (rb_during_gc() || NIL_P(rb_app))
389
- {
390
- std::wcout << file << "(" << line << "): ASSERT " << cond
391
- << (NIL_P(rb_app) ? " fired without THE_APP in " : " fired during GC phase in ")
392
- << func << "() with message [" << msg << "]" << std::endl;
393
- }
394
- else
395
- {
396
- VALUE obj0 = Qnil ;
397
- VALUE obj1 = Qnil ;
398
- VALUE obj2 = Qnil ;
399
- VALUE obj3 = Qnil ;
400
- VALUE obj4 = Qnil ;
401
-
402
- obj0 = rb_str_new2((const char *)wxString(file).utf8_str());
403
- obj1 = INT2NUM(line);
404
- obj2 = rb_str_new2((const char *)wxString(func).utf8_str());
405
- obj3 = rb_str_new2((const char *)wxString(cond).utf8_str());
406
- obj4 = rb_str_new2((const char *)wxString(msg).utf8_str());
407
- (void)wxRuby_Funcall(rb_app, rb_intern("on_assert_failure"), 5,obj0,obj1,obj2,obj3,obj4);
408
- }
409
- }
410
-
411
- void _wxRuby_Cleanup()
412
- {
413
- #ifdef __WXRB_DEBUG__
414
- if (wxRuby_TraceLevel()>0)
415
- std::wcout << "wxRuby_Cleanup..." << std::endl;
416
- #endif
417
- // Note in a global variable that the App has ended, so that we
418
- // can skip any GC marking later
419
- wxRubyApp::instance_ = 0;
420
- this->is_running_ = false;
421
-
422
- // if a Ruby implemented logger has been installed clean that up
423
- // before we exit, otherwise let wxWidgets handle things
424
- wxLog *oldlog = wxLog::GetActiveTarget();
425
- if (wxRuby_FindTracking(oldlog) != Qnil)
426
- {
427
- oldlog = wxLog::SetActiveTarget(new wxLogStderr);
428
- }
429
- else
430
- {
431
- oldlog = 0;
432
- }
433
- SetTopWindow(0);
434
- if ( oldlog )
435
- {
436
- SWIG_RubyUnlinkObjects(oldlog);
437
- SWIG_RubyRemoveTracking(oldlog);
438
- delete oldlog;
439
- }
440
- }
441
- };
442
- wxRubyApp* wxRubyApp::instance_ = 0;
153
+ #include "wxRubyApp.h"
443
154
 
444
155
  WXRUBY_EXPORT bool wxRuby_IsAppRunning()
445
156
  {
446
- return wxRubyApp::GetInstance() != 0 && wxRubyApp::GetInstance()->IsRunning();
157
+ return wxRubyApp::GetInstance() && wxRubyApp::GetInstance()->IsRunning();
447
158
  }
448
159
 
449
160
  WXRUBY_EXPORT void wxRuby_ExitMainLoop(VALUE exception)
450
161
  {
451
- if (wxRubyApp::GetInstance() != 0 && wxRubyApp::GetInstance()->IsRunning())
162
+ if (wxRubyApp::GetInstance() && wxRubyApp::GetInstance()->IsRunning())
452
163
  {
453
164
  if (!NIL_P(exception))
454
165
  {
@@ -470,10 +181,10 @@ module WXRuby3
470
181
  VALUE msg = rb_funcall(err, message_id(), 0);
471
182
  VALUE err_name = rb_funcall(rb_funcall(err, class_id(), 0), name_id(), 0);
472
183
  VALUE bt = rb_funcall(err, backtrace_id(), 0);
473
- bt = rb_funcall(bt, join_id(), 1, rb_str_new2("\\n"));
184
+ bt = rb_funcall(bt, join_id(), 1, rb_str_new2("\\n\\tfrom "));
474
185
  std::cerr << std::endl
475
- << ' ' << StringValuePtr(err_name) << ": " << StringValuePtr(msg) << std::endl
476
- << StringValuePtr(bt) << std::endl;
186
+ << ' ' << StringValuePtr(msg) << '(' << StringValuePtr(err_name) << ')' << std::endl
187
+ << "\\tfrom " << StringValuePtr(bt) << std::endl << std::endl;
477
188
  }
478
189
  __HEREDOC
479
190
  super
@@ -38,8 +38,8 @@ module WXRuby3
38
38
  wxAppTraits::IsUsingUniversalWidgets
39
39
  wxAppTraits::ShowAssertDialog
40
40
  wxAppTraits::SafeMessageBox
41
- wxAppTraits::GetAssertStackTrace
42
41
  ], ignore_doc: false
42
+ spec.ignore('wxAppTraits::GetAssertStackTrace', ignore_doc: 'USE_STACKWALKER')
43
43
  # redefine
44
44
  spec.extend_interface 'wxAppTraits',
45
45
  'wxString GetDesktopEnvironment() const',
@@ -48,21 +48,19 @@ module WXRuby3
48
48
  'bool IsUsingUniversalWidgets() const',
49
49
  'bool ShowAssertDialog(const wxString& msg)',
50
50
  'bool SafeMessageBox(const wxString &text, const wxString &title)'
51
- if Config.instance.features_set?('wxUSE_STACKWALKER')
51
+ if Config.instance.features_set?('USE_STACKWALKER')
52
52
  spec.extend_interface 'wxAppTraits', 'wxString GetAssertStackTrace()'
53
53
  end
54
54
  spec.map_apply 'int * OUTPUT' => ['int *major', 'int *minor', 'int *micro']
55
55
 
56
- unless Config.platform == :mingw
57
- spec.ignore 'wxStandardPaths::DontIgnoreAppSubDir',
58
- 'wxStandardPaths::IgnoreAppSubDir',
59
- 'wxStandardPaths::IgnoreAppBuildSubDirs',
60
- 'wxStandardPaths::MSWGetShellDir'
61
- end
62
- unless Config.platform == :linux
63
- spec.ignore 'wxStandardPaths::SetInstallPrefix',
64
- 'wxStandardPaths::GetInstallPrefix'
65
- end
56
+ spec.ignore_unless('WXMSW',
57
+ 'wxStandardPaths::DontIgnoreAppSubDir',
58
+ 'wxStandardPaths::IgnoreAppSubDir',
59
+ 'wxStandardPaths::IgnoreAppBuildSubDirs',
60
+ 'wxStandardPaths::MSWGetShellDir')
61
+ spec.ignore_unless('WXGTK',
62
+ 'wxStandardPaths::SetInstallPrefix',
63
+ 'wxStandardPaths::GetInstallPrefix')
66
64
  end
67
65
  end
68
66
 
@@ -53,7 +53,7 @@ module WXRuby3
53
53
  if ( TYPE(v_ret) == T_DATA )
54
54
  {
55
55
  void* ptr;
56
- SWIG_ConvertPtr(v_ret, &ptr, SWIGTYPE_p_wxSize, 1);
56
+ SWIG_ConvertPtr(v_ret, &ptr, SWIGTYPE_p_wxSize, 0);
57
57
  return *reinterpret_cast< wxSize * >(ptr);
58
58
  }
59
59
  else if ( TYPE(v_ret) == T_ARRAY )
@@ -51,9 +51,11 @@ module WXRuby3
51
51
  'wxItemContainer::Append(const wxArrayString &, void **)',
52
52
  'wxItemContainer::Insert(const wxArrayString &, unsigned int, void **)',
53
53
  'wxItemContainer::Set(const wxArrayString &, void **)'], ignore_doc: false)
54
- # add undocumented method
55
- spec.extend_interface 'wxControlWithItems',
56
- 'bool IsSorted() const'
54
+ if Config.instance.wx_version < '3.3.0'
55
+ # add undocumented method
56
+ spec.extend_interface 'wxControlWithItems',
57
+ 'bool IsSorted() const'
58
+ end
57
59
  # for doc only
58
60
  spec.map 'void** clientData' => 'Array', swig: false do
59
61
  map_in code: ''
@@ -62,13 +64,23 @@ module WXRuby3
62
64
  # Replace the old Wx definition of this method (which segfaults)
63
65
  # Only need the setter as we cache data in Ruby and the getter
64
66
  # therefor can be pure Ruby
65
- spec.add_extend_code('wxControlWithItems', <<~__HEREDOC
67
+ spec.add_extend_code 'wxControlWithItems', <<~__HEREDOC
66
68
  VALUE set_client_data(int n, VALUE item_data) {
67
69
  self->SetClientData(n, (void *)item_data);
68
70
  return item_data;
69
71
  }
72
+
73
+ VALUE each_string()
74
+ {
75
+ VALUE rc = Qnil;
76
+ for (unsigned int i=0; i<$self->GetCount() ;++i)
77
+ {
78
+ VALUE rb_s = WXSTR_TO_RSTR($self->GetString(i));
79
+ rc = rb_yield(rb_s);
80
+ }
81
+ return rc;
82
+ }
70
83
  __HEREDOC
71
- )
72
84
  end
73
85
  end
74
86
 
@@ -20,7 +20,7 @@ module WXRuby3
20
20
  # The formal signature for these is NativeFormat; this is required on
21
21
  # MSVC as otherwise an impermissible implicit cast is tried, and so
22
22
  # doesn't compile
23
- spec.ignore 'wxDataFormat::GetType'
23
+ spec.ignore 'wxDataFormat::GetType', ignore_doc: false
24
24
  spec.extend_interface 'wxDataFormat',
25
25
  'typedef unsigned short NativeFormat',
26
26
  'wxDataFormat::NativeFormat GetType() const'