wxruby3 0.9.2-x64-mingw-ucrt → 0.9.4-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (668) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +35 -29
  3. data/README.md +24 -15
  4. data/ext/wxbase32u_gcc_custom.dll +0 -0
  5. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  6. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  7. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  8. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  9. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  10. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  11. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  12. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  13. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  14. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  15. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  16. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  17. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  18. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  19. data/lib/wx/core/bitmap_combobox.rb +17 -21
  20. data/lib/wx/core/book_ctrl_base.rb +16 -0
  21. data/lib/wx/core/combobox.rb +13 -3
  22. data/lib/wx/core/config.rb +454 -83
  23. data/lib/wx/core/controlwithitems.rb +40 -130
  24. data/lib/wx/core/enum.rb +17 -1
  25. data/lib/wx/core/event.rb +6 -1
  26. data/lib/wx/core/events/evt_list.rb +5 -4
  27. data/lib/wx/core/evthandler.rb +8 -2
  28. data/lib/wx/core/generic_validator.rb +312 -0
  29. data/lib/wx/core/listbox.rb +2 -2
  30. data/lib/wx/core/log.rb +1 -1
  31. data/lib/wx/core/notebook.rb +10 -8
  32. data/lib/wx/core/owner_drawn_combobox.rb +45 -0
  33. data/lib/wx/core/peristent_object.rb +15 -0
  34. data/lib/wx/core/persistence_manager.rb +39 -0
  35. data/lib/wx/core/persistent_window.rb +16 -0
  36. data/lib/wx/core/size.rb +4 -0
  37. data/lib/wx/core/sizer.rb +1 -2
  38. data/lib/wx/core/standard_paths.rb +22 -0
  39. data/lib/wx/core/text_entry.rb +4 -1
  40. data/lib/wx/core/top_level_window.rb +16 -0
  41. data/lib/wx/core/treebook.rb +18 -0
  42. data/lib/wx/core/validator.rb +70 -5
  43. data/lib/wx/core/window.rb +3 -7
  44. data/lib/wx/core.rb +4 -0
  45. data/lib/wx/doc/art_locator.rb +1 -0
  46. data/lib/wx/doc/book_ctrl_base.rb +19 -0
  47. data/lib/wx/doc/comboctrl.rb +18 -0
  48. data/lib/wx/doc/config.rb +101 -41
  49. data/lib/wx/doc/controlwithitems.rb +16 -0
  50. data/lib/wx/doc/date_picker_ctrl.rb +23 -0
  51. data/lib/wx/doc/editable_listbox.rb +44 -0
  52. data/lib/wx/doc/enum.rb +15 -0
  53. data/lib/wx/doc/event.rb +12 -0
  54. data/lib/wx/doc/extra/12_client_data.md +89 -0
  55. data/lib/wx/doc/extra/13_validators.md +139 -0
  56. data/lib/wx/doc/extra/14_config.md +101 -0
  57. data/lib/wx/doc/extra/15_persistence.md +148 -0
  58. data/lib/wx/doc/gdi_common.rb +4 -0
  59. data/lib/wx/doc/gen/about_dialog_info.rb +25 -0
  60. data/lib/wx/doc/gen/accelerator.rb +7 -1
  61. data/lib/wx/doc/gen/accessible.rb +13 -0
  62. data/lib/wx/doc/gen/activity_indicator.rb +7 -0
  63. data/lib/wx/doc/gen/animation.rb +12 -0
  64. data/lib/wx/doc/gen/animation_ctrl.rb +10 -0
  65. data/lib/wx/doc/gen/any_button.rb +17 -1
  66. data/lib/wx/doc/gen/app.rb +35 -1
  67. data/lib/wx/doc/gen/app_traits.rb +38 -5
  68. data/lib/wx/doc/gen/art_provider.rb +14 -0
  69. data/lib/wx/doc/gen/aui/aui_dock_art.rb +12 -0
  70. data/lib/wx/doc/gen/aui/aui_floating_frame.rb +1 -0
  71. data/lib/wx/doc/gen/aui/aui_manager.rb +24 -1
  72. data/lib/wx/doc/gen/aui/aui_manager_event.rb +9 -1
  73. data/lib/wx/doc/gen/aui/aui_mdi_child_frame.rb +3 -0
  74. data/lib/wx/doc/gen/aui/aui_mdi_client_window.rb +2 -0
  75. data/lib/wx/doc/gen/aui/aui_mdi_parent_frame.rb +3 -1
  76. data/lib/wx/doc/gen/aui/aui_notebook.rb +20 -2
  77. data/lib/wx/doc/gen/aui/aui_notebook_event.rb +2 -1
  78. data/lib/wx/doc/gen/aui/aui_pane_info.rb +30 -1
  79. data/lib/wx/doc/gen/aui/aui_tab_art.rb +6 -0
  80. data/lib/wx/doc/gen/aui/aui_tab_ctrl.rb +1 -0
  81. data/lib/wx/doc/gen/aui/aui_tool_bar.rb +11 -0
  82. data/lib/wx/doc/gen/aui/aui_tool_bar_art.rb +2 -0
  83. data/lib/wx/doc/gen/aui/aui_tool_bar_event.rb +2 -1
  84. data/lib/wx/doc/gen/aui/aui_tool_bar_item.rb +4 -0
  85. data/lib/wx/doc/gen/banner_window.rb +7 -0
  86. data/lib/wx/doc/gen/bitmap.rb +64 -3
  87. data/lib/wx/doc/gen/bitmap_button.rb +6 -1
  88. data/lib/wx/doc/gen/bitmap_combo_box.rb +9 -3
  89. data/lib/wx/doc/gen/book_ctrl_base.rb +17 -2
  90. data/lib/wx/doc/gen/book_ctrl_event.rb +3 -1
  91. data/lib/wx/doc/gen/box_sizer.rb +5 -0
  92. data/lib/wx/doc/gen/brush.rb +16 -1
  93. data/lib/wx/doc/gen/busy_info.rb +8 -0
  94. data/lib/wx/doc/gen/button.rb +11 -3
  95. data/lib/wx/doc/gen/calculate_layout_event.rb +4 -0
  96. data/lib/wx/doc/gen/calendar_ctrl.rb +22 -0
  97. data/lib/wx/doc/gen/calendar_date_attr.rb +1 -0
  98. data/lib/wx/doc/gen/calendar_event.rb +3 -1
  99. data/lib/wx/doc/gen/caret.rb +3 -0
  100. data/lib/wx/doc/gen/check_box.rb +10 -0
  101. data/lib/wx/doc/gen/check_list_box.rb +3 -0
  102. data/lib/wx/doc/gen/choice.rb +14 -2
  103. data/lib/wx/doc/gen/choicebook.rb +1 -0
  104. data/lib/wx/doc/gen/client_dc.rb +1 -0
  105. data/lib/wx/doc/gen/clipboard.rb +9 -0
  106. data/lib/wx/doc/gen/collapsible_pane.rb +3 -0
  107. data/lib/wx/doc/gen/collapsible_pane_event.rb +1 -0
  108. data/lib/wx/doc/gen/colour.rb +20 -0
  109. data/lib/wx/doc/gen/colour_dialog.rb +10 -0
  110. data/lib/wx/doc/gen/colour_picker_ctrl.rb +4 -0
  111. data/lib/wx/doc/gen/colour_picker_event.rb +1 -0
  112. data/lib/wx/doc/gen/combo_box.rb +20 -1
  113. data/lib/wx/doc/gen/combo_ctrl.rb +54 -295
  114. data/lib/wx/doc/gen/command_link_button.rb +8 -0
  115. data/lib/wx/doc/gen/context_help_button.rb +7 -1
  116. data/lib/wx/doc/gen/control.rb +12 -0
  117. data/lib/wx/doc/gen/control_with_items.rb +45 -9
  118. data/lib/wx/doc/gen/core.rb +2 -2
  119. data/lib/wx/doc/gen/cursor.rb +4 -0
  120. data/lib/wx/doc/gen/data_format.rb +1 -0
  121. data/lib/wx/doc/gen/data_object.rb +27 -5
  122. data/lib/wx/doc/gen/date_event.rb +2 -1
  123. data/lib/wx/doc/gen/date_picker_ctrl.rb +7 -1
  124. data/lib/wx/doc/gen/dc.rb +87 -3
  125. data/lib/wx/doc/gen/dial_up_event.rb +2 -0
  126. data/lib/wx/doc/gen/dial_up_manager.rb +12 -0
  127. data/lib/wx/doc/gen/dialog.rb +42 -3
  128. data/lib/wx/doc/gen/dir_dialog.rb +6 -1
  129. data/lib/wx/doc/gen/dir_filter_list_ctrl.rb +1 -0
  130. data/lib/wx/doc/gen/dir_picker_ctrl.rb +5 -0
  131. data/lib/wx/doc/gen/drag_drop.rb +20 -0
  132. data/lib/wx/doc/gen/drag_image.rb +7 -0
  133. data/lib/wx/doc/gen/editable_list_box.rb +5 -3
  134. data/lib/wx/doc/gen/event.rb +26 -11
  135. data/lib/wx/doc/gen/event_blocker.rb +2 -1
  136. data/lib/wx/doc/gen/event_filter.rb +3 -2
  137. data/lib/wx/doc/gen/event_list.rb +4 -4
  138. data/lib/wx/doc/gen/events.rb +165 -26
  139. data/lib/wx/doc/gen/evt_handler.rb +40 -2
  140. data/lib/wx/doc/gen/ext_help_controller.rb +9 -0
  141. data/lib/wx/doc/gen/file_ctrl.rb +11 -2
  142. data/lib/wx/doc/gen/file_ctrl_event.rb +5 -1
  143. data/lib/wx/doc/gen/file_dialog.rb +13 -0
  144. data/lib/wx/doc/gen/file_dialog_custom_control.rb +12 -0
  145. data/lib/wx/doc/gen/file_dialog_customize_hook.rb +11 -2
  146. data/lib/wx/doc/gen/file_dir_picker_event.rb +2 -1
  147. data/lib/wx/doc/gen/file_picker_ctrl.rb +4 -0
  148. data/lib/wx/doc/gen/file_system.rb +17 -1
  149. data/lib/wx/doc/gen/find_dialog_event.rb +2 -1
  150. data/lib/wx/doc/gen/find_replace_data.rb +1 -0
  151. data/lib/wx/doc/gen/find_replace_dialog.rb +3 -0
  152. data/lib/wx/doc/gen/flex_grid_sizer.rb +13 -0
  153. data/lib/wx/doc/gen/font.rb +75 -3
  154. data/lib/wx/doc/gen/font_data.rb +14 -0
  155. data/lib/wx/doc/gen/font_dialog.rb +6 -0
  156. data/lib/wx/doc/gen/font_picker_ctrl.rb +8 -0
  157. data/lib/wx/doc/gen/font_picker_event.rb +1 -0
  158. data/lib/wx/doc/gen/frame.rb +24 -7
  159. data/lib/wx/doc/gen/fs_file.rb +22 -0
  160. data/lib/wx/doc/gen/gauge.rb +8 -0
  161. data/lib/wx/doc/gen/gb_sizer_item.rb +5 -0
  162. data/lib/wx/doc/gen/gcdc.rb +2 -0
  163. data/lib/wx/doc/gen/gdi_common.rb +50 -8
  164. data/lib/wx/doc/gen/gdi_object.rb +1 -0
  165. data/lib/wx/doc/gen/generic_dir_ctrl.rb +7 -0
  166. data/lib/wx/doc/gen/graphics_context.rb +36 -7
  167. data/lib/wx/doc/gen/graphics_object.rb +24 -0
  168. data/lib/wx/doc/gen/grid/grid_cell_activatable_editor.rb +2 -2
  169. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +14 -4
  170. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_editor.rb +1 -2
  171. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_renderer.rb +1 -2
  172. data/lib/wx/doc/gen/grid/grid_cell_bool_editor.rb +2 -2
  173. data/lib/wx/doc/gen/grid/grid_cell_bool_renderer.rb +1 -2
  174. data/lib/wx/doc/gen/grid/grid_cell_choice_editor.rb +2 -2
  175. data/lib/wx/doc/gen/grid/grid_cell_date_editor.rb +1 -2
  176. data/lib/wx/doc/gen/grid/grid_cell_date_renderer.rb +1 -2
  177. data/lib/wx/doc/gen/grid/grid_cell_date_time_renderer.rb +1 -2
  178. data/lib/wx/doc/gen/grid/grid_cell_editor.rb +9 -2
  179. data/lib/wx/doc/gen/grid/grid_cell_enum_editor.rb +1 -2
  180. data/lib/wx/doc/gen/grid/grid_cell_enum_renderer.rb +1 -2
  181. data/lib/wx/doc/gen/grid/grid_cell_float_editor.rb +1 -2
  182. data/lib/wx/doc/gen/grid/grid_cell_float_renderer.rb +2 -2
  183. data/lib/wx/doc/gen/grid/grid_cell_number_editor.rb +2 -2
  184. data/lib/wx/doc/gen/grid/grid_cell_number_renderer.rb +1 -2
  185. data/lib/wx/doc/gen/grid/grid_cell_renderer.rb +6 -2
  186. data/lib/wx/doc/gen/grid/grid_cell_string_renderer.rb +1 -2
  187. data/lib/wx/doc/gen/grid/grid_cell_text_editor.rb +1 -2
  188. data/lib/wx/doc/gen/grid/grid_ctrl.rb +229 -7
  189. data/lib/wx/doc/gen/grid/grid_editor_created_event.rb +4 -1
  190. data/lib/wx/doc/gen/grid/grid_event.rb +4 -1
  191. data/lib/wx/doc/gen/grid/grid_range_select_event.rb +2 -1
  192. data/lib/wx/doc/gen/grid/grid_size_event.rb +2 -1
  193. data/lib/wx/doc/gen/grid/grid_string_table.rb +7 -0
  194. data/lib/wx/doc/gen/grid/grid_table_base.rb +27 -1
  195. data/lib/wx/doc/gen/grid/grid_table_message.rb +1 -0
  196. data/lib/wx/doc/gen/grid_bag_sizer.rb +24 -4
  197. data/lib/wx/doc/gen/grid_sizer.rb +11 -0
  198. data/lib/wx/doc/gen/gui_event_loop.rb +12 -2
  199. data/lib/wx/doc/gen/header_ctrl.rb +106 -6
  200. data/lib/wx/doc/gen/header_ctrl_event.rb +5 -1
  201. data/lib/wx/doc/gen/help_controller.rb +11 -0
  202. data/lib/wx/doc/gen/help_provider.rb +12 -3
  203. data/lib/wx/doc/gen/html/html_cell.rb +25 -0
  204. data/lib/wx/doc/gen/html/html_cell_event.rb +3 -1
  205. data/lib/wx/doc/gen/html/html_easy_printing.rb +13 -1
  206. data/lib/wx/doc/gen/html/html_help_controller.rb +18 -0
  207. data/lib/wx/doc/gen/html/html_help_data.rb +5 -0
  208. data/lib/wx/doc/gen/html/html_help_window.rb +8 -0
  209. data/lib/wx/doc/gen/html/html_link_event.rb +1 -0
  210. data/lib/wx/doc/gen/html/html_list_box.rb +49 -9
  211. data/lib/wx/doc/gen/html/html_printout.rb +7 -0
  212. data/lib/wx/doc/gen/html/html_window.rb +31 -0
  213. data/lib/wx/doc/gen/hyperlink_ctrl.rb +2 -1
  214. data/lib/wx/doc/gen/hyperlink_event.rb +1 -0
  215. data/lib/wx/doc/gen/icon.rb +19 -1
  216. data/lib/wx/doc/gen/icon_location.rb +1 -0
  217. data/lib/wx/doc/gen/image.rb +67 -10
  218. data/lib/wx/doc/gen/image_list.rb +12 -2
  219. data/lib/wx/doc/gen/info_bar.rb +12 -0
  220. data/lib/wx/doc/gen/keyboard_state.rb +11 -0
  221. data/lib/wx/doc/gen/list_box.rb +20 -3
  222. data/lib/wx/doc/gen/list_ctrl.rb +89 -0
  223. data/lib/wx/doc/gen/list_event.rb +11 -1
  224. data/lib/wx/doc/gen/listbook.rb +1 -0
  225. data/lib/wx/doc/gen/locale.rb +22 -0
  226. data/lib/wx/doc/gen/log.rb +42 -0
  227. data/lib/wx/doc/gen/mdi_client_window.rb +4 -1
  228. data/lib/wx/doc/gen/mdi_frame.rb +27 -4
  229. data/lib/wx/doc/gen/media_ctrl.rb +17 -0
  230. data/lib/wx/doc/gen/media_event.rb +2 -1
  231. data/lib/wx/doc/gen/memory_dc.rb +10 -0
  232. data/lib/wx/doc/gen/menu.rb +48 -7
  233. data/lib/wx/doc/gen/menu_bar.rb +32 -13
  234. data/lib/wx/doc/gen/menu_item.rb +26 -0
  235. data/lib/wx/doc/gen/message_dialog.rb +10 -0
  236. data/lib/wx/doc/gen/mini_frame.rb +5 -2
  237. data/lib/wx/doc/gen/mirror_dc.rb +1 -0
  238. data/lib/wx/doc/gen/mouse_state.rb +1 -0
  239. data/lib/wx/doc/gen/multi_choice_dialog.rb +3 -1
  240. data/lib/wx/doc/gen/non_owned_window.rb +3 -0
  241. data/lib/wx/doc/gen/notebook.rb +11 -1
  242. data/lib/wx/doc/gen/num_validator.rb +37 -0
  243. data/lib/wx/doc/gen/number_entry_dialog.rb +4 -0
  244. data/lib/wx/doc/gen/object.rb +3 -0
  245. data/lib/wx/doc/gen/owner_drawn_combo_box.rb +340 -0
  246. data/lib/wx/doc/gen/paint_dc.rb +1 -0
  247. data/lib/wx/doc/gen/palette.rb +5 -0
  248. data/lib/wx/doc/gen/panel.rb +10 -2
  249. data/lib/wx/doc/gen/pen.rb +30 -1
  250. data/lib/wx/doc/gen/persistence_manager.rb +135 -0
  251. data/lib/wx/doc/gen/persistent_object.rb +52 -0
  252. data/lib/wx/doc/gen/persistent_window.rb +116 -0
  253. data/lib/wx/doc/gen/pg/numeric_property_validator.rb +2 -1
  254. data/lib/wx/doc/gen/pg/pg_array_editor_dialog.rb +4 -1
  255. data/lib/wx/doc/gen/pg/pg_cell.rb +6 -1
  256. data/lib/wx/doc/gen/pg/pg_editor.rb +61 -15
  257. data/lib/wx/doc/gen/pg/pg_multi_button.rb +2 -0
  258. data/lib/wx/doc/gen/pg/pg_properties.rb +198 -81
  259. data/lib/wx/doc/gen/pg/pg_property.rb +129 -52
  260. data/lib/wx/doc/gen/pg/pg_validation_info.rb +2 -0
  261. data/lib/wx/doc/gen/pg/property_grid.rb +56 -14
  262. data/lib/wx/doc/gen/pg/property_grid_event.rb +16 -6
  263. data/lib/wx/doc/gen/pg/property_grid_interface.rb +98 -37
  264. data/lib/wx/doc/gen/pg/property_grid_manager.rb +29 -7
  265. data/lib/wx/doc/gen/pg/property_grid_page.rb +11 -4
  266. data/lib/wx/doc/gen/pg/property_grid_page_state.rb +7 -2
  267. data/lib/wx/doc/gen/picker_base.rb +11 -1
  268. data/lib/wx/doc/gen/platform_info.rb +31 -0
  269. data/lib/wx/doc/gen/popup_window.rb +5 -0
  270. data/lib/wx/doc/gen/progress_dialog.rb +4 -0
  271. data/lib/wx/doc/gen/property_sheet_dialog.rb +7 -1
  272. data/lib/wx/doc/gen/prt/page_setup_dialog.rb +2 -0
  273. data/lib/wx/doc/gen/prt/post_script_dc.rb +1 -0
  274. data/lib/wx/doc/gen/prt/preview_frame.rb +4 -0
  275. data/lib/wx/doc/gen/prt/print_abort_dialog.rb +1 -0
  276. data/lib/wx/doc/gen/prt/print_data.rb +27 -0
  277. data/lib/wx/doc/gen/prt/print_dialog.rb +4 -0
  278. data/lib/wx/doc/gen/prt/printer.rb +42 -5
  279. data/lib/wx/doc/gen/prt/printer_dc.rb +2 -0
  280. data/lib/wx/doc/gen/query_layout_info_event.rb +9 -0
  281. data/lib/wx/doc/gen/radio_box.rb +19 -0
  282. data/lib/wx/doc/gen/radio_button.rb +9 -0
  283. data/lib/wx/doc/gen/rbn/ribbon_art_provider.rb +63 -0
  284. data/lib/wx/doc/gen/rbn/ribbon_bar.rb +23 -0
  285. data/lib/wx/doc/gen/rbn/ribbon_bar_event.rb +2 -1
  286. data/lib/wx/doc/gen/rbn/ribbon_button_bar.rb +35 -9
  287. data/lib/wx/doc/gen/rbn/ribbon_button_bar_event.rb +2 -1
  288. data/lib/wx/doc/gen/rbn/ribbon_control.rb +10 -0
  289. data/lib/wx/doc/gen/rbn/ribbon_gallery.rb +17 -7
  290. data/lib/wx/doc/gen/rbn/ribbon_gallery_event.rb +2 -1
  291. data/lib/wx/doc/gen/rbn/ribbon_page.rb +12 -0
  292. data/lib/wx/doc/gen/rbn/ribbon_panel.rb +11 -0
  293. data/lib/wx/doc/gen/rbn/ribbon_panel_event.rb +2 -1
  294. data/lib/wx/doc/gen/rbn/ribbon_tool_bar.rb +25 -0
  295. data/lib/wx/doc/gen/rbn/ribbon_tool_bar_event.rb +2 -1
  296. data/lib/wx/doc/gen/rearrange_ctrl.rb +4 -0
  297. data/lib/wx/doc/gen/rearrange_list.rb +9 -0
  298. data/lib/wx/doc/gen/region.rb +42 -13
  299. data/lib/wx/doc/gen/region_iterator.rb +1 -0
  300. data/lib/wx/doc/gen/rtc/rich_text_box.rb +25 -8
  301. data/lib/wx/doc/gen/rtc/rich_text_buffer.rb +41 -4
  302. data/lib/wx/doc/gen/rtc/rich_text_buffer_data_object.rb +1 -0
  303. data/lib/wx/doc/gen/rtc/rich_text_composite_object.rb +23 -11
  304. data/lib/wx/doc/gen/rtc/rich_text_ctrl.rb +74 -0
  305. data/lib/wx/doc/gen/rtc/rich_text_event.rb +6 -1
  306. data/lib/wx/doc/gen/rtc/rich_text_file_handler.rb +8 -0
  307. data/lib/wx/doc/gen/rtc/rich_text_formatting_dialog.rb +6 -0
  308. data/lib/wx/doc/gen/rtc/rich_text_header_footer_data.rb +1 -0
  309. data/lib/wx/doc/gen/rtc/rich_text_html_handler.rb +4 -0
  310. data/lib/wx/doc/gen/rtc/rich_text_image.rb +7 -0
  311. data/lib/wx/doc/gen/rtc/rich_text_object.rb +64 -4
  312. data/lib/wx/doc/gen/rtc/rich_text_paragraph_layout_box.rb +51 -4
  313. data/lib/wx/doc/gen/rtc/rich_text_printing.rb +13 -0
  314. data/lib/wx/doc/gen/rtc/rich_text_style_list_box.rb +9 -4
  315. data/lib/wx/doc/gen/rtc/rich_text_style_organiser_dialog.rb +3 -0
  316. data/lib/wx/doc/gen/rtc/rich_text_xml_handler.rb +2 -0
  317. data/lib/wx/doc/gen/rtc/symbol_picker_dialog.rb +1 -0
  318. data/lib/wx/doc/gen/sash_event.rb +5 -1
  319. data/lib/wx/doc/gen/sash_layout_window.rb +10 -0
  320. data/lib/wx/doc/gen/sash_window.rb +3 -0
  321. data/lib/wx/doc/gen/screen_dc.rb +1 -0
  322. data/lib/wx/doc/gen/scroll_bar.rb +11 -2
  323. data/lib/wx/doc/gen/scrolled_canvas.rb +20 -4
  324. data/lib/wx/doc/gen/scrolled_control.rb +20 -4
  325. data/lib/wx/doc/gen/scrolled_window.rb +20 -4
  326. data/lib/wx/doc/gen/search_ctrl.rb +6 -0
  327. data/lib/wx/doc/gen/simplebook.rb +7 -0
  328. data/lib/wx/doc/gen/single_choice_dialog.rb +3 -1
  329. data/lib/wx/doc/gen/sizer.rb +79 -9
  330. data/lib/wx/doc/gen/sizer_item.rb +16 -2
  331. data/lib/wx/doc/gen/slider.rb +23 -0
  332. data/lib/wx/doc/gen/spin_button.rb +9 -0
  333. data/lib/wx/doc/gen/spin_ctrl.rb +11 -0
  334. data/lib/wx/doc/gen/spin_ctrl_double.rb +7 -0
  335. data/lib/wx/doc/gen/spin_double_event.rb +4 -1
  336. data/lib/wx/doc/gen/spin_event.rb +2 -1
  337. data/lib/wx/doc/gen/splash_screen.rb +2 -0
  338. data/lib/wx/doc/gen/splitter_event.rb +10 -1
  339. data/lib/wx/doc/gen/splitter_window.rb +38 -14
  340. data/lib/wx/doc/gen/static_bitmap.rb +99 -2
  341. data/lib/wx/doc/gen/static_box.rb +6 -0
  342. data/lib/wx/doc/gen/static_box_sizer.rb +3 -0
  343. data/lib/wx/doc/gen/static_line.rb +4 -0
  344. data/lib/wx/doc/gen/static_text.rb +5 -0
  345. data/lib/wx/doc/gen/status_bar.rb +17 -3
  346. data/lib/wx/doc/gen/stc/styled_text_ctrl.rb +174 -6
  347. data/lib/wx/doc/gen/stc/styled_text_event.rb +27 -1
  348. data/lib/wx/doc/gen/std_dialog_button_sizer.rb +7 -0
  349. data/lib/wx/doc/gen/svg_file_dc.rb +9 -0
  350. data/lib/wx/doc/gen/system_options.rb +8 -0
  351. data/lib/wx/doc/gen/system_settings.rb +7 -0
  352. data/lib/wx/doc/gen/task_bar_button.rb +12 -0
  353. data/lib/wx/doc/gen/task_bar_icon.rb +5 -0
  354. data/lib/wx/doc/gen/task_bar_icon_event.rb +2 -1
  355. data/lib/wx/doc/gen/text_attr.rb +27 -0
  356. data/lib/wx/doc/gen/text_ctrl.rb +27 -3
  357. data/lib/wx/doc/gen/text_entry.rb +43 -9
  358. data/lib/wx/doc/gen/text_entry_dialog.rb +12 -0
  359. data/lib/wx/doc/gen/text_validator.rb +16 -0
  360. data/lib/wx/doc/gen/time_picker_ctrl.rb +6 -0
  361. data/lib/wx/doc/gen/timer.rb +8 -0
  362. data/lib/wx/doc/gen/timer_event.rb +1 -0
  363. data/lib/wx/doc/gen/tip_provider.rb +5 -0
  364. data/lib/wx/doc/gen/toggle_button.rb +68 -0
  365. data/lib/wx/doc/gen/tool_bar.rb +57 -14
  366. data/lib/wx/doc/gen/tool_tip.rb +6 -0
  367. data/lib/wx/doc/gen/toolbook.rb +3 -0
  368. data/lib/wx/doc/gen/top_level_window.rb +34 -3
  369. data/lib/wx/doc/gen/tree_ctrl.rb +49 -0
  370. data/lib/wx/doc/gen/tree_event.rb +7 -1
  371. data/lib/wx/doc/gen/treebook.rb +9 -0
  372. data/lib/wx/doc/gen/ui_action_simulator.rb +4 -0
  373. data/lib/wx/doc/gen/utils.rb +55 -16
  374. data/lib/wx/doc/gen/v_list_box.rb +21 -0
  375. data/lib/wx/doc/gen/v_scrolled_window.rb +15 -0
  376. data/lib/wx/doc/gen/validator.rb +9 -13
  377. data/lib/wx/doc/gen/variant.rb +6 -0
  378. data/lib/wx/doc/gen/window.rb +260 -52
  379. data/lib/wx/doc/gen/window_dc.rb +2 -0
  380. data/lib/wx/doc/gen/window_disabler.rb +1 -0
  381. data/lib/wx/doc/gen/with_images.rb +7 -1
  382. data/lib/wx/doc/gen/wizard.rb +18 -0
  383. data/lib/wx/doc/gen/wizard_event.rb +3 -1
  384. data/lib/wx/doc/gen/wizard_page.rb +5 -0
  385. data/lib/wx/doc/gen/wizard_page_simple.rb +4 -0
  386. data/lib/wx/doc/gen/wrap_sizer.rb +5 -0
  387. data/lib/wx/doc/gen/xml_node.rb +14 -0
  388. data/lib/wx/doc/gen/xml_resource.rb +22 -0
  389. data/lib/wx/doc/generic_validator.rb +95 -0
  390. data/lib/wx/doc/html/simple_html_listbox.rb +22 -0
  391. data/lib/wx/doc/num_validator.rb +387 -0
  392. data/lib/wx/doc/owner_drawn_combobox.rb +96 -0
  393. data/lib/wx/doc/persistence_manager.rb +36 -0
  394. data/lib/wx/doc/persistent_object.rb +27 -0
  395. data/lib/wx/doc/pg/numeric_property_validator.rb +33 -0
  396. data/lib/wx/doc/static_bitmap.rb +25 -0
  397. data/lib/wx/doc/text_validator.rb +10 -0
  398. data/lib/wx/doc/top_level_window.rb +19 -0
  399. data/lib/wx/doc/treebook.rb +6 -1
  400. data/lib/wx/doc/validator.rb +113 -0
  401. data/lib/wx/doc/window.rb +30 -0
  402. data/lib/wx/html/events/evt_list.rb +0 -10
  403. data/lib/wx/html/simple_html_listbox.rb +24 -91
  404. data/lib/wx/keyword_defs.rb +34 -2
  405. data/lib/wx/rbn/ribbon_gallery.rb +0 -21
  406. data/lib/wx/version.rb +1 -1
  407. data/lib/wxruby_aui.so +0 -0
  408. data/lib/wxruby_core.so +0 -0
  409. data/lib/wxruby_grid.so +0 -0
  410. data/lib/wxruby_html.so +0 -0
  411. data/lib/wxruby_pg.so +0 -0
  412. data/lib/wxruby_prt.so +0 -0
  413. data/lib/wxruby_rbn.so +0 -0
  414. data/lib/wxruby_rtc.so +0 -0
  415. data/lib/wxruby_stc.so +0 -0
  416. data/rakelib/lib/config/mingw.rb +12 -0
  417. data/samples/aui/aui.rb +1237 -1233
  418. data/samples/calendar/calendar.rb +293 -289
  419. data/samples/controls/get_item_sample.rb +83 -79
  420. data/samples/controls/htlbox.rb +331 -327
  421. data/samples/dialogs/dialogs.rb +682 -694
  422. data/samples/dialogs/wizard.rb +52 -55
  423. data/samples/dragdrop/dragdrop.rb +146 -142
  424. data/samples/drawing/bitmap.rb +29 -26
  425. data/samples/drawing/bitmap_image.rb +84 -80
  426. data/samples/drawing/graphics_drawing.rb +209 -205
  427. data/samples/drawing/image_prt.rb +344 -340
  428. data/samples/drawing/maths_images.rb +18 -1
  429. data/samples/drawing/rmagic_bitmap_image.rb +88 -84
  430. data/samples/etc/caret.rb +306 -0
  431. data/samples/etc/miniframe.rb +65 -60
  432. data/samples/etc/sash.rb +109 -105
  433. data/samples/etc/scrollwin.rb +86 -80
  434. data/samples/etc/system_settings.rb +216 -209
  435. data/samples/event/activation.rb +72 -67
  436. data/samples/event/event.rb +160 -153
  437. data/samples/event/threaded.rb +8 -1
  438. data/samples/event/update_ui_event.rb +67 -60
  439. data/samples/grid/grid.rb +188 -181
  440. data/samples/grid/gridtablebase.rb +136 -129
  441. data/samples/html/html.rb +208 -204
  442. data/samples/mdi/mdi.rb +59 -54
  443. data/samples/minimal/minimal.rb +54 -51
  444. data/samples/minimal/nothing.rb +1 -0
  445. data/samples/printing/printing.rb +367 -377
  446. data/samples/printing/printing2.rb +203 -198
  447. data/samples/propgrid/propgrid.rb +2312 -2308
  448. data/samples/propgrid/propgrid_minimal.rb +57 -50
  449. data/samples/ribbon/ribbon.rb +780 -774
  450. data/samples/sampler/ext.rb +0 -33
  451. data/samples/sampler/sample.rb +4 -9
  452. data/samples/sampler.rb +1 -1
  453. data/samples/splash/splash.rb +118 -116
  454. data/samples/text/rich_textctrl.rb +207 -201
  455. data/samples/text/richtext.rb +1409 -1405
  456. data/samples/text/scintilla.rb +137 -128
  457. data/samples/text/textctrl.rb +89 -83
  458. data/samples/text/unicode.rb +175 -168
  459. data/samples/treectrl/treectrl.rb +1430 -1426
  460. data/samples/widgets/activityindicator.rb +95 -0
  461. data/samples/widgets/art/widgets/activityindicator.xpm +278 -0
  462. data/samples/widgets/art/widgets/bmpbtn.xpm +37 -0
  463. data/samples/widgets/art/widgets/bmpcombobox.xpm +54 -0
  464. data/samples/widgets/art/widgets/button.xpm +54 -0
  465. data/samples/widgets/art/widgets/checkbox.xpm +54 -0
  466. data/samples/{bigdemo/icons → widgets/art/widgets}/choice.xpm +1 -1
  467. data/samples/widgets/art/widgets/choicebk.xpm +54 -0
  468. data/samples/widgets/art/widgets/clrpicker.xpm +193 -0
  469. data/samples/widgets/art/widgets/combobox.xpm +54 -0
  470. data/samples/widgets/art/widgets/datepick.xpm +200 -0
  471. data/samples/widgets/art/widgets/dirctrl.xpm +54 -0
  472. data/samples/widgets/art/widgets/dirpicker.xpm +213 -0
  473. data/samples/widgets/art/widgets/filepicker.xpm +214 -0
  474. data/samples/widgets/art/widgets/fontpicker.xpm +185 -0
  475. data/samples/widgets/art/widgets/gauge.xpm +54 -0
  476. data/samples/widgets/art/widgets/header.xpm +54 -0
  477. data/samples/widgets/art/widgets/hyperlnk.xpm +54 -0
  478. data/samples/widgets/art/widgets/listbook.xpm +54 -0
  479. data/samples/widgets/art/widgets/listbox.xpm +54 -0
  480. data/samples/widgets/art/widgets/native.xpm +81 -0
  481. data/samples/widgets/art/widgets/notebook.xpm +54 -0
  482. data/samples/widgets/art/widgets/odcombobox.xpm +54 -0
  483. data/samples/widgets/art/widgets/radiobox.xpm +54 -0
  484. data/samples/widgets/art/widgets/scrolbar.xpm +54 -0
  485. data/samples/widgets/art/widgets/slider.xpm +54 -0
  486. data/samples/widgets/art/widgets/spinbtn.xpm +40 -0
  487. data/samples/widgets/art/widgets/statbmp.xpm +40 -0
  488. data/samples/widgets/art/widgets/statbox.xpm +54 -0
  489. data/samples/widgets/art/widgets/stattext.xpm +54 -0
  490. data/samples/widgets/art/widgets/text.xpm +54 -0
  491. data/samples/widgets/art/widgets/timepick.xpm +207 -0
  492. data/samples/widgets/art/widgets/toggle.xpm +54 -0
  493. data/samples/widgets/art/widgets/toucan.png +0 -0
  494. data/samples/widgets/bmpcombobox.rb +651 -0
  495. data/samples/widgets/button.rb +462 -0
  496. data/samples/widgets/checkbox.rb +211 -0
  497. data/samples/widgets/choice.rb +287 -0
  498. data/samples/widgets/clrpicker.rb +156 -0
  499. data/samples/widgets/combobox.rb +516 -0
  500. data/samples/widgets/datepick.rb +215 -0
  501. data/samples/widgets/dirctrl.rb +265 -0
  502. data/samples/widgets/dirpicker.rb +158 -0
  503. data/samples/widgets/editlbox.rb +122 -0
  504. data/samples/widgets/filectrl.rb +216 -0
  505. data/samples/widgets/filepicker.rb +214 -0
  506. data/samples/widgets/fontpicker.rb +135 -0
  507. data/samples/widgets/gauge.rb +311 -0
  508. data/samples/widgets/headerctrl.rb +236 -0
  509. data/samples/widgets/hyperlink.rb +203 -0
  510. data/samples/widgets/itemcontainer.rb +185 -0
  511. data/samples/widgets/listbox.rb +473 -0
  512. data/samples/widgets/notebook.rb +488 -0
  513. data/samples/widgets/odcombobox.rb +608 -0
  514. data/samples/widgets/radiobox.rb +328 -0
  515. data/samples/widgets/searchctrl.rb +159 -0
  516. data/samples/widgets/slider.rb +594 -0
  517. data/samples/widgets/spinbtn.rb +443 -0
  518. data/samples/widgets/statbmp.rb +130 -0
  519. data/samples/widgets/static.rb +436 -0
  520. data/samples/widgets/textctrl.rb +700 -0
  521. data/samples/widgets/timepick.rb +148 -0
  522. data/samples/widgets/tn_widgets.png +0 -0
  523. data/samples/widgets/toggle.rb +385 -0
  524. data/samples/widgets/widgets.rb +1229 -0
  525. data/samples/xrc/custom_xrc_sample.rb +47 -41
  526. data/samples/xrc/xrc_sample.rb +53 -47
  527. data/tests/test_config.rb +207 -42
  528. data/tests/test_event_handling.rb +52 -34
  529. data/tests/test_events.rb +7 -0
  530. data/tests/test_item_data.rb +24 -0
  531. data/tests/test_persistence.rb +142 -0
  532. data/tests/test_sizer.rb +44 -1
  533. data/tests/test_validators.rb +805 -0
  534. metadata +103 -137
  535. data/lib/wx/core/choice.rb +0 -14
  536. data/lib/wx/core/combo_ctrl.rb +0 -110
  537. data/samples/bigdemo/About.rbw +0 -39
  538. data/samples/bigdemo/ColorPanel.rbw +0 -23
  539. data/samples/bigdemo/GridSimple.rbw +0 -78
  540. data/samples/bigdemo/MDIDemo.rbw +0 -57
  541. data/samples/bigdemo/PopupMenu.rbw +0 -146
  542. data/samples/bigdemo/ShapedWindow.rbw +0 -128
  543. data/samples/bigdemo/Sizers.rbw +0 -541
  544. data/samples/bigdemo/bigdemo.rb +0 -817
  545. data/samples/bigdemo/demoTemplate.rbw +0 -33
  546. data/samples/bigdemo/helpfile.htb +0 -0
  547. data/samples/bigdemo/icons/Test 015.jpg +0 -0
  548. data/samples/bigdemo/icons/Test 015.png +0 -0
  549. data/samples/bigdemo/icons/choice.bmp +0 -0
  550. data/samples/bigdemo/icons/combo.bmp +0 -0
  551. data/samples/bigdemo/icons/combo.xpm +0 -27
  552. data/samples/bigdemo/icons/copy.xpm +0 -25
  553. data/samples/bigdemo/icons/cut.xpm +0 -24
  554. data/samples/bigdemo/icons/gauge.bmp +0 -0
  555. data/samples/bigdemo/icons/gauge.xpm +0 -27
  556. data/samples/bigdemo/icons/help.xpm +0 -25
  557. data/samples/bigdemo/icons/list.bmp +0 -0
  558. data/samples/bigdemo/icons/list.xpm +0 -27
  559. data/samples/bigdemo/icons/mondrian.ico +0 -0
  560. data/samples/bigdemo/icons/mondrian.xpm +0 -44
  561. data/samples/bigdemo/icons/new.xpm +0 -24
  562. data/samples/bigdemo/icons/ogl.ico +0 -0
  563. data/samples/bigdemo/icons/ogl.xpm +0 -45
  564. data/samples/bigdemo/icons/open.xpm +0 -26
  565. data/samples/bigdemo/icons/paste.bmp +0 -0
  566. data/samples/bigdemo/icons/paste.xpm +0 -38
  567. data/samples/bigdemo/icons/pointy.png +0 -0
  568. data/samples/bigdemo/icons/preview.xpm +0 -26
  569. data/samples/bigdemo/icons/print.xpm +0 -26
  570. data/samples/bigdemo/icons/radio.bmp +0 -0
  571. data/samples/bigdemo/icons/radio.xpm +0 -27
  572. data/samples/bigdemo/icons/robert.xpm +0 -415
  573. data/samples/bigdemo/icons/sashtest.ico +0 -0
  574. data/samples/bigdemo/icons/save.xpm +0 -25
  575. data/samples/bigdemo/icons/smiles.bmp +0 -0
  576. data/samples/bigdemo/icons/smiles.xpm +0 -39
  577. data/samples/bigdemo/icons/smiley.ico +0 -0
  578. data/samples/bigdemo/icons/smiley.xpm +0 -42
  579. data/samples/bigdemo/icons/stattext.xpm +0 -24
  580. data/samples/bigdemo/icons/test2.bmp +0 -0
  581. data/samples/bigdemo/icons/test2.png +0 -0
  582. data/samples/bigdemo/icons/test2.xpm +0 -79
  583. data/samples/bigdemo/icons/text.bmp +0 -0
  584. data/samples/bigdemo/icons/text.xpm +0 -27
  585. data/samples/bigdemo/icons/tog1.bmp +0 -0
  586. data/samples/bigdemo/icons/tog1.xpm +0 -38
  587. data/samples/bigdemo/icons/tog2.bmp +0 -0
  588. data/samples/bigdemo/icons/tog2.xpm +0 -38
  589. data/samples/bigdemo/icons/wxruby-128x128.png +0 -0
  590. data/samples/bigdemo/icons/wxwin.ico +0 -0
  591. data/samples/bigdemo/icons/wxwin16x16.png +0 -0
  592. data/samples/bigdemo/icons/wxwin16x16.xpm +0 -25
  593. data/samples/bigdemo/icons/wxwin32x32.png +0 -0
  594. data/samples/bigdemo/icons/wxwin48x48.png +0 -0
  595. data/samples/bigdemo/run.rb +0 -98
  596. data/samples/bigdemo/tips.txt +0 -7
  597. data/samples/bigdemo/utils.rb +0 -20
  598. data/samples/bigdemo/wxArtProvider.rbw +0 -282
  599. data/samples/bigdemo/wxBitmapButton.rbw +0 -65
  600. data/samples/bigdemo/wxButton.rbw +0 -64
  601. data/samples/bigdemo/wxCalendarCtrl.rbw +0 -59
  602. data/samples/bigdemo/wxCheckBox.rbw +0 -50
  603. data/samples/bigdemo/wxCheckListBox.rbw +0 -65
  604. data/samples/bigdemo/wxChoice.rbw +0 -47
  605. data/samples/bigdemo/wxChoicebook.rbw +0 -78
  606. data/samples/bigdemo/wxColourDialog.rbw +0 -33
  607. data/samples/bigdemo/wxComboBox.rbw +0 -77
  608. data/samples/bigdemo/wxCursor.rbw +0 -136
  609. data/samples/bigdemo/wxDialog.rbw +0 -74
  610. data/samples/bigdemo/wxDirDialog.rbw +0 -29
  611. data/samples/bigdemo/wxDragImage.rbw +0 -70
  612. data/samples/bigdemo/wxFileDialog.rbw +0 -37
  613. data/samples/bigdemo/wxFileDialog_Save.rbw +0 -35
  614. data/samples/bigdemo/wxFindReplaceDialog.rbw +0 -82
  615. data/samples/bigdemo/wxFontDialog.rbw +0 -200
  616. data/samples/bigdemo/wxFrame.rbw +0 -53
  617. data/samples/bigdemo/wxGauge.rbw +0 -65
  618. data/samples/bigdemo/wxGenericDirCtrl.rbw +0 -74
  619. data/samples/bigdemo/wxGrid.rbw +0 -66
  620. data/samples/bigdemo/wxHtmlHelpController.rbw +0 -52
  621. data/samples/bigdemo/wxListBox.rbw +0 -140
  622. data/samples/bigdemo/wxListCtrl_virtual.rbw +0 -112
  623. data/samples/bigdemo/wxMDIWindows.rbw +0 -50
  624. data/samples/bigdemo/wxMenu.rbw +0 -247
  625. data/samples/bigdemo/wxMessageDialog.rbw +0 -27
  626. data/samples/bigdemo/wxMiniFrame.rbw +0 -70
  627. data/samples/bigdemo/wxMultipleChoiceDialog.rbw +0 -29
  628. data/samples/bigdemo/wxNotebook.rbw +0 -136
  629. data/samples/bigdemo/wxProgressDialog.rbw +0 -43
  630. data/samples/bigdemo/wxRadioBox.rbw +0 -72
  631. data/samples/bigdemo/wxRadioButton.rbw +0 -125
  632. data/samples/bigdemo/wxSashWindow.rbw +0 -141
  633. data/samples/bigdemo/wxScrolledMessageDialog.rbw +0 -57
  634. data/samples/bigdemo/wxScrolledWindow.rbw +0 -199
  635. data/samples/bigdemo/wxSingleChoiceDialog.rbw +0 -33
  636. data/samples/bigdemo/wxSlider.rbw +0 -42
  637. data/samples/bigdemo/wxSpinButton.rbw +0 -50
  638. data/samples/bigdemo/wxSpinCtrl.rbw +0 -51
  639. data/samples/bigdemo/wxSplitterWindow.rbw +0 -63
  640. data/samples/bigdemo/wxStaticBitmap.rbw +0 -47
  641. data/samples/bigdemo/wxStaticText.rbw +0 -55
  642. data/samples/bigdemo/wxStatusBar.rbw +0 -126
  643. data/samples/bigdemo/wxTextCtrl.rbw +0 -149
  644. data/samples/bigdemo/wxTextEntryDialog.rbw +0 -31
  645. data/samples/bigdemo/wxToggleButton.rbw +0 -49
  646. data/samples/bigdemo/wxToolBar.rbw +0 -131
  647. data/samples/bigdemo/wxTreeCtrl.rbw +0 -191
  648. data/samples/caret/caret.rb +0 -298
  649. data/samples/caret/mondrian.xpm +0 -44
  650. data/samples/controls/books.rb +0 -189
  651. data/samples/controls/choice.xpm +0 -27
  652. data/samples/controls/combo.xpm +0 -27
  653. data/samples/controls/controls.rb +0 -1099
  654. data/samples/controls/gauge.xpm +0 -27
  655. data/samples/controls/list.xpm +0 -27
  656. data/samples/controls/mondrian.ico +0 -0
  657. data/samples/controls/mondrian.xpm +0 -44
  658. data/samples/controls/radio.xpm +0 -27
  659. data/samples/controls/stattext.xpm +0 -24
  660. data/samples/controls/test2.bmp +0 -0
  661. data/samples/controls/text.xpm +0 -27
  662. data/samples/controls/tn_books.png +0 -0
  663. data/samples/controls/tn_controls.png +0 -0
  664. data/samples/etc/choice.rb +0 -87
  665. data/samples/etc/tn_choice.png +0 -0
  666. data/samples/text/mondrian.ico +0 -0
  667. data/samples/text/mondrian.xpm +0 -44
  668. /data/samples/{caret → etc}/tn_caret.png +0 -0
@@ -17,1693 +17,1697 @@ require 'wx'
17
17
  # Also, some items remain to be implemented - for example, setting item
18
18
  # icons and item data.
19
19
 
20
- # Just some event ids for the numerous menu items
21
- TreeTest_TogButtons,
22
- TreeTest_TogTwist,
23
- TreeTest_TogLines,
24
- TreeTest_TogEdit,
25
- TreeTest_TogHideRoot,
26
- TreeTest_TogRootLines,
27
- TreeTest_TogBorder,
28
- TreeTest_TogFullHighlight,
29
- TreeTest_SetFgColour,
30
- TreeTest_SetBgColour,
31
- TreeTest_ResetStyle,
32
- TreeTest_Highlight,
33
- TreeTest_Dump,
34
- TreeTest_DumpSelected,
35
- TreeTest_Count,
36
- TreeTest_CountRec,
37
- TreeTest_Sort,
38
- TreeTest_SortRev,
39
- TreeTest_SetBold,
40
- TreeTest_ClearBold,
41
- TreeTest_Rename,
42
- TreeTest_Delete,
43
- TreeTest_DeleteChildren,
44
- TreeTest_DeleteAll,
45
- TreeTest_SelectRoot,
46
- TreeTest_SetFocusedRoot,
47
- TreeTest_ClearFocused,
48
- TreeTest_FreezeThaw,
49
- TreeTest_Recreate,
50
- TreeTest_ToggleImages,
51
- TreeTest_ToggleStates,
52
- TreeTest_ToggleBell,
53
- TreeTest_ToggleAlternateImages,
54
- TreeTest_ToggleAlternateStates,
55
- TreeTest_ToggleButtons,
56
- TreeTest_SetImageSize,
57
- TreeTest_ToggleSel,
58
- TreeTest_CollapseAndReset,
59
- TreeTest_EnsureVisible,
60
- TreeTest_SetFocus,
61
- TreeTest_AddItem,
62
- TreeTest_AddManyItems,
63
- TreeTest_InsertItem,
64
- TreeTest_IncIndent,
65
- TreeTest_DecIndent,
66
- TreeTest_IncSpacing,
67
- TreeTest_DecSpacing,
68
- TreeTest_ToggleIcon,
69
- TreeTest_ToggleState,
70
- TreeTest_ShowFirstVisible,
71
- TreeTest_ShowLastVisible,
72
- TreeTest_ShowNextVisible,
73
- TreeTest_ShowPrevVisible,
74
- TreeTest_ShowParent,
75
- TreeTest_ShowPrevSibling,
76
- TreeTest_ShowNextSibling,
77
- TreeTest_ScrollTo,
78
- TreeTest_SelectLast,
79
- TreeTest_Select,
80
- TreeTest_Unselect,
81
- TreeTest_SelectChildren = (Wx::ID_HIGHEST..Wx::ID_HIGHEST + 61).to_a
82
-
83
- TreeCtrlIcon_File,
84
- TreeCtrlIcon_FileSelected,
85
- TreeCtrlIcon_Folder,
86
- TreeCtrlIcon_FolderSelected,
87
- TreeCtrlIcon_FolderOpened = 0, 1, 2, 3, 4
88
-
89
- class MyTreeCtrl < Wx::TreeCtrl
90
- def initialize(parent, *args)
91
- super(parent, *args)
92
-
93
- @alternate_images = false
94
- @alternate_states = false
95
- @reverse_sort = false
96
-
97
- create_image_list(16)
98
- create_state_imageList
99
-
100
- # add some items to the tree
101
- add_test_items_to_tree(5, 2)
102
-
103
- # TreeCtrl supports a large number of different events...
104
- evt_tree_begin_drag self, :on_begin_drag
105
- evt_tree_begin_rdrag self, :on_begin_rdrag
106
- evt_tree_end_drag self, :on_end_drag
107
- evt_tree_begin_label_edit self, :on_begin_label_edit
108
- evt_tree_end_label_edit self, :on_end_label_edit
109
- evt_tree_delete_item self, :on_delete_item
110
- #evt_tree_set_info self, :on_set_info
111
- evt_tree_item_expanded self, :on_item_expanded
112
- evt_tree_item_expanding self, :on_item_expanding
113
- evt_tree_item_collapsed self, :on_item_collapsed
114
- evt_tree_item_collapsing self, :on_item_collapsing
115
- evt_tree_sel_changed self, :on_sel_changed
116
- evt_tree_sel_changing self, :on_sel_changing
117
- evt_tree_key_down self, :on_tree_key_down
118
- evt_tree_item_activated self, :on_item_activated
119
- evt_tree_state_image_click self, :on_item_state_clicked
120
-
121
- # EVT_TREE_ITEM_MENU is the preferred event for creating context menus
122
- # on a tree control, because it includes the point of the click or item,
123
- # meaning that no additional placement calculations are required.
124
- evt_tree_item_menu self, :on_item_menu
125
- evt_tree_item_right_click self, :on_item_rclick
126
-
127
- evt_context_menu :on_context_menu
128
-
129
- evt_right_dclick :on_rmouse_dclick
130
- evt_right_down :on_rmouse_down
131
- evt_right_up :on_rmouse_up
132
- end
133
-
134
- attr_accessor :alternate_images, :alternate_states, :reverse_sort
135
-
136
- def reset_broken_state_images
137
- count = self.state_image_list.get_image_count
138
- state = count > 0 ? count - 1 : Wx::TREE_ITEMSTATE_NONE
139
- do_reset_broken_state_images(self.root_item, nil, state)
140
- end
141
-
142
- def do_reset_broken_state_images(parent, cookie, state)
143
- unless cookie
144
- id, cookie = get_first_child(parent)
145
- else
146
- id, cookie = get_next_child(parent, cookie)
20
+ module TreeCtrl
21
+
22
+ # Just some event ids for the numerous menu items
23
+ TreeTest_TogButtons,
24
+ TreeTest_TogTwist,
25
+ TreeTest_TogLines,
26
+ TreeTest_TogEdit,
27
+ TreeTest_TogHideRoot,
28
+ TreeTest_TogRootLines,
29
+ TreeTest_TogBorder,
30
+ TreeTest_TogFullHighlight,
31
+ TreeTest_SetFgColour,
32
+ TreeTest_SetBgColour,
33
+ TreeTest_ResetStyle,
34
+ TreeTest_Highlight,
35
+ TreeTest_Dump,
36
+ TreeTest_DumpSelected,
37
+ TreeTest_Count,
38
+ TreeTest_CountRec,
39
+ TreeTest_Sort,
40
+ TreeTest_SortRev,
41
+ TreeTest_SetBold,
42
+ TreeTest_ClearBold,
43
+ TreeTest_Rename,
44
+ TreeTest_Delete,
45
+ TreeTest_DeleteChildren,
46
+ TreeTest_DeleteAll,
47
+ TreeTest_SelectRoot,
48
+ TreeTest_SetFocusedRoot,
49
+ TreeTest_ClearFocused,
50
+ TreeTest_FreezeThaw,
51
+ TreeTest_Recreate,
52
+ TreeTest_ToggleImages,
53
+ TreeTest_ToggleStates,
54
+ TreeTest_ToggleBell,
55
+ TreeTest_ToggleAlternateImages,
56
+ TreeTest_ToggleAlternateStates,
57
+ TreeTest_ToggleButtons,
58
+ TreeTest_SetImageSize,
59
+ TreeTest_ToggleSel,
60
+ TreeTest_CollapseAndReset,
61
+ TreeTest_EnsureVisible,
62
+ TreeTest_SetFocus,
63
+ TreeTest_AddItem,
64
+ TreeTest_AddManyItems,
65
+ TreeTest_InsertItem,
66
+ TreeTest_IncIndent,
67
+ TreeTest_DecIndent,
68
+ TreeTest_IncSpacing,
69
+ TreeTest_DecSpacing,
70
+ TreeTest_ToggleIcon,
71
+ TreeTest_ToggleState,
72
+ TreeTest_ShowFirstVisible,
73
+ TreeTest_ShowLastVisible,
74
+ TreeTest_ShowNextVisible,
75
+ TreeTest_ShowPrevVisible,
76
+ TreeTest_ShowParent,
77
+ TreeTest_ShowPrevSibling,
78
+ TreeTest_ShowNextSibling,
79
+ TreeTest_ScrollTo,
80
+ TreeTest_SelectLast,
81
+ TreeTest_Select,
82
+ TreeTest_Unselect,
83
+ TreeTest_SelectChildren = (Wx::ID_HIGHEST..Wx::ID_HIGHEST + 61).to_a
84
+
85
+ TreeCtrlIcon_File,
86
+ TreeCtrlIcon_FileSelected,
87
+ TreeCtrlIcon_Folder,
88
+ TreeCtrlIcon_FolderSelected,
89
+ TreeCtrlIcon_FolderOpened = 0, 1, 2, 3, 4
90
+
91
+ class MyTreeCtrl < Wx::TreeCtrl
92
+ def initialize(parent, *args)
93
+ super(parent, *args)
94
+
95
+ @alternate_images = false
96
+ @alternate_states = false
97
+ @reverse_sort = false
98
+
99
+ create_image_list(16)
100
+ create_state_imageList
101
+
102
+ # add some items to the tree
103
+ add_test_items_to_tree(5, 2)
104
+
105
+ # TreeCtrl supports a large number of different events...
106
+ evt_tree_begin_drag self, :on_begin_drag
107
+ evt_tree_begin_rdrag self, :on_begin_rdrag
108
+ evt_tree_end_drag self, :on_end_drag
109
+ evt_tree_begin_label_edit self, :on_begin_label_edit
110
+ evt_tree_end_label_edit self, :on_end_label_edit
111
+ evt_tree_delete_item self, :on_delete_item
112
+ #evt_tree_set_info self, :on_set_info
113
+ evt_tree_item_expanded self, :on_item_expanded
114
+ evt_tree_item_expanding self, :on_item_expanding
115
+ evt_tree_item_collapsed self, :on_item_collapsed
116
+ evt_tree_item_collapsing self, :on_item_collapsing
117
+ evt_tree_sel_changed self, :on_sel_changed
118
+ evt_tree_sel_changing self, :on_sel_changing
119
+ evt_tree_key_down self, :on_tree_key_down
120
+ evt_tree_item_activated self, :on_item_activated
121
+ evt_tree_state_image_click self, :on_item_state_clicked
122
+
123
+ # EVT_TREE_ITEM_MENU is the preferred event for creating context menus
124
+ # on a tree control, because it includes the point of the click or item,
125
+ # meaning that no additional placement calculations are required.
126
+ evt_tree_item_menu self, :on_item_menu
127
+ evt_tree_item_right_click self, :on_item_rclick
128
+
129
+ evt_context_menu :on_context_menu
130
+
131
+ evt_right_dclick :on_rmouse_dclick
132
+ evt_right_down :on_rmouse_down
133
+ evt_right_up :on_rmouse_up
147
134
  end
148
135
 
149
- return unless id.ok?
150
-
151
- curState = get_item_state(id)
136
+ attr_accessor :alternate_images, :alternate_states, :reverse_sort
152
137
 
153
- set_item_state(id, state) if curState != Wx::TREE_ITEMSTATE_NONE && curState > state
154
-
155
- do_reset_broken_state_images(id, nil, state) if item_has_children(id)
156
-
157
- do_reset_broken_state_images(parent, cookie, state)
158
- end
159
-
160
- def show_info(id)
161
- Wx::log_message("Item '%s': %sselected, %sexpanded, %sbold,\n" +
162
- "%d children (%d immediately under selected item).",
163
- get_item_text(id),
164
- bool_to_str(is_selected(id)),
165
- bool_to_str(is_expanded(id)),
166
- bool_to_str(is_bold(id)),
167
- get_children_count(id),
168
- get_children_count(id, false))
169
- end
138
+ def reset_broken_state_images
139
+ count = self.state_image_list.get_image_count
140
+ state = count > 0 ? count - 1 : Wx::TREE_ITEMSTATE_NONE
141
+ do_reset_broken_state_images(self.root_item, nil, state)
142
+ end
170
143
 
171
- def bool_to_str(bool)
172
- bool ? " " : "not "
173
- end
144
+ def do_reset_broken_state_images(parent, cookie, state)
145
+ unless cookie
146
+ id, cookie = get_first_child(parent)
147
+ else
148
+ id, cookie = get_next_child(parent, cookie)
149
+ end
174
150
 
175
- def do_sort_children(item, reverse = false)
176
- @reverse_sort = reverse
177
- sort_children(item)
178
- end
151
+ return unless id.ok?
179
152
 
180
- def do_ensure_visible
181
- ensure_visible(@last_item)
182
- end
153
+ curState = get_item_state(id)
183
154
 
184
- def image_size
185
- return @image_size
186
- end
155
+ set_item_state(id, state) if curState != Wx::TREE_ITEMSTATE_NONE && curState > state
187
156
 
188
- def is_test_item(item)
189
- # the test item is the first child folder
190
- return item_parent(item) == root_item && !prev_sibling(item)
191
- end
157
+ do_reset_broken_state_images(id, nil, state) if item_has_children(id)
192
158
 
193
- def create_image_list(size)
194
- if size < 0
195
- unset_image_list
196
- return
197
- elsif size == 0
198
- size = @image_size
199
- else
200
- @image_size = size
201
- end
202
-
203
- Wx::BusyCursor.busy do
204
- # should correspond to TreeCtrlIcon_xxx enum
205
- icons = if @alternate_images
206
- [Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon1.xpm'), Wx::BITMAP_TYPE_XPM),
207
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon2.xpm'), Wx::BITMAP_TYPE_XPM),
208
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
209
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon4.xpm'), Wx::BITMAP_TYPE_XPM),
210
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM),
211
- ]
212
- else
213
- icon_size = Wx::Size.new(@image_size, @image_size)
214
- ic1 = Wx::ArtProvider::get_icon(Wx::ART_NORMAL_FILE, Wx::ART_LIST, icon_size)
215
- ic2 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_LIST, icon_size)
216
- [ic1, ic1, ic2, ic2, ic2]
217
- end
218
-
219
- # Make an image list containing small icons
220
- images = Wx::ImageList.new(@image_size, @image_size, true)
221
- icons.each do |ic|
222
- orig_size = ic.get_width
223
- ic = if @image_size == orig_size
224
- ic
225
- else
226
- Wx::Bitmap.new(ic.convert_to_image.rescale(@image_size, @image_size))
227
- end
228
- images.add(ic)
229
- end
230
- self.image_list = images
159
+ do_reset_broken_state_images(parent, cookie, state)
231
160
  end
232
- end
233
161
 
234
- def unset_image_list
235
- self.image_list = nil
236
- end
237
-
238
- def create_state_imageList(del = false)
239
- if del
240
- self.state_image_list = nil
241
- return
162
+ def show_info(id)
163
+ Wx::log_message("Item '%s': %sselected, %sexpanded, %sbold,\n" +
164
+ "%d children (%d immediately under selected item).",
165
+ get_item_text(id),
166
+ bool_to_str(is_selected(id)),
167
+ bool_to_str(is_expanded(id)),
168
+ bool_to_str(is_bold(id)),
169
+ get_children_count(id),
170
+ get_children_count(id, false))
242
171
  end
243
172
 
244
- Wx::BusyCursor.busy do
245
- icons = if @alternate_states
246
- [Wx::Icon.new(File.join(File.dirname(__FILE__), 'state1.xpm'), Wx::BITMAP_TYPE_XPM),
247
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'state2.xpm'), Wx::BITMAP_TYPE_XPM),
248
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'state3.xpm'), Wx::BITMAP_TYPE_XPM),
249
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'state4.xpm'), Wx::BITMAP_TYPE_XPM),
250
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'state5.xpm'), Wx::BITMAP_TYPE_XPM)]
251
-
252
- else
253
- [Wx::Icon.new(File.join(File.dirname(__FILE__), 'unchecked.xpm'), Wx::BITMAP_TYPE_XPM),
254
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'checked.xpm'), Wx::BITMAP_TYPE_XPM)]
255
- end
173
+ def bool_to_str(bool)
174
+ bool ? " " : "not "
175
+ end
256
176
 
257
- width = icons[0].width
258
- height = icons[0].height
177
+ def do_sort_children(item, reverse = false)
178
+ @reverse_sort = reverse
179
+ sort_children(item)
180
+ end
259
181
 
260
- # Make a state image list containing small icons
261
- states = Wx::ImageList.new(width, height, true)
182
+ def do_ensure_visible
183
+ ensure_visible(@last_item)
184
+ end
262
185
 
263
- icons.each { |ic| states.add(ic) }
186
+ def image_size
187
+ return @image_size
188
+ end
264
189
 
265
- self.state_image_list = states
190
+ def is_test_item(item)
191
+ # the test item is the first child folder
192
+ return item_parent(item) == root_item && !prev_sibling(item)
266
193
  end
267
- end
268
194
 
269
- def create_buttons_image_list(size)
270
- unless Wx::PLATFORM == 'WXMSW'
195
+ def create_image_list(size)
271
196
  if size < 0
272
- self.buttons_image_list = nil
197
+ unset_image_list
273
198
  return
199
+ elsif size == 0
200
+ size = @image_size
201
+ else
202
+ @image_size = size
274
203
  end
275
204
 
276
- # Make an image list containing small icons
277
- images = Wx::ImageList.new(size, size, true)
278
-
279
- # should correspond to TreeCtrlIcon_xxx enum
280
205
  Wx::BusyCursor.busy do
206
+ # should correspond to TreeCtrlIcon_xxx enum
281
207
  icons = if @alternate_images
282
- [Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
208
+ [Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon1.xpm'), Wx::BITMAP_TYPE_XPM),
209
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon2.xpm'), Wx::BITMAP_TYPE_XPM),
283
210
  Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
211
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon4.xpm'), Wx::BITMAP_TYPE_XPM),
284
212
  Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM),
285
- Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM)
286
213
  ]
287
214
  else
288
215
  icon_size = Wx::Size.new(@image_size, @image_size)
289
- ic1 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_LIST, icon_size)
290
- ic2 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER_OPEN, Wx::ART_LIST, icon_size)
291
- [ic1, ic1, ic2, ic2]
216
+ ic1 = Wx::ArtProvider::get_icon(Wx::ART_NORMAL_FILE, Wx::ART_LIST, icon_size)
217
+ ic2 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_LIST, icon_size)
218
+ [ic1, ic1, ic2, ic2, ic2]
292
219
  end
293
220
 
221
+ # Make an image list containing small icons
222
+ images = Wx::ImageList.new(@image_size, @image_size, true)
294
223
  icons.each do |ic|
295
- if ic.width == size
296
- images.add(ic)
297
- else
298
- resized = ic.convert_to_image.rescale(size, size)
299
- images.add(Wx::Bitmap.new(resized))
300
- end
224
+ orig_size = ic.get_width
225
+ ic = if @image_size == orig_size
226
+ ic
227
+ else
228
+ Wx::Bitmap.new(ic.convert_to_image.rescale(@image_size, @image_size))
229
+ end
230
+ images.add(ic)
301
231
  end
302
-
303
- self.buttons_image_list = images
232
+ self.image_list = images
304
233
  end
305
234
  end
306
- end
307
235
 
308
- def on_compare_items(item1, item2)
309
- if @reverse_sort
310
- # just exchange 1st and 2nd items
311
- return super(item2, item1)
312
- else
313
- return super(item1, item2)
236
+ def unset_image_list
237
+ self.image_list = nil
314
238
  end
315
- end
316
239
 
317
- def add_items_recursively(parent_id, num_children, depth, folder)
318
- if depth > 0
319
- has_children = depth > 1
240
+ def create_state_imageList(del = false)
241
+ if del
242
+ self.state_image_list = nil
243
+ return
244
+ end
320
245
 
321
- (0...num_children).each do |n|
322
- # at depth 1 elements won't have any more children
323
- if has_children
324
- str = "Folder child #{n + 1}"
325
- else
326
- str = "File child #{folder}.#{n + 1}"
327
- end
328
- # here we pass to append_item normal and selected item images (we
329
- # suppose that selected image follows the normal one in the enum)
330
- if Wx::THE_APP.show_images
331
- image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder
332
- imageSel = image + 1
333
- else
334
- image = imageSel = -1
335
- end
336
- id = append_item(parent_id, str, image, imageSel)
246
+ Wx::BusyCursor.busy do
247
+ icons = if @alternate_states
248
+ [Wx::Icon.new(File.join(File.dirname(__FILE__), 'state1.xpm'), Wx::BITMAP_TYPE_XPM),
249
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'state2.xpm'), Wx::BITMAP_TYPE_XPM),
250
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'state3.xpm'), Wx::BITMAP_TYPE_XPM),
251
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'state4.xpm'), Wx::BITMAP_TYPE_XPM),
252
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'state5.xpm'), Wx::BITMAP_TYPE_XPM)]
337
253
 
338
- set_item_state(id, 0) if Wx::THE_APP.show_states
254
+ else
255
+ [Wx::Icon.new(File.join(File.dirname(__FILE__), 'unchecked.xpm'), Wx::BITMAP_TYPE_XPM),
256
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'checked.xpm'), Wx::BITMAP_TYPE_XPM)]
257
+ end
339
258
 
340
- # and now we also set the expanded one (only for the folders)
341
- if has_children && Wx::get_app.show_images
342
- set_item_image(id, TreeCtrlIcon_FolderOpened, Wx::TreeItemIcon_Expanded)
343
- end
259
+ width = icons[0].width
260
+ height = icons[0].height
344
261
 
345
- # remember the last child for OnEnsureVisible()
346
- if !has_children && n == num_children - 1
347
- @last_item = id
348
- end
262
+ # Make a state image list containing small icons
263
+ states = Wx::ImageList.new(width, height, true)
264
+
265
+ icons.each { |ic| states.add(ic) }
349
266
 
350
- add_items_recursively(id, num_children, depth - 1, n + 1)
267
+ self.state_image_list = states
351
268
  end
352
269
  end
353
- end
354
270
 
355
- def add_test_items_to_tree(num_children, depth)
356
- image = Wx::THE_APP.show_images ? TreeCtrlIcon_Folder : -1
357
- root_id = add_root("Root", image, image, 'Root item')
358
- if !self.has_flag(Wx::TR_HIDE_ROOT) && image != -1
359
- set_item_image(root_id, TreeCtrlIcon_FolderOpened, Wx::TreeItemIcon_Expanded)
360
- end
271
+ def create_buttons_image_list(size)
272
+ unless Wx::PLATFORM == 'WXMSW'
273
+ if size < 0
274
+ self.buttons_image_list = nil
275
+ return
276
+ end
361
277
 
362
- add_items_recursively(root_id, num_children, depth, 0)
278
+ # Make an image list containing small icons
279
+ images = Wx::ImageList.new(size, size, true)
280
+
281
+ # should correspond to TreeCtrlIcon_xxx enum
282
+ Wx::BusyCursor.busy do
283
+ icons = if @alternate_images
284
+ [Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
285
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon3.xpm'), Wx::BITMAP_TYPE_XPM),
286
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM),
287
+ Wx::Icon.new(File.join(File.dirname(__FILE__), 'icon5.xpm'), Wx::BITMAP_TYPE_XPM)
288
+ ]
289
+ else
290
+ icon_size = Wx::Size.new(@image_size, @image_size)
291
+ ic1 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER, Wx::ART_LIST, icon_size)
292
+ ic2 = Wx::ArtProvider::get_icon(Wx::ART_FOLDER_OPEN, Wx::ART_LIST, icon_size)
293
+ [ic1, ic1, ic2, ic2]
294
+ end
295
+
296
+ icons.each do |ic|
297
+ if ic.width == size
298
+ images.add(ic)
299
+ else
300
+ resized = ic.convert_to_image.rescale(size, size)
301
+ images.add(Wx::Bitmap.new(resized))
302
+ end
303
+ end
363
304
 
364
- # set some colours/fonts for testing
365
- # note that font sizes can also be varied, but only on platforms
366
- # that use the generic TreeCtrl - OS X and GTK, and only if
367
- # Wx::TR_HAS_VARIABLE_ROW_HEIGHT style was used in the constructor
368
- if !self.has_flag(Wx::TR_HIDE_ROOT)
369
- set_item_font(root_id, Wx::ITALIC_FONT)
305
+ self.buttons_image_list = images
306
+ end
307
+ end
370
308
  end
371
309
 
372
- ids = get_item_children(root_id)
310
+ def on_compare_items(item1, item2)
311
+ if @reverse_sort
312
+ # just exchange 1st and 2nd items
313
+ return super(item2, item1)
314
+ else
315
+ return super(item1, item2)
316
+ end
317
+ end
373
318
 
374
- # make the first item blue
375
- set_item_text_colour(ids[0], Wx::BLUE)
319
+ def add_items_recursively(parent_id, num_children, depth, folder)
320
+ if depth > 0
321
+ has_children = depth > 1
376
322
 
377
- # make the third item red on grey
378
- set_item_text_colour(ids[2], Wx::RED)
379
- set_item_background_colour(ids[2], Wx::LIGHT_GREY)
380
- end
323
+ (0...num_children).each do |n|
324
+ # at depth 1 elements won't have any more children
325
+ if has_children
326
+ str = "Folder child #{n + 1}"
327
+ else
328
+ str = "File child #{folder}.#{n + 1}"
329
+ end
330
+ # here we pass to append_item normal and selected item images (we
331
+ # suppose that selected image follows the normal one in the enum)
332
+ if Wx::THE_APP.show_images
333
+ image = depth == 1 ? TreeCtrlIcon_File : TreeCtrlIcon_Folder
334
+ imageSel = image + 1
335
+ else
336
+ image = imageSel = -1
337
+ end
338
+ id = append_item(parent_id, str, image, imageSel)
381
339
 
382
- def get_last_tree_item
383
- item = self.root_item
384
- while item.ok?
385
- itemChild = get_last_child(item)
386
- break unless itemChild.ok?
340
+ set_item_state(id, 0) if Wx::THE_APP.show_states
387
341
 
388
- item = itemChild
389
- end
342
+ # and now we also set the expanded one (only for the folders)
343
+ if has_children && Wx::get_app.show_images
344
+ set_item_image(id, TreeCtrlIcon_FolderOpened, Wx::TreeItemIcon_Expanded)
345
+ end
390
346
 
391
- item
392
- end
393
- alias :last_tree_item :get_last_tree_item
347
+ # remember the last child for OnEnsureVisible()
348
+ if !has_children && n == num_children - 1
349
+ @last_item = id
350
+ end
394
351
 
395
- def get_items_recursively(parent_id, cookie)
396
- if cookie == -1
397
- id, cookie = get_first_child(parent_id)
398
- else
399
- id, cookie = get_next_child(parent_id, cookie)
400
- end
401
- unless id.ok?
402
- return nil
352
+ add_items_recursively(id, num_children, depth - 1, n + 1)
353
+ end
354
+ end
403
355
  end
404
356
 
405
- text = item_text(id)
406
- Wx::log_message(text)
357
+ def add_test_items_to_tree(num_children, depth)
358
+ image = Wx::THE_APP.show_images ? TreeCtrlIcon_Folder : -1
359
+ root_id = add_root("Root", image, image, 'Root item')
360
+ if !self.has_flag(Wx::TR_HIDE_ROOT) && image != -1
361
+ set_item_image(root_id, TreeCtrlIcon_FolderOpened, Wx::TreeItemIcon_Expanded)
362
+ end
407
363
 
408
- if item_has_children(id)
409
- get_items_recursively(id, -1)
410
- end
411
- get_items_recursively(parent_id, cookie)
412
- end
364
+ add_items_recursively(root_id, num_children, depth, 0)
413
365
 
414
- def do_toggle_icon(item)
415
- old_img = get_item_image(item)
416
- if old_img == TreeCtrlIcon_Folder
417
- new_img = TreeCtrlIcon_File
418
- else
419
- new_img = TreeCtrlIcon_Folder
420
- end
366
+ # set some colours/fonts for testing
367
+ # note that font sizes can also be varied, but only on platforms
368
+ # that use the generic TreeCtrl - OS X and GTK, and only if
369
+ # Wx::TR_HAS_VARIABLE_ROW_HEIGHT style was used in the constructor
370
+ if !self.has_flag(Wx::TR_HIDE_ROOT)
371
+ set_item_font(root_id, Wx::ITALIC_FONT)
372
+ end
421
373
 
422
- set_item_image(item, new_img, Wx::TreeItemIcon_Normal)
374
+ ids = get_item_children(root_id)
423
375
 
424
- old_img = get_item_image(item, Wx::TreeItemIcon_Selected)
425
- if old_img == TreeCtrlIcon_Folder
426
- new_img = TreeCtrlIcon_File
427
- else
428
- new_img = TreeCtrlIcon_Folder
429
- end
376
+ # make the first item blue
377
+ set_item_text_colour(ids[0], Wx::BLUE)
430
378
 
431
- set_item_image(item, new_img, Wx::TreeItemIcon_Selected)
432
- end
379
+ # make the third item red on grey
380
+ set_item_text_colour(ids[2], Wx::RED)
381
+ set_item_background_colour(ids[2], Wx::LIGHT_GREY)
382
+ end
433
383
 
434
- def do_toggle_state(item)
435
- if @alternate_states
436
- # sets random state unlike current
437
- nState = state = get_item_state(item)
384
+ def get_last_tree_item
385
+ item = self.root_item
386
+ while item.ok?
387
+ itemChild = get_last_child(item)
388
+ break unless itemChild.ok?
438
389
 
439
- nimg = state_image_list.image_count
440
- nState = (rand(::Time.now.to_i) % nimg) until nState != state
390
+ item = itemChild
391
+ end
441
392
 
442
- set_item_state(item, nState)
443
- else
444
- # we have only 2 checkbox states, so next state will be reversed
445
- set_item_state(item, Wx::TREE_ITEMSTATE_NEXT)
393
+ item
446
394
  end
447
- end
395
+ alias :last_tree_item :get_last_tree_item
448
396
 
449
- def on_begin_rdrag(event)
450
- Wx::log_message("OnBeginRDrag")
451
- event.skip
452
- end
397
+ def get_items_recursively(parent_id, cookie)
398
+ if cookie == -1
399
+ id, cookie = get_first_child(parent_id)
400
+ else
401
+ id, cookie = get_next_child(parent_id, cookie)
402
+ end
403
+ unless id.ok?
404
+ return nil
405
+ end
453
406
 
454
- def on_delete_item(event)
455
- Wx::log_message("OnDeleteItem")
456
- event.skip
457
- end
407
+ text = item_text(id)
408
+ Wx::log_message(text)
458
409
 
459
- def on_get_info(event)
460
- Wx::log_message("OnGetInfo")
461
- event.skip
462
- end
410
+ if item_has_children(id)
411
+ get_items_recursively(id, -1)
412
+ end
413
+ get_items_recursively(parent_id, cookie)
414
+ end
463
415
 
464
- def on_set_info(event)
465
- Wx::log_message("OnSetInfo")
466
- event.skip
467
- end
416
+ def do_toggle_icon(item)
417
+ old_img = get_item_image(item)
418
+ if old_img == TreeCtrlIcon_Folder
419
+ new_img = TreeCtrlIcon_File
420
+ else
421
+ new_img = TreeCtrlIcon_Folder
422
+ end
468
423
 
469
- def on_item_expanded(event)
470
- Wx::log_message("OnItemExpanded")
471
- event.skip
472
- end
424
+ set_item_image(item, new_img, Wx::TreeItemIcon_Normal)
473
425
 
474
- def on_item_expanding(event)
475
- Wx::log_message("OnItemExpanding")
476
- event.skip
477
- end
426
+ old_img = get_item_image(item, Wx::TreeItemIcon_Selected)
427
+ if old_img == TreeCtrlIcon_Folder
428
+ new_img = TreeCtrlIcon_File
429
+ else
430
+ new_img = TreeCtrlIcon_Folder
431
+ end
478
432
 
479
- def on_item_collapsed(event)
480
- Wx::log_message("OnItemCollapsed")
481
- event.skip
482
- end
433
+ set_item_image(item, new_img, Wx::TreeItemIcon_Selected)
434
+ end
483
435
 
484
- def on_sel_changed(event)
485
- Wx::log_message("OnSelChanged")
486
- event.skip
487
- end
436
+ def do_toggle_state(item)
437
+ if @alternate_states
438
+ # sets random state unlike current
439
+ nState = state = get_item_state(item)
488
440
 
489
- def on_sel_changing(event)
490
- Wx::log_message("OnSelChanging")
491
- event.skip
492
- end
441
+ nimg = state_image_list.image_count
442
+ nState = (rand(::Time.now.to_i) % nimg) until nState != state
493
443
 
494
- def log_key_event(name, event)
495
- keycode = event.key_code
496
-
497
- case keycode
498
- when Wx::K_BACK
499
- key = "BACK"
500
- when Wx::K_TAB
501
- key = "TAB"
502
- when Wx::K_RETURN
503
- key = "RETURN"
504
- when Wx::K_ESCAPE
505
- key = "ESCAPE"
506
- when Wx::K_SPACE
507
- key = "SPACE"
508
- when Wx::K_DELETE
509
- key = "DELETE"
510
- when Wx::K_START
511
- key = "START"
512
- when Wx::K_LBUTTON
513
- key = "LBUTTON"
514
- when Wx::K_RBUTTON
515
- key = "RBUTTON"
516
- when Wx::K_CANCEL
517
- key = "CANCEL"
518
- when Wx::K_MBUTTON
519
- key = "MBUTTON"
520
- when Wx::K_CLEAR
521
- key = "CLEAR"
522
- when Wx::K_SHIFT
523
- key = "SHIFT"
524
- when Wx::K_ALT
525
- key = "ALT"
526
- when Wx::K_CONTROL
527
- key = "CONTROL"
528
- when Wx::K_MENU
529
- key = "MENU"
530
- when Wx::K_PAUSE
531
- key = "PAUSE"
532
- when Wx::K_CAPITAL
533
- key = "CAPITAL"
534
- when Wx::K_END
535
- key = "END"
536
- when Wx::K_HOME
537
- key = "HOME"
538
- when Wx::K_LEFT
539
- key = "LEFT"
540
- when Wx::K_UP
541
- key = "UP"
542
- when Wx::K_RIGHT
543
- key = "RIGHT"
544
- when Wx::K_DOWN
545
- key = "DOWN"
546
- when Wx::K_SELECT
547
- key = "SELECT"
548
- when Wx::K_PRINT
549
- key = "PRINT"
550
- when Wx::K_EXECUTE
551
- key = "EXECUTE"
552
- when Wx::K_SNAPSHOT
553
- key = "SNAPSHOT"
554
- when Wx::K_INSERT
555
- key = "INSERT"
556
- when Wx::K_HELP
557
- key = "HELP"
558
- when Wx::K_NUMPAD0
559
- key = "NUMPAD0"
560
- when Wx::K_NUMPAD1
561
- key = "NUMPAD1"
562
- when Wx::K_NUMPAD2
563
- key = "NUMPAD2"
564
- when Wx::K_NUMPAD3
565
- key = "NUMPAD3"
566
- when Wx::K_NUMPAD4
567
- key = "NUMPAD4"
568
- when Wx::K_NUMPAD5
569
- key = "NUMPAD5"
570
- when Wx::K_NUMPAD6
571
- key = "NUMPAD6"
572
- when Wx::K_NUMPAD7
573
- key = "NUMPAD7"
574
- when Wx::K_NUMPAD8
575
- key = "NUMPAD8"
576
- when Wx::K_NUMPAD9
577
- key = "NUMPAD9"
578
- when Wx::K_MULTIPLY
579
- key = "MULTIPLY"
580
- when Wx::K_ADD
581
- key = "ADD"
582
- when Wx::K_SEPARATOR
583
- key = "SEPARATOR"
584
- when Wx::K_SUBTRACT
585
- key = "SUBTRACT"
586
- when Wx::K_DECIMAL
587
- key = "DECIMAL"
588
- when Wx::K_DIVIDE
589
- key = "DIVIDE"
590
- when Wx::K_F1
591
- key = "F1"
592
- when Wx::K_F2
593
- key = "F2"
594
- when Wx::K_F3
595
- key = "F3"
596
- when Wx::K_F4
597
- key = "F4"
598
- when Wx::K_F5
599
- key = "F5"
600
- when Wx::K_F6
601
- key = "F6"
602
- when Wx::K_F7
603
- key = "F7"
604
- when Wx::K_F8
605
- key = "F8"
606
- when Wx::K_F9
607
- key = "F9"
608
- when Wx::K_F10
609
- key = "F10"
610
- when Wx::K_F11
611
- key = "F11"
612
- when Wx::K_F12
613
- key = "F12"
614
- when Wx::K_F13
615
- key = "F13"
616
- when Wx::K_F14
617
- key = "F14"
618
- when Wx::K_F15
619
- key = "F15"
620
- when Wx::K_F16
621
- key = "F16"
622
- when Wx::K_F17
623
- key = "F17"
624
- when Wx::K_F18
625
- key = "F18"
626
- when Wx::K_F19
627
- key = "F19"
628
- when Wx::K_F20
629
- key = "F20"
630
- when Wx::K_F21
631
- key = "F21"
632
- when Wx::K_F22
633
- key = "F22"
634
- when Wx::K_F23
635
- key = "F23"
636
- when Wx::K_F24
637
- key = "F24"
638
- when Wx::K_NUMLOCK
639
- key = "NUMLOCK"
640
- when Wx::K_SCROLL
641
- key = "SCROLL"
642
- when Wx::K_PAGEUP
643
- key = "PAGEUP"
644
- when Wx::K_PAGEDOWN
645
- key = "PAGEDOWN"
646
- when Wx::K_NUMPAD_SPACE
647
- key = "NUMPAD_SPACE"
648
- when Wx::K_NUMPAD_TAB
649
- key = "NUMPAD_TAB"
650
- when Wx::K_NUMPAD_ENTER
651
- key = "NUMPAD_ENTER"
652
- when Wx::K_NUMPAD_F1
653
- key = "NUMPAD_F1"
654
- when Wx::K_NUMPAD_F2
655
- key = "NUMPAD_F2"
656
- when Wx::K_NUMPAD_F3
657
- key = "NUMPAD_F3"
658
- when Wx::K_NUMPAD_F4
659
- key = "NUMPAD_F4"
660
- when Wx::K_NUMPAD_HOME
661
- key = "NUMPAD_HOME"
662
- when Wx::K_NUMPAD_LEFT
663
- key = "NUMPAD_LEFT"
664
- when Wx::K_NUMPAD_UP
665
- key = "NUMPAD_UP"
666
- when Wx::K_NUMPAD_RIGHT
667
- key = "NUMPAD_RIGHT"
668
- when Wx::K_NUMPAD_DOWN
669
- key = "NUMPAD_DOWN"
670
- when Wx::K_NUMPAD_PAGEUP
671
- key = "NUMPAD_PAGEUP"
672
- when Wx::K_NUMPAD_PAGEDOWN
673
- key = "NUMPAD_PAGEDOWN"
674
- when Wx::K_NUMPAD_END
675
- key = "NUMPAD_END"
676
- when Wx::K_NUMPAD_BEGIN
677
- key = "NUMPAD_BEGIN"
678
- when Wx::K_NUMPAD_INSERT
679
- key = "NUMPAD_INSERT"
680
- when Wx::K_NUMPAD_DELETE
681
- key = "NUMPAD_DELETE"
682
- when Wx::K_NUMPAD_EQUAL
683
- key = "NUMPAD_EQUAL"
684
- when Wx::K_NUMPAD_MULTIPLY
685
- key = "NUMPAD_MULTIPLY"
686
- when Wx::K_NUMPAD_ADD
687
- key = "NUMPAD_ADD"
688
- when Wx::K_NUMPAD_SEPARATOR
689
- key = "NUMPAD_SEPARATOR"
690
- when Wx::K_NUMPAD_SUBTRACT
691
- key = "NUMPAD_SUBTRACT"
692
- when Wx::K_NUMPAD_DECIMAL
693
- key = "NUMPAD_DECIMAL"
694
- when Wx::K_BROWSER_BACK
695
- key = "BROWSER_BACK"
696
- when Wx::K_BROWSER_FORWARD
697
- key = "BROWSER_FORWARD"
698
- when Wx::K_BROWSER_REFRESH
699
- key = "BROWSER_REFRESH"
700
- when Wx::K_BROWSER_STOP
701
- key = "BROWSER_STOP"
702
- when Wx::K_BROWSER_SEARCH
703
- key = "BROWSER_SEARCH"
704
- when Wx::K_BROWSER_FAVORITES
705
- key = "BROWSER_FAVORITES"
706
- when Wx::K_BROWSER_HOME
707
- key = "BROWSER_HOME"
708
- when Wx::K_VOLUME_MUTE
709
- key = "VOLUME_MUTE"
710
- when Wx::K_VOLUME_DOWN
711
- key = "VOLUME_DOWN"
712
- when Wx::K_VOLUME_UP
713
- key = "VOLUME_UP"
714
- when Wx::K_MEDIA_NEXT_TRACK
715
- key = "MEDIA_NEXT_TRACK"
716
- when Wx::K_MEDIA_PREV_TRACK
717
- key = "MEDIA_PREV_TRACK"
718
- when Wx::K_MEDIA_STOP
719
- key = "MEDIA_STOP"
720
- when Wx::K_MEDIA_PLAY_PAUSE
721
- key = "MEDIA_PLAY_PAUSE"
722
- when Wx::K_LAUNCH_MAIL
723
- key = "LAUNCH_MAIL"
724
- when Wx::K_LAUNCH_APP1
725
- key = "LAUNCH_APP1"
726
- when Wx::K_LAUNCH_APP2
727
- key = "LAUNCH_APP2"
728
- else
729
- if keycode >= 32 && keycode < 127
730
- key = "'#{keycode.chr}'"
731
- elsif keycode > 0 && keycode < 27
732
- key = "Ctrl-#{?A + keycode - 1}"
444
+ set_item_state(item, nState)
733
445
  else
734
- key = "unknown (#{keycode})"
446
+ # we have only 2 checkbox states, so next state will be reversed
447
+ set_item_state(item, Wx::TREE_ITEMSTATE_NEXT)
735
448
  end
736
449
  end
737
450
 
738
- Wx::log_message("#{name} event: #{key} (flags = %s%s%s%s)" %
739
- [event.control_down ? 'C' : '-',
740
- event.alt_down ? 'A' : '-',
741
- event.shift_down ? 'S' : '-',
742
- event.meta_down ? 'M' : '-'])
743
- end
744
-
745
- def on_tree_key_down(event)
746
- log_key_event("Tree key down ", event.key_event)
747
- event.skip
748
- end
451
+ def on_begin_rdrag(event)
452
+ Wx::log_message("OnBeginRDrag")
453
+ event.skip
454
+ end
749
455
 
750
- def on_begin_drag(event)
751
- # need to explicitly allow drag
752
- if event.item != root_item
753
- @dragged_item = event.item
456
+ def on_delete_item(event)
457
+ Wx::log_message("OnDeleteItem")
458
+ event.skip
459
+ end
754
460
 
755
- clientpt = event.point
756
- screenpt = client_to_screen(clientpt)
757
- Wx::log_message("OnBeginDrag: started dragging %s at screen coords (%i,%i)" %
758
- [item_text(@dragged_item), screenpt.x, screenpt.y])
759
- event.allow
760
- else
761
- Wx::log_message("OnBeginDrag: selected item can't be dragged.")
461
+ def on_get_info(event)
462
+ Wx::log_message("OnGetInfo")
463
+ event.skip
762
464
  end
763
- end
764
465
 
765
- def on_end_drag(event)
766
- src_item = @dragged_item
767
- dest_item = event.item
768
- @dragged_item = nil
466
+ def on_set_info(event)
467
+ Wx::log_message("OnSetInfo")
468
+ event.skip
469
+ end
769
470
 
770
- if dest_item.ok? && !item_has_children(dest_item)
771
- # copy to the parent then
772
- dest_item = get_item_parent(dest_item)
471
+ def on_item_expanded(event)
472
+ Wx::log_message("OnItemExpanded")
473
+ event.skip
773
474
  end
774
475
 
775
- unless dest_item.ok?
776
- Wx::log_message("OnEndDrag: can't drop here.")
777
- return nil
476
+ def on_item_expanding(event)
477
+ Wx::log_message("OnItemExpanding")
478
+ event.skip
778
479
  end
779
480
 
780
- text = item_text(src_item)
781
- Wx::log_message("OnEndDrag: '%s' copied to '%s'.",
782
- text, item_text(dest_item))
481
+ def on_item_collapsed(event)
482
+ Wx::log_message("OnItemCollapsed")
483
+ event.skip
484
+ end
783
485
 
784
- # just do append here - we could also insert it just before/after the item
785
- # on which it was dropped, but self requires slightly more work... we also
786
- # completely ignore the client data and icon of the old item but could
787
- # copy them as well.
788
- #
789
- # Finally, we only copy one item here but we might copy the entire tree if
790
- # we were dragging a folder.
791
- image = Wx::THE_APP.show_images ? TreeCtrlIcon_File : -1
792
- new_id = append_item(dest_item, text, image)
486
+ def on_sel_changed(event)
487
+ Wx::log_message("OnSelChanged")
488
+ event.skip
489
+ end
793
490
 
794
- set_item_state(new_id, get_item_state(src_item)) if Wx::THE_APP.show_states
795
- end
491
+ def on_sel_changing(event)
492
+ Wx::log_message("OnSelChanging")
493
+ event.skip
494
+ end
796
495
 
797
- def on_begin_label_edit(event)
798
- Wx::log_message("OnBeginLabelEdit")
496
+ def log_key_event(name, event)
497
+ keycode = event.key_code
498
+
499
+ case keycode
500
+ when Wx::K_BACK
501
+ key = "BACK"
502
+ when Wx::K_TAB
503
+ key = "TAB"
504
+ when Wx::K_RETURN
505
+ key = "RETURN"
506
+ when Wx::K_ESCAPE
507
+ key = "ESCAPE"
508
+ when Wx::K_SPACE
509
+ key = "SPACE"
510
+ when Wx::K_DELETE
511
+ key = "DELETE"
512
+ when Wx::K_START
513
+ key = "START"
514
+ when Wx::K_LBUTTON
515
+ key = "LBUTTON"
516
+ when Wx::K_RBUTTON
517
+ key = "RBUTTON"
518
+ when Wx::K_CANCEL
519
+ key = "CANCEL"
520
+ when Wx::K_MBUTTON
521
+ key = "MBUTTON"
522
+ when Wx::K_CLEAR
523
+ key = "CLEAR"
524
+ when Wx::K_SHIFT
525
+ key = "SHIFT"
526
+ when Wx::K_ALT
527
+ key = "ALT"
528
+ when Wx::K_CONTROL
529
+ key = "CONTROL"
530
+ when Wx::K_MENU
531
+ key = "MENU"
532
+ when Wx::K_PAUSE
533
+ key = "PAUSE"
534
+ when Wx::K_CAPITAL
535
+ key = "CAPITAL"
536
+ when Wx::K_END
537
+ key = "END"
538
+ when Wx::K_HOME
539
+ key = "HOME"
540
+ when Wx::K_LEFT
541
+ key = "LEFT"
542
+ when Wx::K_UP
543
+ key = "UP"
544
+ when Wx::K_RIGHT
545
+ key = "RIGHT"
546
+ when Wx::K_DOWN
547
+ key = "DOWN"
548
+ when Wx::K_SELECT
549
+ key = "SELECT"
550
+ when Wx::K_PRINT
551
+ key = "PRINT"
552
+ when Wx::K_EXECUTE
553
+ key = "EXECUTE"
554
+ when Wx::K_SNAPSHOT
555
+ key = "SNAPSHOT"
556
+ when Wx::K_INSERT
557
+ key = "INSERT"
558
+ when Wx::K_HELP
559
+ key = "HELP"
560
+ when Wx::K_NUMPAD0
561
+ key = "NUMPAD0"
562
+ when Wx::K_NUMPAD1
563
+ key = "NUMPAD1"
564
+ when Wx::K_NUMPAD2
565
+ key = "NUMPAD2"
566
+ when Wx::K_NUMPAD3
567
+ key = "NUMPAD3"
568
+ when Wx::K_NUMPAD4
569
+ key = "NUMPAD4"
570
+ when Wx::K_NUMPAD5
571
+ key = "NUMPAD5"
572
+ when Wx::K_NUMPAD6
573
+ key = "NUMPAD6"
574
+ when Wx::K_NUMPAD7
575
+ key = "NUMPAD7"
576
+ when Wx::K_NUMPAD8
577
+ key = "NUMPAD8"
578
+ when Wx::K_NUMPAD9
579
+ key = "NUMPAD9"
580
+ when Wx::K_MULTIPLY
581
+ key = "MULTIPLY"
582
+ when Wx::K_ADD
583
+ key = "ADD"
584
+ when Wx::K_SEPARATOR
585
+ key = "SEPARATOR"
586
+ when Wx::K_SUBTRACT
587
+ key = "SUBTRACT"
588
+ when Wx::K_DECIMAL
589
+ key = "DECIMAL"
590
+ when Wx::K_DIVIDE
591
+ key = "DIVIDE"
592
+ when Wx::K_F1
593
+ key = "F1"
594
+ when Wx::K_F2
595
+ key = "F2"
596
+ when Wx::K_F3
597
+ key = "F3"
598
+ when Wx::K_F4
599
+ key = "F4"
600
+ when Wx::K_F5
601
+ key = "F5"
602
+ when Wx::K_F6
603
+ key = "F6"
604
+ when Wx::K_F7
605
+ key = "F7"
606
+ when Wx::K_F8
607
+ key = "F8"
608
+ when Wx::K_F9
609
+ key = "F9"
610
+ when Wx::K_F10
611
+ key = "F10"
612
+ when Wx::K_F11
613
+ key = "F11"
614
+ when Wx::K_F12
615
+ key = "F12"
616
+ when Wx::K_F13
617
+ key = "F13"
618
+ when Wx::K_F14
619
+ key = "F14"
620
+ when Wx::K_F15
621
+ key = "F15"
622
+ when Wx::K_F16
623
+ key = "F16"
624
+ when Wx::K_F17
625
+ key = "F17"
626
+ when Wx::K_F18
627
+ key = "F18"
628
+ when Wx::K_F19
629
+ key = "F19"
630
+ when Wx::K_F20
631
+ key = "F20"
632
+ when Wx::K_F21
633
+ key = "F21"
634
+ when Wx::K_F22
635
+ key = "F22"
636
+ when Wx::K_F23
637
+ key = "F23"
638
+ when Wx::K_F24
639
+ key = "F24"
640
+ when Wx::K_NUMLOCK
641
+ key = "NUMLOCK"
642
+ when Wx::K_SCROLL
643
+ key = "SCROLL"
644
+ when Wx::K_PAGEUP
645
+ key = "PAGEUP"
646
+ when Wx::K_PAGEDOWN
647
+ key = "PAGEDOWN"
648
+ when Wx::K_NUMPAD_SPACE
649
+ key = "NUMPAD_SPACE"
650
+ when Wx::K_NUMPAD_TAB
651
+ key = "NUMPAD_TAB"
652
+ when Wx::K_NUMPAD_ENTER
653
+ key = "NUMPAD_ENTER"
654
+ when Wx::K_NUMPAD_F1
655
+ key = "NUMPAD_F1"
656
+ when Wx::K_NUMPAD_F2
657
+ key = "NUMPAD_F2"
658
+ when Wx::K_NUMPAD_F3
659
+ key = "NUMPAD_F3"
660
+ when Wx::K_NUMPAD_F4
661
+ key = "NUMPAD_F4"
662
+ when Wx::K_NUMPAD_HOME
663
+ key = "NUMPAD_HOME"
664
+ when Wx::K_NUMPAD_LEFT
665
+ key = "NUMPAD_LEFT"
666
+ when Wx::K_NUMPAD_UP
667
+ key = "NUMPAD_UP"
668
+ when Wx::K_NUMPAD_RIGHT
669
+ key = "NUMPAD_RIGHT"
670
+ when Wx::K_NUMPAD_DOWN
671
+ key = "NUMPAD_DOWN"
672
+ when Wx::K_NUMPAD_PAGEUP
673
+ key = "NUMPAD_PAGEUP"
674
+ when Wx::K_NUMPAD_PAGEDOWN
675
+ key = "NUMPAD_PAGEDOWN"
676
+ when Wx::K_NUMPAD_END
677
+ key = "NUMPAD_END"
678
+ when Wx::K_NUMPAD_BEGIN
679
+ key = "NUMPAD_BEGIN"
680
+ when Wx::K_NUMPAD_INSERT
681
+ key = "NUMPAD_INSERT"
682
+ when Wx::K_NUMPAD_DELETE
683
+ key = "NUMPAD_DELETE"
684
+ when Wx::K_NUMPAD_EQUAL
685
+ key = "NUMPAD_EQUAL"
686
+ when Wx::K_NUMPAD_MULTIPLY
687
+ key = "NUMPAD_MULTIPLY"
688
+ when Wx::K_NUMPAD_ADD
689
+ key = "NUMPAD_ADD"
690
+ when Wx::K_NUMPAD_SEPARATOR
691
+ key = "NUMPAD_SEPARATOR"
692
+ when Wx::K_NUMPAD_SUBTRACT
693
+ key = "NUMPAD_SUBTRACT"
694
+ when Wx::K_NUMPAD_DECIMAL
695
+ key = "NUMPAD_DECIMAL"
696
+ when Wx::K_BROWSER_BACK
697
+ key = "BROWSER_BACK"
698
+ when Wx::K_BROWSER_FORWARD
699
+ key = "BROWSER_FORWARD"
700
+ when Wx::K_BROWSER_REFRESH
701
+ key = "BROWSER_REFRESH"
702
+ when Wx::K_BROWSER_STOP
703
+ key = "BROWSER_STOP"
704
+ when Wx::K_BROWSER_SEARCH
705
+ key = "BROWSER_SEARCH"
706
+ when Wx::K_BROWSER_FAVORITES
707
+ key = "BROWSER_FAVORITES"
708
+ when Wx::K_BROWSER_HOME
709
+ key = "BROWSER_HOME"
710
+ when Wx::K_VOLUME_MUTE
711
+ key = "VOLUME_MUTE"
712
+ when Wx::K_VOLUME_DOWN
713
+ key = "VOLUME_DOWN"
714
+ when Wx::K_VOLUME_UP
715
+ key = "VOLUME_UP"
716
+ when Wx::K_MEDIA_NEXT_TRACK
717
+ key = "MEDIA_NEXT_TRACK"
718
+ when Wx::K_MEDIA_PREV_TRACK
719
+ key = "MEDIA_PREV_TRACK"
720
+ when Wx::K_MEDIA_STOP
721
+ key = "MEDIA_STOP"
722
+ when Wx::K_MEDIA_PLAY_PAUSE
723
+ key = "MEDIA_PLAY_PAUSE"
724
+ when Wx::K_LAUNCH_MAIL
725
+ key = "LAUNCH_MAIL"
726
+ when Wx::K_LAUNCH_APP1
727
+ key = "LAUNCH_APP1"
728
+ when Wx::K_LAUNCH_APP2
729
+ key = "LAUNCH_APP2"
730
+ else
731
+ if keycode >= 32 && keycode < 127
732
+ key = "'#{keycode.chr}'"
733
+ elsif keycode > 0 && keycode < 27
734
+ key = "Ctrl-#{?A + keycode - 1}"
735
+ else
736
+ key = "unknown (#{keycode})"
737
+ end
738
+ end
799
739
 
800
- # for testing, prevent self item's label editing
801
- item = event.item
802
- if is_test_item(item)
803
- Wx::message_box("The demo prevents you editing this item.")
804
- event.veto
805
- elsif item == self.root_item
806
- # test that it is possible to change the text of the item being edited
807
- set_item_text(item, "Editing root item")
740
+ Wx::log_message("#{name} event: #{key} (flags = %s%s%s%s)" %
741
+ [event.control_down ? 'C' : '-',
742
+ event.alt_down ? 'A' : '-',
743
+ event.shift_down ? 'S' : '-',
744
+ event.meta_down ? 'M' : '-'])
808
745
  end
809
- end
810
746
 
811
- def on_end_label_edit(event)
812
- Wx::log_message("OnEndLabelEdit")
813
- if event.edit_cancelled?
814
- Wx::log_message("Label edit was cancelled by user")
815
- return
747
+ def on_tree_key_down(event)
748
+ log_key_event("Tree key down ", event.key_event)
749
+ event.skip
816
750
  end
817
751
 
818
- # For a demo, don't allow anything except letters in the labels
819
- unless event.label =~ /^\w+/
820
- msg = "The new label should be a single word."
821
- Wx::message_box(msg)
822
- Wx::log_message("Label edit was cancelled by demo")
823
- event.veto
752
+ def on_begin_drag(event)
753
+ # need to explicitly allow drag
754
+ if event.item != root_item
755
+ @dragged_item = event.item
756
+
757
+ clientpt = event.point
758
+ screenpt = client_to_screen(clientpt)
759
+ Wx::log_message("OnBeginDrag: started dragging %s at screen coords (%i,%i)" %
760
+ [item_text(@dragged_item), screenpt.x, screenpt.y])
761
+ event.allow
762
+ else
763
+ Wx::log_message("OnBeginDrag: selected item can't be dragged.")
764
+ end
824
765
  end
825
- end
826
766
 
827
- def on_item_collapsing(event)
828
- Wx::log_message("OnItemCollapsing")
767
+ def on_end_drag(event)
768
+ src_item = @dragged_item
769
+ dest_item = event.item
770
+ @dragged_item = nil
829
771
 
830
- # for testing, prevent the user from collapsing the first child folder
831
- if is_test_item(event.item)
832
- Wx::message_box("You can't collapse self item.")
833
- event.veto
772
+ if dest_item.ok? && !item_has_children(dest_item)
773
+ # copy to the parent then
774
+ dest_item = get_item_parent(dest_item)
775
+ end
776
+
777
+ unless dest_item.ok?
778
+ Wx::log_message("OnEndDrag: can't drop here.")
779
+ return nil
780
+ end
781
+
782
+ text = item_text(src_item)
783
+ Wx::log_message("OnEndDrag: '%s' copied to '%s'.",
784
+ text, item_text(dest_item))
785
+
786
+ # just do append here - we could also insert it just before/after the item
787
+ # on which it was dropped, but self requires slightly more work... we also
788
+ # completely ignore the client data and icon of the old item but could
789
+ # copy them as well.
790
+ #
791
+ # Finally, we only copy one item here but we might copy the entire tree if
792
+ # we were dragging a folder.
793
+ image = Wx::THE_APP.show_images ? TreeCtrlIcon_File : -1
794
+ new_id = append_item(dest_item, text, image)
795
+
796
+ set_item_state(new_id, get_item_state(src_item)) if Wx::THE_APP.show_states
834
797
  end
835
- end
836
798
 
837
- # show some info about activated item
838
- def on_item_activated(event)
839
- if (item_id = event.item).ok?
840
- show_info(item_id)
799
+ def on_begin_label_edit(event)
800
+ Wx::log_message("OnBeginLabelEdit")
801
+
802
+ # for testing, prevent self item's label editing
803
+ item = event.item
804
+ if is_test_item(item)
805
+ Wx::message_box("The demo prevents you editing this item.")
806
+ event.veto
807
+ elsif item == self.root_item
808
+ # test that it is possible to change the text of the item being edited
809
+ set_item_text(item, "Editing root item")
810
+ end
841
811
  end
842
- Wx::log_message("OnItemActivated")
843
- end
844
812
 
845
- def on_item_state_clicked(event)
846
- if (item_id = event.item).ok?
847
- do_toggle_state(item_id)
813
+ def on_end_label_edit(event)
814
+ Wx::log_message("OnEndLabelEdit")
815
+ if event.edit_cancelled?
816
+ Wx::log_message("Label edit was cancelled by user")
817
+ return
818
+ end
819
+
820
+ # For a demo, don't allow anything except letters in the labels
821
+ unless event.label =~ /^\w+/
822
+ msg = "The new label should be a single word."
823
+ Wx::message_box(msg)
824
+ Wx::log_message("Label edit was cancelled by demo")
825
+ event.veto
826
+ end
848
827
  end
849
- Wx::log_message("Item \"#{get_item_text(item_id)}\" state changed to #{get_item_state(item_id)}")
850
- end
851
828
 
852
- def on_item_menu(event)
853
- return unless (item = event.item).ok?
829
+ def on_item_collapsing(event)
830
+ Wx::log_message("OnItemCollapsing")
854
831
 
855
- item_data = get_item_data(item)
856
- clientpt = event.get_point
857
- screenpt = client_to_screen(clientpt)
832
+ # for testing, prevent the user from collapsing the first child folder
833
+ if is_test_item(event.item)
834
+ Wx::message_box("You can't collapse self item.")
835
+ event.veto
836
+ end
837
+ end
858
838
 
859
- Wx::log_message(
860
- "OnItemMenu for item \"#{item_data ? item_data : 'unknown'}\" at screen coords (#{screenpt.x}, #{screenpt.y})")
839
+ # show some info about activated item
840
+ def on_item_activated(event)
841
+ if (item_id = event.item).ok?
842
+ show_info(item_id)
843
+ end
844
+ Wx::log_message("OnItemActivated")
845
+ end
861
846
 
862
- show_popup_menu(item, clientpt)
863
- end
847
+ def on_item_state_clicked(event)
848
+ if (item_id = event.item).ok?
849
+ do_toggle_state(item_id)
850
+ end
851
+ Wx::log_message("Item \"#{get_item_text(item_id)}\" state changed to #{get_item_state(item_id)}")
852
+ end
864
853
 
865
- def on_context_menu(event)
866
- pt = event.position
854
+ def on_item_menu(event)
855
+ return unless (item = event.item).ok?
867
856
 
868
- Wx::log_message("OnContextMenu at screen coords (#{pt.x}, #{pt.y})")
857
+ item_data = get_item_data(item)
858
+ clientpt = event.get_point
859
+ screenpt = client_to_screen(clientpt)
869
860
 
870
- event.skip
871
- end
861
+ Wx::log_message(
862
+ "OnItemMenu for item \"#{item_data ? item_data : 'unknown'}\" at screen coords (#{screenpt.x}, #{screenpt.y})")
872
863
 
873
- def show_popup_menu(id, pos)
874
- title = ""
875
- if id.ok?
876
- title << "Menu for " << get_item_text(id)
877
- else
878
- title = "Menu for no particular item"
864
+ show_popup_menu(item, clientpt)
879
865
  end
880
866
 
881
- menu = Wx::Menu.new(title)
882
- menu.append(Wx::ID_ABOUT, "&About...")
883
- menu.append_separator
884
- menu.append(TreeTest_Highlight, "&Highlight item")
885
- menu.append(TreeTest_Dump, "&Dump")
886
- popup_menu(menu, pos)
887
- end
888
-
889
- def on_rmouse_down(event)
890
- Wx::log_message("Right mouse button down")
867
+ def on_context_menu(event)
868
+ pt = event.position
891
869
 
892
- event.skip
893
- end
870
+ Wx::log_message("OnContextMenu at screen coords (#{pt.x}, #{pt.y})")
894
871
 
895
- def on_item_rclick(event)
896
- unless (itemId = event.item).ok?
897
- Wx::log_message("on_item_rclick: event should have a valid item")
898
- return
872
+ event.skip
899
873
  end
900
874
 
901
- item_data = get_item_data(itemId)
902
- Wx::log_message("Item \"#{item_data ? item_data : 'unknown'}\" right clicked")
875
+ def show_popup_menu(id, pos)
876
+ title = ""
877
+ if id.ok?
878
+ title << "Menu for " << get_item_text(id)
879
+ else
880
+ title = "Menu for no particular item"
881
+ end
903
882
 
904
- event.skip
905
- end
883
+ menu = Wx::Menu.new(title)
884
+ menu.append(Wx::ID_ABOUT, "&About...")
885
+ menu.append_separator
886
+ menu.append(TreeTest_Highlight, "&Highlight item")
887
+ menu.append(TreeTest_Dump, "&Dump")
888
+ popup_menu(menu, pos)
889
+ end
906
890
 
907
- def on_rmouse_up(event)
908
- Wx::log_message("Right mouse button up")
891
+ def on_rmouse_down(event)
892
+ Wx::log_message("Right mouse button down")
909
893
 
910
- event.skip
911
- end
894
+ event.skip
895
+ end
912
896
 
913
- def on_rmouse_dclick(event)
914
- id = hit_test(event.get_position)
915
- unless id.ok?
916
- Wx::log_message("No item under mouse")
917
- else
918
- item_data = get_item_data(id)
919
- if item_data
920
- Wx::log_message("Item '#{item_data}' under mouse")
897
+ def on_item_rclick(event)
898
+ unless (itemId = event.item).ok?
899
+ Wx::log_message("on_item_rclick: event should have a valid item")
900
+ return
921
901
  end
902
+
903
+ item_data = get_item_data(itemId)
904
+ Wx::log_message("Item \"#{item_data ? item_data : 'unknown'}\" right clicked")
905
+
906
+ event.skip
922
907
  end
923
- end
924
908
 
925
- end
909
+ def on_rmouse_up(event)
910
+ Wx::log_message("Right mouse button up")
926
911
 
927
- class MyFrame < Wx::Frame
928
- def initialize(title, x, y, w, h)
929
- super(nil, :title => title, :pos => [x, y], :size => [w, h])
930
- @panel = nil
931
- #@splitter = nil
932
- @treectrl = nil
933
- @textctrl = nil
934
- @s_num = 0
935
-
936
- # This reduces flicker effects - even better would be to define
937
- # OnEraseBackground to do nothing. When the tree control's scrollbars are
938
- # show or hidden, the frame is sent a background erase event.
939
- self.background_colour = Wx::WHITE
940
-
941
- # Give it an icon
942
- self.icon = Wx::Icon.new(File.join(File.dirname(__FILE__), '..', 'sample.xpm'), Wx::BITMAP_TYPE_XPM)
943
-
944
- # Make a menubar
945
- file_menu = Wx::Menu.new
946
- style_menu = Wx::Menu.new
947
- tree_menu = Wx::Menu.new
948
- item_menu = Wx::Menu.new
949
-
950
- file_menu.append(Wx::ID_CLEAR, "&Clear log\tCtrl-L");
951
- file_menu.append_separator
952
- file_menu.append(Wx::ID_ABOUT, "&About...")
953
- file_menu.append_separator
954
- file_menu.append(Wx::ID_EXIT, "E&xit\tAlt-X")
955
-
956
- style_menu.append(TreeTest_TogButtons,
957
- "Toggle &normal buttons", "", Wx::ITEM_CHECK)
958
- style_menu.append(TreeTest_TogTwist,
959
- "Toggle &twister buttons", "", Wx::ITEM_CHECK)
960
- style_menu.append(TreeTest_ToggleButtons,
961
- "Toggle image &buttons", "", Wx::ITEM_CHECK)
962
- style_menu.append_separator
963
- style_menu.append(TreeTest_TogLines,
964
- "Toggle &no lines", "", Wx::ITEM_CHECK)
965
- style_menu.append(TreeTest_TogRootLines,
966
- "Toggle &lines at root", "", Wx::ITEM_CHECK)
967
- style_menu.append(TreeTest_TogHideRoot,
968
- "Toggle &hidden root", "", Wx::ITEM_CHECK)
969
- style_menu.append(TreeTest_TogBorder,
970
- "Toggle &item border", "", Wx::ITEM_CHECK)
971
- style_menu.append(TreeTest_TogFullHighlight,
972
- "Toggle &full row highlight", "", Wx::ITEM_CHECK)
973
- style_menu.append(TreeTest_TogEdit,
974
- "Toggle &edit mode", "", Wx::ITEM_CHECK)
975
- style_menu.append(TreeTest_ToggleSel,
976
- "Toggle multiple &selection", "", Wx::ITEM_CHECK)
977
- style_menu.append(TreeTest_ToggleImages,
978
- "Toggle show ima&ges", "", Wx::ITEM_CHECK)
979
- style_menu.append(TreeTest_ToggleStates,
980
- "Toggle show st&ates", "", Wx::ITEM_CHECK)
981
- style_menu.append(TreeTest_ToggleBell,
982
- "Toggle &bell on no match", "", Wx::ITEM_CHECK)
983
- style_menu.append(TreeTest_ToggleAlternateImages,
984
- "Toggle alternate images", "", Wx::ITEM_CHECK)
985
- style_menu.append(TreeTest_ToggleAlternateStates,
986
- "Toggle alternate state images", "", Wx::ITEM_CHECK)
987
- style_menu.append(TreeTest_SetImageSize, "Set image si&ze...")
988
- style_menu.append_separator
989
- style_menu.append(TreeTest_SetFgColour, "Set &foreground colour...")
990
- style_menu.append(TreeTest_SetBgColour, "Set &background colour...")
991
- style_menu.append_separator
992
- style_menu.append(TreeTest_ResetStyle, "&Reset to default\tF10")
993
-
994
- tree_menu.append(TreeTest_FreezeThaw,
995
- "&Freeze the tree", "", Wx::ITEM_CHECK)
996
- tree_menu.append(TreeTest_Recreate, "&Recreate the tree")
997
- tree_menu.append(TreeTest_CollapseAndReset, "C&ollapse and reset")
998
- tree_menu.append_separator
999
- tree_menu.append(TreeTest_AddItem, "Append a &new item")
1000
- tree_menu.append(TreeTest_AddManyItems, "Appends &many items")
1001
- tree_menu.append(TreeTest_InsertItem, "&Insert a new item")
1002
- tree_menu.append(TreeTest_Delete, "&Delete selected item")
1003
- tree_menu.append(TreeTest_DeleteChildren, "Delete &children")
1004
- tree_menu.append(TreeTest_DeleteAll, "Delete &all items")
1005
- tree_menu.append(TreeTest_SelectRoot, "Select root item")
1006
- tree_menu.append_separator
1007
- tree_menu.append(TreeTest_SetFocusedRoot, "Set focus to root item")
1008
- tree_menu.append(TreeTest_ClearFocused, "Reset focus")
1009
-
1010
- tree_menu.append_separator
1011
- tree_menu.append(TreeTest_Count, "Count children of current item")
1012
- tree_menu.append(TreeTest_CountRec, "Recursively count children of current item")
1013
- tree_menu.append_separator
1014
- tree_menu.append(TreeTest_Sort, "Sort children of current item")
1015
- tree_menu.append(TreeTest_SortRev, "Sort in reversed order")
1016
- tree_menu.append_separator
1017
- tree_menu.append(TreeTest_EnsureVisible, "Make the last item &visible")
1018
- tree_menu.append(TreeTest_SetFocus, "Set &focus to the tree")
1019
- tree_menu.append_separator
1020
- tree_menu.append(TreeTest_IncIndent, "Add 5 points to indentation\tAlt-I")
1021
- tree_menu.append(TreeTest_DecIndent, "Reduce indentation by 5 points\tAlt-R")
1022
- tree_menu.append_separator
1023
- tree_menu.append(TreeTest_IncSpacing, "Add 5 points to spacing\tCtrl-I")
1024
- tree_menu.append(TreeTest_DecSpacing, "Reduce spacing by 5 points\tCtrl-R")
1025
-
1026
- item_menu.append(TreeTest_Dump, "&Dump item children")
1027
- item_menu.append(TreeTest_Rename, "&Rename item...")
1028
-
1029
- item_menu.append_separator
1030
- item_menu.append(TreeTest_SetBold, "Make item &bold")
1031
- item_menu.append(TreeTest_ClearBold, "Make item &not bold")
1032
- item_menu.append_separator
1033
- item_menu.append(TreeTest_ToggleIcon, "Toggle the item's &icon")
1034
- item_menu.append(TreeTest_ToggleState, "Toggle the item's &state")
1035
-
1036
- item_menu.append_separator
1037
- item_menu.append(TreeTest_ShowFirstVisible, "Show &first visible")
1038
- if Wx.has_feature?(:HAS_LAST_VISIBLE)
1039
- item_menu.append(TreeTest_ShowLastVisible, "Show &last visible")
1040
- end
1041
- item_menu.append(TreeTest_ShowNextVisible, "Show &next visible")
1042
- item_menu.append(TreeTest_ShowPrevVisible, "Show &previous visible")
1043
- item_menu.append_separator
1044
- item_menu.append(TreeTest_ShowParent, "Show pa&rent")
1045
- item_menu.append(TreeTest_ShowPrevSibling, "Show &previous sibling")
1046
- item_menu.append(TreeTest_ShowNextSibling, "Show &next sibling")
1047
- item_menu.append_separator
1048
- item_menu.append(TreeTest_ScrollTo, "Scroll &to item",
1049
- "Scroll to the last by one top level child")
1050
- item_menu.append(TreeTest_SelectLast, "Select &last item",
1051
- "Select the last item")
1052
-
1053
- item_menu.append_separator
1054
- item_menu.append(TreeTest_DumpSelected, "Dump selected items\tAlt-D")
1055
- item_menu.append(TreeTest_Select, "Select current item\tAlt-S")
1056
- item_menu.append(TreeTest_Unselect, "Unselect everything\tAlt-U")
1057
- item_menu.append(TreeTest_SelectChildren, "Select all children\tCtrl-A")
1058
-
1059
- menu_bar = Wx::MenuBar.new
1060
- menu_bar.append(file_menu, "&File")
1061
- menu_bar.append(style_menu, "&Style")
1062
- menu_bar.append(tree_menu, "&Tree")
1063
- menu_bar.append(item_menu, "&Item")
1064
- self.menu_bar = menu_bar
1065
-
1066
- @panel = Wx::Panel.new(self)
1067
-
1068
- # create the controls
1069
- @textctrl = Wx::TextCtrl.new(@panel,
1070
- :value => "Log text\n",
1071
- :style => Wx::TE_MULTILINE | Wx::SUNKEN_BORDER)
1072
-
1073
- create_tree_with_default_style
1074
-
1075
- menu_bar.check(TreeTest_ToggleImages, true)
1076
- menu_bar.check(TreeTest_ToggleStates, true)
1077
- menu_bar.check(TreeTest_ToggleAlternateImages, false)
1078
- menu_bar.check(TreeTest_ToggleAlternateStates, false)
1079
-
1080
- # create a status bar with 3 panes
1081
- create_status_bar(2)
1082
-
1083
- set_status_text("", 0)
1084
-
1085
- # set our text control as the log target
1086
- logWindow = Wx::LogTextCtrl.new(@textctrl)
1087
- @old_log_tgt = Wx::Log::set_active_target(logWindow)
1088
-
1089
- # @splitter.split_horizontally(@treectrl, @textctrl, 500)
1090
-
1091
- evt_close :on_close
1092
- evt_size :on_size
1093
- evt_idle :on_idle
1094
-
1095
- evt_menu Wx::ID_EXIT, :on_quit
1096
- evt_menu Wx::ID_ABOUT, :on_about
1097
- evt_menu Wx::ID_CLEAR, :on_clear_log
1098
-
1099
- evt_menu TreeTest_TogButtons, :on_tog_buttons
1100
- evt_menu TreeTest_TogTwist, :on_tog_twist
1101
- evt_menu TreeTest_TogLines, :on_tog_lines
1102
- evt_menu TreeTest_TogEdit, :on_tog_edit
1103
- evt_menu TreeTest_TogHideRoot, :on_tog_hide_root
1104
- evt_menu TreeTest_TogRootLines, :on_tog_root_lines
1105
- evt_menu TreeTest_TogBorder, :on_tog_border
1106
- evt_menu TreeTest_TogFullHighlight, :on_tog_full_highlight
1107
- evt_menu TreeTest_SetFgColour, :on_set_fg_colour
1108
- evt_menu TreeTest_SetBgColour, :on_set_bg_colour
1109
- evt_menu TreeTest_ResetStyle, :on_reset_style
1110
-
1111
- evt_menu TreeTest_Highlight, :on_highlight
1112
- evt_menu TreeTest_Dump, :on_dump
1113
- evt_menu TreeTest_DumpSelected, :on_dump_selected
1114
- evt_menu TreeTest_Select, :on_select
1115
- evt_menu TreeTest_Unselect, :on_unselect
1116
- evt_menu TreeTest_ToggleSel, :on_toggle_sel
1117
- evt_menu TreeTest_SelectChildren, :on_select_children
1118
- evt_menu TreeTest_Rename, :on_rename
1119
- evt_menu TreeTest_Count, :on_count
1120
- evt_menu TreeTest_CountRec, :on_count_rec
1121
- evt_menu TreeTest_Sort, :on_sort
1122
- evt_menu TreeTest_SortRev, :on_sort_rev
1123
- evt_menu TreeTest_SetBold, :on_set_bold
1124
- evt_menu TreeTest_ClearBold, :on_clear_bold
1125
- evt_menu TreeTest_Delete, :on_delete
1126
- evt_menu TreeTest_DeleteChildren, :on_delete_children
1127
- evt_menu TreeTest_DeleteAll, :on_delete_all
1128
- evt_menu TreeTest_Recreate, :on_recreate
1129
- evt_menu TreeTest_FreezeThaw, :on_freeze_thaw
1130
- evt_menu TreeTest_ToggleImages, :on_toggle_images
1131
- evt_menu TreeTest_ToggleStates, :on_toggle_states
1132
- evt_menu TreeTest_ToggleBell, :on_toggle_bell
1133
- evt_menu TreeTest_ToggleAlternateImages, :on_toggle_alternate_images
1134
- evt_menu TreeTest_ToggleAlternateStates, :on_toggle_alternate_states
1135
- unless Wx.has_feature?(:WXMSW)
1136
- evt_menu TreeTest_ToggleButtons, :on_toggle_buttons
1137
- end
1138
- evt_menu TreeTest_SetImageSize, :on_set_image_size
1139
- evt_menu TreeTest_CollapseAndReset, :on_collapse_and_reset
1140
- evt_menu TreeTest_EnsureVisible, :on_ensure_visible
1141
- evt_menu TreeTest_SetFocus, :on_set_focus
1142
- evt_menu TreeTest_AddItem, :on_add_item
1143
- evt_menu TreeTest_AddManyItems, :on_add_many_items
1144
- evt_menu TreeTest_InsertItem, :on_insert_item
1145
- evt_menu TreeTest_IncIndent, :on_inc_indent
1146
- evt_menu TreeTest_DecIndent, :on_dec_indent
1147
- evt_menu TreeTest_IncSpacing, :on_inc_spacing
1148
- evt_menu TreeTest_DecSpacing, :on_dec_spacing
1149
- evt_menu TreeTest_ToggleIcon, :on_toggle_icon
1150
- evt_menu TreeTest_ToggleState, :on_toggle_state
1151
- evt_menu TreeTest_SelectRoot, :on_select_root
1152
- evt_menu TreeTest_SetFocusedRoot, :on_set_focused_root
1153
- evt_menu TreeTest_ClearFocused, :on_clear_focused
1154
-
1155
- evt_menu TreeTest_ShowFirstVisible, :on_show_first_visible
1156
- if Wx.has_feature?(:HAS_LAST_VISIBLE)
1157
- evt_menu TreeTest_ShowLastVisible, :on_show_last_visible
1158
- end
1159
- evt_menu TreeTest_ShowNextVisible, :on_show_next_visible
1160
- evt_menu TreeTest_ShowPrevVisible, :on_show_prev_visible
1161
- evt_menu TreeTest_ShowParent, :on_show_parent
1162
- evt_menu TreeTest_ShowPrevSibling, :on_show_prev_sibling
1163
- evt_menu TreeTest_ShowNextSibling, :on_show_next_sibling
1164
- evt_menu TreeTest_ScrollTo, :on_scroll_to
1165
- evt_menu TreeTest_SelectLast, :on_select_last
1166
- end
912
+ event.skip
913
+ end
914
+
915
+ def on_rmouse_dclick(event)
916
+ id = hit_test(event.get_position)
917
+ unless id.ok?
918
+ Wx::log_message("No item under mouse")
919
+ else
920
+ item_data = get_item_data(id)
921
+ if item_data
922
+ Wx::log_message("Item '#{item_data}' under mouse")
923
+ end
924
+ end
925
+ end
1167
926
 
1168
- def check_item(id)
1169
- Wx::message_box("Please select some item first!",
1170
- "Tree sample error",
1171
- Wx::OK | Wx::ICON_EXCLAMATION,
1172
- self) unless id && id.ok?
1173
- id && id.ok?
1174
927
  end
1175
928
 
1176
- def create_tree_with_default_style
929
+ class MyFrame < Wx::Frame
930
+ def initialize(title, x, y, w, h)
931
+ super(nil, :title => title, :pos => [x, y], :size => [w, h])
932
+ @panel = nil
933
+ #@splitter = nil
934
+ @treectrl = nil
935
+ @textctrl = nil
936
+ @s_num = 0
937
+
938
+ # This reduces flicker effects - even better would be to define
939
+ # OnEraseBackground to do nothing. When the tree control's scrollbars are
940
+ # show or hidden, the frame is sent a background erase event.
941
+ self.background_colour = Wx::WHITE
942
+
943
+ # Give it an icon
944
+ self.icon = Wx.Icon(:sample, Wx::BITMAP_TYPE_XPM, art_path: File.join(__dir__, '..'))
945
+
946
+ # Make a menubar
947
+ file_menu = Wx::Menu.new
948
+ style_menu = Wx::Menu.new
949
+ tree_menu = Wx::Menu.new
950
+ item_menu = Wx::Menu.new
951
+
952
+ file_menu.append(Wx::ID_CLEAR, "&Clear log\tCtrl-L");
953
+ file_menu.append_separator
954
+ file_menu.append(Wx::ID_ABOUT, "&About...")
955
+ file_menu.append_separator
956
+ file_menu.append(Wx::ID_EXIT, "E&xit\tAlt-X")
957
+
958
+ style_menu.append(TreeTest_TogButtons,
959
+ "Toggle &normal buttons", "", Wx::ITEM_CHECK)
960
+ style_menu.append(TreeTest_TogTwist,
961
+ "Toggle &twister buttons", "", Wx::ITEM_CHECK)
962
+ style_menu.append(TreeTest_ToggleButtons,
963
+ "Toggle image &buttons", "", Wx::ITEM_CHECK)
964
+ style_menu.append_separator
965
+ style_menu.append(TreeTest_TogLines,
966
+ "Toggle &no lines", "", Wx::ITEM_CHECK)
967
+ style_menu.append(TreeTest_TogRootLines,
968
+ "Toggle &lines at root", "", Wx::ITEM_CHECK)
969
+ style_menu.append(TreeTest_TogHideRoot,
970
+ "Toggle &hidden root", "", Wx::ITEM_CHECK)
971
+ style_menu.append(TreeTest_TogBorder,
972
+ "Toggle &item border", "", Wx::ITEM_CHECK)
973
+ style_menu.append(TreeTest_TogFullHighlight,
974
+ "Toggle &full row highlight", "", Wx::ITEM_CHECK)
975
+ style_menu.append(TreeTest_TogEdit,
976
+ "Toggle &edit mode", "", Wx::ITEM_CHECK)
977
+ style_menu.append(TreeTest_ToggleSel,
978
+ "Toggle multiple &selection", "", Wx::ITEM_CHECK)
979
+ style_menu.append(TreeTest_ToggleImages,
980
+ "Toggle show ima&ges", "", Wx::ITEM_CHECK)
981
+ style_menu.append(TreeTest_ToggleStates,
982
+ "Toggle show st&ates", "", Wx::ITEM_CHECK)
983
+ style_menu.append(TreeTest_ToggleBell,
984
+ "Toggle &bell on no match", "", Wx::ITEM_CHECK)
985
+ style_menu.append(TreeTest_ToggleAlternateImages,
986
+ "Toggle alternate images", "", Wx::ITEM_CHECK)
987
+ style_menu.append(TreeTest_ToggleAlternateStates,
988
+ "Toggle alternate state images", "", Wx::ITEM_CHECK)
989
+ style_menu.append(TreeTest_SetImageSize, "Set image si&ze...")
990
+ style_menu.append_separator
991
+ style_menu.append(TreeTest_SetFgColour, "Set &foreground colour...")
992
+ style_menu.append(TreeTest_SetBgColour, "Set &background colour...")
993
+ style_menu.append_separator
994
+ style_menu.append(TreeTest_ResetStyle, "&Reset to default\tF10")
995
+
996
+ tree_menu.append(TreeTest_FreezeThaw,
997
+ "&Freeze the tree", "", Wx::ITEM_CHECK)
998
+ tree_menu.append(TreeTest_Recreate, "&Recreate the tree")
999
+ tree_menu.append(TreeTest_CollapseAndReset, "C&ollapse and reset")
1000
+ tree_menu.append_separator
1001
+ tree_menu.append(TreeTest_AddItem, "Append a &new item")
1002
+ tree_menu.append(TreeTest_AddManyItems, "Appends &many items")
1003
+ tree_menu.append(TreeTest_InsertItem, "&Insert a new item")
1004
+ tree_menu.append(TreeTest_Delete, "&Delete selected item")
1005
+ tree_menu.append(TreeTest_DeleteChildren, "Delete &children")
1006
+ tree_menu.append(TreeTest_DeleteAll, "Delete &all items")
1007
+ tree_menu.append(TreeTest_SelectRoot, "Select root item")
1008
+ tree_menu.append_separator
1009
+ tree_menu.append(TreeTest_SetFocusedRoot, "Set focus to root item")
1010
+ tree_menu.append(TreeTest_ClearFocused, "Reset focus")
1011
+
1012
+ tree_menu.append_separator
1013
+ tree_menu.append(TreeTest_Count, "Count children of current item")
1014
+ tree_menu.append(TreeTest_CountRec, "Recursively count children of current item")
1015
+ tree_menu.append_separator
1016
+ tree_menu.append(TreeTest_Sort, "Sort children of current item")
1017
+ tree_menu.append(TreeTest_SortRev, "Sort in reversed order")
1018
+ tree_menu.append_separator
1019
+ tree_menu.append(TreeTest_EnsureVisible, "Make the last item &visible")
1020
+ tree_menu.append(TreeTest_SetFocus, "Set &focus to the tree")
1021
+ tree_menu.append_separator
1022
+ tree_menu.append(TreeTest_IncIndent, "Add 5 points to indentation\tAlt-I")
1023
+ tree_menu.append(TreeTest_DecIndent, "Reduce indentation by 5 points\tAlt-R")
1024
+ tree_menu.append_separator
1025
+ tree_menu.append(TreeTest_IncSpacing, "Add 5 points to spacing\tCtrl-I")
1026
+ tree_menu.append(TreeTest_DecSpacing, "Reduce spacing by 5 points\tCtrl-R")
1027
+
1028
+ item_menu.append(TreeTest_Dump, "&Dump item children")
1029
+ item_menu.append(TreeTest_Rename, "&Rename item...")
1030
+
1031
+ item_menu.append_separator
1032
+ item_menu.append(TreeTest_SetBold, "Make item &bold")
1033
+ item_menu.append(TreeTest_ClearBold, "Make item &not bold")
1034
+ item_menu.append_separator
1035
+ item_menu.append(TreeTest_ToggleIcon, "Toggle the item's &icon")
1036
+ item_menu.append(TreeTest_ToggleState, "Toggle the item's &state")
1037
+
1038
+ item_menu.append_separator
1039
+ item_menu.append(TreeTest_ShowFirstVisible, "Show &first visible")
1040
+ if Wx.has_feature?(:HAS_LAST_VISIBLE)
1041
+ item_menu.append(TreeTest_ShowLastVisible, "Show &last visible")
1042
+ end
1043
+ item_menu.append(TreeTest_ShowNextVisible, "Show &next visible")
1044
+ item_menu.append(TreeTest_ShowPrevVisible, "Show &previous visible")
1045
+ item_menu.append_separator
1046
+ item_menu.append(TreeTest_ShowParent, "Show pa&rent")
1047
+ item_menu.append(TreeTest_ShowPrevSibling, "Show &previous sibling")
1048
+ item_menu.append(TreeTest_ShowNextSibling, "Show &next sibling")
1049
+ item_menu.append_separator
1050
+ item_menu.append(TreeTest_ScrollTo, "Scroll &to item",
1051
+ "Scroll to the last by one top level child")
1052
+ item_menu.append(TreeTest_SelectLast, "Select &last item",
1053
+ "Select the last item")
1054
+
1055
+ item_menu.append_separator
1056
+ item_menu.append(TreeTest_DumpSelected, "Dump selected items\tAlt-D")
1057
+ item_menu.append(TreeTest_Select, "Select current item\tAlt-S")
1058
+ item_menu.append(TreeTest_Unselect, "Unselect everything\tAlt-U")
1059
+ item_menu.append(TreeTest_SelectChildren, "Select all children\tCtrl-A")
1060
+
1061
+ menu_bar = Wx::MenuBar.new
1062
+ menu_bar.append(file_menu, "&File")
1063
+ menu_bar.append(style_menu, "&Style")
1064
+ menu_bar.append(tree_menu, "&Tree")
1065
+ menu_bar.append(item_menu, "&Item")
1066
+ self.menu_bar = menu_bar
1067
+
1068
+ @panel = Wx::Panel.new(self)
1069
+
1070
+ # create the controls
1071
+ @textctrl = Wx::TextCtrl.new(@panel,
1072
+ :value => "Log text\n",
1073
+ :style => Wx::TE_MULTILINE | Wx::SUNKEN_BORDER)
1074
+
1075
+ create_tree_with_default_style
1076
+
1077
+ menu_bar.check(TreeTest_ToggleImages, true)
1078
+ menu_bar.check(TreeTest_ToggleStates, true)
1079
+ menu_bar.check(TreeTest_ToggleAlternateImages, false)
1080
+ menu_bar.check(TreeTest_ToggleAlternateStates, false)
1081
+
1082
+ # create a status bar with 3 panes
1083
+ create_status_bar(2)
1084
+
1085
+ set_status_text("", 0)
1086
+
1087
+ # set our text control as the log target
1088
+ logWindow = Wx::LogTextCtrl.new(@textctrl)
1089
+ @old_log_tgt = Wx::Log::set_active_target(logWindow)
1090
+
1091
+ # @splitter.split_horizontally(@treectrl, @textctrl, 500)
1092
+
1093
+ evt_close :on_close
1094
+ evt_size :on_size
1095
+ evt_idle :on_idle
1096
+
1097
+ evt_menu Wx::ID_EXIT, :on_quit
1098
+ evt_menu Wx::ID_ABOUT, :on_about
1099
+ evt_menu Wx::ID_CLEAR, :on_clear_log
1100
+
1101
+ evt_menu TreeTest_TogButtons, :on_tog_buttons
1102
+ evt_menu TreeTest_TogTwist, :on_tog_twist
1103
+ evt_menu TreeTest_TogLines, :on_tog_lines
1104
+ evt_menu TreeTest_TogEdit, :on_tog_edit
1105
+ evt_menu TreeTest_TogHideRoot, :on_tog_hide_root
1106
+ evt_menu TreeTest_TogRootLines, :on_tog_root_lines
1107
+ evt_menu TreeTest_TogBorder, :on_tog_border
1108
+ evt_menu TreeTest_TogFullHighlight, :on_tog_full_highlight
1109
+ evt_menu TreeTest_SetFgColour, :on_set_fg_colour
1110
+ evt_menu TreeTest_SetBgColour, :on_set_bg_colour
1111
+ evt_menu TreeTest_ResetStyle, :on_reset_style
1112
+
1113
+ evt_menu TreeTest_Highlight, :on_highlight
1114
+ evt_menu TreeTest_Dump, :on_dump
1115
+ evt_menu TreeTest_DumpSelected, :on_dump_selected
1116
+ evt_menu TreeTest_Select, :on_select
1117
+ evt_menu TreeTest_Unselect, :on_unselect
1118
+ evt_menu TreeTest_ToggleSel, :on_toggle_sel
1119
+ evt_menu TreeTest_SelectChildren, :on_select_children
1120
+ evt_menu TreeTest_Rename, :on_rename
1121
+ evt_menu TreeTest_Count, :on_count
1122
+ evt_menu TreeTest_CountRec, :on_count_rec
1123
+ evt_menu TreeTest_Sort, :on_sort
1124
+ evt_menu TreeTest_SortRev, :on_sort_rev
1125
+ evt_menu TreeTest_SetBold, :on_set_bold
1126
+ evt_menu TreeTest_ClearBold, :on_clear_bold
1127
+ evt_menu TreeTest_Delete, :on_delete
1128
+ evt_menu TreeTest_DeleteChildren, :on_delete_children
1129
+ evt_menu TreeTest_DeleteAll, :on_delete_all
1130
+ evt_menu TreeTest_Recreate, :on_recreate
1131
+ evt_menu TreeTest_FreezeThaw, :on_freeze_thaw
1132
+ evt_menu TreeTest_ToggleImages, :on_toggle_images
1133
+ evt_menu TreeTest_ToggleStates, :on_toggle_states
1134
+ evt_menu TreeTest_ToggleBell, :on_toggle_bell
1135
+ evt_menu TreeTest_ToggleAlternateImages, :on_toggle_alternate_images
1136
+ evt_menu TreeTest_ToggleAlternateStates, :on_toggle_alternate_states
1137
+ unless Wx.has_feature?(:WXMSW)
1138
+ evt_menu TreeTest_ToggleButtons, :on_toggle_buttons
1139
+ end
1140
+ evt_menu TreeTest_SetImageSize, :on_set_image_size
1141
+ evt_menu TreeTest_CollapseAndReset, :on_collapse_and_reset
1142
+ evt_menu TreeTest_EnsureVisible, :on_ensure_visible
1143
+ evt_menu TreeTest_SetFocus, :on_set_focus
1144
+ evt_menu TreeTest_AddItem, :on_add_item
1145
+ evt_menu TreeTest_AddManyItems, :on_add_many_items
1146
+ evt_menu TreeTest_InsertItem, :on_insert_item
1147
+ evt_menu TreeTest_IncIndent, :on_inc_indent
1148
+ evt_menu TreeTest_DecIndent, :on_dec_indent
1149
+ evt_menu TreeTest_IncSpacing, :on_inc_spacing
1150
+ evt_menu TreeTest_DecSpacing, :on_dec_spacing
1151
+ evt_menu TreeTest_ToggleIcon, :on_toggle_icon
1152
+ evt_menu TreeTest_ToggleState, :on_toggle_state
1153
+ evt_menu TreeTest_SelectRoot, :on_select_root
1154
+ evt_menu TreeTest_SetFocusedRoot, :on_set_focused_root
1155
+ evt_menu TreeTest_ClearFocused, :on_clear_focused
1156
+
1157
+ evt_menu TreeTest_ShowFirstVisible, :on_show_first_visible
1158
+ if Wx.has_feature?(:HAS_LAST_VISIBLE)
1159
+ evt_menu TreeTest_ShowLastVisible, :on_show_last_visible
1160
+ end
1161
+ evt_menu TreeTest_ShowNextVisible, :on_show_next_visible
1162
+ evt_menu TreeTest_ShowPrevVisible, :on_show_prev_visible
1163
+ evt_menu TreeTest_ShowParent, :on_show_parent
1164
+ evt_menu TreeTest_ShowPrevSibling, :on_show_prev_sibling
1165
+ evt_menu TreeTest_ShowNextSibling, :on_show_next_sibling
1166
+ evt_menu TreeTest_ScrollTo, :on_scroll_to
1167
+ evt_menu TreeTest_SelectLast, :on_select_last
1168
+ end
1177
1169
 
1178
- style = Wx::TR_DEFAULT_STYLE | Wx::TR_HAS_VARIABLE_ROW_HEIGHT | Wx::TR_EDIT_LABELS
1170
+ def check_item(id)
1171
+ Wx::message_box("Please select some item first!",
1172
+ "Tree sample error",
1173
+ Wx::OK | Wx::ICON_EXCLAMATION,
1174
+ self) unless id && id.ok?
1175
+ id && id.ok?
1176
+ end
1179
1177
 
1180
- create_tree(style | Wx::SUNKEN_BORDER)
1178
+ def create_tree_with_default_style
1181
1179
 
1182
- # as we don't know what Wx::TR_DEFAULT_STYLE could contain, test for
1183
- # everything
1184
- mbar = menu_bar
1185
- mbar.check(TreeTest_TogButtons, (style & Wx::TR_HAS_BUTTONS) != 0)
1186
- mbar.check(TreeTest_TogButtons, (style & Wx::TR_TWIST_BUTTONS) != 0)
1187
- mbar.check(TreeTest_TogLines, (style & Wx::TR_NO_LINES) != 0)
1188
- mbar.check(TreeTest_TogRootLines, (style & Wx::TR_LINES_AT_ROOT) != 0)
1189
- mbar.check(TreeTest_TogHideRoot, (style & Wx::TR_HIDE_ROOT) != 0)
1190
- mbar.check(TreeTest_TogEdit, (style & Wx::TR_EDIT_LABELS) != 0)
1191
- mbar.check(TreeTest_TogBorder, (style & Wx::TR_ROW_LINES) != 0)
1192
- mbar.check(TreeTest_TogFullHighlight, (style & Wx::TR_FULL_ROW_HIGHLIGHT) != 0)
1193
- end
1180
+ style = Wx::TR_DEFAULT_STYLE | Wx::TR_HAS_VARIABLE_ROW_HEIGHT | Wx::TR_EDIT_LABELS
1194
1181
 
1195
- def create_tree(style)
1196
- @treectrl = MyTreeCtrl.new(@panel, :style => style)
1182
+ create_tree(style | Wx::SUNKEN_BORDER)
1197
1183
 
1198
- menu_bar.enable(TreeTest_SelectRoot, (style & Wx::TR_HIDE_ROOT) == 0)
1184
+ # as we don't know what Wx::TR_DEFAULT_STYLE could contain, test for
1185
+ # everything
1186
+ mbar = menu_bar
1187
+ mbar.check(TreeTest_TogButtons, (style & Wx::TR_HAS_BUTTONS) != 0)
1188
+ mbar.check(TreeTest_TogButtons, (style & Wx::TR_TWIST_BUTTONS) != 0)
1189
+ mbar.check(TreeTest_TogLines, (style & Wx::TR_NO_LINES) != 0)
1190
+ mbar.check(TreeTest_TogRootLines, (style & Wx::TR_LINES_AT_ROOT) != 0)
1191
+ mbar.check(TreeTest_TogHideRoot, (style & Wx::TR_HIDE_ROOT) != 0)
1192
+ mbar.check(TreeTest_TogEdit, (style & Wx::TR_EDIT_LABELS) != 0)
1193
+ mbar.check(TreeTest_TogBorder, (style & Wx::TR_ROW_LINES) != 0)
1194
+ mbar.check(TreeTest_TogFullHighlight, (style & Wx::TR_FULL_ROW_HIGHLIGHT) != 0)
1195
+ end
1199
1196
 
1200
- resize
1201
- end
1197
+ def create_tree(style)
1198
+ @treectrl = MyTreeCtrl.new(@panel, :style => style)
1202
1199
 
1203
- def tog_style(id, flag)
1204
- style = @treectrl.get_window_style ^ flag
1200
+ menu_bar.enable(TreeTest_SelectRoot, (style & Wx::TR_HIDE_ROOT) == 0)
1205
1201
 
1206
- if Wx.has_feature?(:WXMSW)
1207
- # treectrl styles can't be changed on the fly using the native
1208
- # control and the tree must be recreated
1209
- @treectrl.destroy
1210
- create_tree(style)
1211
- else
1212
- @treectrl.set_window_style(style)
1202
+ resize
1213
1203
  end
1214
1204
 
1215
- menu_bar.check(id, (style & flag) != 0)
1216
- end
1217
-
1218
- def resize
1219
- size = get_client_size
1220
- @treectrl.set_size(Wx::Rect.new(0, 0, size.width, size.height * 2 / 3)) if @treectrl
1221
- @textctrl.set_size(Wx::Rect.new(0, 2 * size.height / 3, size.width, size.height / 3)) if @textctrl
1222
- end
1205
+ def tog_style(id, flag)
1206
+ style = @treectrl.get_window_style ^ flag
1223
1207
 
1224
- def on_idle(evt)
1225
- if @treectrl
1226
- idRoot = @treectrl.root_item
1227
- if idRoot.ok?
1228
- idLast = @treectrl.get_last_tree_item
1229
- status = "Root/last item is %svisible/%svisible" %
1230
- [@treectrl.is_visible(idRoot) ? '' : 'not ',
1231
- idLast.ok? && @treectrl.is_visible(idLast) ? '' : 'not ']
1208
+ if Wx.has_feature?(:WXMSW)
1209
+ # treectrl styles can't be changed on the fly using the native
1210
+ # control and the tree must be recreated
1211
+ @treectrl.destroy
1212
+ create_tree(style)
1232
1213
  else
1233
- status = "No root item";
1214
+ @treectrl.set_window_style(style)
1234
1215
  end
1235
1216
 
1236
- set_status_text(status, 1)
1217
+ menu_bar.check(id, (style & flag) != 0)
1237
1218
  end
1238
1219
 
1239
- evt.skip
1240
- end
1220
+ def resize
1221
+ size = get_client_size
1222
+ @treectrl.set_size(Wx::Rect.new(0, 0, size.width, size.height * 2 / 3)) if @treectrl
1223
+ @textctrl.set_size(Wx::Rect.new(0, 2 * size.height / 3, size.width, size.height / 3)) if @textctrl
1224
+ end
1241
1225
 
1242
- def on_size(evt)
1243
- resize if (@treectrl && @textctrl)
1244
- evt.skip
1245
- end
1226
+ def on_idle(evt)
1227
+ if @treectrl
1228
+ idRoot = @treectrl.root_item
1229
+ if idRoot.ok?
1230
+ idLast = @treectrl.get_last_tree_item
1231
+ status = "Root/last item is %svisible/%svisible" %
1232
+ [@treectrl.is_visible(idRoot) ? '' : 'not ',
1233
+ idLast.ok? && @treectrl.is_visible(idLast) ? '' : 'not ']
1234
+ else
1235
+ status = "No root item";
1236
+ end
1246
1237
 
1247
- def on_quit(event)
1248
- close(true)
1249
- end
1238
+ set_status_text(status, 1)
1239
+ end
1250
1240
 
1251
- def on_about(event)
1252
- Wx::message_box("Tree test sample\n" +
1253
- "(c) Julian Smart 1997, Vadim Zeitlin 1998, Martin Corino 2022",
1254
- "About wxRuby tree test",
1255
- Wx::OK | Wx::ICON_INFORMATION, self)
1256
- end
1241
+ evt.skip
1242
+ end
1257
1243
 
1258
- def on_clear_log(event)
1259
- @textctrl.clear
1260
- end
1244
+ def on_size(evt)
1245
+ resize if (@treectrl && @textctrl)
1246
+ evt.skip
1247
+ end
1261
1248
 
1262
- def on_rename(event)
1263
- item = @treectrl.selection
1264
- return unless check_item(item)
1265
- # TODO demonstrate creating a custom edit control...
1266
- @treectrl.edit_label(item)
1267
- end
1249
+ def on_quit(event)
1250
+ close(true)
1251
+ end
1268
1252
 
1269
- def on_count(event)
1270
- item = @treectrl.selection
1271
- return unless check_item(item)
1272
- i = @treectrl.children_count(item, false)
1273
- Wx::log_message("%d children", i)
1274
- end
1253
+ def on_about(event)
1254
+ Wx::message_box("Tree test sample\n" +
1255
+ "(c) Julian Smart 1997, Vadim Zeitlin 1998, Martin Corino 2022",
1256
+ "About wxRuby tree test",
1257
+ Wx::OK | Wx::ICON_INFORMATION, self)
1258
+ end
1275
1259
 
1276
- def on_count_rec(event)
1277
- item = @treectrl.selection
1278
- return unless check_item(item)
1279
- Wx::log_message("%d children", @treectrl.children_count(item))
1280
- end
1260
+ def on_clear_log(event)
1261
+ @textctrl.clear
1262
+ end
1281
1263
 
1282
- def do_sort(reverse = false)
1283
- item = @treectrl.selection
1284
- return unless check_item(item)
1285
- @treectrl.do_sort_children(item, reverse)
1286
- end
1264
+ def on_rename(event)
1265
+ item = @treectrl.selection
1266
+ return unless check_item(item)
1267
+ # TODO demonstrate creating a custom edit control...
1268
+ @treectrl.edit_label(item)
1269
+ end
1287
1270
 
1288
- def on_highlight(_event)
1289
- id = @treectrl.get_focused_item
1271
+ def on_count(event)
1272
+ item = @treectrl.selection
1273
+ return unless check_item(item)
1274
+ i = @treectrl.children_count(item, false)
1275
+ Wx::log_message("%d children", i)
1276
+ end
1290
1277
 
1291
- return unless check_item(id)
1278
+ def on_count_rec(event)
1279
+ item = @treectrl.selection
1280
+ return unless check_item(item)
1281
+ Wx::log_message("%d children", @treectrl.children_count(item))
1282
+ end
1292
1283
 
1293
- r = Wx::Rect.new
1294
- if !@treectrl.get_bounding_rect(id, r, true) # text, not full row
1295
- Wx::LogMessage("Failed to get bounding item rect")
1296
- return
1284
+ def do_sort(reverse = false)
1285
+ item = @treectrl.selection
1286
+ return unless check_item(item)
1287
+ @treectrl.do_sort_children(item, reverse)
1297
1288
  end
1298
- @treectrl.paint do |dc|
1299
- dc.set_brush(Wx::RED_BRUSH)
1300
- dc.set_pen(Wx::TRANSPARENT_PEN)
1301
- dc.draw_rectangle(r)
1302
- @treectrl.update
1289
+
1290
+ def on_highlight(_event)
1291
+ id = @treectrl.get_focused_item
1292
+
1293
+ return unless check_item(id)
1294
+
1295
+ r = Wx::Rect.new
1296
+ if !@treectrl.get_bounding_rect(id, r, true) # text, not full row
1297
+ Wx::LogMessage("Failed to get bounding item rect")
1298
+ return
1299
+ end
1300
+ @treectrl.paint do |dc|
1301
+ dc.set_brush(Wx::RED_BRUSH)
1302
+ dc.set_pen(Wx::TRANSPARENT_PEN)
1303
+ dc.draw_rectangle(r)
1304
+ @treectrl.update
1305
+ end
1303
1306
  end
1304
- end
1305
1307
 
1306
- def on_dump(event)
1307
- root = @treectrl.selection
1308
- return unless check_item(root)
1309
- @treectrl.get_items_recursively(root, -1)
1310
- end
1308
+ def on_dump(event)
1309
+ root = @treectrl.selection
1310
+ return unless check_item(root)
1311
+ @treectrl.get_items_recursively(root, -1)
1312
+ end
1311
1313
 
1312
- def on_toggle_sel(event)
1313
- tog_style(event.id, Wx::TR_MULTIPLE)
1314
- end
1314
+ def on_toggle_sel(event)
1315
+ tog_style(event.id, Wx::TR_MULTIPLE)
1316
+ end
1315
1317
 
1316
- def on_dump_selected(event)
1317
- if (@treectrl.window_style & Wx::TR_MULTIPLE) == 0
1318
- item_id = @treectrl.selection
1319
- if item_id.ok?
1320
- Wx::log_message("<TreeItem '%s'>",
1321
- @treectrl.get_item_text(item_id))
1318
+ def on_dump_selected(event)
1319
+ if (@treectrl.window_style & Wx::TR_MULTIPLE) == 0
1320
+ item_id = @treectrl.selection
1321
+ if item_id.ok?
1322
+ Wx::log_message("<TreeItem '%s'>",
1323
+ @treectrl.get_item_text(item_id))
1324
+ else
1325
+ Wx::log_message("No tree item selected")
1326
+ end
1322
1327
  else
1323
- Wx::log_message("No tree item selected")
1328
+ Wx::log_message("NOT IMPLEMENTED: Multiple selections not available")
1329
+ # Requires Wx::List - Ruby Array typemap, pointer handling, 29/08/2006
1330
+ # Currently raises incorrect number of args, 1 for 0
1331
+ # selected = @treectrl.get_selections
1332
+ # selected_items.each do | item_id |
1333
+ # Wx::log_message("\t%s", @treectrl.get_item_text(item_id))
1334
+ # end
1324
1335
  end
1325
- else
1326
- Wx::log_message("NOT IMPLEMENTED: Multiple selections not available")
1327
- # Requires Wx::List - Ruby Array typemap, pointer handling, 29/08/2006
1328
- # Currently raises incorrect number of args, 1 for 0
1329
- # selected = @treectrl.get_selections
1330
- # selected_items.each do | item_id |
1331
- # Wx::log_message("\t%s", @treectrl.get_item_text(item_id))
1332
- # end
1333
1336
  end
1334
- end
1335
-
1336
- def on_select(event)
1337
- @treectrl.select_item(@treectrl.selection)
1338
- end
1339
1337
 
1340
- def on_select_root(event)
1341
- unless @treectrl.has_flag(Wx::TR_HIDE_ROOT)
1342
- @treectrl.select_item(@treectrl.root_item)
1338
+ def on_select(event)
1339
+ @treectrl.select_item(@treectrl.selection)
1343
1340
  end
1344
- end
1345
1341
 
1346
- def on_set_focused_root(event)
1347
- unless @treectrl.has_flag(Wx::TR_HIDE_ROOT)
1348
- @treectrl.set_focused_item(@treectrl.root_item)
1342
+ def on_select_root(event)
1343
+ unless @treectrl.has_flag(Wx::TR_HIDE_ROOT)
1344
+ @treectrl.select_item(@treectrl.root_item)
1345
+ end
1349
1346
  end
1350
- end
1351
1347
 
1352
- def on_clear_focused(event)
1353
- @treectrl.clear_focused_item
1354
- end
1348
+ def on_set_focused_root(event)
1349
+ unless @treectrl.has_flag(Wx::TR_HIDE_ROOT)
1350
+ @treectrl.set_focused_item(@treectrl.root_item)
1351
+ end
1352
+ end
1355
1353
 
1356
- def on_unselect(event)
1357
- @treectrl.unselect_all
1358
- end
1354
+ def on_clear_focused(event)
1355
+ @treectrl.clear_focused_item
1356
+ end
1359
1357
 
1360
- def on_select_children(event)
1361
- item = @treectrl.get_focused_item
1358
+ def on_unselect(event)
1359
+ @treectrl.unselect_all
1360
+ end
1362
1361
 
1363
- item = @treectrl.root_item unless item.ok?
1362
+ def on_select_children(event)
1363
+ item = @treectrl.get_focused_item
1364
1364
 
1365
- @treectrl.select_children(item)
1366
- end
1365
+ item = @treectrl.root_item unless item.ok?
1367
1366
 
1368
- def do_set_bold(bold = true)
1369
- item = @treectrl.selection
1370
- return unless check_item(item)
1371
- @treectrl.set_item_bold(item, bold)
1372
- end
1367
+ @treectrl.select_children(item)
1368
+ end
1373
1369
 
1374
- def on_delete(event)
1375
- item = @treectrl.selection
1376
- return unless check_item(item)
1377
- @treectrl.delete(item)
1378
- end
1370
+ def do_set_bold(bold = true)
1371
+ item = @treectrl.selection
1372
+ return unless check_item(item)
1373
+ @treectrl.set_item_bold(item, bold)
1374
+ end
1379
1375
 
1380
- def on_delete_children(event)
1381
- item = @treectrl.selection
1382
- return unless check_item(item)
1383
- @treectrl.delete_children(item)
1384
- end
1376
+ def on_delete(event)
1377
+ item = @treectrl.selection
1378
+ return unless check_item(item)
1379
+ @treectrl.delete(item)
1380
+ end
1385
1381
 
1386
- def on_delete_all(event)
1387
- @treectrl.delete_all_items
1388
- end
1382
+ def on_delete_children(event)
1383
+ item = @treectrl.selection
1384
+ return unless check_item(item)
1385
+ @treectrl.delete_children(item)
1386
+ end
1389
1387
 
1390
- def on_freeze_thaw(event)
1391
- if event.is_checked
1392
- @treectrl.freeze
1393
- else
1394
- @treectrl.thaw
1388
+ def on_delete_all(event)
1389
+ @treectrl.delete_all_items
1395
1390
  end
1396
1391
 
1397
- Wx::log_message("The tree is %sfrozen", @treectrl.is_frozen ? '' : 'not ')
1398
- end
1392
+ def on_freeze_thaw(event)
1393
+ if event.is_checked
1394
+ @treectrl.freeze
1395
+ else
1396
+ @treectrl.thaw
1397
+ end
1399
1398
 
1400
- def on_recreate(event)
1401
- on_delete_all(event)
1402
- @treectrl.add_test_items_to_tree(5, 2)
1403
- end
1399
+ Wx::log_message("The tree is %sfrozen", @treectrl.is_frozen ? '' : 'not ')
1400
+ end
1404
1401
 
1405
- def on_set_image_size(event)
1406
- size = Wx.get_number_from_user("Enter the size for the images to use",
1407
- "Size: ",
1408
- "TreeCtrl sample",
1409
- @treectrl.image_size)
1410
- if size == -1
1411
- return
1402
+ def on_recreate(event)
1403
+ on_delete_all(event)
1404
+ @treectrl.add_test_items_to_tree(5, 2)
1412
1405
  end
1413
1406
 
1414
- @treectrl.create_image_list(size)
1415
- @treectrl.refresh
1416
- Wx::THE_APP.show_images = true
1417
- end
1407
+ def on_set_image_size(event)
1408
+ size = Wx.get_number_from_user("Enter the size for the images to use",
1409
+ "Size: ",
1410
+ "TreeCtrl sample",
1411
+ @treectrl.image_size)
1412
+ if size == -1
1413
+ return
1414
+ end
1418
1415
 
1419
- def on_toggle_images(event)
1420
- if Wx::get_app.show_images
1421
- @treectrl.unset_image_list
1422
- Wx::get_app.show_images = false
1423
- else
1424
- @treectrl.create_image_list(@treectrl.image_size)
1425
- Wx::get_app.show_images = true
1416
+ @treectrl.create_image_list(size)
1417
+ @treectrl.refresh
1418
+ Wx::THE_APP.show_images = true
1426
1419
  end
1427
- end
1428
1420
 
1429
- def on_toggle_states(event)
1430
- if Wx::get_app.show_states
1431
- @treectrl.create_state_imageList(true)
1432
- Wx::get_app.show_states = false
1433
- else
1434
- @treectrl.create_state_imageList
1435
- Wx::get_app.show_states = true
1421
+ def on_toggle_images(event)
1422
+ if Wx::get_app.show_images
1423
+ @treectrl.unset_image_list
1424
+ Wx::get_app.show_images = false
1425
+ else
1426
+ @treectrl.create_image_list(@treectrl.image_size)
1427
+ Wx::get_app.show_images = true
1428
+ end
1436
1429
  end
1437
- end
1438
1430
 
1439
- def on_toggle_bell(event)
1440
- @treectrl.enable_bell_on_no_match(event.checked?)
1441
- end
1431
+ def on_toggle_states(event)
1432
+ if Wx::get_app.show_states
1433
+ @treectrl.create_state_imageList(true)
1434
+ Wx::get_app.show_states = false
1435
+ else
1436
+ @treectrl.create_state_imageList
1437
+ Wx::get_app.show_states = true
1438
+ end
1439
+ end
1442
1440
 
1443
- def on_toggle_alternate_images(event)
1444
- alternateImages = @treectrl.alternate_images
1441
+ def on_toggle_bell(event)
1442
+ @treectrl.enable_bell_on_no_match(event.checked?)
1443
+ end
1445
1444
 
1446
- @treectrl.alternate_images = !alternateImages
1447
- @treectrl.create_image_list(0)
1448
- end
1445
+ def on_toggle_alternate_images(event)
1446
+ alternateImages = @treectrl.alternate_images
1449
1447
 
1450
- def on_toggle_alternate_states(event)
1451
- alternateStates = @treectrl.alternate_states
1448
+ @treectrl.alternate_images = !alternateImages
1449
+ @treectrl.create_image_list(0)
1450
+ end
1452
1451
 
1453
- @treectrl.alternate_states = !alternateStates
1454
- @treectrl.create_state_imageList
1452
+ def on_toggle_alternate_states(event)
1453
+ alternateStates = @treectrl.alternate_states
1455
1454
 
1456
- # normal states < alternate states
1457
- # so we must reset broken states
1458
- if alternateStates
1459
- @treectrl.reset_broken_state_images
1455
+ @treectrl.alternate_states = !alternateStates
1456
+ @treectrl.create_state_imageList
1457
+
1458
+ # normal states < alternate states
1459
+ # so we must reset broken states
1460
+ if alternateStates
1461
+ @treectrl.reset_broken_state_images
1462
+ end
1460
1463
  end
1461
- end
1462
1464
 
1463
- def on_toggle_buttons(event)
1464
- unless Wx::PLATFORM == 'WXMSW'
1465
- if Wx::THE_APP.show_buttons
1466
- @treectrl.create_buttons_image_list(-1)
1467
- Wx::get_app.show_buttons = false
1468
- else
1469
- @treectrl.create_buttons_image_list(15)
1470
- Wx::get_app.show_buttons = true
1465
+ def on_toggle_buttons(event)
1466
+ unless Wx::PLATFORM == 'WXMSW'
1467
+ if Wx::THE_APP.show_buttons
1468
+ @treectrl.create_buttons_image_list(-1)
1469
+ Wx::get_app.show_buttons = false
1470
+ else
1471
+ @treectrl.create_buttons_image_list(15)
1472
+ Wx::get_app.show_buttons = true
1473
+ end
1471
1474
  end
1472
1475
  end
1473
- end
1474
1476
 
1475
- def on_collapse_and_reset(event)
1476
- @treectrl.collapse_and_reset(@treectrl.get_root_item)
1477
- end
1477
+ def on_collapse_and_reset(event)
1478
+ @treectrl.collapse_and_reset(@treectrl.get_root_item)
1479
+ end
1478
1480
 
1479
- def on_ensure_visible(event)
1480
- @treectrl.do_ensure_visible
1481
- end
1481
+ def on_ensure_visible(event)
1482
+ @treectrl.do_ensure_visible
1483
+ end
1482
1484
 
1483
- def on_set_focus(event)
1484
- @treectrl.set_focus
1485
- end
1485
+ def on_set_focus(event)
1486
+ @treectrl.set_focus
1487
+ end
1486
1488
 
1487
- def on_insert_item(event)
1488
- image = Wx::THE_APP.show_images ? TreeCtrlIcon_File : -1
1489
- @treectrl.insert_item(@treectrl.root_item, -1, "2nd item", image)
1490
- end
1489
+ def on_insert_item(event)
1490
+ image = Wx::THE_APP.show_images ? TreeCtrlIcon_File : -1
1491
+ @treectrl.insert_item(@treectrl.root_item, -1, "2nd item", image)
1492
+ end
1491
1493
 
1492
- def on_add_item(event)
1493
- @s_num += 1
1494
- text = sprintf("Item #%d", @s_num)
1495
- @treectrl.append_item(@treectrl.root_item, text)
1496
- end
1494
+ def on_add_item(event)
1495
+ @s_num += 1
1496
+ text = sprintf("Item #%d", @s_num)
1497
+ @treectrl.append_item(@treectrl.root_item, text)
1498
+ end
1497
1499
 
1498
- def on_add_many_items(event)
1499
- Wx::WindowUpdateLocker.update(@treectrl) do
1500
- root = @treectrl.root_item
1501
- 1000.times {|n| @treectrl.append_item(root, "Item #%03d" % [n]) }
1500
+ def on_add_many_items(event)
1501
+ Wx::WindowUpdateLocker.update(@treectrl) do
1502
+ root = @treectrl.root_item
1503
+ 1000.times {|n| @treectrl.append_item(root, "Item #%03d" % [n]) }
1504
+ end
1502
1505
  end
1503
- end
1504
1506
 
1505
- def on_inc_indent(event)
1506
- if @treectrl.indent < 100
1507
- @treectrl.indent += 5
1507
+ def on_inc_indent(event)
1508
+ if @treectrl.indent < 100
1509
+ @treectrl.indent += 5
1510
+ end
1508
1511
  end
1509
- end
1510
1512
 
1511
- def on_dec_indent(event)
1512
- if @treectrl.indent > 10
1513
- @treectrl.indent -= 5
1513
+ def on_dec_indent(event)
1514
+ if @treectrl.indent > 10
1515
+ @treectrl.indent -= 5
1516
+ end
1514
1517
  end
1515
- end
1516
1518
 
1517
- def on_inc_spacing(event)
1518
- if @treectrl.spacing < 100
1519
- @treectrl.spacing += 5
1519
+ def on_inc_spacing(event)
1520
+ if @treectrl.spacing < 100
1521
+ @treectrl.spacing += 5
1522
+ end
1520
1523
  end
1521
- end
1522
1524
 
1523
- def on_dec_spacing(event)
1524
- if @treectrl.spacing > 10
1525
- @treectrl.spacing -= 5
1525
+ def on_dec_spacing(event)
1526
+ if @treectrl.spacing > 10
1527
+ @treectrl.spacing -= 5
1528
+ end
1526
1529
  end
1527
- end
1528
1530
 
1529
- def on_toggle_icon(event)
1530
- item = @treectrl.focused_item
1531
- return unless check_item(item)
1532
- @treectrl.do_toggle_icon(item)
1533
- end
1531
+ def on_toggle_icon(event)
1532
+ item = @treectrl.focused_item
1533
+ return unless check_item(item)
1534
+ @treectrl.do_toggle_icon(item)
1535
+ end
1534
1536
 
1535
- def on_toggle_state(event)
1536
- item = @treectrl.focused_item
1537
- return unless check_item(item)
1538
- @treectrl.do_toggle_state(item)
1539
- end
1537
+ def on_toggle_state(event)
1538
+ item = @treectrl.focused_item
1539
+ return unless check_item(item)
1540
+ @treectrl.do_toggle_state(item)
1541
+ end
1540
1542
 
1541
- def do_show_first_or_last(label)
1542
- item = yield
1543
- unless item.ok?
1544
- Wx::log_message("There is no %s item" % label)
1545
- else
1546
- Wx::log_message("The %s item is \"%s\"" %
1547
- [label, @treectrl.item_text(item)])
1543
+ def do_show_first_or_last(label)
1544
+ item = yield
1545
+ unless item.ok?
1546
+ Wx::log_message("There is no %s item" % label)
1547
+ else
1548
+ Wx::log_message("The %s item is \"%s\"" %
1549
+ [label, @treectrl.item_text(item)])
1550
+ end
1548
1551
  end
1549
- end
1550
1552
 
1551
- def do_show_relative_item(label)
1552
- item = @treectrl.focused_item
1553
+ def do_show_relative_item(label)
1554
+ item = @treectrl.focused_item
1553
1555
 
1554
- return unless item.ok?
1555
- unless !label['visible'] || @treectrl.visible?(item)
1556
- Wx::log_message("The selected item must be visible.")
1557
- return
1558
- end
1556
+ return unless item.ok?
1557
+ unless !label['visible'] || @treectrl.visible?(item)
1558
+ Wx::log_message("The selected item must be visible.")
1559
+ return
1560
+ end
1559
1561
 
1560
- item = yield(item)
1562
+ item = yield(item)
1561
1563
 
1562
- unless item.ok?
1563
- Wx::log_message("There is no %s item" % label)
1564
- else
1565
- Wx::log_message("The %s item is \"%s\"" %
1566
- [label, @treectrl.item_text(item)])
1564
+ unless item.ok?
1565
+ Wx::log_message("There is no %s item" % label)
1566
+ else
1567
+ Wx::log_message("The %s item is \"%s\"" %
1568
+ [label, @treectrl.item_text(item)])
1569
+ end
1567
1570
  end
1568
- end
1569
1571
 
1570
- def on_show_first_visible(event)
1571
- do_show_first_or_last("first visible") { @treectrl.first_visible_item }
1572
- end
1572
+ def on_show_first_visible(event)
1573
+ do_show_first_or_last("first visible") { @treectrl.first_visible_item }
1574
+ end
1573
1575
 
1574
- def on_show_last_visible(event)
1575
- if Wx.has_feature?(:HAS_LAST_VISIBLE)
1576
- do_show_first_or_last("last visible") { @treectrl.last_visible_item }
1576
+ def on_show_last_visible(event)
1577
+ if Wx.has_feature?(:HAS_LAST_VISIBLE)
1578
+ do_show_first_or_last("last visible") { @treectrl.last_visible_item }
1579
+ end
1577
1580
  end
1578
- end
1579
1581
 
1580
- def on_show_next_visible(event)
1581
- do_show_relative_item("next visible") { |itm| @treectrl.next_visible(itm) }
1582
- end
1582
+ def on_show_next_visible(event)
1583
+ do_show_relative_item("next visible") { |itm| @treectrl.next_visible(itm) }
1584
+ end
1583
1585
 
1584
- def on_show_prev_visible(event)
1585
- do_show_relative_item("prev visible") { |itm| @treectrl.prev_visible(itm) }
1586
- end
1586
+ def on_show_prev_visible(event)
1587
+ do_show_relative_item("prev visible") { |itm| @treectrl.prev_visible(itm) }
1588
+ end
1587
1589
 
1588
- def on_show_parent(event)
1589
- do_show_relative_item("parent") { |itm| @treectrl.item_parent(itm) }
1590
- end
1590
+ def on_show_parent(event)
1591
+ do_show_relative_item("parent") { |itm| @treectrl.item_parent(itm) }
1592
+ end
1591
1593
 
1592
- def on_show_prev_sibling(event)
1593
- do_show_relative_item("previous sibling") { |itm| @treectrl.prev_sibling(itm) }
1594
- end
1594
+ def on_show_prev_sibling(event)
1595
+ do_show_relative_item("previous sibling") { |itm| @treectrl.prev_sibling(itm) }
1596
+ end
1595
1597
 
1596
- def on_show_next_sibling(event)
1597
- do_show_relative_item("next sibling") { |itm| @treectrl.next_sibling(itm) }
1598
- end
1598
+ def on_show_next_sibling(event)
1599
+ do_show_relative_item("next sibling") { |itm| @treectrl.next_sibling(itm) }
1600
+ end
1599
1601
 
1600
- def on_scroll_to(event)
1601
- # scroll to the last but one top level child
1602
- item = @treectrl.get_prev_sibling(
1603
- @treectrl.get_last_child(
1604
- @treectrl.root_item))
1605
- return unless item.ok?
1602
+ def on_scroll_to(event)
1603
+ # scroll to the last but one top level child
1604
+ item = @treectrl.get_prev_sibling(
1605
+ @treectrl.get_last_child(
1606
+ @treectrl.root_item))
1607
+ return unless item.ok?
1606
1608
 
1607
- @treectrl.scroll_to(item)
1608
- end
1609
+ @treectrl.scroll_to(item)
1610
+ end
1609
1611
 
1610
- def on_select_last(event)
1611
- item = @treectrl.last_tree_item
1612
+ def on_select_last(event)
1613
+ item = @treectrl.last_tree_item
1612
1614
 
1613
- return unless item.ok?
1615
+ return unless item.ok?
1614
1616
 
1615
- @treectrl.select_item(item)
1616
- end
1617
+ @treectrl.select_item(item)
1618
+ end
1617
1619
 
1618
- def on_set_fg_colour(event)
1619
- col = Wx::get_colour_from_user(self, @treectrl.foreground_colour)
1620
- if col.ok?
1621
- @treectrl.foreground_colour = col
1620
+ def on_set_fg_colour(event)
1621
+ col = Wx::get_colour_from_user(self, @treectrl.foreground_colour)
1622
+ if col.ok?
1623
+ @treectrl.foreground_colour = col
1624
+ end
1622
1625
  end
1623
- end
1624
1626
 
1625
- def on_set_bg_colour(event)
1626
- col = Wx::get_colour_from_user(self, @treectrl.background_colour)
1627
- if col.ok?
1628
- @treectrl.background_colour = col
1627
+ def on_set_bg_colour(event)
1628
+ col = Wx::get_colour_from_user(self, @treectrl.background_colour)
1629
+ if col.ok?
1630
+ @treectrl.background_colour = col
1631
+ end
1629
1632
  end
1630
- end
1631
1633
 
1632
- def on_tog_buttons(event)
1633
- tog_style(event.id, Wx::TR_HAS_BUTTONS)
1634
- end
1634
+ def on_tog_buttons(event)
1635
+ tog_style(event.id, Wx::TR_HAS_BUTTONS)
1636
+ end
1635
1637
 
1636
- def on_tog_twist(event)
1637
- tog_style(event.id, Wx::TR_TWIST_BUTTONS)
1638
- end
1638
+ def on_tog_twist(event)
1639
+ tog_style(event.id, Wx::TR_TWIST_BUTTONS)
1640
+ end
1639
1641
 
1640
- def on_tog_lines(event)
1641
- tog_style(event.id, Wx::TR_NO_LINES)
1642
- end
1642
+ def on_tog_lines(event)
1643
+ tog_style(event.id, Wx::TR_NO_LINES)
1644
+ end
1643
1645
 
1644
- def on_tog_edit(event)
1645
- tog_style(event.id, Wx::TR_EDIT_LABELS)
1646
- end
1646
+ def on_tog_edit(event)
1647
+ tog_style(event.id, Wx::TR_EDIT_LABELS)
1648
+ end
1647
1649
 
1648
- def on_tog_hide_root(event)
1649
- tog_style(event.id, Wx::TR_HIDE_ROOT)
1650
- end
1650
+ def on_tog_hide_root(event)
1651
+ tog_style(event.id, Wx::TR_HIDE_ROOT)
1652
+ end
1651
1653
 
1652
- def on_tog_root_lines(event)
1653
- tog_style(event.id, Wx::TR_LINES_AT_ROOT)
1654
- end
1654
+ def on_tog_root_lines(event)
1655
+ tog_style(event.id, Wx::TR_LINES_AT_ROOT)
1656
+ end
1655
1657
 
1656
- def on_tog_border(event)
1657
- tog_style(event.id, Wx::TR_ROW_LINES)
1658
- end
1658
+ def on_tog_border(event)
1659
+ tog_style(event.id, Wx::TR_ROW_LINES)
1660
+ end
1659
1661
 
1660
- def on_tog_full_highlight(event)
1661
- tog_style(event.id, Wx::TR_FULL_ROW_HIGHLIGHT)
1662
- end
1662
+ def on_tog_full_highlight(event)
1663
+ tog_style(event.id, Wx::TR_FULL_ROW_HIGHLIGHT)
1664
+ end
1663
1665
 
1664
- def on_reset_style(event)
1665
- create_tree_with_default_style
1666
- end
1666
+ def on_reset_style(event)
1667
+ create_tree_with_default_style
1668
+ end
1667
1669
 
1668
- def on_set_bold(event)
1669
- do_set_bold(true)
1670
- end
1670
+ def on_set_bold(event)
1671
+ do_set_bold(true)
1672
+ end
1671
1673
 
1672
- def on_clear_bold(event)
1673
- do_set_bold(false)
1674
- end
1674
+ def on_clear_bold(event)
1675
+ do_set_bold(false)
1676
+ end
1675
1677
 
1676
- def on_sort(event)
1677
- do_sort
1678
- end
1678
+ def on_sort(event)
1679
+ do_sort
1680
+ end
1679
1681
 
1680
- def on_sort_rev(event)
1681
- do_sort(true)
1682
- end
1682
+ def on_sort_rev(event)
1683
+ do_sort(true)
1684
+ end
1685
+
1686
+ def on_close(event)
1687
+ Wx::Log::active_target = @old_log_tgt
1688
+ destroy
1689
+ end
1683
1690
 
1684
- def on_close(event)
1685
- Wx::Log::active_target = @old_log_tgt
1686
- destroy
1687
1691
  end
1688
1692
 
1689
- end
1693
+ class MyApp < Wx::App
1694
+ attr_accessor :show_images, :show_buttons, :show_states
1690
1695
 
1691
- class MyApp < Wx::App
1692
- attr_accessor :show_images, :show_buttons, :show_states
1696
+ def initialize
1697
+ self.show_images = true
1698
+ self.show_buttons = false
1699
+ self.show_states = true
1700
+ super
1701
+ end
1693
1702
 
1694
- def initialize
1695
- self.show_images = true
1696
- self.show_buttons = false
1697
- self.show_states = true
1698
- super
1703
+ def on_init
1704
+ # Create the main frame window
1705
+ frame = MyFrame.new("TreeCtrl Test", 50, 50, 450, 600)
1706
+ # show the frame
1707
+ frame.show(true)
1708
+ end
1699
1709
  end
1700
1710
 
1701
- def on_init
1702
- # Create the main frame window
1703
- frame = MyFrame.new("TreeCtrl Test", 50, 50, 450, 600)
1704
- # show the frame
1705
- frame.show(true)
1706
- end
1707
1711
  end
1708
1712
 
1709
1713
  module TreeCtrlSample
@@ -1721,7 +1725,7 @@ module TreeCtrlSample
1721
1725
  end
1722
1726
 
1723
1727
  if $0 == __FILE__
1724
- MyApp.run
1728
+ TreeCtrl::MyApp.run
1725
1729
  end
1726
1730
 
1727
1731
  end