wxruby3 0.9.0.pre.beta.14-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 (238) 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/core/art_locator.rb +2 -2
  24. data/lib/wx/core/artprovider.rb +2 -2
  25. data/lib/wx/core/bitmap.rb +6 -5
  26. data/lib/wx/core/bitmap_combobox.rb +34 -0
  27. data/lib/wx/core/controlwithitems.rb +52 -14
  28. data/lib/wx/core/cursor.rb +1 -1
  29. data/lib/wx/core/dc.rb +0 -20
  30. data/lib/wx/core/event_blocker.rb +14 -0
  31. data/lib/wx/core/events/evt_list.rb +12 -0
  32. data/lib/wx/core/evthandler.rb +36 -0
  33. data/lib/wx/core/find_replace_dialog.rb +24 -0
  34. data/lib/wx/core/icon.rb +1 -1
  35. data/lib/wx/core/image.rb +1 -1
  36. data/lib/wx/core/paintdc.rb +8 -0
  37. data/lib/wx/core/text_entry.rb +15 -0
  38. data/lib/wx/core/v_list_box.rb +13 -0
  39. data/lib/wx/core/window.rb +1 -1
  40. data/lib/wx/doc/busy_info.rb +21 -0
  41. data/lib/wx/doc/client_dc.rb +28 -0
  42. data/lib/wx/doc/controlwithitems.rb +11 -0
  43. data/lib/wx/doc/dc.rb +0 -14
  44. data/lib/wx/doc/event_blocker.rb +27 -0
  45. data/lib/wx/doc/evthandler.rb +4 -0
  46. data/lib/wx/doc/extra/02_lifecycles.md +49 -0
  47. data/lib/wx/doc/extra/10_art.md +1 -1
  48. data/lib/wx/doc/extra/11_drawing_and_dc.md +62 -0
  49. data/lib/wx/doc/gen/about_dialog_info.rb +27 -24
  50. data/lib/wx/doc/gen/accelerator.rb +11 -12
  51. data/lib/wx/doc/gen/app.rb +6 -3
  52. data/lib/wx/doc/gen/art_provider.rb +53 -29
  53. data/lib/wx/doc/gen/aui/aui_manager.rb +4 -0
  54. data/lib/wx/doc/gen/aui/aui_mdi_child_frame.rb +1 -1
  55. data/lib/wx/doc/gen/aui/aui_pane_info.rb +2 -0
  56. data/lib/wx/doc/gen/aui/aui_tab_ctrl.rb +2 -0
  57. data/lib/wx/doc/gen/bitmap.rb +25 -25
  58. data/lib/wx/doc/gen/bitmap_combo_box.rb +157 -0
  59. data/lib/wx/doc/gen/box_sizer.rb +6 -8
  60. data/lib/wx/doc/gen/brush.rb +2 -0
  61. data/lib/wx/doc/gen/busy_info.rb +52 -46
  62. data/lib/wx/doc/gen/caret.rb +0 -4
  63. data/lib/wx/doc/gen/check_list_box.rb +0 -2
  64. data/lib/wx/doc/gen/choice.rb +1 -5
  65. data/lib/wx/doc/gen/client_dc.rb +13 -18
  66. data/lib/wx/doc/gen/clipboard.rb +30 -27
  67. data/lib/wx/doc/gen/collapsible_pane.rb +11 -9
  68. data/lib/wx/doc/gen/colour.rb +6 -3
  69. data/lib/wx/doc/gen/colour_dialog.rb +111 -23
  70. data/lib/wx/doc/gen/combo_box.rb +2 -4
  71. data/lib/wx/doc/gen/control.rb +20 -18
  72. data/lib/wx/doc/gen/core.rb +2 -2
  73. data/lib/wx/doc/gen/cursor.rb +18 -50
  74. data/lib/wx/doc/gen/data_format.rb +0 -2
  75. data/lib/wx/doc/gen/data_object.rb +37 -44
  76. data/lib/wx/doc/gen/dc.rb +16 -24
  77. data/lib/wx/doc/gen/defs.rb +3 -40
  78. data/lib/wx/doc/gen/dialog.rb +21 -17
  79. data/lib/wx/doc/gen/dir_dialog.rb +10 -8
  80. data/lib/wx/doc/gen/event.rb +2 -2
  81. data/lib/wx/doc/gen/event_blocker.rb +49 -0
  82. data/lib/wx/doc/gen/event_filter.rb +95 -0
  83. data/lib/wx/doc/gen/event_list.rb +16 -2
  84. data/lib/wx/doc/gen/events.rb +103 -112
  85. data/lib/wx/doc/gen/evt_handler.rb +28 -52
  86. data/lib/wx/doc/gen/file_dialog.rb +8 -4
  87. data/lib/wx/doc/gen/find_replace_dialog.rb +1 -1
  88. data/lib/wx/doc/gen/font.rb +10 -2
  89. data/lib/wx/doc/gen/font_data.rb +2 -0
  90. data/lib/wx/doc/gen/font_dialog.rb +1 -1
  91. data/lib/wx/doc/gen/frame.rb +4 -3
  92. data/lib/wx/doc/gen/fs_file.rb +8 -0
  93. data/lib/wx/doc/gen/gcdc.rb +2 -22
  94. data/lib/wx/doc/gen/gdi_common.rb +18 -2
  95. data/lib/wx/doc/gen/gdi_object.rb +2 -0
  96. data/lib/wx/doc/gen/graphics_context.rb +4 -43
  97. data/lib/wx/doc/gen/graphics_object.rb +2 -0
  98. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +2 -1
  99. data/lib/wx/doc/gen/grid/grid_ctrl.rb +4 -2
  100. data/lib/wx/doc/gen/grid/grid_table_message.rb +2 -0
  101. data/lib/wx/doc/gen/grid_bag_sizer.rb +4 -0
  102. data/lib/wx/doc/gen/help_controller.rb +4 -1
  103. data/lib/wx/doc/gen/html/html_cell.rb +4 -1
  104. data/lib/wx/doc/gen/html/html_help_controller.rb +4 -1
  105. data/lib/wx/doc/gen/html/html_help_data.rb +4 -0
  106. data/lib/wx/doc/gen/html/html_help_window.rb +2 -1
  107. data/lib/wx/doc/gen/html/html_list_box.rb +138 -11
  108. data/lib/wx/doc/gen/html/html_window.rb +9 -3
  109. data/lib/wx/doc/gen/icon.rb +7 -1
  110. data/lib/wx/doc/gen/icon_location.rb +2 -0
  111. data/lib/wx/doc/gen/image.rb +15 -8
  112. data/lib/wx/doc/gen/keyboard_state.rb +6 -0
  113. data/lib/wx/doc/gen/list_box.rb +0 -11
  114. data/lib/wx/doc/gen/list_ctrl.rb +10 -13
  115. data/lib/wx/doc/gen/locale.rb +7 -3
  116. data/lib/wx/doc/gen/log.rb +6 -2
  117. data/lib/wx/doc/gen/mdi_frame.rb +2 -0
  118. data/lib/wx/doc/gen/media_ctrl.rb +2 -0
  119. data/lib/wx/doc/gen/memory_dc.rb +105 -18
  120. data/lib/wx/doc/gen/menu.rb +4 -2
  121. data/lib/wx/doc/gen/menu_bar.rb +0 -2
  122. data/lib/wx/doc/gen/menu_item.rb +9 -3
  123. data/lib/wx/doc/gen/message_dialog.rb +6 -3
  124. data/lib/wx/doc/gen/mirror_dc.rb +2 -8
  125. data/lib/wx/doc/gen/mouse_state.rb +2 -0
  126. data/lib/wx/doc/gen/multi_choice_dialog.rb +0 -2
  127. data/lib/wx/doc/gen/non_owned_window.rb +2 -1
  128. data/lib/wx/doc/gen/notebook.rb +4 -2
  129. data/lib/wx/doc/gen/paint_dc.rb +2 -6
  130. data/lib/wx/doc/gen/palette.rb +3 -3
  131. data/lib/wx/doc/gen/pen.rb +6 -1
  132. data/lib/wx/doc/gen/pg/pg_editor.rb +2 -1
  133. data/lib/wx/doc/gen/pg/pg_multi_button.rb +4 -0
  134. data/lib/wx/doc/gen/pg/pg_properties.rb +30 -3
  135. data/lib/wx/doc/gen/pg/pg_property.rb +30 -4
  136. data/lib/wx/doc/gen/pg/pg_validation_info.rb +2 -0
  137. data/lib/wx/doc/gen/pg/property_grid.rb +5 -2
  138. data/lib/wx/doc/gen/pg/property_grid_interface.rb +6 -2
  139. data/lib/wx/doc/gen/pg/property_grid_manager.rb +2 -0
  140. data/lib/wx/doc/gen/pg/property_grid_page_state.rb +2 -0
  141. data/lib/wx/doc/gen/picker_base.rb +2 -1
  142. data/lib/wx/doc/gen/platform_info.rb +4 -1
  143. data/lib/wx/doc/gen/property_sheet_dialog.rb +2 -0
  144. data/lib/wx/doc/gen/prt/post_script_dc.rb +2 -8
  145. data/lib/wx/doc/gen/prt/print_data.rb +6 -0
  146. data/lib/wx/doc/gen/prt/printer.rb +0 -3
  147. data/lib/wx/doc/gen/prt/printer_dc.rb +2 -6
  148. data/lib/wx/doc/gen/radio_box.rb +2 -2
  149. data/lib/wx/doc/gen/rbn/ribbon_art_provider.rb +6 -0
  150. data/lib/wx/doc/gen/rbn/ribbon_panel.rb +1 -1
  151. data/lib/wx/doc/gen/region.rb +2 -0
  152. data/lib/wx/doc/gen/rtc/rich_text_buffer.rb +6 -0
  153. data/lib/wx/doc/gen/rtc/rich_text_ctrl.rb +0 -4
  154. data/lib/wx/doc/gen/rtc/rich_text_header_footer_data.rb +2 -0
  155. data/lib/wx/doc/gen/rtc/rich_text_html_handler.rb +2 -1
  156. data/lib/wx/doc/gen/rtc/symbol_picker_dialog.rb +2 -0
  157. data/lib/wx/doc/gen/screen_dc.rb +2 -0
  158. data/lib/wx/doc/gen/scroll_bar.rb +2 -1
  159. data/lib/wx/doc/gen/scrolled_canvas.rb +4 -8
  160. data/lib/wx/doc/gen/scrolled_control.rb +4 -8
  161. data/lib/wx/doc/gen/scrolled_window.rb +4 -8
  162. data/lib/wx/doc/gen/search_ctrl.rb +131 -0
  163. data/lib/wx/doc/gen/single_choice_dialog.rb +0 -2
  164. data/lib/wx/doc/gen/sizer.rb +14 -3
  165. data/lib/wx/doc/gen/splash_screen.rb +2 -0
  166. data/lib/wx/doc/gen/static_box.rb +6 -3
  167. data/lib/wx/doc/gen/static_box_sizer.rb +2 -1
  168. data/lib/wx/doc/gen/status_bar.rb +0 -5
  169. data/lib/wx/doc/gen/stc/styled_text_ctrl.rb +4 -5
  170. data/lib/wx/doc/gen/svg_file_dc.rb +10 -11
  171. data/lib/wx/doc/gen/text_ctrl.rb +10 -3
  172. data/lib/wx/doc/gen/text_entry.rb +8 -3
  173. data/lib/wx/doc/gen/text_entry_dialog.rb +4 -2
  174. data/lib/wx/doc/gen/timer_event.rb +2 -0
  175. data/lib/wx/doc/gen/tool_bar.rb +8 -4
  176. data/lib/wx/doc/gen/top_level_window.rb +5 -2
  177. data/lib/wx/doc/gen/tree_ctrl.rb +0 -6
  178. data/lib/wx/doc/gen/ui_action_simulator.rb +100 -0
  179. data/lib/wx/doc/gen/utils.rb +1 -1
  180. data/lib/wx/doc/gen/v_list_box.rb +36 -26
  181. data/lib/wx/doc/gen/validator.rb +2 -1
  182. data/lib/wx/doc/gen/variant.rb +10 -0
  183. data/lib/wx/doc/gen/window.rb +38 -17
  184. data/lib/wx/doc/gen/window_dc.rb +2 -0
  185. data/lib/wx/doc/gen/window_disabler.rb +2 -0
  186. data/lib/wx/doc/gen/wizard_page_simple.rb +2 -0
  187. data/lib/wx/doc/gen/xml_node.rb +6 -0
  188. data/lib/wx/doc/gen/xml_resource.rb +4 -1
  189. data/lib/wx/doc/memory_dc.rb +75 -0
  190. data/lib/wx/doc/mirror_dc.rb +16 -0
  191. data/lib/wx/doc/prt/printer_dc.rb +26 -0
  192. data/lib/wx/doc/screen_dc.rb +10 -6
  193. data/lib/wx/doc/svg_file_dc.rb +20 -0
  194. data/lib/wx/doc/v_list_box.rb +9 -0
  195. data/lib/wx/doc/window_disabler.rb +10 -0
  196. data/lib/wx/html/keyword_defs.rb +6 -7
  197. data/lib/wx/html/require.rb +1 -0
  198. data/lib/wx/html/simple_html_listbox.rb +105 -0
  199. data/lib/wx/keyword_defs.rb +7 -0
  200. data/lib/wx/version.rb +1 -1
  201. data/lib/wx/wxruby/cmd/test.rb +1 -1
  202. data/lib/wxruby_aui.so +0 -0
  203. data/lib/wxruby_core.so +0 -0
  204. data/lib/wxruby_grid.so +0 -0
  205. data/lib/wxruby_html.so +0 -0
  206. data/lib/wxruby_pg.so +0 -0
  207. data/lib/wxruby_prt.so +0 -0
  208. data/lib/wxruby_rbn.so +0 -0
  209. data/lib/wxruby_rtc.so +0 -0
  210. data/lib/wxruby_stc.so +0 -0
  211. data/rakelib/install.rb +3 -1
  212. data/rakelib/yard/yard/relative_markdown_links.rb +5 -1
  213. data/samples/bigdemo/wxArtProvider.rbw +5 -4
  214. data/samples/controls/controls.rb +2 -2
  215. data/samples/controls/htlbox.rb +411 -0
  216. data/samples/controls/tn_htlbox.png +0 -0
  217. data/samples/drawing/graphics_drawing.rb +1 -2
  218. data/samples/drawing/{svgtest.rb → image_prt.rb} +49 -18
  219. data/samples/drawing/tn_image_prt.png +0 -0
  220. data/samples/propgrid/propgrid.rb +23 -21
  221. data/samples/ribbon/ribbon.rb +47 -46
  222. data/tests/lib/wxapp_runner.rb +3 -3
  223. data/tests/lib/wxframe_runner.rb +59 -0
  224. data/tests/test_app_event_filter.rb +74 -0
  225. data/tests/test_art_provider.rb +52 -0
  226. data/tests/test_clipboard.rb +2 -1
  227. data/tests/test_event_handling.rb +199 -16
  228. data/tests/test_events.rb +4 -11
  229. data/tests/test_gdi_object.rb +161 -0
  230. data/tests/test_intl.rb +11 -14
  231. data/tests/test_item_data.rb +33 -1
  232. data/tests/test_std_controls.rb +147 -0
  233. metadata +38 -8
  234. data/lib/wx/doc/gen/auto_buffered_paint_dc.rb +0 -47
  235. data/lib/wx/doc/gen/buffered_dc.rb +0 -95
  236. data/lib/wx/doc/gen/buffered_paint_dc.rb +0 -55
  237. data/lib/wx/doc/gen/colour_data.rb +0 -96
  238. data/samples/drawing/tn_svgtest.png +0 -0
@@ -16,7 +16,7 @@ module WxRuby
16
16
  description
17
17
  else
18
18
  Dir[File.join(WxRuby::ROOT, 'tests', '*.rb')].each do |test|
19
- system(RUBY, test)
19
+ exit(1) unless system(RUBY, test)
20
20
  end
21
21
  end
22
22
  end
data/lib/wxruby_aui.so CHANGED
Binary file
data/lib/wxruby_core.so CHANGED
Binary file
data/lib/wxruby_grid.so CHANGED
Binary file
data/lib/wxruby_html.so CHANGED
Binary file
data/lib/wxruby_pg.so CHANGED
Binary file
data/lib/wxruby_prt.so CHANGED
Binary file
data/lib/wxruby_rbn.so CHANGED
Binary file
data/lib/wxruby_rtc.so CHANGED
Binary file
data/lib/wxruby_stc.so CHANGED
Binary file
data/rakelib/install.rb CHANGED
@@ -34,7 +34,9 @@ module WXRuby3
34
34
  grp_id = m[1]
35
35
  lib_id = m[2]
36
36
  ver = m[3].sub('.', '')
37
- lib = "wx#{grp_id.sub(/u\Z/, '')}#{ver}u#{lib_id}"
37
+ # as of wxw 3.3 there seems to be an additional digit added to the version part of the dll name
38
+ # so add a wildcard ('*') in that spot to match older and newer versions
39
+ lib = "wx#{grp_id.sub(/u\Z/, '')}#{ver}*u#{lib_id}"
38
40
  @wxwin_shlibs.include File.join(libdir, "#{lib}*.#{WXRuby3.config.dll_mask}")
39
41
  end
40
42
  else
@@ -20,7 +20,11 @@ module YARD # rubocop:disable Style/Documentation
20
20
  def resolve_links(text)
21
21
  html = Nokogiri::HTML.fragment(text)
22
22
  html.css("a[href]").each do |link|
23
- href = URI(link["href"])
23
+ begin
24
+ href = URI(link["href"])
25
+ rescue
26
+ return super(text)
27
+ end
24
28
 
25
29
  if href.relative? && options.files
26
30
  fnames = options.files.map(&:filename)
@@ -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