wxruby3 0.9.0.pre.beta.9-x64-mingw-ucrt → 0.9.0.pre.beta.11-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (71) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxbase32u_gcc_custom.dll +0 -0
  3. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  4. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  5. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  6. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  7. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  8. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  9. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  10. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  11. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  12. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  13. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  14. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  15. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  16. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  17. data/lib/wx/core/bitmap.rb +7 -0
  18. data/lib/wx/core/choice.rb +3 -0
  19. data/lib/wx/core/combobox.rb +3 -0
  20. data/lib/wx/core/controlwithitems.rb +98 -2
  21. data/lib/wx/core/data_object.rb +74 -6
  22. data/lib/wx/core/icon.rb +7 -1
  23. data/lib/wx/core/imagelist.rb +11 -0
  24. data/lib/wx/core/listbox.rb +3 -0
  25. data/lib/wx/core/point.rb +21 -10
  26. data/lib/wx/core/real_point.rb +21 -10
  27. data/lib/wx/core/rect.rb +2 -2
  28. data/lib/wx/core/size.rb +12 -5
  29. data/lib/wx/doc/data_object.rb +104 -0
  30. data/lib/wx/doc/gdi_common.rb +33 -5
  31. data/lib/wx/doc/gen/control_with_items.rb +3 -131
  32. data/lib/wx/doc/gen/core.rb +2 -2
  33. data/lib/wx/doc/gen/data_object.rb +0 -20
  34. data/lib/wx/doc/gen/data_object_simple_base.rb +10 -0
  35. data/lib/wx/doc/gen/image_list.rb +9 -10
  36. data/lib/wx/doc/gen/progress_dialog.rb +0 -20
  37. data/lib/wx/doc/gen/prt/print_data.rb +5 -0
  38. data/lib/wx/doc/gen/scaled_dc.rb +10 -0
  39. data/lib/wx/doc/progress_dialog.rb +37 -0
  40. data/lib/wx/doc/scaled_dc.rb +16 -0
  41. data/lib/wx/global_const.rb +4 -3
  42. data/lib/wx/version.rb +1 -1
  43. data/lib/wxruby_aui.so +0 -0
  44. data/lib/wxruby_core.so +0 -0
  45. data/lib/wxruby_grid.so +0 -0
  46. data/lib/wxruby_html.so +0 -0
  47. data/lib/wxruby_pg.so +0 -0
  48. data/lib/wxruby_prt.so +0 -0
  49. data/lib/wxruby_rbn.so +0 -0
  50. data/lib/wxruby_rtc.so +0 -0
  51. data/lib/wxruby_stc.so +0 -0
  52. data/rakelib/lib/config/mingw.rb +3 -0
  53. data/samples/dialogs/dialogs.rb +70 -50
  54. data/samples/drawing/maths_images.rb +1 -1
  55. data/samples/sampler/ext.rb +3 -3
  56. data/samples/sampler/stc_editor.rb +19 -19
  57. data/samples/sampler/txt_editor.rb +2 -2
  58. data/samples/treectrl/treectrl.rb +32 -30
  59. data/tests/lib/wxapp_runner.rb +64 -0
  60. data/tests/test_basic.rb +0 -5
  61. data/tests/test_clipboard.rb +114 -17
  62. data/tests/test_dialog.rb +2 -13
  63. data/tests/test_event_handling.rb +2 -13
  64. data/tests/test_events.rb +2 -6
  65. data/tests/test_geometry.rb +54 -17
  66. data/tests/test_intl.rb +2 -15
  67. data/tests/test_item_data.rb +69 -15
  68. data/tests/test_variant.rb +1 -15
  69. data/tests/testapp.rb +0 -5
  70. data/tests/testapp_noframe.rb +0 -5
  71. metadata +13 -3
@@ -38,12 +38,12 @@ end
38
38
  # otherwise samples using 'include Wx' (or other modules) will fail on referencing
39
39
  # a (module) method unscoped from one of these included modules
40
40
  module ::Kernel
41
- def method_missing(name, *args)
41
+ def method_missing(name, *args, &block)
42
42
  if self.class.name.start_with?('WxRuby::Sample::SampleLoader_') && (scope = self.class.name.split('::')).size > 3
43
43
  top_mod = Object.const_get(scope[0,3].join('::'))
44
- return top_mod.__send__(name, *args) if top_mod.respond_to?(name)
44
+ return top_mod.__send__(name, *args, &block) if top_mod.respond_to?(name)
45
45
  top_mod.included_modules.each do |imod|
46
- return imod.__send__(name, *args) if imod.respond_to?(name)
46
+ return imod.__send__(name, *args, &block) if imod.respond_to?(name)
47
47
  end
48
48
  end
49
49
  super
@@ -117,21 +117,21 @@ module WxRuby
117
117
  style_set_foreground(Wx::STC::STC_STYLE_DEFAULT, Wx::BLACK);
118
118
  style_set_background(Wx::STC::STC_STYLE_DEFAULT, Wx::WHITE);
119
119
  style_clear_all
120
- style_set_foreground(Wx::STC::STC_STYLE_LINENUMBER, Wx::Colour.new('SlateGray'))
120
+ style_set_foreground(Wx::STC::STC_STYLE_LINENUMBER, Wx::Colour.new('Dark Grey'))
121
121
  style_set_background(Wx::STC::STC_STYLE_LINENUMBER, Wx::WHITE);
122
122
  style_set_foreground(Wx::STC::STC_STYLE_INDENTGUIDE, Wx::LIGHT_GREY);
123
- set_whitespace_background(false, Wx::Colour.new('DarkSlateGray'))
124
- style_set_foreground(SCE_RB_COMMENTLINE, Wx::Colour.new('DARKGREEN'))
123
+ set_whitespace_background(false, Wx::Colour.new('Dark Slate Grey'))
124
+ style_set_foreground(SCE_RB_COMMENTLINE, Wx::Colour.new('Dark Green'))
125
125
  style_set_bold(SCE_RB_COMMENTLINE, true)
126
126
  style_set_foreground(SCE_RB_WORD, Wx::BLACK)
127
127
  style_set_bold(SCE_RB_WORD, true)
128
- style_set_foreground(SCE_RB_OPERATOR, Wx::Colour.new('Teal'))
128
+ style_set_foreground(SCE_RB_OPERATOR, Wx::Colour.new('Dark Olive Green'))
129
129
  style_set_bold(SCE_RB_OPERATOR, true)
130
- style_set_foreground(SCE_RB_POD, Wx::Colour.new('GREY'))
130
+ style_set_foreground(SCE_RB_POD, Wx::Colour.new('Grey'))
131
131
  style_set_foreground(SCE_RB_NUMBER, Wx::BLUE)
132
132
  style_set_foreground(SCE_RB_STRING, c_maroon)
133
133
  style_set_foreground(SCE_RB_CHARACTER, Wx::RED)
134
- style_set_foreground(SCE_RB_SYMBOL, Wx::Colour.new('DARKBLUE'))
134
+ style_set_foreground(SCE_RB_SYMBOL, Wx::Colour.new('Navy'))
135
135
  style_set_bold(SCE_RB_SYMBOL, true)
136
136
  if Wx::WXWIDGETS_VERSION >= '3.3.0'
137
137
  style_set_foreground(SCE_RB_HERE_DELIM, Wx::BLACK)
@@ -145,8 +145,8 @@ module WxRuby
145
145
  style_set_foreground(SCE_RB_STRING_QR, c_maroon)
146
146
  style_set_foreground(SCE_RB_STRING_QW, c_maroon)
147
147
  end
148
- bg = Wx::Colour.new('LightGray')
149
- fg = Wx::Colour.new('DarkCyan')
148
+ bg = Wx::Colour.new('Light Grey')
149
+ fg = Wx::Colour.new('Cadet Blue')
150
150
  set_fold_margin_colour(true, bg)
151
151
  set_fold_margin_hi_colour(true, bg)
152
152
  marker_set_foreground(Wx::STC::STC_MARKNUM_FOLDER, fg)
@@ -156,8 +156,8 @@ module WxRuby
156
156
  end
157
157
 
158
158
  def dark_theme
159
- bg = Wx::Colour.new('DarkSlateGray')
160
- c_str = Wx::Colour.new('LimeGreen')
159
+ bg = Wx::Colour.new('Dark Slate Grey')
160
+ c_str = Wx::Colour.new('Lime Green')
161
161
  style_set_background(Wx::STC::STC_STYLE_DEFAULT, bg)
162
162
  style_set_foreground(Wx::STC::STC_STYLE_DEFAULT, Wx::WHITE)
163
163
  style_clear_all
@@ -166,28 +166,28 @@ module WxRuby
166
166
  style_set_foreground(Wx::STC::STC_STYLE_INDENTGUIDE, bg);
167
167
  set_whitespace_background(true, bg)
168
168
  style_set_eol_filled(SCE_RB_DEFAULT, true)
169
- style_set_foreground(SCE_RB_COMMENTLINE, Wx::Colour.new('Silver'))
169
+ style_set_foreground(SCE_RB_COMMENTLINE, Wx::Colour.new('Light Grey'))
170
170
  style_set_background(SCE_RB_COMMENTLINE, bg)
171
171
  style_set_bold(SCE_RB_COMMENTLINE, true)
172
- style_set_foreground(SCE_RB_WORD, Wx::Colour.new('Chocolate'))
172
+ style_set_foreground(SCE_RB_WORD, Wx::Colour.new('Coral'))
173
173
  style_set_background(SCE_RB_WORD, bg)
174
174
  style_set_bold(SCE_RB_WORD, true)
175
- style_set_foreground(SCE_RB_OPERATOR, Wx::Colour.new('LightCyan'))
175
+ style_set_foreground(SCE_RB_OPERATOR, Wx::Colour.new('Light Grey'))
176
176
  style_set_background(SCE_RB_OPERATOR, bg)
177
177
  style_set_bold(SCE_RB_OPERATOR, true)
178
- style_set_foreground(SCE_RB_POD, Wx::Colour.new('Gray'))
178
+ style_set_foreground(SCE_RB_POD, Wx::Colour.new('Grey'))
179
179
  style_set_background(SCE_RB_POD, bg)
180
- style_set_foreground(SCE_RB_NUMBER, Wx::Colour.new('DeepSkyBlue'))
180
+ style_set_foreground(SCE_RB_NUMBER, Wx::Colour.new('Cyan'))
181
181
  style_set_background(SCE_RB_NUMBER, bg)
182
182
  style_set_foreground(SCE_RB_STRING, c_str)
183
183
  style_set_background(SCE_RB_STRING, bg)
184
- style_set_foreground(SCE_RB_CHARACTER, Wx::Colour.new('YellowGreen'))
184
+ style_set_foreground(SCE_RB_CHARACTER, Wx::Colour.new('Yellow Green'))
185
185
  style_set_background(SCE_RB_CHARACTER, bg)
186
186
  style_set_foreground(SCE_RB_SYMBOL, Wx::Colour.new('Gold'))
187
187
  style_set_background(SCE_RB_SYMBOL, bg)
188
188
  style_set_bold(SCE_RB_SYMBOL, true)
189
189
  if Wx::WXWIDGETS_VERSION >= '3.3.0'
190
- style_set_foreground(SCE_RB_HERE_DELIM, Wx::Colour.new('Chocolate'))
190
+ style_set_foreground(SCE_RB_HERE_DELIM, Wx::Colour.new('Coral'))
191
191
  style_set_bold(SCE_RB_HERE_DELIM, true)
192
192
  style_set_foreground(SCE_RB_HERE_Q, c_str)
193
193
  style_set_foreground(SCE_RB_HERE_QQ, c_str)
@@ -198,8 +198,8 @@ module WxRuby
198
198
  style_set_foreground(SCE_RB_STRING_QR, c_str)
199
199
  style_set_foreground(SCE_RB_STRING_QW, c_str)
200
200
  end
201
- bg = Wx::Colour.new('CadetBlue')
202
- fg = Wx::Colour.new('Chocolate')
201
+ bg = Wx::Colour.new('Cadet Blue')
202
+ fg = Wx::Colour.new('Coral')
203
203
  set_fold_margin_colour(true, bg)
204
204
  set_fold_margin_hi_colour(true, bg)
205
205
  marker_set_foreground(Wx::STC::STC_MARKNUM_FOLDER, fg)
@@ -35,9 +35,9 @@ module WxRuby
35
35
  end
36
36
 
37
37
  def dark_theme
38
- self.background_colour = Wx::Colour.new('DarkSlateGray')
38
+ self.background_colour = Wx::Colour.new('Dark Slate Grey')
39
39
  self.foreground_colour = Wx::WHITE
40
- self.set_default_style(txtatt = Wx::TextAttr.new(Wx::WHITE, Wx::Colour.new('DarkSlateGray'), self.font))
40
+ self.set_default_style(txtatt = Wx::TextAttr.new(Wx::WHITE, Wx::Colour.new('Dark Slate Grey'), self.font))
41
41
  self.set_style(0, self.get_last_position, txtatt)
42
42
  end
43
43
 
@@ -262,39 +262,41 @@ class MyTreeCtrl < Wx::TreeCtrl
262
262
  end
263
263
 
264
264
  def create_buttons_image_list(size)
265
- if size < 0
266
- self.buttons_image_list = nil
267
- return
268
- end
269
-
270
- # Make an image list containing small icons
271
- images = Wx::ImageList.new(size, size, true)
265
+ unless Wx::PLATFORM == 'WXMSW'
266
+ if size < 0
267
+ self.buttons_image_list = nil
268
+ return
269
+ end
272
270
 
273
- # should correspond to TreeCtrlIcon_xxx enum
274
- Wx::BusyCursor.busy do
275
- icons = if @alternate_images
276
- [Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
277
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
278
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM),
279
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM)
280
- ]
281
- else
282
- icon_size = Wx::Size.new(@image_size, @image_size)
283
- ic1 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_LIST, icon_size)
284
- ic2 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER_OPEN, Wx::ART_LIST, icon_size)
285
- [ic1, ic1, ic2, ic2]
286
- end
271
+ # Make an image list containing small icons
272
+ images = Wx::ImageList.new(size, size, true)
287
273
 
288
- icons.each do |ic|
289
- if ic.width == size
290
- images.add(ic)
291
- else
292
- resized = ic.convert_to_image.rescale(size, size)
293
- images.add(Wx::Bitmap.new(resized))
274
+ # should correspond to TreeCtrlIcon_xxx enum
275
+ Wx::BusyCursor.busy do
276
+ icons = if @alternate_images
277
+ [Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
278
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
279
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM),
280
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM)
281
+ ]
282
+ else
283
+ icon_size = Wx::Size.new(@image_size, @image_size)
284
+ ic1 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_LIST, icon_size)
285
+ ic2 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER_OPEN, Wx::ART_LIST, icon_size)
286
+ [ic1, ic1, ic2, ic2]
287
+ end
288
+
289
+ icons.each do |ic|
290
+ if ic.width == size
291
+ images.add(ic)
292
+ else
293
+ resized = ic.convert_to_image.rescale(size, size)
294
+ images.add(Wx::Bitmap.new(resized))
295
+ end
294
296
  end
295
- end
296
297
 
297
- self.buttons_image_list = images
298
+ self.buttons_image_list = images
299
+ end
298
300
  end
299
301
  end
300
302
 
@@ -1454,7 +1456,7 @@ class MyFrame < Wx::Frame
1454
1456
  end
1455
1457
 
1456
1458
  def on_toggle_buttons(event)
1457
- unless Wx.has_feature?(:WXMSW)
1459
+ unless Wx::PLATFORM == 'WXMSW'
1458
1460
  if Wx::THE_APP.show_buttons
1459
1461
  @treectrl.create_buttons_image_list(-1)
1460
1462
  Wx::get_app.show_buttons = false
@@ -0,0 +1,64 @@
1
+
2
+ require 'test/unit'
3
+ require 'test/unit/ui/console/testrunner'
4
+ require 'wx'
5
+
6
+ module Wx::SF
7
+
8
+ module Test
9
+
10
+ class App < Wx::App
11
+ def initialize(test_runner, start_mtd)
12
+ super()
13
+ @test_runner = test_runner
14
+ @start_mtd = start_mtd
15
+ end
16
+
17
+ def on_init
18
+ @result = @start_mtd.bind(@test_runner).call
19
+ false
20
+ end
21
+
22
+ attr_reader :result
23
+ end
24
+
25
+ if defined? ::IntelliJ
26
+ require 'test/unit/ui/teamcity/testrunner'
27
+ BaseRunner = ::Test::Unit::UI::TeamCity::TestRunner
28
+ else
29
+ BaseRunner = ::Test::Unit::UI::Console::TestRunner
30
+ end
31
+
32
+ class Runner < BaseRunner
33
+
34
+ org_start_mtd = instance_method :start
35
+ define_method :start do
36
+ (app = Wx::SF::Test::App.new(self, org_start_mtd)).run
37
+ app.result
38
+ end
39
+
40
+ end
41
+
42
+ end
43
+
44
+ end
45
+
46
+ module Test
47
+ module Unit
48
+ AutoRunner.register_runner(:wxapp) do |auto_runner|
49
+ Wx::SF::Test::Runner
50
+ end
51
+ AutoRunner.default_runner = :wxapp
52
+ if defined? ::IntelliJ
53
+ class AutoRunner
54
+ alias :wx_initialize :initialize
55
+ private :wx_initialize
56
+
57
+ def initialize(*args)
58
+ wx_initialize(*args)
59
+ @runner = AutoRunner.default_runner
60
+ end
61
+ end
62
+ end
63
+ end
64
+ end
data/tests/test_basic.rb CHANGED
@@ -13,8 +13,3 @@ class BasicTests < Test::Unit::TestCase
13
13
  end
14
14
 
15
15
  end
16
-
17
- if $0 == __FILE__
18
- require 'test/unit/ui/console/testrunner'
19
- Test::Unit::UI::Console::TestRunner.run(BasicTests)
20
- end
@@ -1,6 +1,5 @@
1
- require 'test/unit'
2
- require 'test/unit/ui/console/testrunner'
3
- require 'wx'
1
+
2
+ require_relative './lib/wxapp_runner'
4
3
 
5
4
  class TestTextData < Test::Unit::TestCase
6
5
  # Using an in-built class
@@ -31,7 +30,7 @@ class TestTextData < Test::Unit::TestCase
31
30
  Wx::Clipboard.open do | clip |
32
31
  clip.fetch td_3
33
32
  end
34
- assert_equal("", td_3.text)
33
+ assert_equal("", td_3.get_data_here)
35
34
  end
36
35
  end
37
36
 
@@ -66,6 +65,37 @@ class TestBitmapData < Test::Unit::TestCase
66
65
  end
67
66
 
68
67
  class TestDataObjectComposite < Test::Unit::TestCase
68
+ MY_INT_ARRAY_FORMAT = Wx::DataFormat.new('application/int_array_format')
69
+
70
+ class MySimpleIntArrayObject < Wx::DataObjectSimpleBase
71
+ def initialize(arr = nil)
72
+ super(MY_INT_ARRAY_FORMAT)
73
+ self.array = arr
74
+ end
75
+
76
+ def array
77
+ @arr
78
+ end
79
+
80
+ def array=(arr)
81
+ @arr = (arr || []).collect { |e| e.to_i }
82
+ end
83
+
84
+ # The default will do in this case but otherwise something like this:
85
+ # def _get_data_size
86
+ # @arr ? @arr.pack('i*').bytesize : 0
87
+ # end
88
+
89
+ def _get_data
90
+ @arr ? @arr.pack('i*') : nil
91
+ end
92
+
93
+ def _set_data(data)
94
+ @arr = data ? data.unpack('i*') : []
95
+ true
96
+ end
97
+ end
98
+
69
99
  def test_data_object_composite
70
100
  d_obj = Wx::DataObjectComposite.new
71
101
  d_txt = Wx::TextDataObject.new
@@ -80,6 +110,9 @@ class TestDataObjectComposite < Test::Unit::TestCase
80
110
  assert_equal( 2, d_txt.get_format_count(Wx::DataObject::Direction::Get) )
81
111
  assert_equal( 3, d_obj.get_format_count(Wx::DataObject::Direction::Get) )
82
112
  end
113
+ d_txt = nil
114
+
115
+ GC.start
83
116
 
84
117
  d_bmp = Wx::BitmapDataObject.new(bmp)
85
118
  Wx::Clipboard.open do | clip |
@@ -87,6 +120,8 @@ class TestDataObjectComposite < Test::Unit::TestCase
87
120
  clip.place d_bmp
88
121
  end
89
122
 
123
+ GC.start
124
+
90
125
  Wx::Clipboard.open do | clip |
91
126
  assert !clip.supported?( Wx::DF_TEXT )
92
127
  assert clip.supported?( Wx::DF_BITMAP )
@@ -94,6 +129,8 @@ class TestDataObjectComposite < Test::Unit::TestCase
94
129
  clip.fetch d_obj
95
130
  end
96
131
 
132
+ GC.start
133
+
97
134
  if Wx::PLATFORM == 'WXMSW'
98
135
  assert_equal d_obj.received_format.get_type, Wx::DF_DIB.get_type
99
136
  d_bmp = d_obj.get_object(Wx::DF_DIB)
@@ -112,6 +149,8 @@ class TestDataObjectComposite < Test::Unit::TestCase
112
149
  clip.place d_txt
113
150
  end
114
151
 
152
+ GC.start
153
+
115
154
  d_obj_2 = Wx::DataObjectComposite.new
116
155
  d_txt = Wx::TextDataObject.new
117
156
  d_obj_2.add d_txt
@@ -125,6 +164,8 @@ class TestDataObjectComposite < Test::Unit::TestCase
125
164
  clip.fetch d_obj_2
126
165
  end
127
166
 
167
+ GC.start
168
+
128
169
  assert_equal d_obj_2.received_format.get_type, d_txt.get_preferred_format(Wx::DataObject::Direction::Set).get_type
129
170
  if Wx::PLATFORM == 'WXMSW'
130
171
  d_txt = d_obj_2.get_object(Wx::DF_UNICODETEXT)
@@ -132,11 +173,58 @@ class TestDataObjectComposite < Test::Unit::TestCase
132
173
  d_txt = d_obj_2.get_object(Wx::DF_TEXT)
133
174
  end
134
175
  assert_equal d_txt.text, 'THE TEXT'
176
+
177
+ GC.start
178
+
179
+ d_obj_2 = Wx::DataObjectComposite.new
180
+ d_obj_2.add Wx::TextDataObject.new
181
+ d_obj_2.add MySimpleIntArrayObject.new([1,2,3,4,5])
182
+ if Wx::PLATFORM == 'WXMSW'
183
+ assert_equal( 2, d_obj_2.get_format_count(Wx::DataObject::Direction::Get) )
184
+ else
185
+ assert_equal( 3, d_obj_2.get_format_count(Wx::DataObject::Direction::Get) )
186
+ end
187
+
188
+ Wx::Clipboard.open do | clip |
189
+ clip.clear
190
+ clip.place d_obj_2
191
+ end
192
+
193
+ GC.start
194
+
195
+ d_iarr = MySimpleIntArrayObject.new
196
+ Wx::Clipboard.open do | clip |
197
+ assert clip.supported?(MY_INT_ARRAY_FORMAT)
198
+ clip.fetch d_iarr
199
+ end
200
+
201
+ assert_equal([1,2,3,4,5], d_iarr.array)
135
202
  end
136
203
  end
137
204
 
138
205
  class TestDataObject < Test::Unit::TestCase
139
206
  MY_CUSTOM_FORMAT = Wx::DataFormat.new('text/custom_format')
207
+ MY_CUSTOM_TEXT = Wx::DataFormat.new('text/custom_text')
208
+
209
+ class MySimpleDataObject < Wx::DataObjectSimpleBase
210
+ def initialize
211
+ super(MY_CUSTOM_TEXT)
212
+ @data = ''
213
+ end
214
+
215
+ def _get_data_size
216
+ @data.bytesize
217
+ end
218
+
219
+ def _get_data
220
+ @data
221
+ end
222
+
223
+ def _set_data(data)
224
+ @data = data ? data : ''
225
+ true
226
+ end
227
+ end
140
228
 
141
229
  class MyBasicDataObject < Wx::DataObject
142
230
  attr_reader :my_data
@@ -187,9 +275,9 @@ class TestDataObject < Test::Unit::TestCase
187
275
  def get_data_size(format)
188
276
  case format.get_type
189
277
  when Wx::DataFormatId::DF_TEXT
190
- get_as_text.to_s.size
278
+ get_as_text.to_s.bytesize
191
279
  when MY_CUSTOM_FORMAT.get_type
192
- get_formatted.to_s.size
280
+ get_formatted.to_s.bytesize
193
281
  else
194
282
  0
195
283
  end
@@ -208,17 +296,35 @@ class TestDataObject < Test::Unit::TestCase
208
296
  end
209
297
  end
210
298
 
299
+ def test_simple_data_obj
300
+ d_obj = MySimpleDataObject.new
301
+ d_obj.set_data('Simple Data')
302
+ assert_equal( 1, d_obj.get_format_count )
303
+ assert_equal('Simple Data', d_obj.get_data_here )
304
+
305
+ Wx::Clipboard.open do | clip |
306
+ clip.place d_obj
307
+ end
308
+
309
+ d_obj2 = MySimpleDataObject.new
310
+ Wx::Clipboard.open do | clip |
311
+ assert clip.supported?( d_obj2.get_format )
312
+ clip.fetch d_obj2
313
+ end
314
+ assert_equal('Simple Data', d_obj2.get_data_here )
315
+ end
316
+
211
317
  def test_data_obj
212
318
  d_obj = MyBasicDataObject.new
213
319
  d_obj.set_data(Wx::DF_TEXT, 'HELLO')
214
- assert_equal( 2, d_obj.get_format_count(0) )
320
+ assert_equal( 2, d_obj.get_format_count(Wx::DataObject::Direction::Get) )
215
321
  assert_equal('HELLO', d_obj.get_data_here(Wx::DF_TEXT) )
216
322
  assert_equal('<b>HELLO</b>', d_obj.get_data_here(MY_CUSTOM_FORMAT) )
217
323
 
218
324
  Wx::Clipboard.open do | clip |
219
325
  clip.place d_obj
220
326
  end
221
-
327
+
222
328
  d_obj_2 = MyBasicDataObject.new
223
329
  Wx::Clipboard.open do | clip |
224
330
  assert clip.supported?( Wx::DF_TEXT )
@@ -230,12 +336,3 @@ class TestDataObject < Test::Unit::TestCase
230
336
  assert_equal('HELLO', d_obj_2.get_data_here(Wx::DF_TEXT) )
231
337
  end
232
338
  end
233
-
234
- Wx::App.run do
235
- # Must run whilst App is alive
236
- Test::Unit::UI::Console::TestRunner.run(TestTextData)
237
- Test::Unit::UI::Console::TestRunner.run(TestBitmapData)
238
- Test::Unit::UI::Console::TestRunner.run(TestDataObjectComposite)
239
- Test::Unit::UI::Console::TestRunner.run(TestDataObject)
240
- false
241
- end
data/tests/test_dialog.rb CHANGED
@@ -1,6 +1,5 @@
1
- require 'test/unit'
2
- require 'test/unit/ui/console/testrunner'
3
- require 'wx'
1
+
2
+ require_relative './lib/wxapp_runner'
4
3
 
5
4
  class DialogTests < Test::Unit::TestCase
6
5
 
@@ -16,13 +15,3 @@ class DialogTests < Test::Unit::TestCase
16
15
  assert_kind_of(Wx::Window, dlg)
17
16
  end
18
17
  end
19
-
20
- class TestApp < Wx::App
21
- def on_init
22
- Test::Unit::UI::Console::TestRunner.run(DialogTests)
23
- false
24
- end
25
- end
26
-
27
- app = TestApp.new
28
- app.run
@@ -1,6 +1,5 @@
1
- require 'test/unit'
2
- require 'test/unit/ui/console/testrunner'
3
- require 'wx'
1
+
2
+ require_relative './lib/wxapp_runner'
4
3
 
5
4
  class EventHandlingTests < Test::Unit::TestCase
6
5
 
@@ -91,13 +90,3 @@ class EventHandlingTests < Test::Unit::TestCase
91
90
  assert_boolean(!win.child.test_cmd_event)
92
91
  end
93
92
  end
94
-
95
- class TestApp < Wx::App
96
- def on_init
97
- Test::Unit::UI::Console::TestRunner.run(EventHandlingTests)
98
- false
99
- end
100
- end
101
-
102
- app = TestApp.new
103
- app.run
data/tests/test_events.rb CHANGED
@@ -1,6 +1,5 @@
1
- require 'test/unit'
2
- require 'test/unit/ui/console/testrunner'
3
- require 'wx'
1
+
2
+ require_relative './lib/wxapp_runner'
4
3
 
5
4
  class EventTests < Test::Unit::TestCase
6
5
 
@@ -40,6 +39,3 @@ class TestApp < Wx::App
40
39
  false
41
40
  end
42
41
  end
43
-
44
- app = TestApp.new
45
- app.run
@@ -12,9 +12,9 @@ class GeometryTests < Test::Unit::TestCase
12
12
  assert_equal(10, w)
13
13
  assert_equal(20, h)
14
14
 
15
- assert(sz == Wx::Size.new(w,h))
16
- assert(sz == [w,h])
17
- assert_raise(TypeError) { sz == '10, 20' }
15
+ assert_equal(sz, Wx::Size.new(w,h))
16
+ assert_equal(sz, [w,h])
17
+ assert_not_equal(sz,'10, 20' )
18
18
 
19
19
  assert(sz.eql? Wx::Size.new(w,h))
20
20
  refute(sz.eql?([w,h]))
@@ -30,6 +30,20 @@ class GeometryTests < Test::Unit::TestCase
30
30
  assert(Wx::Size.new(12,22).eql?(sz + 2))
31
31
  assert(Wx::Size.new(12,23).eql?(sz + Wx::Size.new(2,3)))
32
32
  assert(Wx::Size.new(12,23).eql?(sz + [2,3]))
33
+
34
+ small_sz = Wx::Size.new(10, 10)
35
+ medium_sz = Wx::Size.new(20, 20)
36
+ large_sz = Wx::Size.new(30, 30)
37
+ a = [large_sz, small_sz, medium_sz]
38
+ a.sort!
39
+ assert_equal(a[0], small_sz)
40
+ assert_equal(a[1], medium_sz)
41
+ assert_equal(a[2], large_sz)
42
+
43
+ h = {large_sz => 'Large', small_sz => 'Small', medium_sz => 'Medium'}
44
+ assert_equal(h[Wx::Size.new(10, 10)], 'Small')
45
+ assert_equal(h[Wx::Size.new(20, 20)], 'Medium')
46
+ assert_equal(h[Wx::Size.new(30, 30)], 'Large')
33
47
  end
34
48
 
35
49
  def test_point
@@ -41,9 +55,9 @@ class GeometryTests < Test::Unit::TestCase
41
55
  assert_equal(10, x)
42
56
  assert_equal(20, y)
43
57
 
44
- assert(pt == Wx::Point.new(x,y))
45
- assert(pt == [x,y])
46
- assert_raise(TypeError) { pt == '10, 20' }
58
+ assert_equal(pt, Wx::Point.new(x,y))
59
+ assert_equal(pt, [x,y])
60
+ assert_not_equal(pt, '10, 20')
47
61
 
48
62
  assert(pt.eql? Wx::Point.new(x,y))
49
63
  refute(pt.eql?([x,y]))
@@ -61,6 +75,20 @@ class GeometryTests < Test::Unit::TestCase
61
75
  assert(Wx::Point.new(12,23).eql?(pt + Wx::Point.new(2,3)))
62
76
  assert(Wx::Point.new(12,23).eql?(pt + Wx::Size.new(2,3)))
63
77
  assert(Wx::Point.new(12,23).eql?(pt + [2,3]))
78
+
79
+ nearest_pt = Wx::Point.new(10, 10)
80
+ mid_pt = Wx::Point.new(10, 20)
81
+ furthest_pt = Wx::Point.new(10, 30)
82
+ a = [furthest_pt, nearest_pt, mid_pt]
83
+ a.sort!
84
+ assert_equal(a[0], nearest_pt)
85
+ assert_equal(a[1], mid_pt)
86
+ assert_equal(a[2], furthest_pt)
87
+
88
+ h = {furthest_pt => 'Far', nearest_pt => 'Near', mid_pt => 'Mid'}
89
+ assert_equal(h[Wx::Point.new(10, 10)], 'Near')
90
+ assert_equal(h[Wx::Point.new(10, 20)], 'Mid')
91
+ assert_equal(h[Wx::Point.new(10, 30)], 'Far')
64
92
  end
65
93
 
66
94
  def test_real_point
@@ -72,9 +100,9 @@ class GeometryTests < Test::Unit::TestCase
72
100
  assert_equal(10.0, x)
73
101
  assert_equal(20.0, y)
74
102
 
75
- assert(pt == Wx::RealPoint.new(x,y))
76
- assert(pt == [x,y])
77
- assert_raise(TypeError) { pt == '10.0, 20.0' }
103
+ assert_equal(pt, Wx::RealPoint.new(x,y))
104
+ assert_equal(pt, [x,y])
105
+ assert_not_equal(pt, '10.0, 20.0')
78
106
 
79
107
  assert(pt.eql? Wx::RealPoint.new(x,y))
80
108
  refute(pt.eql?([x,y]))
@@ -94,6 +122,20 @@ class GeometryTests < Test::Unit::TestCase
94
122
  assert(Wx::RealPoint.new(12.0,23.0).eql?(pt + Wx::Point.new(2,3)))
95
123
  assert(Wx::RealPoint.new(12.0,23.0).eql?(pt + Wx::Size.new(2,3)))
96
124
  assert(Wx::RealPoint.new(12.0,23.0).eql?(pt + [2,3]))
125
+
126
+ nearest_pt = Wx::RealPoint.new(10, 10)
127
+ mid_pt = Wx::RealPoint.new(10, 20)
128
+ furthest_pt = Wx::RealPoint.new(10, 30)
129
+ a = [furthest_pt, nearest_pt, mid_pt]
130
+ a.sort!
131
+ assert_equal(a[0], nearest_pt)
132
+ assert_equal(a[1], mid_pt)
133
+ assert_equal(a[2], furthest_pt)
134
+
135
+ h = {furthest_pt => 'Far', nearest_pt => 'Near', mid_pt => 'Mid'}
136
+ assert_equal(h[Wx::RealPoint.new(10, 10)], 'Near')
137
+ assert_equal(h[Wx::RealPoint.new(10, 20)], 'Mid')
138
+ assert_equal(h[Wx::RealPoint.new(10, 30)], 'Far')
97
139
  end
98
140
 
99
141
  def test_rect
@@ -113,9 +155,9 @@ class GeometryTests < Test::Unit::TestCase
113
155
  assert_equal(100, w)
114
156
  assert_equal(300, h)
115
157
 
116
- assert(rect == Wx::Rect.new(x,y,w,h))
117
- assert(rect == [x,y,w,h])
118
- assert_raise(TypeError) { rect == '10,0,20,0' }
158
+ assert_equal(rect, Wx::Rect.new(x,y,w,h))
159
+ assert_equal(rect, [x,y,w,h])
160
+ assert_not_equal(rect, '10,0,20,0')
119
161
 
120
162
  assert(rect.eql? Wx::Rect.new(x,y,w,h))
121
163
  refute(rect.eql?([x,y,w,h]))
@@ -134,8 +176,3 @@ class GeometryTests < Test::Unit::TestCase
134
176
  end
135
177
 
136
178
  end
137
-
138
- if $0 == __FILE__
139
- require 'test/unit/ui/console/testrunner'
140
- Test::Unit::UI::Console::TestRunner.run(GeometryTests)
141
- end