wxruby3 0.9.0.pre.beta.11 → 0.9.0.pre.beta.13

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 (111) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +85 -0
  3. data/README.md +2 -0
  4. data/assets/logo.png +0 -0
  5. data/assets/logo.svg +170 -0
  6. data/assets/logo.xcf +0 -0
  7. data/ext/wxruby3/swig/wx.i +1 -1
  8. data/lib/wx/core/array_ext.rb +26 -0
  9. data/lib/wx/core/art_locator.rb +92 -0
  10. data/lib/wx/core/artprovider.rb +1 -1
  11. data/lib/wx/core/bitmap.rb +90 -53
  12. data/lib/wx/core/cursor.rb +12 -0
  13. data/lib/wx/core/dataformat.rb +3 -1
  14. data/lib/wx/core/dc.rb +76 -52
  15. data/lib/wx/core/enum.rb +4 -0
  16. data/lib/wx/core/event.rb +38 -5
  17. data/lib/wx/core/evthandler.rb +64 -23
  18. data/lib/wx/core/icon.rb +50 -35
  19. data/lib/wx/core/id_helper.rb +32 -0
  20. data/lib/wx/core/image.rb +63 -53
  21. data/lib/wx/core/point.rb +14 -0
  22. data/lib/wx/core/real_point.rb +15 -1
  23. data/lib/wx/core/rect.rb +42 -7
  24. data/lib/wx/core/region_iterator.rb +37 -0
  25. data/lib/wx/core/size.rb +20 -0
  26. data/lib/wx/core/window.rb +8 -31
  27. data/lib/wx/doc/array_ext.rb +27 -0
  28. data/lib/wx/doc/art_locator.rb +57 -0
  29. data/lib/wx/doc/bitmap.rb +27 -0
  30. data/lib/wx/doc/clipboard.rb +12 -0
  31. data/lib/wx/doc/const.rb +77 -0
  32. data/lib/wx/doc/cursor.rb +16 -0
  33. data/lib/wx/doc/data_object.rb +1 -2
  34. data/lib/wx/doc/dc.rb +63 -46
  35. data/lib/wx/doc/event.rb +24 -0
  36. data/lib/wx/doc/events.rb +14 -0
  37. data/lib/wx/doc/evthandler.rb +24 -3
  38. data/lib/wx/doc/extra/00_starting.md +1 -1
  39. data/lib/wx/doc/extra/06_geometry.md +10 -4
  40. data/lib/wx/doc/extra/10_art.md +105 -0
  41. data/lib/wx/doc/gc_dc.rb +21 -0
  42. data/lib/wx/doc/gdi_common.rb +122 -1
  43. data/lib/wx/doc/graphics_context.rb +42 -0
  44. data/lib/wx/doc/icon.rb +18 -0
  45. data/lib/wx/doc/id_helper.rb +25 -0
  46. data/lib/wx/doc/image.rb +33 -0
  47. data/lib/wx/doc/region_iterator.rb +31 -0
  48. data/lib/wx/doc/scaled_dc.rb +1 -0
  49. data/lib/wx/doc/window.rb +18 -0
  50. data/lib/wx/version.rb +1 -1
  51. data/lib/wx/wxruby/cmd/sampler.rb +3 -21
  52. data/rakelib/lib/config.rb +4 -4
  53. data/rakelib/lib/core/package.rb +3 -3
  54. data/rakelib/lib/director/art_provider.rb +2 -2
  55. data/rakelib/lib/director/busy_info.rb +9 -7
  56. data/rakelib/lib/director/clipboard.rb +1 -1
  57. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -0
  58. data/rakelib/lib/director/data_object.rb +72 -4
  59. data/rakelib/lib/director/derived_dc.rb +100 -6
  60. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -0
  61. data/rakelib/lib/director/event.rb +73 -8
  62. data/rakelib/lib/director/events.rb +19 -1
  63. data/rakelib/lib/director/file_picker_ctrl.rb +1 -0
  64. data/rakelib/lib/director/font_picker_ctrl.rb +1 -0
  65. data/rakelib/lib/director/gdicommon.rb +1 -3
  66. data/rakelib/lib/director/graphics_context.rb +89 -0
  67. data/rakelib/lib/director/help_controller.rb +2 -2
  68. data/rakelib/lib/director/html_data_object.rb +37 -0
  69. data/rakelib/lib/director/image.rb +55 -0
  70. data/rakelib/lib/director/region_iterator.rb +48 -0
  71. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  72. data/rakelib/lib/director/richtext_buffer_data_object.rb +45 -0
  73. data/rakelib/lib/director/scroll_bar.rb +39 -0
  74. data/rakelib/lib/director/slider.rb +39 -0
  75. data/rakelib/lib/director/window.rb +36 -5
  76. data/rakelib/lib/director/window_disabler.rb +0 -7
  77. data/rakelib/lib/extractor/class.rb +1 -1
  78. data/rakelib/lib/extractor/function.rb +1 -1
  79. data/rakelib/lib/generate/doc.rb +26 -6
  80. data/rakelib/lib/specs/interfaces.rb +6 -1
  81. data/rakelib/lib/typemap/common.rb +1 -1
  82. data/rakelib/lib/util/string.rb +29 -8
  83. data/samples/art/wxruby-128x128.png +0 -0
  84. data/samples/art/wxruby-256x256.png +0 -0
  85. data/samples/art/wxruby-64x64.png +0 -0
  86. data/samples/art/wxruby.ico +0 -0
  87. data/samples/art/wxruby.png +0 -0
  88. data/samples/drawing/graphics_drawing.rb +1 -2
  89. data/samples/propgrid/propgrid.rb +65 -65
  90. data/samples/sample.xpm +246 -470
  91. data/samples/treectrl/treectrl.rb +1 -1
  92. data/tests/art/my_art/sample.xpm +251 -0
  93. data/tests/art/sample3.xpm +251 -0
  94. data/tests/art/test_art/bitmap/sample.xpm +251 -0
  95. data/tests/art/test_art/bitmap/wxruby.bmp +0 -0
  96. data/tests/art/test_art/bitmap/wxruby.png +0 -0
  97. data/tests/art/test_art/bitmap/wxruby.xpm +251 -0
  98. data/tests/art/test_art/cursor/wxruby.bmp +0 -0
  99. data/tests/art/test_art/icon/sample.xpm +251 -0
  100. data/tests/art/test_art/icon/wxruby.ico +0 -0
  101. data/tests/art/test_art/icon/wxruby.png +0 -0
  102. data/tests/art/test_art/image/sample.xpm +251 -0
  103. data/tests/art/test_art/image/wxruby.jpg +0 -0
  104. data/tests/art/test_art/image/wxruby.png +0 -0
  105. data/tests/art/test_art/sample2.xpm +251 -0
  106. data/tests/test_art.rb +91 -0
  107. data/tests/test_clipboard.rb +35 -0
  108. data/tests/test_dc.rb +70 -0
  109. data/tests/test_events.rb +12 -0
  110. data/tests/test_geometry.rb +13 -0
  111. metadata +51 -5
@@ -66,10 +66,10 @@ module WXRuby3
66
66
  typedef std::map<wxDataObjectComposite*, data_object_list_t> composite_data_object_map_t;
67
67
  static composite_data_object_map_t CompositeDataObject_Map;
68
68
 
69
- static void wxRuby_markCompositeDataObjects()
69
+ static void GC_mark_wxCompositeDataObject(void* ptr)
70
70
  {
71
- composite_data_object_map_t::iterator it;
72
- for( it = CompositeDataObject_Map.begin(); it != CompositeDataObject_Map.end(); ++it )
71
+ composite_data_object_map_t::iterator it = CompositeDataObject_Map.find(static_cast<wxDataObjectComposite*> (ptr));
72
+ if (it != CompositeDataObject_Map.end())
73
73
  {
74
74
  data_object_list_t &do_list = it->second;
75
75
  for (VALUE data_obj : do_list)
@@ -96,12 +96,80 @@ module WXRuby3
96
96
  CompositeDataObject_Map.erase(this);
97
97
  }
98
98
  };
99
+
100
+ #if wxUSE_RICHTEXT
101
+ #include <wx/richtext/richtextbuffer.h>
102
+ #endif
103
+
104
+ // Add custom object wrapper for DataObjectComposite#get_object result
105
+ static VALUE wxRuby_WrapDataObjectSimple(wxDataObjectSimple* d_obj)
106
+ {
107
+ if (!d_obj)
108
+ return Qnil;
109
+
110
+ // check if we have this object tracked
111
+ VALUE r_obj = SWIG_RubyInstanceFor(d_obj);
112
+ if (r_obj != Qnil)
113
+ {
114
+ swig_class* sklass = (swig_class *) SWIGTYPE_p_wxDataObjectSimple->clientdata;
115
+ if (rb_obj_is_kind_of(r_obj, sklass->klass))
116
+ return r_obj;
117
+ }
118
+
119
+ // Otherwise check the returned type and create a new object wrapper
120
+ void* do_ptr;
121
+ if ((do_ptr = dynamic_cast<wxBitmapDataObject*> (d_obj)))
122
+ {
123
+ return SWIG_NewPointerObj(do_ptr, SWIGTYPE_p_wxBitmapDataObject, 0);
124
+ }
125
+ if ((do_ptr = dynamic_cast<wxImageDataObject*> (d_obj)))
126
+ {
127
+ return SWIG_NewPointerObj(do_ptr, SWIGTYPE_p_wxImageDataObject, 0);
128
+ }
129
+ if ((do_ptr = dynamic_cast<wxCustomDataObject*> (d_obj)))
130
+ {
131
+ return SWIG_NewPointerObj(do_ptr, SWIGTYPE_p_wxCustomDataObject, 0);
132
+ }
133
+ if ((do_ptr = dynamic_cast<wxFileDataObject*> (d_obj)))
134
+ {
135
+ return SWIG_NewPointerObj(do_ptr, SWIGTYPE_p_wxFileDataObject, 0);
136
+ }
137
+ if ((do_ptr = dynamic_cast<wxTextDataObject*> (d_obj)))
138
+ {
139
+ return SWIG_NewPointerObj(do_ptr, SWIGTYPE_p_wxTextDataObject, 0);
140
+ }
141
+ #if wxUSE_HTML && (wxVERSION_NUMBER >= 3300)
142
+ if ((do_ptr = dynamic_cast<wxHTMLDataObject*> (d_obj)))
143
+ {
144
+ VALUE r_class = rb_eval_string("Wx::HTML::HTMLDataObject");
145
+ swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(r_class);
146
+ return SWIG_NewPointerObj(do_ptr, swig_type, 0);
147
+ }
148
+ #endif
149
+ /** Leave these for now. RichText has special needs
150
+ #if wxUSE_RICHTEXT
151
+ if ((do_ptr = dynamic_cast<wxRichTextBufferDataObject*> (d_obj)))
152
+ {
153
+ VALUE r_class = rb_eval_string("Wx::RTC::RichTextBufferDataObject");
154
+ swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(r_class);
155
+ return SWIG_NewPointerObj(do_ptr, swig_type, 0);
156
+ }
157
+ #endif
158
+ **/
159
+ return SWIG_NewPointerObj(SWIG_as_voidptr(d_obj), SWIGTYPE_p_wxDataObjectSimple, 0);
160
+ }
99
161
  __HEREDOC
100
162
  # install GC marker
101
- spec.add_init_code 'wxRuby_AppendMarker(wxRuby_markCompositeDataObjects);'
163
+ spec.add_swig_code '%markfunc wxDataObjectComposite "GC_mark_wxCompositeDataObject";'
164
+
102
165
  # use custom implementation class
103
166
  spec.use_class_implementation 'wxDataObjectComposite', 'WxRuby_DataObjectComposite'
104
167
 
168
+ # make sure to return the right derived type
169
+ spec.map 'wxDataObjectSimple*' => 'Wx::DataObjectSimple' do
170
+ map_out code: '$result = wxRuby_WrapDataObjectSimple($1);'
171
+ end
172
+
105
173
  # disable generating the default Add method (keep docs)
106
174
  spec.ignore 'wxDataObjectComposite::Add', ignore_doc: false
107
175
  # Add custom Add implementation
@@ -14,20 +14,24 @@ module WXRuby3
14
14
  spec.disable_proxies
15
15
  if spec.module_name == 'wxScreenDC'
16
16
  spec.make_abstract 'wxScreenDC'
17
+ spec.gc_never 'wxScreenDC'
17
18
  # as a ScreenDC should always be a temporary stack object
18
19
  # we do not allow creation in Ruby but rather provide a class
19
20
  # method for block execution on a temp dc
20
21
  spec.add_extend_code 'wxScreenDC', <<~__HEREDOC
21
22
  static VALUE paint(VALUE proc)
22
23
  {
24
+ VALUE rc = Qnil;
23
25
  if (rb_block_given_p ())
24
26
  {
25
27
  wxScreenDC screen_dc;
26
28
  wxDC* dc_ptr = &screen_dc;
27
29
  VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxScreenDC, 0);
28
- return rb_yield(rb_dc);
30
+ rc = rb_yield(rb_dc);
31
+ SWIG_RubyRemoveTracking((void *)dc_ptr);
32
+ DATA_PTR(rb_dc) = NULL;
29
33
  }
30
- return Qnil;
34
+ return rc;
31
35
  }
32
36
  __HEREDOC
33
37
  # not relevant anymore
@@ -51,13 +55,100 @@ module WXRuby3
51
55
  'wxSVGFileDC::StartPage',
52
56
  'wxSVGFileDC::EndPage'
53
57
  elsif spec.module_name == 'wxGCDC'
58
+ spec.make_abstract 'wxGCDC'
59
+ spec.gc_never 'wxGCDC'
60
+ # as a GCDC should always be a temporary stack object
61
+ # we do not allow creation in Ruby but rather provide class
62
+ # methods for block execution on a temp dc
63
+ spec.add_extend_code 'wxGCDC', <<~__HEREDOC
64
+ static VALUE draw_on(const wxWindowDC& dc)
65
+ {
66
+ VALUE rc = Qnil;
67
+ if (rb_block_given_p ())
68
+ {
69
+ // Somehow there seems to be a problem with the Ruby GCDC value
70
+ // being GC-ed unless we block GC for the duration of the block
71
+ // execution. Unclear why. We have similar code for other objects
72
+ // where this issue does not come up.
73
+ VALUE gc_on = rb_gc_disable();
74
+ wxGCDC gc_dc(dc);
75
+ wxGCDC* dc_ptr = &gc_dc;
76
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
77
+ 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
+ }
82
+ return rc;
83
+ }
84
+ static VALUE draw_on(const wxMemoryDC& dc)
85
+ {
86
+ VALUE rc = Qnil;
87
+ if (rb_block_given_p ())
88
+ {
89
+ // Somehow there seems to be a problem with the Ruby GCDC value
90
+ // being GC-ed unless we block GC for the duration of the block
91
+ // execution. Unclear why. We have similar code for other objects
92
+ // where this issue does not come up.
93
+ VALUE gc_on = rb_gc_disable();
94
+ wxGCDC gc_dc(dc);
95
+ wxGCDC* dc_ptr = &gc_dc;
96
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
97
+ 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
+ }
102
+ return rc;
103
+ }
104
+ static VALUE draw_on(const wxPrinterDC& dc)
105
+ {
106
+ VALUE rc = Qnil;
107
+ if (rb_block_given_p ())
108
+ {
109
+ // Somehow there seems to be a problem with the Ruby GCDC value
110
+ // being GC-ed unless we block GC for the duration of the block
111
+ // execution. Unclear why. We have similar code for other objects
112
+ // where this issue does not come up.
113
+ VALUE gc_on = rb_gc_disable();
114
+ wxGCDC gc_dc(dc);
115
+ wxGCDC* dc_ptr = &gc_dc;
116
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
117
+ 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
+ }
122
+ return rc;
123
+ }
124
+ static VALUE draw_on(wxGraphicsContext* gc)
125
+ {
126
+ VALUE rc = Qnil;
127
+ if (rb_block_given_p ())
128
+ {
129
+ // Somehow there seems to be a problem with the Ruby GCDC value
130
+ // being GC-ed unless we block GC for the duration of the block
131
+ // execution. Unclear why. We have similar code for other objects
132
+ // where this issue does not come up.
133
+ VALUE gc_on = rb_gc_disable();
134
+ wxGCDC gc_dc(gc);
135
+ wxGCDC* dc_ptr = &gc_dc;
136
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(dc_ptr), SWIGTYPE_p_wxGCDC, 0);
137
+ 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
+ }
142
+ return rc;
143
+ }
144
+ __HEREDOC
54
145
  spec.ignore 'wxGCDC::wxGCDC(const wxEnhMetaFileDC &)'
55
146
  elsif spec.module_name == 'wxScaledDC'
56
147
  spec.items.clear # wxRuby extension; no XML docs
57
148
  spec.override_inheritance_chain('wxScaledDC', %w[wxDC wxObject])
58
149
  # as there are no dependencies parsed from XML make sure we're initialized after Wx::DC
59
150
  spec.initialize_at_end = true
60
- spec.gc_as_temporary 'wxScaledDC'
151
+ spec.gc_never 'wxScaledDC'
61
152
  spec.no_proxy 'wxScaledDC'
62
153
  spec.include 'wxruby-ScaledDC.h'
63
154
  # wxScaledDc should ever only be used in a restricted scope
@@ -67,16 +158,19 @@ module WXRuby3
67
158
  # so we use a workaround here)
68
159
  spec.add_swig_code <<~__HEREDOC
69
160
  %extend wxScaledDC {
70
- static void draw_on(wxDC& target, double scale)
161
+ static VALUE draw_on(wxDC& target, double scale)
71
162
  {
163
+ VALUE rc = Qnil;
72
164
  if (rb_block_given_p())
73
165
  {
74
166
  wxScaledDC scaled_dc(target, scale);
75
167
  wxScaledDC* p_scaled_dc = &scaled_dc;
76
168
  VALUE rb_scaled_dc = SWIG_NewPointerObj(SWIG_as_voidptr(p_scaled_dc), SWIGTYPE_p_wxScaledDC, 0);
77
- rb_yield(rb_scaled_dc);
169
+ rc = rb_yield(rb_scaled_dc);
170
+ SWIG_RubyRemoveTracking((void *)p_scaled_dc);
171
+ DATA_PTR(rb_scaled_dc) = NULL;
78
172
  }
79
- return ;
173
+ return rc;
80
174
  }
81
175
  };
82
176
  __HEREDOC
@@ -13,6 +13,7 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
+ spec.add_swig_code '%feature("notabstract") wxDirPickerCtrl;'
16
17
  spec.do_not_generate(:variables, :defines, :enums, :functions) # with FileDirPickerEvent
17
18
  end
18
19
  end # class DirPickerCtrl
@@ -24,11 +24,68 @@ module WXRuby3
24
24
  # make Ruby director and wrappers use custom implementation
25
25
  spec.use_class_implementation('wxEvent', 'wxRubyEvent')
26
26
  spec.extend_interface('wxEvent', 'wxEvent(wxEventType commandType = wxEVT_NULL, int id = 0, int prop_level = wxEVENT_PROPAGATE_NONE)')
27
- spec.extend_interface('wxEvent', 'virtual wxEvent* Clone() const')
28
- spec.ignore %w[wxEvent::Clone wxEvent::GetEventUserData]
27
+ spec.ignore %w[wxEvent::GetEventUserData]
29
28
  spec.ignore 'wxEvent::wxEvent(int,wxEventType)'
30
29
  spec.no_proxy 'wxEvent::Clone'
30
+ spec.regard 'wxEvent::Clone', regard_doc: false # need updated doc
31
+ # need this to force alloc func
32
+ spec.add_swig_code '%feature("notabstract") wxEvent;'
33
+ # type mapping for result #clone
34
+ spec.map 'wxEvent*' => 'Wx::Event' do
35
+ map_out code: <<~__CODE
36
+ $result = wxRuby_WrapClonedWxEvent($1);
37
+ __CODE
38
+ end
31
39
  spec.add_header_code <<~__HEREDOC
40
+ static VALUE Evt_Type_Map = NULL;
41
+ static VALUE wxRuby_WrapClonedWxEvent(wxEvent* wx_evt)
42
+ {
43
+ wxString class_name( wx_evt->GetClassInfo()->GetClassName() );
44
+ if (class_name == "wxEvent" || class_name == "wxCommandEvent")
45
+ {
46
+ // special clones for Ruby derived events are already managed and tracked
47
+ return SWIG_RubyInstanceFor((void *)wx_evt);
48
+ }
49
+
50
+ // otherwise
51
+
52
+ // Get the mapping of event types to classes
53
+ if ( ! Evt_Type_Map )
54
+ {
55
+ Evt_Type_Map = wxRuby_GetEventTypeClassMap ();
56
+ }
57
+
58
+ // Then, look up the event type in this hash (MUCH faster than calling
59
+ // EvtHandler.evt_class_for_type method)
60
+ VALUE rb_event_type_id = INT2NUM( wx_evt->GetEventType() );
61
+ VALUE rb_event_class = rb_hash_aref(Evt_Type_Map, rb_event_type_id);
62
+
63
+ if ( NIL_P(rb_event_class) )
64
+ {
65
+ rb_event_class = wxRuby_GetDefaultEventClass();
66
+ rb_warning("Unmapped event type %i (%s)", wx_evt->GetEventType(), (const char *)class_name.mb_str());
67
+ }
68
+
69
+ // Wrap as owned object as this is a user code factory function.
70
+ swig_type_info* type = wxRuby_GetSwigTypeForClass(rb_event_class);
71
+ swig_class* class_info = (swig_class*)type->clientdata;
72
+ // Create a new (owned) Ruby event object
73
+ VALUE rb_evt = Data_Wrap_Struct(class_info->klass, VOIDFUNC(class_info->mark),
74
+ VOIDFUNC(class_info->destroy),
75
+ wx_evt);
76
+ // track new event object
77
+ SWIG_RubyAddTracking(wx_evt, rb_evt);
78
+ // do not forget to mark the instance with the mangled swig type name
79
+ rb_iv_set(rb_evt, "@__swigtype__", rb_str_new2(type->name));
80
+
81
+ #if __WXRB_DEBUG__
82
+ if (wxRuby_TraceLevel()>1)
83
+ std::wcout << "* wxRuby_WrapClonedWxEvent - wrapped cloned event " << wx_evt << "{" << type->name << "}" << std::endl;
84
+ #endif
85
+
86
+ return rb_evt;
87
+ }
88
+
32
89
  // Custom subclass implementation. Provide a constructor, destructor and
33
90
  // clone functions to allow proper linking to a Ruby object.
34
91
  class WXRUBY_EXPORT wxRubyEvent : public wxEvent
@@ -85,8 +142,8 @@ module WXRuby3
85
142
  wxCommandEvent::SetClientObject
86
143
  wxCommandEvent::GetExtraLong
87
144
  }
88
- spec.extend_interface('wxCommandEvent', 'virtual wxCommandEvent* Clone() const')
89
- spec.no_proxy 'wxCommandEvent::Clone'
145
+ # need this to force alloc func
146
+ spec.add_swig_code '%feature("notabstract") wxCommandEvent;'
90
147
  spec.add_header_code <<~__HEREDOC
91
148
  // Cf wxEvent - has to be written as a C+++ subclass to ensure correct
92
149
  // GC/thread protection of Ruby instance variables when user-written
@@ -129,7 +186,8 @@ module WXRuby3
129
186
  };
130
187
  __HEREDOC
131
188
  spec.add_wrapper_code <<~__HEREDOC
132
- extern VALUE wxRuby_GetDefaultEventClass () {
189
+ extern VALUE wxRuby_GetDefaultEventClass()
190
+ {
133
191
  return SwigClassWxEvent.klass;
134
192
  }
135
193
  __HEREDOC
@@ -145,8 +203,8 @@ module WXRuby3
145
203
 
146
204
  def process(gendoc: false)
147
205
  defmod = super
148
- spec.items.each do |citem|
149
- unless citem == 'wxEvent'
206
+ unless spec.module_name == 'wxEvent'
207
+ spec.items.each do |citem|
150
208
  def_item = defmod.find_item(citem)
151
209
  if Extractor::ClassDef === def_item
152
210
  if def_item.hierarchy.has_key?('wxEvent')
@@ -158,7 +216,14 @@ module WXRuby3
158
216
  elsif def_item.hierarchy.has_key?('wxNotifyEvent')
159
217
  spec.override_inheritance_chain(citem, {'wxNotifyEvent' => 'wxEvents'}, {'wxCommandEvent' => 'wxEvent'}, 'wxEvent', 'wxObject')
160
218
  end
161
- spec.make_abstract(citem) if citem == 'wxPaintEvent' # doc flaw
219
+ case citem
220
+ when 'wxNotifyEvent', 'wxPaintEvent'
221
+ # keep these abstract in wxRuby
222
+ spec.make_abstract(citem)
223
+ else
224
+ # need this to force alloc func
225
+ spec.add_swig_code "%feature(\"notabstract\") #{citem};"
226
+ end
162
227
  end
163
228
  end
164
229
  end
@@ -24,7 +24,7 @@ module WXRuby3
24
24
  wxPaletteChangedEvent wxQueryNewPaletteEvent wxNavigationKeyEvent wxWindowCreateEvent
25
25
  wxWindowDestroyEvent wxHelpEvent wxClipboardTextEvent wxContextMenuEvent wxChildFocusEvent
26
26
  ])
27
- spec.fold_bases('wxMouseEvent' => 'wxMouseState', 'wxKeyEvent' => 'wxKeyboardState')
27
+ spec.fold_bases('wxMouseEvent' => %w[wxMouseState wxKeyboardState], 'wxKeyEvent' => 'wxKeyboardState')
28
28
  spec.set_only_for 'WXWIN_COMPATIBILITY_2_8', 'wxShowEvent::GetShow', 'wxIconizeEvent::Iconized'
29
29
  spec.ignore 'wxKeyEvent::GetPosition(wxCoord *,wxCoord *) const'
30
30
  spec.ignore 'wxMouseState::GetPosition(int *,int *)'
@@ -32,6 +32,24 @@ module WXRuby3
32
32
  spec.do_not_generate(:variables, :defines, :enums, :functions)
33
33
  end
34
34
 
35
+ def process(gendoc: false)
36
+ defmod = super
37
+ # fix documentation errors for wxScrollEvent
38
+ def_item = defmod.find_item('wxScrollEvent')
39
+ if def_item
40
+ def_item.event_types.each do |evt_spec|
41
+ case evt_spec.first
42
+ when 'EVT_COMMAND_SCROLL_THUMBRELEASE', 'EVT_COMMAND_SCROLL_CHANGED'
43
+ if evt_spec[2] == 0
44
+ evt_spec[2] = 1 # incorrectly documented without 'id' argument
45
+ evt_spec[4] = true # ignore extracted docs
46
+ end
47
+ end
48
+ end
49
+ end
50
+ defmod
51
+ end
52
+
35
53
  end # class Events
36
54
 
37
55
  end # class Director
@@ -13,6 +13,7 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
+ spec.add_swig_code '%feature("notabstract") wxFilePickerCtrl;'
16
17
  spec.do_not_generate(:variables, :defines, :enums, :functions) # with FileDirPickerEvent
17
18
  end
18
19
  end # class FilePickerCtrl
@@ -13,6 +13,7 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
+ spec.add_swig_code '%feature("notabstract") wxFontPickerCtrl;'
16
17
  spec.do_not_generate(:variables, :defines, :enums, :functions) # with FontPickerEvent
17
18
  end
18
19
  end # class FontPickerCtrl
@@ -23,14 +23,12 @@ module WXRuby3
23
23
  'wxClientDisplayRect(int *,int *,int *,int *)',
24
24
  'wxDisplaySize(int *,int *)',
25
25
  'wxDisplaySizeMM(int *,int *)',
26
- 'wxRect::Inflate(wxCoord,wxCoord)',
27
26
  'wxRect::Inflate(wxCoord,wxCoord) const',
28
- 'wxRect::Deflate(wxCoord,wxCoord)',
29
27
  'wxRect::Deflate(wxCoord,wxCoord) const',
30
- 'wxRect::Offset(wxCoord,wxCoord)',
31
28
  'wxRect::Intersect(const wxRect &)',
32
29
  'wxRect::Union(const wxRect &)'
33
30
  ]
31
+ spec.regard 'wxRect::Offset', regard_doc: false
34
32
  # overrule common wxPoint mapping for wxRect ctor to fix ctor ambiguities here wrt wxSize
35
33
  spec.map 'const wxPoint& topLeft', 'const wxPoint& bottomRight', as: 'Wx::Point' do
36
34
  map_in code: <<~__CODE
@@ -135,6 +135,95 @@ module WXRuby3
135
135
  }
136
136
  __CODE
137
137
  end
138
+ spec.new_object 'wxGraphicsContext::Create',
139
+ 'wxGraphicsContext::CreateFromUnknownDC'
140
+ # add convenience method providing efficient gc memory management
141
+ spec.add_extend_code 'wxGraphicsContext', <<~__HEREDOC
142
+ static VALUE draw_on(wxWindow* win)
143
+ {
144
+ VALUE rc = Qnil;
145
+ if (rb_block_given_p())
146
+ {
147
+ wxGraphicsContext* p_gc = wxGraphicsContext::Create(win);
148
+ VALUE rb_gc = SWIG_NewPointerObj(SWIG_as_voidptr(p_gc), SWIGTYPE_p_wxGraphicsContext, 1);
149
+ rc = rb_yield(rb_gc);
150
+ SWIG_RubyRemoveTracking((void *)p_gc);
151
+ DATA_PTR(rb_gc) = NULL;
152
+ delete p_gc;
153
+ }
154
+ return rc;
155
+ }
156
+ static VALUE draw_on(const wxWindowDC& dc)
157
+ {
158
+ VALUE rc = Qnil;
159
+ if (rb_block_given_p())
160
+ {
161
+ wxGraphicsContext* p_gc = wxGraphicsContext::Create(dc);
162
+ VALUE rb_gc = SWIG_NewPointerObj(SWIG_as_voidptr(p_gc), SWIGTYPE_p_wxGraphicsContext, 1);
163
+ rc = rb_yield(rb_gc);
164
+ SWIG_RubyRemoveTracking((void *)p_gc);
165
+ DATA_PTR(rb_gc) = NULL;
166
+ delete p_gc;
167
+ }
168
+ return rc;
169
+ }
170
+ static VALUE draw_on(const wxMemoryDC& dc)
171
+ {
172
+ VALUE rc = Qnil;
173
+ if (rb_block_given_p())
174
+ {
175
+ wxGraphicsContext* p_gc = wxGraphicsContext::Create(dc);
176
+ VALUE rb_gc = SWIG_NewPointerObj(SWIG_as_voidptr(p_gc), SWIGTYPE_p_wxGraphicsContext, 1);
177
+ rc = rb_yield(rb_gc);
178
+ SWIG_RubyRemoveTracking((void *)p_gc);
179
+ DATA_PTR(rb_gc) = NULL;
180
+ delete p_gc;
181
+ }
182
+ return rc;
183
+ }
184
+ static VALUE draw_on(const wxPrinterDC& dc)
185
+ {
186
+ VALUE rc = Qnil;
187
+ if (rb_block_given_p())
188
+ {
189
+ wxGraphicsContext* p_gc = wxGraphicsContext::Create(dc);
190
+ VALUE rb_gc = SWIG_NewPointerObj(SWIG_as_voidptr(p_gc), SWIGTYPE_p_wxGraphicsContext, 1);
191
+ rc = rb_yield(rb_gc);
192
+ SWIG_RubyRemoveTracking((void *)p_gc);
193
+ DATA_PTR(rb_gc) = NULL;
194
+ delete p_gc;
195
+ }
196
+ return rc;
197
+ }
198
+ static VALUE draw_on(wxImage& img)
199
+ {
200
+ VALUE rc = Qnil;
201
+ if (rb_block_given_p())
202
+ {
203
+ wxGraphicsContext* p_gc = wxGraphicsContext::Create(img);
204
+ VALUE rb_gc = SWIG_NewPointerObj(SWIG_as_voidptr(p_gc), SWIGTYPE_p_wxGraphicsContext, 1);
205
+ rc = rb_yield(rb_gc);
206
+ SWIG_RubyRemoveTracking((void *)p_gc);
207
+ DATA_PTR(rb_gc) = NULL;
208
+ delete p_gc;
209
+ }
210
+ return rc;
211
+ }
212
+ static VALUE draw_on()
213
+ {
214
+ VALUE rc = Qnil;
215
+ if (rb_block_given_p())
216
+ {
217
+ wxGraphicsContext* p_gc = wxGraphicsContext::Create();
218
+ VALUE rb_gc = SWIG_NewPointerObj(SWIG_as_voidptr(p_gc), SWIGTYPE_p_wxGraphicsContext, 1);
219
+ rc = rb_yield(rb_gc);
220
+ SWIG_RubyRemoveTracking((void *)p_gc);
221
+ DATA_PTR(rb_gc) = NULL;
222
+ delete p_gc;
223
+ }
224
+ return rc;
225
+ }
226
+ __HEREDOC
138
227
  end
139
228
  end # class GraphicsContext
140
229
 
@@ -43,8 +43,8 @@ module WXRuby3
43
43
  {
44
44
  rc = rb_ary_new();
45
45
  rb_ary_push(rc, wxRuby_WrapWxObjectInRuby(result));
46
- rb_ary_push(rc, SWIG_NewPointerObj(SWIG_as_voidptr(&size), SWIGTYPE_p_wxSize, 0));
47
- rb_ary_push(rc, SWIG_NewPointerObj(SWIG_as_voidptr(&pos), SWIGTYPE_p_wxPoint, 0));
46
+ rb_ary_push(rc, SWIG_NewPointerObj(new wxSize(size), SWIGTYPE_p_wxSize, 1));
47
+ rb_ary_push(rc, SWIG_NewPointerObj(new wxPoint(pos), SWIGTYPE_p_wxPoint, 1));
48
48
  rb_ary_push(rc, newFrameEachTime ? Qtrue : Qfalse);
49
49
  }
50
50
  return rc;
@@ -0,0 +1,37 @@
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 HTMLDataObject < Director
11
+
12
+ include Typemap::DataFormat
13
+ include Typemap::DataObjectData
14
+
15
+ def setup
16
+ super
17
+ spec.gc_as_object
18
+ # make sure the build scripts know that DataObjectSimple is part of the DataObject module
19
+ spec.override_inheritance_chain('wxHTMLDataObject', {'wxDataObjectSimple' => 'wxDataObject'}, 'wxDataObject')
20
+ # we only allow Ruby derivatives from wxDataObject but not of any of the C++ implemented
21
+ # specializations
22
+ spec.no_proxy 'wxHTMLDataObject'
23
+ spec.add_swig_code <<~__HEREDOC
24
+ // SWIG gets confused and doesn't realise that various virtual methods
25
+ // from wxDataObject are implemented fully in this subclass, and so,
26
+ // believing it to be abstract doesn't provide an allocator for this
27
+ // class. This undocumented feature overrides this.
28
+ %feature("notabstract") wxHTMLDataObject;
29
+ __HEREDOC
30
+
31
+ end
32
+
33
+ end
34
+
35
+ end
36
+
37
+ end
@@ -43,6 +43,61 @@ module WXRuby3
43
43
  wxImage::InsertHandler
44
44
  wxImage::RemoveHandler
45
45
  ]
46
+ # add convenience class methods
47
+ spec.add_extend_code 'wxImage', <<~__HEREDOC
48
+ static VALUE handlers()
49
+ {
50
+ VALUE hnd_ary = rb_ary_new();
51
+ wxList& hnd_lst = wxImage::GetHandlers();
52
+ for (wxList::compatibility_iterator node = hnd_lst.GetFirst();
53
+ node; node = node->GetNext())
54
+ {
55
+ wxImageHandler *handler = (wxImageHandler *) node->GetData();
56
+ wxBitmapType bmp_type = handler->GetType();
57
+ rb_ary_push(hnd_ary, wxRuby_GetEnumValueObject("wxBitmapType", (int)bmp_type));
58
+ }
59
+ return hnd_ary;
60
+ }
61
+
62
+ static VALUE extensions()
63
+ {
64
+ VALUE ext_ary = rb_ary_new();
65
+ wxList& hnd_lst = wxImage::GetHandlers();
66
+ for (wxList::compatibility_iterator node = hnd_lst.GetFirst();
67
+ node; node = node->GetNext())
68
+ {
69
+ wxImageHandler *handler = (wxImageHandler *) node->GetData();
70
+ rb_ary_push(ext_ary, WXSTR_TO_RSTR(handler->GetExtension()));
71
+ const wxArrayString& alt_ext = handler->GetAltExtensions();
72
+ for (wxArrayString::const_iterator it = alt_ext.begin(); it!=alt_ext.end() ;++it)
73
+ {
74
+ rb_ary_push(ext_ary, WXSTR_TO_RSTR((*it)));
75
+ }
76
+ }
77
+ return ext_ary;
78
+ }
79
+
80
+ static VALUE handler_extensions()
81
+ {
82
+ VALUE ext_hash = rb_hash_new();
83
+ wxList& hnd_lst = wxImage::GetHandlers();
84
+ for (wxList::compatibility_iterator node = hnd_lst.GetFirst();
85
+ node; node = node->GetNext())
86
+ {
87
+ wxImageHandler *handler = (wxImageHandler *) node->GetData();
88
+ VALUE ext_ary = rb_ary_new();
89
+ rb_ary_push(ext_ary, WXSTR_TO_RSTR(handler->GetExtension()));
90
+ const wxArrayString& alt_ext = handler->GetAltExtensions();
91
+ for (wxArrayString::const_iterator it = alt_ext.begin(); it!=alt_ext.end() ;++it)
92
+ {
93
+ rb_ary_push(ext_ary, WXSTR_TO_RSTR((*it)));
94
+ }
95
+ wxBitmapType bmp_type = handler->GetType();
96
+ rb_hash_aset(ext_hash, wxRuby_GetEnumValueObject("wxBitmapType", (int)bmp_type), ext_ary);
97
+ }
98
+ return ext_hash;
99
+ }
100
+ __HEREDOC
46
101
  # The GetRgbData and GetAlphaData methods require special handling using %extend;
47
102
  spec.ignore %w[wxImage::GetData wxImage::GetAlpha]
48
103
  # The SetRgbData and SetAlphaData are dealt with by typemaps (see below).