wxruby3 0.9.0.pre.beta.13-x64-mingw-ucrt → 0.9.0.pre.rc.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (240) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/README.md +47 -4
  4. data/assets/hello_button.png +0 -0
  5. data/assets/hello_button_clicked.png +0 -0
  6. data/assets/hello_world.png +0 -0
  7. data/assets/repo-social-preview.png +0 -0
  8. data/ext/wxbase32u_gcc_custom.dll +0 -0
  9. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  10. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  11. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  12. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  13. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  14. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  15. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  16. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  17. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  18. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  19. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  20. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  21. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  22. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  23. data/lib/wx/accessors.rb +8 -2
  24. data/lib/wx/core/art_locator.rb +2 -2
  25. data/lib/wx/core/artprovider.rb +2 -2
  26. data/lib/wx/core/bitmap.rb +6 -5
  27. data/lib/wx/core/bitmap_combobox.rb +34 -0
  28. data/lib/wx/core/controlwithitems.rb +52 -14
  29. data/lib/wx/core/cursor.rb +1 -1
  30. data/lib/wx/core/dc.rb +0 -20
  31. data/lib/wx/core/event_blocker.rb +14 -0
  32. data/lib/wx/core/events/evt_list.rb +12 -0
  33. data/lib/wx/core/evthandler.rb +36 -0
  34. data/lib/wx/core/find_replace_dialog.rb +24 -0
  35. data/lib/wx/core/icon.rb +1 -1
  36. data/lib/wx/core/image.rb +1 -1
  37. data/lib/wx/core/paintdc.rb +8 -0
  38. data/lib/wx/core/text_entry.rb +15 -0
  39. data/lib/wx/core/v_list_box.rb +13 -0
  40. data/lib/wx/core/window.rb +1 -1
  41. data/lib/wx/doc/busy_info.rb +21 -0
  42. data/lib/wx/doc/client_dc.rb +28 -0
  43. data/lib/wx/doc/controlwithitems.rb +11 -0
  44. data/lib/wx/doc/dc.rb +0 -14
  45. data/lib/wx/doc/event_blocker.rb +27 -0
  46. data/lib/wx/doc/evthandler.rb +4 -0
  47. data/lib/wx/doc/extra/02_lifecycles.md +49 -0
  48. data/lib/wx/doc/extra/10_art.md +1 -1
  49. data/lib/wx/doc/extra/11_drawing_and_dc.md +62 -0
  50. data/lib/wx/doc/gen/about_dialog_info.rb +27 -24
  51. data/lib/wx/doc/gen/accelerator.rb +11 -12
  52. data/lib/wx/doc/gen/app.rb +6 -3
  53. data/lib/wx/doc/gen/art_provider.rb +53 -29
  54. data/lib/wx/doc/gen/aui/aui_manager.rb +4 -0
  55. data/lib/wx/doc/gen/aui/aui_mdi_child_frame.rb +1 -1
  56. data/lib/wx/doc/gen/aui/aui_pane_info.rb +2 -0
  57. data/lib/wx/doc/gen/aui/aui_tab_ctrl.rb +2 -0
  58. data/lib/wx/doc/gen/bitmap.rb +25 -25
  59. data/lib/wx/doc/gen/bitmap_combo_box.rb +157 -0
  60. data/lib/wx/doc/gen/box_sizer.rb +6 -8
  61. data/lib/wx/doc/gen/brush.rb +2 -0
  62. data/lib/wx/doc/gen/busy_info.rb +52 -46
  63. data/lib/wx/doc/gen/caret.rb +0 -4
  64. data/lib/wx/doc/gen/check_list_box.rb +0 -2
  65. data/lib/wx/doc/gen/choice.rb +1 -5
  66. data/lib/wx/doc/gen/client_dc.rb +13 -18
  67. data/lib/wx/doc/gen/clipboard.rb +30 -27
  68. data/lib/wx/doc/gen/collapsible_pane.rb +11 -9
  69. data/lib/wx/doc/gen/colour.rb +6 -3
  70. data/lib/wx/doc/gen/colour_dialog.rb +111 -23
  71. data/lib/wx/doc/gen/combo_box.rb +2 -4
  72. data/lib/wx/doc/gen/control.rb +20 -18
  73. data/lib/wx/doc/gen/core.rb +2 -2
  74. data/lib/wx/doc/gen/cursor.rb +18 -50
  75. data/lib/wx/doc/gen/data_format.rb +0 -2
  76. data/lib/wx/doc/gen/data_object.rb +37 -44
  77. data/lib/wx/doc/gen/dc.rb +16 -24
  78. data/lib/wx/doc/gen/defs.rb +3 -40
  79. data/lib/wx/doc/gen/dialog.rb +21 -17
  80. data/lib/wx/doc/gen/dir_dialog.rb +10 -8
  81. data/lib/wx/doc/gen/event.rb +2 -2
  82. data/lib/wx/doc/gen/event_blocker.rb +49 -0
  83. data/lib/wx/doc/gen/event_filter.rb +95 -0
  84. data/lib/wx/doc/gen/event_list.rb +16 -2
  85. data/lib/wx/doc/gen/events.rb +103 -112
  86. data/lib/wx/doc/gen/evt_handler.rb +28 -52
  87. data/lib/wx/doc/gen/file_dialog.rb +8 -4
  88. data/lib/wx/doc/gen/find_replace_dialog.rb +1 -1
  89. data/lib/wx/doc/gen/font.rb +10 -2
  90. data/lib/wx/doc/gen/font_data.rb +2 -0
  91. data/lib/wx/doc/gen/font_dialog.rb +1 -1
  92. data/lib/wx/doc/gen/frame.rb +4 -3
  93. data/lib/wx/doc/gen/fs_file.rb +8 -0
  94. data/lib/wx/doc/gen/gcdc.rb +2 -22
  95. data/lib/wx/doc/gen/gdi_common.rb +18 -2
  96. data/lib/wx/doc/gen/gdi_object.rb +2 -0
  97. data/lib/wx/doc/gen/graphics_context.rb +4 -43
  98. data/lib/wx/doc/gen/graphics_object.rb +2 -0
  99. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +2 -1
  100. data/lib/wx/doc/gen/grid/grid_ctrl.rb +4 -2
  101. data/lib/wx/doc/gen/grid/grid_table_message.rb +2 -0
  102. data/lib/wx/doc/gen/grid_bag_sizer.rb +4 -0
  103. data/lib/wx/doc/gen/help_controller.rb +4 -1
  104. data/lib/wx/doc/gen/html/html_cell.rb +4 -1
  105. data/lib/wx/doc/gen/html/html_help_controller.rb +4 -1
  106. data/lib/wx/doc/gen/html/html_help_data.rb +4 -0
  107. data/lib/wx/doc/gen/html/html_help_window.rb +2 -1
  108. data/lib/wx/doc/gen/html/html_list_box.rb +138 -11
  109. data/lib/wx/doc/gen/html/html_window.rb +9 -3
  110. data/lib/wx/doc/gen/icon.rb +7 -1
  111. data/lib/wx/doc/gen/icon_location.rb +2 -0
  112. data/lib/wx/doc/gen/image.rb +15 -8
  113. data/lib/wx/doc/gen/keyboard_state.rb +6 -0
  114. data/lib/wx/doc/gen/list_box.rb +0 -11
  115. data/lib/wx/doc/gen/list_ctrl.rb +10 -13
  116. data/lib/wx/doc/gen/locale.rb +7 -3
  117. data/lib/wx/doc/gen/log.rb +6 -2
  118. data/lib/wx/doc/gen/mdi_frame.rb +2 -0
  119. data/lib/wx/doc/gen/media_ctrl.rb +2 -0
  120. data/lib/wx/doc/gen/memory_dc.rb +105 -18
  121. data/lib/wx/doc/gen/menu.rb +4 -2
  122. data/lib/wx/doc/gen/menu_bar.rb +0 -2
  123. data/lib/wx/doc/gen/menu_item.rb +9 -3
  124. data/lib/wx/doc/gen/message_dialog.rb +6 -3
  125. data/lib/wx/doc/gen/mirror_dc.rb +2 -8
  126. data/lib/wx/doc/gen/mouse_state.rb +2 -0
  127. data/lib/wx/doc/gen/multi_choice_dialog.rb +0 -2
  128. data/lib/wx/doc/gen/non_owned_window.rb +2 -1
  129. data/lib/wx/doc/gen/notebook.rb +4 -2
  130. data/lib/wx/doc/gen/paint_dc.rb +2 -6
  131. data/lib/wx/doc/gen/palette.rb +3 -3
  132. data/lib/wx/doc/gen/pen.rb +6 -1
  133. data/lib/wx/doc/gen/pg/pg_editor.rb +2 -1
  134. data/lib/wx/doc/gen/pg/pg_multi_button.rb +4 -0
  135. data/lib/wx/doc/gen/pg/pg_properties.rb +30 -3
  136. data/lib/wx/doc/gen/pg/pg_property.rb +30 -4
  137. data/lib/wx/doc/gen/pg/pg_validation_info.rb +2 -0
  138. data/lib/wx/doc/gen/pg/property_grid.rb +5 -2
  139. data/lib/wx/doc/gen/pg/property_grid_interface.rb +6 -2
  140. data/lib/wx/doc/gen/pg/property_grid_manager.rb +2 -0
  141. data/lib/wx/doc/gen/pg/property_grid_page_state.rb +2 -0
  142. data/lib/wx/doc/gen/picker_base.rb +2 -1
  143. data/lib/wx/doc/gen/platform_info.rb +4 -1
  144. data/lib/wx/doc/gen/property_sheet_dialog.rb +2 -0
  145. data/lib/wx/doc/gen/prt/post_script_dc.rb +2 -8
  146. data/lib/wx/doc/gen/prt/print_data.rb +6 -0
  147. data/lib/wx/doc/gen/prt/printer.rb +0 -3
  148. data/lib/wx/doc/gen/prt/printer_dc.rb +2 -6
  149. data/lib/wx/doc/gen/radio_box.rb +2 -2
  150. data/lib/wx/doc/gen/rbn/ribbon_art_provider.rb +6 -0
  151. data/lib/wx/doc/gen/rbn/ribbon_panel.rb +1 -1
  152. data/lib/wx/doc/gen/region.rb +2 -0
  153. data/lib/wx/doc/gen/rtc/rich_text_buffer.rb +6 -0
  154. data/lib/wx/doc/gen/rtc/rich_text_ctrl.rb +0 -4
  155. data/lib/wx/doc/gen/rtc/rich_text_header_footer_data.rb +2 -0
  156. data/lib/wx/doc/gen/rtc/rich_text_html_handler.rb +2 -1
  157. data/lib/wx/doc/gen/rtc/symbol_picker_dialog.rb +2 -0
  158. data/lib/wx/doc/gen/screen_dc.rb +2 -0
  159. data/lib/wx/doc/gen/scroll_bar.rb +2 -1
  160. data/lib/wx/doc/gen/scrolled_canvas.rb +4 -8
  161. data/lib/wx/doc/gen/scrolled_control.rb +4 -8
  162. data/lib/wx/doc/gen/scrolled_window.rb +4 -8
  163. data/lib/wx/doc/gen/search_ctrl.rb +131 -0
  164. data/lib/wx/doc/gen/single_choice_dialog.rb +0 -2
  165. data/lib/wx/doc/gen/sizer.rb +14 -3
  166. data/lib/wx/doc/gen/splash_screen.rb +2 -0
  167. data/lib/wx/doc/gen/static_box.rb +6 -3
  168. data/lib/wx/doc/gen/static_box_sizer.rb +2 -1
  169. data/lib/wx/doc/gen/status_bar.rb +0 -5
  170. data/lib/wx/doc/gen/stc/styled_text_ctrl.rb +4 -5
  171. data/lib/wx/doc/gen/svg_file_dc.rb +10 -11
  172. data/lib/wx/doc/gen/text_ctrl.rb +10 -3
  173. data/lib/wx/doc/gen/text_entry.rb +8 -3
  174. data/lib/wx/doc/gen/text_entry_dialog.rb +4 -2
  175. data/lib/wx/doc/gen/timer_event.rb +2 -0
  176. data/lib/wx/doc/gen/tool_bar.rb +8 -4
  177. data/lib/wx/doc/gen/top_level_window.rb +5 -2
  178. data/lib/wx/doc/gen/tree_ctrl.rb +0 -6
  179. data/lib/wx/doc/gen/ui_action_simulator.rb +100 -0
  180. data/lib/wx/doc/gen/utils.rb +1 -1
  181. data/lib/wx/doc/gen/v_list_box.rb +36 -26
  182. data/lib/wx/doc/gen/validator.rb +2 -1
  183. data/lib/wx/doc/gen/variant.rb +10 -0
  184. data/lib/wx/doc/gen/window.rb +38 -17
  185. data/lib/wx/doc/gen/window_dc.rb +2 -0
  186. data/lib/wx/doc/gen/window_disabler.rb +2 -0
  187. data/lib/wx/doc/gen/wizard_page_simple.rb +2 -0
  188. data/lib/wx/doc/gen/xml_node.rb +6 -0
  189. data/lib/wx/doc/gen/xml_resource.rb +4 -1
  190. data/lib/wx/doc/memory_dc.rb +75 -0
  191. data/lib/wx/doc/mirror_dc.rb +16 -0
  192. data/lib/wx/doc/prt/printer_dc.rb +26 -0
  193. data/lib/wx/doc/screen_dc.rb +10 -6
  194. data/lib/wx/doc/svg_file_dc.rb +20 -0
  195. data/lib/wx/doc/v_list_box.rb +9 -0
  196. data/lib/wx/doc/window_disabler.rb +10 -0
  197. data/lib/wx/global_const.rb +24 -18
  198. data/lib/wx/html/keyword_defs.rb +6 -7
  199. data/lib/wx/html/require.rb +1 -0
  200. data/lib/wx/html/simple_html_listbox.rb +105 -0
  201. data/lib/wx/keyword_defs.rb +7 -0
  202. data/lib/wx/version.rb +1 -1
  203. data/lib/wx/wxruby/cmd/test.rb +1 -1
  204. data/lib/wxruby_aui.so +0 -0
  205. data/lib/wxruby_core.so +0 -0
  206. data/lib/wxruby_grid.so +0 -0
  207. data/lib/wxruby_html.so +0 -0
  208. data/lib/wxruby_pg.so +0 -0
  209. data/lib/wxruby_prt.so +0 -0
  210. data/lib/wxruby_rbn.so +0 -0
  211. data/lib/wxruby_rtc.so +0 -0
  212. data/lib/wxruby_stc.so +0 -0
  213. data/rakelib/install.rb +3 -1
  214. data/rakelib/yard/yard/relative_markdown_links.rb +5 -1
  215. data/samples/bigdemo/wxArtProvider.rbw +5 -4
  216. data/samples/controls/controls.rb +2 -2
  217. data/samples/controls/htlbox.rb +411 -0
  218. data/samples/controls/tn_htlbox.png +0 -0
  219. data/samples/drawing/graphics_drawing.rb +1 -2
  220. data/samples/drawing/{svgtest.rb → image_prt.rb} +49 -18
  221. data/samples/drawing/tn_image_prt.png +0 -0
  222. data/samples/propgrid/propgrid.rb +23 -21
  223. data/samples/ribbon/ribbon.rb +47 -46
  224. data/tests/lib/wxapp_runner.rb +3 -3
  225. data/tests/lib/wxframe_runner.rb +59 -0
  226. data/tests/test_app_event_filter.rb +74 -0
  227. data/tests/test_art_provider.rb +52 -0
  228. data/tests/test_clipboard.rb +2 -1
  229. data/tests/test_event_handling.rb +199 -16
  230. data/tests/test_events.rb +4 -11
  231. data/tests/test_gdi_object.rb +161 -0
  232. data/tests/test_intl.rb +11 -14
  233. data/tests/test_item_data.rb +33 -1
  234. data/tests/test_std_controls.rb +147 -0
  235. metadata +38 -8
  236. data/lib/wx/doc/gen/auto_buffered_paint_dc.rb +0 -47
  237. data/lib/wx/doc/gen/buffered_dc.rb +0 -95
  238. data/lib/wx/doc/gen/buffered_paint_dc.rb +0 -55
  239. data/lib/wx/doc/gen/colour_data.rb +0 -96
  240. data/samples/drawing/tn_svgtest.png +0 -0
@@ -4,7 +4,7 @@
4
4
 
5
5
  require 'wx'
6
6
 
7
- class SVGPage < Wx::ScrolledWindow
7
+ class ImagePage < Wx::ScrolledWindow
8
8
 
9
9
  PAGES = [
10
10
  'Lines',
@@ -41,9 +41,36 @@ class SVGPage < Wx::ScrolledWindow
41
41
  end
42
42
 
43
43
  def on_save(filename)
44
- svgDC = Wx::SVGFileDC.new(filename, 600, 650)
45
- on_draw(svgDC)
46
- svgDC.ok?
44
+ case File.extname(filename)
45
+ when '.svg'
46
+ Wx::SVGFileDC.draw_on(filename, 600, 650) do |svgDC|
47
+ on_draw(svgDC)
48
+ svgDC.ok?
49
+ end
50
+ when '.ps'
51
+ print_data = Wx::PRT::PrintData.new
52
+ print_data.set_print_mode(Wx::PRINT_MODE_FILE)
53
+ print_data.set_filename(filename)
54
+ print_data.set_orientation(Wx::PrintOrientation::PORTRAIT)
55
+ print_data.set_paper_id(Wx::PaperSize::PAPER_A4)
56
+ screen_ppi = printer_ppi = nil
57
+ Wx::ScreenDC.draw_on do |dc|
58
+ screen_ppi = dc.get_ppi
59
+ end
60
+ Wx::PRT::PostScriptDC.draw_on(print_data) do |dc|
61
+ printer_ppi = dc.get_ppi
62
+ scale = printer_ppi.x.to_f / screen_ppi.x.to_f
63
+ dc.start_doc("Drawing sample")
64
+ # Define default font.
65
+ dc.set_font(Wx::FontInfo.new(10).family(Wx::FontFamily::FONTFAMILY_MODERN))
66
+ dc.start_page
67
+ Wx::ScaledDC.draw_on(dc, scale) do |sdc|
68
+ on_draw(sdc)
69
+ end
70
+ dc.end_page
71
+ dc.end_doc
72
+ end
73
+ end
47
74
  end
48
75
 
49
76
  def on_paint
@@ -278,10 +305,10 @@ class SVGPage < Wx::ScrolledWindow
278
305
 
279
306
  end
280
307
 
281
- class SVGFrame < Wx::Frame
308
+ class ImageFrame < Wx::Frame
282
309
 
283
310
  def initialize
284
- super(nil, title: 'SVG Demo', size: [500, 400])
311
+ super(nil, title: 'ImagePrint Demo', size: [500, 400])
285
312
 
286
313
  icon_file = File.join(__dir__,'..', 'art', "wxruby.png")
287
314
  self.icon = Wx::Icon.new(icon_file)
@@ -310,8 +337,8 @@ class SVGFrame < Wx::Frame
310
337
  @notebook = Wx::Notebook.new(self, style: Wx::BK_TOP)
311
338
 
312
339
  # Add SVG Windows to a notebook
313
- SVGPage::PAGES.each_with_index do |title, index|
314
- @notebook.add_page(SVGPage.new(@notebook, index), title)
340
+ ImagePage::PAGES.each_with_index do |title, index|
341
+ @notebook.add_page(ImagePage.new(@notebook, index), title)
315
342
  end
316
343
 
317
344
  evt_menu Wx::ID_SAVE, :file_save_picture
@@ -322,9 +349,13 @@ class SVGFrame < Wx::Frame
322
349
  def file_save_picture(event)
323
350
  page = @notebook.current_page
324
351
 
352
+ wildcard = 'SVG vector picture files (*.svg)|*.svg'
353
+ if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
354
+ wildcard << '|PostScript files (*.ps)|*.ps'
355
+ end
325
356
  Wx::FileDialog(self, 'Save Picture as', '',
326
357
  @notebook.get_page_text(@notebook.get_selection),
327
- 'SVG vector picture files (*.svg)|*.svg',
358
+ wildcard,
328
359
  Wx::FD_SAVE|Wx::FD_OVERWRITE_PROMPT) do |dlg|
329
360
  if dlg.show_modal == Wx::ID_OK
330
361
  page.on_save(dlg.get_path)
@@ -334,14 +365,14 @@ class SVGFrame < Wx::Frame
334
365
 
335
366
  def on_about(event)
336
367
  Wx.message_box(
337
- "wxRuby SVG sample\n" +
338
- "(converted from wxWidgets)\n" +
368
+ "wxRuby ImagePrint sample\n" +
369
+ "(converted from wxWidgets SVGTest)\n" +
339
370
  "Authors:\n" +
340
371
  " Chris Elliott (c) 2002-2009\n" +
341
372
  " Prashant Kumar Nirmal (c) 2017\n" +
342
373
  " Martin Corino (c) 2023\n" +
343
- 'Usage: click File|Save to Save the Selected SVG Test',
344
- 'About SVG Test')
374
+ 'Usage: click File|Save to Save the Selected Image page',
375
+ 'About ImagePrint Test')
345
376
  end
346
377
 
347
378
  def on_quit(event)
@@ -350,24 +381,24 @@ class SVGFrame < Wx::Frame
350
381
 
351
382
  end
352
383
 
353
- module SVGTestSample
384
+ module ImagePrintSample
354
385
 
355
386
  include WxRuby::Sample if defined? WxRuby::Sample
356
387
 
357
388
  def self.describe
358
389
  { file: __FILE__,
359
- summary: 'wxRuby SVGFileDC example.',
360
- description: 'wxRuby example showcasing Wx::SVGFileDC to create SVG files.' }
390
+ summary: 'wxRuby Image printing example.',
391
+ description: 'wxRuby example showcasing Wx::SVGFileDC/Wx::PostScriptDC to create SVG/PS files.' }
361
392
  end
362
393
 
363
394
  def self.activate
364
- frame = SVGFrame.new
395
+ frame = ImageFrame.new
365
396
  frame.show
366
397
  frame
367
398
  end
368
399
 
369
400
  if $0 == __FILE__
370
- Wx::App.run { SVGTestSample.activate }
401
+ Wx::App.run { ImagePrintSample.activate }
371
402
  end
372
403
 
373
404
  end
Binary file
@@ -1384,29 +1384,31 @@ class FormMain < Wx::Frame
1384
1384
  Wx::PG::PG_LABEL,
1385
1385
  "Test Text"))
1386
1386
  myTestBitmap1x = Wx::Bitmap.new(60, 15, 32)
1387
- mdc = Wx::MemoryDC.new(myTestBitmap1x)
1388
- mdc.set_background(Wx::WHITE_BRUSH)
1389
- mdc.clear
1390
- mdc.set_pen(Wx::BLACK_PEN)
1391
- mdc.set_brush(Wx::WHITE_BRUSH)
1392
- mdc.draw_rectangle(0, 0, 60, 15)
1393
- mdc.draw_line(0, 0, 59, 14)
1394
- mdc.set_text_foreground(Wx::BLACK)
1395
- mdc.draw_text("x1", 0, 0)
1387
+ Wx::MemoryDC.draw_on(myTestBitmap1x) do |mdc|
1388
+ mdc.set_background(Wx::WHITE_BRUSH)
1389
+ mdc.clear
1390
+ mdc.set_pen(Wx::BLACK_PEN)
1391
+ mdc.set_brush(Wx::WHITE_BRUSH)
1392
+ mdc.draw_rectangle(0, 0, 60, 15)
1393
+ mdc.draw_line(0, 0, 59, 14)
1394
+ mdc.set_text_foreground(Wx::BLACK)
1395
+ mdc.draw_text("x1", 0, 0)
1396
+ end
1396
1397
 
1397
1398
  myTestBitmap2x = Wx::Bitmap.new(120, 30, 32)
1398
- mdc = Wx::MemoryDC.new(myTestBitmap2x)
1399
- mdc.set_background(Wx::WHITE_BRUSH)
1400
- mdc.clear
1401
- mdc.set_pen(Wx::Pen.new(Wx::BLUE, 2))
1402
- mdc.set_brush(Wx::WHITE_BRUSH)
1403
- mdc.draw_rectangle(0, 0, 120, 30)
1404
- mdc.draw_line(0, 0, 119, 31)
1405
- mdc.set_text_foreground(Wx::BLUE)
1406
- f = mdc.font
1407
- f.set_pixel_size(f.get_pixel_size * 2)
1408
- mdc.set_font(f)
1409
- mdc.draw_text("x2", 0, 0)
1399
+ Wx::MemoryDC.draw_on(myTestBitmap2x) do |mdc|
1400
+ mdc.set_background(Wx::WHITE_BRUSH)
1401
+ mdc.clear
1402
+ mdc.set_pen(Wx::Pen.new(Wx::BLUE, 2))
1403
+ mdc.set_brush(Wx::WHITE_BRUSH)
1404
+ mdc.draw_rectangle(0, 0, 120, 30)
1405
+ mdc.draw_line(0, 0, 119, 31)
1406
+ mdc.set_text_foreground(Wx::BLUE)
1407
+ f = mdc.font
1408
+ f.set_pixel_size(f.get_pixel_size * 2)
1409
+ mdc.set_font(f)
1410
+ mdc.draw_text("x2", 0, 0)
1411
+ end
1410
1412
 
1411
1413
  myTestBitmap2x.set_scale_factor(2)
1412
1414
  pg.set_property_image("StringPropertyWithBitmap", Wx::BitmapBundle.from_bitmaps(myTestBitmap1x, myTestBitmap2x))
@@ -153,9 +153,7 @@ class MyFrame < Wx::Frame
153
153
  sizer_panelsizer_h.add(sizer_panelsizer_v, 0)
154
154
  sizer_panel.set_sizer(sizer_panelsizer_h)
155
155
 
156
- label_font = Wx::Font.new(Wx::FontInfo.new(8).light)
157
- @bitmap_creation_dc = Wx::MemoryDC.new
158
- @bitmap_creation_dc.set_font(label_font)
156
+ @label_font = Wx::Font.new(Wx::FontInfo.new(8).light)
159
157
 
160
158
  scheme = Wx::RBN::RibbonPage.new(@ribbon, Wx::ID_ANY, "Appearance", bitmap_(:eye_xpm))
161
159
  @default_primary = Wx::Colour.new
@@ -507,9 +505,10 @@ class MyFrame < Wx::Frame
507
505
 
508
506
  # Colour not in gallery - add it
509
507
  unless item
510
- item = add_colour_to_gallery(gallery,
511
- clr.get_as_string(Wx::C2S_HTML_SYNTAX), @bitmap_creation_dc,
512
- clr)
508
+ Wx::MemoryDC.draw_on do |dc|
509
+ item = add_colour_to_gallery(gallery,
510
+ clr.get_as_string(Wx::C2S_HTML_SYNTAX), dc, clr)
511
+ end
513
512
  gallery.realise
514
513
  end
515
514
 
@@ -738,46 +737,47 @@ class MyFrame < Wx::Frame
738
737
  else
739
738
  gallery = Wx::RBN::RibbonGallery.new(panel, gallery_id)
740
739
  end
741
- dc = @bitmap_creation_dc
742
- def_item = add_colour_to_gallery(gallery, "Default", dc, defclr)
743
- gallery.set_selection(def_item)
744
- add_colour_to_gallery(gallery, "BLUE", dc)
745
- add_colour_to_gallery(gallery, "BLUE VIOLET", dc)
746
- add_colour_to_gallery(gallery, "BROWN", dc)
747
- add_colour_to_gallery(gallery, "CADET BLUE", dc)
748
- add_colour_to_gallery(gallery, "CORAL", dc)
749
- add_colour_to_gallery(gallery, "CYAN", dc)
750
- add_colour_to_gallery(gallery, "DARK GREEN", dc)
751
- add_colour_to_gallery(gallery, "DARK ORCHID", dc)
752
- add_colour_to_gallery(gallery, "FIREBRICK", dc)
753
- add_colour_to_gallery(gallery, "GOLD", dc)
754
- add_colour_to_gallery(gallery, "GOLDENROD", dc)
755
- add_colour_to_gallery(gallery, "GREEN", dc)
756
- add_colour_to_gallery(gallery, "INDIAN RED", dc)
757
- add_colour_to_gallery(gallery, "KHAKI", dc)
758
- add_colour_to_gallery(gallery, "LIGHT BLUE", dc)
759
- add_colour_to_gallery(gallery, "LIME GREEN", dc)
760
- add_colour_to_gallery(gallery, "MAGENTA", dc)
761
- add_colour_to_gallery(gallery, "MAROON", dc)
762
- add_colour_to_gallery(gallery, "NAVY", dc)
763
- add_colour_to_gallery(gallery, "ORANGE", dc)
764
- add_colour_to_gallery(gallery, "ORCHID", dc)
765
- add_colour_to_gallery(gallery, "PINK", dc)
766
- add_colour_to_gallery(gallery, "PLUM", dc)
767
- add_colour_to_gallery(gallery, "PURPLE", dc)
768
- add_colour_to_gallery(gallery, "RED", dc)
769
- add_colour_to_gallery(gallery, "SALMON", dc)
770
- add_colour_to_gallery(gallery, "SEA GREEN", dc)
771
- add_colour_to_gallery(gallery, "SIENNA", dc)
772
- add_colour_to_gallery(gallery, "SKY BLUE", dc)
773
- add_colour_to_gallery(gallery, "TAN", dc)
774
- add_colour_to_gallery(gallery, "THISTLE", dc)
775
- add_colour_to_gallery(gallery, "TURQUOISE", dc)
776
- add_colour_to_gallery(gallery, "VIOLET", dc)
777
- add_colour_to_gallery(gallery, "VIOLET RED", dc)
778
- add_colour_to_gallery(gallery, "WHEAT", dc)
779
- add_colour_to_gallery(gallery, "WHITE", dc)
780
- add_colour_to_gallery(gallery, "YELLOW", dc)
740
+ Wx::MemoryDC.draw_on do |dc|
741
+ def_item = add_colour_to_gallery(gallery, "Default", dc, defclr)
742
+ gallery.set_selection(def_item)
743
+ add_colour_to_gallery(gallery, "BLUE", dc)
744
+ add_colour_to_gallery(gallery, "BLUE VIOLET", dc)
745
+ add_colour_to_gallery(gallery, "BROWN", dc)
746
+ add_colour_to_gallery(gallery, "CADET BLUE", dc)
747
+ add_colour_to_gallery(gallery, "CORAL", dc)
748
+ add_colour_to_gallery(gallery, "CYAN", dc)
749
+ add_colour_to_gallery(gallery, "DARK GREEN", dc)
750
+ add_colour_to_gallery(gallery, "DARK ORCHID", dc)
751
+ add_colour_to_gallery(gallery, "FIREBRICK", dc)
752
+ add_colour_to_gallery(gallery, "GOLD", dc)
753
+ add_colour_to_gallery(gallery, "GOLDENROD", dc)
754
+ add_colour_to_gallery(gallery, "GREEN", dc)
755
+ add_colour_to_gallery(gallery, "INDIAN RED", dc)
756
+ add_colour_to_gallery(gallery, "KHAKI", dc)
757
+ add_colour_to_gallery(gallery, "LIGHT BLUE", dc)
758
+ add_colour_to_gallery(gallery, "LIME GREEN", dc)
759
+ add_colour_to_gallery(gallery, "MAGENTA", dc)
760
+ add_colour_to_gallery(gallery, "MAROON", dc)
761
+ add_colour_to_gallery(gallery, "NAVY", dc)
762
+ add_colour_to_gallery(gallery, "ORANGE", dc)
763
+ add_colour_to_gallery(gallery, "ORCHID", dc)
764
+ add_colour_to_gallery(gallery, "PINK", dc)
765
+ add_colour_to_gallery(gallery, "PLUM", dc)
766
+ add_colour_to_gallery(gallery, "PURPLE", dc)
767
+ add_colour_to_gallery(gallery, "RED", dc)
768
+ add_colour_to_gallery(gallery, "SALMON", dc)
769
+ add_colour_to_gallery(gallery, "SEA GREEN", dc)
770
+ add_colour_to_gallery(gallery, "SIENNA", dc)
771
+ add_colour_to_gallery(gallery, "SKY BLUE", dc)
772
+ add_colour_to_gallery(gallery, "TAN", dc)
773
+ add_colour_to_gallery(gallery, "THISTLE", dc)
774
+ add_colour_to_gallery(gallery, "TURQUOISE", dc)
775
+ add_colour_to_gallery(gallery, "VIOLET", dc)
776
+ add_colour_to_gallery(gallery, "VIOLET RED", dc)
777
+ add_colour_to_gallery(gallery, "WHEAT", dc)
778
+ add_colour_to_gallery(gallery, "WHITE", dc)
779
+ add_colour_to_gallery(gallery, "YELLOW", dc)
780
+ end
781
781
 
782
782
  gallery
783
783
  end
@@ -802,6 +802,7 @@ class MyFrame < Wx::Frame
802
802
 
803
803
  bitmap = Wx::Bitmap.new(iWidth, iHeight)
804
804
  dc.select_object(bitmap)
805
+ dc.set_font(@label_font)
805
806
  b = Wx::Brush.new (c)
806
807
  dc.set_pen(Wx::BLACK_PEN)
807
808
  dc.set_brush(b)
@@ -3,7 +3,7 @@ require 'test/unit'
3
3
  require 'test/unit/ui/console/testrunner'
4
4
  require 'wx'
5
5
 
6
- module Wx::SF
6
+ module WxRuby
7
7
 
8
8
  module Test
9
9
 
@@ -33,7 +33,7 @@ module Wx::SF
33
33
 
34
34
  org_start_mtd = instance_method :start
35
35
  define_method :start do
36
- (app = Wx::SF::Test::App.new(self, org_start_mtd)).run
36
+ (app = WxRuby::Test::App.new(self, org_start_mtd)).run
37
37
  app.result
38
38
  end
39
39
 
@@ -46,7 +46,7 @@ end
46
46
  module Test
47
47
  module Unit
48
48
  AutoRunner.register_runner(:wxapp) do |auto_runner|
49
- Wx::SF::Test::Runner
49
+ WxRuby::Test::Runner
50
50
  end
51
51
  AutoRunner.default_runner = :wxapp
52
52
  if defined? ::IntelliJ
@@ -0,0 +1,59 @@
1
+
2
+ require_relative './wxapp_runner'
3
+
4
+ module WxRuby
5
+
6
+ module Test
7
+
8
+ class App < Wx::App
9
+ def on_init
10
+ @tests_have_run = false
11
+ evt_idle :on_idle
12
+ @frame = Wx::Frame.new(nil, size: [600,400])
13
+ @frame.show
14
+ end
15
+
16
+ def on_idle(_evt)
17
+ done = @tests_have_run
18
+ @tests_have_run = true
19
+ @result = @start_mtd.bind(@test_runner).call unless done
20
+ self.exit_main_loop
21
+ end
22
+
23
+ attr_reader :frame
24
+ end
25
+
26
+ class GUITests < ::Test::Unit::TestCase
27
+
28
+ def test_frame
29
+ Wx.get_app.frame
30
+ end
31
+
32
+ class EventCounter
33
+ def initialize
34
+ @count = 0
35
+ end
36
+ attr_accessor :count
37
+
38
+ def inc
39
+ @count +=1
40
+ end
41
+ end
42
+
43
+ def count_events(win, evt, id1=Wx::ID_ANY, id2=nil)
44
+ return 0 unless block_given?
45
+ evt_count = EventCounter.new
46
+ if id2.nil?
47
+ win.event_handler.send(evt.to_sym, id1, ->(_evt){ evt_count.inc })
48
+ else
49
+ win.event_handler.send(evt.to_sym, id1, id2, ->(_evt){ evt_count.inc })
50
+ end
51
+ yield evt_count
52
+ evt_count.count
53
+ end
54
+
55
+ end
56
+
57
+ end
58
+
59
+ end
@@ -0,0 +1,74 @@
1
+
2
+ require_relative './lib/wxapp_runner'
3
+
4
+ class AppEventFilterTests < Test::Unit::TestCase
5
+
6
+ class TestEvent < Wx::Event
7
+ EVT_TEST_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_event', 0)
8
+ def initialize(id=0)
9
+ super(EVT_TEST_EVENT, id)
10
+ end
11
+ end
12
+
13
+ class TestCmdEvent < Wx::CommandEvent
14
+ EVT_TEST_CMD_EVENT = Wx::EvtHandler.register_class(self, nil, 'evt_test_cmd_event', 0)
15
+ def initialize(id=0)
16
+ super(EVT_TEST_CMD_EVENT, id)
17
+ end
18
+ end
19
+
20
+ class TestFrame < Wx::Frame
21
+ def initialize
22
+ super(nil, size: [300,300])
23
+ @test_event = false
24
+ @test_cmd_event = false
25
+
26
+ evt_test_event { |evt| @test_event = true }
27
+ evt_test_cmd_event { |evt| @test_cmd_event = true }
28
+ end
29
+
30
+ attr_reader :test_event, :test_cmd_event
31
+
32
+ def reset
33
+ @test_event = false
34
+ @test_cmd_event = false
35
+ end
36
+ end
37
+
38
+ module ::WxRuby
39
+ module Test
40
+ class App < Wx::App
41
+ def filter_event(event)
42
+ @filtered = true if event.is_a?(TestEvent)
43
+ super
44
+ end
45
+
46
+ def filtered
47
+ @filtered
48
+ end
49
+
50
+ def filtered=(f)
51
+ @filtered = f
52
+ end
53
+ end
54
+ end
55
+ end
56
+
57
+ def test_app_event_filter
58
+ GC.start
59
+ win = TestFrame.new
60
+ win.event_handler.process_event(TestEvent.new)
61
+ GC.start
62
+ assert(Wx.get_app.filtered)
63
+ Wx.get_app.filtered = false
64
+ win.event_handler.process_event(TestCmdEvent.new)
65
+ GC.start
66
+ assert(!Wx.get_app.filtered)
67
+ assert_nothing_raised { Wx::EvtHandler.clear_filters }
68
+ GC.start
69
+ win.event_handler.process_event(TestEvent.new)
70
+ assert(Wx.get_app.filtered)
71
+ GC.start
72
+ end
73
+
74
+ end
@@ -0,0 +1,52 @@
1
+
2
+ require_relative './lib/wxapp_runner'
3
+
4
+ class TestArtProvider < Test::Unit::TestCase
5
+
6
+ class MyArtProvider < Wx::ArtProvider
7
+
8
+ class << self
9
+ def is_called?
10
+ !!@called
11
+ end
12
+ def set_called(f = true)
13
+ @called = f
14
+ end
15
+ end
16
+
17
+ def create_bitmap(id, client, size)
18
+ if id == Wx::ArtProvider.get_message_box_icon_id(Wx::ICON_INFORMATION)
19
+ MyArtProvider.set_called
20
+ Wx::Bitmap(:sample3)
21
+ else
22
+ MyArtProvider.set_called(false)
23
+ super
24
+ end
25
+ end
26
+
27
+ end
28
+
29
+ def test_custom_provider
30
+ assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
31
+ GC.start
32
+ assert(!MyArtProvider.is_called?)
33
+ GC.start
34
+ assert_nothing_raised { Wx::ArtProvider.push(MyArtProvider.new) }
35
+ GC.start
36
+ assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
37
+ GC.start
38
+ assert(MyArtProvider.is_called?)
39
+ GC.start
40
+ assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_ERROR))
41
+ GC.start
42
+ assert(!MyArtProvider.is_called?)
43
+ GC.start
44
+ assert_nothing_raised { Wx::ArtProvider.pop }
45
+ GC.start
46
+ assert_not_nil(Wx::ArtProvider.get_message_box_icon(Wx::ICON_INFORMATION))
47
+ GC.start
48
+ assert(!MyArtProvider.is_called?)
49
+ GC.start
50
+ end
51
+
52
+ end
@@ -54,6 +54,7 @@ if Wx.has_feature?(:USE_HTML) && Wx::WXWIDGETS_VERSION >= '3.3'
54
54
  Wx::Clipboard.open do | clip |
55
55
  clip.fetch td_2
56
56
  end
57
+
57
58
  assert_equal('<html><body><h1>Header</h1></body></html>', td_2.html)
58
59
 
59
60
  Wx::Clipboard.open do | clip |
@@ -64,7 +65,7 @@ if Wx.has_feature?(:USE_HTML) && Wx::WXWIDGETS_VERSION >= '3.3'
64
65
  Wx::Clipboard.open do | clip |
65
66
  clip.fetch td_3
66
67
  end
67
- assert_equal('', td_3.get_data_here)
68
+ assert_equal('', td_3.get_html)
68
69
  end
69
70
  end
70
71
  end