wxruby3 0.9.1 → 0.9.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -0
- data/INSTALL.md +35 -29
- data/README.md +24 -15
- data/ext/wxruby3/include/wxRubyApp.h +338 -0
- data/ext/wxruby3/include/wxruby-ClientData.h +48 -0
- data/ext/wxruby3/include/wxruby-Config.h +6 -6
- data/ext/wxruby3/include/wxruby-Validator.h +39 -0
- data/ext/wxruby3/include/wxruby-ValidatorBinding.h +64 -0
- data/ext/wxruby3/swig/common.i +1 -1
- data/ext/wxruby3/swig/custom/director.swg +8 -0
- data/ext/wxruby3/swig/mark_free_impl.i +0 -33
- data/lib/wx/aui/aui_tab_ctrl.rb +18 -0
- data/lib/wx/aui/auinotebook.rb +6 -2
- data/lib/wx/aui/require.rb +1 -0
- data/lib/wx/core/app.rb +2 -2
- data/lib/wx/core/bitmap_combobox.rb +17 -21
- data/lib/wx/core/collapsible_pane.rb +1 -1
- data/lib/wx/core/combobox.rb +13 -3
- data/lib/wx/core/controlwithitems.rb +40 -128
- data/lib/wx/core/enum.rb +17 -1
- data/lib/wx/core/event.rb +6 -1
- data/lib/wx/core/evthandler.rb +8 -2
- data/lib/wx/core/generic_validator.rb +312 -0
- data/lib/wx/core/listbox.rb +2 -2
- data/lib/wx/core/log.rb +1 -1
- data/lib/wx/core/menu.rb +10 -0
- data/lib/wx/core/notebook.rb +6 -2
- data/lib/wx/core/owner_drawn_combobox.rb +45 -0
- data/lib/wx/core/size.rb +4 -0
- data/lib/wx/core/sizer.rb +12 -2
- data/lib/wx/core/standard_paths.rb +22 -0
- data/lib/wx/core/task_bar_button.rb +19 -0
- data/lib/wx/core/text_entry.rb +4 -1
- data/lib/wx/core/textctrl.rb +11 -1
- data/lib/wx/core/{treectrl.rb → tree_ctrl.rb} +31 -12
- data/lib/wx/core/validator.rb +70 -5
- data/lib/wx/core/window.rb +13 -7
- data/lib/wx/doc/app.rb +48 -38
- data/lib/wx/doc/art_locator.rb +48 -43
- data/lib/wx/doc/aui/auimanager.rb +16 -8
- data/lib/wx/doc/aui/auinotebook.rb +20 -5
- data/lib/wx/doc/clipboard.rb +11 -7
- data/lib/wx/doc/colour_dialog.rb +14 -10
- data/lib/wx/doc/comboctrl.rb +18 -0
- data/lib/wx/doc/controlwithitems.rb +34 -8
- data/lib/wx/doc/data_object.rb +2 -2
- data/lib/wx/doc/date_picker_ctrl.rb +23 -0
- data/lib/wx/doc/editable_listbox.rb +44 -0
- data/lib/wx/doc/enum.rb +15 -0
- data/lib/wx/doc/event.rb +12 -0
- data/lib/wx/doc/evthandler.rb +113 -108
- data/lib/wx/doc/extra/12_client_data.md +89 -0
- data/lib/wx/doc/extra/13_validators.md +139 -0
- data/lib/wx/doc/font.rb +1 -0
- data/lib/wx/doc/gc_dc.rb +6 -1
- data/lib/wx/doc/gdi_common.rb +4 -0
- data/lib/wx/doc/generic_validator.rb +95 -0
- data/lib/wx/doc/graphics_context.rb +1 -0
- data/lib/wx/doc/grid/grid.rb +22 -1
- data/lib/wx/doc/help_controller.rb +11 -7
- data/lib/wx/doc/html/html_help_controller.rb +12 -4
- data/lib/wx/doc/html/simple_html_listbox.rb +22 -0
- data/lib/wx/doc/list_ctrl.rb +33 -29
- data/lib/wx/doc/menu.rb +20 -0
- data/lib/wx/doc/notebook.rb +21 -0
- data/lib/wx/doc/num_validator.rb +387 -0
- data/lib/wx/doc/owner_drawn_combobox.rb +96 -0
- data/lib/wx/doc/pg/events.rb +13 -9
- data/lib/wx/doc/pg/numeric_property_validator.rb +33 -0
- data/lib/wx/doc/pg/pg_property.rb +18 -0
- data/lib/wx/doc/progress_dialog.rb +36 -32
- data/lib/wx/doc/prt/page_setup_dialog.rb +20 -12
- data/lib/wx/doc/prt/print_data.rb +13 -5
- data/lib/wx/doc/prt/print_dialog.rb +31 -23
- data/lib/wx/doc/prt/printer.rb +20 -12
- data/lib/wx/doc/radio_box.rb +19 -15
- data/lib/wx/doc/rbn/ribbon_bar.rb +13 -5
- data/lib/wx/doc/rbn/ribbon_button_bar.rb +13 -5
- data/lib/wx/doc/rbn/ribbon_gallery.rb +13 -5
- data/lib/wx/doc/rbn/ribbon_tool_bar.rb +13 -5
- data/lib/wx/doc/region_iterator.rb +32 -28
- data/lib/wx/doc/rtc/rich_text_composite_object.rb +24 -0
- data/lib/wx/doc/rtc/rich_text_ctrl.rb +24 -0
- data/lib/wx/doc/rtc/rich_text_paragraph.rb +24 -0
- data/lib/wx/doc/rtc/richtext_buffer.rb +27 -19
- data/lib/wx/doc/rtc/richtext_printing.rb +17 -9
- data/lib/wx/doc/rtc/richtext_style_sheet.rb +17 -9
- data/lib/wx/doc/sizer.rb +20 -0
- data/lib/wx/doc/static_bitmap.rb +25 -0
- data/lib/wx/doc/stc/styled_text_ctrl.rb +24 -0
- data/lib/wx/doc/stream.rb +39 -35
- data/lib/wx/doc/system_settings.rb +30 -26
- data/lib/wx/doc/text_validator.rb +23 -9
- data/lib/wx/doc/textctrl.rb +16 -0
- data/lib/wx/doc/tree_ctrl.rb +95 -0
- data/lib/wx/doc/treebook.rb +9 -5
- data/lib/wx/doc/v_list_box.rb +9 -5
- data/lib/wx/doc/validator.rb +113 -0
- data/lib/wx/doc/variant.rb +164 -160
- data/lib/wx/doc/window.rb +87 -47
- data/lib/wx/doc/window_disabler.rb +10 -6
- data/lib/wx/grid/grid.rb +27 -4
- data/lib/wx/html/simple_html_listbox.rb +24 -91
- data/lib/wx/keyword_defs.rb +34 -2
- data/lib/wx/pg/pg_property.rb +22 -0
- data/lib/wx/rbn/ribbon_gallery.rb +0 -21
- data/lib/wx/rtc/require.rb +3 -0
- data/lib/wx/rtc/rich_text_composite_object.rb +25 -0
- data/lib/wx/rtc/rich_text_ctrl.rb +25 -0
- data/lib/wx/rtc/rich_text_paragraph.rb +25 -0
- data/lib/wx/stc/require.rb +1 -0
- data/lib/wx/stc/styled_text_ctrl.rb +25 -0
- data/lib/wx/version.rb +1 -1
- data/rakelib/lib/config/linux.rb +0 -3
- data/rakelib/lib/config/macosx.rb +2 -2
- data/rakelib/lib/config/mingw.rb +13 -1
- data/rakelib/lib/config/unixish.rb +1 -1
- data/rakelib/lib/config.rb +14 -4
- data/rakelib/lib/core/include/client_data.inc +65 -0
- data/rakelib/lib/core/include/funcall.inc +1 -1
- data/rakelib/lib/core/package.rb +31 -9
- data/rakelib/lib/core/parameter.rb +1 -1
- data/rakelib/lib/core/spec.rb +6 -1
- data/rakelib/lib/core/spec_helper.rb +7 -1
- data/rakelib/lib/director/accelerator.rb +2 -3
- data/rakelib/lib/director/accessible.rb +47 -0
- data/rakelib/lib/director/app.rb +30 -319
- data/rakelib/lib/director/app_traits.rb +13 -13
- data/rakelib/lib/director/bitmap_combobox.rb +2 -2
- data/rakelib/lib/director/combobox.rb +22 -0
- data/rakelib/lib/director/comboctrl.rb +1 -55
- data/rakelib/lib/director/ctrl_with_items.rb +105 -26
- data/rakelib/lib/director/data_format.rb +1 -1
- data/rakelib/lib/director/date_picker_ctrl.rb +8 -6
- data/rakelib/lib/director/derived_dc.rb +1 -1
- data/rakelib/lib/director/dialog.rb +1 -0
- data/rakelib/lib/director/drag_image.rb +2 -3
- data/rakelib/lib/director/editable_listbox.rb +30 -0
- data/rakelib/lib/director/event.rb +104 -14
- data/rakelib/lib/director/event_handler.rb +3 -2
- data/rakelib/lib/director/frame.rb +1 -3
- data/rakelib/lib/director/functions.rb +4 -2
- data/rakelib/lib/director/gdicommon.rb +8 -10
- data/rakelib/lib/director/generic_dirctrl.rb +17 -0
- data/rakelib/lib/director/graphics_context.rb +2 -4
- data/rakelib/lib/director/grid_cell_attr.rb +0 -2
- data/rakelib/lib/director/grid_cell_editor.rb +0 -2
- data/rakelib/lib/director/grid_cell_renderer.rb +0 -2
- data/rakelib/lib/director/grid_ctrl.rb +34 -3
- data/rakelib/lib/director/header_ctrl.rb +6 -1
- data/rakelib/lib/director/html_listbox.rb +96 -22
- data/rakelib/lib/director/icon.rb +5 -2
- data/rakelib/lib/director/list_ctrl.rb +5 -6
- data/rakelib/lib/director/locale.rb +1 -3
- data/rakelib/lib/director/log.rb +1 -4
- data/rakelib/lib/director/media_ctrl.rb +54 -0
- data/rakelib/lib/director/menu.rb +16 -1
- data/rakelib/lib/director/menu_item.rb +2 -2
- data/rakelib/lib/director/num_validator.rb +495 -0
- data/rakelib/lib/director/numeric_property_validator.rb +131 -6
- data/rakelib/lib/director/owner_drawn_combobox.rb +192 -0
- data/rakelib/lib/director/pgproperties.rb +1 -1
- data/rakelib/lib/director/pgproperty.rb +27 -30
- data/rakelib/lib/director/property_grid_interface.rb +5 -10
- data/rakelib/lib/director/ribbon_button_bar.rb +3 -3
- data/rakelib/lib/director/ribbon_gallery.rb +3 -5
- data/rakelib/lib/director/richtext_composite_object.rb +25 -0
- data/rakelib/lib/director/richtext_ctrl.rb +14 -4
- data/rakelib/lib/director/richtext_formatting_dialog.rb +7 -5
- data/rakelib/lib/director/richtext_paragraph_layout_box.rb +9 -7
- data/rakelib/lib/director/sizer.rb +30 -4
- data/rakelib/lib/director/sizer_item.rb +13 -0
- data/rakelib/lib/director/static_bitmap.rb +28 -0
- data/rakelib/lib/director/static_box.rb +4 -5
- data/rakelib/lib/director/styled_text_ctrl.rb +12 -0
- data/rakelib/lib/director/task_bar_button.rb +30 -0
- data/rakelib/lib/director/task_bar_icon.rb +5 -13
- data/rakelib/lib/director/text_entry.rb +4 -0
- data/rakelib/lib/director/text_validator.rb +124 -13
- data/rakelib/lib/director/textctrl.rb +12 -1
- data/rakelib/lib/director/toggle_button.rb +1 -0
- data/rakelib/lib/director/tool_tip.rb +1 -1
- data/rakelib/lib/director/top_level_window.rb +4 -7
- data/rakelib/lib/director/tree_ctrl.rb +40 -6
- data/rakelib/lib/director/utils.rb +16 -2
- data/rakelib/lib/director/validator.rb +196 -21
- data/rakelib/lib/director/variant.rb +1 -1
- data/rakelib/lib/director/window.rb +40 -7
- data/rakelib/lib/director.rb +4 -4
- data/rakelib/lib/extractor/function.rb +8 -7
- data/rakelib/lib/extractor.rb +34 -5
- data/rakelib/lib/generate/analyzer.rb +9 -4
- data/rakelib/lib/generate/doc/busy_info.yaml +0 -2
- data/rakelib/lib/generate/doc/clipboard.yaml +0 -2
- data/rakelib/lib/generate/doc/cursor.yaml +0 -2
- data/rakelib/lib/generate/doc/panel.yaml +7 -0
- data/rakelib/lib/generate/doc.rb +85 -17
- data/rakelib/lib/specs/interfaces.rb +163 -160
- data/rakelib/lib/swig_runner.rb +55 -9
- data/rakelib/lib/typemap/client_data.rb +67 -0
- data/rakelib/lib/typemap/common.rb +33 -4
- data/rakelib/lib/typemap/datetime.rb +1 -1
- data/rakelib/lib/typemap/tree_itemid.rb +2 -2
- data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +74 -2
- data/rakelib/yard/templates/default/fulldoc/html/full_list.erb +38 -0
- data/rakelib/yard/templates/default/fulldoc/html/setup.rb +39 -0
- data/rakelib/yard/templates/default/tags/html/wxrb_require.erb +10 -0
- data/rakelib/yard/templates/default/tags/setup.rb +16 -0
- data/rakelib/yard/yard-custom-templates.rb +3 -0
- data/samples/aui/aui.rb +1237 -1233
- data/samples/calendar/calendar.rb +293 -289
- data/samples/controls/get_item_sample.rb +83 -79
- data/samples/controls/htlbox.rb +331 -327
- data/samples/dialogs/dialogs.rb +682 -694
- data/samples/dialogs/wizard.rb +52 -55
- data/samples/dragdrop/dragdrop.rb +146 -142
- data/samples/drawing/bitmap.rb +29 -26
- data/samples/drawing/bitmap_image.rb +84 -80
- data/samples/drawing/graphics_drawing.rb +209 -205
- data/samples/drawing/image_prt.rb +344 -340
- data/samples/drawing/maths_images.rb +18 -1
- data/samples/drawing/rmagic_bitmap_image.rb +88 -84
- data/samples/etc/caret.rb +306 -0
- data/samples/etc/miniframe.rb +65 -60
- data/samples/etc/sash.rb +109 -105
- data/samples/etc/scrollwin.rb +86 -80
- data/samples/etc/system_settings.rb +216 -209
- data/samples/event/activation.rb +72 -67
- data/samples/event/event.rb +160 -153
- data/samples/event/threaded.rb +8 -1
- data/samples/event/update_ui_event.rb +67 -60
- data/samples/grid/grid.rb +188 -181
- data/samples/grid/gridtablebase.rb +136 -129
- data/samples/html/html.rb +208 -204
- data/samples/mdi/mdi.rb +59 -54
- data/samples/minimal/minimal.rb +54 -51
- data/samples/minimal/nothing.rb +1 -0
- data/samples/printing/printing.rb +367 -377
- data/samples/printing/printing2.rb +203 -198
- data/samples/propgrid/propgrid.rb +2312 -2308
- data/samples/propgrid/propgrid_minimal.rb +57 -50
- data/samples/ribbon/ribbon.rb +780 -774
- data/samples/sampler/ext.rb +0 -33
- data/samples/sampler/sample.rb +4 -9
- data/samples/sampler.rb +1 -1
- data/samples/splash/splash.rb +118 -116
- data/samples/text/rich_textctrl.rb +207 -201
- data/samples/text/richtext.rb +1409 -1405
- data/samples/text/scintilla.rb +137 -128
- data/samples/text/textctrl.rb +89 -83
- data/samples/text/unicode.rb +175 -168
- data/samples/treectrl/treectrl.rb +1430 -1426
- data/samples/widgets/activityindicator.rb +95 -0
- data/samples/widgets/art/widgets/activityindicator.xpm +278 -0
- data/samples/widgets/art/widgets/bmpbtn.xpm +37 -0
- data/samples/widgets/art/widgets/bmpcombobox.xpm +54 -0
- data/samples/widgets/art/widgets/button.xpm +54 -0
- data/samples/widgets/art/widgets/checkbox.xpm +54 -0
- data/samples/{bigdemo/icons → widgets/art/widgets}/choice.xpm +1 -1
- data/samples/widgets/art/widgets/choicebk.xpm +54 -0
- data/samples/widgets/art/widgets/clrpicker.xpm +193 -0
- data/samples/widgets/art/widgets/combobox.xpm +54 -0
- data/samples/widgets/art/widgets/datepick.xpm +200 -0
- data/samples/widgets/art/widgets/dirctrl.xpm +54 -0
- data/samples/widgets/art/widgets/dirpicker.xpm +213 -0
- data/samples/widgets/art/widgets/filepicker.xpm +214 -0
- data/samples/widgets/art/widgets/fontpicker.xpm +185 -0
- data/samples/widgets/art/widgets/gauge.xpm +54 -0
- data/samples/widgets/art/widgets/header.xpm +54 -0
- data/samples/widgets/art/widgets/hyperlnk.xpm +54 -0
- data/samples/widgets/art/widgets/listbook.xpm +54 -0
- data/samples/widgets/art/widgets/listbox.xpm +54 -0
- data/samples/widgets/art/widgets/native.xpm +81 -0
- data/samples/widgets/art/widgets/notebook.xpm +54 -0
- data/samples/widgets/art/widgets/odcombobox.xpm +54 -0
- data/samples/widgets/art/widgets/radiobox.xpm +54 -0
- data/samples/widgets/art/widgets/scrolbar.xpm +54 -0
- data/samples/widgets/art/widgets/slider.xpm +54 -0
- data/samples/widgets/art/widgets/spinbtn.xpm +40 -0
- data/samples/widgets/art/widgets/statbmp.xpm +40 -0
- data/samples/widgets/art/widgets/statbox.xpm +54 -0
- data/samples/widgets/art/widgets/stattext.xpm +54 -0
- data/samples/widgets/art/widgets/text.xpm +54 -0
- data/samples/widgets/art/widgets/timepick.xpm +207 -0
- data/samples/widgets/art/widgets/toggle.xpm +54 -0
- data/samples/widgets/art/widgets/toucan.png +0 -0
- data/samples/widgets/bmpcombobox.rb +651 -0
- data/samples/widgets/button.rb +462 -0
- data/samples/widgets/checkbox.rb +211 -0
- data/samples/widgets/choice.rb +287 -0
- data/samples/widgets/clrpicker.rb +156 -0
- data/samples/widgets/combobox.rb +516 -0
- data/samples/widgets/datepick.rb +215 -0
- data/samples/widgets/dirctrl.rb +265 -0
- data/samples/widgets/dirpicker.rb +158 -0
- data/samples/widgets/editlbox.rb +122 -0
- data/samples/widgets/filectrl.rb +216 -0
- data/samples/widgets/filepicker.rb +214 -0
- data/samples/widgets/fontpicker.rb +135 -0
- data/samples/widgets/gauge.rb +311 -0
- data/samples/widgets/headerctrl.rb +236 -0
- data/samples/widgets/hyperlink.rb +203 -0
- data/samples/widgets/itemcontainer.rb +185 -0
- data/samples/widgets/listbox.rb +473 -0
- data/samples/widgets/notebook.rb +488 -0
- data/samples/widgets/odcombobox.rb +608 -0
- data/samples/widgets/radiobox.rb +328 -0
- data/samples/widgets/searchctrl.rb +159 -0
- data/samples/widgets/slider.rb +594 -0
- data/samples/widgets/spinbtn.rb +443 -0
- data/samples/widgets/statbmp.rb +130 -0
- data/samples/widgets/static.rb +436 -0
- data/samples/widgets/textctrl.rb +700 -0
- data/samples/widgets/timepick.rb +148 -0
- data/samples/widgets/tn_widgets.png +0 -0
- data/samples/widgets/toggle.rb +385 -0
- data/samples/widgets/widgets.rb +1233 -0
- data/samples/xrc/custom_xrc_sample.rb +47 -41
- data/samples/xrc/xrc_sample.rb +53 -47
- data/tests/media/beep_lo.wav +0 -0
- data/tests/test_event_handling.rb +52 -34
- data/tests/test_events.rb +7 -0
- data/tests/test_item_data.rb +24 -0
- data/tests/test_list_ctrl.rb +1 -1
- data/tests/test_media_ctrl.rb +38 -0
- data/tests/test_menu.rb +69 -0
- data/tests/test_pg.rb +27 -0
- data/tests/test_richtext.rb +45 -0
- data/tests/test_sizer.rb +59 -0
- data/tests/test_std_controls.rb +42 -1
- data/tests/test_styled_text_ctrl.rb +46 -0
- data/tests/test_tree_ctrl.rb +138 -0
- data/tests/test_validators.rb +805 -0
- data/tests/test_window.rb +12 -0
- data/tests/testapp_noframe.rb +1 -1
- metadata +121 -139
- data/lib/wx/core/choice.rb +0 -14
- data/lib/wx/core/combo_ctrl.rb +0 -110
- data/rakelib/lib/typemap/grid_client_data.rb +0 -58
- data/samples/bigdemo/About.rbw +0 -39
- data/samples/bigdemo/ColorPanel.rbw +0 -23
- data/samples/bigdemo/GridSimple.rbw +0 -78
- data/samples/bigdemo/MDIDemo.rbw +0 -57
- data/samples/bigdemo/PopupMenu.rbw +0 -146
- data/samples/bigdemo/ShapedWindow.rbw +0 -128
- data/samples/bigdemo/Sizers.rbw +0 -541
- data/samples/bigdemo/bigdemo.rb +0 -817
- data/samples/bigdemo/demoTemplate.rbw +0 -33
- data/samples/bigdemo/helpfile.htb +0 -0
- data/samples/bigdemo/icons/Test 015.jpg +0 -0
- data/samples/bigdemo/icons/Test 015.png +0 -0
- data/samples/bigdemo/icons/choice.bmp +0 -0
- data/samples/bigdemo/icons/combo.bmp +0 -0
- data/samples/bigdemo/icons/combo.xpm +0 -27
- data/samples/bigdemo/icons/copy.xpm +0 -25
- data/samples/bigdemo/icons/cut.xpm +0 -24
- data/samples/bigdemo/icons/gauge.bmp +0 -0
- data/samples/bigdemo/icons/gauge.xpm +0 -27
- data/samples/bigdemo/icons/help.xpm +0 -25
- data/samples/bigdemo/icons/list.bmp +0 -0
- data/samples/bigdemo/icons/list.xpm +0 -27
- data/samples/bigdemo/icons/mondrian.ico +0 -0
- data/samples/bigdemo/icons/mondrian.xpm +0 -44
- data/samples/bigdemo/icons/new.xpm +0 -24
- data/samples/bigdemo/icons/ogl.ico +0 -0
- data/samples/bigdemo/icons/ogl.xpm +0 -45
- data/samples/bigdemo/icons/open.xpm +0 -26
- data/samples/bigdemo/icons/paste.bmp +0 -0
- data/samples/bigdemo/icons/paste.xpm +0 -38
- data/samples/bigdemo/icons/pointy.png +0 -0
- data/samples/bigdemo/icons/preview.xpm +0 -26
- data/samples/bigdemo/icons/print.xpm +0 -26
- data/samples/bigdemo/icons/radio.bmp +0 -0
- data/samples/bigdemo/icons/radio.xpm +0 -27
- data/samples/bigdemo/icons/robert.xpm +0 -415
- data/samples/bigdemo/icons/sashtest.ico +0 -0
- data/samples/bigdemo/icons/save.xpm +0 -25
- data/samples/bigdemo/icons/smiles.bmp +0 -0
- data/samples/bigdemo/icons/smiles.xpm +0 -39
- data/samples/bigdemo/icons/smiley.ico +0 -0
- data/samples/bigdemo/icons/smiley.xpm +0 -42
- data/samples/bigdemo/icons/stattext.xpm +0 -24
- data/samples/bigdemo/icons/test2.bmp +0 -0
- data/samples/bigdemo/icons/test2.png +0 -0
- data/samples/bigdemo/icons/test2.xpm +0 -79
- data/samples/bigdemo/icons/text.bmp +0 -0
- data/samples/bigdemo/icons/text.xpm +0 -27
- data/samples/bigdemo/icons/tog1.bmp +0 -0
- data/samples/bigdemo/icons/tog1.xpm +0 -38
- data/samples/bigdemo/icons/tog2.bmp +0 -0
- data/samples/bigdemo/icons/tog2.xpm +0 -38
- data/samples/bigdemo/icons/wxruby-128x128.png +0 -0
- data/samples/bigdemo/icons/wxwin.ico +0 -0
- data/samples/bigdemo/icons/wxwin16x16.png +0 -0
- data/samples/bigdemo/icons/wxwin16x16.xpm +0 -25
- data/samples/bigdemo/icons/wxwin32x32.png +0 -0
- data/samples/bigdemo/icons/wxwin48x48.png +0 -0
- data/samples/bigdemo/run.rb +0 -98
- data/samples/bigdemo/tips.txt +0 -7
- data/samples/bigdemo/utils.rb +0 -20
- data/samples/bigdemo/wxArtProvider.rbw +0 -282
- data/samples/bigdemo/wxBitmapButton.rbw +0 -65
- data/samples/bigdemo/wxButton.rbw +0 -64
- data/samples/bigdemo/wxCalendarCtrl.rbw +0 -59
- data/samples/bigdemo/wxCheckBox.rbw +0 -50
- data/samples/bigdemo/wxCheckListBox.rbw +0 -65
- data/samples/bigdemo/wxChoice.rbw +0 -47
- data/samples/bigdemo/wxChoicebook.rbw +0 -78
- data/samples/bigdemo/wxColourDialog.rbw +0 -33
- data/samples/bigdemo/wxComboBox.rbw +0 -77
- data/samples/bigdemo/wxCursor.rbw +0 -136
- data/samples/bigdemo/wxDialog.rbw +0 -74
- data/samples/bigdemo/wxDirDialog.rbw +0 -29
- data/samples/bigdemo/wxDragImage.rbw +0 -70
- data/samples/bigdemo/wxFileDialog.rbw +0 -37
- data/samples/bigdemo/wxFileDialog_Save.rbw +0 -35
- data/samples/bigdemo/wxFindReplaceDialog.rbw +0 -82
- data/samples/bigdemo/wxFontDialog.rbw +0 -200
- data/samples/bigdemo/wxFrame.rbw +0 -53
- data/samples/bigdemo/wxGauge.rbw +0 -65
- data/samples/bigdemo/wxGenericDirCtrl.rbw +0 -74
- data/samples/bigdemo/wxGrid.rbw +0 -66
- data/samples/bigdemo/wxHtmlHelpController.rbw +0 -52
- data/samples/bigdemo/wxListBox.rbw +0 -140
- data/samples/bigdemo/wxListCtrl_virtual.rbw +0 -112
- data/samples/bigdemo/wxMDIWindows.rbw +0 -50
- data/samples/bigdemo/wxMenu.rbw +0 -247
- data/samples/bigdemo/wxMessageDialog.rbw +0 -27
- data/samples/bigdemo/wxMiniFrame.rbw +0 -70
- data/samples/bigdemo/wxMultipleChoiceDialog.rbw +0 -29
- data/samples/bigdemo/wxNotebook.rbw +0 -136
- data/samples/bigdemo/wxProgressDialog.rbw +0 -43
- data/samples/bigdemo/wxRadioBox.rbw +0 -72
- data/samples/bigdemo/wxRadioButton.rbw +0 -125
- data/samples/bigdemo/wxSashWindow.rbw +0 -141
- data/samples/bigdemo/wxScrolledMessageDialog.rbw +0 -57
- data/samples/bigdemo/wxScrolledWindow.rbw +0 -199
- data/samples/bigdemo/wxSingleChoiceDialog.rbw +0 -33
- data/samples/bigdemo/wxSlider.rbw +0 -42
- data/samples/bigdemo/wxSpinButton.rbw +0 -50
- data/samples/bigdemo/wxSpinCtrl.rbw +0 -51
- data/samples/bigdemo/wxSplitterWindow.rbw +0 -63
- data/samples/bigdemo/wxStaticBitmap.rbw +0 -47
- data/samples/bigdemo/wxStaticText.rbw +0 -55
- data/samples/bigdemo/wxStatusBar.rbw +0 -126
- data/samples/bigdemo/wxTextCtrl.rbw +0 -149
- data/samples/bigdemo/wxTextEntryDialog.rbw +0 -31
- data/samples/bigdemo/wxToggleButton.rbw +0 -49
- data/samples/bigdemo/wxToolBar.rbw +0 -131
- data/samples/bigdemo/wxTreeCtrl.rbw +0 -191
- data/samples/caret/caret.rb +0 -298
- data/samples/caret/mondrian.xpm +0 -44
- data/samples/controls/books.rb +0 -189
- data/samples/controls/choice.xpm +0 -27
- data/samples/controls/combo.xpm +0 -27
- data/samples/controls/controls.rb +0 -1099
- data/samples/controls/gauge.xpm +0 -27
- data/samples/controls/list.xpm +0 -27
- data/samples/controls/mondrian.ico +0 -0
- data/samples/controls/mondrian.xpm +0 -44
- data/samples/controls/radio.xpm +0 -27
- data/samples/controls/stattext.xpm +0 -24
- data/samples/controls/test2.bmp +0 -0
- data/samples/controls/text.xpm +0 -27
- data/samples/controls/tn_books.png +0 -0
- data/samples/controls/tn_controls.png +0 -0
- data/samples/etc/choice.rb +0 -87
- data/samples/etc/tn_choice.png +0 -0
- data/samples/text/mondrian.ico +0 -0
- data/samples/text/mondrian.xpm +0 -44
- /data/samples/{caret → etc}/tn_caret.png +0 -0
data/samples/text/richtext.rb
CHANGED
@@ -8,1747 +8,1751 @@
|
|
8
8
|
require 'wx'
|
9
9
|
require 'stringio'
|
10
10
|
|
11
|
-
|
12
|
-
class RichTextFieldTypePropertiesTest < Wx::RTC::RichTextFieldTypeStandard
|
11
|
+
module RichTextExt
|
13
12
|
|
14
|
-
|
15
|
-
|
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
|
-
|
21
|
-
|
22
|
-
|
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
|
-
|
27
|
-
get_label
|
28
|
-
end
|
20
|
+
def can_edit_properties(_obj); true; end
|
29
21
|
|
30
|
-
|
22
|
+
def edit_properties(_obj, _parent, _buffer)
|
23
|
+
label = get_label
|
24
|
+
Wx.message_box("Editing #{label}")
|
25
|
+
true
|
26
|
+
end
|
31
27
|
|
32
|
-
|
33
|
-
|
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
|
-
|
40
|
-
|
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
|
-
|
37
|
+
def initialize(name, label)
|
38
|
+
super(name, label, Wx::RTC::RICHTEXT_FIELD_STYLE_COMPOSITE)
|
39
|
+
end
|
56
40
|
|
57
|
-
|
58
|
-
|
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
|
-
|
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
|
-
|
70
|
-
def has_virtual_attributes(obj)
|
71
|
-
obj.get_properties.has_property("Lock")
|
72
|
-
end
|
64
|
+
class RichTextEnhancedDrawingHandler < Wx::RTC::RichTextDrawingHandler
|
73
65
|
|
74
|
-
|
75
|
-
|
76
|
-
|
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
|
-
|
85
|
-
|
86
|
-
|
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
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
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
|
-
|
94
|
-
|
95
|
-
|
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
|
-
|
99
|
-
|
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
|
-
|
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
|
-
#
|
104
|
-
|
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
|
-
|
105
|
+
# Define a new application type, each program should derive a class from wxApp
|
106
|
+
class MyRichTextCtrl < Wx::RTC::RichTextCtrl
|
114
107
|
|
115
|
-
|
116
|
-
|
117
|
-
|
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
|
-
|
120
|
-
|
121
|
-
|
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
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
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
|
-
|
137
|
+
end
|
135
138
|
end
|
136
|
-
end
|
137
139
|
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
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
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
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
|
-
|
156
|
+
lock1 = lock2 = -1
|
164
157
|
|
165
|
-
|
166
|
-
|
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
|
-
|
169
|
-
end
|
165
|
+
return false if lock1 != -1 && lock1 == lock2
|
170
166
|
|
171
|
-
|
172
|
-
|
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
|
-
|
176
|
-
if obj.is_a?(Wx::RTC::RichTextTable)
|
177
|
-
return obj
|
170
|
+
true
|
178
171
|
end
|
179
172
|
|
180
|
-
|
181
|
-
|
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
|
-
|
188
|
-
|
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
|
-
|
191
|
-
|
192
|
-
|
189
|
+
nil
|
190
|
+
end
|
191
|
+
|
192
|
+
# Helper for FindTable()
|
193
|
+
def find_current_position
|
194
|
+
position = -1
|
193
195
|
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
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
|
-
|
200
|
-
|
201
|
-
|
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
|
-
|
211
|
+
# Define a new application type
|
212
|
+
class MyApp < Wx::App
|
208
213
|
|
209
|
-
|
210
|
-
|
214
|
+
def initialize
|
215
|
+
super
|
216
|
+
@styleSheet = nil
|
217
|
+
@printing =nil
|
218
|
+
end
|
211
219
|
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
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
|
-
|
219
|
-
|
228
|
+
if Wx.has_feature?(:USE_HELP)
|
229
|
+
Wx::HelpProvider.set(Wx::SimpleHelpProvider.new)
|
230
|
+
end
|
220
231
|
|
221
|
-
|
222
|
-
|
223
|
-
|
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
|
-
|
227
|
-
|
228
|
-
|
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
|
-
|
231
|
-
if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
|
232
|
-
@printing = Wx::RTC::RichTextPrinting.new("Test Document")
|
240
|
+
create_styles
|
233
241
|
|
234
|
-
|
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
|
-
|
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
|
-
|
248
|
+
# Add field types
|
241
249
|
|
242
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
254
|
-
|
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
|
-
|
264
|
+
s4 = RichTextFieldTypeCompositeTest.new("composite", "This is a field value")
|
265
|
+
Wx::RTC::RichTextBuffer.add_field_type(s4)
|
257
266
|
|
258
|
-
|
259
|
-
|
260
|
-
|
267
|
+
if Wx.has_feature? :USE_FILESYSTEM
|
268
|
+
Wx::FileSystem.add_handler(Wx::MemoryFSHandler.new)
|
269
|
+
end
|
261
270
|
|
262
|
-
|
263
|
-
|
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
|
-
|
266
|
-
|
267
|
-
|
276
|
+
if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
|
277
|
+
@printing.set_parent_window(frame)
|
278
|
+
end
|
268
279
|
|
269
|
-
|
270
|
-
|
271
|
-
|
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
|
-
|
275
|
-
|
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
|
-
|
279
|
-
|
280
|
-
|
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
|
-
|
283
|
-
|
284
|
-
|
285
|
-
|
286
|
-
|
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
|
-
|
289
|
-
|
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
|
-
|
417
|
+
@styleSheet.add_list_style(numberedList)
|
395
418
|
|
396
|
-
|
397
|
-
|
398
|
-
|
399
|
-
|
400
|
-
|
401
|
-
|
402
|
-
|
403
|
-
|
404
|
-
|
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
|
-
|
430
|
+
@styleSheet.add_list_style(outlineList)
|
431
|
+
end
|
411
432
|
|
412
|
-
|
433
|
+
def get_style_sheet
|
434
|
+
@styleSheet
|
413
435
|
end
|
414
436
|
|
415
|
-
|
437
|
+
if Wx.has_feature?(:USE_PRINTING_ARCHITECTURE)
|
416
438
|
|
417
|
-
|
418
|
-
|
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
|
-
|
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
|
-
|
442
|
-
|
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
|
-
|
446
|
-
|
447
|
-
|
448
|
-
|
449
|
-
|
450
|
-
|
451
|
-
|
452
|
-
|
453
|
-
|
454
|
-
|
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
|
-
|
469
|
+
RELOAD = self.next_id
|
521
470
|
|
522
|
-
|
523
|
-
|
524
|
-
|
471
|
+
INSERT_SYMBOL = self.next_id
|
472
|
+
INSERT_URL = self.next_id
|
473
|
+
INSERT_IMAGE = self.next_id
|
525
474
|
|
526
|
-
|
475
|
+
FORMAT_ALIGN_LEFT = self.next_id
|
476
|
+
FORMAT_ALIGN_CENTRE = self.next_id
|
477
|
+
FORMAT_ALIGN_RIGHT = self.next_id
|
527
478
|
|
528
|
-
|
529
|
-
|
479
|
+
FORMAT_INDENT_MORE = self.next_id
|
480
|
+
FORMAT_INDENT_LESS = self.next_id
|
530
481
|
|
531
|
-
|
532
|
-
|
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
|
-
|
536
|
-
|
537
|
-
|
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
|
-
|
544
|
-
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
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
|
-
|
644
|
-
|
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
|
-
|
647
|
-
|
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
|
-
|
505
|
+
VIEW_HTML = self.next_id
|
506
|
+
SWITCH_STYLE_SHEETS = self.next_id
|
507
|
+
MANAGE_STYLES = self.next_id
|
653
508
|
|
654
|
-
|
509
|
+
PRINT = self.next_id
|
510
|
+
PREVIEW = self.next_id
|
511
|
+
PAGE_SETUP = self.next_id
|
655
512
|
|
656
|
-
|
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
|
-
|
659
|
-
|
660
|
-
|
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
|
-
|
683
|
-
toolBar.add_control(combo)
|
522
|
+
@richTextCtrl = nil
|
684
523
|
|
685
|
-
|
524
|
+
if Wx::PLATFORM == 'WXMAC'
|
525
|
+
set_window_variant(Wx::WINDOW_VARIANT_SMALL)
|
526
|
+
end
|
686
527
|
|
687
|
-
|
688
|
-
sizer.add(splitter, 1, Wx::EXPAND)
|
528
|
+
self.icon = Wx::Icon.new(local_icon_file('../sample.xpm'))
|
689
529
|
|
690
|
-
|
691
|
-
|
692
|
-
# wxASSERT(!m_richTextCtrl.GetBuffer().GetAttributes().HasFontPixelSize())
|
530
|
+
# create a menu bar
|
531
|
+
fileMenu = Wx::Menu.new
|
693
532
|
|
694
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
645
|
+
sizer = Wx::VBoxSizer.new
|
646
|
+
set_sizer(sizer)
|
703
647
|
|
704
|
-
|
705
|
-
|
706
|
-
|
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
|
-
|
654
|
+
Wx::SystemOptions.set_option("mac.toolbar.no-native", 1)
|
709
655
|
|
710
|
-
|
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
|
-
|
658
|
+
sizer.add(toolBar, 0, Wx::EXPAND)
|
720
659
|
|
721
|
-
|
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
|
-
|
724
|
-
|
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
|
-
|
728
|
-
evt_menu(ID::Quit, :on_quit)
|
729
|
-
evt_menu(ID::About, :on_about)
|
687
|
+
toolBar.realize
|
730
688
|
|
731
|
-
|
732
|
-
|
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
|
-
|
736
|
-
|
737
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
775
|
-
evt_menu(ID::FORMAT_PARAGRAPH_SPACING_LESS, :on_paragraph_spacing_less)
|
700
|
+
# wxASSERT(!m_richTextCtrl.GetBuffer().GetAttributes().HasFontPixelSize())
|
776
701
|
|
777
|
-
|
702
|
+
@richTextCtrl.set_margins(10, 10)
|
778
703
|
|
779
|
-
|
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
|
-
|
784
|
-
|
785
|
-
|
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
|
-
|
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
|
-
|
799
|
-
|
800
|
-
|
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
|
-
|
803
|
-
|
804
|
-
|
805
|
-
|
806
|
-
|
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
|
-
|
809
|
-
|
810
|
+
evt_text_url(Wx::ID_ANY, :on_url)
|
811
|
+
evt_richtext_stylesheet_replacing(Wx::ID_ANY, :on_stylesheet_replacing)
|
810
812
|
|
811
|
-
|
812
|
-
|
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
|
-
|
815
|
-
|
816
|
+
write_initial_text
|
817
|
+
end
|
816
818
|
|
817
|
-
|
818
|
-
|
819
|
-
|
820
|
-
|
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
|
-
|
823
|
-
|
824
|
-
|
825
|
-
|
824
|
+
# event handlers
|
825
|
+
def on_quit(_event)
|
826
|
+
close(true)
|
827
|
+
end
|
826
828
|
|
827
|
-
|
828
|
-
|
829
|
-
|
830
|
-
|
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
|
-
|
833
|
-
|
834
|
-
|
835
|
-
|
836
|
-
|
837
|
-
|
838
|
-
|
839
|
-
|
840
|
-
|
841
|
-
|
842
|
-
|
843
|
-
|
844
|
-
|
845
|
-
|
846
|
-
|
847
|
-
|
848
|
-
|
849
|
-
|
850
|
-
|
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
|
-
|
857
|
-
|
858
|
-
|
859
|
-
|
860
|
-
|
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
|
-
|
865
|
-
|
866
|
+
def on_save_as(_event)
|
867
|
+
filter = Wx::RTC::RichTextBuffer.get_ext_wildcard(false, true)
|
866
868
|
|
867
|
-
|
869
|
+
Wx.FileDialog(self, "Choose a filename", '', '', filter, Wx::FD_SAVE) do |dialog|
|
868
870
|
|
869
|
-
|
870
|
-
|
871
|
+
if dialog.show_modal == Wx::ID_OK
|
872
|
+
path1 = dialog.path
|
871
873
|
|
872
|
-
|
873
|
-
|
874
|
-
|
874
|
+
unless path1.empty?
|
875
|
+
Wx::BusyCursor.busy do
|
876
|
+
start = Time.now
|
875
877
|
|
876
|
-
|
878
|
+
@richTextCtrl.save_file(path1)
|
877
879
|
|
878
|
-
|
879
|
-
|
880
|
-
|
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
|
-
|
888
|
-
|
889
|
-
|
890
|
-
|
891
|
-
|
892
|
-
|
893
|
-
|
894
|
-
|
895
|
-
|
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
|
-
|
898
|
-
|
899
|
-
|
900
|
-
|
901
|
-
|
902
|
-
|
903
|
-
|
904
|
-
|
905
|
-
|
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
|
-
|
908
|
-
|
909
|
-
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
|
914
|
-
|
915
|
-
|
916
|
-
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
|
923
|
-
|
924
|
-
|
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
|
-
|
927
|
-
|
928
|
-
|
929
|
-
|
930
|
-
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
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
|
-
|
937
|
-
|
938
|
-
|
939
|
-
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
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
|
-
|
947
|
-
|
948
|
-
|
948
|
+
def on_indent_more(_event)
|
949
|
+
attr = Wx::RichTextAttr.new
|
950
|
+
attr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT)
|
949
951
|
|
950
|
-
|
951
|
-
|
952
|
-
|
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
|
-
|
956
|
+
attr.set_left_indent(attr.get_left_indent + 100)
|
955
957
|
|
956
|
-
|
957
|
-
|
958
|
+
attr.set_flags(Wx::TEXT_ATTR_LEFT_INDENT)
|
959
|
+
@richTextCtrl.set_style(range, attr)
|
960
|
+
end
|
958
961
|
end
|
959
|
-
|
960
|
-
|
961
|
-
|
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
|
-
|
965
|
-
|
966
|
-
|
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
|
-
|
969
|
-
|
970
|
+
if attr.get_left_indent > 0
|
971
|
+
attr.set_left_indent([0, attr.get_left_indent - 100].max)
|
970
972
|
|
971
|
-
|
973
|
+
@richTextCtrl.set_style(range, attr)
|
974
|
+
end
|
972
975
|
end
|
973
976
|
end
|
974
|
-
end
|
975
977
|
|
976
|
-
|
977
|
-
|
978
|
-
|
979
|
-
|
980
|
-
|
981
|
-
|
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
|
-
|
985
|
+
pages = Wx::RTC::RICHTEXT_FORMAT_FONT
|
984
986
|
|
985
|
-
|
986
|
-
|
987
|
-
|
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
|
-
|
990
|
-
|
991
|
-
|
992
|
-
|
993
|
-
|
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
|
-
|
997
|
-
|
998
|
-
|
999
|
-
|
1000
|
-
|
1001
|
-
|
1002
|
-
|
1003
|
-
|
1004
|
-
|
1005
|
-
|
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
|
-
|
1012
|
-
|
1013
|
-
|
1014
|
-
|
1015
|
-
|
1016
|
-
|
1017
|
-
|
1018
|
-
|
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
|
-
|
1023
|
-
|
1024
|
+
event.enable(false)
|
1025
|
+
end
|
1024
1026
|
|
1025
|
-
|
1026
|
-
|
1027
|
-
|
1028
|
-
|
1029
|
-
|
1030
|
-
|
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
|
-
|
1034
|
+
pages = Wx::RTC::RICHTEXT_FORMAT_INDENTS_SPACING|Wx::RTC::RICHTEXT_FORMAT_TABS|Wx::RTC::RICHTEXT_FORMAT_BULLETS
|
1033
1035
|
|
1034
|
-
|
1035
|
-
|
1036
|
+
Wx::RTC.RichTextFormattingDialog(pages, self) do |formatDlg|
|
1037
|
+
formatDlg.get_style(@richTextCtrl, range)
|
1036
1038
|
|
1037
|
-
|
1039
|
+
formatDlg.apply_style(@richTextCtrl, range) if formatDlg.show_modal == Wx::ID_OK
|
1040
|
+
end
|
1038
1041
|
end
|
1039
|
-
|
1040
|
-
|
1041
|
-
|
1042
|
-
|
1043
|
-
|
1044
|
-
|
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
|
-
|
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
|
-
|
1050
|
-
|
1051
|
+
Wx::RTC.RichTextFormattingDialog(pages, self) do |formatDlg|
|
1052
|
+
formatDlg.get_style(@richTextCtrl, range)
|
1051
1053
|
|
1052
|
-
|
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
|
-
|
1060
|
-
|
1061
|
-
|
1062
|
-
|
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
|
-
|
1065
|
-
|
1066
|
+
currentFontName = ''
|
1067
|
+
currentFontName = attr.font.face_name if attr.has_font && attr.font.ok?
|
1066
1068
|
|
1067
|
-
|
1068
|
-
|
1069
|
-
|
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
|
-
|
1072
|
-
|
1073
|
-
|
1074
|
-
|
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
|
-
|
1078
|
+
@richTextCtrl.write_text(dlg.get_symbol)
|
1077
1079
|
|
1078
|
-
|
1079
|
-
|
1080
|
-
|
1081
|
-
|
1082
|
-
|
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
|
-
|
1090
|
-
|
1091
|
-
|
1091
|
+
def set_selection_spacing(flag, &block)
|
1092
|
+
attr = Wx::RTC::RichTextAttr.new
|
1093
|
+
attr.set_flags(flag)
|
1092
1094
|
|
1093
|
-
|
1094
|
-
|
1095
|
-
|
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
|
-
|
1099
|
+
block.call(attr)
|
1098
1100
|
|
1099
|
-
|
1100
|
-
|
1101
|
+
attr.set_flags(flag)
|
1102
|
+
@richTextCtrl.set_style(range, attr)
|
1103
|
+
end
|
1101
1104
|
end
|
1102
|
-
|
1103
|
-
protected :set_selection_spacing
|
1105
|
+
protected :set_selection_spacing
|
1104
1106
|
|
1105
|
-
|
1106
|
-
|
1107
|
-
|
1108
|
-
|
1109
|
-
|
1110
|
-
|
1111
|
-
|
1112
|
-
|
1113
|
-
|
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
|
-
|
1116
|
-
|
1117
|
-
|
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
|
-
|
1120
|
-
|
1121
|
-
|
1122
|
-
|
1123
|
-
|
1124
|
-
|
1125
|
-
|
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
|
-
|
1131
|
-
|
1132
|
-
|
1133
|
-
|
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
|
-
|
1136
|
-
|
1137
|
-
sheet = @richTextCtrl.get_style_sheet
|
1138
|
+
def on_bullets_and_numbering(_event)
|
1139
|
+
sheet = @richTextCtrl.get_style_sheet
|
1138
1140
|
|
1139
|
-
|
1141
|
+
flags = Wx::RTC::RICHTEXT_ORGANISER_BROWSE_NUMBERING
|
1140
1142
|
|
1141
|
-
|
1142
|
-
|
1143
|
-
|
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
|
-
|
1147
|
-
|
1148
|
-
|
1149
|
-
|
1150
|
-
|
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
|
-
|
1153
|
-
|
1154
|
-
|
1155
|
-
|
1156
|
-
|
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
|
-
|
1159
|
-
|
1160
|
-
|
1161
|
-
|
1162
|
-
|
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
|
-
|
1165
|
-
|
1166
|
-
|
1167
|
-
|
1168
|
-
|
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
|
-
|
1171
|
-
|
1172
|
-
|
1173
|
-
|
1174
|
-
|
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
|
-
|
1179
|
-
|
1180
|
-
|
1181
|
-
|
1182
|
-
|
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
|
-
|
1185
|
-
|
1186
|
-
|
1187
|
-
|
1188
|
-
|
1189
|
-
|
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
|
-
|
1192
|
-
|
1193
|
-
|
1194
|
-
|
1195
|
-
|
1196
|
-
|
1197
|
-
|
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
|
-
|
1200
|
-
|
1201
|
-
|
1202
|
-
|
1203
|
-
|
1204
|
-
|
1205
|
-
|
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
|
-
|
1208
|
-
|
1209
|
-
|
1210
|
-
|
1211
|
-
|
1212
|
-
|
1213
|
-
|
1214
|
-
|
1215
|
-
|
1216
|
-
|
1217
|
-
|
1218
|
-
|
1219
|
-
|
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
|
-
|
1225
|
-
|
1226
|
-
|
1227
|
-
|
1226
|
+
def on_reload(_event)
|
1227
|
+
@richTextCtrl.clear
|
1228
|
+
write_initial_text
|
1229
|
+
end
|
1228
1230
|
|
1229
|
-
|
1230
|
-
|
1231
|
-
|
1232
|
-
|
1233
|
-
|
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
|
-
|
1236
|
-
|
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
|
-
|
1239
|
-
|
1240
|
+
cancelButton = Wx::Button.new(dialog, Wx::ID_CANCEL, '&Close')
|
1241
|
+
boxSizer.add(cancelButton, 0, Wx::ALL|Wx::CENTRE, 5)
|
1240
1242
|
|
1241
|
-
|
1243
|
+
strStream = StringIO.new
|
1242
1244
|
|
1243
|
-
|
1244
|
-
|
1245
|
+
htmlHandler = Wx::RTC::RichTextHTMLHandler.new
|
1246
|
+
htmlHandler.set_flags(Wx::RTC::RICHTEXT_HANDLER_SAVE_IMAGES_TO_MEMORY)
|
1245
1247
|
|
1246
|
-
|
1248
|
+
fontSizeMapping = [7,9,11,12,14,22,100]
|
1247
1249
|
|
1248
|
-
|
1250
|
+
htmlHandler.set_font_size_mapping(fontSizeMapping)
|
1249
1251
|
|
1250
|
-
|
1251
|
-
|
1252
|
-
|
1253
|
-
|
1252
|
+
if htmlHandler.save_file(@richTextCtrl.buffer, strStream)
|
1253
|
+
strStream.rewind
|
1254
|
+
win.set_page(strStream.read || '')
|
1255
|
+
end
|
1254
1256
|
|
1255
|
-
|
1257
|
+
boxSizer.fit(dialog)
|
1256
1258
|
|
1257
|
-
|
1259
|
+
dialog.show_modal
|
1258
1260
|
|
1259
|
-
|
1260
|
-
|
1261
|
-
|
1262
|
-
|
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
|
-
|
1267
|
-
|
1268
|
-
|
1269
|
-
|
1270
|
-
|
1271
|
-
|
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
|
-
|
1276
|
-
|
1277
|
-
|
1278
|
-
|
1279
|
-
|
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
|
-
|
1283
|
+
sheet = @richTextCtrl.get_style_sheet
|
1282
1284
|
|
1283
|
-
|
1284
|
-
|
1285
|
-
|
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
|
-
|
1288
|
-
|
1289
|
-
|
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
|
-
|
1293
|
+
style_def.get_style.set_text_colour(:BLUE) if style_def.get_style.has_text_colour
|
1292
1294
|
|
1293
|
-
|
1294
|
-
|
1295
|
-
|
1296
|
-
|
1297
|
-
|
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
|
-
|
1307
|
-
|
1308
|
-
|
1309
|
-
|
1308
|
+
# Switch sheets
|
1309
|
+
tmp = MyFrame.alternate_style_sheet
|
1310
|
+
MyFrame.alternate_style_sheet = sheet
|
1311
|
+
sheet = tmp
|
1310
1312
|
|
1311
|
-
|
1312
|
-
|
1313
|
+
@richTextCtrl.set_style_sheet(sheet)
|
1314
|
+
@richTextCtrl.apply_style_sheet(sheet) # Makes the control reflect the new style definitions
|
1313
1315
|
|
1314
|
-
|
1315
|
-
|
1316
|
+
styleList.set_style_sheet(sheet)
|
1317
|
+
styleList.update_styles
|
1316
1318
|
|
1317
|
-
|
1318
|
-
|
1319
|
-
|
1320
|
-
|
1321
|
-
|
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
|
-
|
1326
|
-
end
|
1325
|
+
flags = Wx::RTC::RICHTEXT_ORGANISER_CREATE_STYLES|Wx::RTC::RICHTEXT_ORGANISER_EDIT_STYLES
|
1327
1326
|
|
1328
|
-
|
1329
|
-
|
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
|
-
|
1337
|
-
|
1338
|
-
|
1339
|
-
|
1340
|
-
|
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
|
-
|
1352
|
+
if Wx.has_feature? :USE_PRINTING_ARCHITECTURE
|
1351
1353
|
|
1352
|
-
|
1353
|
-
|
1354
|
-
|
1355
|
-
|
1356
|
-
|
1357
|
-
|
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
|
-
|
1361
|
+
end
|
1360
1362
|
|
1361
|
-
|
1362
|
-
|
1363
|
-
|
1364
|
-
|
1365
|
-
|
1366
|
-
|
1367
|
-
|
1368
|
-
|
1369
|
-
|
1370
|
-
|
1371
|
-
|
1372
|
-
|
1373
|
-
|
1374
|
-
|
1375
|
-
|
1376
|
-
|
1377
|
-
|
1378
|
-
|
1379
|
-
|
1380
|
-
|
1381
|
-
|
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
|
-
|
1384
|
-
|
1385
|
-
|
1386
|
-
|
1387
|
-
|
1388
|
-
|
1389
|
-
|
1390
|
-
|
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
|
-
|
1397
|
-
|
1398
|
-
|
1399
|
-
|
1400
|
-
|
1401
|
-
|
1402
|
-
|
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
|
-
|
1405
|
-
|
1406
|
-
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1410
|
-
|
1411
|
-
|
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
|
-
|
1417
|
+
protected
|
1416
1418
|
|
1417
|
-
|
1419
|
+
class << self
|
1418
1420
|
|
1419
|
-
|
1420
|
-
|
1421
|
-
|
1422
|
-
|
1423
|
-
|
1424
|
-
|
1421
|
+
def event_type
|
1422
|
+
@event_type ||= 0
|
1423
|
+
end
|
1424
|
+
def event_type=(v)
|
1425
|
+
@event_type = v
|
1426
|
+
end
|
1425
1427
|
|
1426
|
-
|
1427
|
-
|
1428
|
-
|
1429
|
-
|
1430
|
-
|
1431
|
-
|
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
|
-
|
1435
|
+
end
|
1434
1436
|
|
1435
|
-
|
1436
|
-
|
1437
|
-
|
1437
|
+
# Write text
|
1438
|
+
def write_initial_text
|
1439
|
+
r = @richTextCtrl
|
1438
1440
|
|
1439
|
-
|
1441
|
+
r.set_default_style(Wx::RichTextAttr.new)
|
1440
1442
|
|
1441
|
-
|
1443
|
+
r.freeze
|
1442
1444
|
|
1443
|
-
|
1445
|
+
r.begin_suppress_undo
|
1444
1446
|
|
1445
|
-
|
1447
|
+
r.begin_paragraph_spacing(0, 20)
|
1446
1448
|
|
1447
|
-
|
1448
|
-
|
1449
|
+
r.begin_alignment(Wx::TEXT_ALIGNMENT_CENTRE)
|
1450
|
+
r.begin_bold
|
1449
1451
|
|
1450
|
-
|
1452
|
+
r.begin_font_size(14)
|
1451
1453
|
|
1452
|
-
|
1454
|
+
lineBreak = ?\n
|
1453
1455
|
|
1454
|
-
|
1455
|
-
|
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
|
-
|
1458
|
-
|
1459
|
-
|
1459
|
+
r.begin_italic
|
1460
|
+
r.write_text("by Julian Smart")
|
1461
|
+
r.end_italic
|
1460
1462
|
|
1461
|
-
|
1462
|
-
|
1463
|
+
r.end_bold
|
1464
|
+
r.newline
|
1463
1465
|
|
1464
|
-
|
1466
|
+
r.write_image(Wx.Bitmap(:zebra))
|
1465
1467
|
|
1466
|
-
|
1467
|
-
|
1468
|
+
r.newline
|
1469
|
+
r.newline
|
1468
1470
|
|
1469
|
-
|
1471
|
+
r.end_alignment
|
1470
1472
|
|
1471
1473
|
=begin
|
1472
|
-
|
1473
|
-
|
1474
|
-
|
1475
|
-
|
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
|
-
|
1479
|
-
|
1480
|
-
|
1481
|
-
|
1482
|
-
|
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
|
-
|
1485
|
-
|
1486
|
-
|
1487
|
-
|
1488
|
-
|
1489
|
-
|
1490
|
-
|
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
|
-
|
1494
|
+
r.write_text("What can you do with this thing? ")
|
1493
1495
|
|
1494
|
-
|
1495
|
-
|
1496
|
+
r.write_image(Wx.Bitmap(:smiley))
|
1497
|
+
r.write_text(" Well, you can change text ")
|
1496
1498
|
|
1497
|
-
|
1498
|
-
|
1499
|
-
|
1499
|
+
r.begin_text_colour(Wx::RED)
|
1500
|
+
r.write_text("colour, like this red bit.")
|
1501
|
+
r.end_text_colour
|
1500
1502
|
|
1501
|
-
|
1502
|
-
|
1503
|
-
|
1504
|
-
|
1505
|
-
|
1506
|
-
|
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
|
-
|
1509
|
-
|
1510
|
-
|
1511
|
-
|
1512
|
-
|
1513
|
-
|
1514
|
-
|
1515
|
-
|
1516
|
-
|
1517
|
-
|
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
|
-
|
1520
|
-
|
1521
|
-
|
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
|
-
|
1525
|
+
r.write_text(" Next we'll show an indented paragraph.")
|
1524
1526
|
|
1525
|
-
|
1527
|
+
r.newline
|
1526
1528
|
|
1527
|
-
|
1528
|
-
|
1529
|
-
|
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
|
-
|
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
|
-
|
1540
|
-
r.newline
|
1535
|
+
r.write_text("Next, we'll show a first-line indent, achieved using BeginLeftIndent(100, -40).")
|
1541
1536
|
|
1542
|
-
|
1537
|
+
r.newline
|
1543
1538
|
|
1544
|
-
|
1545
|
-
r.newline
|
1539
|
+
r.begin_left_indent(100, -40)
|
1546
1540
|
|
1547
|
-
|
1548
|
-
|
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
|
-
|
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
|
-
|
1558
|
-
|
1546
|
+
r.write_text("Numbered bullets are possible, again using subindents:")
|
1547
|
+
r.newline
|
1559
1548
|
|
1560
|
-
|
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
|
-
|
1563
|
-
|
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
|
-
|
1559
|
+
r.write_text("The following paragraph is right-indented:")
|
1560
|
+
r.newline
|
1566
1561
|
|
1567
|
-
|
1568
|
-
r.newline
|
1562
|
+
r.begin_right_indent(200)
|
1569
1563
|
|
1570
|
-
|
1571
|
-
|
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
|
-
|
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
|
-
|
1584
|
-
|
1569
|
+
r.write_text("The following paragraph is right-aligned with 1.5 line spacing:")
|
1570
|
+
r.newline
|
1585
1571
|
|
1586
|
-
|
1587
|
-
|
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
|
-
|
1590
|
-
|
1591
|
-
|
1592
|
-
|
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
|
-
|
1595
|
-
|
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
|
-
|
1600
|
-
|
1601
|
-
r.newline
|
1602
|
-
r.end_symbol_bullet
|
1588
|
+
r.write_text("Other notable features of wxRichTextCtrl include:")
|
1589
|
+
r.newline
|
1603
1590
|
|
1604
|
-
|
1605
|
-
|
1606
|
-
|
1607
|
-
|
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
|
-
|
1610
|
-
|
1611
|
-
|
1612
|
-
|
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
|
-
|
1615
|
-
|
1616
|
-
|
1617
|
-
|
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
|
-
|
1620
|
-
|
1621
|
-
|
1622
|
-
|
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
|
-
|
1625
|
-
|
1626
|
-
|
1627
|
-
|
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
|
-
|
1630
|
-
|
1631
|
-
|
1632
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
1658
|
-
|
1659
|
-
|
1660
|
-
|
1661
|
-
|
1662
|
-
|
1663
|
-
|
1664
|
-
|
1665
|
-
|
1666
|
-
|
1667
|
-
|
1668
|
-
|
1669
|
-
|
1670
|
-
|
1671
|
-
|
1672
|
-
|
1673
|
-
|
1674
|
-
|
1675
|
-
|
1676
|
-
|
1677
|
-
|
1678
|
-
|
1679
|
-
|
1680
|
-
|
1681
|
-
|
1682
|
-
|
1683
|
-
|
1684
|
-
|
1685
|
-
|
1686
|
-
|
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
|