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

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