wxruby3 0.9.0.pre.rc.2 → 0.9.0.pre.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (96) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +30 -8
  3. data/README.md +3 -3
  4. data/ext/wxruby3/swig/wx.i +2 -0
  5. data/lib/wx/core/event_loop.rb +7 -0
  6. data/lib/wx/core/image.rb +33 -0
  7. data/lib/wx/core/listctrl.rb +17 -13
  8. data/lib/wx/core/log.rb +90 -0
  9. data/lib/wx/doc/bitmap.rb +11 -15
  10. data/lib/wx/doc/event_loop.rb +7 -0
  11. data/lib/wx/doc/extra/00_starting.md +6 -6
  12. data/lib/wx/doc/extra/02_lifecycles.md +9 -8
  13. data/lib/wx/doc/extra/09_exceptions.md +1 -1
  14. data/lib/wx/doc/extra/11_drawing_and_dc.md +4 -4
  15. data/lib/wx/doc/font.rb +1 -1
  16. data/lib/wx/doc/functions.rb +51 -23
  17. data/lib/wx/doc/gc_dc.rb +1 -1
  18. data/lib/wx/doc/image.rb +42 -12
  19. data/lib/wx/doc/list_ctrl.rb +32 -0
  20. data/lib/wx/doc/log.rb +28 -0
  21. data/lib/wx/doc/prt/printer_dc.rb +2 -2
  22. data/lib/wx/doc/scaled_dc.rb +1 -1
  23. data/lib/wx/doc/text_validator.rb +12 -0
  24. data/lib/wx/version.rb +1 -1
  25. data/rakelib/lib/core/mapping.rb +15 -10
  26. data/rakelib/lib/core/package.rb +3 -0
  27. data/rakelib/lib/core/spec.rb +21 -10
  28. data/rakelib/lib/core/spec_helper.rb +6 -0
  29. data/rakelib/lib/director/dialog.rb +25 -0
  30. data/rakelib/lib/director/event_loop.rb +26 -0
  31. data/rakelib/lib/director/functions.rb +44 -48
  32. data/rakelib/lib/director/image.rb +32 -0
  33. data/rakelib/lib/director/list_ctrl.rb +3 -2
  34. data/rakelib/lib/director/log.rb +64 -4
  35. data/rakelib/lib/director/text_entry.rb +25 -0
  36. data/rakelib/lib/director/text_validator.rb +8 -2
  37. data/rakelib/lib/director/variant.rb +17 -4
  38. data/rakelib/lib/extractor/function.rb +7 -7
  39. data/rakelib/lib/extractor/variable.rb +6 -6
  40. data/rakelib/lib/generate/doc/aui_manager.yaml +21 -0
  41. data/rakelib/lib/generate/doc/font.yaml +29 -0
  42. data/rakelib/lib/generate/doc/frame.yaml +23 -0
  43. data/rakelib/lib/generate/doc/fs_file.yaml +11 -0
  44. data/rakelib/lib/generate/doc/gdi_common.yaml +36 -0
  45. data/rakelib/lib/generate/doc/graphics_context.yaml +34 -0
  46. data/rakelib/lib/generate/doc/gui_event_loop.yaml +12 -0
  47. data/rakelib/lib/generate/doc/help_controller.yaml +24 -0
  48. data/rakelib/lib/generate/doc/icon.yaml +11 -0
  49. data/rakelib/lib/generate/doc/image.yaml +87 -0
  50. data/rakelib/lib/generate/doc/keyboard_state.yaml +19 -0
  51. data/rakelib/lib/generate/doc/list_ctrl.yaml +77 -0
  52. data/rakelib/lib/generate/doc/locale.yaml +12 -0
  53. data/rakelib/lib/generate/doc/log.yaml +86 -0
  54. data/rakelib/lib/generate/doc/mdi_frame.yaml +12 -0
  55. data/rakelib/lib/generate/doc/memory_dc.yaml +42 -0
  56. data/rakelib/lib/generate/doc/menu.yaml +17 -0
  57. data/rakelib/lib/generate/doc/menu_item.yaml +43 -0
  58. data/rakelib/lib/generate/doc/message_dialog.yaml +36 -0
  59. data/rakelib/lib/generate/doc/non_owned_window.yaml +14 -0
  60. data/rakelib/lib/generate/doc/notebook.yaml +18 -0
  61. data/rakelib/lib/generate/doc/pen.yaml +11 -0
  62. data/rakelib/lib/generate/doc/picker_base.yaml +19 -0
  63. data/rakelib/lib/generate/doc/platform_info.yaml +15 -0
  64. data/rakelib/lib/generate/doc/property_sheet_dialog.yaml +26 -0
  65. data/rakelib/lib/generate/doc/scroll_bar.yaml +11 -0
  66. data/rakelib/lib/generate/doc/scrolled_canvas.yaml +37 -0
  67. data/rakelib/lib/generate/doc/scrolled_control.yaml +37 -0
  68. data/rakelib/lib/generate/doc/scrolled_window.yaml +37 -0
  69. data/rakelib/lib/generate/doc/sizer.yaml +69 -0
  70. data/rakelib/lib/generate/doc/splash_screen.yaml +18 -0
  71. data/rakelib/lib/generate/doc/static_box.yaml +52 -0
  72. data/rakelib/lib/generate/doc/static_box_sizer.yaml +22 -0
  73. data/rakelib/lib/generate/doc/svg_file_dc.yaml +11 -0
  74. data/rakelib/lib/generate/doc/text_ctrl.yaml +19 -0
  75. data/rakelib/lib/generate/doc/text_entry.yaml +42 -0
  76. data/rakelib/lib/generate/doc/text_entry_dialog.yaml +17 -0
  77. data/rakelib/lib/generate/doc/timer_event.yaml +28 -0
  78. data/rakelib/lib/generate/doc/tool_bar.yaml +35 -0
  79. data/rakelib/lib/generate/doc/top_level_window.yaml +23 -0
  80. data/rakelib/lib/generate/doc/validator.yaml +12 -0
  81. data/rakelib/lib/generate/doc/variant.yaml +29 -0
  82. data/rakelib/lib/generate/doc/window.yaml +249 -0
  83. data/rakelib/lib/generate/doc/wizard_page_simple.yaml +14 -0
  84. data/rakelib/lib/generate/doc/xml_node.yaml +7 -0
  85. data/rakelib/lib/generate/doc/xml_resource.yaml +27 -0
  86. data/rakelib/lib/generate/doc.rb +35 -1
  87. data/rakelib/lib/specs/interfaces.rb +1 -0
  88. data/rakelib/lib/swig_runner.rb +37 -0
  89. data/tests/test_art.rb +9 -0
  90. data/tests/test_box_sizer.rb +161 -0
  91. data/tests/test_grid_sizer.rb +148 -0
  92. data/tests/test_list_ctrl.rb +53 -0
  93. data/tests/test_log.rb +163 -0
  94. data/tests/test_std_controls.rb +58 -0
  95. data/tests/test_timer.rb +95 -0
  96. metadata +59 -2
data/lib/wx/doc/image.rb CHANGED
@@ -11,23 +11,53 @@ module Wx
11
11
  # @return [Array<String>]
12
12
  def self.extensions; end
13
13
 
14
+ # Returns an array with the supported mime types of the available image handlers.
15
+ # @return [Array<String>]
16
+ def self.mime_types; end
17
+
14
18
  # returns a Hash with all supported extensions per available BitmapType
15
19
  # @return [Hash]
16
20
  def self.handler_extensions; end
17
21
 
18
- # Searches for an art file with basename 'name' and creates an Image if found.
19
- # Raises an ArgumentError if not found.
20
- # Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
21
- # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
22
- # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
23
- # caller's source file). The 'art_type' argument is set to <code>:icon</code>.
24
- # @param [String,Symbol] name base name of art file
25
- # @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
26
- # @param [Integer] index Index of the image to load in the case that the image file contains multiple images. This is only used by GIF, ICO and TIFF handlers. The default value (-1) means "choose the default image" and is interpreted as the first image (index=0) by the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
27
- # @return [Wx::Image]
28
- # @see Wx::ArtLocator::find_art
29
- def self.Image(name, bmp_type = nil, index=-1); end
22
+ module Histogram
23
+
24
+ # Calculate an image histogram key from given RGB values.
25
+ # @param [Integer] r Red value
26
+ # @param [Integer] g Green value
27
+ # @param [Integer] b Blue value
28
+ # @return [Integer] key value
29
+ def make_key(r,g,b) end
30
+
31
+ # Find first colour that is not used in the image and has higher RGB values than RGB(r, g, b)
32
+ # @param [Integer] r Red value
33
+ # @param [Integer] g Green value
34
+ # @param [Integer] b Blue value
35
+ # @return [Array(Integer,Integer,Integer),nil] RGB values of first unused colour or nil if none found
36
+ def find_first_unused_colour(r=1, g=0, b=0) end
37
+
38
+ end
39
+
40
+ # Computes the histogram of the image and fills a hash table, indexed
41
+ # with integer keys built as 0xRRGGBB, containing pairs (Array) of integer values.
42
+ # For each pair the first value is the index of the first pixel in the colour in the image
43
+ # and the second value the number of pixels having the colour in the image.
44
+ # The returned Hash object is extended with the {Wx::Image::Histogram} mixin.
45
+ # @return [Hash] hash object extended with {Wx::Image::Histogram}
46
+ def compute_histogram; end
30
47
 
31
48
  end
32
49
 
50
+ # Searches for an art file with basename 'name' and creates an Image if found.
51
+ # Raises an ArgumentError if not found.
52
+ # Wx::ArtLocator::find_art is used to look up the art file using ::Kernel#caller_locations to
53
+ # determine the values for the 'art_path' and 'art_owner' arguments ('art_path' is set to the
54
+ # absolute path to the folder holding the caller's code and 'art_owner' to the basename of the
55
+ # caller's source file). The 'art_type' argument is set to <code>:icon</code>.
56
+ # @param [String,Symbol] name base name of art file
57
+ # @param [Wx::BitmapType,nil] bmp_type bitmap type for art file (nil means any supported type)
58
+ # @param [Integer] index Index of the image to load in the case that the image file contains multiple images. This is only used by GIF, ICO and TIFF handlers. The default value (-1) means "choose the default image" and is interpreted as the first image (index=0) by the GIF and TIFF handler and as the largest and most colourful one by the ICO handler.
59
+ # @return [Wx::Image]
60
+ # @see Wx::ArtLocator::find_art
61
+ def self.Image(name, bmp_type = nil, index=-1); end
62
+
33
63
  end
@@ -0,0 +1,32 @@
1
+
2
+ class Wx::ListCtrl
3
+
4
+ include Enumerable
5
+
6
+ # Iterates all items in the list control passing each item (id) to the given block.
7
+ # @yieldparam [Integer] item
8
+ # @return [Object] result of last block iteration
9
+ def each(&block) end
10
+
11
+ # Iterates all selected items in the list control (like #get_next_item(item, Wx::LIST_NEXT_ALL, Wx::LIST_STATE_SELECTED))
12
+ # passing each item (id) to the given block.
13
+ # @yieldparam [Integer] item
14
+ # @return [Object] result of last block iteration
15
+ def each_selected(&block) end
16
+
17
+ # Returns array of selected items.
18
+ # @return [Array<Integer>] selected items
19
+ def get_selections; end
20
+
21
+ # Call this function to sort the items in the list control.
22
+ # The sorting method will call the given block repeatedly to compare two items from the list
23
+ # passing the <b>item data</b> for each item as well as the `data` argument given to the #sort_items method.
24
+ # The block should return 0 if the items are equal, negative value if the first item is less than the second
25
+ # one and positive value if the first one is greater than the second one.
26
+ # @param [Object] data user data to pass on to the sorting block
27
+ # @yieldparam [Object] item_data1 data for first item
28
+ # @yieldparam [Object] item_data2 data for second item
29
+ # @yieldparam [Object] data propagated data argument
30
+ def sort_items(data = nil, &block) end
31
+
32
+ end
data/lib/wx/doc/log.rb ADDED
@@ -0,0 +1,28 @@
1
+
2
+ module Wx
3
+
4
+ class Log
5
+
6
+ # Sets the current component for log info to the given value before executing the
7
+ # given block and restores the previous component value after the block returns.
8
+ # @param [String] comp component value for log info
9
+ def self.for_component(comp, &block) end
10
+
11
+ end
12
+
13
+ class LogStderr
14
+
15
+ # Creates a new LogStderr for the given file handle.
16
+ # Possible values are 2 for `stderr` and 1 for `stdout`.
17
+ # @param [Integer] fh file stream handle
18
+ def initialize(fh = 2) end
19
+ end
20
+
21
+ class LogNull
22
+
23
+ # Suspends logging before executing the given block and restarts logging when the block returns.
24
+ def self.no_log(&block) end
25
+
26
+ end
27
+
28
+ end
@@ -8,7 +8,7 @@ module Wx::PRT
8
8
  # @param [Wx::PRT::PrintData] print_data print_data defining the print settings
9
9
  # @yieldparam [Wx::PrinterDC] dc the PrinterDC instance to paint on
10
10
  # @return [Object] result of the block
11
- def self.draw_on(win) end
11
+ def self.draw_on(print_data) end
12
12
 
13
13
  end
14
14
 
@@ -19,7 +19,7 @@ module Wx::PRT
19
19
  # @param [Wx::PRT::PrintData] print_data print_data defining the print settings
20
20
  # @yieldparam [Wx::PostScriptDC] dc the PostScriptDC instance to paint on
21
21
  # @return [Object] result of the block
22
- def self.draw_on(win) end
22
+ def self.draw_on(print_data) end
23
23
 
24
24
  end
25
25
 
@@ -1,5 +1,5 @@
1
1
 
2
- class Wx
2
+ module Wx
3
3
 
4
4
  class ScaledDC < Wx::DC
5
5
 
@@ -0,0 +1,12 @@
1
+
2
+ class Wx::TextValidator
3
+
4
+ # @overload initialize(validator)
5
+ # Copy constructor.
6
+ # @param [Wx::TextValidator] validator validator to copy
7
+ # @overload initialize(style=Wx::FILTER_NONE)
8
+ # Constructor taking a style.
9
+ # @param [Integer] style One or more of the {Wx::TextValidatorStyle} styles. See #set_style.
10
+ def initialize(*args) end
11
+
12
+ end
data/lib/wx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wx
2
- WXRUBY_VERSION = '0.9.0-rc.2'
2
+ WXRUBY_VERSION = '0.9.0-rc.3'
3
3
  end
@@ -61,11 +61,16 @@ module WXRuby3
61
61
  "VOID_#{ctype.tr(' ', '_').upcase}"
62
62
  end
63
63
 
64
+ def self.strip_type_decl(ctype)
65
+ ctype = ctype.gsub(/const\s+/, '')
66
+ ctype.gsub!(/\s+(\*|&)/, '\1')
67
+ ctype.strip!
68
+ ctype.tr!('*&', '')
69
+ ctype
70
+ end
71
+
64
72
  def self.wx_type_to_rb(typestr)
65
- c_type = typestr.gsub(/const\s+/, '')
66
- c_type.gsub!(/\s+(\*|&)/, '\1')
67
- c_type.strip!
68
- c_type.tr!('*&', '')
73
+ c_type = strip_type_decl(typestr)
69
74
  (std_type_maps[c_type] || c_type).sub(/\Awx/, 'Wx::')
70
75
  end
71
76
 
@@ -854,15 +859,15 @@ module WXRuby3
854
859
  if @pattern.param_masks.first == parameters.first
855
860
  # just 'map' the parameter to itself
856
861
  param = parameters.shift # loose the 'mapped' parameter
857
- return [RubyArg[Typemap.wx_type_to_rb(param.type), param_offset], nil]
862
+ return [RubyArg[nil, param_offset], nil]
858
863
  end
859
864
  nil
860
865
  end
861
866
 
862
867
  def map_output(type)
863
- if matches?(type)
864
- return Typemap.wx_type_to_rb(type)
865
- end
868
+ # if matches?(type)
869
+ # return Typemap.wx_type_to_rb(type)
870
+ # end
866
871
  nil
867
872
  end
868
873
 
@@ -994,7 +999,7 @@ module WXRuby3
994
999
  if result
995
1000
  arg_in, arg_out = result
996
1001
  else
997
- arg_in = RubyArg.new(Typemap.wx_type_to_rb(parameters.first.type), param_offset)
1002
+ arg_in = RubyArg.new(nil, param_offset)
998
1003
  parameters.shift # loose the mapped param
999
1004
  end
1000
1005
  # store mapped param
@@ -1009,7 +1014,7 @@ module WXRuby3
1009
1014
  def map_output(type)
1010
1015
  result = nil
1011
1016
  list.reverse_each.detect { |map| result = map.map_output(type) }
1012
- result || Typemap.wx_type_to_rb(type)
1017
+ result
1013
1018
  end
1014
1019
 
1015
1020
  def to_swig
@@ -585,6 +585,9 @@ module WXRuby3
585
585
  # Integer constant reflecting the sub-release number of the wxWidgets release used to build wxRuby
586
586
  WXWIDGETS_SUBRELEASE_NUMBER = \#{Wx::WXWIDGETS_SUBRELEASE_NUMBER}
587
587
 
588
+ # Integer constant reflecting the wxWidgets wxDEBUG_LEVEL
589
+ WXWIDGETS_DEBUG_LEVEL = \#{Wx::WXWIDGETS_DEBUG_LEVEL}
590
+
588
591
  # Boolean constant indicating if wxRuby was build in debug (true) or release (false) mode
589
592
  DEBUG = \#{Wx::DEBUG}
590
593
 
@@ -43,6 +43,7 @@ module WXRuby3
43
43
  @interface_extensions = ::Hash.new
44
44
  @folded_bases = ::Hash.new
45
45
  @abstracts = ::Hash.new
46
+ @disowned_alloc = ::Set.new
46
47
  @mixins = ::Set.new
47
48
  @included_mixins = ::Hash.new
48
49
  @items = [modname]
@@ -165,7 +166,7 @@ module WXRuby3
165
166
  @gc_type = :GC_NEVER
166
167
  else
167
168
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
168
- names.each {|n| @gc_type[n] = :GC_NEVER }
169
+ names.flatten.each {|n| @gc_type[n] = :GC_NEVER }
169
170
  end
170
171
  self
171
172
  end
@@ -175,7 +176,7 @@ module WXRuby3
175
176
  @gc_type = :GC_MANAGE_AS_OBJECT
176
177
  else
177
178
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
178
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_OBJECT }
179
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_OBJECT }
179
180
  end
180
181
  self
181
182
  end
@@ -185,7 +186,7 @@ module WXRuby3
185
186
  @gc_type = :GC_MANAGE_AS_WINDOW
186
187
  else
187
188
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
188
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_WINDOW }
189
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_WINDOW }
189
190
  end
190
191
  self
191
192
  end
@@ -195,7 +196,7 @@ module WXRuby3
195
196
  @gc_type = :GC_MANAGE_AS_FRAME
196
197
  else
197
198
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
198
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_FRAME }
199
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_FRAME }
199
200
  end
200
201
  self
201
202
  end
@@ -205,7 +206,7 @@ module WXRuby3
205
206
  @gc_type = :GC_MANAGE_AS_DIALOG
206
207
  else
207
208
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
208
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_DIALOG }
209
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_DIALOG }
209
210
  end
210
211
  self
211
212
  end
@@ -215,7 +216,7 @@ module WXRuby3
215
216
  @gc_type = :GC_MANAGE_AS_EVENT
216
217
  else
217
218
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
218
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_EVENT }
219
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_EVENT }
219
220
  end
220
221
  self
221
222
  end
@@ -225,7 +226,7 @@ module WXRuby3
225
226
  @gc_type = :GC_MANAGE_AS_SIZER
226
227
  else
227
228
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
228
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_SIZER }
229
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_SIZER }
229
230
  end
230
231
  self
231
232
  end
@@ -235,7 +236,7 @@ module WXRuby3
235
236
  @gc_type = :GC_MANAGE_AS_REFCOUNTED
236
237
  else
237
238
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
238
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_REFCOUNTED }
239
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_REFCOUNTED }
239
240
  end
240
241
  self
241
242
  end
@@ -245,7 +246,7 @@ module WXRuby3
245
246
  @gc_type = :GC_MANAGE_AS_UNTRACKED_REFCOUNTED
246
247
  else
247
248
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
248
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_UNTRACKED_REFCOUNTED }
249
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_UNTRACKED_REFCOUNTED }
249
250
  end
250
251
  self
251
252
  end
@@ -255,7 +256,7 @@ module WXRuby3
255
256
  @gc_type = :GC_MANAGE_AS_UNTRACKED
256
257
  else
257
258
  @gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
258
- names.each {|n| @gc_type[n] = :GC_MANAGE_AS_UNTRACKED }
259
+ names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_UNTRACKED }
259
260
  end
260
261
  self
261
262
  end
@@ -283,6 +284,16 @@ module WXRuby3
283
284
  self
284
285
  end
285
286
 
287
+ def allocate_disowned(cls)
288
+ @disowned_alloc << cls
289
+ post_processors << :fix_disowned_alloc unless post_processors.include? :fix_disowned_alloc
290
+ self
291
+ end
292
+
293
+ def allocate_disowned?(cls)
294
+ @disowned_alloc.include?(cls)
295
+ end
296
+
286
297
  def abstract?(cls)
287
298
  @abstracts.has_key?(cls) && @abstracts[cls]
288
299
  end
@@ -171,6 +171,12 @@ module WXRuby3
171
171
  ifspec.included_mixins
172
172
  end
173
173
 
174
+ def allocate_disowned?(classdef_or_name)
175
+ class_def = (Extractor::ClassDef === classdef_or_name ?
176
+ classdef_or_name : classdef_for_name(classdef_or_name))
177
+ ifspec.allocate_disowned?(class_def.name)
178
+ end
179
+
174
180
  def has_virtuals?(classdef_or_name)
175
181
  class_def = (Extractor::ClassDef === classdef_or_name ?
176
182
  classdef_or_name : classdef_for_name(classdef_or_name))
@@ -28,6 +28,31 @@ module WXRuby3
28
28
  }
29
29
  __HEREDOC
30
30
  when 'wxMessageDialog'
31
+ spec.ignore 'wxMessageDialog::ButtonLabel'
32
+ spec.map 'const ButtonLabel&' => 'String,Integer' do
33
+ add_header_code 'typedef wxMessageDialog::ButtonLabel ButtonLabel;'
34
+ map_in temp: 'std::unique_ptr<wxMessageDialog::ButtonLabel> tmp', code: <<~__CODE
35
+ if (TYPE($input) == T_STRING)
36
+ {
37
+ tmp = std::make_unique<wxMessageDialog::ButtonLabel> (RSTR_TO_WXSTR($input));
38
+ }
39
+ else if (TYPE($input) == T_FIXNUM || wxRuby_IsAnEnum($input))
40
+ {
41
+ tmp = std::make_unique<wxMessageDialog::ButtonLabel> (NUM2INT($input));
42
+ }
43
+ else
44
+ {
45
+ rb_raise(rb_eArgError, "Expected string or stock id for %d", $argnum-1);
46
+ }
47
+ $1 = tmp.get();
48
+ __CODE
49
+ map_directorin code: <<~__CODE
50
+ if ($1.GetStockId() != wxID_NONE)
51
+ { $input = INT2NUM($1.GetStockId()); }
52
+ else
53
+ { $input = WXSTR_TO_RSTR($1.GetAsString()); }
54
+ __CODE
55
+ end
31
56
  when 'wxFontDialog'
32
57
  # ignore the non-const version
33
58
  if Config.platform == :macosx && Config.instance.wx_version < '3.3'
@@ -0,0 +1,26 @@
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 GUIEventLoop < Director
11
+
12
+ def setup
13
+ super
14
+ spec.items << 'wxEventLoopBase'
15
+ spec.gc_as_untracked
16
+ spec.disable_proxies
17
+ spec.make_concrete 'wxGUIEventLoop'
18
+ spec.fold_bases 'wxGUIEventLoop' => 'wxEventLoopBase'
19
+ spec.ignore 'wxEventLoopBase::GetActive',
20
+ 'wxEventLoopBase::SetActive'
21
+ end
22
+ end # class GUIEventLoop
23
+
24
+ end # class Director
25
+
26
+ end # module WXRuby3
@@ -30,93 +30,89 @@ module WXRuby3
30
30
  // sprintf in ruby, then pass the composed message directly to the
31
31
  // log. This also avoids format string attacks.
32
32
 
33
+ static WxRuby_ID __filename_id("filename");
34
+ static WxRuby_ID __line_id("line");
35
+ static WxRuby_ID __func_id("func");
36
+ static WxRuby_ID __comp_id("component");
37
+
38
+ static const char* __wxruby_component = "wxapp";
39
+
40
+ // As the wxw logger will only make synchronous use of the filename, func and component pointers while
41
+ // processing the log entry and never store them we simply gather pointers but no copies
42
+ static void do_log(wxLogLevel lvl, int argc, VALUE *argv, ...)
43
+ {
44
+ const char* filename = nullptr;
45
+ int line = 0;
46
+ const char* func = nullptr;
47
+ const char* component = __wxruby_component;
48
+
49
+ if (argc>1 && TYPE(argv[argc-1]) == T_HASH)
50
+ {
51
+ VALUE rb_hash = argv[--argc];
52
+ VALUE rb_fnm = rb_hash_aref(rb_hash, ID2SYM(__filename_id.get_id()));
53
+ if (!NIL_P(rb_fnm) && TYPE(rb_fnm) == T_STRING) filename = StringValuePtr(rb_fnm);
54
+ VALUE rb_ln = rb_hash_aref(rb_hash, ID2SYM(__line_id.get_id()));
55
+ if (!NIL_P(rb_ln) && TYPE(rb_ln) == T_FIXNUM) line = NUM2INT(rb_ln);
56
+ VALUE rb_func = rb_hash_aref(rb_hash, ID2SYM(__func_id.get_id()));
57
+ if (!NIL_P(rb_func) && TYPE(rb_func) == T_STRING) func = StringValuePtr(rb_func);
58
+ VALUE rb_comp = rb_hash_aref(rb_hash, ID2SYM(__comp_id.get_id()));
59
+ if (!NIL_P(rb_comp) && TYPE(rb_comp) == T_STRING) component = StringValuePtr(rb_comp);
60
+ }
61
+
62
+ VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
63
+ va_list list;
64
+ va_start(list, argv); // just a dummy to satisfy wxLogger::LogV
65
+ wxLogger(lvl, filename, line, func, component).LogV(RSTR_TO_WXSTR(log_msg), list);
66
+ }
67
+
33
68
  // Log a Wx message with the given level to the current Wx log output
34
69
  static VALUE log_generic(int argc, VALUE *argv, VALUE self)
35
70
  {
36
- if ( wxLog::IsEnabled() )
37
- {
38
- wxLogLevel lvl = static_cast<wxLogLevel> (NUM2INT(argv[0]));
39
- VALUE log_msg = argc==2 ? argv[1] : rb_f_sprintf(argc-1, &argv[1]);
40
- wxLog::OnLog( lvl,
41
- wxString(StringValuePtr(log_msg), wxConvUTF8),
42
- time(NULL) );
43
- }
71
+ wxLogLevel lvl = static_cast<wxLogLevel> (NUM2INT(argv[0]));
72
+ do_log(lvl, argc-1, &argv[1]);
44
73
  return Qnil;
45
74
  }
46
75
 
47
76
  // Log a Wx low prio Message to the current Wx log output
48
77
  static VALUE log_info(int argc, VALUE *argv, VALUE self)
49
78
  {
50
- if ( wxLog::IsEnabled() )
51
- {
52
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
53
- wxLog::OnLog( wxLOG_Info,
54
- wxString(StringValuePtr(log_msg), wxConvUTF8),
55
- time(NULL) );
56
- }
79
+ do_log(wxLOG_Info, argc, argv);
57
80
  return Qnil;
58
81
  }
59
82
 
60
83
  // Log a Wx verbose Message to the current Wx log output
61
84
  static VALUE log_verbose(int argc, VALUE *argv, VALUE self)
62
85
  {
63
- if ( wxLog::IsEnabled() && wxLog::GetVerbose () )
64
- {
65
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
66
- wxLog::OnLog( wxLOG_Info,
67
- wxString(StringValuePtr(log_msg), wxConvUTF8),
68
- time(NULL) );
69
- }
86
+ if (wxLog::GetVerbose ())
87
+ do_log(wxLOG_Info, argc, argv);
70
88
  return Qnil;
71
89
  }
72
90
 
73
91
  // Log a Wx Message to the current Wx log output
74
92
  static VALUE log_message(int argc, VALUE *argv, VALUE self)
75
93
  {
76
- if ( wxLog::IsEnabled() )
77
- {
78
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
79
- wxLog::OnLog( wxLOG_Message,
80
- wxString(StringValuePtr(log_msg), wxConvUTF8),
81
- time(NULL) );
82
- }
94
+ do_log(wxLOG_Message, argc, argv);
83
95
  return Qnil;
84
96
  }
85
97
 
86
98
  // Log a Wx Warning message to the current Wx log output
87
99
  static VALUE log_warning(int argc, VALUE *argv, VALUE self)
88
100
  {
89
- if ( wxLog::IsEnabled() )
90
- {
91
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
92
- wxLog::OnLog( wxLOG_Warning,
93
- wxString(StringValuePtr(log_msg), wxConvUTF8),
94
- time(NULL) );
95
- }
101
+ do_log(wxLOG_Warning, argc, argv);
96
102
  return Qnil;
97
103
  }
98
104
 
99
105
  // Log an error message to the current output
100
106
  static VALUE log_error(int argc, VALUE *argv, VALUE self)
101
107
  {
102
- if ( wxLog::IsEnabled() )
103
- {
104
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
105
- wxLog::OnLog( wxLOG_Error,
106
- wxString(StringValuePtr(log_msg), wxConvUTF8),
107
- time(NULL) );
108
- }
108
+ do_log(wxLOG_Error, argc, argv);
109
109
  return Qnil;
110
110
  }
111
111
 
112
112
  // Log a debug message
113
113
  static VALUE log_debug(int argc, VALUE *argv, VALUE self)
114
114
  {
115
- if (wxLog::IsLevelEnabled(wxLOG_Debug, wxASCII_STR(wxLOG_COMPONENT)))
116
- {
117
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
118
- wxLogDebug(wxString(StringValuePtr(log_msg), wxConvUTF8));
119
- }
115
+ do_log(wxLOG_Debug, argc, argv);
120
116
  return Qnil;
121
117
  }
122
118
 
@@ -77,6 +77,19 @@ module WXRuby3
77
77
  return ext_ary;
78
78
  }
79
79
 
80
+ static VALUE mime_types()
81
+ {
82
+ VALUE ext_ary = rb_ary_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
+ rb_ary_push(ext_ary, WXSTR_TO_RSTR(handler->GetMimeType()));
89
+ }
90
+ return ext_ary;
91
+ }
92
+
80
93
  static VALUE handler_extensions()
81
94
  {
82
95
  VALUE ext_hash = rb_hash_new();
@@ -157,6 +170,25 @@ module WXRuby3
157
170
  return rb_str_new( (const char*)rgb_data, length);
158
171
  }
159
172
  __HEREDOC
173
+ # ignore this so we do not have to wrap wxImageHistogram
174
+ spec.ignore 'wxImage::ComputeHistogram'
175
+ # add custom method simply returning Hash; finish off in pure Ruby
176
+ spec.add_extend_code 'wxImage', <<~__HEREDOC
177
+ VALUE compute_histogram()
178
+ {
179
+ VALUE rb_img_hist = rb_hash_new();
180
+ wxImageHistogram img_hist;
181
+ $self->ComputeHistogram(img_hist);
182
+ for (auto pair : img_hist)
183
+ {
184
+ VALUE rb_hist_entry = rb_ary_new();
185
+ rb_ary_push(rb_hist_entry, ULL2NUM(pair.second.index));
186
+ rb_ary_push(rb_hist_entry, ULL2NUM(pair.second.value));
187
+ rb_hash_aset(rb_img_hist, ULL2NUM(pair.first), rb_hist_entry);
188
+ }
189
+ return rb_img_hist;
190
+ }
191
+ __HEREDOC
160
192
  spec.do_not_generate(:functions)
161
193
  end
162
194
  end # class Image
@@ -100,6 +100,7 @@ module WXRuby3
100
100
  VALUE items = rb_ary_new();
101
101
  rb_ary_push(items, (VALUE)item1);
102
102
  rb_ary_push(items, (VALUE)item2);
103
+ rb_ary_push(items, (VALUE)data);
103
104
  VALUE the_order = rb_yield(items);
104
105
  return NUM2INT(the_order);
105
106
  }
@@ -183,9 +184,9 @@ module WXRuby3
183
184
  return Qnil;
184
185
  }
185
186
 
186
- void sort_items()
187
+ void sort_items(VALUE data = Qnil)
187
188
  {
188
- self->SortItems(wxListCtrl_SortByYielding, 0);
189
+ $self->SortItems(wxListCtrl_SortByYielding, static_cast<wxIntPtr> (data));
189
190
  }
190
191
  __HEREDOC
191
192
  super