wxruby3 0.9.0.pre.beta.14 → 0.9.0.pre.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (214) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/INSTALL.md +51 -22
  4. data/README.md +81 -6
  5. data/assets/hello_button-macos.png +0 -0
  6. data/assets/hello_button-msw.png +0 -0
  7. data/assets/hello_button.png +0 -0
  8. data/assets/hello_button_clicked-macos.png +0 -0
  9. data/assets/hello_button_clicked-msw.png +0 -0
  10. data/assets/hello_button_clicked.png +0 -0
  11. data/assets/hello_button_clicked_combi.png +0 -0
  12. data/assets/hello_world-macos.png +0 -0
  13. data/assets/hello_world-msw.png +0 -0
  14. data/assets/hello_world.png +0 -0
  15. data/assets/hello_world_combi.png +0 -0
  16. data/assets/repo-social-preview.png +0 -0
  17. data/ext/wxruby3/include/wxruby-runtime.h +1 -0
  18. data/ext/wxruby3/swig/memory_management.i +6 -10
  19. data/ext/wxruby3/swig/wx.i +17 -6
  20. data/lib/wx/core/art_locator.rb +2 -2
  21. data/lib/wx/core/artprovider.rb +2 -2
  22. data/lib/wx/core/bitmap.rb +6 -5
  23. data/lib/wx/core/bitmap_combobox.rb +34 -0
  24. data/lib/wx/core/brush.rb +6 -0
  25. data/lib/wx/core/controlwithitems.rb +52 -14
  26. data/lib/wx/core/cursor.rb +1 -1
  27. data/lib/wx/core/dc.rb +0 -20
  28. data/lib/wx/core/event_blocker.rb +14 -0
  29. data/lib/wx/core/evthandler.rb +48 -2
  30. data/lib/wx/core/find_replace_dialog.rb +24 -0
  31. data/lib/wx/core/font.rb +22 -14
  32. data/lib/wx/core/helpprovider.rb +2 -2
  33. data/lib/wx/core/icon.rb +1 -1
  34. data/lib/wx/core/image.rb +1 -1
  35. data/lib/wx/core/menu.rb +5 -0
  36. data/lib/wx/core/paintdc.rb +8 -0
  37. data/lib/wx/core/pen.rb +6 -0
  38. data/lib/wx/core/text_entry.rb +15 -0
  39. data/lib/wx/core/v_list_box.rb +13 -0
  40. data/lib/wx/core/window.rb +29 -2
  41. data/lib/wx/doc/app.rb +40 -0
  42. data/lib/wx/doc/brush.rb +17 -0
  43. data/lib/wx/doc/busy_info.rb +21 -0
  44. data/lib/wx/doc/client_dc.rb +28 -0
  45. data/lib/wx/doc/controlwithitems.rb +11 -0
  46. data/lib/wx/doc/dc.rb +0 -14
  47. data/lib/wx/doc/event_blocker.rb +27 -0
  48. data/lib/wx/doc/evthandler.rb +4 -0
  49. data/lib/wx/doc/extra/02_lifecycles.md +49 -0
  50. data/lib/wx/doc/extra/10_art.md +1 -1
  51. data/lib/wx/doc/extra/11_drawing_and_dc.md +62 -0
  52. data/lib/wx/doc/font.rb +27 -0
  53. data/lib/wx/doc/memory_dc.rb +75 -0
  54. data/lib/wx/doc/mirror_dc.rb +16 -0
  55. data/lib/wx/doc/pen.rb +17 -0
  56. data/lib/wx/doc/prt/printer_dc.rb +26 -0
  57. data/lib/wx/doc/radio_box.rb +20 -0
  58. data/lib/wx/doc/screen_dc.rb +10 -6
  59. data/lib/wx/doc/svg_file_dc.rb +20 -0
  60. data/lib/wx/doc/v_list_box.rb +9 -0
  61. data/lib/wx/doc/window.rb +27 -0
  62. data/lib/wx/doc/window_disabler.rb +10 -0
  63. data/lib/wx/html/keyword_defs.rb +6 -7
  64. data/lib/wx/html/require.rb +1 -0
  65. data/lib/wx/html/simple_html_listbox.rb +105 -0
  66. data/lib/wx/keyword_defs.rb +83 -75
  67. data/lib/wx/prt/keyword_defs.rb +5 -1
  68. data/lib/wx/version.rb +1 -1
  69. data/lib/wx/wxruby/cmd/test.rb +1 -1
  70. data/rakelib/install.rb +20 -7
  71. data/rakelib/lib/config/linux.rb +4 -2
  72. data/rakelib/lib/config/macosx.rb +120 -1
  73. data/rakelib/lib/config/mingw.rb +6 -1
  74. data/rakelib/lib/config/unixish.rb +26 -11
  75. data/rakelib/lib/config.rb +15 -6
  76. data/rakelib/lib/core/mapping.rb +5 -5
  77. data/rakelib/lib/core/package.rb +1 -1
  78. data/rakelib/lib/core/spec.rb +9 -5
  79. data/rakelib/lib/core/spec_helper.rb +9 -1
  80. data/rakelib/lib/director/accelerator.rb +1 -1
  81. data/rakelib/lib/director/app.rb +55 -4
  82. data/rakelib/lib/director/art_provider.rb +5 -1
  83. data/rakelib/lib/director/aui_pane_info.rb +1 -1
  84. data/rakelib/lib/director/aui_tab_ctrl.rb +1 -1
  85. data/rakelib/lib/director/aui_toolbar.rb +41 -0
  86. data/rakelib/lib/director/bitmap.rb +2 -1
  87. data/rakelib/lib/director/bitmap_combobox.rb +32 -0
  88. data/rakelib/lib/director/brush.rb +11 -1
  89. data/rakelib/lib/director/busy_info.rb +1 -1
  90. data/rakelib/lib/director/choice.rb +1 -0
  91. data/rakelib/lib/director/clipboard.rb +1 -1
  92. data/rakelib/lib/director/colour.rb +1 -0
  93. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -1
  94. data/rakelib/lib/director/combobox.rb +2 -3
  95. data/rakelib/lib/director/context_help_button.rb +23 -0
  96. data/rakelib/lib/director/ctrl_with_items.rb +3 -0
  97. data/rakelib/lib/director/cursor.rb +1 -0
  98. data/rakelib/lib/director/data_object.rb +5 -7
  99. data/rakelib/lib/director/dc.rb +5 -1
  100. data/rakelib/lib/director/defs.rb +3 -0
  101. data/rakelib/lib/director/derived_dc.rb +278 -27
  102. data/rakelib/lib/director/dialog.rb +12 -3
  103. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -1
  104. data/rakelib/lib/director/event.rb +3 -3
  105. data/rakelib/lib/director/event_blocker.rb +41 -0
  106. data/rakelib/lib/director/event_filter.rb +20 -0
  107. data/rakelib/lib/director/event_handler.rb +29 -2
  108. data/rakelib/lib/director/file_picker_ctrl.rb +1 -1
  109. data/rakelib/lib/director/find_replace_data.rb +1 -0
  110. data/rakelib/lib/director/font.rb +14 -4
  111. data/rakelib/lib/director/font_data.rb +1 -0
  112. data/rakelib/lib/director/font_picker_ctrl.rb +1 -1
  113. data/rakelib/lib/director/gdi_object.rb +1 -0
  114. data/rakelib/lib/director/graphics_context.rb +6 -6
  115. data/rakelib/lib/director/grid_table_message.rb +1 -1
  116. data/rakelib/lib/director/help_provider.rb +8 -10
  117. data/rakelib/lib/director/html_cell.rb +1 -1
  118. data/rakelib/lib/director/html_data_object.rb +5 -7
  119. data/rakelib/lib/director/html_listbox.rb +65 -1
  120. data/rakelib/lib/director/hyperlink_event.rb +22 -0
  121. data/rakelib/lib/director/icon.rb +2 -0
  122. data/rakelib/lib/director/listbox.rb +1 -0
  123. data/rakelib/lib/director/locale.rb +2 -1
  124. data/rakelib/lib/director/menu.rb +0 -3
  125. data/rakelib/lib/director/menu_bar.rb +3 -0
  126. data/rakelib/lib/director/palette.rb +1 -0
  127. data/rakelib/lib/director/pen.rb +12 -2
  128. data/rakelib/lib/director/pgproperties.rb +1 -1
  129. data/rakelib/lib/director/pgproperty.rb +1 -1
  130. data/rakelib/lib/director/pgvalidation_info.rb +1 -1
  131. data/rakelib/lib/director/platform_info.rb +1 -1
  132. data/rakelib/lib/director/popup_window.rb +18 -0
  133. data/rakelib/lib/director/print_data.rb +1 -1
  134. data/rakelib/lib/director/property_grid_interface.rb +1 -1
  135. data/rakelib/lib/director/property_grid_page_state.rb +1 -1
  136. data/rakelib/lib/director/radio_box.rb +15 -4
  137. data/rakelib/lib/director/region.rb +1 -0
  138. data/rakelib/lib/director/ribbon_art_provider.rb +1 -1
  139. data/rakelib/lib/director/richtext_buffer_data_object.rb +5 -7
  140. data/rakelib/lib/director/richtext_header_footer_data.rb +1 -1
  141. data/rakelib/lib/director/searchctrl.rb +25 -0
  142. data/rakelib/lib/director/sizer.rb +2 -2
  143. data/rakelib/lib/director/static_box.rb +1 -1
  144. data/rakelib/lib/director/styled_text_ctrl.rb +2 -0
  145. data/rakelib/lib/director/text_entry.rb +7 -2
  146. data/rakelib/lib/director/textctrl.rb +1 -1
  147. data/rakelib/lib/director/tree_ctrl.rb +6 -3
  148. data/rakelib/lib/director/uiaction_simulator.rb +20 -0
  149. data/rakelib/lib/director/variant.rb +1 -1
  150. data/rakelib/lib/director/vlistbox.rb +25 -0
  151. data/rakelib/lib/director/window.rb +37 -7
  152. data/rakelib/lib/director/with_images.rb +1 -1
  153. data/rakelib/lib/director/xml_node.rb +1 -1
  154. data/rakelib/lib/extractor/function.rb +5 -3
  155. data/rakelib/lib/generate/doc/about_dialog_info.yaml +46 -0
  156. data/rakelib/lib/generate/doc/accelerator.yaml +21 -0
  157. data/rakelib/lib/generate/doc/art_provider.yaml +35 -0
  158. data/rakelib/lib/generate/doc/bitmap.yaml +37 -0
  159. data/rakelib/lib/generate/doc/box_sizer.yaml +15 -0
  160. data/rakelib/lib/generate/doc/busy_info.yaml +74 -0
  161. data/rakelib/lib/generate/doc/client_dc.yaml +19 -0
  162. data/rakelib/lib/generate/doc/clipboard.yaml +43 -0
  163. data/rakelib/lib/generate/doc/collapsible_pane.yaml +21 -0
  164. data/rakelib/lib/generate/doc/colour_dialog.yaml +32 -0
  165. data/rakelib/lib/generate/doc/context_help_button.yaml +16 -0
  166. data/rakelib/lib/generate/doc/control.yaml +46 -0
  167. data/rakelib/lib/generate/doc/cursor.yaml +40 -0
  168. data/rakelib/lib/generate/doc/data_object.yaml +55 -0
  169. data/rakelib/lib/generate/doc/dc.yaml +14 -0
  170. data/rakelib/lib/generate/doc/dialog.yaml +36 -0
  171. data/rakelib/lib/generate/doc/dir_dialog.yaml +25 -0
  172. data/rakelib/lib/generate/doc/event_blocker.yaml +27 -0
  173. data/rakelib/lib/generate/doc/event_filter.yaml +47 -0
  174. data/rakelib/lib/generate/doc/events.yaml +152 -0
  175. data/rakelib/lib/generate/doc/evt_handler.yaml +63 -0
  176. data/rakelib/lib/generate/doc/file_dialog.yaml +68 -0
  177. data/rakelib/lib/generate/doc.rb +77 -14
  178. data/rakelib/lib/generate/interface.rb +22 -10
  179. data/rakelib/lib/specs/interfaces.rb +9 -5
  180. data/rakelib/lib/swig_runner.rb +3 -3
  181. data/rakelib/lib/typemap/common.rb +15 -3
  182. data/rakelib/lib/util/string.rb +1 -0
  183. data/rakelib/yard/yard/relative_markdown_links.rb +5 -1
  184. data/samples/aui/aui.rb +432 -363
  185. data/samples/bigdemo/wxArtProvider.rbw +5 -4
  186. data/samples/controls/controls.rb +2 -2
  187. data/samples/controls/htlbox.rb +411 -0
  188. data/samples/controls/tn_htlbox.png +0 -0
  189. data/samples/drawing/graphics_drawing.rb +1 -2
  190. data/samples/drawing/{svgtest.rb → image_prt.rb} +49 -18
  191. data/samples/drawing/tn_image_prt.png +0 -0
  192. data/samples/propgrid/propgrid.rb +26 -21
  193. data/samples/ribbon/ribbon.rb +47 -46
  194. data/samples/sampler/editor.rb +33 -25
  195. data/samples/sampler/sample.rb +2 -2
  196. data/samples/sampler/stc_editor.rb +4 -2
  197. data/tests/lib/item_container_tests.rb +82 -0
  198. data/tests/lib/text_entry_tests.rb +80 -0
  199. data/tests/lib/wxapp_runner.rb +15 -3
  200. data/tests/lib/wxframe_runner.rb +144 -0
  201. data/tests/test_app_event_filter.rb +74 -0
  202. data/tests/test_art_provider.rb +52 -0
  203. data/tests/test_clipboard.rb +2 -1
  204. data/tests/test_event_handling.rb +199 -16
  205. data/tests/test_events.rb +4 -11
  206. data/tests/test_ext_controls.rb +28 -0
  207. data/tests/test_font.rb +239 -0
  208. data/tests/test_gdi_object.rb +161 -0
  209. data/tests/test_intl.rb +16 -15
  210. data/tests/test_item_data.rb +33 -1
  211. data/tests/test_std_controls.rb +373 -0
  212. data/tests/test_window.rb +340 -0
  213. metadata +82 -4
  214. data/samples/drawing/tn_svgtest.png +0 -0
@@ -13,7 +13,7 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
- spec.add_swig_code '%feature("notabstract") wxColourPickerCtrl;'
16
+ spec.make_concrete 'wxColourPickerCtrl'
17
17
  spec.do_not_generate(:variables, :defines, :enums, :functions) # with ColourPickerEvent
18
18
  end
19
19
  end # class ColourPickerCtrl
@@ -15,15 +15,14 @@ module WXRuby3
15
15
  super
16
16
  setup_ctrl_with_items('wxComboBox')
17
17
  # mixin TextEntry
18
- spec.include_mixin 'wxComboBox', 'Wx::TextEntry'
18
+ spec.include_mixin 'wxComboBox', { 'Wx::TextEntry' => 'wxTextEntryBase' }
19
19
  spec.override_inheritance_chain('wxComboBox',
20
20
  %w[wxControlWithItems
21
21
  wxControl
22
22
  wxWindow
23
23
  wxEvtHandler
24
24
  wxObject])
25
- spec.ignore(%w[
26
- wxComboBox::IsEmpty])
25
+ spec.ignore('wxComboBox::IsEmpty') # ambiguous ControlWithItems<>TextEntry
27
26
  spec.rename_for_ruby(
28
27
  'SetTextSelectionRange' => 'wxComboBox::SetSelection(long, long)',
29
28
  'GetTextSelectionRange' => 'wxComboBox::GetSelection(long *, long *) const')
@@ -0,0 +1,23 @@
1
+ ###
2
+ # wxRuby3 wxWidgets interface director
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ require_relative './button'
7
+
8
+ module WXRuby3
9
+
10
+ class Director
11
+
12
+ class ContextHelpButton < Button
13
+
14
+ def setup
15
+ super
16
+ spec.items << 'wxContextHelp'
17
+ spec.no_proxy 'wxContextHelp'
18
+ end
19
+ end # class ContextHelpButton
20
+
21
+ end # class Director
22
+
23
+ end # module WXRuby3
@@ -47,6 +47,9 @@ module WXRuby3
47
47
  'wxItemContainer::Append(const wxArrayString &, void **)',
48
48
  'wxItemContainer::Insert(const wxArrayString &, unsigned int, void **)',
49
49
  'wxItemContainer::Set(const wxArrayString &, void **)'], ignore_doc: false)
50
+ # add undocumented method
51
+ spec.extend_interface 'wxControlWithItems',
52
+ 'bool IsSorted() const'
50
53
  # for doc only
51
54
  spec.map 'void** clientData' => 'Array', swig: false do
52
55
  map_in code: ''
@@ -10,6 +10,7 @@ module WXRuby3
10
10
  class Cursor < Director
11
11
 
12
12
  def setup
13
+ spec.gc_as_untracked 'wxCursor'
13
14
  # all but the default ctor require a running App
14
15
  spec.require_app 'wxCursor::wxCursor(const wxString &, wxBitmapType, int, int)',
15
16
  'wxCursor::wxCursor(wxStockCursor)',
@@ -44,13 +44,11 @@ module WXRuby3
44
44
  spec.ignore 'wxTextDataObject::GetAllFormats'
45
45
 
46
46
  %w[wxDataObjectComposite wxBitmapDataObject wxFileDataObject wxTextDataObject wxImageDataObject wxURLDataObject].each do |kls|
47
- spec.add_swig_code <<~__HEREDOC
48
- // SWIG gets confused and doesn't realise that various virtual methods
49
- // from wxDataObject are implemented fully in this subclass, and so,
50
- // believing it to be abstract doesn't provide an allocator for this
51
- // class. This undocumented feature overrides this.
52
- %feature("notabstract") #{kls};
53
- __HEREDOC
47
+ # SWIG gets confused and doesn't realise that various virtual methods
48
+ # from wxDataObject are implemented fully in these subclasses, and so,
49
+ # believing it to be abstract doesn't provide an allocator for this
50
+ # class. This overrides this.
51
+ spec.make_concrete kls
54
52
  end
55
53
 
56
54
  # Once a DataObject has been added, it belongs to the wxDataObjectComposite object,
@@ -13,8 +13,12 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
+ # it's not safe to track DC objects as these are often created on the stack in C++
17
+ # before being passed to Ruby methods
18
+ # as we cannot capture their deletion in anyway this would leave the tracked items
19
+ # registered and reused when future stack allocated DC's happen to have the same address
20
+ spec.gc_as_untracked
16
21
  spec.ignore [
17
- 'wxDC::StartPage',
18
22
  'wxDC::GetPartialTextExtents',
19
23
  'wxDC::DrawLines(const wxPointList *,wxCoord,wxCoord)',
20
24
  'wxDC::DrawPolygon(const wxPointList *,wxCoord,wxCoord,wxPolygonFillMode)',
@@ -25,6 +25,9 @@ module WXRuby3
25
25
  wxINT64_MAX
26
26
  wxUINT64_MAX
27
27
  wxVaCopy
28
+ wxDELETE
29
+ wxDELETEA
30
+ wxSwap
28
31
  }
29
32
  if Config.instance.wx_version >= '3.3.0'
30
33
  spec.ignore 'wxOVERRIDE'
@@ -12,24 +12,24 @@ module WXRuby3
12
12
  def setup
13
13
  super
14
14
  spec.disable_proxies
15
+ spec.gc_as_untracked spec.module_name
15
16
  if spec.module_name == 'wxScreenDC'
16
17
  spec.make_abstract 'wxScreenDC'
17
- spec.gc_never 'wxScreenDC'
18
18
  # as a ScreenDC should always be a temporary stack object
19
19
  # we do not allow creation in Ruby but rather provide a class
20
20
  # method for block execution on a temp dc
21
21
  spec.add_extend_code 'wxScreenDC', <<~__HEREDOC
22
- static VALUE paint(VALUE proc)
22
+ static VALUE draw_on()
23
23
  {
24
+ if (!wxRuby_IsAppRunning())
25
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
24
26
  VALUE rc = Qnil;
25
27
  if (rb_block_given_p ())
26
28
  {
27
29
  wxScreenDC screen_dc;
28
- wxDC* dc_ptr = &screen_dc;
30
+ wxScreenDC* dc_ptr = &screen_dc;
29
31
  VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxScreenDC, 0);
30
32
  rc = rb_yield(rb_dc);
31
- SWIG_RubyRemoveTracking((void *)dc_ptr);
32
- DATA_PTR(rb_dc) = NULL;
33
33
  }
34
34
  return rc;
35
35
  }
@@ -38,8 +38,223 @@ module WXRuby3
38
38
  spec.ignore 'wxScreenDC::StartDrawingOnTop',
39
39
  'wxScreenDC::EndDrawingOnTop',
40
40
  'wxScreenDC::wxScreenDC'
41
+ elsif spec.module_name == 'wxClientDC'
42
+ spec.make_abstract 'wxClientDC'
43
+ spec.ignore 'wxClientDC::wxClientDC'
44
+ # as a ClientDC should best always be a temporary stack object
45
+ # we do not allow creation in Ruby but rather provide a class
46
+ # method for block execution on a temp dc
47
+ spec.add_extend_code 'wxClientDC', <<~__HEREDOC
48
+ static VALUE draw_on(wxWindow* win)
49
+ {
50
+ if (!wxRuby_IsAppRunning())
51
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
52
+ VALUE rc = Qnil;
53
+ if (rb_block_given_p ())
54
+ {
55
+ wxClientDC client_dc(win);
56
+ wxClientDC* dc_ptr = &client_dc;
57
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxClientDC, 0);
58
+ rc = rb_yield(rb_dc);
59
+ }
60
+ return rc;
61
+ }
62
+ __HEREDOC
63
+ elsif spec.module_name == 'wxPaintDC'
64
+ spec.make_abstract 'wxPaintDC'
65
+ spec.ignore 'wxPaintDC::wxPaintDC'
66
+ elsif spec.module_name == 'wxMemoryDC'
67
+ spec.items << 'wxBufferedDC' << 'wxBufferedPaintDC' << 'wxAutoBufferedPaintDC'
68
+ spec.make_abstract 'wxMemoryDC'
69
+ spec.make_abstract 'wxBufferedDC'
70
+ spec.make_abstract 'wxBufferedPaintDC'
71
+ spec.make_abstract 'wxAutoBufferedPaintDC'
72
+ spec.ignore 'wxMemoryDC::wxMemoryDC',
73
+ 'wxBufferedDC::wxBufferedDC',
74
+ 'wxBufferedPaintDC::wxBufferedPaintDC',
75
+ 'wxAutoBufferedPaintDC::wxAutoBufferedPaintDC'
76
+ # like all DC's these should best always be a temporary stack objects
77
+ # we do not allow creation in Ruby but rather provide a class
78
+ # method for block execution on a temp dc
79
+ spec.add_extend_code 'wxMemoryDC', <<~__HEREDOC
80
+ static VALUE draw_on()
81
+ {
82
+ if (!wxRuby_IsAppRunning())
83
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
84
+ VALUE rc = Qnil;
85
+ if (rb_block_given_p ())
86
+ {
87
+ wxMemoryDC mem_dc;
88
+ wxMemoryDC* dc_ptr = &mem_dc;
89
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxMemoryDC, 0);
90
+ rc = rb_yield(rb_dc);
91
+ }
92
+ return rc;
93
+ }
94
+ static VALUE draw_on(wxDC* tgt)
95
+ {
96
+ if (!wxRuby_IsAppRunning())
97
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
98
+ VALUE rc = Qnil;
99
+ if (rb_block_given_p ())
100
+ {
101
+ wxMemoryDC mem_dc(tgt);
102
+ wxMemoryDC* dc_ptr = &mem_dc;
103
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxMemoryDC, 0);
104
+ rc = rb_yield(rb_dc);
105
+ }
106
+ return rc;
107
+ }
108
+ static VALUE draw_on(wxBitmap& tgt)
109
+ {
110
+ if (!wxRuby_IsAppRunning())
111
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
112
+ VALUE rc = Qnil;
113
+ if (rb_block_given_p ())
114
+ {
115
+ wxMemoryDC mem_dc(tgt);
116
+ wxMemoryDC* dc_ptr = &mem_dc;
117
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxMemoryDC, 0);
118
+ rc = rb_yield(rb_dc);
119
+ }
120
+ return rc;
121
+ }
122
+ __HEREDOC
123
+ spec.add_extend_code 'wxBufferedDC', <<~__HEREDOC
124
+ static VALUE draw_on()
125
+ {
126
+ if (!wxRuby_IsAppRunning())
127
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
128
+ VALUE rc = Qnil;
129
+ if (rb_block_given_p ())
130
+ {
131
+ wxBufferedDC dc;
132
+ wxBufferedDC* dc_ptr = &dc;
133
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxBufferedDC, 0);
134
+ rc = rb_yield(rb_dc);
135
+ }
136
+ return rc;
137
+ }
138
+ static VALUE draw_on(wxDC* tgt, const wxSize &area, int style=wxBUFFER_CLIENT_AREA)
139
+ {
140
+ if (!wxRuby_IsAppRunning())
141
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
142
+ VALUE rc = Qnil;
143
+ if (rb_block_given_p ())
144
+ {
145
+ wxBufferedDC dc(tgt, area, style);
146
+ wxBufferedDC* dc_ptr = &dc;
147
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxBufferedDC, 0);
148
+ rc = rb_yield(rb_dc);
149
+ }
150
+ return rc;
151
+ }
152
+ static VALUE draw_on(wxDC* tgt, wxBitmap &buffer=wxNullBitmap, int style=wxBUFFER_CLIENT_AREA)
153
+ {
154
+ if (!wxRuby_IsAppRunning())
155
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
156
+ VALUE rc = Qnil;
157
+ if (rb_block_given_p ())
158
+ {
159
+ wxBufferedDC dc(tgt, buffer, style);
160
+ wxBufferedDC* dc_ptr = &dc;
161
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxBufferedDC, 0);
162
+ rc = rb_yield(rb_dc);
163
+ }
164
+ return rc;
165
+ }
166
+ __HEREDOC
167
+ spec.add_extend_code 'wxBufferedPaintDC', <<~__HEREDOC
168
+ static VALUE draw_on(wxWindow* tgt, int style=wxBUFFER_CLIENT_AREA)
169
+ {
170
+ if (!wxRuby_IsAppRunning())
171
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
172
+ VALUE rc = Qnil;
173
+ if (rb_block_given_p ())
174
+ {
175
+ wxBufferedPaintDC dc(tgt, style);
176
+ wxBufferedPaintDC* dc_ptr = &dc;
177
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxBufferedPaintDC, 0);
178
+ rc = rb_yield(rb_dc);
179
+ }
180
+ return rc;
181
+ }
182
+ static VALUE draw_on(wxWindow* tgt, wxBitmap &buffer=wxNullBitmap, int style=wxBUFFER_CLIENT_AREA)
183
+ {
184
+ if (!wxRuby_IsAppRunning())
185
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
186
+ VALUE rc = Qnil;
187
+ if (rb_block_given_p ())
188
+ {
189
+ wxBufferedPaintDC dc(tgt, buffer, style);
190
+ wxBufferedPaintDC* dc_ptr = &dc;
191
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxBufferedPaintDC, 0);
192
+ rc = rb_yield(rb_dc);
193
+ }
194
+ return rc;
195
+ }
196
+ __HEREDOC
197
+ spec.add_extend_code 'wxAutoBufferedPaintDC', <<~__HEREDOC
198
+ static VALUE draw_on(wxWindow* tgt)
199
+ {
200
+ if (!wxRuby_IsAppRunning())
201
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
202
+ VALUE rc = Qnil;
203
+ if (rb_block_given_p ())
204
+ {
205
+ wxAutoBufferedPaintDC dc(tgt);
206
+ wxAutoBufferedPaintDC* dc_ptr = &dc;
207
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxAutoBufferedPaintDC, 0);
208
+ rc = rb_yield(rb_dc);
209
+ }
210
+ return rc;
211
+ }
212
+ __HEREDOC
213
+ elsif spec.module_name == 'wxMirrorDC'
214
+ spec.make_abstract 'wxMirrorDC'
215
+ spec.ignore 'wxMirrorDC::wxMirrorDC'
216
+ # as a MirrorDC should best always be a temporary stack object
217
+ # we do not allow creation in Ruby but rather provide a class
218
+ # method for block execution on a temp dc
219
+ spec.add_extend_code 'wxMirrorDC', <<~__HEREDOC
220
+ static VALUE draw_on(wxDC* dc, bool mirror)
221
+ {
222
+ if (!wxRuby_IsAppRunning())
223
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
224
+ VALUE rc = Qnil;
225
+ if (rb_block_given_p ())
226
+ {
227
+ wxMirrorDC dc(dc, mirror);
228
+ wxMirrorDC* dc_ptr = &dc;
229
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxMirrorDC, 0);
230
+ rc = rb_yield(rb_dc);
231
+ }
232
+ return rc;
233
+ }
234
+ __HEREDOC
41
235
  elsif spec.module_name == 'wxSVGFileDC'
42
236
  spec.items.concat %w[wxSVGBitmapHandler wxSVGBitmapFileHandler wxSVGBitmapEmbedHandler]
237
+ spec.make_abstract 'wxSVGFileDC'
238
+ spec.ignore 'wxSVGFileDC::wxSVGFileDC'
239
+ # like all DC this should best always be a temporary stack object
240
+ # we do not allow creation in Ruby but rather provide a class
241
+ # method for block execution on a temp dc
242
+ spec.add_extend_code 'wxSVGFileDC', <<~__HEREDOC
243
+ static VALUE draw_on(const wxString &filename, int width=320, int height=240, double dpi=72, const wxString &title=wxString())
244
+ {
245
+ if (!wxRuby_IsAppRunning())
246
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
247
+ VALUE rc = Qnil;
248
+ if (rb_block_given_p ())
249
+ {
250
+ wxSVGFileDC dc(filename, width, height, dpi, title);
251
+ wxSVGFileDC* dc_ptr = &dc;
252
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxSVGFileDC, 0);
253
+ rc = rb_yield(rb_dc);
254
+ }
255
+ return rc;
256
+ }
257
+ __HEREDOC
43
258
  spec.disown 'wxSVGBitmapHandler *handler'
44
259
  # all inherited from wxDC; only documented since they are not implemented for this DC class
45
260
  spec.ignore 'wxSVGFileDC::DestroyClippingRegion',
@@ -56,13 +271,15 @@ module WXRuby3
56
271
  'wxSVGFileDC::EndPage'
57
272
  elsif spec.module_name == 'wxGCDC'
58
273
  spec.make_abstract 'wxGCDC'
59
- spec.gc_never 'wxGCDC'
60
- # as a GCDC should always be a temporary stack object
274
+ spec.ignore 'wxGCDC::wxGCDC'
275
+ # like all DC this should best always be a temporary stack object
61
276
  # we do not allow creation in Ruby but rather provide class
62
277
  # methods for block execution on a temp dc
63
278
  spec.add_extend_code 'wxGCDC', <<~__HEREDOC
64
279
  static VALUE draw_on(const wxWindowDC& dc)
65
280
  {
281
+ if (!wxRuby_IsAppRunning())
282
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
66
283
  VALUE rc = Qnil;
67
284
  if (rb_block_given_p ())
68
285
  {
@@ -70,19 +287,17 @@ module WXRuby3
70
287
  // being GC-ed unless we block GC for the duration of the block
71
288
  // execution. Unclear why. We have similar code for other objects
72
289
  // where this issue does not come up.
73
- VALUE gc_on = rb_gc_disable();
74
290
  wxGCDC gc_dc(dc);
75
291
  wxGCDC* dc_ptr = &gc_dc;
76
292
  VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
77
293
  rc = rb_yield(rb_dc);
78
- SWIG_RubyRemoveTracking((void *)dc_ptr);
79
- DATA_PTR(rb_dc) = NULL;
80
- if (gc_on == Qtrue) rb_gc_enable();
81
294
  }
82
295
  return rc;
83
296
  }
84
297
  static VALUE draw_on(const wxMemoryDC& dc)
85
298
  {
299
+ if (!wxRuby_IsAppRunning())
300
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
86
301
  VALUE rc = Qnil;
87
302
  if (rb_block_given_p ())
88
303
  {
@@ -90,19 +305,17 @@ module WXRuby3
90
305
  // being GC-ed unless we block GC for the duration of the block
91
306
  // execution. Unclear why. We have similar code for other objects
92
307
  // where this issue does not come up.
93
- VALUE gc_on = rb_gc_disable();
94
308
  wxGCDC gc_dc(dc);
95
309
  wxGCDC* dc_ptr = &gc_dc;
96
310
  VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
97
311
  rc = rb_yield(rb_dc);
98
- SWIG_RubyRemoveTracking((void *)dc_ptr);
99
- DATA_PTR(rb_dc) = NULL;
100
- if (gc_on == Qtrue) rb_gc_enable();
101
312
  }
102
313
  return rc;
103
314
  }
104
315
  static VALUE draw_on(const wxPrinterDC& dc)
105
316
  {
317
+ if (!wxRuby_IsAppRunning())
318
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
106
319
  VALUE rc = Qnil;
107
320
  if (rb_block_given_p ())
108
321
  {
@@ -110,19 +323,17 @@ module WXRuby3
110
323
  // being GC-ed unless we block GC for the duration of the block
111
324
  // execution. Unclear why. We have similar code for other objects
112
325
  // where this issue does not come up.
113
- VALUE gc_on = rb_gc_disable();
114
326
  wxGCDC gc_dc(dc);
115
327
  wxGCDC* dc_ptr = &gc_dc;
116
328
  VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
117
329
  rc = rb_yield(rb_dc);
118
- SWIG_RubyRemoveTracking((void *)dc_ptr);
119
- DATA_PTR(rb_dc) = NULL;
120
- if (gc_on == Qtrue) rb_gc_enable();
121
330
  }
122
331
  return rc;
123
332
  }
124
333
  static VALUE draw_on(wxGraphicsContext* gc)
125
334
  {
335
+ if (!wxRuby_IsAppRunning())
336
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
126
337
  VALUE rc = Qnil;
127
338
  if (rb_block_given_p ())
128
339
  {
@@ -130,14 +341,10 @@ module WXRuby3
130
341
  // being GC-ed unless we block GC for the duration of the block
131
342
  // execution. Unclear why. We have similar code for other objects
132
343
  // where this issue does not come up.
133
- VALUE gc_on = rb_gc_disable();
134
344
  wxGCDC gc_dc(gc);
135
345
  wxGCDC* dc_ptr = &gc_dc;
136
346
  VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
137
347
  rc = rb_yield(rb_dc);
138
- SWIG_RubyRemoveTracking((void *)dc_ptr);
139
- DATA_PTR(rb_dc) = NULL;
140
- if (gc_on == Qtrue) rb_gc_enable();
141
348
  }
142
349
  return rc;
143
350
  }
@@ -148,7 +355,6 @@ module WXRuby3
148
355
  spec.override_inheritance_chain('wxScaledDC', %w[wxDC wxObject])
149
356
  # as there are no dependencies parsed from XML make sure we're initialized after Wx::DC
150
357
  spec.initialize_at_end = true
151
- spec.gc_never 'wxScaledDC'
152
358
  spec.no_proxy 'wxScaledDC'
153
359
  spec.include 'wxruby-ScaledDC.h'
154
360
  # wxScaledDc should ever only be used in a restricted scope
@@ -160,6 +366,8 @@ module WXRuby3
160
366
  %extend wxScaledDC {
161
367
  static VALUE draw_on(wxDC& target, double scale)
162
368
  {
369
+ if (!wxRuby_IsAppRunning())
370
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
163
371
  VALUE rc = Qnil;
164
372
  if (rb_block_given_p())
165
373
  {
@@ -167,8 +375,6 @@ module WXRuby3
167
375
  wxScaledDC* p_scaled_dc = &scaled_dc;
168
376
  VALUE rb_scaled_dc = SWIG_NewPointerObj(SWIG_as_voidptr(p_scaled_dc), SWIGTYPE_p_wxScaledDC, 0);
169
377
  rc = rb_yield(rb_scaled_dc);
170
- SWIG_RubyRemoveTracking((void *)p_scaled_dc);
171
- DATA_PTR(rb_scaled_dc) = NULL;
172
378
  }
173
379
  return rc;
174
380
  }
@@ -180,10 +386,55 @@ module WXRuby3
180
386
  class wxScaledDC : public wxDC
181
387
  {
182
388
  public:
183
- wxScaledDC(wxDC& target, double scale);
184
389
  virtual ~wxScaledDC() = 0;
390
+ protected:
391
+ wxScaledDC(wxDC& target, double scale);
185
392
  };
186
393
  __HEREDOC
394
+ elsif spec.module_name == 'wxPrinterDC'
395
+ spec.make_abstract 'wxPrinterDC'
396
+ spec.ignore 'wxPrinterDC::wxPrinterDC'
397
+ # as a PrinterDC should best always be a temporary stack object
398
+ # we do not allow creation in Ruby but rather provide a class
399
+ # method for block execution on a temp dc
400
+ spec.add_extend_code 'wxPrinterDC', <<~__HEREDOC
401
+ static VALUE draw_on(const wxPrintData &printData)
402
+ {
403
+ if (!wxRuby_IsAppRunning())
404
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
405
+ VALUE rc = Qnil;
406
+ if (rb_block_given_p ())
407
+ {
408
+ wxPrinterDC dc(printData);
409
+ wxPrinterDC* dc_ptr = &dc;
410
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxPrinterDC, 0);
411
+ rc = rb_yield(rb_dc);
412
+ }
413
+ return rc;
414
+ }
415
+ __HEREDOC
416
+ elsif spec.module_name == 'wxPostScriptDC'
417
+ spec.make_abstract 'wxPostScriptDC'
418
+ spec.ignore 'wxPostScriptDC::wxPostScriptDC'
419
+ # as a PostScriptDC should best always be a temporary stack object
420
+ # we do not allow creation in Ruby but rather provide a class
421
+ # method for block execution on a temp dc
422
+ spec.add_extend_code 'wxPostScriptDC', <<~__HEREDOC
423
+ static VALUE draw_on(const wxPrintData &printData)
424
+ {
425
+ if (!wxRuby_IsAppRunning())
426
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
427
+ VALUE rc = Qnil;
428
+ if (rb_block_given_p ())
429
+ {
430
+ wxPostScriptDC dc(printData);
431
+ wxPostScriptDC* dc_ptr = &dc;
432
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxPostScriptDC, 0);
433
+ rc = rb_yield(rb_dc);
434
+ }
435
+ return rc;
436
+ }
437
+ __HEREDOC
187
438
  else
188
439
  # ctors of all other derived DC require a running App
189
440
  spec.require_app spec.module_name
@@ -30,8 +30,14 @@ module WXRuby3
30
30
  when 'wxMessageDialog'
31
31
  when 'wxFontDialog'
32
32
  # ignore the non-const version
33
- spec.ignore 'wxFontDialog::GetFontData'
34
- spec.regard 'wxFontDialog::GetFontData() const'
33
+ if Config.platform == :macosx && Config.instance.wx_version < '3.3'
34
+ # MacOSX implementation is incorrect so we need to use
35
+ # the non-const definition here
36
+ spec.ignore 'wxFontDialog::GetFontData() const'
37
+ else
38
+ spec.ignore 'wxFontDialog::GetFontData'
39
+ spec.regard 'wxFontDialog::GetFontData() const'
40
+ end
35
41
  when 'wxFileDialog'
36
42
  # override the wxArrayString& typemap for GetFilenames and GetPaths
37
43
  spec.map 'wxArrayString&' => 'Array<String>' do
@@ -64,9 +70,12 @@ module WXRuby3
64
70
  __HEREDOC
65
71
  when 'wxFindReplaceDialog'
66
72
  spec.ignore 'wxFindReplaceDialog::wxFindReplaceDialog()'
67
- spec.map_apply 'SWIGTYPE *DISOWN' => 'wxFindReplaceData* data'
73
+ # add undocumented method
74
+ spec.extend_interface 'wxFindReplaceDialog', 'void SetData(wxFindReplaceData *data)'
68
75
  spec.do_not_generate(:variables, :enums)
69
76
  when 'wxColourDialog'
77
+ spec.items << 'wxColourData'
78
+ spec.gc_as_untracked 'wxColourData'
70
79
  # make interface GC-safe
71
80
  spec.ignore 'wxColourDialog::GetColourData'
72
81
  spec.add_extend_code 'wxColourDialog', <<~__HEREDOC
@@ -13,7 +13,7 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
- spec.add_swig_code '%feature("notabstract") wxDirPickerCtrl;'
16
+ spec.make_concrete 'wxDirPickerCtrl'
17
17
  spec.do_not_generate(:variables, :defines, :enums, :functions) # with FileDirPickerEvent
18
18
  end
19
19
  end # class DirPickerCtrl
@@ -29,7 +29,7 @@ module WXRuby3
29
29
  spec.no_proxy 'wxEvent::Clone'
30
30
  spec.regard 'wxEvent::Clone', regard_doc: false # need updated doc
31
31
  # need this to force alloc func
32
- spec.add_swig_code '%feature("notabstract") wxEvent;'
32
+ spec.make_concrete 'wxEvent'
33
33
  # type mapping for result #clone
34
34
  spec.map 'wxEvent*' => 'Wx::Event' do
35
35
  map_out code: <<~__CODE
@@ -143,7 +143,7 @@ module WXRuby3
143
143
  wxCommandEvent::GetExtraLong
144
144
  }
145
145
  # need this to force alloc func
146
- spec.add_swig_code '%feature("notabstract") wxCommandEvent;'
146
+ spec.make_concrete 'wxCommandEvent'
147
147
  spec.add_header_code <<~__HEREDOC
148
148
  // Cf wxEvent - has to be written as a C+++ subclass to ensure correct
149
149
  // GC/thread protection of Ruby instance variables when user-written
@@ -222,7 +222,7 @@ module WXRuby3
222
222
  spec.make_abstract(citem)
223
223
  else
224
224
  # need this to force alloc func
225
- spec.add_swig_code "%feature(\"notabstract\") #{citem};"
225
+ spec.make_concrete(citem)
226
226
  end
227
227
  end
228
228
  end
@@ -0,0 +1,41 @@
1
+ ###
2
+ # wxRuby3 wxWidgets interface director
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ module WXRuby3
7
+
8
+ class Director
9
+
10
+ class EventBlocker < Director
11
+
12
+ def setup
13
+ super
14
+ spec.gc_as_untracked # no tracking
15
+ spec.make_abstract('wxEventBlocker')
16
+ spec.ignore 'wxEventBlocker::wxEventBlocker'
17
+ spec.no_proxy 'wxEventBlocker'
18
+ # needs construction on stack so make abstract and add factory class method for block execution
19
+ spec.add_extend_code 'wxEventBlocker', <<~__HEREDOC
20
+ static VALUE blocked_for(wxWindow* win, wxEventType evt_type = wxEVT_ANY)
21
+ {
22
+ if (!wxRuby_IsAppRunning())
23
+ rb_raise(rb_eRuntimeError, "A running Wx::App is required.");
24
+ VALUE rc = Qnil;
25
+ if (rb_block_given_p ())
26
+ {
27
+ wxEventBlocker blkr(win, evt_type);
28
+ wxEventBlocker *blk_p = &blkr;
29
+ VALUE rb_blkr = SWIG_NewPointerObj(SWIG_as_voidptr(blk_p), SWIGTYPE_p_wxEventBlocker, 0);
30
+ rc = rb_yield(rb_blkr);
31
+ }
32
+ return rc;
33
+ }
34
+ __HEREDOC
35
+ spec.do_not_generate :variables, :defines, :enums, :functions
36
+ end
37
+ end # class EventBlocker
38
+
39
+ end # class Director
40
+
41
+ end # module WXRuby3