wxruby3 0.9.3 → 0.9.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/INSTALL.md +1 -1
- data/README.md +2 -2
- data/ext/wxruby3/include/wxruby-ComboPopup.h +777 -0
- 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/combo_ctrl.rb +171 -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/comboctrl.rb +128 -3
- 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/owner_drawn_combobox.rb +5 -1
- 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/include/funcall.inc +2 -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/comboctrl.rb +104 -3
- data/rakelib/lib/director/config_base.rb +490 -19
- data/rakelib/lib/director/defs.rb +1 -3
- 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/gdicommon.rb +6 -0
- 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/menu_item.rb +1 -1
- data/rakelib/lib/director/num_validator.rb +5 -7
- data/rakelib/lib/director/owner_drawn_combobox.rb +1 -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/pgeditor.rb +1 -1
- data/rakelib/lib/director/pgproperties.rb +3 -3
- data/rakelib/lib/director/pgproperty.rb +5 -1
- data/rakelib/lib/director/richtext_style_listbox.rb +5 -0
- data/rakelib/lib/director/sizer.rb +1 -1
- data/rakelib/lib/director/static_bitmap.rb +4 -0
- data/rakelib/lib/director/text_entry.rb +1 -1
- data/rakelib/lib/director/window.rb +4 -0
- data/rakelib/lib/extractor/module.rb +15 -0
- data/rakelib/lib/generate/analyzer.rb +43 -43
- data/rakelib/lib/generate/doc/combo_ctrl.yaml +135 -0
- data/rakelib/lib/generate/doc/file_dialog_customize_hook.yaml +62 -0
- data/rakelib/lib/generate/doc/file_system.yaml +28 -0
- data/rakelib/lib/generate/doc.rb +1 -1
- data/rakelib/lib/generate/interface.rb +12 -4
- data/rakelib/lib/specs/interfaces.rb +3 -0
- data/rakelib/lib/swig_runner.rb +7 -4
- data/rakelib/lib/typemap/combo_popup.rb +42 -0
- data/rakelib/lib/typemap/config.rb +8 -0
- data/samples/widgets/widgets.rb +5 -9
- data/tests/test_combo_ctrl.rb +196 -0
- data/tests/test_config.rb +207 -42
- data/tests/test_persistence.rb +142 -0
- metadata +26 -2
@@ -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
|
-
|
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
|
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.
|
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.
|
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
|
@@ -0,0 +1,171 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
|
5
|
+
|
6
|
+
module Wx
|
7
|
+
|
8
|
+
module ComboPopup
|
9
|
+
|
10
|
+
def self.included(mod)
|
11
|
+
unless mod == Wx::ComboPopupWx
|
12
|
+
mod.class_eval { include Wx::ComboPopup::Methods }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
module Methods
|
17
|
+
# Returns pointer to the associated parent {Wx::ComboCtrl}.
|
18
|
+
# @return [Wx::ComboCtrl]
|
19
|
+
# def get_combo_ctrl; end
|
20
|
+
|
21
|
+
# The including class must implement this to initialize its internal variables.
|
22
|
+
#
|
23
|
+
# This method is called immediately after construction finishes. m_combo member variable has been initialized before the call.
|
24
|
+
# @return [void]
|
25
|
+
def init
|
26
|
+
end
|
27
|
+
|
28
|
+
# The including class may implement this to return true if it wants to delay call to {Wx::ComboPopup#create} until the popup is shown for the first time.
|
29
|
+
#
|
30
|
+
# It is more efficient, but on the other hand it is often more convenient to have the control created immediately.
|
31
|
+
#
|
32
|
+
# <div class="wxrb-remark">
|
33
|
+
# <b>Remark:</b>
|
34
|
+
# <p>Base implementation returns false.
|
35
|
+
# </p>
|
36
|
+
# </div>
|
37
|
+
# @return [Boolean]
|
38
|
+
def lazy_create
|
39
|
+
false
|
40
|
+
end
|
41
|
+
|
42
|
+
# The including class must implement this to create the popup control.
|
43
|
+
#
|
44
|
+
# true if the call succeeded, false otherwise.
|
45
|
+
# @param parent [Wx::Window]
|
46
|
+
# @return [Boolean]
|
47
|
+
def create(parent)
|
48
|
+
false
|
49
|
+
end
|
50
|
+
|
51
|
+
# You only need to implement this member function if you create your popup class in non-standard way.
|
52
|
+
#
|
53
|
+
# The default implementation can handle both multiple-inherited popup control (as seen in {Wx::ComboCtrl} samples) and one allocated separately in heap.
|
54
|
+
# If you do completely re-implement this function, make sure it calls Destroy() for the popup control and also deletes this object (usually as the last thing).
|
55
|
+
# @return [void]
|
56
|
+
def destroy_popup
|
57
|
+
end
|
58
|
+
|
59
|
+
# Implement to customize matching of value string to an item container entry.
|
60
|
+
#
|
61
|
+
# <div class="wxrb-remark">
|
62
|
+
# <b>Remark:</b>
|
63
|
+
# <p>Default implementation always return true and does not alter trueItem.
|
64
|
+
# </p>
|
65
|
+
# </div>
|
66
|
+
# @param item [String] String entered, usually by user or from SetValue() call.
|
67
|
+
# @param trueItem [Boolean] if true the true item string should be returned in case matching but different
|
68
|
+
# @return [Boolean, String] Returns true if a match is found or false if not. If trueItem == true and item matches an entry, but the entry's string representation is not exactly the same (case mismatch, for example), then the true item string should be returned as the match result.
|
69
|
+
def find_item(item, trueItem=false)
|
70
|
+
true
|
71
|
+
end
|
72
|
+
|
73
|
+
# The including class may implement this to return adjusted size for the popup control, according to the variables given.
|
74
|
+
#
|
75
|
+
# <div class="wxrb-remark">
|
76
|
+
# <b>Remark:</b>
|
77
|
+
# <p>This function is called each time popup is about to be shown.
|
78
|
+
# </p>
|
79
|
+
# </div>
|
80
|
+
# @param minWidth [Integer] Preferred minimum width.
|
81
|
+
# @param prefHeight [Integer] Preferred height. May be -1 to indicate no preference.
|
82
|
+
# @param maxHeight [Integer] Max height for window, as limited by screen size.
|
83
|
+
# @return [Wx::Size]
|
84
|
+
def get_adjusted_size(minWidth, prefHeight, maxHeight)
|
85
|
+
Wx::Size.new(minWidth, prefHeight)
|
86
|
+
end
|
87
|
+
|
88
|
+
# The including class must implement this to return pointer to the associated control created in {Wx::ComboPopup#create}.
|
89
|
+
# @return [Wx::Window]
|
90
|
+
def get_control
|
91
|
+
end
|
92
|
+
|
93
|
+
# The including class must implement this to receive string value changes from {Wx::ComboCtrl}.
|
94
|
+
# @param value [String]
|
95
|
+
# @return [void]
|
96
|
+
def set_string_value(value)
|
97
|
+
end
|
98
|
+
|
99
|
+
# The including class must implement this to return string representation of the value.
|
100
|
+
# @return [String]
|
101
|
+
def get_string_value
|
102
|
+
nil
|
103
|
+
end
|
104
|
+
|
105
|
+
# The including class may implement this to do something when the parent {Wx::ComboCtrl} gets double-clicked.
|
106
|
+
# @return [void]
|
107
|
+
def on_combo_double_click
|
108
|
+
end
|
109
|
+
|
110
|
+
# The including class may implement this to receive key down events from the parent {Wx::ComboCtrl}.
|
111
|
+
#
|
112
|
+
# Events not handled should be skipped, as usual.
|
113
|
+
# @param event [Wx::KeyEvent]
|
114
|
+
# @return [void]
|
115
|
+
def on_combo_key_event(event)
|
116
|
+
event.skip
|
117
|
+
end
|
118
|
+
|
119
|
+
# The including class may implement this to receive char events from the parent {Wx::ComboCtrl}.
|
120
|
+
#
|
121
|
+
# Events not handled should be skipped, as usual.
|
122
|
+
# @param event [Wx::KeyEvent]
|
123
|
+
# @return [void]
|
124
|
+
def on_combo_char_event(event)
|
125
|
+
event.skip
|
126
|
+
end
|
127
|
+
|
128
|
+
# The including class may implement this to do special processing when popup is hidden.
|
129
|
+
# @return [void]
|
130
|
+
def on_dismiss
|
131
|
+
end
|
132
|
+
|
133
|
+
# The including class may implement this to do special processing when popup is shown.
|
134
|
+
# @return [void]
|
135
|
+
def on_popup
|
136
|
+
end
|
137
|
+
|
138
|
+
# The including class may implement this to paint the parent {Wx::ComboCtrl}.
|
139
|
+
# This is called to custom paint in the combo control itself (ie. not the popup).
|
140
|
+
#
|
141
|
+
# Default implementation draws value as string.
|
142
|
+
# @param dc [Wx::DC]
|
143
|
+
# @param rect [Wx::Rect]
|
144
|
+
# @return [void]
|
145
|
+
def paint_combo_control(dc, rect)
|
146
|
+
combo = get_combo_ctrl
|
147
|
+
if combo.get_window_style.allbits?(Wx::CB_READONLY) # ie. no textctrl
|
148
|
+
combo.prepare_background(dc, rect,0)
|
149
|
+
|
150
|
+
dc.draw_text(combo.get_value,
|
151
|
+
rect.x + combo.get_margin_left,
|
152
|
+
(rect.height-dc.get_char_height)/2 + rect.y)
|
153
|
+
end
|
154
|
+
end
|
155
|
+
|
156
|
+
end
|
157
|
+
|
158
|
+
end
|
159
|
+
|
160
|
+
class ComboPopupWx
|
161
|
+
|
162
|
+
include ComboPopup
|
163
|
+
|
164
|
+
# this method has not been wrapped as a default popup control will always already have been
|
165
|
+
# initialized before returned from #get_combo_control
|
166
|
+
# just do nothing here (or should we raise an exception?)
|
167
|
+
def init; end
|
168
|
+
|
169
|
+
end
|
170
|
+
|
171
|
+
end
|