wxruby3 0.9.2 → 0.9.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/INSTALL.md +35 -29
- data/README.md +24 -15
- data/ext/wxruby3/include/wxruby-ClientData.h +48 -0
- data/ext/wxruby3/include/wxruby-Config.h +23 -5
- data/ext/wxruby3/include/wxruby-Persistence.h +79 -0
- data/ext/wxruby3/include/wxruby-Validator.h +39 -0
- data/ext/wxruby3/include/wxruby-ValidatorBinding.h +64 -0
- data/ext/wxruby3/swig/custom/director.swg +8 -0
- data/ext/wxruby3/swig/mark_free_impl.i +0 -33
- data/ext/wxruby3/swig/memory_management.i +6 -0
- data/lib/wx/core/bitmap_combobox.rb +17 -21
- data/lib/wx/core/book_ctrl_base.rb +16 -0
- data/lib/wx/core/combobox.rb +13 -3
- data/lib/wx/core/config.rb +454 -83
- data/lib/wx/core/controlwithitems.rb +40 -130
- 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/notebook.rb +10 -8
- data/lib/wx/core/owner_drawn_combobox.rb +45 -0
- data/lib/wx/core/peristent_object.rb +15 -0
- data/lib/wx/core/persistence_manager.rb +39 -0
- data/lib/wx/core/persistent_window.rb +16 -0
- data/lib/wx/core/size.rb +4 -0
- data/lib/wx/core/sizer.rb +1 -2
- data/lib/wx/core/standard_paths.rb +22 -0
- data/lib/wx/core/text_entry.rb +4 -1
- data/lib/wx/core/top_level_window.rb +16 -0
- data/lib/wx/core/treebook.rb +18 -0
- data/lib/wx/core/validator.rb +70 -5
- data/lib/wx/core/window.rb +3 -7
- data/lib/wx/core.rb +4 -0
- data/lib/wx/doc/art_locator.rb +1 -0
- data/lib/wx/doc/book_ctrl_base.rb +19 -0
- data/lib/wx/doc/comboctrl.rb +18 -0
- data/lib/wx/doc/config.rb +101 -41
- data/lib/wx/doc/controlwithitems.rb +16 -0
- 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/extra/12_client_data.md +89 -0
- data/lib/wx/doc/extra/13_validators.md +139 -0
- data/lib/wx/doc/extra/14_config.md +101 -0
- data/lib/wx/doc/extra/15_persistence.md +148 -0
- data/lib/wx/doc/gdi_common.rb +4 -0
- data/lib/wx/doc/generic_validator.rb +95 -0
- data/lib/wx/doc/html/simple_html_listbox.rb +22 -0
- data/lib/wx/doc/num_validator.rb +387 -0
- data/lib/wx/doc/owner_drawn_combobox.rb +96 -0
- data/lib/wx/doc/persistence_manager.rb +36 -0
- data/lib/wx/doc/persistent_object.rb +27 -0
- data/lib/wx/doc/pg/numeric_property_validator.rb +33 -0
- data/lib/wx/doc/static_bitmap.rb +25 -0
- data/lib/wx/doc/text_validator.rb +10 -0
- data/lib/wx/doc/top_level_window.rb +19 -0
- data/lib/wx/doc/treebook.rb +6 -1
- data/lib/wx/doc/validator.rb +113 -0
- data/lib/wx/doc/window.rb +30 -0
- data/lib/wx/html/simple_html_listbox.rb +24 -91
- data/lib/wx/keyword_defs.rb +34 -2
- data/lib/wx/rbn/ribbon_gallery.rb +0 -21
- data/lib/wx/version.rb +1 -1
- data/rakelib/build.rb +1 -1
- data/rakelib/lib/config/mingw.rb +12 -0
- 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 +39 -3
- data/rakelib/lib/core/parameter.rb +1 -1
- data/rakelib/lib/core/spec.rb +10 -0
- data/rakelib/lib/core/spec_helper.rb +8 -2
- data/rakelib/lib/director/app.rb +18 -0
- data/rakelib/lib/director/app_traits.rb +3 -1
- 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/config_base.rb +490 -19
- data/rakelib/lib/director/ctrl_with_items.rb +88 -21
- data/rakelib/lib/director/date_picker_ctrl.rb +8 -6
- data/rakelib/lib/director/editable_listbox.rb +30 -0
- data/rakelib/lib/director/event.rb +102 -12
- data/rakelib/lib/director/event_filter.rb +1 -1
- data/rakelib/lib/director/event_handler.rb +3 -2
- data/rakelib/lib/director/event_loop.rb +1 -1
- data/rakelib/lib/director/file_dialog_customize_hook.rb +2 -2
- data/rakelib/lib/director/functions.rb +4 -2
- data/rakelib/lib/director/generic_dirctrl.rb +17 -0
- data/rakelib/lib/director/grid_cell_attr.rb +1 -3
- data/rakelib/lib/director/grid_cell_editor.rb +1 -3
- data/rakelib/lib/director/grid_cell_renderer.rb +1 -3
- data/rakelib/lib/director/header_ctrl.rb +9 -1
- data/rakelib/lib/director/html_listbox.rb +97 -22
- 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/persistence_manager.rb +410 -0
- data/rakelib/lib/director/persistent_object.rb +70 -0
- data/rakelib/lib/director/persistent_window.rb +73 -0
- data/rakelib/lib/director/pgproperty.rb +3 -29
- data/rakelib/lib/director/ribbon_button_bar.rb +3 -3
- data/rakelib/lib/director/ribbon_gallery.rb +3 -5
- data/rakelib/lib/director/sizer.rb +15 -4
- data/rakelib/lib/director/sizer_item.rb +13 -0
- data/rakelib/lib/director/static_bitmap.rb +32 -0
- data/rakelib/lib/director/text_entry.rb +5 -1
- data/rakelib/lib/director/text_validator.rb +124 -13
- data/rakelib/lib/director/toggle_button.rb +1 -0
- data/rakelib/lib/director/top_level_window.rb +0 -2
- data/rakelib/lib/director/tree_ctrl.rb +35 -0
- data/rakelib/lib/director/utils.rb +16 -2
- data/rakelib/lib/director/validator.rb +196 -21
- data/rakelib/lib/director/window.rb +16 -2
- data/rakelib/lib/extractor/function.rb +2 -1
- data/rakelib/lib/generate/analyzer.rb +44 -44
- data/rakelib/lib/generate/doc.rb +11 -5
- data/rakelib/lib/specs/interfaces.rb +5 -0
- data/rakelib/lib/swig_runner.rb +55 -9
- data/rakelib/lib/typemap/client_data.rb +67 -0
- data/rakelib/lib/typemap/common.rb +3 -3
- data/rakelib/lib/typemap/config.rb +8 -0
- data/rakelib/lib/typemap/datetime.rb +1 -1
- data/rakelib/lib/typemap/tree_itemid.rb +2 -2
- 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 +1229 -0
- data/samples/xrc/custom_xrc_sample.rb +47 -41
- data/samples/xrc/xrc_sample.rb +53 -47
- data/tests/test_config.rb +207 -42
- 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_persistence.rb +142 -0
- data/tests/test_sizer.rb +44 -1
- data/tests/test_validators.rb +805 -0
- metadata +109 -138
- 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
|
@@ -0,0 +1,410 @@
|
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
|
2
|
+
#
|
|
3
|
+
# This software is released under the MIT license.
|
|
4
|
+
|
|
5
|
+
###
|
|
6
|
+
# wxRuby3 wxWidgets interface director
|
|
7
|
+
###
|
|
8
|
+
|
|
9
|
+
module WXRuby3
|
|
10
|
+
|
|
11
|
+
class Director
|
|
12
|
+
|
|
13
|
+
class PersistenceManager < Director
|
|
14
|
+
|
|
15
|
+
include Typemap::ConfigBase
|
|
16
|
+
|
|
17
|
+
def setup
|
|
18
|
+
super
|
|
19
|
+
spec.gc_as_marked
|
|
20
|
+
spec.use_class_implementation 'wxPersistenceManager', 'WxRubyPersistenceManager'
|
|
21
|
+
spec.ignore 'wxPersistenceManager::Register',
|
|
22
|
+
'wxPersistenceManager::Find',
|
|
23
|
+
'wxPersistenceManager::Unregister',
|
|
24
|
+
'wxPersistenceManager::Save',
|
|
25
|
+
'wxPersistenceManager::Restore',
|
|
26
|
+
'wxPersistenceManager::SaveAndUnregister',
|
|
27
|
+
'wxPersistenceManager::RegisterAndRestore',
|
|
28
|
+
ignore_doc: false
|
|
29
|
+
# doc gen only
|
|
30
|
+
spec.map 'void *obj' => 'Object', swig: false do
|
|
31
|
+
map_in code: ''
|
|
32
|
+
end
|
|
33
|
+
spec.map 'T *obj' => 'Object', swig: false do
|
|
34
|
+
map_in code: ''
|
|
35
|
+
end
|
|
36
|
+
spec.regard 'wxPersistenceManager::wxPersistenceManager',
|
|
37
|
+
'wxPersistenceManager::GetConfig',
|
|
38
|
+
'wxPersistenceManager::GetKey'
|
|
39
|
+
spec.suppress_warning 473, 'wxPersistenceManager::GetConfig'
|
|
40
|
+
spec.ignore %w[wxCreatePersistentObject wxPersistentRegisterAndRestore]
|
|
41
|
+
spec.add_header_code <<~__HEREDOC
|
|
42
|
+
#include "wxruby-Persistence.h"
|
|
43
|
+
|
|
44
|
+
// default global wxRuby persistence manager
|
|
45
|
+
static WxRubyPersistenceManager s_wxruby_persistence_manager {};
|
|
46
|
+
|
|
47
|
+
static WxRuby_ID to_f_id("to_f");
|
|
48
|
+
static WxRuby_ID to_i_id("to_i");
|
|
49
|
+
static WxRuby_ID to_s_id("to_s");
|
|
50
|
+
static WxRuby_ID save_value_id("save_value");
|
|
51
|
+
static WxRuby_ID restore_value_id("save_value");
|
|
52
|
+
static WxRuby_ID create_po_id("create_persistent_object");
|
|
53
|
+
|
|
54
|
+
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
|
55
|
+
#define PO_LONG wxLongLong_t
|
|
56
|
+
#define PO_NUM2LONG(n) NUM2LL(n)
|
|
57
|
+
#define PO_LONG2NUM(l) LL2NUM(l)
|
|
58
|
+
#else
|
|
59
|
+
#define PO_LONG long
|
|
60
|
+
#define PO_NUM2LONG(n) NUM2LONG(n)
|
|
61
|
+
#define PO_LONG2NUM(l) LONG2NUM(l)
|
|
62
|
+
#endif
|
|
63
|
+
|
|
64
|
+
bool WxRubyPersistenceManager::SaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value)
|
|
65
|
+
{
|
|
66
|
+
Swig::Director* dir = dynamic_cast<Swig::Director*> (this);
|
|
67
|
+
// is this a user defined Ruby persistence manager with overridden #save_value?
|
|
68
|
+
if (dir && !wxRuby_IsNativeMethod(dir->swig_get_self(), save_value_id()))
|
|
69
|
+
{
|
|
70
|
+
VALUE rb_who = SWIG_NewPointerObj(SWIG_as_voidptr(&who), SWIGTYPE_p_wxPersistentObject, 0 );
|
|
71
|
+
return wxRuby_Funcall(dir->swig_get_self(), save_value_id(), 3, rb_who, WXSTR_TO_RSTR(name), value);
|
|
72
|
+
}
|
|
73
|
+
else
|
|
74
|
+
{
|
|
75
|
+
// just call C++ base implementation
|
|
76
|
+
return DoSaveRubyValue(who, name, value);
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
VALUE WxRubyPersistenceManager::RestoreRubyValue(const wxPersistentObject& who, const wxString& name)
|
|
81
|
+
{
|
|
82
|
+
Swig::Director* dir = dynamic_cast<Swig::Director*> (this);
|
|
83
|
+
// is this a user defined Ruby persistence manager with overridden #restore_value?
|
|
84
|
+
if (dir && !wxRuby_IsNativeMethod(dir->swig_get_self(), restore_value_id()))
|
|
85
|
+
{
|
|
86
|
+
VALUE rb_who = SWIG_NewPointerObj(SWIG_as_voidptr(&who), SWIGTYPE_p_wxPersistentObject, 0 );
|
|
87
|
+
return wxRuby_Funcall(dir->swig_get_self(), restore_value_id(), 3, rb_who, WXSTR_TO_RSTR(name));
|
|
88
|
+
}
|
|
89
|
+
else
|
|
90
|
+
{
|
|
91
|
+
// just call C++ base implementation
|
|
92
|
+
return DoRestoreRubyValue(who, name);
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
bool WxRubyPersistenceManager::DoSaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value)
|
|
97
|
+
{
|
|
98
|
+
wxConfigBase* cfg = this->GetConfig();
|
|
99
|
+
if (!cfg)
|
|
100
|
+
return false;
|
|
101
|
+
wxString key = this->GetKey(who, name);
|
|
102
|
+
switch(TYPE(value))
|
|
103
|
+
{
|
|
104
|
+
case T_TRUE:
|
|
105
|
+
case T_FALSE:
|
|
106
|
+
return cfg->Write(key, value == Qtrue);
|
|
107
|
+
|
|
108
|
+
case T_FIXNUM:
|
|
109
|
+
case T_BIGNUM:
|
|
110
|
+
return cfg->Write(key, PO_NUM2LONG(value));
|
|
111
|
+
|
|
112
|
+
case T_FLOAT:
|
|
113
|
+
return cfg->Write(key, NUM2DBL(value));
|
|
114
|
+
|
|
115
|
+
case T_STRING:
|
|
116
|
+
return cfg->Write(key, RSTR_TO_WXSTR(value));
|
|
117
|
+
|
|
118
|
+
default:
|
|
119
|
+
if (rb_respond_to(value, to_i_id()))
|
|
120
|
+
{
|
|
121
|
+
VALUE ival = rb_funcall(value, to_i_id(), 0);
|
|
122
|
+
return cfg->Write(key, PO_NUM2LONG(ival));
|
|
123
|
+
}
|
|
124
|
+
else if (rb_respond_to(value, to_f_id()))
|
|
125
|
+
{
|
|
126
|
+
VALUE fval = rb_funcall(value, to_f_id(), 0);
|
|
127
|
+
return cfg->Write(key, NUM2DBL(fval));
|
|
128
|
+
}
|
|
129
|
+
break;
|
|
130
|
+
}
|
|
131
|
+
VALUE sval = rb_funcall(value, to_s_id(), 0);
|
|
132
|
+
return cfg->Write(key, RSTR_TO_WXSTR(sval));
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
VALUE WxRubyPersistenceManager::DoRestoreRubyValue(const wxPersistentObject& who, const wxString& name)
|
|
136
|
+
{
|
|
137
|
+
wxConfigBase* cfg = this->GetConfig();
|
|
138
|
+
if (!cfg)
|
|
139
|
+
return Qnil;
|
|
140
|
+
wxString key = this->GetKey(who, name);
|
|
141
|
+
wxConfigBase::EntryType vtype = cfg->GetEntryType(key);
|
|
142
|
+
switch(vtype)
|
|
143
|
+
{
|
|
144
|
+
case wxConfigBase::Type_Boolean:
|
|
145
|
+
{
|
|
146
|
+
bool v;
|
|
147
|
+
if (cfg->Read(key, &v))
|
|
148
|
+
{
|
|
149
|
+
return v ? Qtrue : Qfalse;
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
}
|
|
153
|
+
case wxConfigBase::Type_Integer:
|
|
154
|
+
{
|
|
155
|
+
PO_LONG v;
|
|
156
|
+
if (cfg->Read(key, &v))
|
|
157
|
+
{
|
|
158
|
+
return PO_LONG2NUM(v);
|
|
159
|
+
}
|
|
160
|
+
break;
|
|
161
|
+
}
|
|
162
|
+
case wxConfigBase::Type_Float:
|
|
163
|
+
{
|
|
164
|
+
double v;
|
|
165
|
+
if (cfg->Read(key, &v))
|
|
166
|
+
{
|
|
167
|
+
return DBL2NUM(v);
|
|
168
|
+
}
|
|
169
|
+
break;
|
|
170
|
+
}
|
|
171
|
+
case wxConfigBase::Type_String:
|
|
172
|
+
{
|
|
173
|
+
wxString v;
|
|
174
|
+
if (cfg->Read(key, &v))
|
|
175
|
+
{
|
|
176
|
+
return WXSTR_TO_RSTR(v);
|
|
177
|
+
}
|
|
178
|
+
break;
|
|
179
|
+
}
|
|
180
|
+
default:
|
|
181
|
+
break;
|
|
182
|
+
}
|
|
183
|
+
return Qnil;
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
void WxRubyPersistenceManager::UnregisterPersistentObject(VALUE rb_obj)
|
|
187
|
+
{
|
|
188
|
+
WxRubyPersistenceManager* wxrb_pm =
|
|
189
|
+
dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
|
|
190
|
+
if (wxrb_pm) wxrb_pm->UnregisterRbPO(rb_obj);
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
void WxRubyPersistenceManager::GC_markPO()
|
|
194
|
+
{
|
|
195
|
+
rb_object_to_rb_po_map_t::iterator it;
|
|
196
|
+
for( it = rb_object_po_map_.begin(); it != rb_object_po_map_.end(); ++it )
|
|
197
|
+
{
|
|
198
|
+
rb_gc_mark(it->first);
|
|
199
|
+
rb_gc_mark(it->second);
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
static void wxRuby_markPersistentObjects()
|
|
204
|
+
{
|
|
205
|
+
WxRubyPersistenceManager* wxrb_pm =
|
|
206
|
+
dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
|
|
207
|
+
if (wxrb_pm) wxrb_pm->GC_markPO();
|
|
208
|
+
}
|
|
209
|
+
__HEREDOC
|
|
210
|
+
spec.add_extend_code 'wxPersistenceManager', <<~__HEREDOC
|
|
211
|
+
VALUE Register(VALUE obj)
|
|
212
|
+
{
|
|
213
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
214
|
+
VALUE rb_po = rb_funcall(obj, create_po_id(), 0);
|
|
215
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
216
|
+
{
|
|
217
|
+
void* ptr;
|
|
218
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
|
|
219
|
+
if (!SWIG_IsOK(res))
|
|
220
|
+
{
|
|
221
|
+
rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
|
|
222
|
+
}
|
|
223
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
224
|
+
if ($self->Register(po->GetObject(), po))
|
|
225
|
+
{
|
|
226
|
+
wxrb_pm->RegisterRbPO(obj, rb_po);
|
|
227
|
+
return rb_po;
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
return Qnil;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
VALUE Register(VALUE obj, VALUE rb_po)
|
|
234
|
+
{
|
|
235
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
236
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
237
|
+
{
|
|
238
|
+
void* ptr;
|
|
239
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
|
|
240
|
+
if (!SWIG_IsOK(res))
|
|
241
|
+
{
|
|
242
|
+
rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
|
|
243
|
+
}
|
|
244
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
245
|
+
if ($self->Register(po->GetObject(), po))
|
|
246
|
+
{
|
|
247
|
+
wxrb_pm->RegisterRbPO(obj, rb_po);
|
|
248
|
+
return rb_po;
|
|
249
|
+
}
|
|
250
|
+
}
|
|
251
|
+
return Qnil;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
VALUE Find(VALUE obj)
|
|
255
|
+
{
|
|
256
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
257
|
+
VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
|
|
258
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
259
|
+
{
|
|
260
|
+
void* ptr;
|
|
261
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
|
|
262
|
+
if (!SWIG_IsOK(res))
|
|
263
|
+
{
|
|
264
|
+
rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
|
|
265
|
+
}
|
|
266
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
267
|
+
if ($self->Find(po->GetObject()))
|
|
268
|
+
return rb_po;
|
|
269
|
+
}
|
|
270
|
+
return Qnil;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
void Unregister(VALUE obj)
|
|
274
|
+
{
|
|
275
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
276
|
+
VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
|
|
277
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
278
|
+
{
|
|
279
|
+
void* ptr;
|
|
280
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
|
|
281
|
+
if (!SWIG_IsOK(res))
|
|
282
|
+
{
|
|
283
|
+
rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
|
|
284
|
+
}
|
|
285
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
286
|
+
$self->Unregister(po->GetObject());
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
void Save(VALUE obj)
|
|
291
|
+
{
|
|
292
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
293
|
+
VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
|
|
294
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
295
|
+
{
|
|
296
|
+
void* ptr;
|
|
297
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
|
|
298
|
+
if (!SWIG_IsOK(res))
|
|
299
|
+
{
|
|
300
|
+
rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
|
|
301
|
+
}
|
|
302
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
303
|
+
$self->Save(po->GetObject());
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
bool Restore(VALUE obj)
|
|
308
|
+
{
|
|
309
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
310
|
+
VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
|
|
311
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
312
|
+
{
|
|
313
|
+
void* ptr;
|
|
314
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
|
|
315
|
+
if (!SWIG_IsOK(res))
|
|
316
|
+
{
|
|
317
|
+
rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
|
|
318
|
+
}
|
|
319
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
320
|
+
return $self->Restore(po->GetObject());
|
|
321
|
+
}
|
|
322
|
+
return false;
|
|
323
|
+
}
|
|
324
|
+
|
|
325
|
+
void SaveAndUnregister(VALUE obj)
|
|
326
|
+
{
|
|
327
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
328
|
+
VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
|
|
329
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
330
|
+
{
|
|
331
|
+
void* ptr;
|
|
332
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
|
|
333
|
+
if (!SWIG_IsOK(res))
|
|
334
|
+
{
|
|
335
|
+
rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
|
|
336
|
+
}
|
|
337
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
338
|
+
$self->Save(po->GetObject());
|
|
339
|
+
$self->Unregister(po->GetObject());
|
|
340
|
+
}
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
bool RegisterAndRestore(VALUE obj)
|
|
344
|
+
{
|
|
345
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
346
|
+
VALUE rb_po = rb_funcall(obj, create_po_id(), 0);
|
|
347
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
348
|
+
{
|
|
349
|
+
void* ptr;
|
|
350
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
|
|
351
|
+
if (!SWIG_IsOK(res))
|
|
352
|
+
{
|
|
353
|
+
rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
|
|
354
|
+
}
|
|
355
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
356
|
+
if ($self->Register(po->GetObject(), po))
|
|
357
|
+
{
|
|
358
|
+
wxrb_pm->RegisterRbPO(obj, rb_po);
|
|
359
|
+
return $self->Restore(po->GetObject());
|
|
360
|
+
}
|
|
361
|
+
}
|
|
362
|
+
return false;
|
|
363
|
+
}
|
|
364
|
+
|
|
365
|
+
bool RegisterAndRestore(VALUE obj, VALUE rb_po)
|
|
366
|
+
{
|
|
367
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
368
|
+
if (!NIL_P(rb_po) && wxrb_pm)
|
|
369
|
+
{
|
|
370
|
+
void* ptr;
|
|
371
|
+
int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
|
|
372
|
+
if (!SWIG_IsOK(res))
|
|
373
|
+
{
|
|
374
|
+
rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
|
|
375
|
+
}
|
|
376
|
+
wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
|
|
377
|
+
if ($self->Register(po->GetObject(), po))
|
|
378
|
+
{
|
|
379
|
+
wxrb_pm->RegisterRbPO(obj, rb_po);
|
|
380
|
+
return $self->Restore(po->GetObject());
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
return false;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
bool SaveValue(const wxPersistentObject& who, const wxString& name, VALUE value)
|
|
387
|
+
{
|
|
388
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
389
|
+
return wxrb_pm ? wxrb_pm->DoSaveRubyValue(who, name, value) : false;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
VALUE RestoreValue(const wxPersistentObject& who, const wxString& name)
|
|
393
|
+
{
|
|
394
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
|
|
395
|
+
return wxrb_pm ? wxrb_pm->DoRestoreRubyValue(who, name) : Qnil;
|
|
396
|
+
}
|
|
397
|
+
__HEREDOC
|
|
398
|
+
spec.add_init_code <<~__HEREDOC
|
|
399
|
+
// install the default global wxRuby persistence manager
|
|
400
|
+
wxPersistenceManager::Set(s_wxruby_persistence_manager);
|
|
401
|
+
// and the persistent object marker
|
|
402
|
+
wxRuby_AppendMarker(wxRuby_markPersistentObjects);
|
|
403
|
+
__HEREDOC
|
|
404
|
+
end
|
|
405
|
+
|
|
406
|
+
end # class PersistenceManager
|
|
407
|
+
|
|
408
|
+
end # class Director
|
|
409
|
+
|
|
410
|
+
end # module WXRuby3
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
|
2
|
+
#
|
|
3
|
+
# This software is released under the MIT license.
|
|
4
|
+
|
|
5
|
+
###
|
|
6
|
+
# wxRuby3 wxWidgets interface director
|
|
7
|
+
###
|
|
8
|
+
|
|
9
|
+
module WXRuby3
|
|
10
|
+
|
|
11
|
+
class Director
|
|
12
|
+
|
|
13
|
+
class PersistentObject < Director
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
super
|
|
17
|
+
spec.gc_as_marked
|
|
18
|
+
spec.add_header_code <<~__HEREDOC
|
|
19
|
+
#include "wxruby-Persistence.h"
|
|
20
|
+
|
|
21
|
+
WxRubyPersistentObject::WxRubyPersistentObject(VALUE rb_obj)
|
|
22
|
+
: wxPersistentObject((void*)rb_obj)
|
|
23
|
+
{}
|
|
24
|
+
|
|
25
|
+
WxRubyPersistentObject::~WxRubyPersistentObject()
|
|
26
|
+
{
|
|
27
|
+
if (this->GetObject())
|
|
28
|
+
WxRubyPersistenceManager::UnregisterPersistentObject(
|
|
29
|
+
reinterpret_cast<VALUE> (this->GetObject()));
|
|
30
|
+
}
|
|
31
|
+
__HEREDOC
|
|
32
|
+
spec.use_class_implementation 'wxPersistentObject', 'WxRubyPersistentObject'
|
|
33
|
+
spec.ignore %w[wxPersistentObject::GetObject wxPersistentObject::wxPersistentObject]
|
|
34
|
+
spec.ignore %w[wxCreatePersistentObject wxPersistentRegisterAndRestore]
|
|
35
|
+
spec.extend_interface 'wxPersistentObject',
|
|
36
|
+
'wxPersistentObject(VALUE rb_obj)',
|
|
37
|
+
visibility: 'protected'
|
|
38
|
+
spec.add_extend_code 'wxPersistentObject', <<~__HEREDOC
|
|
39
|
+
bool SaveValue(const wxString& name, VALUE value)
|
|
40
|
+
{
|
|
41
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
|
|
42
|
+
return wxrb_pm ? wxrb_pm->SaveRubyValue(*$self, name, value) : false;
|
|
43
|
+
}
|
|
44
|
+
VALUE RestoreValue(const wxString& name)
|
|
45
|
+
{
|
|
46
|
+
WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
|
|
47
|
+
return wxrb_pm ? wxrb_pm->RestoreRubyValue(*$self, name) : Qnil;
|
|
48
|
+
}
|
|
49
|
+
__HEREDOC
|
|
50
|
+
spec.add_extend_code 'wxPersistentObject', <<~__HEREDOC
|
|
51
|
+
VALUE GetObject()
|
|
52
|
+
{
|
|
53
|
+
WxRubyPersistentObject* rpo = dynamic_cast<WxRubyPersistentObject*> ($self);
|
|
54
|
+
if (rpo)
|
|
55
|
+
{
|
|
56
|
+
return reinterpret_cast<VALUE> (rpo->GetObject());
|
|
57
|
+
}
|
|
58
|
+
else
|
|
59
|
+
{
|
|
60
|
+
return Qnil;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
__HEREDOC
|
|
64
|
+
super
|
|
65
|
+
end
|
|
66
|
+
end # class PersistentObject
|
|
67
|
+
|
|
68
|
+
end # class Director
|
|
69
|
+
|
|
70
|
+
end # module WXRuby3
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
|
2
|
+
#
|
|
3
|
+
# This software is released under the MIT license.
|
|
4
|
+
|
|
5
|
+
###
|
|
6
|
+
# wxRuby3 wxWidgets interface director
|
|
7
|
+
###
|
|
8
|
+
|
|
9
|
+
module WXRuby3
|
|
10
|
+
|
|
11
|
+
class Director
|
|
12
|
+
|
|
13
|
+
class PersistentWindow < Director
|
|
14
|
+
|
|
15
|
+
def setup
|
|
16
|
+
spec.items << 'wxPersistentTLW' << 'wxPersistentBookCtrl' << 'wxPersistentTreeBookCtrl'
|
|
17
|
+
if Config.instance.wx_version >= '3.3.0'
|
|
18
|
+
# before 3.3.0 this was not properly available
|
|
19
|
+
spec.items << 'wxPersistentComboBox'
|
|
20
|
+
end
|
|
21
|
+
super
|
|
22
|
+
spec.gc_as_marked
|
|
23
|
+
spec.use_template_as_class('wxPersistentWindow', 'wxPersistentWindowBase')
|
|
24
|
+
spec.override_inheritance_chain('wxPersistentWindow', %w[wxPersistentObject])
|
|
25
|
+
spec.ignore 'wxPersistentWindow::wxPersistentWindow',
|
|
26
|
+
'wxPersistentWindow::Get',
|
|
27
|
+
ignore_doc: false
|
|
28
|
+
# make ctor protected because of pure virt methods
|
|
29
|
+
spec.extend_interface 'wxPersistentWindow',
|
|
30
|
+
'wxPersistentWindowBase(wxWindow *win)',
|
|
31
|
+
visibility: 'protected'
|
|
32
|
+
spec.add_header_code 'typedef wxWindow WindowType;'
|
|
33
|
+
spec.add_swig_code 'typedef wxWindow WindowType;'
|
|
34
|
+
spec.map 'WindowType *' => 'Wx::Window', swig: false do
|
|
35
|
+
map_in code: ''
|
|
36
|
+
map_out code: ''
|
|
37
|
+
end
|
|
38
|
+
spec.add_extend_code 'wxPersistentWindowBase', <<~__HEREDOC
|
|
39
|
+
wxWindow * GetObject()
|
|
40
|
+
{
|
|
41
|
+
return reinterpret_cast<wxWindow*> ($self->GetObject());
|
|
42
|
+
}
|
|
43
|
+
__HEREDOC
|
|
44
|
+
# wxPersistentTLW
|
|
45
|
+
spec.override_inheritance_chain('wxPersistentTLW', [{ 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
|
|
46
|
+
# add method override missing from docs
|
|
47
|
+
spec.extend_interface 'wxPersistentTLW',
|
|
48
|
+
'virtual wxString GetKind() const override'
|
|
49
|
+
# wxPersistentBookCtrl
|
|
50
|
+
spec.override_inheritance_chain('wxPersistentBookCtrl', [{ 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
|
|
51
|
+
# add method override missing from docs
|
|
52
|
+
spec.extend_interface 'wxPersistentBookCtrl',
|
|
53
|
+
'virtual wxString GetKind() const override'
|
|
54
|
+
# wxPersistentTreeBookCtrl
|
|
55
|
+
spec.override_inheritance_chain('wxPersistentTreeBookCtrl', ['wxPersistentBookCtrl', { 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
|
|
56
|
+
# add method override missing from docs
|
|
57
|
+
spec.extend_interface 'wxPersistentTreeBookCtrl',
|
|
58
|
+
'virtual wxString GetKind() const override'
|
|
59
|
+
spec.do_not_generate :functions, :defines, :typedefs, :variables, :enums
|
|
60
|
+
if Config.instance.wx_version >= '3.0.0'
|
|
61
|
+
# wxPersistentComboBox
|
|
62
|
+
spec.override_inheritance_chain('wxPersistentComboBox', [{ 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
|
|
63
|
+
# add method override missing from docs
|
|
64
|
+
spec.extend_interface 'wxPersistentComboBox',
|
|
65
|
+
'virtual wxString GetKind() const override'
|
|
66
|
+
end
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
end
|
|
70
|
+
|
|
71
|
+
end
|
|
72
|
+
|
|
73
|
+
end
|
|
@@ -18,6 +18,8 @@ module WXRuby3
|
|
|
18
18
|
|
|
19
19
|
include Typemap::PGCell
|
|
20
20
|
|
|
21
|
+
include Typemap::ClientData
|
|
22
|
+
|
|
21
23
|
def setup
|
|
22
24
|
super
|
|
23
25
|
if spec.module_name == 'wxPGProperty'
|
|
@@ -113,7 +115,7 @@ module WXRuby3
|
|
|
113
115
|
# obsolete
|
|
114
116
|
spec.ignore %w[wxPGProperty::AddChild wxPGProperty::GetValueString]
|
|
115
117
|
# not of use in Ruby
|
|
116
|
-
spec.ignore(%w[wxPGProperty::
|
|
118
|
+
spec.ignore(%w[wxPGProperty::GetClientData wxPGProperty::SetClientData])
|
|
117
119
|
# only keep the const version
|
|
118
120
|
spec.ignore 'wxPGProperty::GetCell'
|
|
119
121
|
spec.regard 'wxPGProperty::GetCell(unsigned int) const'
|
|
@@ -146,32 +148,6 @@ module WXRuby3
|
|
|
146
148
|
spec.suppress_warning(473,
|
|
147
149
|
'wxPGProperty::DoGetEditorClass',
|
|
148
150
|
'wxPGProperty::DoGetValidator')
|
|
149
|
-
spec.add_header_code <<~__HEREDOC
|
|
150
|
-
extern void GC_mark_wxPGProperty(void* ptr)
|
|
151
|
-
{
|
|
152
|
-
#ifdef __WXRB_DEBUG__
|
|
153
|
-
if (wxRuby_TraceLevel()>1)
|
|
154
|
-
{
|
|
155
|
-
std::wcout << "> GC_mark_wxPGProperty : " << ptr;
|
|
156
|
-
if (ptr) std::wcout << " (" << ((wxPGProperty*)ptr)->GetName() << ')';
|
|
157
|
-
std::wcout << std::endl;
|
|
158
|
-
}
|
|
159
|
-
#endif
|
|
160
|
-
if (ptr)
|
|
161
|
-
{
|
|
162
|
-
VALUE object = (VALUE)((wxPGProperty*)ptr)->GetClientData();
|
|
163
|
-
if (object && !NIL_P(object))
|
|
164
|
-
{
|
|
165
|
-
#ifdef __WXRB_DEBUG__
|
|
166
|
-
if (wxRuby_TraceLevel()>2)
|
|
167
|
-
std::wcout << "*** marking property data " << ptr << std::endl;
|
|
168
|
-
#endif
|
|
169
|
-
rb_gc_mark(object);
|
|
170
|
-
}
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
__HEREDOC
|
|
174
|
-
spec.add_swig_code '%markfunc wxPGProperty "GC_mark_wxPGProperty";'
|
|
175
151
|
spec.ignore 'wxPGProperty::m_clientData' # not wanted for wxRuby
|
|
176
152
|
# take protected members into account
|
|
177
153
|
spec.regard 'wxPGProperty::wxPGProperty',
|
|
@@ -237,7 +213,6 @@ module WXRuby3
|
|
|
237
213
|
}
|
|
238
214
|
__CODE
|
|
239
215
|
else
|
|
240
|
-
spec.add_header_code 'extern void GC_mark_wxPGProperty(void* ptr);'
|
|
241
216
|
spec.items.each do |itm|
|
|
242
217
|
unless itm == 'wxColourPropertyValue'
|
|
243
218
|
# add protected member methods and var to complement base class
|
|
@@ -250,7 +225,6 @@ module WXRuby3
|
|
|
250
225
|
'wxVariant m_value',
|
|
251
226
|
visibility: 'protected'
|
|
252
227
|
spec.rename_for_ruby 'value_' => "#{itm}::m_value"
|
|
253
|
-
spec.add_swig_code %Q{%markfunc #{itm} "GC_mark_wxPGProperty";}
|
|
254
228
|
spec.new_object %Q{#{itm}::GetEditorDialog}
|
|
255
229
|
spec.suppress_warning(473, "#{itm}::GetEditorDialog")
|
|
256
230
|
end
|
|
@@ -14,13 +14,13 @@ module WXRuby3
|
|
|
14
14
|
|
|
15
15
|
class RibbonButtonBar < Window
|
|
16
16
|
|
|
17
|
+
include Typemap::ClientData
|
|
18
|
+
|
|
17
19
|
def setup
|
|
18
20
|
super
|
|
19
21
|
# exclude these; far better done in pure Ruby
|
|
20
22
|
spec.ignore 'wxRibbonButtonBar::SetItemClientData',
|
|
21
|
-
'wxRibbonButtonBar::GetItemClientData'
|
|
22
|
-
spec.ignore 'wxRibbonButtonBar::SetItemClientObject',
|
|
23
|
-
'wxRibbonButtonBar::GetItemClientObject'
|
|
23
|
+
'wxRibbonButtonBar::GetItemClientData'
|
|
24
24
|
# not needed because of type mapping
|
|
25
25
|
spec.ignore 'wxRibbonButtonBar::GetItemId',
|
|
26
26
|
'wxRibbonButtonBar::GetItemById'
|
|
@@ -14,15 +14,13 @@ module WXRuby3
|
|
|
14
14
|
|
|
15
15
|
class RibbonGallery < Window
|
|
16
16
|
|
|
17
|
+
include Typemap::ClientData
|
|
18
|
+
|
|
17
19
|
def setup
|
|
18
20
|
super
|
|
19
|
-
# exclude these; far better done in pure Ruby
|
|
20
|
-
spec.ignore 'wxRibbonGallery::SetItemClientObject',
|
|
21
|
-
'wxRibbonGallery::GetItemClientObject',
|
|
22
|
-
'wxRibbonGallery::Append(const wxBitmap &, int, wxClientData *)'
|
|
23
21
|
spec.ignore 'wxRibbonGallery::SetItemClientData',
|
|
24
22
|
'wxRibbonGallery::GetItemClientData',
|
|
25
|
-
'wxRibbonGallery::Append(const wxBitmap &, int, void *)'
|
|
23
|
+
'wxRibbonGallery::Append(const wxBitmap &, int, void *)'
|
|
26
24
|
spec.map 'wxRibbonGalleryItem*' => 'Integer' do
|
|
27
25
|
map_out code: '$result = ULL2NUM(reinterpret_cast<uintptr_t> ($1));'
|
|
28
26
|
map_directorout code: '$result = reinterpret_cast<wxRibbonGalleryItem*> ((uintptr_t)NUM2ULL($1));'
|