wxruby3 0.9.0.pre.rc.3-x64-mingw-ucrt → 0.9.1-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (685) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/ext/mkrf_conf_bingem.rb +4 -1
  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/accessors.rb +10 -2
  20. data/lib/wx/aui/auifloatframe.rb +20 -0
  21. data/lib/wx/aui/auimanager.rb +3 -0
  22. data/lib/wx/aui/auinotebook.rb +17 -0
  23. data/lib/wx/aui/events/evt_list.rb +7 -7
  24. data/lib/wx/aui/require.rb +5 -1
  25. data/lib/wx/aui.rb +4 -1
  26. data/lib/wx/core/acceleratortable.rb +8 -0
  27. data/lib/wx/core/animation.rb +8 -0
  28. data/lib/wx/core/app.rb +8 -0
  29. data/lib/wx/core/array_ext.rb +7 -0
  30. data/lib/wx/core/art_locator.rb +7 -0
  31. data/lib/wx/core/artprovider.rb +9 -0
  32. data/lib/wx/core/bitmap.rb +16 -4
  33. data/lib/wx/core/bitmap_combobox.rb +7 -0
  34. data/lib/wx/core/brush.rb +7 -0
  35. data/lib/wx/core/busycursor.rb +9 -0
  36. data/lib/wx/core/choice.rb +7 -0
  37. data/lib/wx/core/choicedlg.rb +7 -0
  38. data/lib/wx/core/clientdc.rb +9 -0
  39. data/lib/wx/core/clipboard.rb +8 -0
  40. data/lib/wx/core/collapsible_pane.rb +8 -1
  41. data/lib/wx/core/colour.rb +8 -0
  42. data/lib/wx/core/combo_ctrl.rb +110 -0
  43. data/lib/wx/core/combobox.rb +7 -0
  44. data/lib/wx/core/config.rb +303 -0
  45. data/lib/wx/core/const.rb +83 -0
  46. data/lib/wx/core/controlwithitems.rb +12 -1
  47. data/lib/wx/core/cursor.rb +14 -4
  48. data/lib/wx/core/data_object.rb +7 -0
  49. data/lib/wx/core/dataformat.rb +9 -0
  50. data/lib/wx/core/datetime.rb +14 -0
  51. data/lib/wx/core/dc.rb +7 -0
  52. data/lib/wx/core/dialog.rb +18 -1
  53. data/lib/wx/core/enum.rb +7 -0
  54. data/lib/wx/core/event.rb +7 -0
  55. data/lib/wx/core/event_blocker.rb +7 -0
  56. data/lib/wx/core/event_loop.rb +7 -0
  57. data/lib/wx/core/events/evt_list.rb +100 -0
  58. data/lib/wx/core/evthandler.rb +8 -0
  59. data/lib/wx/core/ext.rb +7 -0
  60. data/lib/wx/core/file_dialog.rb +23 -0
  61. data/lib/wx/core/find_replace_dialog.rb +7 -0
  62. data/lib/wx/core/functions.rb +8 -0
  63. data/lib/wx/core/gauge.rb +10 -1
  64. data/lib/wx/core/genericdirctrl.rb +9 -0
  65. data/lib/wx/core/hboxsizer.rb +16 -0
  66. data/lib/wx/core/helpcontroller.rb +8 -0
  67. data/lib/wx/core/helpcontrollerhelpprovider.rb +9 -0
  68. data/lib/wx/core/helpprovider.rb +10 -1
  69. data/lib/wx/core/icon.rb +17 -6
  70. data/lib/wx/core/id_helper.rb +7 -0
  71. data/lib/wx/core/image.rb +16 -4
  72. data/lib/wx/core/imagelist.rb +8 -1
  73. data/lib/wx/core/listbox.rb +7 -0
  74. data/lib/wx/core/listctrl.rb +9 -0
  75. data/lib/wx/core/locale.rb +8 -0
  76. data/lib/wx/core/log.rb +24 -0
  77. data/lib/wx/core/menu.rb +9 -0
  78. data/lib/wx/core/menu_bar.rb +7 -0
  79. data/lib/wx/core/menuitem.rb +9 -0
  80. data/lib/wx/core/notebook.rb +9 -0
  81. data/lib/wx/core/object.rb +9 -0
  82. data/lib/wx/core/paintdc.rb +7 -0
  83. data/lib/wx/core/pen.rb +7 -0
  84. data/lib/wx/core/pen_info.rb +7 -0
  85. data/lib/wx/core/platform_info.rb +7 -0
  86. data/lib/wx/core/point.rb +8 -0
  87. data/lib/wx/core/real_point.rb +8 -0
  88. data/lib/wx/core/rect.rb +9 -0
  89. data/lib/wx/core/region_iterator.rb +7 -0
  90. data/lib/wx/core/simplehelpprovider.rb +9 -0
  91. data/lib/wx/core/size.rb +8 -0
  92. data/lib/wx/core/sizer.rb +9 -0
  93. data/lib/wx/core/splash_screen.rb +22 -2
  94. data/lib/wx/core/text_entry.rb +7 -0
  95. data/lib/wx/core/textctrl.rb +86 -5
  96. data/lib/wx/core/timer.rb +9 -0
  97. data/lib/wx/core/toolbar.rb +9 -0
  98. data/lib/wx/core/toolbartool.rb +8 -0
  99. data/lib/wx/core/treectrl.rb +9 -0
  100. data/lib/wx/core/v_list_box.rb +7 -0
  101. data/lib/wx/core/validator.rb +7 -0
  102. data/lib/wx/core/variant.rb +7 -0
  103. data/lib/wx/core/vboxsizer.rb +16 -0
  104. data/lib/wx/core/window.rb +8 -0
  105. data/lib/wx/core/window_update_locker.rb +9 -0
  106. data/lib/wx/core/xmlresource.rb +8 -0
  107. data/lib/wx/core.rb +4 -1
  108. data/lib/wx/doc/app.rb +7 -1
  109. data/lib/wx/doc/array_ext.rb +6 -0
  110. data/lib/wx/doc/art_locator.rb +7 -0
  111. data/lib/wx/doc/aui/auimanager.rb +6 -0
  112. data/lib/wx/doc/aui/auinotebook.rb +6 -0
  113. data/lib/wx/doc/bitmap.rb +12 -4
  114. data/lib/wx/doc/brush.rb +6 -0
  115. data/lib/wx/doc/busy_info.rb +6 -0
  116. data/lib/wx/doc/client_dc.rb +6 -0
  117. data/lib/wx/doc/clipboard.rb +6 -0
  118. data/lib/wx/doc/colour_dialog.rb +6 -0
  119. data/lib/wx/doc/config.rb +190 -0
  120. data/lib/wx/doc/const.rb +73 -66
  121. data/lib/wx/doc/controlwithitems.rb +6 -0
  122. data/lib/wx/doc/core.rb +6 -0
  123. data/lib/wx/doc/cursor.rb +13 -5
  124. data/lib/wx/doc/data_object.rb +6 -0
  125. data/lib/wx/doc/datetime.rb +16 -0
  126. data/lib/wx/doc/dc.rb +6 -0
  127. data/lib/wx/doc/enum.rb +8 -1
  128. data/lib/wx/doc/event.rb +6 -0
  129. data/lib/wx/doc/event_blocker.rb +6 -0
  130. data/lib/wx/doc/event_loop.rb +6 -0
  131. data/lib/wx/doc/events.rb +6 -0
  132. data/lib/wx/doc/evthandler.rb +8 -0
  133. data/lib/wx/doc/extra/01_packages.md +52 -51
  134. data/lib/wx/doc/extra/05_event-handling.md +37 -12
  135. data/lib/wx/doc/extra/06_geometry.md +5 -5
  136. data/lib/wx/doc/extra/07_colour_and_font.md +2 -2
  137. data/lib/wx/doc/extra/09_exceptions.md +1 -1
  138. data/lib/wx/doc/extra/10_art.md +18 -12
  139. data/lib/wx/doc/extra/11_drawing_and_dc.md +4 -4
  140. data/lib/wx/doc/font.rb +6 -0
  141. data/lib/wx/doc/font_data.rb +16 -0
  142. data/lib/wx/doc/functions.rb +18 -10
  143. data/lib/wx/doc/gc_dc.rb +6 -0
  144. data/lib/wx/doc/gdi_common.rb +8 -1
  145. data/lib/wx/doc/gen/about_dialog_info.rb +9 -9
  146. data/lib/wx/doc/gen/accelerator.rb +4 -9
  147. data/lib/wx/doc/gen/accessible.rb +21 -21
  148. data/lib/wx/doc/gen/activity_indicator.rb +4 -4
  149. data/lib/wx/doc/gen/animation.rb +13 -13
  150. data/lib/wx/doc/gen/animation_ctrl.rb +9 -9
  151. data/lib/wx/doc/gen/any_button.rb +2 -2
  152. data/lib/wx/doc/gen/app.rb +16 -85
  153. data/lib/wx/doc/gen/app_traits.rb +381 -0
  154. data/lib/wx/doc/gen/art_provider.rb +4 -4
  155. data/lib/wx/doc/gen/aui/aui_manager.rb +12 -14
  156. data/lib/wx/doc/gen/aui/aui_manager_event.rb +5 -5
  157. data/lib/wx/doc/gen/aui/aui_mdi_child_frame.rb +15 -16
  158. data/lib/wx/doc/gen/aui/aui_mdi_client_window.rb +1 -1
  159. data/lib/wx/doc/gen/aui/aui_mdi_parent_frame.rb +4 -4
  160. data/lib/wx/doc/gen/aui/aui_notebook.rb +102 -19
  161. data/lib/wx/doc/gen/aui/aui_notebook_event.rb +1 -1
  162. data/lib/wx/doc/gen/aui/aui_pane_info.rb +44 -44
  163. data/lib/wx/doc/gen/aui/aui_tab_art.rb +11 -11
  164. data/lib/wx/doc/gen/aui/aui_tool_bar.rb +28 -28
  165. data/lib/wx/doc/gen/aui/aui_tool_bar_art.rb +2 -2
  166. data/lib/wx/doc/gen/aui/aui_tool_bar_event.rb +3 -3
  167. data/lib/wx/doc/gen/aui/aui_tool_bar_item.rb +7 -7
  168. data/lib/wx/doc/gen/aui/event_list.rb +7 -0
  169. data/lib/wx/doc/gen/banner_window.rb +98 -0
  170. data/lib/wx/doc/gen/bitmap.rb +26 -57
  171. data/lib/wx/doc/gen/bitmap_button.rb +5 -5
  172. data/lib/wx/doc/gen/bitmap_combo_box.rb +6 -6
  173. data/lib/wx/doc/gen/book_ctrl_base.rb +13 -13
  174. data/lib/wx/doc/gen/book_ctrl_event.rb +1 -1
  175. data/lib/wx/doc/gen/brush.rb +8 -8
  176. data/lib/wx/doc/gen/button.rb +6 -6
  177. data/lib/wx/doc/gen/calendar_ctrl.rb +12 -12
  178. data/lib/wx/doc/gen/calendar_date_attr.rb +11 -11
  179. data/lib/wx/doc/gen/calendar_event.rb +2 -8
  180. data/lib/wx/doc/gen/caret.rb +4 -4
  181. data/lib/wx/doc/gen/check_box.rb +11 -11
  182. data/lib/wx/doc/gen/check_list_box.rb +7 -7
  183. data/lib/wx/doc/gen/choice.rb +5 -5
  184. data/lib/wx/doc/gen/choicebook.rb +1 -1
  185. data/lib/wx/doc/gen/clipboard.rb +9 -9
  186. data/lib/wx/doc/gen/collapsible_pane.rb +6 -6
  187. data/lib/wx/doc/gen/collapsible_pane_event.rb +3 -3
  188. data/lib/wx/doc/gen/colour.rb +26 -26
  189. data/lib/wx/doc/gen/colour_dialog.rb +6 -6
  190. data/lib/wx/doc/gen/colour_picker_ctrl.rb +3 -3
  191. data/lib/wx/doc/gen/combo_box.rb +11 -11
  192. data/lib/wx/doc/gen/combo_ctrl.rb +960 -0
  193. data/lib/wx/doc/gen/command_link_button.rb +110 -0
  194. data/lib/wx/doc/gen/config_base.rb +10 -0
  195. data/lib/wx/doc/gen/context_help_button.rb +3 -3
  196. data/lib/wx/doc/gen/control.rb +5 -5
  197. data/lib/wx/doc/gen/control_with_items.rb +5 -5
  198. data/lib/wx/doc/gen/core.rb +6 -6
  199. data/lib/wx/doc/gen/cursor.rb +4 -9
  200. data/lib/wx/doc/gen/data_format.rb +3 -3
  201. data/lib/wx/doc/gen/data_object.rb +14 -14
  202. data/lib/wx/doc/gen/date_event.rb +1 -1
  203. data/lib/wx/doc/gen/date_picker_ctrl.rb +5 -5
  204. data/lib/wx/doc/gen/dc.rb +127 -64
  205. data/lib/wx/doc/gen/defs.rb +3 -3
  206. data/lib/wx/doc/gen/dial_up_event.rb +42 -0
  207. data/lib/wx/doc/gen/dial_up_manager.rb +129 -0
  208. data/lib/wx/doc/gen/dialog.rb +48 -19
  209. data/lib/wx/doc/gen/dir_filter_list_ctrl.rb +1 -1
  210. data/lib/wx/doc/gen/dir_picker_ctrl.rb +5 -5
  211. data/lib/wx/doc/gen/drag_drop.rb +18 -44
  212. data/lib/wx/doc/gen/drag_image.rb +7 -32
  213. data/lib/wx/doc/gen/editable_list_box.rb +4 -4
  214. data/lib/wx/doc/gen/event.rb +22 -24
  215. data/lib/wx/doc/gen/event_blocker.rb +1 -1
  216. data/lib/wx/doc/gen/event_list.rb +133 -7
  217. data/lib/wx/doc/gen/events.rb +162 -166
  218. data/lib/wx/doc/gen/evt_handler.rb +7 -7
  219. data/lib/wx/doc/gen/ext_help_controller.rb +8 -8
  220. data/lib/wx/doc/gen/file_ctrl.rb +200 -0
  221. data/lib/wx/doc/gen/file_ctrl_event.rb +80 -0
  222. data/lib/wx/doc/gen/file_dialog.rb +5 -3
  223. data/lib/wx/doc/gen/file_dialog_custom_control.rb +146 -0
  224. data/lib/wx/doc/gen/file_dialog_customize_hook.rb +159 -0
  225. data/lib/wx/doc/gen/file_dir_picker_event.rb +1 -1
  226. data/lib/wx/doc/gen/file_picker_ctrl.rb +5 -5
  227. data/lib/wx/doc/gen/file_system.rb +250 -0
  228. data/lib/wx/doc/gen/find_dialog_event.rb +1 -1
  229. data/lib/wx/doc/gen/find_replace_dialog.rb +1 -1
  230. data/lib/wx/doc/gen/flex_grid_sizer.rb +4 -4
  231. data/lib/wx/doc/gen/font.rb +61 -66
  232. data/lib/wx/doc/gen/font_data.rb +6 -6
  233. data/lib/wx/doc/gen/font_dialog.rb +2 -2
  234. data/lib/wx/doc/gen/font_picker_ctrl.rb +3 -3
  235. data/lib/wx/doc/gen/frame.rb +10 -24
  236. data/lib/wx/doc/gen/fs_file.rb +61 -21
  237. data/lib/wx/doc/gen/gauge.rb +5 -5
  238. data/lib/wx/doc/gen/gb_sizer_item.rb +12 -26
  239. data/lib/wx/doc/gen/gdi_common.rb +8 -8
  240. data/lib/wx/doc/gen/generic_dir_ctrl.rb +8 -8
  241. data/lib/wx/doc/gen/graphics_context.rb +291 -60
  242. data/lib/wx/doc/gen/graphics_object.rb +47 -101
  243. data/lib/wx/doc/gen/grid/grid_cell_activatable_editor.rb +2 -0
  244. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +36 -51
  245. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_editor.rb +2 -0
  246. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_renderer.rb +2 -0
  247. data/lib/wx/doc/gen/grid/grid_cell_bool_editor.rb +3 -1
  248. data/lib/wx/doc/gen/grid/grid_cell_bool_renderer.rb +2 -0
  249. data/lib/wx/doc/gen/grid/grid_cell_choice_editor.rb +7 -12
  250. data/lib/wx/doc/gen/grid/grid_cell_date_editor.rb +2 -0
  251. data/lib/wx/doc/gen/grid/grid_cell_date_renderer.rb +2 -0
  252. data/lib/wx/doc/gen/grid/grid_cell_date_time_renderer.rb +3 -1
  253. data/lib/wx/doc/gen/grid/grid_cell_editor.rb +6 -4
  254. data/lib/wx/doc/gen/grid/grid_cell_enum_editor.rb +2 -0
  255. data/lib/wx/doc/gen/grid/grid_cell_enum_renderer.rb +2 -0
  256. data/lib/wx/doc/gen/grid/grid_cell_float_editor.rb +2 -0
  257. data/lib/wx/doc/gen/grid/grid_cell_float_renderer.rb +2 -0
  258. data/lib/wx/doc/gen/grid/grid_cell_number_editor.rb +2 -0
  259. data/lib/wx/doc/gen/grid/grid_cell_number_renderer.rb +2 -0
  260. data/lib/wx/doc/gen/grid/grid_cell_renderer.rb +3 -1
  261. data/lib/wx/doc/gen/grid/grid_cell_string_renderer.rb +2 -0
  262. data/lib/wx/doc/gen/grid/grid_cell_text_editor.rb +2 -0
  263. data/lib/wx/doc/gen/grid/grid_ctrl.rb +416 -173
  264. data/lib/wx/doc/gen/grid/grid_editor_created_event.rb +1 -1
  265. data/lib/wx/doc/gen/grid/grid_event.rb +7 -7
  266. data/lib/wx/doc/gen/grid/grid_range_select_event.rb +9 -9
  267. data/lib/wx/doc/gen/grid/grid_size_event.rb +5 -5
  268. data/lib/wx/doc/gen/grid/grid_string_table.rb +6 -6
  269. data/lib/wx/doc/gen/grid/grid_table_base.rb +15 -15
  270. data/lib/wx/doc/gen/grid_bag_sizer.rb +10 -10
  271. data/lib/wx/doc/gen/gui_event_loop.rb +12 -12
  272. data/lib/wx/doc/gen/header_ctrl.rb +755 -0
  273. data/lib/wx/doc/gen/header_ctrl_event.rb +131 -0
  274. data/lib/wx/doc/gen/help_controller.rb +46 -7
  275. data/lib/wx/doc/gen/help_provider.rb +3 -3
  276. data/lib/wx/doc/gen/html/html_cell.rb +67 -44
  277. data/lib/wx/doc/gen/html/html_cell_event.rb +3 -3
  278. data/lib/wx/doc/gen/html/html_easy_printing.rb +6 -6
  279. data/lib/wx/doc/gen/html/html_help_controller.rb +79 -52
  280. data/lib/wx/doc/gen/html/html_help_data.rb +2 -2
  281. data/lib/wx/doc/gen/html/html_help_window.rb +21 -27
  282. data/lib/wx/doc/gen/html/html_list_box.rb +11 -11
  283. data/lib/wx/doc/gen/html/html_printout.rb +1 -1
  284. data/lib/wx/doc/gen/html/html_window.rb +36 -32
  285. data/lib/wx/doc/gen/hyperlink_ctrl.rb +5 -5
  286. data/lib/wx/doc/gen/icon.rb +10 -10
  287. data/lib/wx/doc/gen/icon_location.rb +1 -1
  288. data/lib/wx/doc/gen/image.rb +46 -51
  289. data/lib/wx/doc/gen/image_list.rb +14 -24
  290. data/lib/wx/doc/gen/info_bar.rb +152 -0
  291. data/lib/wx/doc/gen/keyboard_state.rb +17 -17
  292. data/lib/wx/doc/gen/list_box.rb +24 -24
  293. data/lib/wx/doc/gen/list_ctrl.rb +61 -96
  294. data/lib/wx/doc/gen/list_event.rb +2 -2
  295. data/lib/wx/doc/gen/listbook.rb +1 -1
  296. data/lib/wx/doc/gen/locale.rb +15 -39
  297. data/lib/wx/doc/gen/log.rb +17 -67
  298. data/lib/wx/doc/gen/mdi_client_window.rb +1 -1
  299. data/lib/wx/doc/gen/mdi_frame.rb +12 -12
  300. data/lib/wx/doc/gen/media_ctrl.rb +17 -17
  301. data/lib/wx/doc/gen/media_event.rb +1 -1
  302. data/lib/wx/doc/gen/memory_dc.rb +3 -6
  303. data/lib/wx/doc/gen/menu.rb +15 -16
  304. data/lib/wx/doc/gen/menu_bar.rb +9 -26
  305. data/lib/wx/doc/gen/menu_item.rb +88 -88
  306. data/lib/wx/doc/gen/message_dialog.rb +6 -6
  307. data/lib/wx/doc/gen/mini_frame.rb +4 -4
  308. data/lib/wx/doc/gen/mouse_state.rb +50 -10
  309. data/lib/wx/doc/gen/non_owned_window.rb +2 -2
  310. data/lib/wx/doc/gen/notebook.rb +9 -9
  311. data/lib/wx/doc/gen/number_entry_dialog.rb +1 -1
  312. data/lib/wx/doc/gen/object.rb +1 -12
  313. data/lib/wx/doc/gen/palette.rb +12 -14
  314. data/lib/wx/doc/gen/panel.rb +6 -6
  315. data/lib/wx/doc/gen/pen.rb +25 -25
  316. data/lib/wx/doc/gen/pg/numeric_property_validator.rb +2 -2
  317. data/lib/wx/doc/gen/pg/pg_array_editor_dialog.rb +14 -14
  318. data/lib/wx/doc/gen/pg/pg_cell.rb +3 -6
  319. data/lib/wx/doc/gen/pg/pg_editor.rb +19 -19
  320. data/lib/wx/doc/gen/pg/pg_multi_button.rb +61 -86
  321. data/lib/wx/doc/gen/pg/pg_properties.rb +210 -263
  322. data/lib/wx/doc/gen/pg/pg_property.rb +161 -257
  323. data/lib/wx/doc/gen/pg/pg_validation_info.rb +2 -2
  324. data/lib/wx/doc/gen/pg/property_grid.rb +32 -32
  325. data/lib/wx/doc/gen/pg/property_grid_event.rb +7 -7
  326. data/lib/wx/doc/gen/pg/property_grid_interface.rb +43 -49
  327. data/lib/wx/doc/gen/pg/property_grid_manager.rb +41 -44
  328. data/lib/wx/doc/gen/pg/property_grid_page.rb +11 -20
  329. data/lib/wx/doc/gen/pg/property_grid_page_state.rb +10 -19
  330. data/lib/wx/doc/gen/picker_base.rb +5 -5
  331. data/lib/wx/doc/gen/platform_info.rb +174 -14
  332. data/lib/wx/doc/gen/popup_window.rb +2 -2
  333. data/lib/wx/doc/gen/progress_dialog.rb +2 -2
  334. data/lib/wx/doc/gen/property_sheet_dialog.rb +3 -3
  335. data/lib/wx/doc/gen/prt/preview_frame.rb +14 -1
  336. data/lib/wx/doc/gen/prt/print_abort_dialog.rb +1 -1
  337. data/lib/wx/doc/gen/prt/print_data.rb +44 -44
  338. data/lib/wx/doc/gen/prt/printer.rb +23 -28
  339. data/lib/wx/doc/gen/query_layout_info_event.rb +4 -4
  340. data/lib/wx/doc/gen/radio_box.rb +13 -13
  341. data/lib/wx/doc/gen/radio_button.rb +7 -7
  342. data/lib/wx/doc/gen/rbn/ribbon_art_provider.rb +28 -28
  343. data/lib/wx/doc/gen/rbn/ribbon_bar.rb +13 -13
  344. data/lib/wx/doc/gen/rbn/ribbon_bar_event.rb +1 -1
  345. data/lib/wx/doc/gen/rbn/ribbon_button_bar.rb +13 -13
  346. data/lib/wx/doc/gen/rbn/ribbon_button_bar_event.rb +2 -2
  347. data/lib/wx/doc/gen/rbn/ribbon_control.rb +8 -8
  348. data/lib/wx/doc/gen/rbn/ribbon_gallery.rb +8 -14
  349. data/lib/wx/doc/gen/rbn/ribbon_gallery_event.rb +1 -1
  350. data/lib/wx/doc/gen/rbn/ribbon_page.rb +7 -7
  351. data/lib/wx/doc/gen/rbn/ribbon_panel.rb +12 -16
  352. data/lib/wx/doc/gen/rbn/ribbon_panel_event.rb +1 -1
  353. data/lib/wx/doc/gen/rbn/ribbon_tool_bar.rb +13 -13
  354. data/lib/wx/doc/gen/rbn/ribbon_tool_bar_event.rb +2 -2
  355. data/lib/wx/doc/gen/rearrange_ctrl.rb +60 -0
  356. data/lib/wx/doc/gen/rearrange_list.rb +99 -0
  357. data/lib/wx/doc/gen/region.rb +26 -35
  358. data/lib/wx/doc/gen/region_iterator.rb +1 -1
  359. data/lib/wx/doc/gen/rtc/rich_text_box.rb +423 -0
  360. data/lib/wx/doc/gen/rtc/rich_text_buffer.rb +608 -1520
  361. data/lib/wx/doc/gen/rtc/rich_text_buffer_data_object.rb +37 -0
  362. data/lib/wx/doc/gen/rtc/rich_text_composite_object.rb +525 -0
  363. data/lib/wx/doc/gen/rtc/rich_text_ctrl.rb +437 -474
  364. data/lib/wx/doc/gen/rtc/rich_text_event.rb +9 -9
  365. data/lib/wx/doc/gen/rtc/rich_text_file_handler.rb +13 -13
  366. data/lib/wx/doc/gen/rtc/rich_text_formatting_dialog.rb +282 -0
  367. data/lib/wx/doc/gen/rtc/rich_text_header_footer_data.rb +14 -14
  368. data/lib/wx/doc/gen/rtc/rich_text_html_handler.rb +3 -16
  369. data/lib/wx/doc/gen/rtc/rich_text_image.rb +328 -0
  370. data/lib/wx/doc/gen/rtc/rich_text_object.rb +2849 -0
  371. data/lib/wx/doc/gen/rtc/rich_text_paragraph_layout_box.rb +1174 -0
  372. data/lib/wx/doc/gen/rtc/rich_text_printing.rb +18 -18
  373. data/lib/wx/doc/gen/rtc/rich_text_style_list_box.rb +305 -0
  374. data/lib/wx/doc/gen/rtc/rich_text_style_organiser_dialog.rb +183 -0
  375. data/lib/wx/doc/gen/rtc/rich_text_xml_handler.rb +3 -3
  376. data/lib/wx/doc/gen/rtc/symbol_picker_dialog.rb +34 -37
  377. data/lib/wx/doc/gen/sash_event.rb +8 -5
  378. data/lib/wx/doc/gen/sash_layout_window.rb +10 -10
  379. data/lib/wx/doc/gen/sash_window.rb +7 -7
  380. data/lib/wx/doc/gen/scroll_bar.rb +6 -6
  381. data/lib/wx/doc/gen/scrolled_canvas.rb +12 -18
  382. data/lib/wx/doc/gen/scrolled_control.rb +12 -18
  383. data/lib/wx/doc/gen/scrolled_window.rb +12 -18
  384. data/lib/wx/doc/gen/search_ctrl.rb +7 -7
  385. data/lib/wx/doc/gen/simplebook.rb +5 -5
  386. data/lib/wx/doc/gen/single_choice_dialog.rb +1 -2
  387. data/lib/wx/doc/gen/sizer.rb +40 -45
  388. data/lib/wx/doc/gen/sizer_item.rb +5 -5
  389. data/lib/wx/doc/gen/slider.rb +4 -4
  390. data/lib/wx/doc/gen/spin_button.rb +3 -3
  391. data/lib/wx/doc/gen/spin_ctrl.rb +3 -3
  392. data/lib/wx/doc/gen/spin_ctrl_double.rb +146 -0
  393. data/lib/wx/doc/gen/spin_double_event.rb +53 -0
  394. data/lib/wx/doc/gen/spin_event.rb +1 -1
  395. data/lib/wx/doc/gen/splitter_event.rb +1 -1
  396. data/lib/wx/doc/gen/splitter_window.rb +18 -14
  397. data/lib/wx/doc/gen/static_bitmap.rb +6 -6
  398. data/lib/wx/doc/gen/static_box.rb +11 -11
  399. data/lib/wx/doc/gen/static_line.rb +5 -5
  400. data/lib/wx/doc/gen/static_text.rb +5 -5
  401. data/lib/wx/doc/gen/status_bar.rb +41 -7
  402. data/lib/wx/doc/gen/stc/styled_text_ctrl.rb +148 -180
  403. data/lib/wx/doc/gen/stc/styled_text_event.rb +6 -6
  404. data/lib/wx/doc/gen/svg_file_dc.rb +5 -5
  405. data/lib/wx/doc/gen/system_options.rb +2 -2
  406. data/lib/wx/doc/gen/system_settings.rb +6 -6
  407. data/lib/wx/doc/gen/task_bar_icon.rb +7 -7
  408. data/lib/wx/doc/gen/task_bar_icon_event.rb +1 -1
  409. data/lib/wx/doc/gen/text_attr.rb +56 -54
  410. data/lib/wx/doc/gen/text_ctrl.rb +15 -39
  411. data/lib/wx/doc/gen/text_entry.rb +16 -16
  412. data/lib/wx/doc/gen/text_entry_dialog.rb +4 -4
  413. data/lib/wx/doc/gen/text_validator.rb +3 -8
  414. data/lib/wx/doc/gen/time_picker_ctrl.rb +5 -5
  415. data/lib/wx/doc/gen/timer.rb +5 -5
  416. data/lib/wx/doc/gen/tip_provider.rb +2 -2
  417. data/lib/wx/doc/gen/toggle_button.rb +6 -6
  418. data/lib/wx/doc/gen/tool_bar.rb +32 -39
  419. data/lib/wx/doc/gen/tool_tip.rb +1 -9
  420. data/lib/wx/doc/gen/toolbook.rb +6 -6
  421. data/lib/wx/doc/gen/top_level_window.rb +27 -97
  422. data/lib/wx/doc/gen/tree_ctrl.rb +22 -22
  423. data/lib/wx/doc/gen/tree_event.rb +2 -2
  424. data/lib/wx/doc/gen/treebook.rb +14 -14
  425. data/lib/wx/doc/gen/ui_action_simulator.rb +19 -18
  426. data/lib/wx/doc/gen/utils.rb +12 -12
  427. data/lib/wx/doc/gen/v_list_box.rb +11 -11
  428. data/lib/wx/doc/gen/v_scrolled_window.rb +9 -9
  429. data/lib/wx/doc/gen/validator.rb +3 -3
  430. data/lib/wx/doc/gen/variant.rb +22 -22
  431. data/lib/wx/doc/gen/window.rb +162 -127
  432. data/lib/wx/doc/gen/with_images.rb +1 -1
  433. data/lib/wx/doc/gen/wizard.rb +4 -4
  434. data/lib/wx/doc/gen/wizard_event.rb +3 -3
  435. data/lib/wx/doc/gen/wizard_page.rb +2 -2
  436. data/lib/wx/doc/gen/wizard_page_simple.rb +1 -1
  437. data/lib/wx/doc/gen/wrap_sizer.rb +65 -0
  438. data/lib/wx/doc/gen/xml_node.rb +10 -10
  439. data/lib/wx/doc/gen/xml_resource.rb +12 -12
  440. data/lib/wx/doc/graphics_context.rb +59 -39
  441. data/lib/wx/doc/grid/grid.rb +16 -1
  442. data/lib/wx/doc/hboxsizer.rb +33 -0
  443. data/lib/wx/doc/help_controller.rb +6 -0
  444. data/lib/wx/doc/html/html_help_controller.rb +6 -0
  445. data/lib/wx/doc/icon.rb +13 -5
  446. data/lib/wx/doc/id_helper.rb +6 -0
  447. data/lib/wx/doc/image.rb +12 -4
  448. data/lib/wx/doc/list_ctrl.rb +6 -0
  449. data/lib/wx/doc/log.rb +17 -0
  450. data/lib/wx/doc/memory_dc.rb +6 -0
  451. data/lib/wx/doc/mirror_dc.rb +6 -0
  452. data/lib/wx/doc/pen.rb +6 -0
  453. data/lib/wx/doc/pg/events.rb +6 -0
  454. data/lib/wx/doc/pg/pg_property.rb +17 -0
  455. data/lib/wx/doc/pg/pgeditor.rb +6 -0
  456. data/lib/wx/doc/pg/property_grid.rb +6 -0
  457. data/lib/wx/doc/pg/property_grid_interface.rb +6 -0
  458. data/lib/wx/doc/progress_dialog.rb +6 -0
  459. data/lib/wx/doc/prt/page_setup_dialog.rb +6 -0
  460. data/lib/wx/doc/prt/print_data.rb +6 -0
  461. data/lib/wx/doc/prt/print_dialog.rb +6 -0
  462. data/lib/wx/doc/prt/printer.rb +6 -0
  463. data/lib/wx/doc/prt/printer_dc.rb +6 -0
  464. data/lib/wx/doc/radio_box.rb +6 -0
  465. data/lib/wx/doc/rbn/ribbon_bar.rb +6 -0
  466. data/lib/wx/doc/rbn/ribbon_button_bar.rb +6 -0
  467. data/lib/wx/doc/rbn/ribbon_gallery.rb +6 -0
  468. data/lib/wx/doc/rbn/ribbon_tool_bar.rb +6 -0
  469. data/lib/wx/doc/region_iterator.rb +6 -0
  470. data/lib/wx/doc/rtc/richtext_buffer.rb +28 -0
  471. data/lib/wx/doc/rtc/richtext_formatting_dialog.rb +68 -0
  472. data/lib/wx/doc/rtc/richtext_printing.rb +6 -0
  473. data/lib/wx/doc/rtc/richtext_style_sheet.rb +20 -0
  474. data/lib/wx/doc/scaled_dc.rb +6 -0
  475. data/lib/wx/doc/screen_dc.rb +6 -0
  476. data/lib/wx/doc/stock_objects.rb +6 -0
  477. data/lib/wx/doc/stream.rb +6 -0
  478. data/lib/wx/doc/svg_file_dc.rb +6 -0
  479. data/lib/wx/doc/system_settings.rb +6 -0
  480. data/lib/wx/doc/text_validator.rb +6 -0
  481. data/lib/wx/doc/textctrl.rb +89 -0
  482. data/lib/wx/doc/tree_event.rb +20 -0
  483. data/lib/wx/doc/treebook.rb +6 -0
  484. data/lib/wx/doc/v_list_box.rb +6 -0
  485. data/lib/wx/doc/variant.rb +6 -0
  486. data/lib/wx/doc/vboxsizer.rb +33 -0
  487. data/lib/wx/doc/window.rb +11 -0
  488. data/lib/wx/doc/window_disabler.rb +6 -0
  489. data/lib/wx/doc/xml_resource.rb +8 -0
  490. data/lib/wx/global_const.rb +4 -1
  491. data/lib/wx/grid/grid.rb +23 -3
  492. data/lib/wx/grid/keyword_defs.rb +8 -1
  493. data/lib/wx/grid/require.rb +4 -1
  494. data/lib/wx/grid.rb +4 -1
  495. data/lib/wx/helpers.rb +8 -1
  496. data/lib/wx/html/htmlhelpcontroller.rb +29 -3
  497. data/lib/wx/html/htmlwindow.rb +23 -12
  498. data/lib/wx/html/keyword_defs.rb +8 -1
  499. data/lib/wx/html/require.rb +4 -1
  500. data/lib/wx/html/simple_html_listbox.rb +3 -0
  501. data/lib/wx/html.rb +4 -1
  502. data/lib/wx/keyword_ctors.rb +22 -3
  503. data/lib/wx/keyword_defs.rb +96 -7
  504. data/lib/wx/pg/events.rb +4 -1
  505. data/lib/wx/pg/keyword_defs.rb +8 -1
  506. data/lib/wx/pg/pg_editor.rb +3 -0
  507. data/lib/wx/pg/pg_properties.rb +4 -1
  508. data/lib/wx/pg/pg_property.rb +18 -5
  509. data/lib/wx/pg/property_grid.rb +4 -1
  510. data/lib/wx/pg/property_grid_interface.rb +3 -0
  511. data/lib/wx/pg/require.rb +4 -1
  512. data/lib/wx/pg.rb +4 -1
  513. data/lib/wx/prt/keyword_defs.rb +8 -1
  514. data/lib/wx/prt/page_setup_dialog.rb +3 -0
  515. data/lib/wx/prt/previewframe.rb +5 -0
  516. data/lib/wx/prt/require.rb +4 -1
  517. data/lib/wx/prt.rb +4 -1
  518. data/lib/wx/rbn/events.rb +4 -1
  519. data/lib/wx/rbn/keyword_defs.rb +8 -1
  520. data/lib/wx/rbn/require.rb +5 -1
  521. data/lib/wx/rbn/ribbon_art_provider.rb +3 -1
  522. data/lib/wx/rbn/ribbon_bar.rb +3 -0
  523. data/lib/wx/rbn/ribbon_button_bar.rb +3 -0
  524. data/lib/wx/rbn/ribbon_control.rb +3 -0
  525. data/lib/wx/rbn/ribbon_gallery.rb +10 -0
  526. data/lib/wx/rbn/ribbon_page.rb +3 -0
  527. data/lib/wx/rbn/ribbon_panel.rb +3 -0
  528. data/lib/wx/rbn/ribbon_tool_bar.rb +3 -0
  529. data/lib/wx/rbn.rb +4 -1
  530. data/lib/wx/rtc/ext.rb +4 -1
  531. data/lib/wx/rtc/keyword_defs.rb +18 -7
  532. data/lib/wx/rtc/require.rb +8 -1
  533. data/lib/wx/rtc/richtext_buffer.rb +36 -0
  534. data/lib/wx/rtc/richtext_formatting_dialog.rb +88 -0
  535. data/lib/wx/rtc/richtext_style_organiser_dialog.rb +46 -0
  536. data/lib/wx/rtc/symbol_picker_dialog.rb +47 -0
  537. data/lib/wx/rtc.rb +5 -1
  538. data/lib/wx/stc/keyword_defs.rb +8 -1
  539. data/lib/wx/stc/require.rb +4 -1
  540. data/lib/wx/stc.rb +4 -1
  541. data/lib/wx/version.rb +5 -1
  542. data/lib/wx/wxruby/base.rb +4 -1
  543. data/lib/wx/wxruby/cmd/sampler.rb +4 -1
  544. data/lib/wx/wxruby/cmd/test.rb +4 -1
  545. data/lib/wx.rb +4 -1
  546. data/lib/wxruby_aui.so +0 -0
  547. data/lib/wxruby_core.so +0 -0
  548. data/lib/wxruby_grid.so +0 -0
  549. data/lib/wxruby_html.so +0 -0
  550. data/lib/wxruby_pg.so +0 -0
  551. data/lib/wxruby_prt.so +0 -0
  552. data/lib/wxruby_rbn.so +0 -0
  553. data/lib/wxruby_rtc.so +0 -0
  554. data/lib/wxruby_stc.so +0 -0
  555. data/rakelib/install.rb +4 -1
  556. data/rakelib/lib/config/cygwin.rb +4 -1
  557. data/rakelib/lib/config/linux.rb +4 -1
  558. data/rakelib/lib/config/macosx.rb +6 -3
  559. data/rakelib/lib/config/mingw.rb +4 -1
  560. data/rakelib/lib/config/netbsd.rb +4 -1
  561. data/rakelib/lib/config/unixish.rb +10 -7
  562. data/rakelib/lib/config.rb +7 -2
  563. data/rakelib/lib/ext/enum_chain.rb +4 -1
  564. data/rakelib/prepost.rake +4 -1
  565. data/rakelib/prepost.rb +4 -1
  566. data/samples/aui/aui.rb +8 -3
  567. data/samples/bigdemo/bigdemo.rb +9 -2
  568. data/samples/bigdemo/run.rb +9 -2
  569. data/samples/bigdemo/utils.rb +9 -1
  570. data/samples/calendar/calendar.rb +9 -4
  571. data/samples/caret/caret.rb +8 -3
  572. data/samples/controls/books.rb +8 -2
  573. data/samples/controls/controls.rb +33 -77
  574. data/samples/controls/get_item_sample.rb +8 -2
  575. data/samples/controls/htlbox.rb +10 -3
  576. data/samples/dialogs/dialogs.rb +9 -4
  577. data/samples/dialogs/wizard.rb +8 -3
  578. data/samples/dragdrop/dragdrop.rb +8 -3
  579. data/samples/drawing/bitmap.rb +8 -3
  580. data/samples/drawing/bitmap_image.rb +8 -3
  581. data/samples/drawing/graphics_drawing.rb +44 -33
  582. data/samples/drawing/image_prt.rb +8 -2
  583. data/samples/drawing/maths_images.rb +8 -3
  584. data/samples/drawing/rmagic_bitmap_image.rb +8 -3
  585. data/samples/etc/choice.rb +8 -3
  586. data/samples/etc/miniframe.rb +8 -3
  587. data/samples/etc/sash.rb +8 -3
  588. data/samples/etc/scrollwin.rb +8 -3
  589. data/samples/etc/system_settings.rb +8 -3
  590. data/samples/event/activation.rb +8 -3
  591. data/samples/event/event.rb +8 -3
  592. data/samples/event/threaded.rb +8 -3
  593. data/samples/event/update_ui_event.rb +8 -3
  594. data/samples/grid/grid.rb +9 -3
  595. data/samples/grid/gridtablebase.rb +8 -3
  596. data/samples/html/html.rb +8 -3
  597. data/samples/mdi/mdi.rb +8 -3
  598. data/samples/minimal/minimal.rb +8 -3
  599. data/samples/minimal/nothing.rb +8 -3
  600. data/samples/printing/printing.rb +8 -3
  601. data/samples/printing/printing2.rb +8 -2
  602. data/samples/propgrid/propgrid.rb +4 -1
  603. data/samples/propgrid/propgrid_minimal.rb +4 -2
  604. data/samples/propgrid/sample_props.rb +4 -1
  605. data/samples/ribbon/ribbon.rb +4 -1
  606. data/samples/sampler/editor.rb +4 -1
  607. data/samples/sampler/ext.rb +4 -1
  608. data/samples/sampler/sample.rb +13 -4
  609. data/samples/sampler/stc_editor.rb +4 -1
  610. data/samples/sampler/txt_editor.rb +4 -1
  611. data/samples/sampler.rb +11 -3
  612. data/samples/splash/splash.rb +4 -2
  613. data/samples/text/art/richtext/alignleft.xpm +24 -0
  614. data/samples/text/art/richtext/alignright.xpm +24 -0
  615. data/samples/text/art/richtext/bold.xpm +24 -0
  616. data/samples/text/art/richtext/centre.xpm +24 -0
  617. data/samples/text/art/richtext/copy.xpm +45 -0
  618. data/samples/text/art/richtext/cut.xpm +47 -0
  619. data/samples/text/art/richtext/font.xpm +25 -0
  620. data/samples/text/art/richtext/idea.xpm +47 -0
  621. data/samples/text/art/richtext/indentless.xpm +25 -0
  622. data/samples/text/art/richtext/indentmore.xpm +25 -0
  623. data/samples/text/art/richtext/italic.xpm +25 -0
  624. data/samples/text/art/richtext/open.xpm +58 -0
  625. data/samples/text/art/richtext/paste.xpm +47 -0
  626. data/samples/text/art/richtext/redo.xpm +59 -0
  627. data/samples/text/art/richtext/save.xpm +43 -0
  628. data/samples/text/art/richtext/smiley.xpm +42 -0
  629. data/samples/text/art/richtext/underline.xpm +25 -0
  630. data/samples/text/art/richtext/undo.xpm +59 -0
  631. data/samples/text/art/richtext/zebra.xpm +409 -0
  632. data/samples/text/rich_textctrl.rb +8 -3
  633. data/samples/text/richtext.rb +1794 -0
  634. data/samples/text/scintilla.rb +8 -3
  635. data/samples/text/textctrl.rb +21 -4
  636. data/samples/text/tn_richtext.png +0 -0
  637. data/samples/text/unicode.rb +9 -4
  638. data/samples/treectrl/treectrl.rb +10 -5
  639. data/samples/xrc/custom_xrc_sample.rb +8 -3
  640. data/samples/xrc/xrc_sample.rb +8 -3
  641. data/tests/art/test_art/bitmap/wxruby-128x128.png +0 -0
  642. data/tests/art/test_art/bitmap/wxruby-256x256.png +0 -0
  643. data/tests/art/test_art/bitmap/wxruby-64x64.png +0 -0
  644. data/tests/lib/item_container_tests.rb +3 -0
  645. data/tests/lib/text_entry_tests.rb +3 -0
  646. data/tests/lib/wxapp_runner.rb +3 -0
  647. data/tests/lib/wxframe_runner.rb +81 -3
  648. data/tests/test_app_event_filter.rb +3 -0
  649. data/tests/test_app_exit_exception.rb +36 -0
  650. data/tests/test_app_init_exception.rb +20 -0
  651. data/tests/test_app_traits.rb +33 -0
  652. data/tests/test_art.rb +22 -0
  653. data/tests/test_art_provider.rb +3 -0
  654. data/tests/test_aui.rb +65 -0
  655. data/tests/test_basic.rb +5 -1
  656. data/tests/test_book_controls.rb +29 -0
  657. data/tests/test_box_sizer.rb +5 -2
  658. data/tests/test_clipboard.rb +3 -0
  659. data/tests/test_config.rb +150 -0
  660. data/tests/test_dc.rb +3 -0
  661. data/tests/test_dialog.rb +3 -0
  662. data/tests/test_event_handling.rb +3 -0
  663. data/tests/test_events.rb +3 -0
  664. data/tests/test_exceptions.rb +41 -0
  665. data/tests/test_ext_controls.rb +286 -3
  666. data/tests/test_file_dialog.rb +55 -0
  667. data/tests/test_font.rb +8 -5
  668. data/tests/test_gdi_object.rb +3 -0
  669. data/tests/test_geometry.rb +4 -0
  670. data/tests/test_grid_sizer.rb +7 -4
  671. data/tests/test_intl.rb +3 -0
  672. data/tests/test_item_data.rb +3 -0
  673. data/tests/test_list_ctrl.rb +4 -1
  674. data/tests/test_log.rb +63 -0
  675. data/tests/test_proof_check.rb +52 -0
  676. data/tests/test_richtext.rb +204 -0
  677. data/tests/test_sizer.rb +43 -0
  678. data/tests/test_std_controls.rb +81 -35
  679. data/tests/test_timer.rb +3 -0
  680. data/tests/test_variant.rb +3 -0
  681. data/tests/test_window.rb +10 -8
  682. data/tests/testapp.rb +4 -0
  683. data/tests/testapp_noframe.rb +4 -0
  684. metadata +86 -3
  685. data/lib/wx/doc/gen/html/html_help_frame.rb +0 -112
@@ -0,0 +1,1794 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+ #
5
+ # Adapted for wxRuby from wxWidgets richtext sample
6
+ # Copyright (c) Julian Smart
7
+
8
+ require 'wx'
9
+ require 'stringio'
10
+
11
+ # A custom field type
12
+ class RichTextFieldTypePropertiesTest < Wx::RTC::RichTextFieldTypeStandard
13
+
14
+ def initialize(name, label_or_bmp, displayStyle = Wx::RTC::RICHTEXT_FIELD_STYLE_RECTANGLE)
15
+ super(name, label_or_bmp, displayStyle)
16
+ end
17
+
18
+ def can_edit_properties(_obj); true; end
19
+
20
+ def edit_properties(_obj, _parent, _buffer)
21
+ label = get_label
22
+ Wx.message_box("Editing #{label}")
23
+ true
24
+ end
25
+
26
+ def get_properties_menu_label(_obj)
27
+ get_label
28
+ end
29
+
30
+ end
31
+
32
+ # A custom composite field type
33
+ class RichTextFieldTypeCompositeTest < RichTextFieldTypePropertiesTest
34
+
35
+ def initialize(name, label)
36
+ super(name, label, Wx::RTC::RICHTEXT_FIELD_STYLE_COMPOSITE)
37
+ end
38
+
39
+ def update_field(buffer, obj)
40
+ if buffer
41
+ attr = Wx::RTC::RichTextAttr.new(buffer.get_attributes)
42
+ attr.get_text_box_attr.reset
43
+ attr.set_paragraph_spacing_after(0)
44
+ attr.set_line_spacing(10)
45
+ obj.set_attributes(attr)
46
+ end
47
+ obj.delete_children
48
+ para = Wx::RTC::RichTextParagraph.new
49
+ text = Wx::RTC::RichTextPlainText.new(get_label)
50
+ para.append_child(text)
51
+ obj.append_child(para)
52
+ true
53
+ end
54
+
55
+ end
56
+
57
+ # ----------------------------------------------------------------------------
58
+ # private classes
59
+ # ----------------------------------------------------------------------------
60
+
61
+
62
+ class RichTextEnhancedDrawingHandler < Wx::RTC::RichTextDrawingHandler
63
+
64
+ def initialize(name = nil)
65
+ super("enhanceddrawing")
66
+ @lockBackgroundColour = Wx::Colour.new(220, 220, 220)
67
+ end
68
+
69
+ # Returns @true if this object has virtual attributes that we can provide.
70
+ def has_virtual_attributes(obj)
71
+ obj.get_properties.has_property("Lock")
72
+ end
73
+
74
+ # Provides virtual attributes that we can provide.
75
+ def get_virtual_attributes(attr, obj)
76
+ if obj.get_properties.has_property("Lock")
77
+ attr.set_background_colour(@lockBackgroundColour)
78
+ true
79
+ else
80
+ false
81
+ end
82
+ end
83
+
84
+ # Gets the count for mixed virtual attributes for individual positions within the object.
85
+ # For example, individual characters within a text object may require special highlighting.
86
+ def get_virtual_subobject_attributes_count(_obj); 0; end
87
+
88
+ # Gets the mixed virtual attributes for individual positions within the object.
89
+ # For example, individual characters within a text object may require special highlighting.
90
+ # Returns the number of virtual attributes found.
91
+ def get_virtual_subobject_attributes(_obj, _positions, _attributes); 0; end
92
+
93
+ # Do we have virtual text for this object? Virtual text allows an application
94
+ # to replace characters in an object for editing and display purposes, for example
95
+ # for highlighting special characters.
96
+ def has_virtual_text(_obj); false; end
97
+
98
+ # Gets the virtual text for this object.
99
+ def get_virtual_text(_obj, _text); false; end
100
+
101
+ end
102
+
103
+ # Define a new application type, each program should derive a class from wxApp
104
+ class MyRichTextCtrl < Wx::RTC::RichTextCtrl
105
+
106
+ def initialize(parent, id: Wx::ID_ANY, value: '', pos: Wx::DEFAULT_POSITION, size: Wx::DEFAULT_SIZE,
107
+ style: Wx::RTC::RE_MULTILINE, validator: Wx::DEFAULT_VALIDATOR, name: 'myRichTextCtrl')
108
+ super(parent, id: id, value: value, pos: pos, size: size, style: style, validator: validator, name: name)
109
+ @lockId = 0
110
+ @locked = false
111
+ end
112
+
113
+ attr_accessor :lockId
114
+
115
+ def begin_lock; @lockId += 1; @locked = true; end
116
+ def end_lock; @locked = false; end
117
+ def is_locked?; @locked; end
118
+
119
+ def self.set_enhanced_drawing_handler
120
+ Wx::RTC::RichTextBuffer::add_drawing_handler(RichTextEnhancedDrawingHandler.new)
121
+ end
122
+
123
+ # Prepares the content just before insertion (or after buffer reset). Called by the same function in wxRichTextBuffer.
124
+ # Currently is only called if undo mode is on.
125
+ def prepare_content(container)
126
+ if is_locked?
127
+ # Lock all content that's about to be added to the control
128
+ container.get_children.each do |child|
129
+ if child.is_a?(Wx::RTC::RichTextParagraph)
130
+ child.get_children.each do |obj|
131
+ obj.get_properties.set_property("Lock", @lockId)
132
+ end
133
+ end
134
+ end
135
+ end
136
+ end
137
+
138
+ # Can we delete this range?
139
+ # Sends an event to the control.
140
+ def can_delete_range(container, range)
141
+ Range.new(range.begin, range.end, true).each do |i|
142
+ obj = container.get_leaf_object_at_position(i)
143
+ return false if obj && obj.get_properties.has_property("Lock")
144
+ end
145
+ true
146
+ end
147
+
148
+ # Can we insert content at this position?
149
+ # Sends an event to the control.
150
+ def can_insert_content(container, pos)
151
+ child1 = container.get_leaf_object_at_position(pos)
152
+ child2 = container.get_leaf_object_at_position(pos-1)
153
+
154
+ lock1 = lock2 = -1
155
+
156
+ if child1 && child1.get_properties.has_property("Lock")
157
+ lock1 = child1.get_properties.get_property_long("Lock")
158
+ end
159
+ if child2 && child2.get_properties.has_property("Lock")
160
+ lock2 = child2.get_properties.get_property_long("Lock")
161
+ end
162
+
163
+ return false if lock1 != -1 && lock1 == lock2
164
+
165
+ # Don't allow insertion before a locked object if it's at the beginning of the buffer.
166
+ return false if pos == 0 && lock1 != -1
167
+
168
+ true
169
+ end
170
+
171
+ # Finds a table, either selected or near the cursor
172
+ def find_table
173
+ obj = find_current_position
174
+
175
+ # It could be a table or a cell (or neither)
176
+ if obj.is_a?(Wx::RTC::RichTextTable)
177
+ return obj
178
+ end
179
+
180
+ while obj
181
+ obj = obj.get_parent
182
+ if obj.is_a?(Wx::RTC::RichTextTable)
183
+ return obj
184
+ end
185
+ end
186
+
187
+ nil
188
+ end
189
+
190
+ # Helper for FindTable()
191
+ def find_current_position
192
+ position = -1
193
+
194
+ if has_selection # First see if there's a selection
195
+ range = get_selection_range
196
+ if (range.size-1) == 1
197
+ position = range.begin
198
+ end
199
+ end
200
+ if position == -1 # Failing that, near cursor
201
+ position = get_adjusted_caret_position(get_caret_position)
202
+ end
203
+
204
+ get_focus_object.get_leaf_object_at_position(position)
205
+ end
206
+
207
+ end
208
+
209
+ # Define a new application type
210
+ class MyApp < Wx::App
211
+
212
+ def initialize
213
+ super
214
+ @styleSheet = nil
215
+ @printing =nil
216
+ end
217
+
218
+ # override base class virtuals
219
+ # ----------------------------
220
+
221
+ # this one is called on application startup and is a good place for the app
222
+ # initialization (doing it here and not in the ctor allows to have an error
223
+ # return: if on_init() returns false, the application terminates)
224
+ def on_init
225
+
226
+ if Wx.has_feature?(:USE_HELP)
227
+ Wx::HelpProvider.set(Wx::SimpleHelpProvider.new)
228
+ end
229
+
230
+ @styleSheet = Wx::RTC::RichTextStyleSheet.new
231
+ if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
232
+ @printing = Wx::RTC::RichTextPrinting.new("Test Document")
233
+
234
+ @printing.set_footer_text("@TITLE@", Wx::RTC::RICHTEXT_PAGE_ALL, Wx::RTC::RICHTEXT_PAGE_CENTRE)
235
+ @printing.set_footer_text("Page @PAGENUM@", Wx::RTC::RICHTEXT_PAGE_ALL, Wx::RTC::RICHTEXT_PAGE_RIGHT)
236
+ end
237
+
238
+ create_styles
239
+
240
+ MyRichTextCtrl.set_enhanced_drawing_handler
241
+
242
+ # Add extra handlers (plain text is automatically added)
243
+ Wx::RTC::RichTextBuffer.add_handler(Wx::RTC::RichTextXMLHandler.new)
244
+ Wx::RTC::RichTextBuffer.add_handler(Wx::RTC::RichTextHTMLHandler.new)
245
+
246
+ # Add field types
247
+
248
+ Wx::RTC::RichTextBuffer.add_field_type(RichTextFieldTypePropertiesTest.new("rectangle", "RECTANGLE", Wx::RTC::RichTextFieldTypeStandard::RICHTEXT_FIELD_STYLE_RECTANGLE))
249
+
250
+ s1 = Wx::RTC::RichTextFieldTypeStandard.new("begin-section", "SECTION", Wx::RTC::RichTextFieldTypeStandard::RICHTEXT_FIELD_STYLE_START_TAG)
251
+ s1.set_background_colour(Wx::BLUE)
252
+
253
+ s2 = Wx::RTC::RichTextFieldTypeStandard.new("end-section", "SECTION", Wx::RTC::RichTextFieldTypeStandard::RICHTEXT_FIELD_STYLE_END_TAG)
254
+ s2.set_background_colour(Wx::BLUE)
255
+
256
+ s3 = Wx::RTC::RichTextFieldTypeStandard.new("bitmap", Wx.Bitmap(:paste), Wx::RTC::RichTextFieldTypeStandard::RICHTEXT_FIELD_STYLE_NO_BORDER)
257
+
258
+ Wx::RTC::RichTextBuffer.add_field_type(s1)
259
+ Wx::RTC::RichTextBuffer.add_field_type(s2)
260
+ Wx::RTC::RichTextBuffer.add_field_type(s3)
261
+
262
+ s4 = RichTextFieldTypeCompositeTest.new("composite", "This is a field value")
263
+ Wx::RTC::RichTextBuffer.add_field_type(s4)
264
+
265
+ if Wx.has_feature? :USE_FILESYSTEM
266
+ Wx::FileSystem.add_handler(Wx::MemoryFSHandler.new)
267
+ end
268
+
269
+ # create the main application window
270
+ size = Wx.get_display_size
271
+ size.scale(0.75, 0.75)
272
+ frame = MyFrame.new("Wx::RTC::RichTextCtrl Sample", size: size)
273
+
274
+ if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
275
+ @printing.set_parent_window(frame)
276
+ end
277
+
278
+ # and show it (the frames, unlike simple controls, are not shown when
279
+ # created initially)
280
+ frame.show(true)
281
+
282
+ # success: wxApp::OnRun() will be called which will enter the main message
283
+ # loop and the application will run. If we returned false here, the
284
+ # application would exit immediately.
285
+ true
286
+ end
287
+
288
+ def create_styles
289
+ # Paragraph styles
290
+
291
+ romanFont = Wx::Font.new(Wx::FontInfo.new(12).family(Wx::FONTFAMILY_ROMAN))
292
+ swissFont = Wx::Font.new(Wx::FontInfo.new(12).family(Wx::FONTFAMILY_SWISS))
293
+
294
+ normalPara = Wx::RTC::RichTextParagraphStyleDefinition.new("Normal")
295
+ normalAttr = Wx::RTC::RichTextAttr.new
296
+ normalAttr.set_font_face_name(romanFont.get_face_name)
297
+ normalAttr.set_font_size(12)
298
+ # Let's set all attributes for this style
299
+ normalAttr.set_flags(Wx::TEXT_ATTR_FONT | Wx::TEXT_ATTR_BACKGROUND_COLOUR | Wx::TEXT_ATTR_TEXT_COLOUR|Wx::TEXT_ATTR_ALIGNMENT|Wx::TEXT_ATTR_LEFT_INDENT|Wx::TEXT_ATTR_RIGHT_INDENT|Wx::TEXT_ATTR_TABS|
300
+ Wx::TEXT_ATTR_PARA_SPACING_BEFORE|Wx::TEXT_ATTR_PARA_SPACING_AFTER|Wx::TEXT_ATTR_LINE_SPACING|
301
+ Wx::TEXT_ATTR_BULLET_STYLE|Wx::TEXT_ATTR_BULLET_NUMBER)
302
+ normalPara.set_style(normalAttr)
303
+
304
+ @styleSheet.add_paragraph_style(normalPara)
305
+
306
+ indentedPara = Wx::RTC::RichTextParagraphStyleDefinition.new("Indented")
307
+ indentedAttr = Wx::RTC::RichTextAttr.new
308
+ indentedAttr.set_font_face_name(romanFont.get_face_name)
309
+ indentedAttr.set_font_size(12)
310
+ indentedAttr.set_left_indent(100, 0)
311
+ # We only want to affect indentation
312
+ indentedAttr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT|Wx::TEXT_ATTR_RIGHT_INDENT)
313
+ indentedPara.set_style(indentedAttr)
314
+
315
+ @styleSheet.add_paragraph_style(indentedPara)
316
+
317
+ indentedPara2 = Wx::RTC::RichTextParagraphStyleDefinition.new("Red Bold Indented")
318
+ indentedAttr2 = Wx::RTC::RichTextAttr.new
319
+ indentedAttr2.set_font_face_name(romanFont.get_face_name)
320
+ indentedAttr2.set_font_size(12)
321
+ indentedAttr2.set_font_weight(Wx::FONTWEIGHT_BOLD)
322
+ indentedAttr2.set_text_colour(Wx::RED)
323
+ indentedAttr2.set_font_size(12)
324
+ indentedAttr2.set_left_indent(100, 0)
325
+ # We want to affect indentation, font and text colour
326
+ indentedAttr2.set_flags(Wx::TEXT_ATTR_LEFT_INDENT|Wx::TEXT_ATTR_RIGHT_INDENT|Wx::TEXT_ATTR_FONT|Wx::TEXT_ATTR_TEXT_COLOUR)
327
+ indentedPara2.set_style(indentedAttr2)
328
+
329
+ @styleSheet.add_paragraph_style(indentedPara2)
330
+
331
+ flIndentedPara = Wx::RTC::RichTextParagraphStyleDefinition.new("First Line Indented")
332
+ flIndentedAttr = Wx::RTC::RichTextAttr.new
333
+ flIndentedAttr.set_font_face_name(swissFont.get_face_name)
334
+ flIndentedAttr.set_font_size(12)
335
+ flIndentedAttr.set_left_indent(100, -100)
336
+ # We only want to affect indentation
337
+ flIndentedAttr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT|Wx::TEXT_ATTR_RIGHT_INDENT)
338
+ flIndentedPara.set_style(flIndentedAttr)
339
+
340
+ @styleSheet.add_paragraph_style(flIndentedPara)
341
+
342
+ # Character styles
343
+
344
+ boldDef = Wx::RTC::RichTextCharacterStyleDefinition.new("Bold")
345
+ boldAttr = Wx::RTC::RichTextAttr.new
346
+ boldAttr.set_font_face_name(romanFont.get_face_name)
347
+ boldAttr.set_font_size(12)
348
+ boldAttr.set_font_weight(Wx::FONTWEIGHT_BOLD)
349
+ # We only want to affect boldness
350
+ boldAttr.set_flags(Wx::TEXT_ATTR_FONT_WEIGHT)
351
+ boldDef.set_style(boldAttr)
352
+
353
+ @styleSheet.add_character_style(boldDef)
354
+
355
+ italicDef = Wx::RTC::RichTextCharacterStyleDefinition.new("Italic")
356
+ italicAttr = Wx::RTC::RichTextAttr.new
357
+ italicAttr.set_font_face_name(romanFont.get_face_name)
358
+ italicAttr.set_font_size(12)
359
+ italicAttr.set_font_style(Wx::FONTSTYLE_ITALIC)
360
+ # We only want to affect italics
361
+ italicAttr.set_flags(Wx::TEXT_ATTR_FONT_ITALIC)
362
+ italicDef.set_style(italicAttr)
363
+
364
+ @styleSheet.add_character_style(italicDef)
365
+
366
+ redDef = Wx::RTC::RichTextCharacterStyleDefinition.new("Red Bold")
367
+ redAttr = Wx::RTC::RichTextAttr.new
368
+ redAttr.set_font_face_name(romanFont.get_face_name)
369
+ redAttr.set_font_size(12)
370
+ redAttr.set_font_weight(Wx::FONTWEIGHT_BOLD)
371
+ redAttr.set_text_colour(Wx::RED)
372
+ # We only want to affect colour, weight and face
373
+ redAttr.set_flags(Wx::TEXT_ATTR_FONT_FACE|Wx::TEXT_ATTR_FONT_WEIGHT|Wx::TEXT_ATTR_TEXT_COLOUR)
374
+ redDef.set_style(redAttr)
375
+
376
+ @styleSheet.add_character_style(redDef)
377
+
378
+ bulletList = Wx::RTC::RichTextListStyleDefinition.new("Bullet List 1")
379
+ 10.times do |i|
380
+ if i == 0
381
+ bulletText = "standard/circle"
382
+ elsif i == 1
383
+ bulletText = "standard/square"
384
+ elsif i == 2
385
+ bulletText = "standard/circle"
386
+ elsif i == 3
387
+ bulletText = "standard/square"
388
+ else
389
+ bulletText = "standard/circle"
390
+ end
391
+ bulletList.set_attributes(i, (i+1)*60, 60, Wx::TEXT_ATTR_BULLET_STYLE_STANDARD, bulletText)
392
+ end
393
+
394
+ @styleSheet.add_list_style(bulletList)
395
+
396
+ numberedList = Wx::RTC::RichTextListStyleDefinition.new("Numbered List 1")
397
+ 10.times do |i|
398
+ if i == 0
399
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_ARABIC|Wx::TEXT_ATTR_BULLET_STYLE_PERIOD
400
+ elsif i == 1
401
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_LETTERS_LOWER|Wx::TEXT_ATTR_BULLET_STYLE_PARENTHESES
402
+ elsif i == 2
403
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_ROMAN_LOWER|Wx::TEXT_ATTR_BULLET_STYLE_PARENTHESES
404
+ elsif i == 3
405
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_ROMAN_UPPER|Wx::TEXT_ATTR_BULLET_STYLE_PARENTHESES
406
+ else
407
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_ARABIC|Wx::TEXT_ATTR_BULLET_STYLE_PERIOD
408
+ end
409
+
410
+ numberStyle |= Wx::TEXT_ATTR_BULLET_STYLE_ALIGN_RIGHT
411
+
412
+ numberedList.set_attributes(i, (i+1)*60, 60, numberStyle)
413
+ end
414
+
415
+ @styleSheet.add_list_style(numberedList)
416
+
417
+ outlineList = Wx::RTC::RichTextListStyleDefinition.new("Outline List 1")
418
+ 10.times do |i|
419
+ if i < 4
420
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_OUTLINE|Wx::TEXT_ATTR_BULLET_STYLE_PERIOD
421
+ else
422
+ numberStyle = Wx::TEXT_ATTR_BULLET_STYLE_ARABIC|Wx::TEXT_ATTR_BULLET_STYLE_PERIOD
423
+ end
424
+
425
+ outlineList.set_attributes(i, (i+1)*120, 120, numberStyle)
426
+ end
427
+
428
+ @styleSheet.add_list_style(outlineList)
429
+ end
430
+
431
+ def get_style_sheet
432
+ @styleSheet
433
+ end
434
+
435
+ if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
436
+
437
+ def get_printing
438
+ @printing
439
+ end
440
+
441
+ end
442
+ end
443
+
444
+
445
+ # Define a new frame type: this is going to be our main frame
446
+ class MyFrame < Wx::Frame
447
+
448
+ # IDs for the controls and the menu commands
449
+ module ID
450
+ include Wx::IDHelper
451
+
452
+ # menu items
453
+ Quit = Wx::ID_EXIT
454
+ About = Wx::ID_ABOUT
455
+
456
+ FORMAT_BOLD = self.next_id
457
+ FORMAT_ITALIC = self.next_id
458
+ FORMAT_UNDERLINE = self.next_id
459
+ FORMAT_STRIKETHROUGH = self.next_id
460
+ FORMAT_SUPERSCRIPT = self.next_id
461
+ FORMAT_SUBSCRIPT = self.next_id
462
+ FORMAT_FONT = self.next_id
463
+ FORMAT_IMAGE = self.next_id
464
+ FORMAT_PARAGRAPH = self.next_id
465
+ FORMAT_CONTENT = self.next_id
466
+
467
+ RELOAD = self.next_id
468
+
469
+ INSERT_SYMBOL = self.next_id
470
+ INSERT_URL = self.next_id
471
+ INSERT_IMAGE = self.next_id
472
+
473
+ FORMAT_ALIGN_LEFT = self.next_id
474
+ FORMAT_ALIGN_CENTRE = self.next_id
475
+ FORMAT_ALIGN_RIGHT = self.next_id
476
+
477
+ FORMAT_INDENT_MORE = self.next_id
478
+ FORMAT_INDENT_LESS = self.next_id
479
+
480
+ FORMAT_PARAGRAPH_SPACING_MORE = self.next_id
481
+ FORMAT_PARAGRAPH_SPACING_LESS = self.next_id
482
+
483
+ FORMAT_LINE_SPACING_HALF = self.next_id
484
+ FORMAT_LINE_SPACING_DOUBLE = self.next_id
485
+ FORMAT_LINE_SPACING_SINGLE = self.next_id
486
+
487
+ FORMAT_NUMBER_LIST = self.next_id
488
+ FORMAT_BULLETS_AND_NUMBERING = self.next_id
489
+ FORMAT_ITEMIZE_LIST = self.next_id
490
+ FORMAT_RENUMBER_LIST = self.next_id
491
+ FORMAT_PROMOTE_LIST = self.next_id
492
+ FORMAT_DEMOTE_LIST = self.next_id
493
+ FORMAT_CLEAR_LIST = self.next_id
494
+
495
+ TABLE_ADD_COLUMN = self.next_id
496
+ TABLE_ADD_ROW = self.next_id
497
+ TABLE_DELETE_COLUMN = self.next_id
498
+ TABLE_DELETE_ROW = self.next_id
499
+
500
+ SET_FONT_SCALE = self.next_id
501
+ SET_DIMENSION_SCALE = self.next_id
502
+
503
+ VIEW_HTML = self.next_id
504
+ SWITCH_STYLE_SHEETS = self.next_id
505
+ MANAGE_STYLES = self.next_id
506
+
507
+ PRINT = self.next_id
508
+ PREVIEW = self.next_id
509
+ PAGE_SETUP = self.next_id
510
+
511
+ RICHTEXT_CTRL = self.next_id
512
+ RICHTEXT_STYLE_LIST = self.next_id
513
+ RICHTEXT_STYLE_COMBO = self.next_id
514
+ end
515
+
516
+ # ctor(s)
517
+ def initialize(title, id: Wx::ID_ANY, pos: Wx::DEFAULT_POSITION, size: Wx::DEFAULT_SIZE, style: Wx::DEFAULT_FRAME_STYLE)
518
+ super(nil, id: id, pos: pos, size: size, style: style)
519
+
520
+ @richTextCtrl = nil
521
+
522
+ if Wx::PLATFORM == 'WXMAC'
523
+ set_window_variant(Wx::WINDOW_VARIANT_SMALL)
524
+ end
525
+
526
+ self.icon = Wx::Icon.new(local_icon_file('../sample.xpm'))
527
+
528
+ # create a menu bar
529
+ fileMenu = Wx::Menu.new
530
+
531
+ # the "About" item should be in the help menu
532
+ helpMenu = Wx::Menu.new
533
+ helpMenu.append(ID::About, "&About\tF1", "Show about dialog")
534
+
535
+ fileMenu.append(Wx::ID_OPEN, "&Open\tCtrl+O", "Open a file")
536
+ fileMenu.append(Wx::ID_SAVE, "&Save\tCtrl+S", "Save a file")
537
+ fileMenu.append(Wx::ID_SAVEAS, "&Save As...\tF12", "Save to a new file")
538
+ fileMenu.append_separator
539
+ fileMenu.append(ID::RELOAD, "&Reload Text\tF2", "Reload the initial text")
540
+ fileMenu.append_separator
541
+ fileMenu.append(ID::PAGE_SETUP, "Page Set&up...", "Page setup")
542
+
543
+ if Wx.has_feature? :USE_PRINTING_ARCHITECTURE
544
+ fileMenu.append(ID::PRINT, "&Print...\tCtrl+P", "Print")
545
+ fileMenu.append(ID::PREVIEW, "Print Pre&view", "Print preview")
546
+ end
547
+
548
+ fileMenu.append_separator
549
+ fileMenu.append(ID::VIEW_HTML, "&View as HTML", "View HTML")
550
+ fileMenu.append_separator
551
+ fileMenu.append(ID::Quit, "E&xit\tAlt+X", "Quit this program")
552
+
553
+ editMenu = Wx::Menu.new
554
+ editMenu.append(Wx::ID_UNDO, "&Undo\tCtrl+Z")
555
+ editMenu.append(Wx::ID_REDO, "&Redo\tCtrl+Y")
556
+ editMenu.append_separator
557
+ editMenu.append(Wx::ID_CUT, "Cu&t\tCtrl+X")
558
+ editMenu.append(Wx::ID_COPY, "&Copy\tCtrl+C")
559
+ editMenu.append(Wx::ID_PASTE, "&Paste\tCtrl+V")
560
+
561
+ editMenu.append_separator
562
+ editMenu.append(Wx::ID_SELECTALL, "Select A&ll\tCtrl+A")
563
+ editMenu.append_separator
564
+ editMenu.append(ID::SET_FONT_SCALE, "Set &Text Scale...")
565
+ editMenu.append(ID::SET_DIMENSION_SCALE, "Set &Dimension Scale...")
566
+
567
+ formatMenu = Wx::Menu.new
568
+ formatMenu.append_check_item(ID::FORMAT_BOLD, "&Bold\tCtrl+B")
569
+ formatMenu.append_check_item(ID::FORMAT_ITALIC, "&Italic\tCtrl+I")
570
+ formatMenu.append_check_item(ID::FORMAT_UNDERLINE, "&Underline\tCtrl+U")
571
+ formatMenu.append_separator
572
+ formatMenu.append_check_item(ID::FORMAT_STRIKETHROUGH, "Stri&kethrough")
573
+ formatMenu.append_check_item(ID::FORMAT_SUPERSCRIPT, "Superscrip&t")
574
+ formatMenu.append_check_item(ID::FORMAT_SUBSCRIPT, "Subscrip&t")
575
+ formatMenu.append_separator
576
+ formatMenu.append_check_item(ID::FORMAT_ALIGN_LEFT, "L&eft Align")
577
+ formatMenu.append_check_item(ID::FORMAT_ALIGN_RIGHT, "&Right Align")
578
+ formatMenu.append_check_item(ID::FORMAT_ALIGN_CENTRE, "&Centre")
579
+ formatMenu.append_separator
580
+ formatMenu.append(ID::FORMAT_INDENT_MORE, "Indent &More")
581
+ formatMenu.append(ID::FORMAT_INDENT_LESS, "Indent &Less")
582
+ formatMenu.append_separator
583
+ formatMenu.append(ID::FORMAT_PARAGRAPH_SPACING_MORE, "Increase Paragraph &Spacing")
584
+ formatMenu.append(ID::FORMAT_PARAGRAPH_SPACING_LESS, "Decrease &Paragraph Spacing")
585
+ formatMenu.append_separator
586
+ formatMenu.append(ID::FORMAT_LINE_SPACING_SINGLE, "Normal Line Spacing")
587
+ formatMenu.append(ID::FORMAT_LINE_SPACING_HALF, "1.5 Line Spacing")
588
+ formatMenu.append(ID::FORMAT_LINE_SPACING_DOUBLE, "Double Line Spacing")
589
+ formatMenu.append_separator
590
+ formatMenu.append(ID::FORMAT_FONT, "&Font...")
591
+ formatMenu.append(ID::FORMAT_IMAGE, "Image Property")
592
+ formatMenu.append(ID::FORMAT_PARAGRAPH, "&Paragraph...")
593
+ formatMenu.append(ID::FORMAT_CONTENT, "Font and Pa&ragraph...\tShift+Ctrl+F")
594
+ formatMenu.append_separator
595
+ formatMenu.append(ID::SWITCH_STYLE_SHEETS, "&Switch Style Sheets")
596
+ formatMenu.append(ID::MANAGE_STYLES, "&Manage Styles")
597
+
598
+ listsMenu = Wx::Menu.new
599
+ listsMenu.append(ID::FORMAT_BULLETS_AND_NUMBERING, "Bullets and &Numbering...")
600
+ listsMenu.append_separator
601
+ listsMenu.append(ID::FORMAT_NUMBER_LIST, "Number List")
602
+ listsMenu.append(ID::FORMAT_ITEMIZE_LIST, "Itemize List")
603
+ listsMenu.append(ID::FORMAT_RENUMBER_LIST, "Renumber List")
604
+ listsMenu.append(ID::FORMAT_PROMOTE_LIST, "Promote List Items")
605
+ listsMenu.append(ID::FORMAT_DEMOTE_LIST, "Demote List Items")
606
+ listsMenu.append(ID::FORMAT_CLEAR_LIST, "Clear List Formatting")
607
+
608
+ tableMenu = Wx::Menu.new
609
+ tableMenu.append(ID::TABLE_ADD_COLUMN, "&Add Column")
610
+ tableMenu.append(ID::TABLE_ADD_ROW, "Add &Row")
611
+ tableMenu.append(ID::TABLE_DELETE_COLUMN, "Delete &Column")
612
+ tableMenu.append(ID::TABLE_DELETE_ROW, "&Delete Row")
613
+
614
+ insertMenu = Wx::Menu.new
615
+ insertMenu.append(ID::INSERT_SYMBOL, "&Symbol...\tCtrl+I")
616
+ insertMenu.append(ID::INSERT_URL, "&URL...")
617
+ insertMenu.append(ID::INSERT_IMAGE, "&Image...")
618
+
619
+ # now append the freshly created menu to the menu bar...
620
+ menuBar = Wx::MenuBar.new
621
+ menuBar.append(fileMenu, "&File")
622
+ menuBar.append(editMenu, "&Edit")
623
+ menuBar.append(formatMenu, "F&ormat")
624
+ menuBar.append(listsMenu, "&Lists")
625
+ menuBar.append(tableMenu, "&Tables")
626
+ menuBar.append(insertMenu, "&Insert")
627
+ menuBar.append(helpMenu, "&Help")
628
+
629
+ # ... and attach this menu bar to the frame
630
+ set_menu_bar(menuBar)
631
+
632
+ # create a status bar just for fun (by default with 1 pane only)
633
+ # but don't create it on limited screen space (mobile device)
634
+ is_pda = Wx::SystemSettings.get_screen_type <= Wx::SYS_SCREEN_PDA
635
+
636
+ if Wx.has_feature? :USE_STATUSBAR
637
+ unless is_pda
638
+ create_status_bar(2)
639
+ set_status_text("Welcome to wxRichTextCtrl!")
640
+ end
641
+ end
642
+
643
+ sizer = Wx::VBoxSizer.new
644
+ set_sizer(sizer)
645
+
646
+ # On Mac, don't create a 'native' wxToolBar because small bitmaps are not supported by native
647
+ # toolbars. On Mac, a non-native, small-bitmap toolbar doesn't show unless it is explicitly
648
+ # managed, hence the use of sizers. In a real application, use larger icons for the main
649
+ # toolbar to avoid the need for this workaround. Or, use the toolbar in a container window
650
+ # as part of a more complex hierarchy, and the toolbar will automatically be non-native.
651
+
652
+ Wx::SystemOptions.set_option("mac.toolbar.no-native", 1)
653
+
654
+ toolBar = Wx::ToolBar.new(self, style: Wx::NO_BORDER|Wx::TB_FLAT|Wx::TB_NODIVIDER|Wx::TB_NOALIGN)
655
+
656
+ sizer.add(toolBar, 0, Wx::EXPAND)
657
+
658
+ toolBar.add_tool(Wx::ID_OPEN, '', Wx.Bitmap(:open), "Open")
659
+ toolBar.add_tool(Wx::ID_SAVEAS, '', Wx.Bitmap(:save), "Save")
660
+ toolBar.add_separator
661
+ toolBar.add_tool(Wx::ID_CUT, '', Wx.Bitmap(:cut), "Cut")
662
+ toolBar.add_tool(Wx::ID_COPY, '', Wx.Bitmap(:copy), "Copy")
663
+ toolBar.add_tool(Wx::ID_PASTE, '', Wx.Bitmap(:paste), "Paste")
664
+ toolBar.add_separator
665
+ toolBar.add_tool(Wx::ID_UNDO, '', Wx.Bitmap(:undo), "Undo")
666
+ toolBar.add_tool(Wx::ID_REDO, '', Wx.Bitmap(:redo), "Redo")
667
+ toolBar.add_separator
668
+ toolBar.add_check_tool(ID::FORMAT_BOLD, '', Wx.Bitmap(:bold), nil, "Bold")
669
+ toolBar.add_check_tool(ID::FORMAT_ITALIC, '', Wx.Bitmap(:italic), nil, "Italic")
670
+ toolBar.add_check_tool(ID::FORMAT_UNDERLINE, '', Wx.Bitmap(:underline), nil, "Underline")
671
+ toolBar.add_separator
672
+ toolBar.add_check_tool(ID::FORMAT_ALIGN_LEFT, '', Wx.Bitmap(:alignleft), nil, "Align Left")
673
+ toolBar.add_check_tool(ID::FORMAT_ALIGN_CENTRE, '', Wx.Bitmap(:centre), nil, "Centre")
674
+ toolBar.add_check_tool(ID::FORMAT_ALIGN_RIGHT, '', Wx.Bitmap(:alignright), nil, "Align Right")
675
+ toolBar.add_separator
676
+ toolBar.add_tool(ID::FORMAT_INDENT_LESS, '', Wx.Bitmap(:indentless), "Indent Less")
677
+ toolBar.add_tool(ID::FORMAT_INDENT_MORE, '', Wx.Bitmap(:indentmore), "Indent More")
678
+ toolBar.add_separator
679
+ toolBar.add_tool(ID::FORMAT_FONT, '', Wx.Bitmap(:font), "Font")
680
+ toolBar.add_separator
681
+
682
+ combo = Wx::RTC::RichTextStyleComboCtrl.new(toolBar, ID::RICHTEXT_STYLE_COMBO, size: [160, -1], style: Wx::CB_READONLY)
683
+ toolBar.add_control(combo)
684
+
685
+ toolBar.realize
686
+
687
+ splitter = Wx::SplitterWindow.new(self, style: Wx::SP_LIVE_UPDATE)
688
+ sizer.add(splitter, 1, Wx::EXPAND)
689
+
690
+ @richTextCtrl = MyRichTextCtrl.new(splitter, id: ID::RICHTEXT_CTRL, style: Wx::VSCROLL|Wx::HSCROLL) # /*|wxWANTS_CHARS*/)
691
+ # @richTextCtrl = Wx::RTC::RichTextCtrl.new(splitter, id: ID::RICHTEXT_CTRL, style: Wx::VSCROLL|Wx::HSCROLL) # /*|wxWANTS_CHARS*/)
692
+ # wxASSERT(!m_richTextCtrl.GetBuffer().GetAttributes().HasFontPixelSize())
693
+
694
+ font = Wx::Font.new(Wx::FontInfo.new(12).family(Wx::FONTFAMILY_ROMAN))
695
+
696
+ @richTextCtrl.set_font(font)
697
+
698
+ # wxASSERT(!m_richTextCtrl.GetBuffer().GetAttributes().HasFontPixelSize())
699
+
700
+ @richTextCtrl.set_margins(10, 10)
701
+
702
+ @richTextCtrl.set_style_sheet(Wx.get_app.get_style_sheet)
703
+
704
+ combo.set_style_sheet(Wx.get_app.get_style_sheet)
705
+ combo.set_rich_text_ctrl(@richTextCtrl)
706
+ combo.update_styles
707
+
708
+ styleListCtrl = Wx::RTC::RichTextStyleListCtrl.new(splitter, ID::RICHTEXT_STYLE_LIST)
709
+
710
+ display = Wx.get_display_size
711
+ if is_pda && display.width < display.height
712
+ splitter.split_horizontally(@richTextCtrl, styleListCtrl)
713
+ else
714
+ width = get_client_size.width * 4 / 5
715
+ splitter.split_vertically(@richTextCtrl, styleListCtrl, width)
716
+ splitter.set_sash_gravity(0.8)
717
+ end
718
+
719
+ layout
720
+
721
+ splitter.update_size
722
+
723
+ styleListCtrl.set_style_sheet(Wx.get_app.get_style_sheet)
724
+ styleListCtrl.set_rich_text_ctrl(@richTextCtrl)
725
+ styleListCtrl.update_styles
726
+
727
+ # attach event handlers
728
+ evt_menu(ID::Quit, :on_quit)
729
+ evt_menu(ID::About, :on_about)
730
+
731
+ evt_menu(Wx::ID_OPEN, :on_open)
732
+ evt_menu(Wx::ID_SAVE, :on_save)
733
+ evt_menu(Wx::ID_SAVEAS, :on_save_as)
734
+
735
+ evt_menu(ID::FORMAT_BOLD, :on_bold)
736
+ evt_menu(ID::FORMAT_ITALIC, :on_italic)
737
+ evt_menu(ID::FORMAT_UNDERLINE, :on_underline)
738
+
739
+ evt_menu(ID::FORMAT_STRIKETHROUGH, :on_strikethrough)
740
+ evt_menu(ID::FORMAT_SUPERSCRIPT, :on_superscript)
741
+ evt_menu(ID::FORMAT_SUBSCRIPT, :on_subscript)
742
+
743
+ evt_update_ui(ID::FORMAT_BOLD, :on_update_bold)
744
+ evt_update_ui(ID::FORMAT_ITALIC, :on_update_italic)
745
+ evt_update_ui(ID::FORMAT_UNDERLINE, :on_update_underline)
746
+
747
+ evt_update_ui(ID::FORMAT_STRIKETHROUGH, :on_update_strikethrough)
748
+ evt_update_ui(ID::FORMAT_SUPERSCRIPT, :on_update_superscript)
749
+ evt_update_ui(ID::FORMAT_SUBSCRIPT, :on_update_subscript)
750
+
751
+ evt_menu(ID::FORMAT_ALIGN_LEFT, :on_align_left)
752
+ evt_menu(ID::FORMAT_ALIGN_CENTRE, :on_align_centre)
753
+ evt_menu(ID::FORMAT_ALIGN_RIGHT, :on_align_right)
754
+
755
+ evt_update_ui(ID::FORMAT_ALIGN_LEFT, :on_update_align_left)
756
+ evt_update_ui(ID::FORMAT_ALIGN_CENTRE, :on_update_align_centre)
757
+ evt_update_ui(ID::FORMAT_ALIGN_RIGHT, :on_update_align_right)
758
+
759
+ evt_menu(ID::FORMAT_FONT, :on_font)
760
+ evt_menu(ID::FORMAT_IMAGE, :on_image)
761
+ evt_menu(ID::FORMAT_PARAGRAPH, :on_paragraph)
762
+ evt_menu(ID::FORMAT_CONTENT, :on_format)
763
+ evt_update_ui(ID::FORMAT_CONTENT, :on_update_format)
764
+ evt_update_ui(ID::FORMAT_FONT, :on_update_format)
765
+ evt_update_ui(ID::FORMAT_IMAGE, :on_update_image)
766
+ evt_update_ui(ID::FORMAT_PARAGRAPH, :on_update_format)
767
+ evt_menu(ID::FORMAT_INDENT_MORE, :on_indent_more)
768
+ evt_menu(ID::FORMAT_INDENT_LESS, :on_indent_less)
769
+
770
+ evt_menu(ID::FORMAT_LINE_SPACING_HALF, :on_line_spacing_half)
771
+ evt_menu(ID::FORMAT_LINE_SPACING_SINGLE, :on_line_spacing_single)
772
+ evt_menu(ID::FORMAT_LINE_SPACING_DOUBLE, :on_line_spacing_double)
773
+
774
+ evt_menu(ID::FORMAT_PARAGRAPH_SPACING_MORE, :on_paragraph_spacing_more)
775
+ evt_menu(ID::FORMAT_PARAGRAPH_SPACING_LESS, :on_paragraph_spacing_less)
776
+
777
+ evt_menu(ID::RELOAD, :on_reload)
778
+
779
+ evt_menu(ID::INSERT_SYMBOL, :on_insert_symbol)
780
+ evt_menu(ID::INSERT_URL, :on_insert_url)
781
+ evt_menu(ID::INSERT_IMAGE, :on_insert_image)
782
+
783
+ evt_menu(ID::FORMAT_NUMBER_LIST, :on_number_list)
784
+ evt_menu(ID::FORMAT_BULLETS_AND_NUMBERING, :on_bullets_and_numbering)
785
+ evt_menu(ID::FORMAT_ITEMIZE_LIST, :on_itemize_list)
786
+ evt_menu(ID::FORMAT_RENUMBER_LIST, :on_renumber_list)
787
+ evt_menu(ID::FORMAT_PROMOTE_LIST, :on_promote_list)
788
+ evt_menu(ID::FORMAT_DEMOTE_LIST, :on_demote_list)
789
+ evt_menu(ID::FORMAT_CLEAR_LIST, :on_clear_list)
790
+
791
+ evt_menu(ID::TABLE_ADD_COLUMN, :on_table_add_column)
792
+ evt_menu(ID::TABLE_ADD_ROW, :on_table_add_row)
793
+ evt_menu(ID::TABLE_DELETE_COLUMN, :on_table_delete_column)
794
+ evt_menu(ID::TABLE_DELETE_ROW, :on_table_delete_row)
795
+ evt_update_ui_range(ID::TABLE_ADD_COLUMN, ID::TABLE_ADD_ROW, :on_table_focused_update_ui)
796
+ evt_update_ui_range(ID::TABLE_DELETE_COLUMN, ID::TABLE_DELETE_ROW, :on_table_has_cells_update_ui)
797
+
798
+ evt_menu(ID::VIEW_HTML, :on_view_html)
799
+ evt_menu(ID::SWITCH_STYLE_SHEETS, :on_switch_stylesheets)
800
+ evt_menu(ID::MANAGE_STYLES, :on_manage_styles)
801
+
802
+ if Wx.has_feature? :USE_PRINTING_ARCHITECTURE
803
+ evt_menu(ID::PRINT, :on_print)
804
+ evt_menu(ID::PREVIEW, :on_preview)
805
+ end
806
+ evt_menu(ID::PAGE_SETUP, :on_page_setup)
807
+
808
+ evt_text_url(Wx::ID_ANY, :on_url)
809
+ evt_richtext_stylesheet_replacing(Wx::ID_ANY, :on_stylesheet_replacing)
810
+
811
+ evt_menu(ID::SET_FONT_SCALE, :on_set_font_scale)
812
+ evt_menu(ID::SET_DIMENSION_SCALE, :on_set_dimension_scale)
813
+
814
+ write_initial_text
815
+ end
816
+
817
+ # utility function to find an icon relative to this ruby script
818
+ def local_icon_file(icon_name)
819
+ File.join(File.dirname(__FILE__), icon_name)
820
+ end
821
+
822
+ # event handlers
823
+ def on_quit(_event)
824
+ close(true)
825
+ end
826
+
827
+ def on_about(_event)
828
+ msg = "This is a demo for Wx::RTC::RichTextCtrl, a control for editing styled text.\nOriginal code (c) Julian Smart, 2005\nAdapted for wxRuby3 (c) Martin JN Corino, 2023"
829
+ Wx.message_box(msg, "About wxRichTextCtrl Sample", Wx::OK | Wx::ICON_INFORMATION, self)
830
+ end
831
+
832
+ def on_open(_event)
833
+ fileTypes = []
834
+ filter = Wx::RTC::RichTextBuffer.get_ext_wildcard(false, false, fileTypes)
835
+ filter += "|" unless filter.empty?
836
+
837
+ filter += "All files (*.*)|*.*"
838
+
839
+ Wx.FileDialog(self, "Choose a filename",
840
+ '',
841
+ '',
842
+ filter,
843
+ Wx::FD_OPEN) do |dialog|
844
+ if dialog.show_modal == Wx::ID_OK
845
+ path1 = dialog.path
846
+
847
+ unless path1.empty?
848
+ filterIndex = dialog.get_filter_index
849
+ fileType = filterIndex < fileTypes.size ? fileTypes[filterIndex] : Wx::RTC::RICHTEXT_TYPE_TEXT
850
+ @richTextCtrl.load_file(path1, fileType)
851
+ end
852
+ end
853
+ end
854
+ end
855
+
856
+ def on_save(event)
857
+ if @richTextCtrl.get_filename.empty?
858
+ on_save_as(event)
859
+ else
860
+ @richTextCtrl.save_file
861
+ end
862
+ end
863
+
864
+ def on_save_as(_event)
865
+ filter = Wx::RTC::RichTextBuffer.get_ext_wildcard(false, true)
866
+
867
+ Wx.FileDialog(self, "Choose a filename", '', '', filter, Wx::FD_SAVE) do |dialog|
868
+
869
+ if dialog.show_modal == Wx::ID_OK
870
+ path1 = dialog.path
871
+
872
+ unless path1.empty?
873
+ Wx::BusyCursor.busy do
874
+ start = Time.now
875
+
876
+ @richTextCtrl.save_file(path1)
877
+
878
+ td = Time.now-start
879
+ Wx.log_debug("Saving took #{td}s")
880
+ Wx.message_box("Saving took #{td}s")
881
+ end
882
+ end
883
+ end
884
+ end
885
+ end
886
+
887
+ def on_bold(_event)
888
+ @richTextCtrl.apply_bold_to_selection
889
+ end
890
+ def on_italic(_event)
891
+ @richTextCtrl.apply_italic_to_selection
892
+ end
893
+ def on_underline(_event)
894
+ @richTextCtrl.apply_underline_to_selection
895
+ end
896
+
897
+ def on_strikethrough(_event)
898
+ @richTextCtrl.apply_text_effect_to_selection(Wx::TEXT_ATTR_EFFECT_STRIKETHROUGH)
899
+ end
900
+ def on_superscript(_event)
901
+ @richTextCtrl.apply_text_effect_to_selection(Wx::TEXT_ATTR_EFFECT_SUPERSCRIPT)
902
+ end
903
+ def on_subscript(_event)
904
+ @richTextCtrl.apply_text_effect_to_selection(Wx::TEXT_ATTR_EFFECT_SUBSCRIPT)
905
+ end
906
+
907
+ def on_update_bold(event)
908
+ event.check(@richTextCtrl.is_selection_bold)
909
+ end
910
+ def on_update_italic(event)
911
+ event.check(@richTextCtrl.is_selection_italics)
912
+ end
913
+ def on_update_underline(event)
914
+ event.check(@richTextCtrl.is_selection_underlined)
915
+ end
916
+ def on_update_strikethrough(event)
917
+ event.check(@richTextCtrl.does_selection_have_text_effect_flag(Wx::TEXT_ATTR_EFFECT_STRIKETHROUGH))
918
+ end
919
+ def on_update_superscript(event)
920
+ event.check(@richTextCtrl.does_selection_have_text_effect_flag(Wx::TEXT_ATTR_EFFECT_SUPERSCRIPT))
921
+ end
922
+ def on_update_subscript(event)
923
+ event.check(@richTextCtrl.does_selection_have_text_effect_flag(Wx::TEXT_ATTR_EFFECT_SUBSCRIPT))
924
+ end
925
+
926
+ def on_align_left(_event)
927
+ @richTextCtrl.apply_alignment_to_selection(Wx::TEXT_ALIGNMENT_LEFT)
928
+ end
929
+ def on_align_centre(_event)
930
+ @richTextCtrl.apply_alignment_to_selection(Wx::TEXT_ALIGNMENT_CENTRE)
931
+ end
932
+ def on_align_right(_event)
933
+ @richTextCtrl.apply_alignment_to_selection(Wx::TEXT_ALIGNMENT_RIGHT)
934
+ end
935
+
936
+ def on_update_align_left(event)
937
+ event.check(@richTextCtrl.is_selection_aligned(Wx::TEXT_ALIGNMENT_LEFT))
938
+ end
939
+ def on_update_align_centre(event)
940
+ event.check(@richTextCtrl.is_selection_aligned(Wx::TEXT_ALIGNMENT_CENTRE))
941
+ end
942
+ def on_update_align_right(event)
943
+ event.check(@richTextCtrl.is_selection_aligned(Wx::TEXT_ALIGNMENT_RIGHT))
944
+ end
945
+
946
+ def on_indent_more(_event)
947
+ attr = Wx::RichTextAttr.new
948
+ attr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT)
949
+
950
+ if @richTextCtrl.get_style(@richTextCtrl.get_insertion_point, attr)
951
+ range = @richTextCtrl.get_insertion_point..@richTextCtrl.get_insertion_point
952
+ range = @richTextCtrl.selection_range if @richTextCtrl.has_selection
953
+
954
+ attr.set_left_indent(attr.get_left_indent + 100)
955
+
956
+ attr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT)
957
+ @richTextCtrl.set_style(range, attr)
958
+ end
959
+ end
960
+ def on_indent_less(_event)
961
+ attr = Wx::RichTextAttr.new
962
+ attr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT)
963
+
964
+ if @richTextCtrl.get_style(@richTextCtrl.get_insertion_point, attr)
965
+ range = @richTextCtrl.get_insertion_point..@richTextCtrl.get_insertion_point
966
+ range = @richTextCtrl.selection_range if @richTextCtrl.has_selection
967
+
968
+ if attr.get_left_indent > 0
969
+ attr.set_left_indent([0, attr.get_left_indent - 100].max)
970
+
971
+ @richTextCtrl.set_style(range, attr)
972
+ end
973
+ end
974
+ end
975
+
976
+ def on_font(_event)
977
+ if @richTextCtrl.has_selection
978
+ range = @richTextCtrl.selection_range
979
+ else
980
+ range = 0..(@richTextCtrl.last_position+1)
981
+ end
982
+
983
+ pages = Wx::RTC::RICHTEXT_FORMAT_FONT
984
+
985
+ Wx::RTC.RichTextFormattingDialog(pages, self) do |formatDlg|
986
+ formatDlg.set_options(Wx::RTC::RichTextFormattingDialog::Option_AllowPixelFontSize)
987
+ formatDlg.get_style(@richTextCtrl, range)
988
+
989
+ if formatDlg.show_modal == Wx::ID_OK
990
+ formatDlg.apply_style(@richTextCtrl, range,
991
+ Wx::RTC::RICHTEXT_SETSTYLE_WITH_UNDO|
992
+ Wx::RTC::RICHTEXT_SETSTYLE_OPTIMIZE|
993
+ Wx::RTC::RICHTEXT_SETSTYLE_CHARACTERS_ONLY)
994
+ end
995
+ end
996
+ end
997
+ def on_image(_event)
998
+ if @richTextCtrl.has_selection
999
+ range = @richTextCtrl.selection_range
1000
+ if (range.begin...range.end).size == 1
1001
+ image = @richTextCtrl.get_focus_object.get_leaf_object_at_position(range.begin)
1002
+ if image.is_a?(Wx::RTC::RichTextImage)
1003
+ Wx::RTC.RichTextObjectPropertiesDialog(image, self) do |imageDlg|
1004
+ if imageDlg.show_modal == Wx::ID_OK
1005
+ imageDlg.apply_style(@richTextCtrl)
1006
+ end
1007
+ end
1008
+ end
1009
+ end
1010
+ end
1011
+ end
1012
+ def on_update_image(event)
1013
+ range = @richTextCtrl.selection_range
1014
+ if (range.begin...range.end).size == 1
1015
+ obj = @richTextCtrl.get_focus_object.get_leaf_object_at_position(range.begin)
1016
+ if obj && obj.is_a?(Wx::RTC::RichTextImage)
1017
+ event.enable(true)
1018
+ return
1019
+ end
1020
+ end
1021
+
1022
+ event.enable(false)
1023
+ end
1024
+
1025
+ def on_paragraph(_event)
1026
+ range = if @richTextCtrl.has_selection
1027
+ @richTextCtrl.selection_range
1028
+ else
1029
+ 0..(@richTextCtrl.last_position + 1)
1030
+ end
1031
+
1032
+ pages = Wx::RTC::RICHTEXT_FORMAT_INDENTS_SPACING|Wx::RTC::RICHTEXT_FORMAT_TABS|Wx::RTC::RICHTEXT_FORMAT_BULLETS
1033
+
1034
+ Wx::RTC.RichTextFormattingDialog(pages, self) do |formatDlg|
1035
+ formatDlg.get_style(@richTextCtrl, range)
1036
+
1037
+ formatDlg.apply_style(@richTextCtrl, range) if formatDlg.show_modal == Wx::ID_OK
1038
+ end
1039
+ end
1040
+ def on_format(_event)
1041
+ range = if @richTextCtrl.has_selection
1042
+ @richTextCtrl.selection_range
1043
+ else
1044
+ 0..(@richTextCtrl.last_position + 1)
1045
+ end
1046
+
1047
+ pages = Wx::RTC::RICHTEXT_FORMAT_FONT|Wx::RTC::RICHTEXT_FORMAT_INDENTS_SPACING|Wx::RTC::RICHTEXT_FORMAT_TABS|Wx::RTC::RICHTEXT_FORMAT_BULLETS
1048
+
1049
+ Wx::RTC.RichTextFormattingDialog(pages, self) do |formatDlg|
1050
+ formatDlg.get_style(@richTextCtrl, range)
1051
+
1052
+ formatDlg.apply_style(@richTextCtrl, range) if formatDlg.show_modal == Wx::ID_OK
1053
+ end
1054
+ end
1055
+ def on_update_format(event)
1056
+ event.enable(@richTextCtrl.has_selection)
1057
+ end
1058
+
1059
+ def on_insert_symbol(_event)
1060
+ attr = Wx::RTC::RichTextAttr.new
1061
+ attr.set_flags(Wx::TEXT_ATTR_FONT)
1062
+ @richTextCtrl.get_style(@richTextCtrl.insertion_point, attr)
1063
+
1064
+ currentFontName = ''
1065
+ currentFontName = attr.font.face_name if attr.has_font && attr.font.ok?
1066
+
1067
+ # Don't set the initial font in the dialog (so the user is choosing
1068
+ # 'normal text', i.e. the current font) but do tell the dialog
1069
+ # what 'normal text' is.
1070
+
1071
+ Wx::RTC.SymbolPickerDialog("*", '', currentFontName, self) do |dlg|
1072
+ if dlg.show_modal == Wx::ID_OK
1073
+ if dlg.has_selection
1074
+ insertionPoint = @richTextCtrl.insertion_point
1075
+
1076
+ @richTextCtrl.write_text(dlg.get_symbol)
1077
+
1078
+ unless dlg.use_normal_font
1079
+ font = Wx::Font.new(attr.font)
1080
+ font.set_face_name(dlg.font_name)
1081
+ attr.set_font(font)
1082
+ @richTextCtrl.set_style(insertionPoint, insertionPoint+1, attr)
1083
+ end
1084
+ end
1085
+ end
1086
+ end
1087
+ end
1088
+
1089
+ def set_selection_spacing(flag, &block)
1090
+ attr = Wx::RTC::RichTextAttr.new
1091
+ attr.set_flags(flag)
1092
+
1093
+ if @richTextCtrl.get_style(@richTextCtrl.insertion_point, attr)
1094
+ range = @richTextCtrl.insertion_point..@richTextCtrl.insertion_point
1095
+ range = @richTextCtrl.selection_range if @richTextCtrl.has_selection
1096
+
1097
+ block.call(attr)
1098
+
1099
+ attr.set_flags(flag)
1100
+ @richTextCtrl.set_style(range, attr)
1101
+ end
1102
+ end
1103
+ protected :set_selection_spacing
1104
+
1105
+ def on_line_spacing_half(_event)
1106
+ set_selection_spacing(Wx::TEXT_ATTR_LINE_SPACING) { |attr| attr.set_line_spacing(15) }
1107
+ end
1108
+ def on_line_spacing_double(_event)
1109
+ set_selection_spacing(Wx::TEXT_ATTR_LINE_SPACING) { |attr| attr.set_line_spacing(20) }
1110
+ end
1111
+ def on_line_spacing_single(_event)
1112
+ set_selection_spacing(Wx::TEXT_ATTR_LINE_SPACING) { |attr| attr.set_line_spacing(0) } # you could also use 10
1113
+ end
1114
+
1115
+ def on_paragraph_spacing_more(_event)
1116
+ set_selection_spacing(Wx::TEXT_ATTR_PARA_SPACING_AFTER) do |attr|
1117
+ attr.set_paragraph_spacing_after(attr.get_paragraph_spacing_after + 20)
1118
+ end
1119
+ end
1120
+ def on_paragraph_spacing_less(_event)
1121
+ set_selection_spacing(Wx::TEXT_ATTR_PARA_SPACING_AFTER) do |attr|
1122
+ if attr.get_paragraph_spacing_after >= 20
1123
+ attr.set_paragraph_spacing_after(attr.get_paragraph_spacing_after - 20)
1124
+ else
1125
+ attr.set_paragraph_spacing_after(0)
1126
+ end
1127
+ end
1128
+ end
1129
+
1130
+ def on_number_list(_event)
1131
+ if @richTextCtrl.has_selection
1132
+ range = @richTextCtrl.selection_range
1133
+ @richTextCtrl.set_list_style(range, 'Numbered List 1', Wx::RTC::RICHTEXT_SETSTYLE_WITH_UNDO|Wx::RTC::RICHTEXT_SETSTYLE_RENUMBER)
1134
+ end
1135
+ end
1136
+ def on_bullets_and_numbering(_event)
1137
+ sheet = @richTextCtrl.get_style_sheet
1138
+
1139
+ flags = Wx::RTC::RICHTEXT_ORGANISER_BROWSE_NUMBERING
1140
+
1141
+ Wx::RTC.RichTextStyleOrganiserDialog(flags, sheet, @richTextCtrl, self, Wx::ID_ANY, 'Bullets and Numbering') do |dlg|
1142
+ if dlg.show_modal == Wx::ID_OK
1143
+ dlg.apply_style if dlg.get_selected_style_definition
1144
+ end
1145
+ end
1146
+ end
1147
+ def on_itemize_list(_event)
1148
+ if @richTextCtrl.has_selection
1149
+ range = @richTextCtrl.get_selection_range
1150
+ @richTextCtrl.set_list_style(range, 'Bullet List 1')
1151
+ end
1152
+ end
1153
+ def on_renumber_list(_event)
1154
+ if @richTextCtrl.has_selection
1155
+ range = @richTextCtrl.get_selection_range
1156
+ @richTextCtrl.number_list(range, nil, Wx::RTC::RICHTEXT_SETSTYLE_WITH_UNDO|Wx::RTC::RICHTEXT_SETSTYLE_RENUMBER)
1157
+ end
1158
+ end
1159
+ def on_promote_list(_event)
1160
+ if @richTextCtrl.has_selection
1161
+ range = @richTextCtrl.get_selection_range
1162
+ @richTextCtrl.promote_list(1, range, nil)
1163
+ end
1164
+ end
1165
+ def on_demote_list(_event)
1166
+ if @richTextCtrl.has_selection
1167
+ range = @richTextCtrl.get_selection_range
1168
+ @richTextCtrl.promote_list(-1, range, nil)
1169
+ end
1170
+ end
1171
+ def on_clear_list(_event)
1172
+ if @richTextCtrl.has_selection
1173
+ range = @richTextCtrl.get_selection_range
1174
+ @richTextCtrl.clear_list_style(range)
1175
+ end
1176
+ end
1177
+
1178
+ def on_table_add_column(_event)
1179
+ table = @richTextCtrl.find_table
1180
+ if table.is_a?(Wx::RTC::RichTextTable)
1181
+ cellAttr = table.get_cell(0, 0).attributes
1182
+ table.add_columns(table.column_count, 1, cellAttr)
1183
+ end
1184
+ end
1185
+ def on_table_add_row(_event)
1186
+ table = @richTextCtrl.find_table
1187
+ if table.is_a?(Wx::RTC::RichTextTable)
1188
+ cellAttr = table.get_cell(0, 0).attributes
1189
+ table.add_rows(table.row_count, 1, cellAttr)
1190
+ end
1191
+ end
1192
+ def on_table_delete_column(_event)
1193
+ table = @richTextCtrl.find_table
1194
+ if table.is_a?(Wx::RTC::RichTextTable)
1195
+ _, col = table.get_focused_cell
1196
+ col = table.column_count-1 if col == -1
1197
+ table.delete_columns(col, 1)
1198
+ end
1199
+ end
1200
+ def on_table_delete_row(_event)
1201
+ table = @richTextCtrl.find_table
1202
+ if table.is_a?(Wx::RTC::RichTextTable)
1203
+ row, _ = table.get_focused_cell
1204
+ row = table.row_count-1 if row == -1
1205
+ table.delete_rows(row, 1)
1206
+ end
1207
+ end
1208
+ def on_table_focused_update_ui(event)
1209
+ event.enable(@richTextCtrl.find_table != nil)
1210
+ end
1211
+ def on_table_has_cells_update_ui(event)
1212
+ enable = false
1213
+ table = @richTextCtrl.find_table
1214
+ if table.is_a?(Wx::RTC::RichTextTable)
1215
+ if event.id == ID::TABLE_DELETE_COLUMN
1216
+ enable = table.column_count > 1
1217
+ else
1218
+ enable = table.row_count > 1
1219
+ end
1220
+ end
1221
+ event.enable(enable)
1222
+ end
1223
+
1224
+ def on_reload(_event)
1225
+ @richTextCtrl.clear
1226
+ write_initial_text
1227
+ end
1228
+
1229
+ def on_view_html(_event)
1230
+ dialog = Wx::Dialog.new(self, Wx::ID_ANY, 'HTML', Wx::DEFAULT_POSITION, [500, 400], Wx::DEFAULT_DIALOG_STYLE)
1231
+ begin
1232
+ boxSizer = Wx::VBoxSizer.new
1233
+ dialog.set_sizer(boxSizer)
1234
+
1235
+ win = Wx::HTML::HtmlWindow.new(dialog, size: [500, 400], style: Wx::SUNKEN_BORDER)
1236
+ boxSizer.add(win, 1, Wx::ALL, 5)
1237
+
1238
+ cancelButton = Wx::Button.new(dialog, Wx::ID_CANCEL, '&Close')
1239
+ boxSizer.add(cancelButton, 0, Wx::ALL|Wx::CENTRE, 5)
1240
+
1241
+ strStream = StringIO.new
1242
+
1243
+ htmlHandler = Wx::RTC::RichTextHTMLHandler.new
1244
+ htmlHandler.set_flags(Wx::RTC::RICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY)
1245
+
1246
+ fontSizeMapping = [7,9,11,12,14,22,100]
1247
+
1248
+ htmlHandler.set_font_size_mapping(fontSizeMapping)
1249
+
1250
+ if htmlHandler.save_file(@richTextCtrl.buffer, strStream)
1251
+ strStream.rewind
1252
+ win.set_page(strStream.read || '')
1253
+ end
1254
+
1255
+ boxSizer.fit(dialog)
1256
+
1257
+ dialog.show_modal
1258
+
1259
+ # Now delete the temporary in-memory images
1260
+ htmlHandler.delete_temporary_images
1261
+ ensure
1262
+ dialog.destroy
1263
+ end
1264
+ end
1265
+
1266
+ class << self
1267
+ def alternate_style_sheet
1268
+ @alternate_style_sheet
1269
+ end
1270
+ def alternate_style_sheet=(alt)
1271
+ @alternate_style_sheet = alt
1272
+ end
1273
+ end
1274
+
1275
+ # Demonstrates how you can change the style sheets and have the changes
1276
+ # reflected in the control content without wiping out character formatting.
1277
+ def on_switch_stylesheets(_event)
1278
+ styleList = find_window_by_id(ID::RICHTEXT_STYLE_LIST)
1279
+ styleCombo = find_window_by_id(ID::RICHTEXT_STYLE_COMBO)
1280
+
1281
+ sheet = @richTextCtrl.get_style_sheet
1282
+
1283
+ # One-time creation of an alternate style sheet
1284
+ unless MyFrame.alternate_style_sheet
1285
+ MyFrame.alternate_style_sheet = Wx::RTC::RichTextStyleSheet.new(sheet)
1286
+
1287
+ # Make some modifications
1288
+ MyFrame.alternate_style_sheet.paragraph_style_count.times do |i|
1289
+ style_def = MyFrame.alternate_style_sheet.get_paragraph_style(i)
1290
+
1291
+ style_def.get_style.set_text_colour(:BLUE) if style_def.get_style.has_text_colour
1292
+
1293
+ if style_def.get_style.has_alignment
1294
+ if style_def.get_style.get_alignment == Wx::TEXT_ALIGNMENT_CENTRE
1295
+ style_def.get_style.set_alignment(Wx::TEXT_ALIGNMENT_RIGHT)
1296
+ elsif style_def.get_style.get_alignment == Wx::TEXT_ALIGNMENT_LEFT
1297
+ style_def.get_style.set_alignment(Wx::TEXT_ALIGNMENT_CENTRE)
1298
+ end
1299
+ end
1300
+ if style_def.get_style.has_left_indent
1301
+ style_def.get_style.set_left_indent(style_def.get_style.get_left_indent * 2)
1302
+ end
1303
+ end
1304
+ end
1305
+
1306
+ # Switch sheets
1307
+ tmp = MyFrame.alternate_style_sheet
1308
+ MyFrame.alternate_style_sheet = sheet
1309
+ sheet = tmp
1310
+
1311
+ @richTextCtrl.set_style_sheet(sheet)
1312
+ @richTextCtrl.apply_style_sheet(sheet) # Makes the control reflect the new style definitions
1313
+
1314
+ styleList.set_style_sheet(sheet)
1315
+ styleList.update_styles
1316
+
1317
+ styleCombo.set_style_sheet(sheet)
1318
+ styleCombo.update_styles
1319
+ end
1320
+ def on_manage_styles(_event)
1321
+ sheet = @richTextCtrl.get_style_sheet
1322
+
1323
+ flags = Wx::RTC::RICHTEXT_ORGANISER_CREATE_STYLES|Wx::RTC::RICHTEXT_ORGANISER_EDIT_STYLES
1324
+
1325
+ Wx::RTC.RichTextStyleOrganiserDialog(flags, sheet, nil, self, Wx::ID_ANY, 'Style Manager')
1326
+ end
1327
+
1328
+ def on_insert_url(_event)
1329
+ url = Wx.get_text_from_user('URL:', 'Insert URL')
1330
+ unless url.empty?
1331
+ # Make a style suitable for showing a URL
1332
+ urlStyle = Wx::RichTextAttr.new
1333
+ urlStyle.set_text_colour(:BLUE)
1334
+ urlStyle.set_font_underlined(true)
1335
+
1336
+ @richTextCtrl.begin_style(urlStyle)
1337
+ @richTextCtrl.begin_url(url)
1338
+ @richTextCtrl.write_text(url)
1339
+ @richTextCtrl.end_url
1340
+ @richTextCtrl.end_style
1341
+ end
1342
+ end
1343
+ def on_url(event)
1344
+ Wx.message_box(event.get_string)
1345
+ end
1346
+ def on_stylesheet_replacing(event)
1347
+ event.veto
1348
+ end
1349
+
1350
+ if Wx.has_feature? :USE_PRINTING_ARCHITECTURE
1351
+
1352
+ def on_print(_event)
1353
+ Wx.get_app.get_printing.print_buffer(@richTextCtrl.buffer)
1354
+ end
1355
+ def on_preview(_event)
1356
+ Wx.get_app.get_printing.preview_buffer(@richTextCtrl.buffer)
1357
+ end
1358
+
1359
+ end
1360
+
1361
+ def on_page_setup(_event)
1362
+ # dialog = Wx::Dialog.new(self, Wx::ID_ANY, 'Testing', [10, 10], [400, 300], Wx::DEFAULT_DIALOG_STYLE)
1363
+ # begin
1364
+ # nb = Wx::Notebook.new(dialog, pos: [5, 5], size: [300, 250])
1365
+ # panel = Wx::Panel.new(nb)
1366
+ # panel2 = Wx::Panel.new(nb)
1367
+ #
1368
+ # Wx::RichTextCtrl.new(panel, pos: [5, 5], size: [200, 150], style: Wx::VSCROLL|Wx::TE_READONLY)
1369
+ # nb.add_page(panel, 'Page 1')
1370
+ #
1371
+ # Wx::RichTextCtrl.new(panel2, pos: [5, 5], size: [200, 150], style: Wx::VSCROLL|Wx::TE_READONLY)
1372
+ # nb.add_page(panel2, 'Page 2')
1373
+ #
1374
+ # Wx::Button.new(dialog, Wx::ID_OK, 'OK', [5, 180])
1375
+ #
1376
+ # dialog.show_modal
1377
+ # ensure
1378
+ # dialog.destroy
1379
+ # end
1380
+ Wx.get_app.get_printing.page_setup
1381
+ end
1382
+
1383
+ def on_insert_image(_event)
1384
+ Wx.FileDialog(self, 'Choose an image', '', '',
1385
+ 'BMP and GIF files (*.bmp;*.gif)|*.bmp;*.gif|PNG files (*.png)|*.png|JPEG files (*.jpg;*.jpeg)|*.jpg;*.jpeg') do |dialog|
1386
+ if dialog.show_modal == Wx::ID_OK
1387
+ path = dialog.path
1388
+ image = Wx::Image.new
1389
+ if image.load_file(path) && image.type != Wx::BITMAP_TYPE_INVALID
1390
+ @richTextCtrl.write_image(path, image.type)
1391
+ end
1392
+ end
1393
+ end
1394
+ end
1395
+
1396
+ def on_set_font_scale(_event)
1397
+ value = "%g" % @richTextCtrl.get_font_scale
1398
+ text = Wx.get_text_from_user('Enter a text scale factor:', 'Text Scale Factor', value, Wx.get_top_level_parent(self))
1399
+ if !text.empty? && value != text
1400
+ scale = text.to_f
1401
+ scale = 1.0 if scale == 0.0
1402
+ @richTextCtrl.set_font_scale(scale, true)
1403
+ end
1404
+ end
1405
+ def on_set_dimension_scale(_event)
1406
+ value = "%g" % @richTextCtrl.get_dimension_scale
1407
+ text = Wx.get_text_from_user('Enter a dimension scale factor:', 'Dimension Scale Factor', value, Wx.get_top_level_parent(self))
1408
+ if !text.empty? && value != text
1409
+ scale = text.to_f
1410
+ scale = 1.0 if scale == 0.0
1411
+ @richTextCtrl.set_dimension_scale(scale, true)
1412
+ end
1413
+ end
1414
+
1415
+ protected
1416
+
1417
+ class << self
1418
+
1419
+ def event_type
1420
+ @event_type ||= 0
1421
+ end
1422
+ def event_type=(v)
1423
+ @event_type = v
1424
+ end
1425
+
1426
+ def win_id
1427
+ @win_id ||= 0
1428
+ end
1429
+ def win_id=(id)
1430
+ @win_id = id.to_i
1431
+ end
1432
+
1433
+ end
1434
+
1435
+ # Write text
1436
+ def write_initial_text
1437
+ r = @richTextCtrl
1438
+
1439
+ r.set_default_style(Wx::RichTextAttr.new)
1440
+
1441
+ r.freeze
1442
+
1443
+ r.begin_suppress_undo
1444
+
1445
+ r.begin_paragraph_spacing(0, 20)
1446
+
1447
+ r.begin_alignment(Wx::TEXT_ALIGNMENT_CENTRE)
1448
+ r.begin_bold
1449
+
1450
+ r.begin_font_size(14)
1451
+
1452
+ lineBreak = ?\n
1453
+
1454
+ r.write_text("Welcome to wxRichTextCtrl, a wxWidgets control" + lineBreak + "for editing and presenting styled text and images\n")
1455
+ r.end_font_size
1456
+
1457
+ r.begin_italic
1458
+ r.write_text("by Julian Smart")
1459
+ r.end_italic
1460
+
1461
+ r.end_bold
1462
+ r.newline
1463
+
1464
+ r.write_image(Wx.Bitmap(:zebra))
1465
+
1466
+ r.newline
1467
+ r.newline
1468
+
1469
+ r.end_alignment
1470
+
1471
+ =begin
1472
+ r.begin_alignment(wxTEXT_ALIGNMENT_CENTRE)
1473
+ r.write_text("This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side.")
1474
+ r.newline
1475
+ r.end_alignment
1476
+ =end
1477
+
1478
+ r.begin_alignment(Wx::TEXT_ALIGNMENT_LEFT)
1479
+ imageAttr = Wx::RTC::RichTextAttr.new
1480
+ imageAttr.get_text_box_attr.set_float_mode(Wx::TEXT_BOX_ATTR_FLOAT_LEFT)
1481
+ r.write_text("This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side. This is a simple test for a floating left image test. The zebra image should be placed at the left side of the current buffer and all the text should flow around it at the right side.")
1482
+ r.write_image(Wx.Bitmap(:zebra), Wx::BITMAP_TYPE_PNG, imageAttr)
1483
+
1484
+ imageAttr.get_text_box_attr.top.set_value(200)
1485
+ imageAttr.get_text_box_attr.top.set_units(Wx::TEXT_ATTR_UNITS_PIXELS)
1486
+ imageAttr.get_text_box_attr.set_float_mode(Wx::TEXT_BOX_ATTR_FLOAT_RIGHT)
1487
+ r.write_image(Wx.Bitmap(:zebra), Wx::BITMAP_TYPE_PNG, imageAttr)
1488
+ r.write_text("This is a simple test for a floating right image test. The zebra image should be placed at the right side of the current buffer and all the text should flow around it at the left side. This is a simple test for a floating left image test. The zebra image should be placed at the right side of the current buffer and all the text should flow around it at the left side. This is a simple test for a floating left image test. The zebra image should be placed at the right side of the current buffer and all the text should flow around it at the left side.")
1489
+ r.end_alignment
1490
+ r.newline
1491
+
1492
+ r.write_text("What can you do with this thing? ")
1493
+
1494
+ r.write_image(Wx.Bitmap(:smiley))
1495
+ r.write_text(" Well, you can change text ")
1496
+
1497
+ r.begin_text_colour(Wx::RED)
1498
+ r.write_text("colour, like this red bit.")
1499
+ r.end_text_colour
1500
+
1501
+ backgroundColourAttr = Wx::RTC::RichTextAttr.new
1502
+ backgroundColourAttr.set_background_colour(Wx::GREEN)
1503
+ backgroundColourAttr.set_text_colour(:BLUE)
1504
+ r.begin_style(backgroundColourAttr)
1505
+ r.write_text(" And this blue on green bit.")
1506
+ r.end_style
1507
+
1508
+ r.write_text(" Naturally you can make things ")
1509
+ r.begin_bold
1510
+ r.write_text("bold ")
1511
+ r.end_bold
1512
+ r.begin_italic
1513
+ r.write_text("or italic ")
1514
+ r.end_italic
1515
+ r.begin_underline
1516
+ r.write_text("or underlined.")
1517
+ r.end_underline
1518
+
1519
+ r.begin_font_size(14)
1520
+ r.write_text(" Different font sizes on the same line is allowed, too.")
1521
+ r.end_font_size
1522
+
1523
+ r.write_text(" Next we'll show an indented paragraph.")
1524
+
1525
+ r.newline
1526
+
1527
+ r.begin_left_indent(60)
1528
+ r.write_text("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.")
1529
+ r.newline
1530
+
1531
+ r.end_left_indent
1532
+
1533
+ r.write_text("Next, we'll show a first-line indent, achieved using BeginLeftIndent(100, -40).")
1534
+
1535
+ r.newline
1536
+
1537
+ r.begin_left_indent(100, -40)
1538
+
1539
+ r.write_text("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.")
1540
+ r.newline
1541
+
1542
+ r.end_left_indent
1543
+
1544
+ r.write_text("Numbered bullets are possible, again using subindents:")
1545
+ r.newline
1546
+
1547
+ r.begin_numbered_bullet(1, 100, 60)
1548
+ r.write_text("This is my first item. Note that wxRichTextCtrl can apply numbering and bullets automatically based on list styles, but this list is formatted explicitly by setting indents.")
1549
+ r.newline
1550
+ r.end_numbered_bullet
1551
+
1552
+ r.begin_numbered_bullet(2, 100, 60)
1553
+ r.write_text("This is my second item.")
1554
+ r.newline
1555
+ r.end_numbered_bullet
1556
+
1557
+ r.write_text("The following paragraph is right-indented:")
1558
+ r.newline
1559
+
1560
+ r.begin_right_indent(200)
1561
+
1562
+ r.write_text("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.")
1563
+ r.newline
1564
+
1565
+ r.end_right_indent
1566
+
1567
+ r.write_text("The following paragraph is right-aligned with 1.5 line spacing:")
1568
+ r.newline
1569
+
1570
+ r.begin_alignment(Wx::TEXT_ALIGNMENT_RIGHT)
1571
+ r.begin_line_spacing(Wx::TEXT_ATTR_LINE_SPACING_HALF)
1572
+ r.write_text("It was in January, the most down-trodden month of an Edinburgh winter. An attractive woman came into the cafe, which is nothing remarkable.")
1573
+ r.newline
1574
+ r.end_line_spacing
1575
+ r.end_alignment
1576
+
1577
+ tabs = [400, 600, 800, 1000]
1578
+ attr = Wx::RichTextAttr.new
1579
+ attr.set_flags(Wx::TEXT_ATTR_TABS)
1580
+ attr.set_tabs(tabs)
1581
+ r.set_default_style(attr)
1582
+
1583
+ r.write_text("This line contains tabs:\tFirst tab\tSecond tab\tThird tab")
1584
+ r.newline
1585
+
1586
+ r.write_text("Other notable features of wxRichTextCtrl include:")
1587
+ r.newline
1588
+
1589
+ r.begin_symbol_bullet('*', 100, 60)
1590
+ r.write_text("Compatibility with wxTextCtrl API")
1591
+ r.newline
1592
+ r.end_symbol_bullet
1593
+
1594
+ r.begin_symbol_bullet('*', 100, 60)
1595
+ r.write_text("Easy stack-based BeginXXX()...EndXXX() style setting in addition to SetStyle()")
1596
+ r.newline
1597
+ r.end_symbol_bullet
1598
+
1599
+ r.begin_symbol_bullet('*', 100, 60)
1600
+ r.write_text("XML loading and saving")
1601
+ r.newline
1602
+ r.end_symbol_bullet
1603
+
1604
+ r.begin_symbol_bullet('*', 100, 60)
1605
+ r.write_text("Undo/Redo, with batching option and Undo suppressing")
1606
+ r.newline
1607
+ r.end_symbol_bullet
1608
+
1609
+ r.begin_symbol_bullet('*', 100, 60)
1610
+ r.write_text("Clipboard copy and paste")
1611
+ r.newline
1612
+ r.end_symbol_bullet
1613
+
1614
+ r.begin_symbol_bullet('*', 100, 60)
1615
+ r.write_text("wxRichTextStyleSheet with named character and paragraph styles, and control for applying named styles")
1616
+ r.newline
1617
+ r.end_symbol_bullet
1618
+
1619
+ r.begin_symbol_bullet('*', 100, 60)
1620
+ r.write_text("A design that can easily be extended to other content types, ultimately with text boxes, tables, controls, and so on")
1621
+ r.newline
1622
+ r.end_symbol_bullet
1623
+
1624
+ # Make a style suitable for showing a URL
1625
+ urlStyle = Wx::RichTextAttr.new
1626
+ urlStyle.set_text_colour(:BLUE)
1627
+ urlStyle.set_font_underlined(true)
1628
+
1629
+ r.write_text("wxRichTextCtrl can also display URLs, such as this one: ")
1630
+ r.begin_style(urlStyle)
1631
+ r.begin_url("http:#www.wxwidgets.org")
1632
+ r.write_text("The wxWidgets Web Site")
1633
+ r.end_url
1634
+ r.end_style
1635
+ r.write_text(". Click on the URL to generate an event.")
1636
+
1637
+ r.newline
1638
+
1639
+ r.write_text("Note: this sample content was generated programmatically from within the MyFrame constructor in the demo. The images were loaded from inline XPMs. Enjoy wxRichTextCtrl!\n")
1640
+
1641
+ r.end_paragraph_spacing
1642
+
1643
+ # Add a text box
1644
+
1645
+ r.newline
1646
+
1647
+ attr1 = Wx::RichTextAttr.new
1648
+ attr1.get_text_box_attr.margins.left.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
1649
+ attr1.get_text_box_attr.margins.top.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
1650
+ attr1.get_text_box_attr.margins.right.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
1651
+ attr1.get_text_box_attr.margins.bottom.set_value(20, Wx::TEXT_ATTR_UNITS_PIXELS)
1652
+
1653
+ attr1.get_text_box_attr.border.set_colour(:BLACK)
1654
+ attr1.get_text_box_attr.border.set_width(1, Wx::TEXT_ATTR_UNITS_PIXELS)
1655
+ attr1.get_text_box_attr.border.set_style(Wx::TEXT_BOX_ATTR_BORDER_SOLID)
1656
+
1657
+ textBox = r.write_text_box(attr1)
1658
+ r.set_focus_object(textBox)
1659
+
1660
+ r.write_text("This is a text box. Just testing! Once more unto the breach, dear friends, once more...")
1661
+
1662
+ r.set_focus_object(nil) # Set the focus back to the main buffer
1663
+ r.set_insertion_point_end
1664
+
1665
+ # Add a table
1666
+
1667
+ r.newline
1668
+
1669
+ attr1 = Wx::RichTextAttr.new
1670
+ attr1.get_text_box_attr.margins.left.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
1671
+ attr1.get_text_box_attr.margins.top.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
1672
+ attr1.get_text_box_attr.margins.right.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
1673
+ attr1.get_text_box_attr.margins.bottom.set_value(5, Wx::TEXT_ATTR_UNITS_PIXELS)
1674
+ attr1.get_text_box_attr.padding.apply(attr.get_text_box_attr.margins)
1675
+
1676
+ attr1.get_text_box_attr.border.set_colour(:BLACK)
1677
+ attr1.get_text_box_attr.border.set_width(1, Wx::TEXT_ATTR_UNITS_PIXELS)
1678
+ attr1.get_text_box_attr.border.set_style(Wx::TEXT_BOX_ATTR_BORDER_SOLID)
1679
+
1680
+ cellAttr = Wx::RichTextAttr.new(attr1)
1681
+ cellAttr.get_text_box_attr.width.set_value(200, Wx::TEXT_ATTR_UNITS_PIXELS)
1682
+ cellAttr.get_text_box_attr.height.set_value(150, Wx::TEXT_ATTR_UNITS_PIXELS)
1683
+
1684
+ table = r.write_table(6, 4, attr1, cellAttr)
1685
+
1686
+ table.get_row_count.times do |j|
1687
+ table.get_column_count.times do |i|
1688
+ msg = "This is cell %d, %d" % [(j+1), (i+1)]
1689
+ r.set_focus_object(table.cell(j, i))
1690
+ r.write_text(msg)
1691
+ end
1692
+ end
1693
+
1694
+ # Demonstrate colspan and rowspan
1695
+ cell = table.cell(1, 0)
1696
+ cell.set_col_span(2)
1697
+ r.set_focus_object(cell)
1698
+ cell.clear
1699
+ r.write_text("This cell spans 2 columns")
1700
+
1701
+ cell = table.cell(1, 3)
1702
+ cell.set_row_span(2)
1703
+ r.set_focus_object(cell)
1704
+ cell.clear
1705
+ r.write_text("This cell spans 2 rows")
1706
+
1707
+ cell = table.cell(2, 1)
1708
+ cell.set_col_span(2)
1709
+ cell.set_row_span(3)
1710
+ r.set_focus_object(cell)
1711
+ cell.clear
1712
+ r.write_text("This cell spans 2 columns and 3 rows")
1713
+
1714
+ r.set_focus_object(nil) # Set the focus back to the main buffer
1715
+ r.set_insertion_point_end
1716
+
1717
+ r.newline; r.newline
1718
+
1719
+ properties = Wx::RTC::RichTextProperties.new
1720
+ r.write_text("This is a rectangle field: ")
1721
+ r.write_field("rectangle", properties)
1722
+ r.write_text(" and a begin section field: ")
1723
+ r.write_field("begin-section", properties)
1724
+ r.write_text("This is text between the two tags.")
1725
+ r.write_field("end-section", properties)
1726
+ r.write_text(" Now a bitmap. ")
1727
+ r.write_field("bitmap", properties)
1728
+ r.write_text(" Before we go, here's a composite field: ***")
1729
+ field = r.write_field("composite", properties)
1730
+ field.update_field(r.get_buffer) # Creates the composite value (sort of a text box)
1731
+ r.write_text("*** End of composite field.")
1732
+
1733
+ r.newline
1734
+ r.end_suppress_undo
1735
+
1736
+ # Add some locked content first - needs Undo to be enabled
1737
+ r.begin_lock
1738
+ r.write_text("This is a locked object.")
1739
+ r.end_lock
1740
+
1741
+ r.write_text(" This is unlocked text. ")
1742
+
1743
+ r.begin_lock
1744
+ r.write_text("More locked content.")
1745
+ r.end_lock
1746
+ r.newline
1747
+
1748
+ # Flush the Undo buffer
1749
+ r.command_processor.clear_commands
1750
+
1751
+ r.thaw
1752
+ end
1753
+
1754
+ end
1755
+
1756
+ module RichTextExtSample
1757
+
1758
+ include WxRuby::Sample if defined? WxRuby::Sample
1759
+
1760
+ def self.describe
1761
+ { file: __FILE__,
1762
+ summary: 'wxRuby extended Wx::RichTextCtrl demo.',
1763
+ description: <<~__HEREDOC
1764
+ Extended wxRuby sample for Wx::RichTextCtrl
1765
+ It includes the following functionality:
1766
+
1767
+ * Text entry, paragraph wrapping
1768
+ * Scrolling, keyboard navigation
1769
+ * Application of character styles:
1770
+ bold, italic, underlined, font face, text colour
1771
+ * Application of paragraph styles:
1772
+ left/right indentation, sub-indentation (first-line indent),
1773
+ paragraph spacing (before and after), line spacing,
1774
+ left/centre/right alignment, numbered bullets
1775
+ * Insertion of images
1776
+ * Copy/paste
1777
+ * Undo/Redo with optional batching and undo history suppression
1778
+ * Named paragraph and character styles management and application
1779
+ * File handlers allow addition of file formats
1780
+ * Text saving and loading, XML saving and loading, HTML saving (unfinished)
1781
+ * etc.
1782
+ __HEREDOC
1783
+ }
1784
+ end
1785
+
1786
+ def self.run
1787
+ execute(__FILE__)
1788
+ end
1789
+
1790
+ if $0 == __FILE__
1791
+ MyApp.run
1792
+ end
1793
+
1794
+ end