wxruby3 0.9.0.pre.beta.10 → 0.9.0.pre.beta.13

Sign up to get free protection for your applications and to get access to all the features.
Files changed (126) 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/include/wxruby-ScaledDC.h +549 -0
  8. data/ext/wxruby3/swig/wx.i +1 -1
  9. data/lib/wx/core/array_ext.rb +26 -0
  10. data/lib/wx/core/art_locator.rb +92 -0
  11. data/lib/wx/core/artprovider.rb +1 -1
  12. data/lib/wx/core/bitmap.rb +90 -53
  13. data/lib/wx/core/cursor.rb +12 -0
  14. data/lib/wx/core/data_object.rb +74 -6
  15. data/lib/wx/core/dataformat.rb +3 -1
  16. data/lib/wx/core/dc.rb +76 -52
  17. data/lib/wx/core/enum.rb +4 -0
  18. data/lib/wx/core/event.rb +38 -5
  19. data/lib/wx/core/evthandler.rb +64 -23
  20. data/lib/wx/core/icon.rb +50 -35
  21. data/lib/wx/core/id_helper.rb +32 -0
  22. data/lib/wx/core/image.rb +63 -53
  23. data/lib/wx/core/point.rb +35 -10
  24. data/lib/wx/core/real_point.rb +35 -10
  25. data/lib/wx/core/rect.rb +44 -9
  26. data/lib/wx/core/region_iterator.rb +37 -0
  27. data/lib/wx/core/size.rb +32 -5
  28. data/lib/wx/core/window.rb +8 -31
  29. data/lib/wx/doc/array_ext.rb +27 -0
  30. data/lib/wx/doc/art_locator.rb +57 -0
  31. data/lib/wx/doc/bitmap.rb +27 -0
  32. data/lib/wx/doc/clipboard.rb +12 -0
  33. data/lib/wx/doc/const.rb +77 -0
  34. data/lib/wx/doc/cursor.rb +16 -0
  35. data/lib/wx/doc/data_object.rb +103 -0
  36. data/lib/wx/doc/dc.rb +63 -46
  37. data/lib/wx/doc/event.rb +24 -0
  38. data/lib/wx/doc/events.rb +14 -0
  39. data/lib/wx/doc/evthandler.rb +24 -3
  40. data/lib/wx/doc/extra/00_starting.md +1 -1
  41. data/lib/wx/doc/extra/06_geometry.md +10 -4
  42. data/lib/wx/doc/extra/10_art.md +105 -0
  43. data/lib/wx/doc/gc_dc.rb +21 -0
  44. data/lib/wx/doc/gdi_common.rb +155 -6
  45. data/lib/wx/doc/graphics_context.rb +42 -0
  46. data/lib/wx/doc/icon.rb +18 -0
  47. data/lib/wx/doc/id_helper.rb +25 -0
  48. data/lib/wx/doc/image.rb +33 -0
  49. data/lib/wx/doc/region_iterator.rb +31 -0
  50. data/lib/wx/doc/scaled_dc.rb +17 -0
  51. data/lib/wx/doc/window.rb +18 -0
  52. data/lib/wx/global_const.rb +4 -3
  53. data/lib/wx/version.rb +1 -1
  54. data/lib/wx/wxruby/cmd/sampler.rb +3 -21
  55. data/rakelib/lib/config.rb +4 -4
  56. data/rakelib/lib/core/package.rb +6 -6
  57. data/rakelib/lib/core/spec.rb +2 -0
  58. data/rakelib/lib/director/art_provider.rb +2 -2
  59. data/rakelib/lib/director/busy_info.rb +9 -7
  60. data/rakelib/lib/director/clipboard.rb +1 -1
  61. data/rakelib/lib/director/colour_picker_ctrl.rb +1 -0
  62. data/rakelib/lib/director/data_object.rb +162 -0
  63. data/rakelib/lib/director/data_object_simple_base.rb +123 -0
  64. data/rakelib/lib/director/derived_dc.rb +134 -2
  65. data/rakelib/lib/director/dir_picker_ctrl.rb +1 -0
  66. data/rakelib/lib/director/event.rb +73 -8
  67. data/rakelib/lib/director/events.rb +19 -1
  68. data/rakelib/lib/director/file_picker_ctrl.rb +1 -0
  69. data/rakelib/lib/director/font_picker_ctrl.rb +1 -0
  70. data/rakelib/lib/director/gdicommon.rb +1 -3
  71. data/rakelib/lib/director/graphics_context.rb +89 -0
  72. data/rakelib/lib/director/help_controller.rb +2 -2
  73. data/rakelib/lib/director/html_data_object.rb +37 -0
  74. data/rakelib/lib/director/image.rb +55 -0
  75. data/rakelib/lib/director/region_iterator.rb +48 -0
  76. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  77. data/rakelib/lib/director/richtext_buffer_data_object.rb +45 -0
  78. data/rakelib/lib/director/scroll_bar.rb +39 -0
  79. data/rakelib/lib/director/slider.rb +39 -0
  80. data/rakelib/lib/director/window.rb +36 -5
  81. data/rakelib/lib/director/window_disabler.rb +0 -7
  82. data/rakelib/lib/extractor/class.rb +1 -1
  83. data/rakelib/lib/extractor/function.rb +1 -1
  84. data/rakelib/lib/generate/doc.rb +26 -6
  85. data/rakelib/lib/specs/interfaces.rb +8 -1
  86. data/rakelib/lib/typemap/common.rb +1 -1
  87. data/rakelib/lib/typemap/data_object_data.rb +13 -4
  88. data/rakelib/lib/util/string.rb +29 -8
  89. data/samples/art/wxruby-128x128.png +0 -0
  90. data/samples/art/wxruby-256x256.png +0 -0
  91. data/samples/art/wxruby-64x64.png +0 -0
  92. data/samples/art/wxruby.ico +0 -0
  93. data/samples/art/wxruby.png +0 -0
  94. data/samples/drawing/graphics_drawing.rb +1 -2
  95. data/samples/propgrid/propgrid.rb +65 -65
  96. data/samples/sample.xpm +246 -470
  97. data/samples/treectrl/treectrl.rb +1 -1
  98. data/tests/art/my_art/sample.xpm +251 -0
  99. data/tests/art/sample3.xpm +251 -0
  100. data/tests/art/test_art/bitmap/sample.xpm +251 -0
  101. data/tests/art/test_art/bitmap/wxruby.bmp +0 -0
  102. data/tests/art/test_art/bitmap/wxruby.png +0 -0
  103. data/tests/art/test_art/bitmap/wxruby.xpm +251 -0
  104. data/tests/art/test_art/cursor/wxruby.bmp +0 -0
  105. data/tests/art/test_art/icon/sample.xpm +251 -0
  106. data/tests/art/test_art/icon/wxruby.ico +0 -0
  107. data/tests/art/test_art/icon/wxruby.png +0 -0
  108. data/tests/art/test_art/image/sample.xpm +251 -0
  109. data/tests/art/test_art/image/wxruby.jpg +0 -0
  110. data/tests/art/test_art/image/wxruby.png +0 -0
  111. data/tests/art/test_art/sample2.xpm +251 -0
  112. data/tests/lib/wxapp_runner.rb +64 -0
  113. data/tests/test_art.rb +91 -0
  114. data/tests/test_basic.rb +0 -5
  115. data/tests/test_clipboard.rb +149 -17
  116. data/tests/test_dc.rb +70 -0
  117. data/tests/test_dialog.rb +2 -13
  118. data/tests/test_event_handling.rb +2 -13
  119. data/tests/test_events.rb +14 -6
  120. data/tests/test_geometry.rb +67 -17
  121. data/tests/test_intl.rb +2 -15
  122. data/tests/test_item_data.rb +2 -15
  123. data/tests/test_variant.rb +1 -15
  124. data/tests/testapp.rb +0 -5
  125. data/tests/testapp_noframe.rb +0 -5
  126. metadata +56 -5
@@ -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).
@@ -0,0 +1,48 @@
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 RegionIterator < Director
11
+
12
+ def setup
13
+ super
14
+ spec.gc_never
15
+ spec.disable_proxies
16
+ spec.make_abstract 'wxRegionIterator'
17
+ # not useful in wxRuby
18
+ spec.ignore 'wxRegionIterator::Reset(const wxRegion &)',
19
+ 'wxRegionIterator::operator bool'
20
+ # add iteration control methods
21
+ spec.add_extend_code 'wxRegionIterator', <<~__HEREDOC
22
+ void next_rect()
23
+ {
24
+ $self->operator ++();
25
+ }
26
+ __HEREDOC
27
+ # add custom factory method
28
+ spec.add_extend_code 'wxRegionIterator', <<~__HEREDOC
29
+ static void for_region(const wxRegion& region)
30
+ {
31
+ wxRegionIterator region_it(region);
32
+ if (rb_block_given_p())
33
+ {
34
+ wxRegionIterator *p_region_it = &region_it;
35
+ VALUE rb_region_it = SWIG_NewPointerObj(SWIG_as_voidptr(p_region_it), SWIGTYPE_p_wxRegionIterator, 0);
36
+ rb_yield(rb_region_it);
37
+ SWIG_RubyRemoveTracking((void *)p_region_it);
38
+ DATA_PTR(rb_region_it) = NULL;
39
+ }
40
+ }
41
+ __HEREDOC
42
+ spec.do_not_generate :functions, :variables, :defines, :enums
43
+ end
44
+ end # class RegionIterator
45
+
46
+ end # class Director
47
+
48
+ end # module WXRuby3
@@ -22,7 +22,7 @@ module WXRuby3
22
22
  wxRichTextBuffer
23
23
  ]
24
24
  spec.gc_as_object 'wxRichTextAttr'
25
- spec.gc_never 'wxRichTextBuffer'
25
+ spec.gc_as_object 'wxRichTextBuffer'
26
26
  spec.override_inheritance_chain('wxRichTextBuffer', %w[wxObject])
27
27
  spec.ignore %w[
28
28
  wxRichTextBuffer::GetBatchedCommand
@@ -0,0 +1,45 @@
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 RichTextBufferDataObject < 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('wxRichTextBufferDataObject', {'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 'wxRichTextBufferDataObject'
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") wxRichTextBufferDataObject;
29
+ __HEREDOC
30
+
31
+ # ignore overrrides (will be available through base class)
32
+ spec.ignore 'wxRichTextBufferDataObject::GetPreferredFormat'
33
+ spec.ignore 'wxRichTextBufferDataObject::GetDataSize'
34
+ spec.ignore 'wxRichTextBufferDataObject::GetDataHere'
35
+ spec.ignore 'wxRichTextBufferDataObject::SetData'
36
+
37
+ spec.new_object 'wxRichTextBufferDataObject::GetRichTextBuffer'
38
+ spec.do_not_generate :variables, :defines, :functions, :enums
39
+ end
40
+
41
+ end
42
+
43
+ end
44
+
45
+ end
@@ -0,0 +1,39 @@
1
+ ###
2
+ # wxRuby3 wxWidgets interface director
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ require_relative './window'
7
+
8
+ module WXRuby3
9
+
10
+ class Director
11
+
12
+ class ScrollBar < Window
13
+
14
+ def setup
15
+ super
16
+ end
17
+
18
+ def process(gendoc: false)
19
+ defmod = super
20
+ # fix documentation errors for scroll events
21
+ def_item = defmod.find_item('wxScrollBar')
22
+ if def_item
23
+ def_item.event_types.each do |evt_spec|
24
+ case evt_spec.first
25
+ when 'EVT_COMMAND_SCROLL_THUMBRELEASE', 'EVT_COMMAND_SCROLL_CHANGED'
26
+ if evt_spec[2] == 0
27
+ evt_spec[2] = 1 # incorrectly documented without 'id' argument
28
+ evt_spec[4] = true # ignore extracted docs
29
+ end
30
+ end
31
+ end
32
+ end
33
+ defmod
34
+ end
35
+ end # class ScrollBar
36
+
37
+ end # class Director
38
+
39
+ end # module WXRuby3
@@ -0,0 +1,39 @@
1
+ ###
2
+ # wxRuby3 wxWidgets interface director
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ require_relative './window'
7
+
8
+ module WXRuby3
9
+
10
+ class Director
11
+
12
+ class Slider < Window
13
+
14
+ def setup
15
+ super
16
+ end
17
+
18
+ def process(gendoc: false)
19
+ defmod = super
20
+ # fix documentation errors for scroll events
21
+ def_item = defmod.find_item('wxSlider')
22
+ if def_item
23
+ def_item.event_types.each do |evt_spec|
24
+ case evt_spec.first
25
+ when 'EVT_COMMAND_SCROLL_THUMBRELEASE', 'EVT_COMMAND_SCROLL_CHANGED'
26
+ if evt_spec[2] == 0
27
+ evt_spec[2] = 1 # incorrectly documented without 'id' argument
28
+ evt_spec[4] = true # ignore extracted docs
29
+ end
30
+ end
31
+ end
32
+ end
33
+ defmod
34
+ end
35
+ end # class Slider
36
+
37
+ end # class Director
38
+
39
+ end # module WXRuby3
@@ -156,7 +156,29 @@ module WXRuby3
156
156
  extern VALUE wxRuby_GetWindowClass() {
157
157
  return SwigClassWxWindow.klass;
158
158
  }
159
+ // we need this static method here because we do not want SWIG to parse the preprocessor
160
+ // statements (#if/#else/#endif) which it does in %extend blocks
161
+ static VALUE do_paint_buffered(wxWindow* ptr)
162
+ {
163
+ VALUE rc = Qnil;
164
+ wxAutoBufferedPaintDC dc(ptr);
165
+ #if wxALWAYS_NATIVE_DOUBLE_BUFFER
166
+ wxPaintDC* ptr_dc = &dc;
167
+ VALUE r_class = rb_const_get(mWxCore, rb_intern("PaintDC"));
168
+ #else
169
+ wxMemoryDC* ptr_dc = &dc;
170
+ VALUE r_class = rb_const_get(mWxCore, rb_intern("MemoryDC"));
171
+ #endif
172
+ swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(r_class);
173
+ VALUE rb_dc = SWIG_NewPointerObj(SWIG_as_voidptr(ptr_dc), swig_type, 0);
174
+ rc = rb_yield(rb_dc);
175
+ SWIG_RubyRemoveTracking((void *)ptr_dc);
176
+ DATA_PTR(rb_dc) = NULL;
177
+
178
+ return rc;
179
+ }
159
180
  __HEREDOC
181
+ spec.add_header_code 'static VALUE do_paint_buffered(wxWindow* ptr);'
160
182
  spec.add_extend_code 'wxWindow', <<~__HEREDOC
161
183
  // passes a DC for drawing on Window into a passed ruby block, and
162
184
  // ensure that the DC is correctly deleted when drawing is
@@ -167,9 +189,9 @@ module WXRuby3
167
189
  {
168
190
  static WxRuby_ID painting_id("@__painting__");
169
191
 
170
- if ( ! rb_block_given_p() )
171
- rb_raise(rb_eArgError, "No block given for Window#paint");
192
+ if (!rb_block_given_p()) rb_raise(rb_eArgError, "No block given for Window#paint");
172
193
 
194
+ VALUE rc = Qnil;
173
195
  wxWindow *ptr = self;
174
196
  VALUE rb_win = SWIG_RubyInstanceFor(ptr);
175
197
  // see if within an evt_paint block - see classes/window.rb
@@ -178,7 +200,7 @@ module WXRuby3
178
200
  {
179
201
  wxPaintDC dc(ptr);
180
202
  VALUE dcVal = SWIG_NewPointerObj((void *) &dc,SWIGTYPE_p_wxPaintDC, 0);
181
- rb_yield(dcVal);
203
+ rc = rb_yield(dcVal);
182
204
  SWIG_RubyRemoveTracking((void *) &dc);
183
205
  DATA_PTR(dcVal) = NULL;
184
206
  }
@@ -186,12 +208,21 @@ module WXRuby3
186
208
  {
187
209
  wxClientDC dc(ptr);
188
210
  VALUE dcVal = SWIG_NewPointerObj((void *) &dc,SWIGTYPE_p_wxClientDC, 0);
189
- rb_yield(dcVal);
211
+ rc = rb_yield(dcVal);
190
212
  SWIG_RubyRemoveTracking((void *) &dc);
191
213
  DATA_PTR(dcVal) = NULL;
192
214
  }
193
215
 
194
- return Qnil;
216
+ return rc;
217
+ }
218
+
219
+ // similar to the paint() method but now for buffered painting
220
+ // we do not check __painting__ here, instead we do that in pure Ruby
221
+ VALUE paint_buffered()
222
+ {
223
+ if (!rb_block_given_p()) rb_raise(rb_eArgError, "No block given for Window#paint_buffered");
224
+
225
+ return do_paint_buffered(self);
195
226
  }
196
227
 
197
228
  // Return a window handle as a platform-specific ruby integer
@@ -28,13 +28,6 @@ module WXRuby3
28
28
  return ;
29
29
  }
30
30
  __HEREDOC
31
- spec.ignore %w[
32
- wxFindWindowByLabel
33
- wxFindWindowByName
34
- wxNewId
35
- wxUsleep
36
- ]
37
- spec.ignore 'wxPostDelete' unless Config.instance.wx_version >= '3.3.0'
38
31
  spec.do_not_generate(:variables, :enums, :defines, :functions)
39
32
  end
40
33
  end # class WindowDisabler
@@ -227,7 +227,7 @@ module WXRuby3
227
227
  end
228
228
  # record event handler (macro) name, event type handled and the number of event id arguments
229
229
  evt_arity = args.inject(0) {|c, a| c += 1 if a.start_with?('id'); c }
230
- @event_types << [evt_handler, evt_type, evt_arity, evt_klass]
230
+ @event_types << [evt_handler, evt_type, evt_arity, evt_klass, false]
231
231
  end
232
232
  end
233
233
  end
@@ -111,7 +111,7 @@ module WXRuby3
111
111
  end
112
112
  params << { name: pnm, type: arg.type }
113
113
  if paramdef.default
114
- defexp = rb_constant_expression(paramdef.default)
114
+ defexp = rb_constant_expression(paramdef.default, xml_trans.constants_xref_db)
115
115
  # in case the default expression dereferences a pointer or passes an address clean it up
116
116
  defexp.sub!(/\A\s*[\*\&]/, '')
117
117
  # in case the default expression contains anything else but simple numbers or identifiers, wrap in ()
@@ -46,12 +46,17 @@ module WXRuby3
46
46
  tmpfile << script
47
47
  tmpfile.close(false)
48
48
  result = if Director.trace?
49
- Config.instance.run(ftmp_name, capture: :out)
49
+ Config.instance.run(ftmp_name, capture: :out, verbose: false)
50
50
  else
51
- Config.instance.run(ftmp_name, capture: :no_err)
51
+ Config.instance.run(ftmp_name, capture: :no_err, verbose: false)
52
52
  end
53
53
  STDERR.puts "* got constants collection output:\n#{result}" if Director.trace?
54
- db = JSON.load(result)
54
+ begin
55
+ db = JSON.load(result)
56
+ rescue Exception
57
+ File.open('constants_raw.json', "w") { |f| f << result } if Director.verbose?
58
+ ::Kernel.raise RuntimeError, "Exception loading constants collection result: #{$!.message.slice(0, 512)}", cause: nil
59
+ end
55
60
  File.open('constants.json', "w") { |f| f << JSON.pretty_generate(db) } if Director.verbose?
56
61
  return db
57
62
  ensure
@@ -293,6 +298,8 @@ module WXRuby3
293
298
  ["#{DocGenerator.constants_xref_db[constnm]['mod']}::#{constnm}", true]
294
299
  elsif DocGenerator.constants_xref_db.has_key?(rb_constant_name(nm_str))
295
300
  ["Wx::#{rb_constant_name(nm_str)}", true]
301
+ elsif DocGenerator.constants_xref_db.has_key?(rb_constant_name(nm_str, false))
302
+ ["Wx::#{rb_constant_name(nm_str, false)}", true]
296
303
  elsif !_is_method?(nm_str, ref_scope)
297
304
  ["Wx::#{constnm}", true]
298
305
  else
@@ -324,6 +331,9 @@ module WXRuby3
324
331
  elsif DocGenerator.constants_xref_db.has_key?(rb_constant_name(nm_str))
325
332
  cnm = rb_constant_name(nm_str)
326
333
  constnm = "#{DocGenerator.constants_xref_db[cnm]['mod']}::#{cnm}"
334
+ elsif DocGenerator.constants_xref_db.has_key?(rb_constant_name(nm_str, false))
335
+ cnm = rb_constant_name(nm_str, false)
336
+ constnm = "#{DocGenerator.constants_xref_db[cnm]['mod']}::#{cnm}"
327
337
  elsif nm_str.start_with?('wx')
328
338
  known = false
329
339
  constnm = "Wx::#{constnm}"
@@ -411,10 +421,12 @@ module WXRuby3
411
421
  para = node_to_doc(node)
412
422
  # loose specific notes paragraphs
413
423
  case para
414
- when /\A\s*wxPerl Note:/, # wxPerl note
415
- /\A\s*Library:/ # Library note
424
+ when /\A(\<b\>)?wxPerl Note:/, # wxPerl note
425
+ /\A\s*Library:/, # Library note
426
+ /\A\s*Include\s+file:/ # Include file note
416
427
  ''
417
428
  else
429
+ para.sub!(/Include\s+file:\s+\#include\s+\<[^>]+\>\s*\Z/, '')
418
430
  if event_section?
419
431
  case para
420
432
  when /The following event handler macros redirect.*(\{.*})/
@@ -509,6 +521,14 @@ module WXRuby3
509
521
  doc
510
522
  end
511
523
 
524
+ def constants_db
525
+ DocGenerator.constants_db
526
+ end
527
+
528
+ def constants_xref_db
529
+ DocGenerator.constants_xref_db
530
+ end
531
+
512
532
  end
513
533
 
514
534
  def run
@@ -611,7 +631,7 @@ module WXRuby3
611
631
  end
612
632
  else
613
633
  item.items.each do |e|
614
- const_name = rb_constant_name(e.name)
634
+ const_name = rb_constant_name(e.name, false)
615
635
  if xref_table.has_key?(const_name)
616
636
  gen_constant_doc(fdoc, const_name, xref_table[const_name], get_constant_doc(e))
617
637
  end
@@ -29,6 +29,7 @@ module WXRuby3
29
29
  Director.Spec(pkg, 'wxScreenDC', director: Director::DerivedDC)
30
30
  Director.Spec(pkg, 'wxSVGFileDC', director: Director::DerivedDC, requirements: %w[wxUSE_SVG])
31
31
  Director.Spec(pkg, 'wxGCDC', director: Director::DerivedDC, requirements: %w[wxUSE_GRAPHICS_CONTEXT])
32
+ Director.Spec(pkg, 'wxScaledDC', director: Director::DerivedDC)
32
33
  Director.Spec(pkg, 'wxWindow')
33
34
  Director.Spec(pkg, 'wxNonOwnedWindow', director: Director::Window)
34
35
  Director.Spec(pkg, 'wxPopupWindow')
@@ -42,6 +43,7 @@ module WXRuby3
42
43
  Director.Spec(pkg, 'wxPen')
43
44
  Director.Spec(pkg, 'wxPalette')
44
45
  Director.Spec(pkg, 'wxRegion')
46
+ Director.Spec(pkg, 'wxRegionIterator')
45
47
  Director.Spec(pkg, 'wxIconLocation')
46
48
  Director.Spec(pkg, 'wxBitmap')
47
49
  Director.Spec(pkg, 'wxIcon')
@@ -83,7 +85,8 @@ module WXRuby3
83
85
  Director.Spec(pkg, 'wxCollapsiblePaneEvent', requirements: %w[wxUSE_COLLPANE])
84
86
  Director.Spec(pkg, 'wxStaticLine', director: Director::Window)
85
87
  Director.Spec(pkg, 'wxGauge', director: Director::Window)
86
- Director.Spec(pkg, 'wxSlider', director: Director::Window)
88
+ Director.Spec(pkg, 'wxSlider')
89
+ Director.Spec(pkg, 'wxScrollBar')
87
90
  Director.Spec(pkg, 'wxStaticText', director: Director::Window)
88
91
  Director.Spec(pkg, 'wxSpinButton', director: Director::Window, requirements: %w[wxUSE_SPINBTN])
89
92
  Director.Spec(pkg, 'wxSpinEvent', director: Director::Event, requirements: Director.AnyOf(*%w[wxUSE_SPINBTN wxUSE_SPINCTRL]))
@@ -171,6 +174,7 @@ module WXRuby3
171
174
  Director.Spec(pkg, 'wxCheckListBox', requirements: %w[wxUSE_CHECKLISTBOX])
172
175
  Director.Spec(pkg, 'wxDataFormat', requirements: %w[wxUSE_CLIPBOARD])
173
176
  Director.Spec(pkg, 'wxDataObject', requirements: %w[wxUSE_CLIPBOARD])
177
+ Director.Spec(pkg, 'wxDataObjectSimpleBase', requirements: %w[wxUSE_CLIPBOARD])
174
178
  Director.Spec(pkg, 'wxClipboard', requirements: %w[wxUSE_CLIPBOARD])
175
179
  Director.Spec(pkg, 'wxDragDrop', requirements: %w[wxUSE_DRAG_AND_DROP])
176
180
  Director.Spec(pkg, 'wxContextHelpButton', director: Director::Button, requirements: %w[wxUSE_HELP])
@@ -218,6 +222,8 @@ module WXRuby3
218
222
  Director.Spec(pkg, 'wxRichTextHeaderFooterData', requirements: %w[wxUSE_PRINTING_ARCHITECTURE])
219
223
  Director.Spec(pkg, 'wxRichTextPrinting', requirements: %w[wxUSE_PRINTING_ARCHITECTURE])
220
224
  Director.Spec(pkg, 'wxSymbolPickerDialog', director: Director::Dialog)
225
+ # need to look into special needs
226
+ # Director.Spec(pkg, 'wxRichTextBufferDataObject')
221
227
  }
222
228
 
223
229
  Director.Package('Wx::STC', 'wxUSE_STC') { |pkg|
@@ -268,6 +274,7 @@ module WXRuby3
268
274
  Director.Spec(pkg, 'wxHtmlEasyPrinting', requirements: %w[wxUSE_PRINTING_ARCHITECTURE])
269
275
  Director.Spec(pkg, 'wxHtmlPrintout', requirements: %w[wxUSE_PRINTING_ARCHITECTURE])
270
276
  Director.Spec(pkg, 'wxHtmlListBox')
277
+ Director.Spec(pkg, 'wxHTMLDataObject') if Config.instance.wx_version >= '3.3'
271
278
  }
272
279
 
273
280
  Director.Package('Wx::AUI', 'wxUSE_AUI') { |pkg|
@@ -588,7 +588,7 @@ module WXRuby3
588
588
  end
589
589
 
590
590
  # special case bc SWIG causes trouble in Window.cpp
591
- map 'const wxRegion&', 'const wxRegion*' do
591
+ map 'const wxRegion&', 'const wxRegion*', as: 'Wx::Region' do
592
592
  map_out code: '$result = wxRuby_WrapWxObjectInRuby(new wxRegion(*static_cast<const wxRegion*> ($1)));'
593
593
  end
594
594
 
@@ -47,7 +47,7 @@ module WXRuby3
47
47
  map_argout as: {type: 'String', index: 1}, code: <<~__CODE
48
48
  if (result)
49
49
  {
50
- $result = rb_str_new( (const char*)data_buf$argnum.get(), data_size$argnum);
50
+ $result = rb_utf8_str_new( (const char*)data_buf$argnum.get(), data_size$argnum);
51
51
  }
52
52
  else
53
53
  $result = Qnil;
@@ -83,11 +83,20 @@ module WXRuby3
83
83
  map 'size_t len, const void* buf' do
84
84
 
85
85
  map_in from: {type: 'String', index: 1}, code: <<~__CODE
86
- $1 = RSTRING_LEN($input);
87
- $2 = (void*)StringValuePtr($input);
86
+ if (RTEST($input) && TYPE($input) == T_STRING)
87
+ {
88
+ $1 = RSTRING_LEN($input);
89
+ $2 = (void*)StringValuePtr($input);
90
+ }
91
+ else
92
+ {
93
+ $1 = 0; $2 = NULL;
94
+ }
88
95
  __CODE
89
96
 
90
- map_directorin code: '$input = rb_external_str_new( (const char *)buf, len );'
97
+ map_directorin code: '$input = rb_utf8_str_new( (const char *)buf, len );'
98
+
99
+ map_typecheck precedence: 'pointer', code: '$1 = (TYPE($input) == T_STRING);'
91
100
  end
92
101
 
93
102
  end # define