wxruby3 0.9.3 → 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/ext/wxruby3/include/wxruby-Config.h +23 -5
- data/ext/wxruby3/include/wxruby-Persistence.h +79 -0
- data/ext/wxruby3/swig/memory_management.i +6 -0
- data/lib/wx/core/book_ctrl_base.rb +16 -0
- data/lib/wx/core/config.rb +454 -83
- data/lib/wx/core/notebook.rb +10 -8
- 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/top_level_window.rb +16 -0
- data/lib/wx/core/treebook.rb +18 -0
- data/lib/wx/core.rb +4 -0
- data/lib/wx/doc/book_ctrl_base.rb +19 -0
- data/lib/wx/doc/config.rb +101 -41
- data/lib/wx/doc/extra/14_config.md +101 -0
- data/lib/wx/doc/extra/15_persistence.md +148 -0
- data/lib/wx/doc/persistence_manager.rb +36 -0
- data/lib/wx/doc/persistent_object.rb +27 -0
- data/lib/wx/doc/top_level_window.rb +19 -0
- data/lib/wx/doc/treebook.rb +6 -1
- data/lib/wx/version.rb +1 -1
- data/rakelib/build.rb +1 -1
- data/rakelib/lib/core/package.rb +22 -1
- data/rakelib/lib/core/spec.rb +10 -0
- data/rakelib/lib/core/spec_helper.rb +1 -1
- data/rakelib/lib/director/config_base.rb +490 -19
- data/rakelib/lib/director/event_filter.rb +1 -1
- data/rakelib/lib/director/event_loop.rb +1 -1
- data/rakelib/lib/director/file_dialog_customize_hook.rb +2 -2
- data/rakelib/lib/director/grid_cell_attr.rb +1 -1
- data/rakelib/lib/director/grid_cell_editor.rb +1 -1
- data/rakelib/lib/director/grid_cell_renderer.rb +1 -1
- data/rakelib/lib/director/header_ctrl.rb +3 -0
- data/rakelib/lib/director/html_listbox.rb +2 -1
- 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/static_bitmap.rb +4 -0
- data/rakelib/lib/director/text_entry.rb +1 -1
- data/rakelib/lib/generate/analyzer.rb +43 -43
- data/rakelib/lib/generate/doc.rb +1 -1
- data/rakelib/lib/specs/interfaces.rb +3 -0
- data/rakelib/lib/typemap/config.rb +8 -0
- data/samples/widgets/widgets.rb +5 -9
- data/tests/test_config.rb +207 -42
- data/tests/test_persistence.rb +142 -0
- metadata +19 -2
data/rakelib/lib/generate/doc.rb
CHANGED
@@ -480,7 +480,7 @@ module WXRuby3
|
|
480
480
|
/\A\s*Include\s+file:/ # Include file note
|
481
481
|
''
|
482
482
|
else
|
483
|
-
para.sub!(/Include\s+file:\s
|
483
|
+
para.sub!(/Include\s+file:\s+\\?#include\s+<[^>]+> */, '')
|
484
484
|
if event_section?
|
485
485
|
case para
|
486
486
|
when /The following event handler macros redirect.*(\{.*})/
|
@@ -230,6 +230,9 @@ module WXRuby3
|
|
230
230
|
Director.Spec(pkg, 'wxFileSystem', requirements: %w[USE_FILESYSTEM])
|
231
231
|
Director.Spec(pkg, 'wxDialUpManager', requirements: %w[USE_DIALUP_MANAGER])
|
232
232
|
Director.Spec(pkg, 'wxDialUpEvent', requirements: %w[USE_DIALUP_MANAGER])
|
233
|
+
Director.Spec(pkg, 'wxPersistenceManager', requirements: %w[USE_CONFIG])
|
234
|
+
Director.Spec(pkg, 'wxPersistentObject', requirements: %w[USE_CONFIG])
|
235
|
+
Director.Spec(pkg, 'wxPersistentWindow', requirements: %w[USE_CONFIG])
|
233
236
|
}
|
234
237
|
|
235
238
|
Director.Package('Wx::PRT', 'USE_PRINTING_ARCHITECTURE') do |pkg|
|
@@ -44,6 +44,14 @@ module WXRuby3
|
|
44
44
|
$input = wxRuby_ConfigBase2Ruby($1);
|
45
45
|
__CODE
|
46
46
|
|
47
|
+
map_out code: <<~__CODE
|
48
|
+
$result = wxRuby_ConfigBase2Ruby($1);
|
49
|
+
__CODE
|
50
|
+
|
51
|
+
map_directorout code: <<~__CODE
|
52
|
+
$result = wxRuby_Ruby2ConfigBase($1);
|
53
|
+
__CODE
|
54
|
+
|
47
55
|
end
|
48
56
|
|
49
57
|
end
|
data/samples/widgets/widgets.rb
CHANGED
@@ -456,12 +456,10 @@ module Widgets
|
|
456
456
|
|
457
457
|
@panel.set_sizer(sizerTop)
|
458
458
|
|
459
|
-
|
460
|
-
|
461
|
-
|
459
|
+
sizeSet = Wx.persistent_register_and_restore(self, "Main")
|
460
|
+
|
462
461
|
sizeMin = @panel.get_best_size
|
463
|
-
|
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
|
-
|
1072
|
-
|
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
|
-
'
|
17
|
-
'
|
18
|
-
'
|
19
|
-
'
|
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
|
-
'
|
24
|
-
'
|
23
|
+
'Group2_1' => {
|
24
|
+
'Group2_1_1' => {
|
25
25
|
'String' => 'hello'
|
26
26
|
},
|
27
|
-
'
|
27
|
+
'Group2_1_2' => {
|
28
28
|
'String' => 'world'
|
29
29
|
},
|
30
|
-
'
|
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
|
-
|
72
|
+
assert_equal_cfg(DEMO_CONFIG, cfg.to_h)
|
40
73
|
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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/
|
81
|
+
assert_true(cfg.has_entry?('/Group2/Group2_1/Group2_1_2/String'))
|
49
82
|
|
50
|
-
assert_false(cfg.has_entry?('/Group2/Group2.2/
|
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/
|
54
|
-
assert_true(cfg.has_group?('/Group2/
|
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/
|
89
|
+
assert_false(cfg.has_group?('/Group2/Group2_1/Group2_1_2/String'))
|
57
90
|
|
58
|
-
grp = cfg['/Group1/
|
91
|
+
grp = cfg['/Group1/Group1_1']
|
59
92
|
|
60
|
-
|
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?('
|
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/
|
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
|
-
|
73
|
-
|
74
|
-
|
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/
|
77
|
-
|
78
|
-
|
79
|
-
|
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
|
-
|
82
|
-
|
83
|
-
assert_equal('world', grp['../
|
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.
|
91
|
-
|
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
|
-
|
94
|
-
|
174
|
+
grp = cfg.Group2.Group2_1.Group2_1_3
|
175
|
+
assert_true_cfg(grp.True)
|
176
|
+
assert_false_cfg(grp.False)
|
95
177
|
|
96
|
-
|
97
|
-
|
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
|
100
|
-
|
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.
|
4
|
+
version: 0.9.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Martin Corino
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-01-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: nokogiri
|
@@ -100,6 +100,7 @@ files:
|
|
100
100
|
- ext/wxruby3/include/wxRubyApp.h
|
101
101
|
- ext/wxruby3/include/wxruby-ClientData.h
|
102
102
|
- ext/wxruby3/include/wxruby-Config.h
|
103
|
+
- ext/wxruby3/include/wxruby-Persistence.h
|
103
104
|
- ext/wxruby3/include/wxruby-ScaledDC.h
|
104
105
|
- ext/wxruby3/include/wxruby-Validator.h
|
105
106
|
- ext/wxruby3/include/wxruby-ValidatorBinding.h
|
@@ -138,6 +139,7 @@ files:
|
|
138
139
|
- lib/wx/core/artprovider.rb
|
139
140
|
- lib/wx/core/bitmap.rb
|
140
141
|
- lib/wx/core/bitmap_combobox.rb
|
142
|
+
- lib/wx/core/book_ctrl_base.rb
|
141
143
|
- lib/wx/core/brush.rb
|
142
144
|
- lib/wx/core/busycursor.rb
|
143
145
|
- lib/wx/core/choicedlg.rb
|
@@ -189,6 +191,9 @@ files:
|
|
189
191
|
- lib/wx/core/paintdc.rb
|
190
192
|
- lib/wx/core/pen.rb
|
191
193
|
- lib/wx/core/pen_info.rb
|
194
|
+
- lib/wx/core/peristent_object.rb
|
195
|
+
- lib/wx/core/persistence_manager.rb
|
196
|
+
- lib/wx/core/persistent_window.rb
|
192
197
|
- lib/wx/core/platform_info.rb
|
193
198
|
- lib/wx/core/point.rb
|
194
199
|
- lib/wx/core/real_point.rb
|
@@ -205,7 +210,9 @@ files:
|
|
205
210
|
- lib/wx/core/timer.rb
|
206
211
|
- lib/wx/core/toolbar.rb
|
207
212
|
- lib/wx/core/toolbartool.rb
|
213
|
+
- lib/wx/core/top_level_window.rb
|
208
214
|
- lib/wx/core/tree_ctrl.rb
|
215
|
+
- lib/wx/core/treebook.rb
|
209
216
|
- lib/wx/core/v_list_box.rb
|
210
217
|
- lib/wx/core/validator.rb
|
211
218
|
- lib/wx/core/variant.rb
|
@@ -219,6 +226,7 @@ files:
|
|
219
226
|
- lib/wx/doc/aui/auimanager.rb
|
220
227
|
- lib/wx/doc/aui/auinotebook.rb
|
221
228
|
- lib/wx/doc/bitmap.rb
|
229
|
+
- lib/wx/doc/book_ctrl_base.rb
|
222
230
|
- lib/wx/doc/brush.rb
|
223
231
|
- lib/wx/doc/busy_info.rb
|
224
232
|
- lib/wx/doc/client_dc.rb
|
@@ -255,6 +263,8 @@ files:
|
|
255
263
|
- lib/wx/doc/extra/11_drawing_and_dc.md
|
256
264
|
- lib/wx/doc/extra/12_client_data.md
|
257
265
|
- lib/wx/doc/extra/13_validators.md
|
266
|
+
- lib/wx/doc/extra/14_config.md
|
267
|
+
- lib/wx/doc/extra/15_persistence.md
|
258
268
|
- lib/wx/doc/font.rb
|
259
269
|
- lib/wx/doc/font_data.rb
|
260
270
|
- lib/wx/doc/functions.rb
|
@@ -279,6 +289,8 @@ files:
|
|
279
289
|
- lib/wx/doc/num_validator.rb
|
280
290
|
- lib/wx/doc/owner_drawn_combobox.rb
|
281
291
|
- lib/wx/doc/pen.rb
|
292
|
+
- lib/wx/doc/persistence_manager.rb
|
293
|
+
- lib/wx/doc/persistent_object.rb
|
282
294
|
- lib/wx/doc/pg/events.rb
|
283
295
|
- lib/wx/doc/pg/numeric_property_validator.rb
|
284
296
|
- lib/wx/doc/pg/pg_property.rb
|
@@ -315,6 +327,7 @@ files:
|
|
315
327
|
- lib/wx/doc/system_settings.rb
|
316
328
|
- lib/wx/doc/text_validator.rb
|
317
329
|
- lib/wx/doc/textctrl.rb
|
330
|
+
- lib/wx/doc/top_level_window.rb
|
318
331
|
- lib/wx/doc/tree_ctrl.rb
|
319
332
|
- lib/wx/doc/tree_event.rb
|
320
333
|
- lib/wx/doc/treebook.rb
|
@@ -546,6 +559,9 @@ files:
|
|
546
559
|
- rakelib/lib/director/palette.rb
|
547
560
|
- rakelib/lib/director/panel.rb
|
548
561
|
- rakelib/lib/director/pen.rb
|
562
|
+
- rakelib/lib/director/persistence_manager.rb
|
563
|
+
- rakelib/lib/director/persistent_object.rb
|
564
|
+
- rakelib/lib/director/persistent_window.rb
|
549
565
|
- rakelib/lib/director/pgarray_editor_dialog.rb
|
550
566
|
- rakelib/lib/director/pgcell.rb
|
551
567
|
- rakelib/lib/director/pgeditor.rb
|
@@ -1090,6 +1106,7 @@ files:
|
|
1090
1106
|
- tests/test_log.rb
|
1091
1107
|
- tests/test_media_ctrl.rb
|
1092
1108
|
- tests/test_menu.rb
|
1109
|
+
- tests/test_persistence.rb
|
1093
1110
|
- tests/test_pg.rb
|
1094
1111
|
- tests/test_proof_check.rb
|
1095
1112
|
- tests/test_richtext.rb
|