wxruby3 0.9.0.pre.beta.9 → 0.9.0.pre.beta.11

Sign up to get free protection for your applications and to get access to all the features.
Files changed (55) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxruby3/include/wxruby-ScaledDC.h +549 -0
  3. data/ext/wxruby3/swig/mark_free_impl.i +0 -34
  4. data/ext/wxruby3/swig/wx.i +1 -1
  5. data/lib/wx/core/bitmap.rb +7 -0
  6. data/lib/wx/core/choice.rb +3 -0
  7. data/lib/wx/core/combobox.rb +3 -0
  8. data/lib/wx/core/controlwithitems.rb +98 -2
  9. data/lib/wx/core/data_object.rb +74 -6
  10. data/lib/wx/core/icon.rb +7 -1
  11. data/lib/wx/core/imagelist.rb +11 -0
  12. data/lib/wx/core/listbox.rb +3 -0
  13. data/lib/wx/core/point.rb +21 -10
  14. data/lib/wx/core/real_point.rb +21 -10
  15. data/lib/wx/core/rect.rb +2 -2
  16. data/lib/wx/core/size.rb +12 -5
  17. data/lib/wx/doc/data_object.rb +104 -0
  18. data/lib/wx/doc/gdi_common.rb +33 -5
  19. data/lib/wx/doc/progress_dialog.rb +37 -0
  20. data/lib/wx/doc/scaled_dc.rb +16 -0
  21. data/lib/wx/global_const.rb +4 -3
  22. data/lib/wx/version.rb +1 -1
  23. data/rakelib/lib/config/mingw.rb +3 -0
  24. data/rakelib/lib/core/include/init.inc +2 -2
  25. data/rakelib/lib/core/package.rb +3 -3
  26. data/rakelib/lib/core/spec.rb +2 -0
  27. data/rakelib/lib/director/ctrl_with_items.rb +29 -17
  28. data/rakelib/lib/director/data_object.rb +94 -0
  29. data/rakelib/lib/director/data_object_simple_base.rb +123 -0
  30. data/rakelib/lib/director/derived_dc.rb +38 -0
  31. data/rakelib/lib/director/dialog.rb +29 -54
  32. data/rakelib/lib/director/image_list.rb +3 -1
  33. data/rakelib/lib/director/preview_frame.rb +41 -0
  34. data/rakelib/lib/director/print_data.rb +5 -7
  35. data/rakelib/lib/specs/interfaces.rb +2 -0
  36. data/rakelib/lib/typemap/data_object_data.rb +13 -4
  37. data/samples/dialogs/dialogs.rb +70 -50
  38. data/samples/drawing/maths_images.rb +1 -1
  39. data/samples/sampler/ext.rb +3 -3
  40. data/samples/sampler/stc_editor.rb +19 -19
  41. data/samples/sampler/txt_editor.rb +2 -2
  42. data/samples/treectrl/treectrl.rb +32 -30
  43. data/tests/lib/wxapp_runner.rb +64 -0
  44. data/tests/test_basic.rb +0 -5
  45. data/tests/test_clipboard.rb +114 -17
  46. data/tests/test_dialog.rb +2 -13
  47. data/tests/test_event_handling.rb +2 -13
  48. data/tests/test_events.rb +2 -6
  49. data/tests/test_geometry.rb +54 -17
  50. data/tests/test_intl.rb +2 -15
  51. data/tests/test_item_data.rb +69 -15
  52. data/tests/test_variant.rb +1 -15
  53. data/tests/testapp.rb +0 -5
  54. data/tests/testapp_noframe.rb +0 -5
  55. metadata +8 -2
@@ -36,6 +36,7 @@ DIALOGS_STYLED_BUSYINFO = 25
36
36
  DIALOGS_FIND = 26
37
37
  DIALOGS_REPLACE = 27
38
38
  DIALOGS_PREFS = 28
39
+ DIALOGS_PREFS_TOOLBOOK = 29
39
40
 
40
41
  class MyTipProvider < TipProvider
41
42
  TIPS = [
@@ -147,16 +148,18 @@ end
147
148
  # PropertySheetDialog is specialised for doing preferences dialogs; it
148
149
  # contains a BookCtrl of some sort
149
150
  class MyPrefsDialog < Wx::PropertySheetDialog
150
- def initialize(parent)
151
+ def initialize(parent, pref_type)
151
152
  # Using Book type other than Notebook needs two-step construction
152
153
  super()
153
- self.sheet_style = Wx::PROPSHEET_BUTTONTOOLBOOK
154
- self.sheet_outer_border = 1
155
- self.sheet_inner_border = 2
156
- img_list = Wx::ImageList.new(32, 32)
157
- img_list << std_bitmap(Wx::ART_NORMAL_FILE)
158
- img_list << std_bitmap(Wx::ART_CDROM)
159
- img_list << std_bitmap(Wx::ART_REPORT_VIEW)
154
+ if pref_type == DIALOGS_PREFS_TOOLBOOK
155
+ self.sheet_style = Wx::PROPSHEET_BUTTONTOOLBOOK
156
+ self.sheet_outer_border = 1
157
+ self.sheet_inner_border = 2
158
+ img_list = Wx::ImageList.new(32, 32)
159
+ img_list << std_bitmap(Wx::ART_NORMAL_FILE)
160
+ img_list << std_bitmap(Wx::ART_CDROM)
161
+ img_list << std_bitmap(Wx::ART_REPORT_VIEW)
162
+ end
160
163
 
161
164
  create(parent, -1, "Preferences")
162
165
  create_buttons(Wx::ID_OK|Wx::ID_CANCEL)
@@ -247,40 +250,41 @@ class MyFrame < Frame
247
250
  @index = -1
248
251
  @index_2 = -1
249
252
 
250
- @max = 10
253
+ @max = 100
251
254
 
252
255
  create_status_bar()
253
256
 
254
- evt_menu(DIALOGS_CHOOSE_COLOUR) {|event| on_choose_colour(event) }
255
- evt_menu(DIALOGS_CHOOSE_FONT) {|event| on_choose_font(event) }
256
- evt_menu(DIALOGS_LOG_DIALOG) {|event| on_log_dialog(event) }
257
- evt_menu(DIALOGS_MESSAGE_BOX) {|event| on_message_box(event) }
258
- evt_menu(DIALOGS_TEXT_ENTRY) {|event| on_text_entry(event) }
259
- evt_menu(DIALOGS_PASSWORD_ENTRY) {|event| on_password_entry(event) }
260
- evt_menu(DIALOGS_NUM_ENTRY) {|event| on_numeric_entry(event) }
261
- evt_menu(DIALOGS_SINGLE_CHOICE) {|event| on_single_choice(event) }
262
- evt_menu(DIALOGS_MULTI_CHOICE) {|event| on_multi_choice(event) }
263
- evt_menu(DIALOGS_FILE_OPEN) {|event| on_file_open(event) }
264
- evt_menu(DIALOGS_FILE_OPEN2) {|event| on_file_open2(event) }
265
- evt_menu(DIALOGS_FILES_OPEN) {|event| on_files_open(event) }
266
- evt_menu(DIALOGS_FILE_SAVE) {|event| on_file_save(event) }
267
- evt_menu(DIALOGS_DIR_CHOOSE) {|event| on_dir_choose(event) }
268
- evt_menu(DIALOGS_MODAL) {|event| on_modal_dlg(event) }
269
- evt_menu(DIALOGS_MODELESS) {|event| on_modeless_dlg(event) }
270
- evt_menu(DIALOGS_TIP) {|event| on_show_tip(event) }
271
- evt_menu(DIALOGS_CUSTOM_TIP) {|event| on_show_custom_tip(event) }
272
- evt_menu(DIALOGS_PROGRESS) {|event| on_show_progress(event) }
273
- evt_menu(DIALOGS_BUSYINFO) {|event| on_show_busy_info(event) }
274
- evt_menu(DIALOGS_STYLED_BUSYINFO) {|event| on_show_styled_busy_info(event) }
275
- evt_menu(DIALOGS_PREFS) {|event| on_show_prefs(event) }
276
- evt_menu(DIALOGS_FIND) {|event| on_show_find_dialog(event) }
277
- evt_menu(DIALOGS_REPLACE) {|event| on_show_replace_dialog(event) }
278
- evt_find(-1) {|event| on_find_dialog(event) }
279
- evt_find_next(-1) {|event| on_find_dialog(event) }
280
- evt_find_replace(-1) {|event| on_find_dialog(event) }
281
- evt_find_replace_all(-1) {|event| on_find_dialog(event) }
282
- evt_find_close(-1) {|event| on_find_dialog(event) }
283
- evt_menu(ID_EXIT) {|event| on_exit(event) }
257
+ evt_menu(DIALOGS_CHOOSE_COLOUR, :on_choose_colour)
258
+ evt_menu(DIALOGS_CHOOSE_FONT, :on_choose_font)
259
+ evt_menu(DIALOGS_LOG_DIALOG, :on_log_dialog)
260
+ evt_menu(DIALOGS_MESSAGE_BOX, :on_message_box)
261
+ evt_menu(DIALOGS_TEXT_ENTRY, :on_text_entry)
262
+ evt_menu(DIALOGS_PASSWORD_ENTRY, :on_password_entry)
263
+ evt_menu(DIALOGS_NUM_ENTRY, :on_numeric_entry)
264
+ evt_menu(DIALOGS_SINGLE_CHOICE, :on_single_choice)
265
+ evt_menu(DIALOGS_MULTI_CHOICE, :on_multi_choice)
266
+ evt_menu(DIALOGS_FILE_OPEN, :on_file_open)
267
+ evt_menu(DIALOGS_FILE_OPEN2, :on_file_open2)
268
+ evt_menu(DIALOGS_FILES_OPEN, :on_files_open)
269
+ evt_menu(DIALOGS_FILE_SAVE, :on_file_save)
270
+ evt_menu(DIALOGS_DIR_CHOOSE, :on_dir_choose)
271
+ evt_menu(DIALOGS_MODAL, :on_modal_dlg)
272
+ evt_menu(DIALOGS_MODELESS, :on_modeless_dlg)
273
+ evt_menu(DIALOGS_TIP, :on_show_tip)
274
+ evt_menu(DIALOGS_CUSTOM_TIP, :on_show_custom_tip)
275
+ evt_menu(DIALOGS_PROGRESS, :on_show_progress)
276
+ evt_menu(DIALOGS_BUSYINFO, :on_show_busy_info)
277
+ evt_menu(DIALOGS_STYLED_BUSYINFO, :on_show_styled_busy_info)
278
+ evt_menu(DIALOGS_PREFS, :on_show_prefs)
279
+ evt_menu(DIALOGS_PREFS_TOOLBOOK,:on_show_prefs)
280
+ evt_menu(DIALOGS_FIND, :on_show_find_dialog)
281
+ evt_menu(DIALOGS_REPLACE, :on_show_replace_dialog)
282
+ evt_find(-1, :on_find_dialog)
283
+ evt_find_next(-1, :on_find_dialog)
284
+ evt_find_replace(-1, :on_find_dialog)
285
+ evt_find_replace_all(-1, :on_find_dialog)
286
+ evt_find_close(-1, :on_find_dialog)
287
+ evt_menu(ID_EXIT, :on_exit)
284
288
 
285
289
  end
286
290
 
@@ -614,26 +618,37 @@ class MyFrame < Frame
614
618
 
615
619
 
616
620
  def on_show_prefs(event)
617
- MyPrefsDialog(self)
621
+ MyPrefsDialog(self, event.id)
618
622
  end
619
623
 
620
624
  def on_show_progress(event)
621
625
  cont = false
622
626
  Wx::ProgressDialog("Progress dialog example",
623
- "An informative message",
627
+ "An informative message\n"+"#{' '*100}\n\n\n\n",
624
628
  @max, # range
625
629
  self, # parent
626
- PD_CAN_ABORT | PD_APP_MODAL |
630
+ PD_CAN_ABORT | PD_CAN_SKIP | PD_APP_MODAL |
627
631
  PD_ELAPSED_TIME | PD_ESTIMATED_TIME |
628
632
  PD_REMAINING_TIME) do |dialog|
629
633
  cont = true
630
- (@max+1).times do |i|
631
- if i == @max
632
- cont = dialog.update(i, "That's all, folks!")
633
- elsif i == @max / 2
634
- cont = dialog.update(i, "Only half of it left (very long message)!")
635
- else
634
+ i = 0
635
+ while i <= @max
636
+ if i == 0
636
637
  cont = dialog.update(i)
638
+ elsif i == @max
639
+ cont = dialog.update(i, "That's all, folks!\n\nNothing more to see here any more.")
640
+ elsif i <= (@max / 2)
641
+ cont = dialog.pulse("Testing indeterminate mode\n" +
642
+ "\n" +
643
+ "This mode allows you to show to the user\n" +
644
+ "that something is going on even if you don't know\n" +
645
+ "when exactly will you finish.")
646
+ else
647
+ cont = dialog.update(i, "Now in standard determinate mode\n" +
648
+ "\n" +
649
+ "This is the standard usage mode in which you\n" +
650
+ "update the dialog after performing each new step of work.\n" +
651
+ "It requires knowing the total number of steps in advance.")
637
652
  end
638
653
 
639
654
  if !cont
@@ -644,8 +659,12 @@ class MyFrame < Frame
644
659
  break
645
660
  end
646
661
  dialog.resume
662
+ elsif cont == :skipped
663
+ i += (@max / 4)
664
+ i = @max-1 if i >= @max
647
665
  end
648
- sleep(1)
666
+ sleep(i == 0 ? 1 : 0.15)
667
+ i += 1
649
668
  end
650
669
  end
651
670
 
@@ -831,7 +850,8 @@ class MyApp < App
831
850
  file_menu.append(DIALOGS_PROGRESS, "Pro&gress dialog\tCtrl-G")
832
851
  file_menu.append(DIALOGS_BUSYINFO, "&Busy info dialog\tCtrl-B")
833
852
  file_menu.append(DIALOGS_STYLED_BUSYINFO, "Styled BusyInfo dialog")
834
- file_menu.append(DIALOGS_PREFS, "Propert&y sheet dialog\tCtrl-Y")
853
+ file_menu.append(DIALOGS_PREFS, "Standard propert&y sheet dialog\tCtrl-Y")
854
+ file_menu.append(DIALOGS_PREFS_TOOLBOOK, "&Toolbook property sheet dialog\tShift-Ctrl-Y")
835
855
  file_menu.append(DIALOGS_FIND, "&Find dialog\tCtrl-F", "", ITEM_CHECK)
836
856
  file_menu.append(DIALOGS_REPLACE, "Find and &replace dialog\tShift-Ctrl-F", "", ITEM_CHECK)
837
857
 
@@ -211,7 +211,7 @@ class MathsPanel < Panel
211
211
  # Display a dialog to save the image to a file
212
212
  def on_save
213
213
  SaveImageDialog(parent) do |dlg|
214
- if dlg.show_modal == ID_OK
214
+ if dlg.show_modal == Wx::ID_OK
215
215
  if dlg.image_type == Wx::BITMAP_TYPE_PNG
216
216
  # test writing to IO
217
217
  File.open(dlg.path, 'w') do |f|
@@ -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