wxruby3 0.9.3 → 0.9.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxruby3/include/wxruby-Config.h +23 -5
  3. data/ext/wxruby3/include/wxruby-Persistence.h +79 -0
  4. data/ext/wxruby3/swig/memory_management.i +6 -0
  5. data/lib/wx/core/book_ctrl_base.rb +16 -0
  6. data/lib/wx/core/config.rb +454 -83
  7. data/lib/wx/core/notebook.rb +10 -8
  8. data/lib/wx/core/peristent_object.rb +15 -0
  9. data/lib/wx/core/persistence_manager.rb +39 -0
  10. data/lib/wx/core/persistent_window.rb +16 -0
  11. data/lib/wx/core/top_level_window.rb +16 -0
  12. data/lib/wx/core/treebook.rb +18 -0
  13. data/lib/wx/core.rb +4 -0
  14. data/lib/wx/doc/book_ctrl_base.rb +19 -0
  15. data/lib/wx/doc/config.rb +101 -41
  16. data/lib/wx/doc/extra/14_config.md +101 -0
  17. data/lib/wx/doc/extra/15_persistence.md +148 -0
  18. data/lib/wx/doc/persistence_manager.rb +36 -0
  19. data/lib/wx/doc/persistent_object.rb +27 -0
  20. data/lib/wx/doc/top_level_window.rb +19 -0
  21. data/lib/wx/doc/treebook.rb +6 -1
  22. data/lib/wx/version.rb +1 -1
  23. data/rakelib/build.rb +1 -1
  24. data/rakelib/lib/core/package.rb +22 -1
  25. data/rakelib/lib/core/spec.rb +10 -0
  26. data/rakelib/lib/core/spec_helper.rb +1 -1
  27. data/rakelib/lib/director/config_base.rb +490 -19
  28. data/rakelib/lib/director/event_filter.rb +1 -1
  29. data/rakelib/lib/director/event_loop.rb +1 -1
  30. data/rakelib/lib/director/file_dialog_customize_hook.rb +2 -2
  31. data/rakelib/lib/director/grid_cell_attr.rb +1 -1
  32. data/rakelib/lib/director/grid_cell_editor.rb +1 -1
  33. data/rakelib/lib/director/grid_cell_renderer.rb +1 -1
  34. data/rakelib/lib/director/header_ctrl.rb +3 -0
  35. data/rakelib/lib/director/html_listbox.rb +2 -1
  36. data/rakelib/lib/director/persistence_manager.rb +410 -0
  37. data/rakelib/lib/director/persistent_object.rb +70 -0
  38. data/rakelib/lib/director/persistent_window.rb +73 -0
  39. data/rakelib/lib/director/static_bitmap.rb +4 -0
  40. data/rakelib/lib/director/text_entry.rb +1 -1
  41. data/rakelib/lib/generate/analyzer.rb +43 -43
  42. data/rakelib/lib/generate/doc.rb +1 -1
  43. data/rakelib/lib/specs/interfaces.rb +3 -0
  44. data/rakelib/lib/typemap/config.rb +8 -0
  45. data/samples/widgets/widgets.rb +5 -9
  46. data/tests/test_config.rb +207 -42
  47. data/tests/test_persistence.rb +142 -0
  48. metadata +19 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: ef007e75aefb2b02a91a0818c8ef2d5191075e280c4dbd01bda827cdd65f9957
4
- data.tar.gz: d52b47712bd0d0d9705270e8c1487e2a1d797bcc52a46253b866e0fe4c6a1617
3
+ metadata.gz: 59f48a6760484b863b4f3255bf866ecbd18faa5c0488fd40c6379bda58747299
4
+ data.tar.gz: f131b88dab9c1994d98ae2fede1021308a539d298b6743c67a62ffc679748f0e
5
5
  SHA512:
6
- metadata.gz: ba7a127d408a2ab7ce745b0ad1d6d88eee710953ecceaa42a7880c6fb258a4b684cbc9f8bf11d36b1473bb99a55fd219a8fd434475f7352c238b1c2d03bdce9e
7
- data.tar.gz: 2d99560d20e4d04a1b5c6abacba8579e0973bca2251fb402caa1a301e8a99317eed6a864892a47b8740a87a3861aeb6692791e97fc61c0a57e20d8b41727e930
6
+ metadata.gz: 9f5a04f23e4978c856f79a8d2393d2cb08e2c4ce971fb915123cefb5ea2ee92a6fca38b3c7ccbc456c1e07480158dae5191635a9861cdcb5d7919be5f3c9e169
7
+ data.tar.gz: ee935202f9fb3ef7af42da60b4311725c584485548f35c55b6f12ae4fa2b410740fc117b718134052a7aeb915ba7d2140cd096bc3f20a2ab1a1b5e30e82234b5
@@ -53,6 +53,7 @@ static int wxrb_CountConfig(VALUE key, VALUE value, VALUE rbCounter)
53
53
  }
54
54
 
55
55
  static VALUE g_cConfigBase;
56
+ static VALUE g_cConfigWx;
56
57
  static VALUE g_cConfig;
57
58
 
58
59
  /*
@@ -88,12 +89,18 @@ public:
88
89
 
89
90
  virtual ~wxRbHashConfig()
90
91
  {
91
- DATA_PTR(m_cfgInstance) = 0; // make sure it never get's deleted twice
92
+ if (!NIL_P(m_cfgInstance))
93
+ {
94
+ DATA_PTR(m_cfgInstance) = 0; // make sure it never get's deleted twice
95
+ }
92
96
  }
93
97
 
94
- // Get wrapped Ruby ConfigBase instance
98
+ // Get wrapped Ruby Config instance
95
99
  VALUE GetRubyConfig() const { return m_cfgInstance; }
96
100
 
101
+ // Reset wrapped Ruby Config instance
102
+ void ResetRubyConfig() { m_cfgInstance = Qnil; }
103
+
97
104
  // implement inherited pure virtual functions
98
105
  virtual void SetPath(const wxString& strPath) override { DoSetPath(strPath, true /* create missing components */); }
99
106
  virtual const wxString& GetPath() const override { return m_strPath; }
@@ -806,7 +813,7 @@ private:
806
813
 
807
814
  void SetRootPath()
808
815
  {
809
- m_strPath.Empty();
816
+ m_strPath.Clear();
810
817
  m_cfgGroup = m_cfgHash;
811
818
  m_cfgGroupKeys = Qnil;
812
819
  }
@@ -815,7 +822,7 @@ private:
815
822
  // if path doesn't exist and createMissingComponents == false
816
823
  bool DoSetPath(const wxString& strPath, bool createMissingComponents)
817
824
  {
818
- if ( strPath.empty() )
825
+ if ( strPath.IsEmpty() || strPath == cfgSepStr)
819
826
  {
820
827
  SetRootPath();
821
828
  return true;
@@ -913,7 +920,8 @@ static const char * __iv_Config_data = "@data";
913
920
 
914
921
  WXRUBY_EXPORT bool wxRuby_IsRubyConfig(VALUE rbConfig)
915
922
  {
916
- return rb_obj_is_kind_of(rbConfig, g_cConfig) == Qtrue;
923
+ return rb_obj_is_kind_of(rbConfig, g_cConfig) == Qtrue ||
924
+ rb_obj_is_kind_of(rbConfig, g_cConfigWx) == Qtrue;
917
925
  }
918
926
 
919
927
  // Wrap a Ruby hash for input type mapping
@@ -933,6 +941,12 @@ WXRUBY_EXPORT wxConfigBase* wxRuby_Ruby2ConfigBase(VALUE rbConfig)
933
941
  // return wrapper
934
942
  return config;
935
943
  }
944
+ else if (rb_obj_is_kind_of(rbConfig, g_cConfigWx) == Qtrue)
945
+ {
946
+ wxConfigBase* cfg;
947
+ Data_Get_Struct(rbConfig, wxConfigBase, cfg);
948
+ return cfg;
949
+ }
936
950
  return nullptr;
937
951
  }
938
952
 
@@ -946,6 +960,10 @@ WXRUBY_EXPORT VALUE wxRuby_ConfigBase2Ruby(wxConfigBase* config)
946
960
  {
947
961
  return hsh_config->GetRubyConfig();
948
962
  }
963
+ else
964
+ {
965
+ return Data_Wrap_Struct(g_cConfigWx, 0, 0, config);
966
+ }
949
967
  }
950
968
  return Qnil;
951
969
  }
@@ -0,0 +1,79 @@
1
+ // Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ //
3
+ // This software is released under the MIT license.
4
+
5
+ /*
6
+ * WxRuby3 persistence classes
7
+ */
8
+
9
+ #ifndef _WXRUBY_PERSISTENCE_HASH_H
10
+ #define _WXRUBY_PERSISTENCE_HASH_H
11
+
12
+ #include <wx/persist.h>
13
+ #include <wx/config.h>
14
+
15
+ #include <map>
16
+
17
+ /*
18
+ This class serves as a base for any Ruby defined persistence manager in order to provide
19
+ customized save and restore methods for Ruby values but also as a replacement for the
20
+ default global persistence manager instance.
21
+ */
22
+ class WxRubyPersistenceManager : public wxPersistenceManager
23
+ {
24
+ private:
25
+ typedef std::map<VALUE, VALUE> rb_object_to_rb_po_map_t;
26
+ rb_object_to_rb_po_map_t rb_object_po_map_;
27
+
28
+ public:
29
+ WxRubyPersistenceManager() : wxPersistenceManager() {}
30
+
31
+ bool SaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value);
32
+
33
+ VALUE RestoreRubyValue(const wxPersistentObject& who, const wxString& name);
34
+
35
+
36
+ bool DoSaveRubyValue(const wxPersistentObject& who, const wxString& name, VALUE value);
37
+
38
+ VALUE DoRestoreRubyValue(const wxPersistentObject& who, const wxString& name);
39
+
40
+ void RegisterRbPO(VALUE rb_obj, VALUE rb_po)
41
+ {
42
+ rb_object_po_map_[rb_obj] = rb_po;
43
+ }
44
+
45
+ VALUE FindRbPO(VALUE rb_obj)
46
+ {
47
+ VALUE rb_po = Qnil;
48
+ if (rb_object_po_map_.count(rb_obj) > 0)
49
+ {
50
+ rb_po = rb_object_po_map_[rb_obj];
51
+ }
52
+ return rb_po;
53
+ }
54
+
55
+ VALUE UnregisterRbPO(VALUE rb_obj)
56
+ {
57
+ VALUE rb_po = Qnil;
58
+ if (rb_object_po_map_.count(rb_obj) > 0)
59
+ {
60
+ rb_po = rb_object_po_map_[rb_obj];
61
+ rb_object_po_map_.erase(rb_obj);
62
+ }
63
+ return rb_po;
64
+ }
65
+
66
+ void GC_markPO();
67
+
68
+ static void UnregisterPersistentObject(VALUE rb_obj);
69
+ };
70
+
71
+ class WxRubyPersistentObject : public wxPersistentObject
72
+ {
73
+ public:
74
+ virtual ~WxRubyPersistentObject();
75
+ protected:
76
+ WxRubyPersistentObject(VALUE rb_obj);
77
+ };
78
+
79
+ #endif /* _WXRUBY_PERSISTENCE_HASH_H */
@@ -106,6 +106,12 @@ GC_NEVER(kls);
106
106
  %define GC_MANAGE_AS_UNTRACKED(kls)
107
107
  %enddef
108
108
 
109
+ // Strategy for objects that are GC marked through customized, tailored, mechanisms outside
110
+ // of the standard SWIG object tracking option.
111
+ // The different naming is mostly to allow doc gen to properly recognize these objects.
112
+ %define GC_MANAGE_AS_MARKED(kls)
113
+ %enddef
114
+
109
115
  // Sizers attached to windows are automatically destroyed by wxWidgets,
110
116
  // so they should not be deleted.
111
117
  //
@@ -0,0 +1,16 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ module Wx
6
+
7
+ class BookCtrlBase
8
+
9
+ # create PersistentObject for toplevel windows (incl. Dialog and Frame)
10
+ def create_persistent_object
11
+ PersistentBookCtrl.new(self)
12
+ end
13
+
14
+ end
15
+
16
+ end