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
@@ -0,0 +1,105 @@
1
+
2
+ class Wx::HTML::SimpleHtmlListBox
3
+
4
+ # Make this a Ruby enumerable so find, find_all, map etc are available
5
+ include Enumerable
6
+
7
+ # Passes each valid item index into the passed block
8
+ def each
9
+ get_count.times { | i | yield i }
10
+ end
11
+
12
+ # We need to cache client data in Ruby variables as we cannot access items
13
+ # during the GC mark phase as for some platforms (WXMSW at least) that would
14
+ # involve calling methods that would break in that phase.
15
+
16
+ def client_data_store
17
+ @client_data ||= []
18
+ end
19
+ private :client_data_store
20
+
21
+ wx_set_client_data = instance_method :set_client_data
22
+ define_method :set_client_data do |item, data|
23
+ item = item.to_i
24
+ wx_set_client_data.bind(self).call(item, data)
25
+ client_data_store[item] = data
26
+ end
27
+
28
+ def get_client_data(item)
29
+ client_data_store[item.to_i]
30
+ end
31
+
32
+ wx_append = instance_method :append
33
+ define_method :append do |item, data=nil|
34
+ if data
35
+ if ::Array === item
36
+ if !(::Array === data)
37
+ ::Kernel.raise ::TypeError.new("Expected Array for argument 3")
38
+ elsif data.size != item.size
39
+ ::Kernel.raise ::ArgumentError.new("item and data array must be equal size")
40
+ end
41
+ offs = get_count
42
+ wx_append.bind(self).call(item)
43
+ item.size.times { |ix| set_client_data(offs+ix, data[ix]) }
44
+ else
45
+ wx_append.bind(self).call(item, data)
46
+ client_data_store[get_count-1] = data
47
+ end
48
+ else
49
+ wx_append.bind(self).call(item)
50
+ # no changes to data store
51
+ end
52
+ end
53
+
54
+ wx_insert = instance_method :insert
55
+ define_method :insert do |item, pos, data=nil|
56
+ if data
57
+ if ::Array === item
58
+ if !(::Array === data)
59
+ ::Kernel.raise ::TypeError.new("Expected Array for argument 3")
60
+ elsif data.size != item.size
61
+ ::Kernel.raise ::ArgumentError.new("item and data array must be equal size")
62
+ end
63
+ wx_insert.bind(self).call(item, pos)
64
+ client_data_store.insert(pos, *::Array.new(item.size))
65
+ item.size.times { |ix| set_client_data(pos+ix, data[ix]) }
66
+ else
67
+ wx_insert.bind(self).call(item, pos, data)
68
+ client_data_store.insert(pos, data)
69
+ end
70
+ else
71
+ wx_insert.bind(self).call(item, pos)
72
+ if ::Array === item
73
+ client_data_store.insert(pos, *::Array.new(item.size))
74
+ else
75
+ client_data_store.insert(pos, nil)
76
+ end
77
+ end
78
+ end
79
+
80
+ wx_set = instance_method :set
81
+ define_method :set do |items, data=nil|
82
+ if data
83
+ if !(::Array === data)
84
+ ::Kernel.raise ::TypeError.new("Expected Array for argument 2")
85
+ elsif data.size != items.size
86
+ ::Kernel.raise ::ArgumentError.new("items and data array must be equal size")
87
+ end
88
+ end
89
+ wx_set.bind(self).call(items)
90
+ client_data_store.clear
91
+ items.each_with_index { |item, ix| set_client_data(item, data[ix]) }
92
+ end
93
+
94
+ wx_clear = instance_method :clear
95
+ define_method :clear do
96
+ wx_clear.bind(self).call
97
+ client_data_store.clear
98
+ end
99
+
100
+ wx_delete = instance_method :delete
101
+ define_method :delete do |item|
102
+ wx_delete.bind(self).call(item.to_i)
103
+ client_data_store.slice!(item.to_i)
104
+ end
105
+ end
@@ -296,6 +296,13 @@ Wx::define_keyword_ctors('CheckBox') do
296
296
  wx_ctor_params :validator, :name => 'checkBox'
297
297
  end
298
298
 
299
+ # wxListBox A list of strings for single or multiple selection
300
+ Wx::define_keyword_ctors('ListBox') do
301
+ wx_ctor_params :id, :pos, :size, :choices => []
302
+ wx_ctor_params :style
303
+ wx_ctor_params :validator, :name => 'listBox'
304
+ end
305
+
299
306
  # A listbox with a checkbox to the left of each item
300
307
  Wx::define_keyword_ctors('CheckListBox') do
301
308
  wx_ctor_params :id, :pos, :size, :choices, :style
data/lib/wx/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Wx
2
- WXRUBY_VERSION = '0.9.0-beta.13'
2
+ WXRUBY_VERSION = '0.9.0-rc.1'
3
3
  end
@@ -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)