wxruby3 0.9.3-x64-mingw-ucrt → 0.9.4-x64-mingw-ucrt

Sign up to get free protection for your applications and to get access to all the features.
Files changed (113) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxbase32u_gcc_custom.dll +0 -0
  3. data/ext/wxbase32u_net_gcc_custom.dll +0 -0
  4. data/ext/wxbase32u_xml_gcc_custom.dll +0 -0
  5. data/ext/wxmsw32u_aui_gcc_custom.dll +0 -0
  6. data/ext/wxmsw32u_core_gcc_custom.dll +0 -0
  7. data/ext/wxmsw32u_gl_gcc_custom.dll +0 -0
  8. data/ext/wxmsw32u_html_gcc_custom.dll +0 -0
  9. data/ext/wxmsw32u_media_gcc_custom.dll +0 -0
  10. data/ext/wxmsw32u_propgrid_gcc_custom.dll +0 -0
  11. data/ext/wxmsw32u_qa_gcc_custom.dll +0 -0
  12. data/ext/wxmsw32u_ribbon_gcc_custom.dll +0 -0
  13. data/ext/wxmsw32u_richtext_gcc_custom.dll +0 -0
  14. data/ext/wxmsw32u_stc_gcc_custom.dll +0 -0
  15. data/ext/wxmsw32u_webview_gcc_custom.dll +0 -0
  16. data/ext/wxmsw32u_xrc_gcc_custom.dll +0 -0
  17. data/lib/wx/core/book_ctrl_base.rb +16 -0
  18. data/lib/wx/core/config.rb +454 -83
  19. data/lib/wx/core/notebook.rb +10 -8
  20. data/lib/wx/core/peristent_object.rb +15 -0
  21. data/lib/wx/core/persistence_manager.rb +39 -0
  22. data/lib/wx/core/persistent_window.rb +16 -0
  23. data/lib/wx/core/top_level_window.rb +16 -0
  24. data/lib/wx/core/treebook.rb +18 -0
  25. data/lib/wx/core.rb +4 -0
  26. data/lib/wx/doc/book_ctrl_base.rb +19 -0
  27. data/lib/wx/doc/config.rb +101 -41
  28. data/lib/wx/doc/extra/14_config.md +101 -0
  29. data/lib/wx/doc/extra/15_persistence.md +148 -0
  30. data/lib/wx/doc/gen/aui/aui_manager_event.rb +1 -1
  31. data/lib/wx/doc/gen/aui/aui_notebook_event.rb +1 -1
  32. data/lib/wx/doc/gen/aui/aui_tool_bar_event.rb +1 -1
  33. data/lib/wx/doc/gen/book_ctrl_event.rb +1 -1
  34. data/lib/wx/doc/gen/calendar_event.rb +1 -1
  35. data/lib/wx/doc/gen/core.rb +2 -2
  36. data/lib/wx/doc/gen/date_event.rb +1 -1
  37. data/lib/wx/doc/gen/event.rb +4 -4
  38. data/lib/wx/doc/gen/event_blocker.rb +1 -1
  39. data/lib/wx/doc/gen/event_filter.rb +0 -2
  40. data/lib/wx/doc/gen/events.rb +15 -15
  41. data/lib/wx/doc/gen/file_ctrl_event.rb +1 -1
  42. data/lib/wx/doc/gen/file_dialog_customize_hook.rb +2 -2
  43. data/lib/wx/doc/gen/file_dir_picker_event.rb +1 -1
  44. data/lib/wx/doc/gen/find_dialog_event.rb +1 -1
  45. data/lib/wx/doc/gen/gdi_common.rb +0 -8
  46. data/lib/wx/doc/gen/grid/grid_cell_activatable_editor.rb +0 -2
  47. data/lib/wx/doc/gen/grid/grid_cell_attr.rb +0 -2
  48. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_editor.rb +0 -2
  49. data/lib/wx/doc/gen/grid/grid_cell_auto_wrap_string_renderer.rb +0 -2
  50. data/lib/wx/doc/gen/grid/grid_cell_bool_editor.rb +0 -2
  51. data/lib/wx/doc/gen/grid/grid_cell_bool_renderer.rb +0 -2
  52. data/lib/wx/doc/gen/grid/grid_cell_choice_editor.rb +0 -2
  53. data/lib/wx/doc/gen/grid/grid_cell_date_editor.rb +0 -2
  54. data/lib/wx/doc/gen/grid/grid_cell_date_renderer.rb +0 -2
  55. data/lib/wx/doc/gen/grid/grid_cell_date_time_renderer.rb +0 -2
  56. data/lib/wx/doc/gen/grid/grid_cell_editor.rb +0 -2
  57. data/lib/wx/doc/gen/grid/grid_cell_enum_editor.rb +0 -2
  58. data/lib/wx/doc/gen/grid/grid_cell_enum_renderer.rb +0 -2
  59. data/lib/wx/doc/gen/grid/grid_cell_float_editor.rb +0 -2
  60. data/lib/wx/doc/gen/grid/grid_cell_float_renderer.rb +0 -2
  61. data/lib/wx/doc/gen/grid/grid_cell_number_editor.rb +0 -2
  62. data/lib/wx/doc/gen/grid/grid_cell_number_renderer.rb +0 -2
  63. data/lib/wx/doc/gen/grid/grid_cell_renderer.rb +0 -2
  64. data/lib/wx/doc/gen/grid/grid_cell_string_renderer.rb +0 -2
  65. data/lib/wx/doc/gen/grid/grid_cell_text_editor.rb +0 -2
  66. data/lib/wx/doc/gen/grid/grid_editor_created_event.rb +1 -1
  67. data/lib/wx/doc/gen/grid/grid_event.rb +1 -1
  68. data/lib/wx/doc/gen/grid/grid_range_select_event.rb +1 -1
  69. data/lib/wx/doc/gen/grid/grid_size_event.rb +1 -1
  70. data/lib/wx/doc/gen/gui_event_loop.rb +0 -2
  71. data/lib/wx/doc/gen/header_ctrl.rb +0 -6
  72. data/lib/wx/doc/gen/header_ctrl_event.rb +1 -1
  73. data/lib/wx/doc/gen/html/html_cell_event.rb +1 -1
  74. data/lib/wx/doc/gen/list_event.rb +1 -1
  75. data/lib/wx/doc/gen/media_event.rb +1 -1
  76. data/lib/wx/doc/gen/persistence_manager.rb +135 -0
  77. data/lib/wx/doc/gen/persistent_object.rb +52 -0
  78. data/lib/wx/doc/gen/persistent_window.rb +116 -0
  79. data/lib/wx/doc/gen/pg/property_grid_event.rb +1 -1
  80. data/lib/wx/doc/gen/pg/property_grid_interface.rb +2 -2
  81. data/lib/wx/doc/gen/rbn/ribbon_bar_event.rb +1 -1
  82. data/lib/wx/doc/gen/rbn/ribbon_button_bar_event.rb +1 -1
  83. data/lib/wx/doc/gen/rbn/ribbon_gallery_event.rb +1 -1
  84. data/lib/wx/doc/gen/rbn/ribbon_panel_event.rb +1 -1
  85. data/lib/wx/doc/gen/rbn/ribbon_tool_bar_event.rb +1 -1
  86. data/lib/wx/doc/gen/rtc/rich_text_event.rb +1 -1
  87. data/lib/wx/doc/gen/spin_double_event.rb +1 -1
  88. data/lib/wx/doc/gen/spin_event.rb +1 -1
  89. data/lib/wx/doc/gen/splitter_event.rb +1 -1
  90. data/lib/wx/doc/gen/stc/styled_text_event.rb +1 -1
  91. data/lib/wx/doc/gen/task_bar_icon_event.rb +1 -1
  92. data/lib/wx/doc/gen/text_entry.rb +0 -4
  93. data/lib/wx/doc/gen/tree_event.rb +1 -1
  94. data/lib/wx/doc/gen/utils.rb +0 -16
  95. data/lib/wx/doc/gen/wizard_event.rb +1 -1
  96. data/lib/wx/doc/persistence_manager.rb +36 -0
  97. data/lib/wx/doc/persistent_object.rb +27 -0
  98. data/lib/wx/doc/top_level_window.rb +19 -0
  99. data/lib/wx/doc/treebook.rb +6 -1
  100. data/lib/wx/version.rb +1 -1
  101. data/lib/wxruby_aui.so +0 -0
  102. data/lib/wxruby_core.so +0 -0
  103. data/lib/wxruby_grid.so +0 -0
  104. data/lib/wxruby_html.so +0 -0
  105. data/lib/wxruby_pg.so +0 -0
  106. data/lib/wxruby_prt.so +0 -0
  107. data/lib/wxruby_rbn.so +0 -0
  108. data/lib/wxruby_rtc.so +0 -0
  109. data/lib/wxruby_stc.so +0 -0
  110. data/samples/widgets/widgets.rb +5 -9
  111. data/tests/test_config.rb +207 -42
  112. data/tests/test_persistence.rb +142 -0
  113. metadata +18 -2
data/lib/wxruby_aui.so CHANGED
Binary file
data/lib/wxruby_core.so CHANGED
Binary file
data/lib/wxruby_grid.so CHANGED
Binary file
data/lib/wxruby_html.so CHANGED
Binary file
data/lib/wxruby_pg.so CHANGED
Binary file
data/lib/wxruby_prt.so CHANGED
Binary file
data/lib/wxruby_rbn.so CHANGED
Binary file
data/lib/wxruby_rtc.so CHANGED
Binary file
data/lib/wxruby_stc.so CHANGED
Binary file
@@ -456,12 +456,10 @@ module Widgets
456
456
 
457
457
  @panel.set_sizer(sizerTop)
458
458
 
459
- # TODO - review wxPersistenceManager
460
- # sizeSet = wxPersistentRegisterAndRestore(this, "Main")
461
-
459
+ sizeSet = Wx.persistent_register_and_restore(self, "Main")
460
+
462
461
  sizeMin = @panel.get_best_size
463
- # if ( !sizeSet )
464
- set_client_size(sizeMin)
462
+ set_client_size(sizeMin) unless sizeSet
465
463
  set_min_client_size(sizeMin)
466
464
 
467
465
  # connect the event handlers
@@ -1068,10 +1066,8 @@ module Widgets
1068
1066
  evt_choicebook_page_changed(ID::Widgets_BookCtrl, :on_page_changed)
1069
1067
  end
1070
1068
 
1071
- # TODO - review wxPersistenceManager
1072
- # const bool pageSet = wxPersistentRegisterAndRestore(m_book)
1073
- pageSet = false
1074
-
1069
+ pageSet = Wx.persistent_register_and_restore(@book)
1070
+
1075
1071
  if Wx.has_feature?(:USE_TREEBOOK)
1076
1072
  # for treebook page #0 is empty parent page only so select the first page
1077
1073
  # with some contents
data/tests/test_config.rb CHANGED
@@ -13,21 +13,21 @@ class TestConfig < Test::Unit::TestCase
13
13
  'RootEntry4' => 3.14,
14
14
  'Group1' => {
15
15
  'Group1Entry' => 'Group1 string',
16
- 'Group1.1' => {
17
- 'Group1.1Integer' => 999,
18
- 'Group1.1Bignum' => 2**999,
19
- 'Group1.1Float' => (2**999)-0.1
16
+ 'Group1_1' => {
17
+ 'Group1_1Integer' => 999,
18
+ 'Group1_1Bignum' => 2**999,
19
+ 'Group1_1Float' => (2**999)-0.1
20
20
  }
21
21
  },
22
22
  'Group2' => {
23
- 'Group2.1' => {
24
- 'Group2.1.1' => {
23
+ 'Group2_1' => {
24
+ 'Group2_1_1' => {
25
25
  'String' => 'hello'
26
26
  },
27
- 'Group2.1.2' => {
27
+ 'Group2_1_2' => {
28
28
  'String' => 'world'
29
29
  },
30
- 'Group2.1.3' => {
30
+ 'Group2_1_3' => {
31
31
  'True' => true,
32
32
  'False' => false
33
33
  }
@@ -35,79 +35,222 @@ class TestConfig < Test::Unit::TestCase
35
35
  }
36
36
  }
37
37
 
38
+ def stringified_entry(val)
39
+ case val
40
+ when TrueClass,FalseClass
41
+ val ? '1' : '0'
42
+ when Float
43
+ '%g' % val
44
+ else
45
+ val.to_s
46
+ end
47
+ end
48
+
49
+ def stringified(val)
50
+ val.is_a?(::Hash) ? val.inject({}) { |hash, pair| hash[pair.first] = stringified(pair.last); hash } : stringified_entry(val)
51
+ end
52
+
53
+ def assert_true_cfg(val)
54
+ assert_block('expected "1" or true') do
55
+ val == '1' || val == 1 || val == true
56
+ end
57
+ end
58
+
59
+ def assert_false_cfg(val)
60
+ assert_block("expected '0' or false") do
61
+ val == '0' || val == 0 || val == false
62
+ end
63
+ end
64
+
65
+ def assert_equal_cfg(expected, val)
66
+ assert_block("expected #{expected.is_a?(::Hash) ? stringified(expected) : %Q['#{stringified(expected)}']} \nor #{expected}\nbut got #{val}") do
67
+ expected == val || stringified(expected) == stringified(val)
68
+ end
69
+ end
70
+
38
71
  def run_config_tests(cfg)
39
- assert_equal(DEMO_CONFIG, cfg.to_h)
72
+ assert_equal_cfg(DEMO_CONFIG, cfg.to_h)
40
73
 
41
- assert_equal(4, cfg.number_of_entries)
42
- assert_equal(2, cfg.number_of_groups)
43
- assert_equal(12, cfg.number_of_entries(recurse: true))
44
- assert_equal(7, cfg.number_of_groups(recurse: true))
74
+ assert_equal_cfg(4, cfg.number_of_entries)
75
+ assert_equal_cfg(2, cfg.number_of_groups)
76
+ assert_equal_cfg(12, cfg.number_of_entries(recurse: true))
77
+ assert_equal_cfg(7, cfg.number_of_groups(recurse: true))
45
78
 
46
79
  assert_true(cfg.has_entry?('/RootEntry2'))
47
80
  assert_true(cfg.has_entry?('/Group1/Group1Entry'))
48
- assert_true(cfg.has_entry?('/Group2/Group2.1/Group2.1.2/String'))
81
+ assert_true(cfg.has_entry?('/Group2/Group2_1/Group2_1_2/String'))
49
82
 
50
- assert_false(cfg.has_entry?('/Group2/Group2.2/Group2.1.2/String'))
83
+ assert_false(cfg.has_entry?('/Group2/Group2.2/Group2_1_2/String'))
51
84
 
52
85
  assert_true(cfg.has_group?('/Group2'))
53
- assert_true(cfg.has_group?('/Group1/Group1.1'))
54
- assert_true(cfg.has_group?('/Group2/Group2.1/Group2.1.2'))
86
+ assert_true(cfg.has_group?('/Group1/Group1_1'))
87
+ assert_true(cfg.has_group?('/Group2/Group2_1/Group2_1_2'))
55
88
 
56
- assert_false(cfg.has_group?('/Group2/Group2.1/Group2.1.2/String'))
89
+ assert_false(cfg.has_group?('/Group2/Group2_1/Group2_1_2/String'))
57
90
 
58
- grp = cfg['/Group1/Group1.1']
91
+ grp = cfg['/Group1/Group1_1']
59
92
 
60
- assert_equal(DEMO_CONFIG['Group1']['Group1.1'], grp.to_h)
93
+ assert_equal_cfg(DEMO_CONFIG['Group1']['Group1_1'], grp.to_h)
61
94
 
62
95
  assert_equal(3, grp.number_of_entries)
63
96
  assert_equal(0, grp.number_of_groups)
64
97
 
65
- assert_true(grp.has_entry?('Group1.1Integer'))
98
+ assert_true(grp.has_entry?('Group1_1Integer'))
66
99
  assert_false(grp.has_entry?('Group1Entry'))
67
100
  assert_true(grp.has_entry?('../Group1Entry'))
68
101
 
69
- assert_true(grp.has_group?('/Group2/Group2.1/Group2.1.2'))
102
+ assert_true(grp.has_group?('/Group2/Group2_1/Group2_1_2'))
70
103
 
71
104
  assert_equal('This is a string value', cfg['/RootEntry1'])
72
- assert_equal(true, cfg['/RootEntry2'])
73
- assert_equal(101, cfg['/RootEntry3'])
74
- assert_equal(3.14, cfg['/RootEntry4'])
105
+ assert_equal_cfg(true, cfg['/RootEntry2'])
106
+ assert_equal_cfg(101, cfg['/RootEntry3'])
107
+ assert_equal_cfg(3.14, cfg['/RootEntry4'])
75
108
 
76
- grp = cfg['/Group2/Group2.1/Group2.1.3']
77
- assert_true(grp.get('True'))
78
- assert_false(grp.get('False'))
79
- assert_nil(grp.get('../Group2.1.2/String'))
109
+ grp = cfg['/Group2/Group2_1/Group2_1_3']
110
+ assert_true_cfg(grp.get('True'))
111
+ assert_false_cfg(grp.get('False'))
112
+ assert_raise(ArgumentError) { grp.get('../Group2_1_2/String') }
80
113
 
81
- assert_true(grp['True'])
82
- assert_false(grp['False'])
83
- assert_equal('world', grp['../Group2.1.2/String'])
114
+ assert_true_cfg(grp['True'])
115
+ assert_false_cfg(grp['False'])
116
+ assert_equal('world', grp['../Group2_1_2/String'])
84
117
 
85
118
  cfg.set('RootEntry1', 'Altered string value')
86
119
  assert_equal('Altered string value', cfg['RootEntry1'])
87
120
  assert_equal('Altered string value', cfg['/RootEntry1'])
88
121
  assert_equal('Altered string value', cfg.get('RootEntry1'))
89
122
 
90
- cfg.set('RootEntry3', cfg.get('RootEntry3')+99)
91
- assert_equal(200, cfg['/RootEntry3'])
123
+ cfg.set('RootEntry3', cfg.read('RootEntry3', ::Integer)+99)
124
+ assert_equal_cfg(200, cfg['/RootEntry3'])
125
+
126
+ cfg.set('Group1', { 'Group1_2' => { 'Integer' => 777 }})
127
+ assert_equal_cfg(777, cfg['/Group1/Group1_2/Integer'])
128
+
129
+ cfg['/Group1/Group1_2/Integer'] = 666
130
+ assert_equal_cfg(666, cfg['/Group1/Group1_2'].get('Integer'))
131
+
132
+ cfg['/Group1/Group1_2'] = { 'Float' => 0.3330 }
133
+ assert_equal_cfg(0.3330, cfg['/Group1/Group1_2'].get('Float'))
134
+
135
+ assert_equal(0.3330, cfg.read('/Group1/Group1_2/Float').to_f)
136
+ assert_equal(0.3330, cfg.read('/Group1/Group1_2/Float', Float))
137
+ assert_equal(0.3330, cfg.read('/Group1/Group1_2/Float', ->(v) { v.to_f }))
138
+
139
+ cfg.replace(DEMO_CONFIG) # reset
140
+ end
141
+
142
+ def run_auto_accessor_tests(cfg)
143
+ assert_not_nil(cfg.RootEntry2)
144
+ assert_not_nil(cfg.Group1.Group1Entry)
145
+ assert_not_nil(cfg.Group2.Group2_1.Group2_1_2.String)
146
+
147
+ assert_nil(cfg.Group2.Group2_1.Group2_1_2.AString)
148
+
149
+ assert_kind_of(cfg.class::Group, cfg.Group2)
150
+ assert_kind_of(cfg.class::Group, cfg.Group1.Group1_1)
151
+ assert_kind_of(cfg.class::Group, cfg.Group2.Group2_1.Group2_1_2)
152
+
153
+ assert_not_kind_of(cfg.class::Group, cfg.Group2.Group2_1.Group2_1_2.String)
154
+
155
+ grp = cfg.Group1
156
+
157
+ assert_equal_cfg(DEMO_CONFIG['Group1'], grp.to_h)
158
+
159
+ assert_not_nil(grp.Group1Entry)
160
+ assert_nil(grp.Group1_1Integer)
161
+
162
+ assert_kind_of(grp.class, grp.Group1_1)
163
+ assert_not_nil(grp.Group1_1.Group1_1Integer)
164
+
165
+ assert_true(grp.has_entry?('../RootEntry1'))
166
+
167
+ assert_true(grp.has_group?('/Group2/Group2_1/Group2_1_2'))
168
+
169
+ assert_equal_cfg('This is a string value', cfg.RootEntry1)
170
+ assert_equal_cfg(true, cfg.RootEntry2)
171
+ assert_equal_cfg(101, cfg.RootEntry3)
172
+ assert_equal_cfg(3.14, cfg.RootEntry4)
92
173
 
93
- cfg.set('Group1', { 'Group1.2' => { 'Integer' => 777 }})
94
- assert_equal(777, cfg['/Group1/Group1.2/Integer'])
174
+ grp = cfg.Group2.Group2_1.Group2_1_3
175
+ assert_true_cfg(grp.True)
176
+ assert_false_cfg(grp.False)
95
177
 
96
- cfg['/Group1/Group1.2/Integer'] = 666
97
- assert_equal(666, cfg['/Group1/Group1.2'].get('Integer'))
178
+ assert_true_cfg(grp['True'])
179
+ assert_false_cfg(grp['False'])
180
+ assert_equal_cfg('world', grp['../Group2_1_2/String'])
98
181
 
99
- cfg['/Group1/Group1.2'] = { 'Float' => 0.3330 }
100
- assert_equal(0.3330, cfg['/Group1/Group1.2'].get('Float'))
182
+ cfg.RootEntry1 = 'Altered string value'
183
+ assert_equal_cfg('Altered string value', cfg['RootEntry1'])
184
+ assert_equal_cfg('Altered string value', cfg['/RootEntry1'])
185
+ assert_equal_cfg('Altered string value', cfg.get('RootEntry1'))
186
+ assert_equal_cfg('Altered string value', cfg.RootEntry1)
187
+
188
+ cfg.RootEntry3 = (Kernel.Integer(cfg.RootEntry3) rescue 0)+99
189
+ assert_equal_cfg(200, cfg.RootEntry3)
190
+
191
+ cfg.Group1 = { 'Group1_2' => { 'Integer' => 777 }}
192
+ assert_equal_cfg(777, cfg.Group1.Group1_2.Integer)
193
+
194
+ cfg.Group1.Group1_2.Integer = 666
195
+ assert_equal_cfg(666, cfg.Group1.Group1_2.get('Integer'))
196
+
197
+ cfg.Group1.Group1_2 = { 'Float' => 0.3330 }
198
+ assert_equal_cfg(0.3330, cfg.Group1.Group1_2.get('Float'))
199
+
200
+ cfg.replace(DEMO_CONFIG) # reset
201
+ end
202
+
203
+ def run_env_var_tests(cfg)
204
+ # by default expansion is on
205
+
206
+ # add a number of entries for env var in new group 'Environment'
207
+ cfg['/Environment/HOME'] = '$HOME'
208
+ cfg['Environment'].USER = Wx::PLATFORM == 'WXMSW' ? '%USERNAME%' : '${USER}'
209
+ cfg['/Environment/PATH'] = '$(PATH)'
210
+
211
+ assert_equal(ENV['HOME'], cfg.Environment['HOME'])
212
+ assert_equal(ENV[Wx::PLATFORM == 'WXMSW' ? 'USERNAME' : 'USER'], cfg['/Environment/USER'])
213
+ assert_equal(ENV['PATH'], cfg.Environment.PATH)
214
+
215
+ # test escaping
216
+ cfg['/Environment/Escaped_HOME'] = '\$HOME'
217
+ cfg['/Environment/Escaped_HOME2'] = '\\$HOME'
218
+ cfg['/Environment/Escaped_HOME3'] = '\\\$HOME'
219
+
220
+ assert_equal('$HOME', cfg.Environment['Escaped_HOME'])
221
+ assert_equal('$HOME', cfg.Environment['Escaped_HOME2'])
222
+ assert_equal('\$HOME', cfg.Environment['Escaped_HOME3'])
223
+
224
+ cfg['/Environment/NONSENSE'] = '${NonExistingLongNonsenseVariable}'
225
+
226
+ assert_equal('${NonExistingLongNonsenseVariable}', cfg.Environment['NONSENSE'])
227
+
228
+ cfg['/Environment/MULTIPLE'] = "$HOME / #{Wx::PLATFORM == 'WXMSW' ? '%USERNAME%' : '${USER}'}"
229
+
230
+ assert_equal("#{ENV['HOME']} / #{Wx::PLATFORM == 'WXMSW' ? ENV['USERNAME'] : ENV['USER']}", cfg.Environment['MULTIPLE'])
231
+
232
+ # disable env var expansion
233
+ cfg.expand_env_vars = false
234
+ begin
235
+ assert_equal('$HOME', cfg.Environment['HOME'])
236
+ ensure
237
+ # re-enable
238
+ cfg.set_expand_env_vars(true)
239
+ end
101
240
  end
102
241
 
103
242
  def test_basic
104
243
  cfg = Wx::Config.new(DEMO_CONFIG)
105
244
 
106
245
  run_config_tests(cfg)
246
+ run_auto_accessor_tests(cfg)
247
+ run_env_var_tests(cfg)
107
248
  end
108
249
 
109
250
  def test_global
110
- cfg = Wx::ConfigBase.create
251
+ cfg = Wx::ConfigBase.create(true, use_hash_config: true)
252
+
253
+ assert_kind_of(Wx::Config, cfg)
111
254
 
112
255
  cfg.replace(DEMO_CONFIG)
113
256
 
@@ -116,6 +259,8 @@ class TestConfig < Test::Unit::TestCase
116
259
  assert_equal(cfg, Wx::ConfigBase.get(false))
117
260
 
118
261
  run_config_tests(cfg)
262
+ run_auto_accessor_tests(cfg)
263
+ run_env_var_tests(cfg)
119
264
 
120
265
  cfg_old = Wx::ConfigBase.set(nil)
121
266
 
@@ -123,8 +268,28 @@ class TestConfig < Test::Unit::TestCase
123
268
  assert_nil(Wx::ConfigBase.get(false))
124
269
  end
125
270
 
271
+ # default registry based config does not seem to do well in CI build env
272
+ unless is_ci_build? && Wx::PLATFORM == 'WXMSW'
273
+
274
+ def test_default_wx
275
+ Wx::ConfigBase.set(nil) # reset global instance
276
+ cfg = Wx::ConfigBase.get # forced auto creation of default config
277
+
278
+ assert_kind_of(Wx::ConfigWx, cfg)
279
+
280
+ cfg.replace(DEMO_CONFIG)
281
+
282
+ run_config_tests(cfg)
283
+ run_auto_accessor_tests(cfg)
284
+ run_env_var_tests(cfg)
285
+
286
+ assert_true(cfg.clear) # cleanup
287
+ end
288
+
289
+ end
290
+
126
291
  def test_html_help
127
- cfg = Wx::ConfigBase.create
292
+ cfg = Wx::ConfigBase.create(true, use_hash_config: true)
128
293
 
129
294
  assert_true(cfg.to_h.empty?)
130
295
 
@@ -0,0 +1,142 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ require_relative './lib/wxframe_runner'
6
+
7
+ class TopLevelPersistenceTests < WxRuby::Test::GUITests
8
+
9
+ PERSIST_ROOT = 'Persistent_Options'
10
+
11
+ def run_frame_props_tests
12
+ Wx.persistent_register_and_restore(frame_win, 'TestFrame')
13
+
14
+ frame_win.size = [450, 350]
15
+ frame_win.position = [100, 150]
16
+
17
+ Wx::PersistenceManager.get.save_and_unregister(frame_win)
18
+
19
+ cfg = Wx::ConfigBase.get
20
+ assert_kind_of(Wx::ConfigBase, cfg)
21
+ grp = cfg.get(PERSIST_ROOT)
22
+ assert_kind_of(cfg.class::Group, grp)
23
+ grp = grp.get('Window')
24
+ assert_kind_of(cfg.class::Group, grp)
25
+ grp = grp.get('TestFrame')
26
+ assert_kind_of(cfg.class::Group, grp)
27
+
28
+ assert_equal(100, Integer(grp['x']))
29
+ assert_equal(150, Integer(grp['y']))
30
+ assert_equal(450, Integer(grp.w))
31
+ assert_equal(350, Integer(grp.h))
32
+
33
+ grp.x = 110
34
+ grp.y = 140
35
+
36
+ assert_equal(110, Integer(grp['x']))
37
+ assert_equal(140, Integer(grp['y']))
38
+
39
+ Wx.persistent_register_and_restore(frame_win, 'TestFrame')
40
+
41
+ assert_equal(Wx::Point.new(110, 140), frame_win.position)
42
+
43
+ Wx::PersistenceManager.get.unregister(frame_win)
44
+ end
45
+
46
+ def test_frame_props_ruby_config
47
+ # force creation of hash based Wx::Config instance
48
+ Wx::ConfigBase.create(true, use_hash_config: true)
49
+
50
+ run_frame_props_tests
51
+
52
+ Wx::ConfigBase.get.clear
53
+ end
54
+
55
+ # default registry based config does not seem to do well in CI build env
56
+ unless is_ci_build? && Wx::PLATFORM == 'WXMSW'
57
+
58
+ def test_frame_props_default_config
59
+ # force creation of default C++ config instance
60
+ Wx::ConfigBase.create(true)
61
+
62
+ run_frame_props_tests
63
+
64
+ Wx::ConfigBase.get.clear
65
+ end
66
+
67
+ end
68
+
69
+ class PersistentButton < Wx::PersistentWindowBase
70
+
71
+ def get_kind
72
+ 'Button'
73
+ end
74
+
75
+ def save
76
+ save_value('w', get.size.width)
77
+ save_value('h', get.size.height)
78
+ save_value('label', get.label)
79
+ save_value('my_custom_value', get.my_custom_value)
80
+ end
81
+
82
+ def restore
83
+ get.size = [Integer(restore_value('w')), Integer(restore_value('h'))]
84
+ get.label = restore_value('label')
85
+ get.my_custom_value = Float(restore_value('my_custom_value'))
86
+ true
87
+ end
88
+
89
+ end
90
+
91
+ class MyButton < Wx::Button
92
+
93
+ def initialize(parent=nil, name)
94
+ super(parent, label: '', name: name)
95
+ @my_custom_value = ''
96
+ end
97
+
98
+ attr_accessor :my_custom_value
99
+
100
+ def create_persistent_object
101
+ PersistentButton.new(self)
102
+ end
103
+
104
+ end
105
+
106
+ def test_custom_persistent_object
107
+ # force creation of hash based Wx::Config instance
108
+ Wx::ConfigBase.create(true, use_hash_config: true)
109
+
110
+ assert_false(Wx::ConfigBase.get.has_group?(PERSIST_ROOT))
111
+
112
+ btn = MyButton.new(frame_win, 'AButton')
113
+ btn.label = 'Hello world'
114
+ btn.my_custom_value = 3.14
115
+
116
+ Wx::PersistenceManager.get.register(btn)
117
+
118
+ assert_false(Wx::ConfigBase.get.has_group?(PERSIST_ROOT))
119
+
120
+ # destroying window should save and unregister
121
+ btn.destroy
122
+ btn = nil
123
+
124
+
125
+ assert_true(Wx::ConfigBase.get.has_group?(PERSIST_ROOT))
126
+
127
+ cfg = Wx::ConfigBase.get[PERSIST_ROOT]['Button']['AButton']
128
+ assert_true(cfg.has_entry?('w'))
129
+ assert_true(cfg.has_entry?('h'))
130
+ assert_true(cfg.has_entry?('label'))
131
+ assert_true(cfg.has_entry?('my_custom_value'))
132
+
133
+
134
+ btn = MyButton.new(frame_win, 'AButton')
135
+
136
+ Wx::PersistenceManager.get.register_and_restore(btn)
137
+
138
+ assert_equal('Hello world', btn.label)
139
+ assert_equal(3.14, btn.my_custom_value)
140
+ end
141
+
142
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: wxruby3
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.3
4
+ version: 0.9.4
5
5
  platform: x64-mingw-ucrt
6
6
  authors:
7
7
  - Martin Corino
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-12-15 00:00:00.000000000 Z
11
+ date: 2024-01-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -118,6 +118,7 @@ files:
118
118
  - lib/wx/core/artprovider.rb
119
119
  - lib/wx/core/bitmap.rb
120
120
  - lib/wx/core/bitmap_combobox.rb
121
+ - lib/wx/core/book_ctrl_base.rb
121
122
  - lib/wx/core/brush.rb
122
123
  - lib/wx/core/busycursor.rb
123
124
  - lib/wx/core/choicedlg.rb
@@ -171,6 +172,9 @@ files:
171
172
  - lib/wx/core/paintdc.rb
172
173
  - lib/wx/core/pen.rb
173
174
  - lib/wx/core/pen_info.rb
175
+ - lib/wx/core/peristent_object.rb
176
+ - lib/wx/core/persistence_manager.rb
177
+ - lib/wx/core/persistent_window.rb
174
178
  - lib/wx/core/platform_info.rb
175
179
  - lib/wx/core/point.rb
176
180
  - lib/wx/core/real_point.rb
@@ -187,7 +191,9 @@ files:
187
191
  - lib/wx/core/timer.rb
188
192
  - lib/wx/core/toolbar.rb
189
193
  - lib/wx/core/toolbartool.rb
194
+ - lib/wx/core/top_level_window.rb
190
195
  - lib/wx/core/tree_ctrl.rb
196
+ - lib/wx/core/treebook.rb
191
197
  - lib/wx/core/v_list_box.rb
192
198
  - lib/wx/core/validator.rb
193
199
  - lib/wx/core/variant.rb
@@ -201,6 +207,7 @@ files:
201
207
  - lib/wx/doc/aui/auimanager.rb
202
208
  - lib/wx/doc/aui/auinotebook.rb
203
209
  - lib/wx/doc/bitmap.rb
210
+ - lib/wx/doc/book_ctrl_base.rb
204
211
  - lib/wx/doc/brush.rb
205
212
  - lib/wx/doc/busy_info.rb
206
213
  - lib/wx/doc/client_dc.rb
@@ -237,6 +244,8 @@ files:
237
244
  - lib/wx/doc/extra/11_drawing_and_dc.md
238
245
  - lib/wx/doc/extra/12_client_data.md
239
246
  - lib/wx/doc/extra/13_validators.md
247
+ - lib/wx/doc/extra/14_config.md
248
+ - lib/wx/doc/extra/15_persistence.md
240
249
  - lib/wx/doc/font.rb
241
250
  - lib/wx/doc/font_data.rb
242
251
  - lib/wx/doc/functions.rb
@@ -440,6 +449,9 @@ files:
440
449
  - lib/wx/doc/gen/palette.rb
441
450
  - lib/wx/doc/gen/panel.rb
442
451
  - lib/wx/doc/gen/pen.rb
452
+ - lib/wx/doc/gen/persistence_manager.rb
453
+ - lib/wx/doc/gen/persistent_object.rb
454
+ - lib/wx/doc/gen/persistent_window.rb
443
455
  - lib/wx/doc/gen/pg/event_list.rb
444
456
  - lib/wx/doc/gen/pg/numeric_property_validator.rb
445
457
  - lib/wx/doc/gen/pg/pg_array_editor_dialog.rb
@@ -601,6 +613,8 @@ files:
601
613
  - lib/wx/doc/num_validator.rb
602
614
  - lib/wx/doc/owner_drawn_combobox.rb
603
615
  - lib/wx/doc/pen.rb
616
+ - lib/wx/doc/persistence_manager.rb
617
+ - lib/wx/doc/persistent_object.rb
604
618
  - lib/wx/doc/pg/events.rb
605
619
  - lib/wx/doc/pg/numeric_property_validator.rb
606
620
  - lib/wx/doc/pg/pg_property.rb
@@ -637,6 +651,7 @@ files:
637
651
  - lib/wx/doc/system_settings.rb
638
652
  - lib/wx/doc/text_validator.rb
639
653
  - lib/wx/doc/textctrl.rb
654
+ - lib/wx/doc/top_level_window.rb
640
655
  - lib/wx/doc/tree_ctrl.rb
641
656
  - lib/wx/doc/tree_event.rb
642
657
  - lib/wx/doc/treebook.rb
@@ -1056,6 +1071,7 @@ files:
1056
1071
  - tests/test_log.rb
1057
1072
  - tests/test_media_ctrl.rb
1058
1073
  - tests/test_menu.rb
1074
+ - tests/test_persistence.rb
1059
1075
  - tests/test_pg.rb
1060
1076
  - tests/test_proof_check.rb
1061
1077
  - tests/test_richtext.rb