wxruby3 0.9.3 → 0.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +1 -1
  3. data/README.md +2 -2
  4. data/ext/wxruby3/include/wxruby-ComboPopup.h +777 -0
  5. data/ext/wxruby3/include/wxruby-Config.h +23 -5
  6. data/ext/wxruby3/include/wxruby-Persistence.h +79 -0
  7. data/ext/wxruby3/swig/memory_management.i +6 -0
  8. data/lib/wx/core/book_ctrl_base.rb +16 -0
  9. data/lib/wx/core/combo_ctrl.rb +171 -0
  10. data/lib/wx/core/config.rb +454 -83
  11. data/lib/wx/core/notebook.rb +10 -8
  12. data/lib/wx/core/peristent_object.rb +15 -0
  13. data/lib/wx/core/persistence_manager.rb +39 -0
  14. data/lib/wx/core/persistent_window.rb +16 -0
  15. data/lib/wx/core/top_level_window.rb +16 -0
  16. data/lib/wx/core/treebook.rb +18 -0
  17. data/lib/wx/core.rb +4 -0
  18. data/lib/wx/doc/book_ctrl_base.rb +19 -0
  19. data/lib/wx/doc/comboctrl.rb +128 -3
  20. data/lib/wx/doc/config.rb +101 -41
  21. data/lib/wx/doc/extra/14_config.md +101 -0
  22. data/lib/wx/doc/extra/15_persistence.md +148 -0
  23. data/lib/wx/doc/owner_drawn_combobox.rb +5 -1
  24. data/lib/wx/doc/persistence_manager.rb +36 -0
  25. data/lib/wx/doc/persistent_object.rb +27 -0
  26. data/lib/wx/doc/top_level_window.rb +19 -0
  27. data/lib/wx/doc/treebook.rb +6 -1
  28. data/lib/wx/version.rb +1 -1
  29. data/rakelib/build.rb +1 -1
  30. data/rakelib/lib/core/include/funcall.inc +2 -1
  31. data/rakelib/lib/core/package.rb +22 -1
  32. data/rakelib/lib/core/spec.rb +10 -0
  33. data/rakelib/lib/core/spec_helper.rb +1 -1
  34. data/rakelib/lib/director/comboctrl.rb +104 -3
  35. data/rakelib/lib/director/config_base.rb +490 -19
  36. data/rakelib/lib/director/defs.rb +1 -3
  37. data/rakelib/lib/director/event_filter.rb +1 -1
  38. data/rakelib/lib/director/event_loop.rb +1 -1
  39. data/rakelib/lib/director/file_dialog_customize_hook.rb +2 -2
  40. data/rakelib/lib/director/gdicommon.rb +6 -0
  41. data/rakelib/lib/director/grid_cell_attr.rb +1 -1
  42. data/rakelib/lib/director/grid_cell_editor.rb +1 -1
  43. data/rakelib/lib/director/grid_cell_renderer.rb +1 -1
  44. data/rakelib/lib/director/header_ctrl.rb +3 -0
  45. data/rakelib/lib/director/html_listbox.rb +2 -1
  46. data/rakelib/lib/director/menu_item.rb +1 -1
  47. data/rakelib/lib/director/num_validator.rb +5 -7
  48. data/rakelib/lib/director/owner_drawn_combobox.rb +1 -0
  49. data/rakelib/lib/director/persistence_manager.rb +410 -0
  50. data/rakelib/lib/director/persistent_object.rb +70 -0
  51. data/rakelib/lib/director/persistent_window.rb +73 -0
  52. data/rakelib/lib/director/pgeditor.rb +1 -1
  53. data/rakelib/lib/director/pgproperties.rb +3 -3
  54. data/rakelib/lib/director/pgproperty.rb +5 -1
  55. data/rakelib/lib/director/richtext_style_listbox.rb +5 -0
  56. data/rakelib/lib/director/sizer.rb +1 -1
  57. data/rakelib/lib/director/static_bitmap.rb +4 -0
  58. data/rakelib/lib/director/text_entry.rb +1 -1
  59. data/rakelib/lib/director/window.rb +4 -0
  60. data/rakelib/lib/extractor/module.rb +15 -0
  61. data/rakelib/lib/generate/analyzer.rb +43 -43
  62. data/rakelib/lib/generate/doc/combo_ctrl.yaml +135 -0
  63. data/rakelib/lib/generate/doc/file_dialog_customize_hook.yaml +62 -0
  64. data/rakelib/lib/generate/doc/file_system.yaml +28 -0
  65. data/rakelib/lib/generate/doc.rb +1 -1
  66. data/rakelib/lib/generate/interface.rb +12 -4
  67. data/rakelib/lib/specs/interfaces.rb +3 -0
  68. data/rakelib/lib/swig_runner.rb +7 -4
  69. data/rakelib/lib/typemap/combo_popup.rb +42 -0
  70. data/rakelib/lib/typemap/config.rb +8 -0
  71. data/samples/widgets/widgets.rb +5 -9
  72. data/tests/test_combo_ctrl.rb +196 -0
  73. data/tests/test_config.rb +207 -42
  74. data/tests/test_persistence.rb +142 -0
  75. metadata +26 -2
@@ -24,7 +24,7 @@ module WXRuby3
24
24
  spec.ignore_unless('USE_ACCEL', 'wxMenuItem::GetAccel')
25
25
  spec.no_proxy 'wxMenuItem::GetAccel'
26
26
  spec.ignore 'wxMenuItem::GetBitmap(bool)' # not portable
27
- if Config.instance.wx_version >= '3.3.0'
27
+ if Config.instance.wx_version > '3.2.4'
28
28
  spec.ignore_unless('WXMSW', 'wxMenuItem::SetBackgroundColour','wxMenuItem::SetFont','wxMenuItem::SetTextColour')
29
29
  end
30
30
  super
@@ -383,13 +383,11 @@ module WXRuby3
383
383
  # hardcoded interface declarations
384
384
  spec.add_interface_code <<~__HEREDOC
385
385
  // Bit masks used for numeric validator styles.
386
- enum wxNumValidatorStyle
387
- {
388
- wxNUM_VAL_DEFAULT = 0x0,
389
- wxNUM_VAL_THOUSANDS_SEPARATOR = 0x1,
390
- wxNUM_VAL_ZERO_AS_BLANK = 0x2,
391
- wxNUM_VAL_NO_TRAILING_ZEROES = 0x4
392
- };
386
+ enum wxNumValidatorStyle;
387
+ %constant int NumValidatorStyle_wxNUM_VAL_DEFAULT = 0x0;
388
+ %constant int NumValidatorStyle_wxNUM_VAL_THOUSANDS_SEPARATOR = 0x1;
389
+ %constant int NumValidatorStyle_wxNUM_VAL_ZERO_AS_BLANK = 0x2;
390
+ %constant int NumValidatorStyle_wxNUM_VAL_NO_TRAILING_ZEROES = 0x4;
393
391
 
394
392
  %alias WXIntegerValidator::GetMin "min";
395
393
  %alias WXIntegerValidator::SetMin "min=";
@@ -15,6 +15,7 @@ module WXRuby3
15
15
  class OwnerDrawnComboBox < Window
16
16
 
17
17
  include Typemap::ClientData
18
+ include Typemap::ComboPopup
18
19
 
19
20
  def setup
20
21
  super
@@ -0,0 +1,410 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 wxWidgets interface director
7
+ ###
8
+
9
+ module WXRuby3
10
+
11
+ class Director
12
+
13
+ class PersistenceManager < Director
14
+
15
+ include Typemap::ConfigBase
16
+
17
+ def setup
18
+ super
19
+ spec.gc_as_marked
20
+ spec.use_class_implementation 'wxPersistenceManager', 'WxRubyPersistenceManager'
21
+ spec.ignore 'wxPersistenceManager::Register',
22
+ 'wxPersistenceManager::Find',
23
+ 'wxPersistenceManager::Unregister',
24
+ 'wxPersistenceManager::Save',
25
+ 'wxPersistenceManager::Restore',
26
+ 'wxPersistenceManager::SaveAndUnregister',
27
+ 'wxPersistenceManager::RegisterAndRestore',
28
+ ignore_doc: false
29
+ # doc gen only
30
+ spec.map 'void *obj' => 'Object', swig: false do
31
+ map_in code: ''
32
+ end
33
+ spec.map 'T *obj' => 'Object', swig: false do
34
+ map_in code: ''
35
+ end
36
+ spec.regard 'wxPersistenceManager::wxPersistenceManager',
37
+ 'wxPersistenceManager::GetConfig',
38
+ 'wxPersistenceManager::GetKey'
39
+ spec.suppress_warning 473, 'wxPersistenceManager::GetConfig'
40
+ spec.ignore %w[wxCreatePersistentObject wxPersistentRegisterAndRestore]
41
+ spec.add_header_code <<~__HEREDOC
42
+ #include "wxruby-Persistence.h"
43
+
44
+ // default global wxRuby persistence manager
45
+ static WxRubyPersistenceManager s_wxruby_persistence_manager {};
46
+
47
+ static WxRuby_ID to_f_id("to_f");
48
+ static WxRuby_ID to_i_id("to_i");
49
+ static WxRuby_ID to_s_id("to_s");
50
+ static WxRuby_ID save_value_id("save_value");
51
+ static WxRuby_ID restore_value_id("save_value");
52
+ static WxRuby_ID create_po_id("create_persistent_object");
53
+
54
+ #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
55
+ #define PO_LONG wxLongLong_t
56
+ #define PO_NUM2LONG(n) NUM2LL(n)
57
+ #define PO_LONG2NUM(l) LL2NUM(l)
58
+ #else
59
+ #define PO_LONG long
60
+ #define PO_NUM2LONG(n) NUM2LONG(n)
61
+ #define PO_LONG2NUM(l) LONG2NUM(l)
62
+ #endif
63
+
64
+ bool WxRubyPersistenceManager::SaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value)
65
+ {
66
+ Swig::Director* dir = dynamic_cast<Swig::Director*> (this);
67
+ // is this a user defined Ruby persistence manager with overridden #save_value?
68
+ if (dir && !wxRuby_IsNativeMethod(dir->swig_get_self(), save_value_id()))
69
+ {
70
+ VALUE rb_who = SWIG_NewPointerObj(SWIG_as_voidptr(&who), SWIGTYPE_p_wxPersistentObject, 0 );
71
+ return wxRuby_Funcall(dir->swig_get_self(), save_value_id(), 3, rb_who, WXSTR_TO_RSTR(name), value);
72
+ }
73
+ else
74
+ {
75
+ // just call C++ base implementation
76
+ return DoSaveRubyValue(who, name, value);
77
+ }
78
+ }
79
+
80
+ VALUE WxRubyPersistenceManager::RestoreRubyValue(const wxPersistentObject& who, const wxString& name)
81
+ {
82
+ Swig::Director* dir = dynamic_cast<Swig::Director*> (this);
83
+ // is this a user defined Ruby persistence manager with overridden #restore_value?
84
+ if (dir && !wxRuby_IsNativeMethod(dir->swig_get_self(), restore_value_id()))
85
+ {
86
+ VALUE rb_who = SWIG_NewPointerObj(SWIG_as_voidptr(&who), SWIGTYPE_p_wxPersistentObject, 0 );
87
+ return wxRuby_Funcall(dir->swig_get_self(), restore_value_id(), 3, rb_who, WXSTR_TO_RSTR(name));
88
+ }
89
+ else
90
+ {
91
+ // just call C++ base implementation
92
+ return DoRestoreRubyValue(who, name);
93
+ }
94
+ }
95
+
96
+ bool WxRubyPersistenceManager::DoSaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value)
97
+ {
98
+ wxConfigBase* cfg = this->GetConfig();
99
+ if (!cfg)
100
+ return false;
101
+ wxString key = this->GetKey(who, name);
102
+ switch(TYPE(value))
103
+ {
104
+ case T_TRUE:
105
+ case T_FALSE:
106
+ return cfg->Write(key, value == Qtrue);
107
+
108
+ case T_FIXNUM:
109
+ case T_BIGNUM:
110
+ return cfg->Write(key, PO_NUM2LONG(value));
111
+
112
+ case T_FLOAT:
113
+ return cfg->Write(key, NUM2DBL(value));
114
+
115
+ case T_STRING:
116
+ return cfg->Write(key, RSTR_TO_WXSTR(value));
117
+
118
+ default:
119
+ if (rb_respond_to(value, to_i_id()))
120
+ {
121
+ VALUE ival = rb_funcall(value, to_i_id(), 0);
122
+ return cfg->Write(key, PO_NUM2LONG(ival));
123
+ }
124
+ else if (rb_respond_to(value, to_f_id()))
125
+ {
126
+ VALUE fval = rb_funcall(value, to_f_id(), 0);
127
+ return cfg->Write(key, NUM2DBL(fval));
128
+ }
129
+ break;
130
+ }
131
+ VALUE sval = rb_funcall(value, to_s_id(), 0);
132
+ return cfg->Write(key, RSTR_TO_WXSTR(sval));
133
+ }
134
+
135
+ VALUE WxRubyPersistenceManager::DoRestoreRubyValue(const wxPersistentObject& who, const wxString& name)
136
+ {
137
+ wxConfigBase* cfg = this->GetConfig();
138
+ if (!cfg)
139
+ return Qnil;
140
+ wxString key = this->GetKey(who, name);
141
+ wxConfigBase::EntryType vtype = cfg->GetEntryType(key);
142
+ switch(vtype)
143
+ {
144
+ case wxConfigBase::Type_Boolean:
145
+ {
146
+ bool v;
147
+ if (cfg->Read(key, &v))
148
+ {
149
+ return v ? Qtrue : Qfalse;
150
+ }
151
+ break;
152
+ }
153
+ case wxConfigBase::Type_Integer:
154
+ {
155
+ PO_LONG v;
156
+ if (cfg->Read(key, &v))
157
+ {
158
+ return PO_LONG2NUM(v);
159
+ }
160
+ break;
161
+ }
162
+ case wxConfigBase::Type_Float:
163
+ {
164
+ double v;
165
+ if (cfg->Read(key, &v))
166
+ {
167
+ return DBL2NUM(v);
168
+ }
169
+ break;
170
+ }
171
+ case wxConfigBase::Type_String:
172
+ {
173
+ wxString v;
174
+ if (cfg->Read(key, &v))
175
+ {
176
+ return WXSTR_TO_RSTR(v);
177
+ }
178
+ break;
179
+ }
180
+ default:
181
+ break;
182
+ }
183
+ return Qnil;
184
+ }
185
+
186
+ void WxRubyPersistenceManager::UnregisterPersistentObject(VALUE rb_obj)
187
+ {
188
+ WxRubyPersistenceManager* wxrb_pm =
189
+ dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
190
+ if (wxrb_pm) wxrb_pm->UnregisterRbPO(rb_obj);
191
+ }
192
+
193
+ void WxRubyPersistenceManager::GC_markPO()
194
+ {
195
+ rb_object_to_rb_po_map_t::iterator it;
196
+ for( it = rb_object_po_map_.begin(); it != rb_object_po_map_.end(); ++it )
197
+ {
198
+ rb_gc_mark(it->first);
199
+ rb_gc_mark(it->second);
200
+ }
201
+ }
202
+
203
+ static void wxRuby_markPersistentObjects()
204
+ {
205
+ WxRubyPersistenceManager* wxrb_pm =
206
+ dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
207
+ if (wxrb_pm) wxrb_pm->GC_markPO();
208
+ }
209
+ __HEREDOC
210
+ spec.add_extend_code 'wxPersistenceManager', <<~__HEREDOC
211
+ VALUE Register(VALUE obj)
212
+ {
213
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
214
+ VALUE rb_po = rb_funcall(obj, create_po_id(), 0);
215
+ if (!NIL_P(rb_po) && wxrb_pm)
216
+ {
217
+ void* ptr;
218
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
219
+ if (!SWIG_IsOK(res))
220
+ {
221
+ rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
222
+ }
223
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
224
+ if ($self->Register(po->GetObject(), po))
225
+ {
226
+ wxrb_pm->RegisterRbPO(obj, rb_po);
227
+ return rb_po;
228
+ }
229
+ }
230
+ return Qnil;
231
+ }
232
+
233
+ VALUE Register(VALUE obj, VALUE rb_po)
234
+ {
235
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
236
+ if (!NIL_P(rb_po) && wxrb_pm)
237
+ {
238
+ void* ptr;
239
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
240
+ if (!SWIG_IsOK(res))
241
+ {
242
+ rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
243
+ }
244
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
245
+ if ($self->Register(po->GetObject(), po))
246
+ {
247
+ wxrb_pm->RegisterRbPO(obj, rb_po);
248
+ return rb_po;
249
+ }
250
+ }
251
+ return Qnil;
252
+ }
253
+
254
+ VALUE Find(VALUE obj)
255
+ {
256
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
257
+ VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
258
+ if (!NIL_P(rb_po) && wxrb_pm)
259
+ {
260
+ void* ptr;
261
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
262
+ if (!SWIG_IsOK(res))
263
+ {
264
+ rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
265
+ }
266
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
267
+ if ($self->Find(po->GetObject()))
268
+ return rb_po;
269
+ }
270
+ return Qnil;
271
+ }
272
+
273
+ void Unregister(VALUE obj)
274
+ {
275
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
276
+ VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
277
+ if (!NIL_P(rb_po) && wxrb_pm)
278
+ {
279
+ void* ptr;
280
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
281
+ if (!SWIG_IsOK(res))
282
+ {
283
+ rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
284
+ }
285
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
286
+ $self->Unregister(po->GetObject());
287
+ }
288
+ }
289
+
290
+ void Save(VALUE obj)
291
+ {
292
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
293
+ VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
294
+ if (!NIL_P(rb_po) && wxrb_pm)
295
+ {
296
+ void* ptr;
297
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
298
+ if (!SWIG_IsOK(res))
299
+ {
300
+ rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
301
+ }
302
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
303
+ $self->Save(po->GetObject());
304
+ }
305
+ }
306
+
307
+ bool Restore(VALUE obj)
308
+ {
309
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
310
+ VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
311
+ if (!NIL_P(rb_po) && wxrb_pm)
312
+ {
313
+ void* ptr;
314
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
315
+ if (!SWIG_IsOK(res))
316
+ {
317
+ rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
318
+ }
319
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
320
+ return $self->Restore(po->GetObject());
321
+ }
322
+ return false;
323
+ }
324
+
325
+ void SaveAndUnregister(VALUE obj)
326
+ {
327
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
328
+ VALUE rb_po = wxrb_pm ? wxrb_pm->FindRbPO(obj) : Qnil;
329
+ if (!NIL_P(rb_po) && wxrb_pm)
330
+ {
331
+ void* ptr;
332
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, 0);
333
+ if (!SWIG_IsOK(res))
334
+ {
335
+ rb_raise(rb_eRuntimeError, "Invalid Wx::PersistentObject for object");
336
+ }
337
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
338
+ $self->Save(po->GetObject());
339
+ $self->Unregister(po->GetObject());
340
+ }
341
+ }
342
+
343
+ bool RegisterAndRestore(VALUE obj)
344
+ {
345
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
346
+ VALUE rb_po = rb_funcall(obj, create_po_id(), 0);
347
+ if (!NIL_P(rb_po) && wxrb_pm)
348
+ {
349
+ void* ptr;
350
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
351
+ if (!SWIG_IsOK(res))
352
+ {
353
+ rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
354
+ }
355
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
356
+ if ($self->Register(po->GetObject(), po))
357
+ {
358
+ wxrb_pm->RegisterRbPO(obj, rb_po);
359
+ return $self->Restore(po->GetObject());
360
+ }
361
+ }
362
+ return false;
363
+ }
364
+
365
+ bool RegisterAndRestore(VALUE obj, VALUE rb_po)
366
+ {
367
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
368
+ if (!NIL_P(rb_po) && wxrb_pm)
369
+ {
370
+ void* ptr;
371
+ int res = SWIG_ConvertPtr(rb_po, &ptr, SWIGTYPE_p_wxPersistentObject, SWIG_POINTER_DISOWN);
372
+ if (!SWIG_IsOK(res))
373
+ {
374
+ rb_raise(rb_eRuntimeError, "Unable to create Wx::PersistentObject for object");
375
+ }
376
+ wxPersistentObject* po = reinterpret_cast< wxPersistentObject * >(ptr);
377
+ if ($self->Register(po->GetObject(), po))
378
+ {
379
+ wxrb_pm->RegisterRbPO(obj, rb_po);
380
+ return $self->Restore(po->GetObject());
381
+ }
382
+ }
383
+ return false;
384
+ }
385
+
386
+ bool SaveValue(const wxPersistentObject& who, const wxString& name, VALUE value)
387
+ {
388
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
389
+ return wxrb_pm ? wxrb_pm->DoSaveRubyValue(who, name, value) : false;
390
+ }
391
+
392
+ VALUE RestoreValue(const wxPersistentObject& who, const wxString& name)
393
+ {
394
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> ($self);
395
+ return wxrb_pm ? wxrb_pm->DoRestoreRubyValue(who, name) : Qnil;
396
+ }
397
+ __HEREDOC
398
+ spec.add_init_code <<~__HEREDOC
399
+ // install the default global wxRuby persistence manager
400
+ wxPersistenceManager::Set(s_wxruby_persistence_manager);
401
+ // and the persistent object marker
402
+ wxRuby_AppendMarker(wxRuby_markPersistentObjects);
403
+ __HEREDOC
404
+ end
405
+
406
+ end # class PersistenceManager
407
+
408
+ end # class Director
409
+
410
+ end # module WXRuby3
@@ -0,0 +1,70 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 wxWidgets interface director
7
+ ###
8
+
9
+ module WXRuby3
10
+
11
+ class Director
12
+
13
+ class PersistentObject < Director
14
+
15
+ def setup
16
+ super
17
+ spec.gc_as_marked
18
+ spec.add_header_code <<~__HEREDOC
19
+ #include "wxruby-Persistence.h"
20
+
21
+ WxRubyPersistentObject::WxRubyPersistentObject(VALUE rb_obj)
22
+ : wxPersistentObject((void*)rb_obj)
23
+ {}
24
+
25
+ WxRubyPersistentObject::~WxRubyPersistentObject()
26
+ {
27
+ if (this->GetObject())
28
+ WxRubyPersistenceManager::UnregisterPersistentObject(
29
+ reinterpret_cast<VALUE> (this->GetObject()));
30
+ }
31
+ __HEREDOC
32
+ spec.use_class_implementation 'wxPersistentObject', 'WxRubyPersistentObject'
33
+ spec.ignore %w[wxPersistentObject::GetObject wxPersistentObject::wxPersistentObject]
34
+ spec.ignore %w[wxCreatePersistentObject wxPersistentRegisterAndRestore]
35
+ spec.extend_interface 'wxPersistentObject',
36
+ 'wxPersistentObject(VALUE rb_obj)',
37
+ visibility: 'protected'
38
+ spec.add_extend_code 'wxPersistentObject', <<~__HEREDOC
39
+ bool SaveValue(const wxString& name, VALUE value)
40
+ {
41
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
42
+ return wxrb_pm ? wxrb_pm->SaveRubyValue(*$self, name, value) : false;
43
+ }
44
+ VALUE RestoreValue(const wxString& name)
45
+ {
46
+ WxRubyPersistenceManager* wxrb_pm = dynamic_cast<WxRubyPersistenceManager*> (&wxPersistenceManager::Get());
47
+ return wxrb_pm ? wxrb_pm->RestoreRubyValue(*$self, name) : Qnil;
48
+ }
49
+ __HEREDOC
50
+ spec.add_extend_code 'wxPersistentObject', <<~__HEREDOC
51
+ VALUE GetObject()
52
+ {
53
+ WxRubyPersistentObject* rpo = dynamic_cast<WxRubyPersistentObject*> ($self);
54
+ if (rpo)
55
+ {
56
+ return reinterpret_cast<VALUE> (rpo->GetObject());
57
+ }
58
+ else
59
+ {
60
+ return Qnil;
61
+ }
62
+ }
63
+ __HEREDOC
64
+ super
65
+ end
66
+ end # class PersistentObject
67
+
68
+ end # class Director
69
+
70
+ end # module WXRuby3
@@ -0,0 +1,73 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ ###
6
+ # wxRuby3 wxWidgets interface director
7
+ ###
8
+
9
+ module WXRuby3
10
+
11
+ class Director
12
+
13
+ class PersistentWindow < Director
14
+
15
+ def setup
16
+ spec.items << 'wxPersistentTLW' << 'wxPersistentBookCtrl' << 'wxPersistentTreeBookCtrl'
17
+ if Config.instance.wx_version > '3.2.4'
18
+ # only after 3.2.4 properly available
19
+ spec.items << 'wxPersistentComboBox'
20
+ end
21
+ super
22
+ spec.gc_as_marked
23
+ spec.use_template_as_class('wxPersistentWindow', 'wxPersistentWindowBase')
24
+ spec.override_inheritance_chain('wxPersistentWindow', %w[wxPersistentObject])
25
+ spec.ignore 'wxPersistentWindow::wxPersistentWindow',
26
+ 'wxPersistentWindow::Get',
27
+ ignore_doc: false
28
+ # make ctor protected because of pure virt methods
29
+ spec.extend_interface 'wxPersistentWindow',
30
+ 'wxPersistentWindowBase(wxWindow *win)',
31
+ visibility: 'protected'
32
+ spec.add_header_code 'typedef wxWindow WindowType;'
33
+ spec.add_swig_code 'typedef wxWindow WindowType;'
34
+ spec.map 'WindowType *' => 'Wx::Window', swig: false do
35
+ map_in code: ''
36
+ map_out code: ''
37
+ end
38
+ spec.add_extend_code 'wxPersistentWindowBase', <<~__HEREDOC
39
+ wxWindow * GetObject()
40
+ {
41
+ return reinterpret_cast<wxWindow*> ($self->GetObject());
42
+ }
43
+ __HEREDOC
44
+ # wxPersistentTLW
45
+ spec.override_inheritance_chain('wxPersistentTLW', [{ 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
46
+ # add method override missing from docs
47
+ spec.extend_interface 'wxPersistentTLW',
48
+ 'virtual wxString GetKind() const override'
49
+ # wxPersistentBookCtrl
50
+ spec.override_inheritance_chain('wxPersistentBookCtrl', [{ 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
51
+ # add method override missing from docs
52
+ spec.extend_interface 'wxPersistentBookCtrl',
53
+ 'virtual wxString GetKind() const override'
54
+ # wxPersistentTreeBookCtrl
55
+ spec.override_inheritance_chain('wxPersistentTreeBookCtrl', ['wxPersistentBookCtrl', { 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
56
+ # add method override missing from docs
57
+ spec.extend_interface 'wxPersistentTreeBookCtrl',
58
+ 'virtual wxString GetKind() const override'
59
+ spec.do_not_generate :functions, :defines, :typedefs, :variables, :enums
60
+ if Config.instance.wx_version >= '3.0.0'
61
+ # wxPersistentComboBox
62
+ spec.override_inheritance_chain('wxPersistentComboBox', [{ 'wxPersistentWindowBase' => 'wxPersistentWindow' }, 'wxPersistentObject'])
63
+ # add method override missing from docs
64
+ spec.extend_interface 'wxPersistentComboBox',
65
+ 'virtual wxString GetKind() const override'
66
+ end
67
+ end
68
+
69
+ end
70
+
71
+ end
72
+
73
+ end
@@ -17,7 +17,7 @@ module WXRuby3
17
17
  spec.items.concat %w[wxPGCheckBoxEditor wxPGChoiceEditor wxPGChoiceAndButtonEditor wxPGComboBoxEditor
18
18
  wxPGTextCtrlEditor wxPGSpinCtrlEditor wxPGTextCtrlAndButtonEditor wxPGEditorDialogAdapter]
19
19
  spec.includes << 'wx/propgrid/propgriddefs.h'
20
- if Config.instance.wx_version >= '3.3.0'
20
+ if Config.instance.wx_version > '3.2.4'
21
21
  # make sure SWIG knows this as enum type
22
22
  spec.add_swig_code 'enum wxPGPropertyFlags;'
23
23
  end
@@ -65,7 +65,7 @@ module WXRuby3
65
65
  'wxUIntProperty::m_prefix',
66
66
  'wxDateProperty::m_format',
67
67
  'wxDateProperty::m_dpStyle'
68
- if Config.instance.wx_version >= '3.3.0'
68
+ if Config.instance.wx_version > '3.2.4'
69
69
  # currently missing from interface docs
70
70
  spec.extend_interface 'wxEnumProperty',
71
71
  'bool ValueFromString_(wxVariant& value, int* pIndex, const wxString& text,int argFlags) const',
@@ -111,7 +111,7 @@ module WXRuby3
111
111
  end
112
112
  # make sure the derived Enum property classes provide the protected accessors too
113
113
  %w[wxCursorProperty wxEditEnumProperty wxSystemColourProperty wxColourProperty].each do |kls|
114
- if Config.instance.wx_version >= '3.3.0'
114
+ if Config.instance.wx_version > '3.2.4'
115
115
  # currently missing from interface docs
116
116
  spec.extend_interface kls,
117
117
  'int GetIndex() const',
@@ -136,7 +136,7 @@ module WXRuby3
136
136
  'wxLongStringProperty::DisplayEditorDialog',
137
137
  'wxMultiChoiceProperty::DisplayEditorDialog',
138
138
  'wxFontProperty::DisplayEditorDialog'
139
- if Config.instance.wx_version >= '3.3.0'
139
+ if Config.instance.wx_version > '3.2.4'
140
140
  # for wxEnumProperty and derivatives ValueFromString_/ValueFromInt_
141
141
  spec.map_apply 'int * OUTPUT' => 'int* pIndex'
142
142
  end
@@ -113,7 +113,11 @@ module WXRuby3
113
113
  # do not think this useful for wxRuby (Also; caused GC problems)
114
114
  spec.ignore 'wxPGProperty::GetCellRenderer'
115
115
  # obsolete
116
- spec.ignore %w[wxPGProperty::AddChild wxPGProperty::GetValueString]
116
+ if Config.instance.wx_version < '3.3.0'
117
+ spec.ignore %w[wxPGProperty::AddChild wxPGProperty::GetValueString]
118
+ else
119
+ spec.ignore 'wxPGProperty::AddChild'
120
+ end
117
121
  # not of use in Ruby
118
122
  spec.ignore(%w[wxPGProperty::GetClientData wxPGProperty::SetClientData])
119
123
  # only keep the const version
@@ -15,6 +15,7 @@ module WXRuby3
15
15
  class RichTextStyleListBox < Window
16
16
 
17
17
  include Typemap::RichText
18
+ include Typemap::ComboPopup
18
19
 
19
20
  def setup
20
21
  super
@@ -28,6 +29,10 @@ module WXRuby3
28
29
  wxWindow
29
30
  wxEvtHandler
30
31
  wxObject])
32
+ # missing from docs; required so proxy calls correct override
33
+ spec.extend_interface 'wxRichTextStyleComboCtrl',
34
+ 'virtual void DoSetPopupControl(wxComboPopup* popup)',
35
+ visibility: 'protected'
31
36
  end
32
37
 
33
38
  end
@@ -20,7 +20,7 @@ module WXRuby3
20
20
  when 'wxSizer'
21
21
  spec.items << 'wxSizerFlags'
22
22
  spec.gc_as_untracked('wxSizerFlags')
23
- if Config.instance.wx_version < '3.3.0'
23
+ unless Config.instance.wx_version > '3.2.4'
24
24
  # missing from docs
25
25
  spec.extend_interface 'wxSizerFlags',
26
26
  'wxSizerFlags& HorzBorder()'