wxruby3 0.9.2 → 0.9.4
Sign up to get free protection for your applications and to get access to all the features.
- 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
@@ -29,6 +29,28 @@ module WXRuby3
|
|
29
29
|
spec.rename_for_ruby(
|
30
30
|
'SetTextSelectionRange' => 'wxComboBox::SetSelection(long, long)',
|
31
31
|
'GetTextSelectionRange' => 'wxComboBox::GetSelection(long *, long *) const')
|
32
|
+
spec.ignore 'wxComboBox::SetSelection(long, long)',
|
33
|
+
'wxComboBox::GetSelection(long *, long *) const',
|
34
|
+
ignore_doc: false
|
35
|
+
# workaround because renaming and alias definitions clash
|
36
|
+
spec.add_extend_code 'wxComboBox', <<~__HEREDOC
|
37
|
+
void SetTextSelectionRange(long from, long to)
|
38
|
+
{
|
39
|
+
$self->SetSelection(from, to);
|
40
|
+
}
|
41
|
+
|
42
|
+
void GetTextSelectionRange(long *from, long *to)
|
43
|
+
{
|
44
|
+
$self->GetSelection(from, to);
|
45
|
+
}
|
46
|
+
__HEREDOC
|
47
|
+
# fix override of TextEntry#clear; to be finished in pure Ruby
|
48
|
+
spec.add_extend_code 'wxComboBox', <<~__HEREDOC
|
49
|
+
void ClearItems()
|
50
|
+
{
|
51
|
+
$self->Clear();
|
52
|
+
}
|
53
|
+
__HEREDOC
|
32
54
|
spec.map_apply 'long * OUTPUT' => [ 'long *from', 'long *to' ]
|
33
55
|
end
|
34
56
|
|
@@ -16,7 +16,7 @@ module WXRuby3
|
|
16
16
|
|
17
17
|
def setup
|
18
18
|
super
|
19
|
-
spec.items << 'wxComboPopup'
|
19
|
+
spec.items << 'wxComboPopup'
|
20
20
|
# mixin TextEntry
|
21
21
|
spec.include_mixin 'wxComboCtrl', { 'Wx::TextEntry' => 'wxTextEntryBase' }
|
22
22
|
spec.override_inheritance_chain('wxComboCtrl',
|
@@ -31,60 +31,6 @@ module WXRuby3
|
|
31
31
|
]
|
32
32
|
# turn wxComboPopup into a mixin module
|
33
33
|
spec.make_mixin 'wxComboPopup'
|
34
|
-
# override inheritance chain
|
35
|
-
spec.override_inheritance_chain('wxOwnerDrawnComboBox', %w[wxComboCtrl wxControl wxWindow wxEvtHandler wxObject])
|
36
|
-
spec.fold_bases('wxOwnerDrawnComboBox' => %w[wxItemContainer])
|
37
|
-
spec.regard %w[
|
38
|
-
wxOwnerDrawnComboBox::OnDrawBackground
|
39
|
-
wxOwnerDrawnComboBox::OnDrawItem
|
40
|
-
wxOwnerDrawnComboBox::OnMeasureItem
|
41
|
-
wxOwnerDrawnComboBox::OnMeasureItemWidth
|
42
|
-
]
|
43
|
-
# unuseful overloads
|
44
|
-
spec.ignore 'wxOwnerDrawnComboBox::wxOwnerDrawnComboBox(wxWindow *, wxWindowID, const wxString &, const wxPoint &, const wxSize &, int, const wxString [], long, const wxValidator &, const wxString &)',
|
45
|
-
'wxOwnerDrawnComboBox::Create(wxWindow *, wxWindowID, const wxString &, const wxPoint &, const wxSize &, int, const wxString [], long, const wxValidator &, const wxString &)'
|
46
|
-
spec.ignore('wxItemContainer::Append(const wxString &, wxClientData *)',
|
47
|
-
'wxItemContainer::Append(const std::vector< wxString > &)',
|
48
|
-
'wxItemContainer::Append(const wxArrayString &, wxClientData **)',
|
49
|
-
'wxItemContainer::Append(unsigned int, const wxString *)',
|
50
|
-
'wxItemContainer::Append(unsigned int, const wxString *, void **)',
|
51
|
-
'wxItemContainer::Append(unsigned int, const wxString *, wxClientData **)',
|
52
|
-
'wxItemContainer::Insert(const wxString &, unsigned int, wxClientData *)',
|
53
|
-
'wxItemContainer::Insert(const std::vector< wxString > &)',
|
54
|
-
'wxItemContainer::Insert(const wxArrayString &, unsigned int, wxClientData **)',
|
55
|
-
'wxItemContainer::Insert(unsigned int, const wxString *, unsigned int)',
|
56
|
-
'wxItemContainer::Insert(unsigned int, const wxString *, unsigned int, void **)',
|
57
|
-
'wxItemContainer::Insert(unsigned int, const wxString *, unsigned int, wxClientData **)',
|
58
|
-
'wxItemContainer::Set(const std::vector< wxString > &)',
|
59
|
-
'wxItemContainer::Set(const wxArrayString &, wxClientData **)',
|
60
|
-
'wxItemContainer::Set(unsigned int, const wxString *)',
|
61
|
-
'wxItemContainer::Set(unsigned int, const wxString *, void **)',
|
62
|
-
'wxItemContainer::Set(unsigned int, const wxString *, wxClientData **)',
|
63
|
-
'wxItemContainer::DetachClientObject',
|
64
|
-
'wxItemContainer::HasClientObjectData',
|
65
|
-
'wxItemContainer::GetClientObject',
|
66
|
-
'wxItemContainer::SetClientObject',
|
67
|
-
'wxItemContainer::HasClientUntypedData',
|
68
|
-
'wxItemContainer::Clear')
|
69
|
-
spec.ignore('wxItemContainer::Append(const wxArrayString &, void **)',
|
70
|
-
'wxItemContainer::Insert(const wxArrayString &, unsigned int, void **)',
|
71
|
-
'wxItemContainer::Set(const wxArrayString &, void **)', ignore_doc: false)
|
72
|
-
# ambiguous
|
73
|
-
spec.ignore 'wxOwnerDrawnComboBox::IsEmpty', ignore_doc: false
|
74
|
-
# for doc only
|
75
|
-
spec.map 'void** clientData' => 'Array', swig: false do
|
76
|
-
map_in code: ''
|
77
|
-
end
|
78
|
-
spec.ignore(%w[wxItemContainer::GetClientData wxItemContainer::SetClientData], ignore_doc: false) # keep docs
|
79
|
-
# Replace the old Wx definition of this method (which segfaults)
|
80
|
-
# Only need the setter as we cache data in Ruby and the getter
|
81
|
-
# therefor can be pure Ruby
|
82
|
-
spec.add_extend_code 'wxOwnerDrawnComboBox', <<~__HEREDOC
|
83
|
-
VALUE set_client_data(int n, VALUE item_data) {
|
84
|
-
self->SetClientData(n, (void *)item_data);
|
85
|
-
return item_data;
|
86
|
-
}
|
87
|
-
__HEREDOC
|
88
34
|
end
|
89
35
|
|
90
36
|
end # class ComboCtrl
|
@@ -17,9 +17,22 @@ module WXRuby3
|
|
17
17
|
spec.items.clear
|
18
18
|
spec.add_header_code <<~__HEREDOC
|
19
19
|
#include "wxruby-Config.h"
|
20
|
+
#include <limits>
|
20
21
|
|
21
22
|
static const char * __iv_ConfigBase_sc_config = "@config";
|
22
23
|
|
24
|
+
static WxRuby_ID s_use_hash_config_id("use_hash_config");
|
25
|
+
|
26
|
+
static void
|
27
|
+
_free_config_wx(void* cfg)
|
28
|
+
{
|
29
|
+
if (cfg)
|
30
|
+
{
|
31
|
+
wxConfigBase* config = (wxConfigBase*)cfg;
|
32
|
+
delete config;
|
33
|
+
}
|
34
|
+
}
|
35
|
+
|
23
36
|
static VALUE config_base_get(int argc, VALUE *argv, VALUE self)
|
24
37
|
{
|
25
38
|
bool autoCreate = true;
|
@@ -30,34 +43,110 @@ module WXRuby3
|
|
30
43
|
rb_raise(rb_eArgError, "Expected a single boolean argument");
|
31
44
|
return Qnil;
|
32
45
|
}
|
33
|
-
autoCreate = !(argv[0] == Qfalse || argv[0] == Qnil);
|
46
|
+
autoCreate = !(argv[0] == Qfalse || argv[0] == Qnil); // test truthy-ness
|
34
47
|
}
|
35
48
|
|
49
|
+
// get global ConfigBase instance from Ruby instance variable of ConfigBase singleton class
|
36
50
|
VALUE cConfigBase_Singleton = rb_funcall(g_cConfigBase, rb_intern("singleton_class"), 0, 0);
|
37
51
|
VALUE curConfig = rb_iv_get(cConfigBase_Singleton, __iv_ConfigBase_sc_config);
|
38
|
-
|
39
|
-
if (NIL_P(curConfig)
|
52
|
+
|
53
|
+
if (NIL_P(curConfig))
|
40
54
|
{
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
}
|
55
|
+
wxConfigBase* cfg = wxConfigBase::Get(autoCreate);
|
56
|
+
if (cfg)
|
57
|
+
{
|
58
|
+
// wrap the C++ config object
|
59
|
+
curConfig = Data_Wrap_Struct(g_cConfigWx, 0, 0, cfg);
|
60
|
+
// store global ConfigBase instance as Ruby instance variable of ConfigBase singleton class
|
61
|
+
rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, curConfig);
|
62
|
+
}
|
63
|
+
}
|
50
64
|
return curConfig;
|
51
65
|
}
|
52
66
|
|
53
67
|
static VALUE config_base_create(int argc, VALUE *argv, VALUE self)
|
54
68
|
{
|
69
|
+
bool forced_create = false;
|
70
|
+
bool use_hash = false;
|
55
71
|
if (argc>0)
|
56
72
|
{
|
57
|
-
|
58
|
-
|
73
|
+
if (argc>2)
|
74
|
+
{
|
75
|
+
rb_raise(rb_eArgError, "Unexpected number of arguments.");
|
76
|
+
return Qnil;
|
77
|
+
}
|
78
|
+
if (argc>1 && TYPE(argv[1]) != T_HASH)
|
79
|
+
{
|
80
|
+
rb_raise(rb_eArgError, "Expected kwargs for 2.");
|
81
|
+
return Qnil;
|
82
|
+
}
|
83
|
+
if ((argc==1 && TYPE(argv[0]) != T_HASH) || argc>1)
|
84
|
+
{
|
85
|
+
VALUE rb_forced_create = argc==1 ? argv[0] : argv[1];
|
86
|
+
forced_create = !(rb_forced_create == Qfalse || rb_forced_create == Qnil); // test truthy-ness
|
87
|
+
}
|
88
|
+
if (TYPE(argv[argc-1]) == T_HASH)
|
89
|
+
{
|
90
|
+
VALUE rb_hash = argv[argc-1];
|
91
|
+
int hsz = RHASH_SIZE(rb_hash);
|
92
|
+
if (hsz>1 || (hsz==1 &&!rb_hash_includes(rb_hash, ID2SYM(s_use_hash_config_id()))))
|
93
|
+
{
|
94
|
+
rb_raise(rb_eArgError, "Unexpected keyword argument. Only :use_hash_config allowed.");
|
95
|
+
return Qnil;
|
96
|
+
}
|
97
|
+
|
98
|
+
VALUE rb_use_hash = rb_hash_aref(rb_hash, ID2SYM(s_use_hash_config_id()));
|
99
|
+
use_hash = !(rb_use_hash == Qfalse || rb_use_hash == Qnil); // test truthy-ness
|
100
|
+
}
|
101
|
+
}
|
102
|
+
|
103
|
+
VALUE curConfig = Qnil;
|
104
|
+
|
105
|
+
// get singleton class
|
106
|
+
VALUE cConfigBase_Singleton = rb_funcall(g_cConfigBase, rb_intern("singleton_class"), 0, 0);
|
107
|
+
|
108
|
+
// Any existing C++ global instance known? (do not auto-create if not)
|
109
|
+
wxConfigBase* config = wxConfigBase::Get(false);
|
110
|
+
if (config == nullptr || forced_create)
|
111
|
+
{
|
112
|
+
if (use_hash)
|
113
|
+
{
|
114
|
+
// create new Wx::Config instance
|
115
|
+
curConfig = rb_class_new_instance(0, 0, g_cConfig);
|
116
|
+
// set global wxConfigBase instance to a new Ruby Config wrapper
|
117
|
+
wxConfigBase::Set(wxRuby_Ruby2ConfigBase(curConfig));
|
118
|
+
}
|
119
|
+
else
|
120
|
+
{
|
121
|
+
if (config) wxConfigBase::Set(nullptr); // reset
|
122
|
+
wxConfigBase* new_cfg = wxConfigBase::Create(); // create new C++ instance
|
123
|
+
// wrap the C++ config object
|
124
|
+
curConfig = Data_Wrap_Struct(g_cConfigWx, 0, 0, new_cfg);
|
125
|
+
}
|
126
|
+
// store global ConfigBase instance as Ruby instance variable of ConfigBase singleton class
|
127
|
+
// (keeps it safe from GC)
|
128
|
+
rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, curConfig);
|
129
|
+
if (config)
|
130
|
+
{
|
131
|
+
// clean up; destroy any previous config instance
|
132
|
+
delete config;
|
133
|
+
}
|
134
|
+
}
|
135
|
+
else
|
136
|
+
{
|
137
|
+
// check if this instance was already wrapped
|
138
|
+
curConfig = rb_iv_get(cConfigBase_Singleton, __iv_ConfigBase_sc_config);
|
139
|
+
if (NIL_P(curConfig))
|
140
|
+
{
|
141
|
+
// no global Ruby instance known so can't be wrapped yet (must be C++ instance than)
|
142
|
+
// wrap the C++ config object
|
143
|
+
curConfig = Data_Wrap_Struct(g_cConfigWx, 0, 0, config);
|
144
|
+
// store global ConfigBase instance as Ruby instance variable of ConfigBase singleton class
|
145
|
+
// (keeps it safe from GC)
|
146
|
+
rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, curConfig);
|
147
|
+
}
|
59
148
|
}
|
60
|
-
return
|
149
|
+
return curConfig;
|
61
150
|
}
|
62
151
|
|
63
152
|
static VALUE config_base_set(int argc, VALUE *argv, VALUE self)
|
@@ -82,15 +171,376 @@ module WXRuby3
|
|
82
171
|
VALUE cConfigBase_Singleton = rb_funcall(g_cConfigBase, rb_intern("singleton_class"), 0, 0);
|
83
172
|
VALUE curConfig = rb_iv_get(cConfigBase_Singleton, __iv_ConfigBase_sc_config);
|
84
173
|
// set new config instance (could be nil)
|
85
|
-
|
174
|
+
// set global wxConfigBase instance to a (new) Ruby Hash wrapper (or nullptr)
|
175
|
+
wxConfigBase::Set(wxRuby_Ruby2ConfigBase(newCfg));
|
176
|
+
rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, newCfg);
|
177
|
+
|
178
|
+
// check curConfig type
|
179
|
+
if (!NIL_P(curConfig) && rb_obj_is_kind_of(curConfig, g_cConfigWx) != Qtrue)
|
86
180
|
{
|
87
|
-
//
|
88
|
-
|
181
|
+
// need to make config Ruby owned to it gets proper GC handling
|
182
|
+
// and the C++ allocated config instance gets destroyed
|
183
|
+
RDATA(curConfig)->dfree = _free_config_wx;
|
89
184
|
}
|
90
|
-
rb_iv_set(cConfigBase_Singleton, __iv_ConfigBase_sc_config, newCfg);
|
91
185
|
|
92
186
|
return curConfig; // return old config (if any)
|
93
187
|
}
|
188
|
+
|
189
|
+
static WxRuby_ID to_f_id("to_f");
|
190
|
+
static WxRuby_ID to_i_id("to_i");
|
191
|
+
static WxRuby_ID to_s_id("to_s");
|
192
|
+
|
193
|
+
#ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
|
194
|
+
#define PO_LONG wxLongLong_t
|
195
|
+
#define PO_NUM2LONG(n) NUM2LL(n)
|
196
|
+
#define PO_LONG2NUM(l) LL2NUM(l)
|
197
|
+
#else
|
198
|
+
#define PO_LONG long
|
199
|
+
#define PO_NUM2LONG(n) NUM2LONG(n)
|
200
|
+
#define PO_LONG2NUM(l) LONG2NUM(l)
|
201
|
+
#endif
|
202
|
+
|
203
|
+
static VALUE config_wx_read(int argc, VALUE *argv, VALUE self)
|
204
|
+
{
|
205
|
+
wxConfigBase *cfg;
|
206
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
207
|
+
|
208
|
+
if (argc < 1 || argc > 1)
|
209
|
+
{
|
210
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
211
|
+
}
|
212
|
+
wxString key = RSTR_TO_WXSTR(argv[0]);
|
213
|
+
wxConfigBase::EntryType vtype = cfg->GetEntryType(key);
|
214
|
+
switch(vtype)
|
215
|
+
{
|
216
|
+
case wxConfigBase::Type_Boolean:
|
217
|
+
{
|
218
|
+
bool v = false;
|
219
|
+
if (cfg->Read(key, &v))
|
220
|
+
{
|
221
|
+
return v ? Qtrue : Qfalse;
|
222
|
+
}
|
223
|
+
break;
|
224
|
+
}
|
225
|
+
case wxConfigBase::Type_Integer:
|
226
|
+
{
|
227
|
+
PO_LONG v = 0;
|
228
|
+
if (cfg->Read(key, &v))
|
229
|
+
{
|
230
|
+
return PO_LONG2NUM(v);
|
231
|
+
}
|
232
|
+
break;
|
233
|
+
}
|
234
|
+
case wxConfigBase::Type_Float:
|
235
|
+
{
|
236
|
+
double v = 0.0;
|
237
|
+
if (cfg->Read(key, &v))
|
238
|
+
{
|
239
|
+
return DBL2NUM(v);
|
240
|
+
}
|
241
|
+
break;
|
242
|
+
}
|
243
|
+
case wxConfigBase::Type_String:
|
244
|
+
{
|
245
|
+
wxString v;
|
246
|
+
if (cfg->Read(key, &v))
|
247
|
+
{
|
248
|
+
return WXSTR_TO_RSTR(v);
|
249
|
+
}
|
250
|
+
break;
|
251
|
+
}
|
252
|
+
default:
|
253
|
+
break;
|
254
|
+
}
|
255
|
+
return Qnil;
|
256
|
+
}
|
257
|
+
|
258
|
+
static VALUE config_wx_write(int argc, VALUE *argv, VALUE self)
|
259
|
+
{
|
260
|
+
wxConfigBase *cfg;
|
261
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
262
|
+
|
263
|
+
if (argc < 2 || argc > 2)
|
264
|
+
{
|
265
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 2)", argc);
|
266
|
+
}
|
267
|
+
wxString key = RSTR_TO_WXSTR(argv[0]);
|
268
|
+
VALUE value = argv[1];
|
269
|
+
bool rc = false;
|
270
|
+
switch(TYPE(value))
|
271
|
+
{
|
272
|
+
case T_TRUE:
|
273
|
+
case T_FALSE:
|
274
|
+
{
|
275
|
+
int32_t v = (value == Qtrue ? 1 : 0);
|
276
|
+
rc = cfg->Write(key, v);
|
277
|
+
break;
|
278
|
+
}
|
279
|
+
|
280
|
+
case T_FIXNUM:
|
281
|
+
{
|
282
|
+
PO_LONG v = PO_NUM2LONG(value);
|
283
|
+
if (v > std::numeric_limits<int32_t>::max())
|
284
|
+
{ rc = cfg->Write(key, PO_NUM2LONG(value)); }
|
285
|
+
else
|
286
|
+
{ rc = cfg->Write(key, static_cast<int32_t> (v)); }
|
287
|
+
break;
|
288
|
+
}
|
289
|
+
|
290
|
+
case T_BIGNUM:
|
291
|
+
{
|
292
|
+
VALUE sval = rb_funcall(value, to_s_id(), 0);
|
293
|
+
rc = cfg->Write(key, RSTR_TO_WXSTR(sval));
|
294
|
+
}
|
295
|
+
break;
|
296
|
+
|
297
|
+
case T_FLOAT:
|
298
|
+
rc = cfg->Write(key, NUM2DBL(value));
|
299
|
+
break;
|
300
|
+
|
301
|
+
case T_STRING:
|
302
|
+
rc = cfg->Write(key, RSTR_TO_WXSTR(value));
|
303
|
+
break;
|
304
|
+
|
305
|
+
default:
|
306
|
+
if (rb_respond_to(value, to_i_id()))
|
307
|
+
{
|
308
|
+
VALUE ival = rb_funcall(value, to_i_id(), 0);
|
309
|
+
rc = cfg->Write(key, PO_NUM2LONG(ival));
|
310
|
+
}
|
311
|
+
else if (rb_respond_to(value, to_f_id()))
|
312
|
+
{
|
313
|
+
VALUE fval = rb_funcall(value, to_f_id(), 0);
|
314
|
+
rc = cfg->Write(key, NUM2DBL(fval));
|
315
|
+
}
|
316
|
+
else
|
317
|
+
{
|
318
|
+
VALUE sval = rb_funcall(value, to_s_id(), 0);
|
319
|
+
rc = cfg->Write(key, RSTR_TO_WXSTR(sval));
|
320
|
+
}
|
321
|
+
break;
|
322
|
+
}
|
323
|
+
return rc ? Qtrue : Qfalse;
|
324
|
+
}
|
325
|
+
|
326
|
+
static VALUE config_wx_for_path(int argc, VALUE *argv, VALUE self)
|
327
|
+
{
|
328
|
+
wxConfigBase *cfg;
|
329
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
330
|
+
|
331
|
+
if (argc < 1 || argc > 1)
|
332
|
+
{
|
333
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
334
|
+
}
|
335
|
+
wxString name = RSTR_TO_WXSTR(argv[0]);
|
336
|
+
wxConfigPathChanger path(cfg, name);
|
337
|
+
VALUE rc = Qnil;
|
338
|
+
if (rb_block_given_p ())
|
339
|
+
{
|
340
|
+
VALUE key = WXSTR_TO_RSTR(path.Name());
|
341
|
+
rc = rb_yield_values(2, self, key);
|
342
|
+
}
|
343
|
+
return rc;
|
344
|
+
}
|
345
|
+
|
346
|
+
static VALUE config_wx_delete(int argc, VALUE *argv, VALUE self)
|
347
|
+
{
|
348
|
+
wxConfigBase *cfg;
|
349
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
350
|
+
|
351
|
+
if (argc < 1 || argc > 1)
|
352
|
+
{
|
353
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
354
|
+
}
|
355
|
+
wxString key = RSTR_TO_WXSTR(argv[0]);
|
356
|
+
VALUE rc = Qfalse;
|
357
|
+
if (cfg->HasGroup(key))
|
358
|
+
{
|
359
|
+
rc = cfg->DeleteGroup(key) ? Qtrue : Qfalse;
|
360
|
+
}
|
361
|
+
else if (cfg->HasEntry(key))
|
362
|
+
{
|
363
|
+
rc = cfg->DeleteEntry(key) ? Qtrue : Qfalse;
|
364
|
+
}
|
365
|
+
return rc;
|
366
|
+
}
|
367
|
+
|
368
|
+
static VALUE config_wx_rename(int argc, VALUE *argv, VALUE self)
|
369
|
+
{
|
370
|
+
wxConfigBase *cfg;
|
371
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
372
|
+
|
373
|
+
if (argc < 2 || argc > 2)
|
374
|
+
{
|
375
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 2)", argc);
|
376
|
+
}
|
377
|
+
wxString key = RSTR_TO_WXSTR(argv[0]);
|
378
|
+
wxString newKey = RSTR_TO_WXSTR(argv[1]);
|
379
|
+
VALUE rc = Qfalse;
|
380
|
+
if (cfg->HasGroup(key))
|
381
|
+
{
|
382
|
+
rc = cfg->RenameGroup(key, newKey) ? Qtrue : Qfalse;
|
383
|
+
}
|
384
|
+
else
|
385
|
+
{
|
386
|
+
rc = cfg->RenameEntry(key, newKey) ? Qtrue : Qfalse;
|
387
|
+
}
|
388
|
+
return rc;
|
389
|
+
}
|
390
|
+
|
391
|
+
static VALUE config_wx_each_entry(int argc, VALUE *argv, VALUE self)
|
392
|
+
{
|
393
|
+
wxConfigBase *cfg;
|
394
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
395
|
+
|
396
|
+
if (argc < 0 || argc > 0)
|
397
|
+
{
|
398
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
|
399
|
+
}
|
400
|
+
wxString key;
|
401
|
+
long index = 0;
|
402
|
+
VALUE rc = Qnil;
|
403
|
+
if (rb_block_given_p())
|
404
|
+
{
|
405
|
+
if (cfg->GetFirstEntry(key, index))
|
406
|
+
{
|
407
|
+
do {
|
408
|
+
VALUE rb_key = WXSTR_TO_RSTR(key);
|
409
|
+
rc = rb_yield(rb_key);
|
410
|
+
} while (cfg->GetNextEntry(key, index));
|
411
|
+
}
|
412
|
+
}
|
413
|
+
return rc;
|
414
|
+
}
|
415
|
+
|
416
|
+
static VALUE config_wx_each_group(int argc, VALUE *argv, VALUE self)
|
417
|
+
{
|
418
|
+
wxConfigBase *cfg;
|
419
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
420
|
+
|
421
|
+
if (argc < 0 || argc > 0)
|
422
|
+
{
|
423
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 0)", argc);
|
424
|
+
}
|
425
|
+
wxString key;
|
426
|
+
long index = 0;
|
427
|
+
VALUE rc = Qnil;
|
428
|
+
if (rb_block_given_p())
|
429
|
+
{
|
430
|
+
if (cfg->GetFirstGroup(key, index))
|
431
|
+
{
|
432
|
+
do {
|
433
|
+
VALUE rb_key = WXSTR_TO_RSTR(key);
|
434
|
+
rc = rb_yield(rb_key);
|
435
|
+
} while (cfg->GetNextGroup(key, index));
|
436
|
+
}
|
437
|
+
}
|
438
|
+
return rc;
|
439
|
+
}
|
440
|
+
|
441
|
+
static VALUE config_wx_number_of_entries(int argc, VALUE *argv, VALUE self)
|
442
|
+
{
|
443
|
+
wxConfigBase *cfg;
|
444
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
445
|
+
|
446
|
+
if (argc < 0 || argc > 2)
|
447
|
+
{
|
448
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
449
|
+
}
|
450
|
+
bool recurse = argc>0 ? (argv[0] != Qfalse && argv[0] != Qnil) : false;
|
451
|
+
size_t n = cfg->GetNumberOfEntries(recurse);
|
452
|
+
return LONG2NUM(n);
|
453
|
+
}
|
454
|
+
|
455
|
+
static VALUE config_wx_number_of_groups(int argc, VALUE *argv, VALUE self)
|
456
|
+
{
|
457
|
+
wxConfigBase *cfg;
|
458
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
459
|
+
|
460
|
+
if (argc < 0 || argc > 2)
|
461
|
+
{
|
462
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
463
|
+
}
|
464
|
+
bool recurse = argc>0 ? (argv[0] != Qfalse && argv[0] != Qnil) : false;
|
465
|
+
size_t n = cfg->GetNumberOfGroups(recurse);
|
466
|
+
return LONG2NUM(n);
|
467
|
+
}
|
468
|
+
|
469
|
+
static VALUE config_wx_has_entry(int argc, VALUE *argv, VALUE self)
|
470
|
+
{
|
471
|
+
wxConfigBase *cfg;
|
472
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
473
|
+
|
474
|
+
if (argc < 1 || argc > 1)
|
475
|
+
{
|
476
|
+
rb_raise(rb_eArgError, "wrong # of arguments(%d for 1)", argc);
|
477
|
+
}
|
478
|
+
wxString path = RSTR_TO_WXSTR(argv[0]);
|
479
|
+
return cfg->HasEntry(path) ? Qtrue : Qfalse;
|
480
|
+
}
|
481
|
+
|
482
|
+
static VALUE config_wx_has_group(int argc, VALUE *argv, VALUE self)
|
483
|
+
{
|
484
|
+
wxConfigBase *cfg;
|
485
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
486
|
+
|
487
|
+
if (argc < 1 || argc > 1)
|
488
|
+
{
|
489
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
490
|
+
}
|
491
|
+
wxString path = RSTR_TO_WXSTR(argv[0]);
|
492
|
+
return cfg->HasGroup(path) ? Qtrue : Qfalse;
|
493
|
+
}
|
494
|
+
|
495
|
+
static VALUE config_wx_path(int argc, VALUE *argv, VALUE self)
|
496
|
+
{
|
497
|
+
wxConfigBase *cfg;
|
498
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
499
|
+
|
500
|
+
if (argc < 0 || argc > 2)
|
501
|
+
{
|
502
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
503
|
+
}
|
504
|
+
return WXSTR_TO_RSTR(cfg->GetPath());
|
505
|
+
}
|
506
|
+
|
507
|
+
static VALUE config_wx_clear(int argc, VALUE *argv, VALUE self)
|
508
|
+
{
|
509
|
+
wxConfigBase *cfg;
|
510
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
511
|
+
|
512
|
+
if (argc < 0 || argc > 2)
|
513
|
+
{
|
514
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
515
|
+
}
|
516
|
+
return cfg->DeleteAll() ? Qtrue : Qfalse;
|
517
|
+
}
|
518
|
+
|
519
|
+
static VALUE config_wx_is_expanding_env_vars(int argc, VALUE *argv, VALUE self)
|
520
|
+
{
|
521
|
+
wxConfigBase *cfg;
|
522
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
523
|
+
|
524
|
+
if (argc != 0)
|
525
|
+
{
|
526
|
+
rb_raise(rb_eArgError, "No arguments expected");
|
527
|
+
}
|
528
|
+
return cfg->IsExpandingEnvVars() ? Qtrue : Qfalse;
|
529
|
+
}
|
530
|
+
|
531
|
+
static VALUE config_wx_set_expand_env_vars(int argc, VALUE *argv, VALUE self)
|
532
|
+
{
|
533
|
+
wxConfigBase *cfg;
|
534
|
+
Data_Get_Struct(self, wxConfigBase, cfg);
|
535
|
+
|
536
|
+
if (argc < 1 || argc > 1)
|
537
|
+
{
|
538
|
+
rb_raise(rb_eArgError, "wrong # of arguments (%d for 1)", argc);
|
539
|
+
}
|
540
|
+
bool expand = (argv[0] != Qfalse && argv[0] != Qnil);
|
541
|
+
cfg->SetExpandEnvVars(expand);
|
542
|
+
return Qnil;
|
543
|
+
}
|
94
544
|
__HEREDOC
|
95
545
|
spec.add_wrapper_code <<~__HEREDOC
|
96
546
|
SWIGINTERN void
|
@@ -99,6 +549,7 @@ module WXRuby3
|
|
99
549
|
if (cfg)
|
100
550
|
{
|
101
551
|
wxRbHashConfig* config = (wxRbHashConfig*)cfg;
|
552
|
+
config->ResetRubyConfig();
|
102
553
|
delete config;
|
103
554
|
}
|
104
555
|
}
|
@@ -123,6 +574,26 @@ module WXRuby3
|
|
123
574
|
rb_define_module_function(g_cConfigBase, "get", VALUEFUNC(config_base_get), -1);
|
124
575
|
rb_define_module_function(g_cConfigBase, "set", VALUEFUNC(config_base_set), -1);
|
125
576
|
|
577
|
+
g_cConfigWx = rb_define_class_under(mWxCore, "ConfigWx", g_cConfigBase);
|
578
|
+
rb_undef_alloc_func(g_cConfigWx);
|
579
|
+
rb_define_protected_method(g_cConfigWx, "read_entry", VALUEFUNC(config_wx_read), -1);
|
580
|
+
rb_define_protected_method(g_cConfigWx, "write_entry", VALUEFUNC(config_wx_write), -1);
|
581
|
+
rb_define_method(g_cConfigWx, "for_path", VALUEFUNC(config_wx_for_path), -1);
|
582
|
+
rb_define_method(g_cConfigWx, "each_entry", VALUEFUNC(config_wx_each_entry), -1);
|
583
|
+
rb_define_method(g_cConfigWx, "each_group", VALUEFUNC(config_wx_each_group), -1);
|
584
|
+
rb_define_method(g_cConfigWx, "number_of_entries", VALUEFUNC(config_wx_number_of_entries), -1);
|
585
|
+
rb_define_method(g_cConfigWx, "number_of_groups", VALUEFUNC(config_wx_number_of_groups), -1);
|
586
|
+
rb_define_method(g_cConfigWx, "has_entry?", VALUEFUNC(config_wx_has_entry), -1);
|
587
|
+
rb_define_method(g_cConfigWx, "has_group?", VALUEFUNC(config_wx_has_group), -1);
|
588
|
+
rb_define_method(g_cConfigWx, "delete", VALUEFUNC(config_wx_delete), -1);
|
589
|
+
rb_define_method(g_cConfigWx, "rename", VALUEFUNC(config_wx_rename), -1);
|
590
|
+
rb_define_method(g_cConfigWx, "path", VALUEFUNC(config_wx_path), -1);
|
591
|
+
rb_define_method(g_cConfigWx, "clear", VALUEFUNC(config_wx_clear), -1);
|
592
|
+
rb_define_method(g_cConfigWx, "is_expanding_env_vars", VALUEFUNC(config_wx_is_expanding_env_vars), -1);
|
593
|
+
rb_define_alias(g_cConfigWx, "expanding_env_vars?", "is_expanding_env_vars");
|
594
|
+
rb_define_method(g_cConfigWx, "set_expand_env_vars", VALUEFUNC(config_wx_set_expand_env_vars), -1);
|
595
|
+
rb_define_alias(g_cConfigWx, "expand_env_vars=", "set_expand_env_vars");
|
596
|
+
|
126
597
|
g_cConfig = rb_define_class_under(mWxCore, "Config", g_cConfigBase);
|
127
598
|
rb_define_alloc_func(g_cConfig, config_allocate);
|
128
599
|
__HEREDOC
|