wxruby3 0.9.0.pre.beta.14-x64-mingw-ucrt → 0.9.0.pre.rc.2-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (278) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/INSTALL.md +51 -22
  4. data/README.md +81 -6
  5. data/assets/hello_button-macos.png +0 -0
  6. data/assets/hello_button-msw.png +0 -0
  7. data/assets/hello_button.png +0 -0
  8. data/assets/hello_button_clicked-macos.png +0 -0
  9. data/assets/hello_button_clicked-msw.png +0 -0
  10. data/assets/hello_button_clicked.png +0 -0
  11. data/assets/hello_button_clicked_combi.png +0 -0
  12. data/assets/hello_world-macos.png +0 -0
  13. data/assets/hello_world-msw.png +0 -0
  14. data/assets/hello_world.png +0 -0
  15. data/assets/hello_world_combi.png +0 -0
  16. data/assets/repo-social-preview.png +0 -0
  17. data/ext/wxbase32u_gcc_custom.dll +0 -0
  18. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  19. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  20. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  21. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  22. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  23. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  24. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  25. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  26. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  27. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  28. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  29. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  30. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  31. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  32. data/lib/wx/core/art_locator.rb +2 -2
  33. data/lib/wx/core/artprovider.rb +2 -2
  34. data/lib/wx/core/bitmap.rb +6 -5
  35. data/lib/wx/core/bitmap_combobox.rb +34 -0
  36. data/lib/wx/core/brush.rb +6 -0
  37. data/lib/wx/core/controlwithitems.rb +52 -14
  38. data/lib/wx/core/cursor.rb +1 -1
  39. data/lib/wx/core/dc.rb +0 -20
  40. data/lib/wx/core/event_blocker.rb +14 -0
  41. data/lib/wx/core/events/evt_list.rb +19 -0
  42. data/lib/wx/core/evthandler.rb +48 -2
  43. data/lib/wx/core/find_replace_dialog.rb +24 -0
  44. data/lib/wx/core/font.rb +22 -14
  45. data/lib/wx/core/helpprovider.rb +2 -2
  46. data/lib/wx/core/icon.rb +1 -1
  47. data/lib/wx/core/image.rb +1 -1
  48. data/lib/wx/core/menu.rb +5 -0
  49. data/lib/wx/core/paintdc.rb +8 -0
  50. data/lib/wx/core/pen.rb +6 -0
  51. data/lib/wx/core/text_entry.rb +15 -0
  52. data/lib/wx/core/v_list_box.rb +13 -0
  53. data/lib/wx/core/window.rb +29 -2
  54. data/lib/wx/doc/app.rb +40 -0
  55. data/lib/wx/doc/brush.rb +17 -0
  56. data/lib/wx/doc/busy_info.rb +21 -0
  57. data/lib/wx/doc/client_dc.rb +28 -0
  58. data/lib/wx/doc/controlwithitems.rb +11 -0
  59. data/lib/wx/doc/dc.rb +0 -14
  60. data/lib/wx/doc/event_blocker.rb +27 -0
  61. data/lib/wx/doc/evthandler.rb +4 -0
  62. data/lib/wx/doc/extra/02_lifecycles.md +49 -0
  63. data/lib/wx/doc/extra/10_art.md +1 -1
  64. data/lib/wx/doc/extra/11_drawing_and_dc.md +62 -0
  65. data/lib/wx/doc/font.rb +27 -0
  66. data/lib/wx/doc/gen/about_dialog_info.rb +27 -24
  67. data/lib/wx/doc/gen/accelerator.rb +11 -12
  68. data/lib/wx/doc/gen/activity_indicator.rb +65 -0
  69. data/lib/wx/doc/gen/app.rb +6 -3
  70. data/lib/wx/doc/gen/art_provider.rb +53 -29
  71. data/lib/wx/doc/gen/aui/aui_manager.rb +4 -0
  72. data/lib/wx/doc/gen/aui/aui_mdi_child_frame.rb +1 -1
  73. data/lib/wx/doc/gen/aui/aui_pane_info.rb +2 -0
  74. data/lib/wx/doc/gen/aui/aui_tab_ctrl.rb +2 -0
  75. data/lib/wx/doc/gen/aui/aui_tool_bar.rb +2 -2
  76. data/lib/wx/doc/gen/bitmap.rb +25 -25
  77. data/lib/wx/doc/gen/bitmap_combo_box.rb +157 -0
  78. data/lib/wx/doc/gen/box_sizer.rb +6 -8
  79. data/lib/wx/doc/gen/brush.rb +2 -0
  80. data/lib/wx/doc/gen/busy_info.rb +52 -46
  81. data/lib/wx/doc/gen/caret.rb +0 -4
  82. data/lib/wx/doc/gen/check_list_box.rb +0 -2
  83. data/lib/wx/doc/gen/choice.rb +1 -5
  84. data/lib/wx/doc/gen/client_dc.rb +13 -18
  85. data/lib/wx/doc/gen/clipboard.rb +30 -27
  86. data/lib/wx/doc/gen/collapsible_pane.rb +11 -9
  87. data/lib/wx/doc/gen/colour.rb +6 -3
  88. data/lib/wx/doc/gen/colour_dialog.rb +111 -23
  89. data/lib/wx/doc/gen/combo_box.rb +2 -4
  90. data/lib/wx/doc/gen/context_help_button.rb +48 -0
  91. data/lib/wx/doc/gen/control.rb +20 -18
  92. data/lib/wx/doc/gen/core.rb +2 -2
  93. data/lib/wx/doc/gen/cursor.rb +18 -50
  94. data/lib/wx/doc/gen/data_format.rb +0 -2
  95. data/lib/wx/doc/gen/data_object.rb +37 -44
  96. data/lib/wx/doc/gen/dc.rb +16 -24
  97. data/lib/wx/doc/gen/defs.rb +3 -40
  98. data/lib/wx/doc/gen/dialog.rb +21 -17
  99. data/lib/wx/doc/gen/dir_dialog.rb +10 -8
  100. data/lib/wx/doc/gen/event.rb +2 -2
  101. data/lib/wx/doc/gen/event_blocker.rb +51 -0
  102. data/lib/wx/doc/gen/event_filter.rb +88 -0
  103. data/lib/wx/doc/gen/event_list.rb +23 -2
  104. data/lib/wx/doc/gen/events.rb +103 -112
  105. data/lib/wx/doc/gen/evt_handler.rb +28 -52
  106. data/lib/wx/doc/gen/file_dialog.rb +53 -50
  107. data/lib/wx/doc/gen/find_replace_dialog.rb +1 -1
  108. data/lib/wx/doc/gen/font.rb +19 -2
  109. data/lib/wx/doc/gen/font_data.rb +2 -0
  110. data/lib/wx/doc/gen/font_dialog.rb +1 -1
  111. data/lib/wx/doc/gen/frame.rb +4 -3
  112. data/lib/wx/doc/gen/fs_file.rb +8 -0
  113. data/lib/wx/doc/gen/gcdc.rb +2 -22
  114. data/lib/wx/doc/gen/gdi_common.rb +18 -2
  115. data/lib/wx/doc/gen/gdi_object.rb +2 -0
  116. data/lib/wx/doc/gen/graphics_context.rb +4 -43
  117. data/lib/wx/doc/gen/graphics_object.rb +2 -0
  118. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +2 -1
  119. data/lib/wx/doc/gen/grid/grid_ctrl.rb +4 -2
  120. data/lib/wx/doc/gen/grid/grid_table_message.rb +2 -0
  121. data/lib/wx/doc/gen/grid_bag_sizer.rb +4 -0
  122. data/lib/wx/doc/gen/help_controller.rb +4 -1
  123. data/lib/wx/doc/gen/html/html_cell.rb +4 -1
  124. data/lib/wx/doc/gen/html/html_help_controller.rb +4 -1
  125. data/lib/wx/doc/gen/html/html_help_data.rb +4 -0
  126. data/lib/wx/doc/gen/html/html_help_window.rb +2 -1
  127. data/lib/wx/doc/gen/html/html_list_box.rb +138 -11
  128. data/lib/wx/doc/gen/html/html_window.rb +9 -3
  129. data/lib/wx/doc/gen/hyperlink_ctrl.rb +147 -0
  130. data/lib/wx/doc/gen/hyperlink_event.rb +43 -0
  131. data/lib/wx/doc/gen/icon.rb +7 -1
  132. data/lib/wx/doc/gen/icon_location.rb +2 -0
  133. data/lib/wx/doc/gen/image.rb +15 -8
  134. data/lib/wx/doc/gen/keyboard_state.rb +6 -0
  135. data/lib/wx/doc/gen/list_box.rb +0 -11
  136. data/lib/wx/doc/gen/list_ctrl.rb +10 -13
  137. data/lib/wx/doc/gen/locale.rb +7 -3
  138. data/lib/wx/doc/gen/log.rb +6 -2
  139. data/lib/wx/doc/gen/mdi_frame.rb +2 -0
  140. data/lib/wx/doc/gen/media_ctrl.rb +2 -0
  141. data/lib/wx/doc/gen/memory_dc.rb +105 -18
  142. data/lib/wx/doc/gen/menu.rb +4 -2
  143. data/lib/wx/doc/gen/menu_bar.rb +0 -8
  144. data/lib/wx/doc/gen/menu_item.rb +9 -3
  145. data/lib/wx/doc/gen/message_dialog.rb +6 -3
  146. data/lib/wx/doc/gen/mirror_dc.rb +2 -8
  147. data/lib/wx/doc/gen/mouse_state.rb +2 -0
  148. data/lib/wx/doc/gen/multi_choice_dialog.rb +0 -2
  149. data/lib/wx/doc/gen/non_owned_window.rb +2 -1
  150. data/lib/wx/doc/gen/notebook.rb +4 -2
  151. data/lib/wx/doc/gen/paint_dc.rb +2 -6
  152. data/lib/wx/doc/gen/palette.rb +3 -3
  153. data/lib/wx/doc/gen/pen.rb +6 -1
  154. data/lib/wx/doc/gen/pg/pg_editor.rb +2 -1
  155. data/lib/wx/doc/gen/pg/pg_multi_button.rb +4 -0
  156. data/lib/wx/doc/gen/pg/pg_properties.rb +30 -3
  157. data/lib/wx/doc/gen/pg/pg_property.rb +30 -4
  158. data/lib/wx/doc/gen/pg/pg_validation_info.rb +2 -0
  159. data/lib/wx/doc/gen/pg/property_grid.rb +5 -2
  160. data/lib/wx/doc/gen/pg/property_grid_interface.rb +6 -2
  161. data/lib/wx/doc/gen/pg/property_grid_manager.rb +2 -0
  162. data/lib/wx/doc/gen/pg/property_grid_page_state.rb +2 -0
  163. data/lib/wx/doc/gen/picker_base.rb +2 -1
  164. data/lib/wx/doc/gen/platform_info.rb +4 -1
  165. data/lib/wx/doc/gen/property_sheet_dialog.rb +2 -0
  166. data/lib/wx/doc/gen/prt/post_script_dc.rb +2 -8
  167. data/lib/wx/doc/gen/prt/print_data.rb +6 -0
  168. data/lib/wx/doc/gen/prt/printer.rb +0 -3
  169. data/lib/wx/doc/gen/prt/printer_dc.rb +2 -6
  170. data/lib/wx/doc/gen/radio_box.rb +2 -10
  171. data/lib/wx/doc/gen/rbn/ribbon_art_provider.rb +6 -0
  172. data/lib/wx/doc/gen/rbn/ribbon_panel.rb +1 -1
  173. data/lib/wx/doc/gen/region.rb +2 -0
  174. data/lib/wx/doc/gen/rtc/rich_text_buffer.rb +6 -0
  175. data/lib/wx/doc/gen/rtc/rich_text_ctrl.rb +0 -4
  176. data/lib/wx/doc/gen/rtc/rich_text_header_footer_data.rb +2 -0
  177. data/lib/wx/doc/gen/rtc/rich_text_html_handler.rb +2 -1
  178. data/lib/wx/doc/gen/rtc/symbol_picker_dialog.rb +2 -0
  179. data/lib/wx/doc/gen/screen_dc.rb +2 -0
  180. data/lib/wx/doc/gen/scroll_bar.rb +2 -1
  181. data/lib/wx/doc/gen/scrolled_canvas.rb +4 -8
  182. data/lib/wx/doc/gen/scrolled_control.rb +4 -8
  183. data/lib/wx/doc/gen/scrolled_window.rb +4 -8
  184. data/lib/wx/doc/gen/search_ctrl.rb +131 -0
  185. data/lib/wx/doc/gen/single_choice_dialog.rb +0 -2
  186. data/lib/wx/doc/gen/sizer.rb +14 -3
  187. data/lib/wx/doc/gen/splash_screen.rb +2 -0
  188. data/lib/wx/doc/gen/static_box.rb +6 -3
  189. data/lib/wx/doc/gen/static_box_sizer.rb +2 -1
  190. data/lib/wx/doc/gen/status_bar.rb +0 -5
  191. data/lib/wx/doc/gen/stc/styled_text_ctrl.rb +4 -5
  192. data/lib/wx/doc/gen/svg_file_dc.rb +10 -11
  193. data/lib/wx/doc/gen/text_ctrl.rb +10 -3
  194. data/lib/wx/doc/gen/text_entry.rb +8 -3
  195. data/lib/wx/doc/gen/text_entry_dialog.rb +4 -2
  196. data/lib/wx/doc/gen/timer_event.rb +2 -0
  197. data/lib/wx/doc/gen/tool_bar.rb +8 -4
  198. data/lib/wx/doc/gen/top_level_window.rb +5 -2
  199. data/lib/wx/doc/gen/tree_ctrl.rb +0 -6
  200. data/lib/wx/doc/gen/ui_action_simulator.rb +100 -0
  201. data/lib/wx/doc/gen/utils.rb +1 -1
  202. data/lib/wx/doc/gen/v_list_box.rb +36 -26
  203. data/lib/wx/doc/gen/validator.rb +2 -1
  204. data/lib/wx/doc/gen/variant.rb +10 -0
  205. data/lib/wx/doc/gen/window.rb +38 -17
  206. data/lib/wx/doc/gen/window_dc.rb +2 -0
  207. data/lib/wx/doc/gen/window_disabler.rb +2 -0
  208. data/lib/wx/doc/gen/wizard_page_simple.rb +2 -0
  209. data/lib/wx/doc/gen/xml_node.rb +6 -0
  210. data/lib/wx/doc/gen/xml_resource.rb +4 -1
  211. data/lib/wx/doc/memory_dc.rb +75 -0
  212. data/lib/wx/doc/mirror_dc.rb +16 -0
  213. data/lib/wx/doc/pen.rb +17 -0
  214. data/lib/wx/doc/prt/printer_dc.rb +26 -0
  215. data/lib/wx/doc/radio_box.rb +20 -0
  216. data/lib/wx/doc/screen_dc.rb +10 -6
  217. data/lib/wx/doc/svg_file_dc.rb +20 -0
  218. data/lib/wx/doc/v_list_box.rb +9 -0
  219. data/lib/wx/doc/window.rb +27 -0
  220. data/lib/wx/doc/window_disabler.rb +10 -0
  221. data/lib/wx/html/keyword_defs.rb +6 -7
  222. data/lib/wx/html/require.rb +1 -0
  223. data/lib/wx/html/simple_html_listbox.rb +105 -0
  224. data/lib/wx/keyword_defs.rb +83 -75
  225. data/lib/wx/prt/keyword_defs.rb +5 -1
  226. data/lib/wx/version.rb +1 -1
  227. data/lib/wx/wxruby/cmd/test.rb +1 -1
  228. data/lib/wxruby_aui.so +0 -0
  229. data/lib/wxruby_core.so +0 -0
  230. data/lib/wxruby_grid.so +0 -0
  231. data/lib/wxruby_html.so +0 -0
  232. data/lib/wxruby_pg.so +0 -0
  233. data/lib/wxruby_prt.so +0 -0
  234. data/lib/wxruby_rbn.so +0 -0
  235. data/lib/wxruby_rtc.so +0 -0
  236. data/lib/wxruby_stc.so +0 -0
  237. data/rakelib/install.rb +20 -7
  238. data/rakelib/lib/config/linux.rb +4 -2
  239. data/rakelib/lib/config/macosx.rb +120 -1
  240. data/rakelib/lib/config/mingw.rb +6 -1
  241. data/rakelib/lib/config/unixish.rb +26 -11
  242. data/rakelib/lib/config.rb +15 -6
  243. data/rakelib/yard/yard/relative_markdown_links.rb +5 -1
  244. data/samples/aui/aui.rb +432 -363
  245. data/samples/bigdemo/wxArtProvider.rbw +5 -4
  246. data/samples/controls/controls.rb +2 -2
  247. data/samples/controls/htlbox.rb +411 -0
  248. data/samples/controls/tn_htlbox.png +0 -0
  249. data/samples/drawing/graphics_drawing.rb +1 -2
  250. data/samples/drawing/{svgtest.rb → image_prt.rb} +49 -18
  251. data/samples/drawing/tn_image_prt.png +0 -0
  252. data/samples/propgrid/propgrid.rb +26 -21
  253. data/samples/ribbon/ribbon.rb +47 -46
  254. data/samples/sampler/editor.rb +33 -25
  255. data/samples/sampler/sample.rb +2 -2
  256. data/samples/sampler/stc_editor.rb +4 -2
  257. data/tests/lib/item_container_tests.rb +82 -0
  258. data/tests/lib/text_entry_tests.rb +80 -0
  259. data/tests/lib/wxapp_runner.rb +15 -3
  260. data/tests/lib/wxframe_runner.rb +144 -0
  261. data/tests/test_app_event_filter.rb +74 -0
  262. data/tests/test_art_provider.rb +52 -0
  263. data/tests/test_clipboard.rb +2 -1
  264. data/tests/test_event_handling.rb +199 -16
  265. data/tests/test_events.rb +4 -11
  266. data/tests/test_ext_controls.rb +28 -0
  267. data/tests/test_font.rb +239 -0
  268. data/tests/test_gdi_object.rb +161 -0
  269. data/tests/test_intl.rb +16 -15
  270. data/tests/test_item_data.rb +33 -1
  271. data/tests/test_std_controls.rb +373 -0
  272. data/tests/test_window.rb +340 -0
  273. metadata +61 -8
  274. data/lib/wx/doc/gen/auto_buffered_paint_dc.rb +0 -47
  275. data/lib/wx/doc/gen/buffered_dc.rb +0 -95
  276. data/lib/wx/doc/gen/buffered_paint_dc.rb +0 -55
  277. data/lib/wx/doc/gen/colour_data.rb +0 -96
  278. data/samples/drawing/tn_svgtest.png +0 -0
@@ -242,10 +242,11 @@ class TestPanel < Wx::Panel
242
242
 
243
243
 
244
244
  def clear_bmp(bmp)
245
- dc = Wx::MemoryDC.new
246
- dc.select_object(bmp)
247
- dc.set_background(Wx::WHITE_BRUSH)
248
- dc.clear
245
+ Wx::MemoryDC.draw_on do |dc|
246
+ dc.select_object(bmp)
247
+ dc.set_background(Wx::WHITE_BRUSH)
248
+ dc.clear
249
+ end
249
250
  end
250
251
  end
251
252
 
@@ -117,8 +117,8 @@ class MyComboBox < ComboBox
117
117
  end
118
118
 
119
119
  def onChar(event)
120
- log_message("MyComboBox::OnChar")
121
- if event.key_code() == ?w
120
+ log_message("MyComboBox::OnChar : [#{event.get_unicode_key ? event.get_unicode_key.ord : 0}]")
121
+ if event.get_unicode_key == ?w
122
122
  log_message("MyComboBox: 'w' will be ignored.")
123
123
  else
124
124
  event.skip()
@@ -0,0 +1,411 @@
1
+ #!/usr/bin/env ruby
2
+ # Copyright (c) M.J.N. Corino, The Netherlands
3
+ ###
4
+
5
+ require 'wx'
6
+
7
+ # to use Wx::HtmlListBox you must derive a new class from it as you must
8
+ # implement virtual on_get_item
9
+ class MyHtmlListBox < Wx::HTML::HtmlListBox
10
+
11
+ def initialize(parent, multi = false)
12
+ super(parent, style: multi ? Wx::LB_MULTIPLE : 0)
13
+ # flag telling us whether we should use fg colour even for the selected
14
+ # item
15
+ @change = false
16
+ # flag which we toggle to update the first items text in on_get_item()
17
+ @first_item_updated = false
18
+ @link_clicked = false
19
+
20
+ set_margins(5, 5)
21
+
22
+ set_item_count(1000)
23
+
24
+ set_selection(3)
25
+ end
26
+
27
+ attr_accessor :link_clicked
28
+
29
+ def set_change_sel_fg(change)
30
+ @change = change
31
+ end
32
+
33
+ def update_first_item
34
+ @first_item_updated = !@first_item_updated
35
+
36
+ refresh_row(0)
37
+ end
38
+
39
+ protected
40
+
41
+ # override this method to return data to be shown in the listbox (this is
42
+ # mandatory)
43
+ def on_get_item(n)
44
+ return '<h1><b>Just updated</b></h1>' if n == 0 && @first_item_updated
45
+
46
+ level = n % 6 + 1
47
+
48
+ clr = Wx::Colour.new((n - 192).abs % 256,
49
+ (n - 256).abs % 256,
50
+ (n - 128).abs % 256)
51
+
52
+ label = "<h#{level}><font color=#{clr.get_as_string(Wx::C2S_HTML_SYNTAX)}>Item</font> <b>#{n}</b></h#{level}>"
53
+ if n == 1
54
+ if !@link_clicked
55
+ label += "<a href='1'>Click here...</a>"
56
+ else
57
+ label += "<font color='#9999ff'>Clicked here...</font>"
58
+ end
59
+ end
60
+
61
+ label
62
+ end
63
+
64
+ # change the appearance by overriding these functions (this is optional)
65
+ def on_draw_separator(dc, rect, _)
66
+ if get_parent.menu_bar.is_checked(MyFrame::ID::HtmlLbox_DrawSeparator)
67
+ dc.with_pen(Wx::BLACK_DASHED_PEN) do
68
+ dc.draw_line(rect.x, rect.y, rect.right, rect.y)
69
+ dc.draw_line(rect.x, rect.bottom, rect.right, rect.bottom)
70
+ end
71
+ end
72
+ end
73
+
74
+ def get_selected_text_colour(col_fg)
75
+ @change ? super : col_fg
76
+ end
77
+
78
+ end
79
+
80
+ class MyFrame < Wx::Frame
81
+
82
+ # IDs for the controls and the menu commands
83
+ module ID
84
+ include Wx::IDHelper
85
+ # menu items
86
+ HtmlLbox_CustomBox = self.next_id
87
+ HtmlLbox_SimpleBox = self.next_id
88
+ HtmlLbox_Quit = self.next_id
89
+
90
+ HtmlLbox_SetMargins = self.next_id
91
+ HtmlLbox_DrawSeparator = self.next_id
92
+ HtmlLbox_ToggleMulti = self.next_id
93
+ HtmlLbox_SelectAll = self.next_id
94
+ HtmlLbox_UpdateItem = self.next_id
95
+ HtmlLbox_GetItemRect = self.next_id
96
+
97
+ HtmlLbox_SetBgCol = self.next_id
98
+ HtmlLbox_SetSelBgCol = self.next_id
99
+ HtmlLbox_SetSelFgCol = self.next_id
100
+
101
+ HtmlLbox_Clear = self.next_id
102
+
103
+ # it is important for the id corresponding to the "About" command to have
104
+ # this standard value as otherwise it won't be handled properly under Mac
105
+ # (where it is special and put into the "Apple" menu)
106
+ HtmlLbox_About = Wx::ID_ABOUT
107
+ end
108
+
109
+ Wx::ArtLocator.add_search_path(File.dirname(__dir__))
110
+
111
+ def initialize
112
+ super(nil, title: 'HtmlLbox wxWidgets Sample',size: [500, 500])
113
+
114
+ # set the frame icon
115
+ set_icon(Wx::Icon(:sample))
116
+
117
+ if Wx.has_feature?(:USE_MENUS)
118
+
119
+ # create a menu bar
120
+ menu_file = Wx::Menu.new
121
+ menu_file.append_radio_item(ID::HtmlLbox_CustomBox, "Use custom box",
122
+ "Use a wxHtmlListBox virtual class control")
123
+ menu_file.append_radio_item(ID::HtmlLbox_SimpleBox, "Use simple box",
124
+ "Use a wxSimpleHtmlListBox control")
125
+ menu_file.append_separator
126
+ menu_file.append(ID::HtmlLbox_Quit, "E&xit\tAlt-X", "Quit this program")
127
+
128
+ # create our specific menu
129
+ menu_hl_box = Wx::Menu.new
130
+ menu_hl_box.append(ID::HtmlLbox_SetMargins, "Set &margins...\tCtrl-G", "Change the margins around the items")
131
+ menu_hl_box.append_check_item(ID::HtmlLbox_DrawSeparator,
132
+ "&Draw separators\tCtrl-D" ,
133
+ "Toggle drawing separators between cells")
134
+ menu_hl_box.append_separator
135
+ menu_hl_box.append_check_item(ID::HtmlLbox_ToggleMulti,
136
+ "&Multiple selection\tCtrl-M",
137
+ "Toggle multiple selection on/off")
138
+ menu_hl_box.append_separator
139
+ menu_hl_box.append(ID::HtmlLbox_SelectAll, "Select &all items\tCtrl-A")
140
+ menu_hl_box.append(ID::HtmlLbox_UpdateItem, "Update &first item\tCtrl-U")
141
+ menu_hl_box.append(ID::HtmlLbox_GetItemRect, "Show &rectangle of item #10\tCtrl-R")
142
+ menu_hl_box.append_separator
143
+ menu_hl_box.append(ID::HtmlLbox_SetBgCol, "Set &background...\tCtrl-B")
144
+ menu_hl_box.append(ID::HtmlLbox_SetSelBgCol,
145
+ "Set &selection background...\tCtrl-S")
146
+ menu_hl_box.append_check_item(ID::HtmlLbox_SetSelFgCol,
147
+ "Keep &foreground in selection\tCtrl-F")
148
+
149
+ menu_hl_box.append_separator
150
+ menu_hl_box.append(ID::HtmlLbox_Clear, "&Clear\tCtrl-L")
151
+
152
+ # the "About" item should be in the help menu
153
+ help_menu = Wx::Menu.new
154
+ help_menu.append(ID::HtmlLbox_About, "&About\tF1", "Show about dialog")
155
+
156
+ # now append the freshly created menu to the menu bar...
157
+ mbar = Wx::MenuBar.new
158
+ mbar.append(menu_file, "&File")
159
+ mbar.append(menu_hl_box, "&Listbox")
160
+ mbar.append(help_menu, "&Help")
161
+
162
+ mbar.check(ID::HtmlLbox_DrawSeparator, true)
163
+
164
+ # ... and attach this menu bar to the frame
165
+ self.menu_bar = mbar
166
+
167
+ end # USE_MENUS
168
+
169
+ if Wx.has_feature?(:USE_STATUSBAR)
170
+ # create a status bar just for fun (by default with 1 pane only)
171
+ create_status_bar(2)
172
+ set_status_text("Welcome to wxWidgets!")
173
+ end # USE_STATUSBAR
174
+
175
+ # create the child controls
176
+ create_box
177
+ text = Wx::TextCtrl.new(self, Wx::ID_ANY, "", style: Wx::TE_MULTILINE)
178
+ Wx::Log.set_active_target(Wx::LogTextCtrl.new(text))
179
+
180
+ # and lay them out
181
+ sizer = Wx::HBoxSizer.new
182
+ sizer.add(@hlbox, 2, Wx::GROW)
183
+ sizer.add(text, 3, Wx::GROW)
184
+
185
+ self.sizer = sizer
186
+
187
+ evt_menu ID::HtmlLbox_CustomBox, :on_simple_or_custom_box
188
+ evt_menu ID::HtmlLbox_SimpleBox, :on_simple_or_custom_box
189
+ evt_menu ID::HtmlLbox_Quit, :on_quit
190
+
191
+ evt_menu ID::HtmlLbox_SetMargins, :on_set_margins
192
+ evt_menu ID::HtmlLbox_DrawSeparator, :on_draw_separator
193
+ evt_menu ID::HtmlLbox_ToggleMulti, :on_toggle_multi
194
+ evt_menu ID::HtmlLbox_SelectAll, :on_select_all
195
+ evt_menu ID::HtmlLbox_UpdateItem, :on_update_item
196
+ evt_menu ID::HtmlLbox_GetItemRect, :on_get_item_rect
197
+
198
+ evt_menu ID::HtmlLbox_About, :on_about
199
+
200
+ evt_menu ID::HtmlLbox_SetBgCol, :on_set_bg_col
201
+ evt_menu ID::HtmlLbox_SetSelBgCol, :on_set_sel_bg_col
202
+ evt_menu ID::HtmlLbox_SetSelFgCol, :on_set_sel_fg_col
203
+
204
+ evt_menu ID::HtmlLbox_Clear, :on_clear
205
+
206
+ evt_update_ui ID::HtmlLbox_SelectAll, :on_update_ui_select_all
207
+
208
+ evt_listbox Wx::ID_ANY, :on_lbox_select
209
+ evt_listbox_dclick Wx::ID_ANY, :on_lbox_d_click
210
+
211
+ # the HTML listbox's events
212
+ evt_html_link_clicked Wx::ID_ANY, :on_html_link_clicked
213
+ evt_html_cell_hover Wx::ID_ANY, :on_html_cell_hover
214
+ evt_html_cell_clicked Wx::ID_ANY, :on_html_cell_clicked
215
+ end
216
+
217
+ # event handlers
218
+ def on_simple_or_custom_box(event)
219
+ old = @hlbox
220
+
221
+ # we need to recreate the listbox
222
+ create_box
223
+ get_sizer.replace(old, @hlbox)
224
+ old.destroy
225
+
226
+ get_sizer.layout
227
+ refresh
228
+ end
229
+ def on_quit(event)
230
+ # true is to force the frame to close
231
+ close(true)
232
+ end
233
+ def on_about(event)
234
+ Wx.message_box("This sample shows Wx::HtmlListBox class.\n"+
235
+ "\n"+
236
+ "(c) 2023 Martin Corino\n" +
237
+ "(original (c) 2003 Vadim Zeitlin)\n",
238
+ "About HtmlLbox",
239
+ Wx::OK | Wx::ICON_INFORMATION,
240
+ self)
241
+ end
242
+
243
+ def on_set_margins(event)
244
+ margin = Wx.get_number_from_user(
245
+ "Enter the margins to use for the listbox items.",
246
+ "Margin: ",
247
+ "HtmlLbox: Set the margins",
248
+ 0, 0, 20,
249
+ self)
250
+
251
+ if margin != -1
252
+ @hlbox.set_margins(margin, margin)
253
+ @hlbox.refresh_all
254
+ end
255
+ end
256
+ def on_draw_separator(_event)
257
+ @hlbox.refresh_all
258
+ end
259
+ def on_toggle_multi(event)
260
+ old = @hlbox
261
+
262
+ # we need to recreate the listbox
263
+ create_box
264
+ get_sizer.replace(old, @hlbox)
265
+ old.destroy
266
+
267
+ get_sizer.layout
268
+ end
269
+ def on_select_all(event)
270
+ @hlbox.select_all
271
+ end
272
+ def on_update_item(event)
273
+ @hlbox.update_first_item if @hlbox.is_a?(MyHtmlListBox)
274
+ end
275
+
276
+ def on_get_item_rect(event)
277
+ r = @hlbox.get_item_rect(10)
278
+ Wx.log_message("Rect of item %d: (%d, %d)-(%d, %d)",
279
+ 10, r.x, r.y, r.x + r.width, r.y + r.height)
280
+ end
281
+
282
+ def on_set_bg_col(event)
283
+ col = Wx.get_colour_from_user(self, @hlbox.get_background_colour)
284
+ if col.ok?
285
+ @hlbox.set_background_colour(col)
286
+ @hlbox.refresh
287
+
288
+ if Wx.has_feature?(:USE_STATUSBAR)
289
+ set_status_text("Background colour changed.")
290
+ end # wxUSE_STATUSBAR
291
+ end
292
+ end
293
+ def on_set_sel_bg_col(event)
294
+ col = Wx.get_colour_from_user(self, @hlbox.get_selection_background)
295
+ if col.ok?
296
+ @hlbox.set_selection_background(col)
297
+ @hlbox.refresh
298
+
299
+ if Wx.has_feature?(:USE_STATUSBAR)
300
+ set_status_text("Selection Background colour changed.")
301
+ end # wxUSE_STATUSBAR
302
+ end
303
+ end
304
+ def on_set_sel_fg_col(event)
305
+ if @hlbox.is_a?(MyHtmlListBox)
306
+ @hlbox.set_change_sel_fg(!event.checked?)
307
+ @hlbox.refresh
308
+ end
309
+ end
310
+
311
+ def on_clear(event)
312
+ @hlbox.clear
313
+ end
314
+
315
+ def on_update_ui_select_all(event)
316
+ event.enable(@hlbox && @hlbox.has_multiple_selection)
317
+ end
318
+
319
+ def on_lbox_select(event)
320
+ Wx.log_message("Listbox selection is now %d.", event.get_int)
321
+
322
+ if @hlbox.has_multiple_selection
323
+ s = ''
324
+ @hlbox.each_selected do |item|
325
+ s << ', ' unless s.empty?
326
+ s << item.to_s
327
+ end
328
+ Wx.log_message("Selected items: #{s}") unless s.empty?
329
+ end
330
+
331
+ if Wx.has_feature?(:USE_STATUSBAR)
332
+ set_status_text("# items selected = #{@hlbox.get_selected_count}")
333
+ end # wxUSE_STATUSBAR
334
+ end
335
+
336
+ def on_lbox_d_click(event)
337
+ Wx.log_message("Listbox item #{event.get_int} double clicked.")
338
+ end
339
+
340
+ def on_html_link_clicked(event)
341
+ Wx.log_message("The url '%s' has been clicked!", event.get_link_info.get_href)
342
+
343
+ if @hlbox.is_a?(MyHtmlListBox)
344
+ @hlbox.link_clicked = true
345
+ @hlbox.refresh_row(1)
346
+ end
347
+ end
348
+ def on_html_cell_hover(event)
349
+ Wx.log_message("Mouse moved over cell %s at %d;%d",
350
+ event.get_cell.id, event.get_point.x, event.get_point.y)
351
+ end
352
+ def on_html_cell_clicked(event)
353
+ Wx.log_message("Click over cell %s at %d;%d",
354
+ event.get_cell.id, event.get_point.x, event.get_point.y)
355
+
356
+ # if we don't skip the event, OnHtmlLinkClicked won't be called!
357
+ event.skip
358
+ end
359
+
360
+ def create_box
361
+ multi = get_menu_bar.is_checked(ID::HtmlLbox_ToggleMulti)
362
+
363
+ if get_menu_bar.is_checked(ID::HtmlLbox_CustomBox)
364
+ @hlbox = MyHtmlListBox.new(self, multi)
365
+ else # simple listbox
366
+ @hlbox = Wx::HTML::SimpleHtmlListBox.new(self, style: multi ? Wx::LB_MULTIPLE : 0)
367
+
368
+ # unlike Wx::HTML::HtmlListBox which is abstract, Wx::HTML::SimpleHtmlListBox is a
369
+ # concrete control and doesn't support virtual mode, this we need
370
+ # to add all of its items from the beginning
371
+ arr = []
372
+ 1000.times do |n|
373
+ clr = Wx::Colour.new((n - 192).abs % 256,
374
+ (n - 256).abs % 256,
375
+ (n - 128).abs % 256)
376
+ level = n % 6 + 1
377
+
378
+ label = "<h#{level}><font color=#{clr.get_as_string(Wx::C2S_HTML_SYNTAX)}>Item</font> <b>#{n}</b></h#{level}>"
379
+ arr << label
380
+ end
381
+
382
+ @hlbox.append(arr)
383
+ end
384
+ end
385
+
386
+ end
387
+
388
+ module HtmlListBoxSample
389
+
390
+ include WxRuby::Sample if defined? WxRuby::Sample
391
+
392
+ def self.describe
393
+ { file: __FILE__,
394
+ summary: 'wxRuby HtmlListBox control example.',
395
+ description: "wxRuby example showcasing the HtmlListBox controls.\n"+
396
+ " - Wx::HtmlListBox\n"+
397
+ " - Wx::SimpleHtmlListBox\n"
398
+ }
399
+ end
400
+
401
+ def self.activate
402
+ frame = MyFrame.new
403
+ frame.show
404
+ frame
405
+ end
406
+
407
+ if $0 == __FILE__
408
+ Wx::App.run { HtmlListBoxSample.activate }
409
+ end
410
+
411
+ end
Binary file
@@ -108,8 +108,7 @@ class GraphicsWindow < Wx::Window
108
108
  @rtxt[:font] = gdc.create_font(@font,Wx::RED); @rtxt[:txt] = "This is a red string"
109
109
  @gtxt[:font] = gdc.create_font(@font,Wx::GREEN); @gtxt[:txt] = "This is a green string"
110
110
  @btxt[:font] = gdc.create_font(@font,Wx::BLUE); @btxt[:txt] = "This is a blue string"
111
- # Create the GraphicsContext resources. For some reason, unable to utilize
112
- # GraphicsContext#create(wxWindow) to create these resources in initialize.
111
+ # Create the GraphicsContext resources.
113
112
  @rbrush = gdc.create_brush(RED_BRUSH)
114
113
  @gbrush = gdc.create_brush(GREEN_BRUSH)
115
114
  @bbrush = gdc.create_brush(BLUE_BRUSH)
@@ -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
@@ -603,6 +603,9 @@ class FormMain < Wx::Frame
603
603
  menuHelp = Wx::Menu.new
604
604
 
605
605
  menuHelp.append(ID::ABOUT, '&About', 'Show about dialog')
606
+ if Wx::PLATFORM == 'WXOSX'
607
+ Wx.get_app.mac_about_menu_itemid = ID::ABOUT
608
+ end
606
609
 
607
610
  menuTools1.append(ID::APPENDPROP, 'Append New Property')
608
611
  menuTools1.append(ID::APPENDCAT, "Append New Category\tCtrl-S")
@@ -1384,29 +1387,31 @@ class FormMain < Wx::Frame
1384
1387
  Wx::PG::PG_LABEL,
1385
1388
  "Test Text"))
1386
1389
  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)
1390
+ Wx::MemoryDC.draw_on(myTestBitmap1x) do |mdc|
1391
+ mdc.set_background(Wx::WHITE_BRUSH)
1392
+ mdc.clear
1393
+ mdc.set_pen(Wx::BLACK_PEN)
1394
+ mdc.set_brush(Wx::WHITE_BRUSH)
1395
+ mdc.draw_rectangle(0, 0, 60, 15)
1396
+ mdc.draw_line(0, 0, 59, 14)
1397
+ mdc.set_text_foreground(Wx::BLACK)
1398
+ mdc.draw_text("x1", 0, 0)
1399
+ end
1396
1400
 
1397
1401
  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)
1402
+ Wx::MemoryDC.draw_on(myTestBitmap2x) do |mdc|
1403
+ mdc.set_background(Wx::WHITE_BRUSH)
1404
+ mdc.clear
1405
+ mdc.set_pen(Wx::Pen.new(Wx::BLUE, 2))
1406
+ mdc.set_brush(Wx::WHITE_BRUSH)
1407
+ mdc.draw_rectangle(0, 0, 120, 30)
1408
+ mdc.draw_line(0, 0, 119, 31)
1409
+ mdc.set_text_foreground(Wx::BLUE)
1410
+ f = mdc.font
1411
+ f.set_pixel_size(f.get_pixel_size * 2)
1412
+ mdc.set_font(f)
1413
+ mdc.draw_text("x2", 0, 0)
1414
+ end
1410
1415
 
1411
1416
  myTestBitmap2x.set_scale_factor(2)
1412
1417
  pg.set_property_image("StringPropertyWithBitmap", Wx::BitmapBundle.from_bitmaps(myTestBitmap1x, myTestBitmap2x))