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
@@ -0,0 +1,148 @@
|
|
1
|
+
<!--
|
2
|
+
# @markup markdown
|
3
|
+
# @title 15. Persistence support
|
4
|
+
-->
|
5
|
+
|
6
|
+
# 15. Persistence support
|
7
|
+
|
8
|
+
## Introduction
|
9
|
+
|
10
|
+
wxRuby3 fully supports the wxWidgets persistence framework.
|
11
|
+
|
12
|
+
This framework provides the means to persist window (and other object) states which can than be restored when
|
13
|
+
re-creating these objects.
|
14
|
+
|
15
|
+
The persistence framework depends on the configuration framework (see [here](14_config.md)).
|
16
|
+
|
17
|
+
The persistence framework includes the following components:
|
18
|
+
|
19
|
+
* {Wx::PersistenceManager} which all persistent objects register themselves with. This class handles actual saving
|
20
|
+
and restoring of persistent data.
|
21
|
+
* Persistent object adapters for persistent objects. These adapters provide a bridge between the associated class –
|
22
|
+
which has no special persistence support – and {Wx::PersistenceManager}. All Persistent object adapters need to derive
|
23
|
+
from {Wx::PersistentObject} (like {Wx::PersistentWindowBase} and it's derivatives).
|
24
|
+
* The {Wx.create_persistent_object} and {Wx.persistent_register_and_restore} methods (mainly convenience methods for
|
25
|
+
wxWidgets compatibility).
|
26
|
+
|
27
|
+
## Persistence manager
|
28
|
+
|
29
|
+
By default a global singleton manager instance is available through {Wx::PersistenceManager.get} which will be used
|
30
|
+
by all available persistent object adapters for saving/restoring state values.
|
31
|
+
|
32
|
+
An alternate (possibly customized) manager instance can be installed through {Wx::PersistenceManager.set}.
|
33
|
+
|
34
|
+
## Persistent object adapters
|
35
|
+
|
36
|
+
All persistent object adapters must be derived from {Wx::PersistentObject}. This class provides common methods for
|
37
|
+
saving and restoring state values connecting to the persistence manager for actual writing and reading.
|
38
|
+
|
39
|
+
All windows/objects to be persisted need to be registered with the persistence manager. Creating the correct persistent
|
40
|
+
object adapter instance for an object to persist is abstracted away in wxWidgets by using template methods allowing
|
41
|
+
to simply only provide the object to persist instead of having to explicitly instantiate an adapter instance and provide
|
42
|
+
both to the persistence manager (which is however still possible).
|
43
|
+
|
44
|
+
wxRuby3 replaces this convenience interface (incompatible with Ruby) by a Ruby-fied approach which relies on Rubies
|
45
|
+
trusted *duck typing*.<br>
|
46
|
+
In wxRuby3 any class supported by a specific persistent object adapter class should implement the method
|
47
|
+
`#create_persistent_object` which should return a unique adapter instance for the object instance to be persisted
|
48
|
+
like this:
|
49
|
+
|
50
|
+
```ruby
|
51
|
+
class MyPersistentObject < Wx::PersistentObject
|
52
|
+
|
53
|
+
# Save the object properties.
|
54
|
+
# The implementation of this method should use {Wx::PersistentObject#save_value}.
|
55
|
+
# @return [void]
|
56
|
+
def save
|
57
|
+
# ...
|
58
|
+
end
|
59
|
+
|
60
|
+
# Restore the object properties.
|
61
|
+
# The implementation of this method should use {Wx::PersistentObject#restore_value}.
|
62
|
+
# @return [Boolean]
|
63
|
+
def restore
|
64
|
+
# ...
|
65
|
+
end
|
66
|
+
|
67
|
+
# Returns the string uniquely identifying the objects supported by this adapter.
|
68
|
+
# This method has default implementations in any of the built-in derived adapter classes.
|
69
|
+
# @return [String]
|
70
|
+
def get_kind
|
71
|
+
'MyObject'
|
72
|
+
end
|
73
|
+
|
74
|
+
# Returns the string uniquely identifying the object we're associated with among all the other objects of the same type.
|
75
|
+
# This method has a default implementation in Wx::PersistentWindowBase returning the window name.
|
76
|
+
# @return [String]
|
77
|
+
def get_name
|
78
|
+
'object_1'
|
79
|
+
end
|
80
|
+
|
81
|
+
end
|
82
|
+
|
83
|
+
class MyObject
|
84
|
+
|
85
|
+
# ...
|
86
|
+
|
87
|
+
def create_persistent_object
|
88
|
+
MyPersistentObject.new(self)
|
89
|
+
end
|
90
|
+
|
91
|
+
# ...
|
92
|
+
|
93
|
+
end
|
94
|
+
```
|
95
|
+
|
96
|
+
## Persistent windows
|
97
|
+
|
98
|
+
A number of classes provide built-in support for persistence of a number of windows or controls:
|
99
|
+
|
100
|
+
* {Wx::PersistentTLW} supports top level windows (including {Wx::Frame} and {Wx::Dialog}).
|
101
|
+
* {Wx::PersistentBookCtrl} supports the book controls {Wx::Notebook}, {Wx::Listbook}, {Wx::Toolbook} and {Wx::Choicebook}.
|
102
|
+
* {Wx::PersistentTreeBookCtrl} supports {Wx::Treebook}
|
103
|
+
|
104
|
+
All persistent window adapters are derived from {Wx::PersistentWindowBase}. This class makes sure that any window
|
105
|
+
registered for persisting gets automatically saved when the window is destroyed. Intermittently explicit saving still
|
106
|
+
remains possible of course.
|
107
|
+
|
108
|
+
User defined persistent window adapters can be derived from this class or any of the built-in derivatives to support
|
109
|
+
otherwise unsupported or custom windows/controls like this:
|
110
|
+
|
111
|
+
```ruby
|
112
|
+
class PersistentButton < Wx::PersistentWindowBase
|
113
|
+
|
114
|
+
def get_kind
|
115
|
+
'Button'
|
116
|
+
end
|
117
|
+
|
118
|
+
def save
|
119
|
+
save_value('w', get.size.width)
|
120
|
+
save_value('h', get.size.height)
|
121
|
+
save_value('label', get.label)
|
122
|
+
save_value('my_custom_value', get.my_custom_value)
|
123
|
+
end
|
124
|
+
|
125
|
+
def restore
|
126
|
+
get.size = [Integer(restore_value('w')), Integer(restore_value('h'))]
|
127
|
+
get.label = restore_value('label')
|
128
|
+
get.my_custom_value = Float(restore_value('my_custom_value'))
|
129
|
+
true
|
130
|
+
end
|
131
|
+
|
132
|
+
end
|
133
|
+
|
134
|
+
class MyButton < Wx::Button
|
135
|
+
|
136
|
+
def initialize(parent=nil, name)
|
137
|
+
super(parent, label: '', name: name)
|
138
|
+
@my_custom_value = ''
|
139
|
+
end
|
140
|
+
|
141
|
+
attr_accessor :my_custom_value
|
142
|
+
|
143
|
+
def create_persistent_object
|
144
|
+
PersistentButton.new(self)
|
145
|
+
end
|
146
|
+
|
147
|
+
end
|
148
|
+
```
|
@@ -7,7 +7,11 @@
|
|
7
7
|
|
8
8
|
module Wx
|
9
9
|
|
10
|
-
class OwnerDrawnComboBox
|
10
|
+
class OwnerDrawnComboBox < ComboCtrl
|
11
|
+
|
12
|
+
alias :get_item_data :get_client_object
|
13
|
+
|
14
|
+
alias :set_item_data :set_client_object
|
11
15
|
|
12
16
|
# Returns the label of the selected item or an empty string if no item is selected.
|
13
17
|
#
|
@@ -0,0 +1,36 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
3
|
+
#
|
4
|
+
# This software is released under the MIT license.
|
5
|
+
# :startdoc:
|
6
|
+
|
7
|
+
|
8
|
+
module Wx
|
9
|
+
|
10
|
+
# Function used to create the correct persistent adapter for the given object.
|
11
|
+
#
|
12
|
+
# This is a compatibility function that simply redirects the call to the object itself. Any object class
|
13
|
+
# supporting persistence should implement the #create_persistent_object method to return a Wx::PersistentObject
|
14
|
+
# instance for the object it is called for.
|
15
|
+
# This method raises a NoImplementError if the object class does not support persistence.
|
16
|
+
# @see Defining Custom Persistent Windows
|
17
|
+
# @param obj [Object]
|
18
|
+
# @return [Wx::PersistentObject]
|
19
|
+
def self.create_persistent_object(obj) end
|
20
|
+
|
21
|
+
# A shorter synonym for {Wx::PersistenceManager#register_and_restore}.
|
22
|
+
#
|
23
|
+
# This function simply calls {Wx::PersistenceManager#register_and_restore} but using it results in slightly shorter
|
24
|
+
# code as it calls {Wx::PersistenceManager.get} internally. As an additional convenience, this function can also set the window name.
|
25
|
+
#
|
26
|
+
# Returns true if the settings were restored or false otherwise (this will always be the case when the program runs
|
27
|
+
# for the first time, for example).
|
28
|
+
# @param obj [Wx::Window] window to register with persistence manager and to try to restore the settings for.
|
29
|
+
# @param name [String] If specified non-empty, window name is changed to the provided value before registering it.
|
30
|
+
# @return [Boolean]
|
31
|
+
def self.persistent_register_and_restore(obj, name=nil) end
|
32
|
+
|
33
|
+
# class alias
|
34
|
+
PersistentWindow = PersistentWindowBase
|
35
|
+
|
36
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
3
|
+
#
|
4
|
+
# This software is released under the MIT license.
|
5
|
+
# :startdoc:
|
6
|
+
|
7
|
+
|
8
|
+
module Wx
|
9
|
+
|
10
|
+
class PersistentObject < ::Object
|
11
|
+
|
12
|
+
# Save the specified value using the given name.
|
13
|
+
# @param [String] name The name of the value in the configuration file.
|
14
|
+
# @param [Object] value The value to save, currently must be a type supported by wxConfig.
|
15
|
+
# @return [Boolean] true if the value was saved or false if an error occurred.
|
16
|
+
def save_value(name, value); end
|
17
|
+
protected :save_value
|
18
|
+
|
19
|
+
# Restore a value saved by {#save_value}.
|
20
|
+
# @param [String] name The name of the value in the configuration file.
|
21
|
+
# @return [Object,nil] The value if successfully read, nil otherwise
|
22
|
+
def restore_value(name); end
|
23
|
+
protected :restore_value
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
# :stopdoc:
|
2
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
3
|
+
#
|
4
|
+
# This software is released under the MIT license.
|
5
|
+
# :startdoc:
|
6
|
+
|
7
|
+
|
8
|
+
module Wx
|
9
|
+
|
10
|
+
class TopLevelWindow < NonOwnedWindow
|
11
|
+
|
12
|
+
# Creates PersistentObject for this toplevel window instance (incl. Dialog and Frame).
|
13
|
+
# @see Wx.create_persistent_object
|
14
|
+
# @return [Wx::PersistentTLW]
|
15
|
+
def create_persistent_object; end
|
16
|
+
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
data/lib/wx/doc/treebook.rb
CHANGED
@@ -7,13 +7,18 @@
|
|
7
7
|
|
8
8
|
module Wx
|
9
9
|
|
10
|
-
class Treebook
|
10
|
+
class Treebook < BookCtrlBase
|
11
11
|
|
12
12
|
# Returns the Wx::TreeCtrl used for this Treebook
|
13
13
|
# @return [Wx::TreeCtrl] the tree control
|
14
14
|
def get_tree_ctrl; end
|
15
15
|
alias :tree_ctrl :get_tree_ctrl
|
16
16
|
|
17
|
+
# Creates PersistentObject for this treebook control instance.
|
18
|
+
# @see Wx.create_persistent_object
|
19
|
+
# @return [Wx::PersistentTreeBookCtrl]
|
20
|
+
def create_persistent_object; end
|
21
|
+
|
17
22
|
end
|
18
23
|
|
19
24
|
end
|
data/lib/wx/version.rb
CHANGED
data/rakelib/build.rb
CHANGED
@@ -48,7 +48,7 @@ if WXRuby3.is_bootstrapped?
|
|
48
48
|
end
|
49
49
|
|
50
50
|
# The main source module - which needs to initialize all the other modules in the package
|
51
|
-
file pkg.initializer_src => pkg.all_swig_files do |t|
|
51
|
+
file pkg.initializer_src => (pkg.all_swig_files + (pkg.parent ? [pkg.parent.initializer_src] : [])) do |t|
|
52
52
|
pkg.generate_initializer
|
53
53
|
end
|
54
54
|
|
@@ -22,7 +22,8 @@ namespace Swig
|
|
22
22
|
DirectorRubyException(VALUE error, VALUE rcvr, ID fn_id)
|
23
23
|
: DirectorException(Qnil)
|
24
24
|
{
|
25
|
-
VALUE msg = rb_sprintf("Caught exception in SWIG director method for %s#%s", rb_class2name(CLASS_OF(rcvr)), rb_id2name(fn_id));
|
25
|
+
VALUE msg = rb_sprintf("Caught exception in SWIG director method for %s#%s : ", rb_class2name(CLASS_OF(rcvr)), rb_id2name(fn_id));
|
26
|
+
rb_str_append(msg, rb_funcall(error, rb_intern("message"), 0));
|
26
27
|
this->swig_msg = StringValuePtr(msg);
|
27
28
|
swig_error = rb_exc_new_str(rb_eRuntimeError, msg);
|
28
29
|
VALUE bt = rb_funcall(error, rb_intern("backtrace"), 0);
|
data/rakelib/lib/core/package.rb
CHANGED
@@ -6,6 +6,8 @@
|
|
6
6
|
# wxRuby3 extension library Package class
|
7
7
|
###
|
8
8
|
|
9
|
+
require 'monitor'
|
10
|
+
|
9
11
|
module WXRuby3
|
10
12
|
|
11
13
|
class Director
|
@@ -434,9 +436,29 @@ module WXRuby3
|
|
434
436
|
def generated_events
|
435
437
|
@generated_events ||= ::Set.new
|
436
438
|
end
|
439
|
+
|
440
|
+
def event_list_packages
|
441
|
+
unless @event_list_packages
|
442
|
+
@event_list_packages = ::Set.new
|
443
|
+
@event_list_packages.extend(MonitorMixin)
|
444
|
+
end
|
445
|
+
@event_list_packages
|
446
|
+
end
|
437
447
|
end
|
438
448
|
|
439
449
|
def generate_event_list
|
450
|
+
# make sure parent package has already generated event list
|
451
|
+
Package.event_list_packages.synchronize do
|
452
|
+
if parent && !Package.event_list_packages.include?(parent)
|
453
|
+
# make sure all included director modules have been extracted
|
454
|
+
parent.included_directors.each do |dir|
|
455
|
+
dir.extract_interface(false) # no need to generate anything here
|
456
|
+
end
|
457
|
+
parent.generate_event_list
|
458
|
+
end
|
459
|
+
end
|
460
|
+
# list ourselves as generated
|
461
|
+
Package.event_list_packages << self
|
440
462
|
# determine Ruby library events root for package
|
441
463
|
rbevt_root = File.join(ruby_classes_path, 'events')
|
442
464
|
# create event list file
|
@@ -483,7 +505,6 @@ module WXRuby3
|
|
483
505
|
fout.puts 'end'
|
484
506
|
end
|
485
507
|
end
|
486
|
-
private :generate_event_list
|
487
508
|
|
488
509
|
def find_event_doc(evh_name)
|
489
510
|
unless doc = event_docs[evh_name]
|
data/rakelib/lib/core/spec.rb
CHANGED
@@ -272,6 +272,16 @@ module WXRuby3
|
|
272
272
|
self
|
273
273
|
end
|
274
274
|
|
275
|
+
def gc_as_marked(*names)
|
276
|
+
if names.empty?
|
277
|
+
@gc_type = :GC_MANAGE_AS_MARKED
|
278
|
+
else
|
279
|
+
@gc_type = ::Hash.new unless @gc_type.is_a?(::Hash)
|
280
|
+
names.flatten.each {|n| @gc_type[n] = :GC_MANAGE_AS_MARKED }
|
281
|
+
end
|
282
|
+
self
|
283
|
+
end
|
284
|
+
|
275
285
|
def gc_type(name)
|
276
286
|
@gc_type.is_a?(::Hash) ? @gc_type[name] : @gc_type
|
277
287
|
end
|
@@ -121,7 +121,7 @@ module WXRuby3
|
|
121
121
|
|
122
122
|
def get_base_module_list(hierarchy, foldedbases, list = ::Set.new)
|
123
123
|
hierarchy.each_value do |super_def|
|
124
|
-
list << super_def.module unless foldedbases.include?(super_def.name)
|
124
|
+
list << super_def.module unless foldedbases.include?(super_def.name) || super_def.module == module_name
|
125
125
|
get_base_module_list(super_def.supers, folded_bases(super_def.name), list)
|
126
126
|
end
|
127
127
|
list
|
@@ -14,9 +14,10 @@ module WXRuby3
|
|
14
14
|
|
15
15
|
class ComboCtrl < Window
|
16
16
|
|
17
|
+
include Typemap::ComboPopup
|
18
|
+
|
17
19
|
def setup
|
18
20
|
super
|
19
|
-
spec.items << 'wxComboPopup'
|
20
21
|
# mixin TextEntry
|
21
22
|
spec.include_mixin 'wxComboCtrl', { 'Wx::TextEntry' => 'wxTextEntryBase' }
|
22
23
|
spec.override_inheritance_chain('wxComboCtrl',
|
@@ -29,8 +30,108 @@ module WXRuby3
|
|
29
30
|
wxComboCtrl::DoSetPopupControl
|
30
31
|
wxComboCtrl::DoShowPopup
|
31
32
|
]
|
32
|
-
|
33
|
-
|
33
|
+
spec.add_header_code <<~__HEREDOC
|
34
|
+
#include "wxruby-ComboPopup.h"
|
35
|
+
|
36
|
+
static VALUE g_rb_mWxComboPopup = Qnil;
|
37
|
+
static VALUE g_rb_cComboPopupWx = Qnil;
|
38
|
+
|
39
|
+
WXRUBY_EXPORT wxComboPopup* wxRuby_ComboPopupFromRuby(VALUE popup)
|
40
|
+
{
|
41
|
+
if (!NIL_P(popup) && !rb_obj_is_kind_of(popup, g_rb_mWxComboPopup))
|
42
|
+
{
|
43
|
+
rb_raise(rb_eArgError, "Expected a Wx::ComboPopup or nil for 1");
|
44
|
+
return nullptr;
|
45
|
+
}
|
46
|
+
|
47
|
+
wxComboPopup* cpp = nullptr;
|
48
|
+
if (!NIL_P(popup))
|
49
|
+
{
|
50
|
+
VALUE rb_cp_proxy = rb_iv_get(popup, "@_wx_combo_popup_proxy");
|
51
|
+
if (NIL_P(rb_cp_proxy))
|
52
|
+
{
|
53
|
+
cpp = new WxRubyComboPopup(popup);
|
54
|
+
rb_cp_proxy = Data_Wrap_Struct(rb_cObject, 0, 0, cpp);
|
55
|
+
rb_iv_set(popup, "@_wx_combo_popup_proxy", rb_cp_proxy);
|
56
|
+
}
|
57
|
+
else
|
58
|
+
{
|
59
|
+
Data_Get_Struct(rb_cp_proxy, wxComboPopup, cpp);
|
60
|
+
}
|
61
|
+
}
|
62
|
+
return cpp;
|
63
|
+
}
|
64
|
+
|
65
|
+
WXRUBY_EXPORT VALUE wxRuby_ComboPopupToRuby(wxComboPopup* cpp)
|
66
|
+
{
|
67
|
+
VALUE rb_cpp = Qnil;
|
68
|
+
if (cpp)
|
69
|
+
{
|
70
|
+
WxRubyComboPopup *wxrb_cpp = dynamic_cast<WxRubyComboPopup*> (cpp);
|
71
|
+
if (wxrb_cpp)
|
72
|
+
{
|
73
|
+
rb_cpp = wxrb_cpp->GetRubyComboPopup();
|
74
|
+
}
|
75
|
+
else
|
76
|
+
{
|
77
|
+
// in this case we're probably working for a wxOwnerDrawnComboBox or wxRichTextListbox
|
78
|
+
// with default popup control which is a C++ implemented class without any Ruby linkage.
|
79
|
+
// wrap this in the Wx::ComboPopupWx class to provide a Ruby interface
|
80
|
+
rb_cpp = Data_Wrap_Struct(g_rb_cComboPopupWx, 0, 0, cpp); // do not own or track
|
81
|
+
}
|
82
|
+
}
|
83
|
+
return rb_cpp;
|
84
|
+
}
|
85
|
+
|
86
|
+
static void wxRuby_markComboPopups()
|
87
|
+
{
|
88
|
+
WxRubyComboPopup::GC_mark_combo_popups();
|
89
|
+
}
|
90
|
+
__HEREDOC
|
91
|
+
# ignore these
|
92
|
+
spec.ignore 'wxComboCtrl::SetPopupControl',
|
93
|
+
'wxComboCtrl::GetPopupControl',
|
94
|
+
ignore_doc: false
|
95
|
+
# for GetPopupControl docs only
|
96
|
+
spec.map 'wxComboPopup*' => 'Wx::ComboPopup', swig: false do
|
97
|
+
map_out code: ''
|
98
|
+
end
|
99
|
+
# and replace
|
100
|
+
spec.add_extend_code 'wxComboCtrl', <<~__HEREDOC
|
101
|
+
void SetPopupControl(VALUE popup)
|
102
|
+
{
|
103
|
+
wxComboPopup* cpp = wxRuby_ComboPopupFromRuby(popup);
|
104
|
+
$self->SetPopupControl(cpp);
|
105
|
+
}
|
106
|
+
|
107
|
+
VALUE GetPopupControl()
|
108
|
+
{
|
109
|
+
return wxRuby_ComboPopupToRuby($self->GetPopupControl());
|
110
|
+
}
|
111
|
+
__HEREDOC
|
112
|
+
spec.add_init_code <<~__HEREDOC
|
113
|
+
wxRuby_AppendMarker(wxRuby_markComboPopups);
|
114
|
+
|
115
|
+
g_rb_mWxComboPopup = rb_define_module_under(mWxCore, "ComboPopup");
|
116
|
+
rb_define_method(g_rb_mWxComboPopup, "get_combo_ctrl", VALUEFUNC(wx_combo_popup_get_combo_ctrl), -1);
|
117
|
+
|
118
|
+
g_rb_cComboPopupWx = rb_define_class_under(mWxCore, "ComboPopupWx", rb_cObject);
|
119
|
+
rb_undef_alloc_func(g_rb_cComboPopupWx);
|
120
|
+
rb_define_method(g_rb_cComboPopupWx, "lazy_create", VALUEFUNC(combo_popup_wx_lazy_create), -1);
|
121
|
+
rb_define_method(g_rb_cComboPopupWx, "create", VALUEFUNC(combo_popup_wx_create), -1);
|
122
|
+
rb_define_method(g_rb_cComboPopupWx, "get_combo_ctrl", VALUEFUNC(combo_popup_wx_get_combo_ctrl), -1);
|
123
|
+
rb_define_method(g_rb_cComboPopupWx, "find_item", VALUEFUNC(combo_popup_wx_find_item), -1);
|
124
|
+
rb_define_method(g_rb_cComboPopupWx, "get_adjusted_size", VALUEFUNC(combo_popup_wx_get_adjusted_size), -1);
|
125
|
+
rb_define_method(g_rb_cComboPopupWx, "get_control", VALUEFUNC(combo_popup_wx_get_control), -1);
|
126
|
+
rb_define_method(g_rb_cComboPopupWx, "set_string_value", VALUEFUNC(combo_popup_wx_set_string_value), -1);
|
127
|
+
rb_define_method(g_rb_cComboPopupWx, "get_string_value", VALUEFUNC(combo_popup_wx_get_string_value), -1);
|
128
|
+
rb_define_method(g_rb_cComboPopupWx, "on_combo_double_click", VALUEFUNC(combo_popup_wx_on_combo_double_click), -1);
|
129
|
+
rb_define_method(g_rb_cComboPopupWx, "on_combo_key_event", VALUEFUNC(combo_popup_wx_on_combo_key_event), -1);
|
130
|
+
rb_define_method(g_rb_cComboPopupWx, "on_combo_char_event", VALUEFUNC(combo_popup_wx_on_combo_char_event), -1);
|
131
|
+
rb_define_method(g_rb_cComboPopupWx, "on_dismiss", VALUEFUNC(combo_popup_wx_on_dismiss), -1);
|
132
|
+
rb_define_method(g_rb_cComboPopupWx, "on_popup", VALUEFUNC(combo_popup_wx_on_popup), -1);
|
133
|
+
rb_define_method(g_rb_cComboPopupWx, "paint_combo_control", VALUEFUNC(combo_popup_wx_paint_combo_control), -1);
|
134
|
+
__HEREDOC
|
34
135
|
end
|
35
136
|
|
36
137
|
end # class ComboCtrl
|