wxruby3 1.3.0 → 1.4.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/INSTALL.md +16 -12
- data/README.md +4 -3
- data/ext/wxruby3/include/wxRubyApp.h +9 -9
- data/ext/wxruby3/swig/custom/director.swg +11 -3
- data/ext/wxruby3/swig/custom/rubyapi.swg +15 -1
- data/ext/wxruby3/swig/mark_free_impl.i +47 -11
- data/ext/wxruby3/swig/wx.i +30 -12
- data/lib/wx/aui/auifloatframe.rb +1 -1
- data/lib/wx/aui/auimanager.rb +50 -14
- data/lib/wx/aui/auinotebook.rb +1 -1
- data/lib/wx/aui/require.rb +0 -2
- data/lib/wx/core/acceleratortable.rb +1 -1
- data/lib/wx/core/animation.rb +2 -2
- data/lib/wx/core/app.rb +1 -1
- data/lib/wx/core/array_ext.rb +1 -0
- data/lib/wx/core/artprovider.rb +4 -4
- data/lib/wx/core/bitmap.rb +1 -1
- data/lib/wx/core/bitmap_combobox.rb +2 -2
- data/lib/wx/core/brush.rb +8 -0
- data/lib/wx/core/clientdc.rb +1 -1
- data/lib/wx/core/clipboard.rb +4 -4
- data/lib/wx/core/colour.rb +1 -1
- data/lib/wx/core/combobox.rb +1 -1
- data/lib/wx/core/config.rb +7 -7
- data/lib/wx/core/controlwithitems.rb +3 -3
- data/lib/wx/core/data_object.rb +4 -4
- data/lib/wx/core/dataformat.rb +9 -3
- data/lib/wx/core/defs.rb +49 -0
- data/lib/wx/core/dialog.rb +3 -2
- data/lib/wx/core/enum.rb +16 -3
- data/lib/wx/core/event.rb +3 -3
- data/lib/wx/core/evthandler.rb +317 -289
- data/lib/wx/core/file_dialog.rb +1 -1
- data/lib/wx/core/find_replace_dialog.rb +2 -2
- data/lib/wx/core/font.rb +14 -0
- data/lib/wx/core/functions.rb +1 -1
- data/lib/wx/core/genericdirctrl.rb +1 -1
- data/lib/wx/core/geometry.rb +2 -2
- data/lib/wx/core/graphics_pen_info.rb +1 -1
- data/lib/wx/core/hboxsizer.rb +24 -4
- data/lib/wx/core/helpprovider.rb +1 -1
- data/lib/wx/core/icon.rb +1 -1
- data/lib/wx/core/image.rb +2 -2
- data/lib/wx/core/imagelist.rb +1 -1
- data/lib/wx/core/locale.rb +5 -5
- data/lib/wx/core/log.rb +8 -8
- data/lib/wx/core/menu.rb +3 -3
- data/lib/wx/core/module_ext.rb +16 -0
- data/lib/wx/core/owner_drawn_combobox.rb +3 -3
- data/lib/wx/core/pen.rb +20 -0
- data/lib/wx/core/pen_info.rb +1 -1
- data/lib/wx/core/persistence_manager.rb +2 -2
- data/lib/wx/core/real_point.rb +1 -0
- data/lib/wx/core/rect.rb +1 -1
- data/lib/wx/core/secret_store.rb +1 -1
- data/lib/wx/core/simplehelpprovider.rb +1 -1
- data/lib/wx/core/sizer.rb +166 -39
- data/lib/wx/core/splash_screen.rb +1 -1
- data/lib/wx/core/standard_paths.rb +1 -1
- data/lib/wx/core/task_bar_button.rb +1 -1
- data/lib/wx/core/text_entry.rb +1 -1
- data/lib/wx/core/textctrl.rb +2 -2
- data/lib/wx/core/timer.rb +2 -2
- data/lib/wx/core/tree_ctrl.rb +1 -1
- data/lib/wx/core/v_list_box.rb +1 -1
- data/lib/wx/core/validator.rb +2 -2
- data/lib/wx/core/variant.rb +2 -2
- data/lib/wx/core/vboxsizer.rb +24 -4
- data/lib/wx/core/window.rb +48 -2
- data/lib/wx/core/xmlresource.rb +4 -4
- data/lib/wx/core.rb +2 -0
- data/lib/wx/doc/array_ext.rb +1 -0
- data/lib/wx/doc/aui/auimanager.rb +2 -0
- data/lib/wx/doc/enum.rb +26 -0
- data/lib/wx/doc/evthandler.rb +1 -0
- data/lib/wx/doc/gdi_common.rb +1 -0
- data/lib/wx/doc/tip_window.rb +22 -0
- data/lib/wx/grid/grid.rb +3 -3
- data/lib/wx/grid/require.rb +0 -2
- data/lib/wx/html/htmlhelpcontroller.rb +1 -1
- data/lib/wx/html/htmlwindow.rb +1 -1
- data/lib/wx/html/require.rb +0 -2
- data/lib/wx/html/simple_html_listbox.rb +3 -3
- data/lib/wx/keyword_ctors.rb +14 -7
- data/lib/wx/keyword_defs.rb +7 -7
- data/lib/wx/pg/pg_properties.rb +1 -1
- data/lib/wx/pg/pg_property.rb +3 -3
- data/lib/wx/pg/property_grid.rb +2 -2
- data/lib/wx/pg/property_grid_interface.rb +2 -2
- data/lib/wx/pg/require.rb +0 -2
- data/lib/wx/prt/previewframe.rb +1 -1
- data/lib/wx/prt/require.rb +0 -2
- data/lib/wx/rbn/ribbon_control.rb +1 -1
- data/lib/wx/rbn/ribbon_page.rb +1 -1
- data/lib/wx/rbn/ribbon_panel.rb +1 -1
- data/lib/wx/rtc/require.rb +0 -2
- data/lib/wx/rtc/rich_text_composite_object.rb +1 -1
- data/lib/wx/rtc/rich_text_ctrl.rb +1 -1
- data/lib/wx/rtc/rich_text_paragraph.rb +1 -1
- data/lib/wx/rtc/richtext_buffer.rb +3 -3
- data/lib/wx/rtc/richtext_formatting_dialog.rb +2 -2
- data/lib/wx/rtc/richtext_style_organiser_dialog.rb +1 -1
- data/lib/wx/rtc/symbol_picker_dialog.rb +1 -1
- data/lib/wx/stc/require.rb +0 -2
- data/lib/wx/stc/styled_text_ctrl.rb +1 -1
- data/lib/wx/version.rb +1 -1
- data/lib/wx/wxruby/base.rb +8 -2
- data/lib/wx/wxruby/cmd/setup.rb +61 -37
- data/rakelib/gem.rb +8 -4
- data/rakelib/lib/config/mingw.rb +1 -1
- data/rakelib/lib/core/include/swigrubyrun.inc +2 -2
- data/rakelib/lib/director/about_dialog_info.rb +1 -0
- data/rakelib/lib/director/aui_manager.rb +124 -3
- data/rakelib/lib/director/aui_notebook.rb +7 -0
- data/rakelib/lib/director/colour.rb +1 -1
- data/rakelib/lib/director/data_format.rb +1 -1
- data/rakelib/lib/director/dialog.rb +4 -2
- data/rakelib/lib/director/event.rb +1 -0
- data/rakelib/lib/director/event_handler.rb +82 -46
- data/rakelib/lib/director/functions.rb +0 -3
- data/rakelib/lib/director/list_ctrl.rb +14 -10
- data/rakelib/lib/director/locale.rb +2 -0
- data/rakelib/lib/director/num_validator.rb +7 -0
- data/rakelib/lib/director/pgproperties.rb +2 -2
- data/rakelib/lib/director/property_grid_interface.rb +4 -3
- data/rakelib/lib/director/textctrl.rb +7 -0
- data/rakelib/lib/director/tip_window.rb +34 -0
- data/rakelib/lib/director/variant.rb +2 -2
- data/rakelib/lib/director/window.rb +9 -1
- data/rakelib/lib/director.rb +0 -1
- data/rakelib/lib/extractor/function.rb +5 -0
- data/rakelib/lib/generate/doc/evt_handler.yaml +31 -12
- data/rakelib/lib/specs/interfaces.rb +1 -0
- data/rakelib/lib/typemap/common.rb +2 -2
- data/samples/dialogs/dialogs.rb +1 -1
- data/tests/test_combo_ctrl.rb +1 -0
- data/tests/test_event_handling.rb +158 -31
- metadata +7 -5
data/lib/wx/core/file_dialog.rb
CHANGED
@@ -13,7 +13,7 @@ module Wx
|
|
13
13
|
class FileDialog
|
14
14
|
|
15
15
|
wx_set_customize_hook = instance_method :set_customize_hook
|
16
|
-
|
16
|
+
wx_redefine_method :set_customize_hook do |hook|
|
17
17
|
wx_set_customize_hook.bind(self).call(hook)
|
18
18
|
@hook = hook # cache hook to prevent premature GC collection
|
19
19
|
end
|
@@ -15,13 +15,13 @@ module Wx
|
|
15
15
|
# the data object so we need to keep it alive here
|
16
16
|
|
17
17
|
wx_initialize = instance_method :initialize
|
18
|
-
|
18
|
+
wx_redefine_method :initialize do |parent, data, *args|
|
19
19
|
wx_initialize.bind(self).call(parent, data, *args)
|
20
20
|
@fr_data = data
|
21
21
|
end
|
22
22
|
|
23
23
|
wx_set_data = instance_method :set_data
|
24
|
-
|
24
|
+
wx_redefine_method :set_data do |data|
|
25
25
|
wx_set_data.bind(self).call(data)
|
26
26
|
@fr_data = data
|
27
27
|
end
|
data/lib/wx/core/font.rb
CHANGED
@@ -1,5 +1,13 @@
|
|
1
|
+
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
|
2
|
+
#
|
3
|
+
# This software is released under the MIT license.
|
4
|
+
#
|
5
|
+
# Some parts are
|
6
|
+
# Copyright 2004-2007, wxRuby development team
|
7
|
+
# released under the MIT-like wxRuby2 license
|
1
8
|
|
2
9
|
require_relative './font/encoding'
|
10
|
+
require_relative './enum'
|
3
11
|
|
4
12
|
module Wx
|
5
13
|
|
@@ -27,4 +35,10 @@ module Wx
|
|
27
35
|
# can be accessed through that name too.
|
28
36
|
TheFontList = Font
|
29
37
|
|
38
|
+
class FontFlag < Wx::Enum
|
39
|
+
|
40
|
+
set_non_distinct(%i[FONTFLAG_MASK])
|
41
|
+
|
42
|
+
end
|
43
|
+
|
30
44
|
end
|
data/lib/wx/core/functions.rb
CHANGED
@@ -13,7 +13,7 @@ module Wx
|
|
13
13
|
# Allow this to be called with keyword parameters, and avoid
|
14
14
|
# segfaults on OS X with bad params
|
15
15
|
wx_about_box = self.instance_method(:about_box)
|
16
|
-
|
16
|
+
wx_redefine_method(:about_box) do | info, parent=nil |
|
17
17
|
case info
|
18
18
|
when Wx::AboutDialogInfo
|
19
19
|
ab_info = info
|
data/lib/wx/core/geometry.rb
CHANGED
@@ -23,7 +23,7 @@ module Wx
|
|
23
23
|
private :add, :sub, :mul, :div
|
24
24
|
|
25
25
|
wx_assign = instance_method :assign
|
26
|
-
|
26
|
+
wx_redefine_method :assign do |pt|
|
27
27
|
wx_assign.bind(self).call(pt)
|
28
28
|
self
|
29
29
|
end
|
@@ -76,7 +76,7 @@ module Wx
|
|
76
76
|
private :add, :sub, :mul, :div
|
77
77
|
|
78
78
|
wx_assign = instance_method :assign
|
79
|
-
|
79
|
+
wx_redefine_method :assign do |pt|
|
80
80
|
wx_assign.bind(self).call(pt)
|
81
81
|
self
|
82
82
|
end
|
data/lib/wx/core/hboxsizer.rb
CHANGED
@@ -9,14 +9,34 @@
|
|
9
9
|
# Just a shortcut version for creating a horizontal box sizer
|
10
10
|
|
11
11
|
class Wx::HBoxSizer < Wx::BoxSizer
|
12
|
-
def initialize
|
13
|
-
super(Wx::HORIZONTAL)
|
12
|
+
def initialize(&block)
|
13
|
+
super(Wx::HORIZONTAL, &nil)
|
14
|
+
if block
|
15
|
+
if block.arity == -1 or block.arity == 0
|
16
|
+
self.instance_eval(&block)
|
17
|
+
elsif block.arity == 1
|
18
|
+
block.call(self)
|
19
|
+
else
|
20
|
+
Kernel.raise ArgumentError,
|
21
|
+
"Block to initialize should accept a single argument or none"
|
22
|
+
end
|
23
|
+
end
|
14
24
|
end
|
15
25
|
end
|
16
26
|
|
17
27
|
# Just a shortcut version for creating a horizontal wrap sizer
|
18
28
|
class Wx::HWrapSizer < Wx::WrapSizer
|
19
|
-
def initialize(flags=Wx::WRAPSIZER_DEFAULT_FLAGS)
|
20
|
-
super(Wx::HORIZONTAL)
|
29
|
+
def initialize(flags=Wx::WRAPSIZER_DEFAULT_FLAGS, &block)
|
30
|
+
super(Wx::HORIZONTAL, &nil)
|
31
|
+
if block
|
32
|
+
if block.arity == -1 or block.arity == 0
|
33
|
+
self.instance_eval(&block)
|
34
|
+
elsif block.arity == 1
|
35
|
+
block.call(self)
|
36
|
+
else
|
37
|
+
Kernel.raise ArgumentError,
|
38
|
+
"Block to initialize should accept a single argument or none"
|
39
|
+
end
|
40
|
+
end
|
21
41
|
end
|
22
42
|
end
|
data/lib/wx/core/helpprovider.rb
CHANGED
@@ -16,7 +16,7 @@ class Wx::HelpProvider
|
|
16
16
|
# easiest way is to make the currently set one an instance variable
|
17
17
|
# of this class
|
18
18
|
wx_set = instance_method :set
|
19
|
-
|
19
|
+
wx_redefine_method(:set) do | help_provider |
|
20
20
|
wx_set.bind(self).call(help_provider)
|
21
21
|
@__hp__ = help_provider
|
22
22
|
end
|
data/lib/wx/core/icon.rb
CHANGED
@@ -44,7 +44,7 @@ module Wx
|
|
44
44
|
# just carries on with an empty icon, which may cause faults
|
45
45
|
# later. Also guess icon type from filename, if not specified.
|
46
46
|
wx_init = self.instance_method(:initialize)
|
47
|
-
|
47
|
+
wx_redefine_method(:initialize) do | *args |
|
48
48
|
if args[0].kind_of? String
|
49
49
|
if not File.exist?( File.expand_path(args[0]) )
|
50
50
|
Kernel.raise(ArgumentError, "Icon file does not exist: #{args[0]}")
|
data/lib/wx/core/image.rb
CHANGED
@@ -58,7 +58,7 @@ module Wx
|
|
58
58
|
# later. Also, if loading from a file, and the type is not specified,
|
59
59
|
# try to guess it from the filename extension
|
60
60
|
wx_init = self.instance_method(:initialize)
|
61
|
-
|
61
|
+
wx_redefine_method(:initialize) do | *args |
|
62
62
|
if args[0].kind_of? String
|
63
63
|
if not File.exist?( File.expand_path(args[0]) )
|
64
64
|
Kernel.raise(ArgumentError, "Image file does not exist: #{args[0]}")
|
@@ -103,7 +103,7 @@ module Wx
|
|
103
103
|
end
|
104
104
|
|
105
105
|
wx_compute_histogram = instance_method :compute_histogram
|
106
|
-
|
106
|
+
wx_redefine_method :compute_histogram do
|
107
107
|
hist_hash = wx_compute_histogram.bind(self).call
|
108
108
|
hist_hash.extend Histogram
|
109
109
|
hist_hash
|
data/lib/wx/core/imagelist.rb
CHANGED
@@ -10,7 +10,7 @@ class Wx::ImageList
|
|
10
10
|
|
11
11
|
# provide seamless support for adding icons on all platforms
|
12
12
|
wx_add = instance_method :add
|
13
|
-
|
13
|
+
wx_redefine_method :add do |*args|
|
14
14
|
if Wx::PLATFORM == 'WXMSW' && args.size == 1 && Wx::Icon === args.first
|
15
15
|
args[0] = args.first.to_bitmap
|
16
16
|
end
|
data/lib/wx/core/locale.rb
CHANGED
@@ -32,22 +32,22 @@ class Wx::Locale
|
|
32
32
|
# as wxWidgets defines an enum wxLanguage but still uses a mix of enum args and int args
|
33
33
|
# to specify languages we need to fix some things here to make that easier
|
34
34
|
wx_is_available = Wx::Locale.method(:is_available)
|
35
|
-
|
35
|
+
wx_redefine_method :is_available do |lang|
|
36
36
|
wx_is_available.call(lang.to_i)
|
37
37
|
end
|
38
38
|
|
39
39
|
wx_get_language_info = Wx::Locale.method(:get_language_info)
|
40
|
-
|
40
|
+
wx_redefine_method :get_language_info do |lang|
|
41
41
|
wx_get_language_info.call(lang.to_i)
|
42
42
|
end
|
43
43
|
|
44
44
|
wx_get_language_name = Wx::Locale.method(:get_language_name)
|
45
|
-
|
45
|
+
wx_redefine_method :get_language_name do |lang|
|
46
46
|
wx_get_language_name.call(lang.to_i)
|
47
47
|
end
|
48
48
|
|
49
49
|
wx_get_language_canonical_name = Wx::Locale.method(:get_language_canonical_name)
|
50
|
-
|
50
|
+
wx_redefine_method :get_language_canonical_name do |lang|
|
51
51
|
wx_get_language_canonical_name.call(lang.to_i)
|
52
52
|
end
|
53
53
|
end
|
@@ -66,7 +66,7 @@ class Wx::Locale
|
|
66
66
|
# as wxWidgets defines an enum wxLanguage but still uses a mix of enum args and int args
|
67
67
|
# to specify languages we need to fix some things here to make that easier
|
68
68
|
wx_init = instance_method(:init)
|
69
|
-
|
69
|
+
wx_redefine_method :init do |*args|
|
70
70
|
if args.empty? || ::String === args.first
|
71
71
|
wx_init.bind(self).call(*args)
|
72
72
|
else
|
data/lib/wx/core/log.rb
CHANGED
@@ -48,13 +48,13 @@ module Wx
|
|
48
48
|
class LogChain
|
49
49
|
|
50
50
|
wx_initialize = instance_method :initialize
|
51
|
-
|
51
|
+
wx_redefine_method :initialize do |new_log|
|
52
52
|
wx_initialize.bind(self).call(new_log)
|
53
53
|
@new_log = new_log # cache to prevent premature GC collection; old_log managed in C++ wrapper
|
54
54
|
end
|
55
55
|
|
56
56
|
wx_set_log = instance_method :set_log
|
57
|
-
|
57
|
+
wx_redefine_method :set_log do |new_log|
|
58
58
|
wx_set_log.bind(self).call(new_log)
|
59
59
|
@new_log = new_log # cache to prevent premature GC collection; old_log managed in C++ wrapper
|
60
60
|
end
|
@@ -100,32 +100,32 @@ module Wx
|
|
100
100
|
private :setup_log_info
|
101
101
|
|
102
102
|
wx_log_generic = self.instance_method :log_generic
|
103
|
-
|
103
|
+
wx_redefine_method :log_generic do |lvl, fmt, *args, filename: nil, line: 0, func: nil, component: nil|
|
104
104
|
wx_log_generic.bind(self).call(lvl, *setup_log_info(fmt, args, filename, line, func, component))
|
105
105
|
end
|
106
106
|
|
107
107
|
wx_log_info = self.instance_method :log_info
|
108
|
-
|
108
|
+
wx_redefine_method :log_info do |fmt, *args, filename: nil, line: 0, func: nil, component: nil|
|
109
109
|
wx_log_info.bind(self).call(*setup_log_info(fmt, args, filename, line, func, component))
|
110
110
|
end
|
111
111
|
|
112
112
|
wx_log_verbose = self.instance_method :log_verbose
|
113
|
-
|
113
|
+
wx_redefine_method :log_verbose do |fmt, *args, filename: nil, line: 0, func: nil, component: nil|
|
114
114
|
wx_log_verbose.bind(self).call(*setup_log_info(fmt, args, filename, line, func, component))
|
115
115
|
end
|
116
116
|
|
117
117
|
wx_log_message = self.instance_method :log_message
|
118
|
-
|
118
|
+
wx_redefine_method :log_message do |fmt, *args, filename: nil, line: 0, func: nil, component: nil|
|
119
119
|
wx_log_message.bind(self).call(*setup_log_info(fmt, args, filename, line, func, component))
|
120
120
|
end
|
121
121
|
|
122
122
|
wx_log_warning = self.instance_method :log_warning
|
123
|
-
|
123
|
+
wx_redefine_method :log_warning do |fmt, *args, filename: nil, line: 0, func: nil, component: nil|
|
124
124
|
wx_log_warning.bind(self).call(*setup_log_info(fmt, args, filename, line, func, component))
|
125
125
|
end
|
126
126
|
|
127
127
|
wx_log_error = self.instance_method :log_error
|
128
|
-
|
128
|
+
wx_redefine_method :log_error do |fmt, *args, filename: nil, line: 0, func: nil, component: nil|
|
129
129
|
wx_log_error.bind(self).call(*setup_log_info(fmt, args, filename, line, func, component))
|
130
130
|
end
|
131
131
|
|
data/lib/wx/core/menu.rb
CHANGED
@@ -28,7 +28,7 @@ class Wx::Menu
|
|
28
28
|
|
29
29
|
# Overload to provide Enumerator without block
|
30
30
|
wx_each_item = instance_method :each_item
|
31
|
-
|
31
|
+
wx_redefine_method :each_item do |&block|
|
32
32
|
if block
|
33
33
|
wx_each_item.bind(self).call(&block)
|
34
34
|
else
|
@@ -56,7 +56,7 @@ class Wx::Menu
|
|
56
56
|
class_eval do
|
57
57
|
meth_names.each do | meth |
|
58
58
|
old_meth = instance_method(meth)
|
59
|
-
|
59
|
+
wx_redefine_method(meth) do | *args |
|
60
60
|
case args.first
|
61
61
|
when Integer, Wx::Enum then old_meth.bind(self).call(*args)
|
62
62
|
when String then old_meth.bind(self).call(Wx::ID_ANY, *args)
|
@@ -79,7 +79,7 @@ class Wx::Menu
|
|
79
79
|
class_eval do
|
80
80
|
meth_names.each do | meth |
|
81
81
|
old_meth = instance_method(meth)
|
82
|
-
|
82
|
+
wx_redefine_method(meth) do | pos, *args |
|
83
83
|
case args.first
|
84
84
|
when Integer, Wx::Enum then old_meth.bind(self).call(pos, *args)
|
85
85
|
when String then old_meth.bind(self).call(pos, Wx::ID_ANY, *args)
|
@@ -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 Kernel
|
6
|
+
|
7
|
+
def wx_redefine_method(mtd, &block)
|
8
|
+
warn_lvl = $VERBOSE
|
9
|
+
$VERBOSE = nil
|
10
|
+
undef_method(mtd)
|
11
|
+
define_method(mtd, &block)
|
12
|
+
ensure
|
13
|
+
$VERBOSE = warn_lvl
|
14
|
+
end
|
15
|
+
|
16
|
+
end
|
@@ -8,7 +8,7 @@ module Wx
|
|
8
8
|
|
9
9
|
# make sure to honor the inherited common overloads
|
10
10
|
wx_get_client_object = instance_method :get_client_object
|
11
|
-
|
11
|
+
wx_redefine_method :get_client_object do |*args|
|
12
12
|
if args.empty?
|
13
13
|
super()
|
14
14
|
else
|
@@ -16,7 +16,7 @@ module Wx
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
wx_set_client_object = instance_method :set_client_object
|
19
|
-
|
19
|
+
wx_redefine_method :set_client_object do |*args|
|
20
20
|
if args.size < 2
|
21
21
|
super(*args)
|
22
22
|
else
|
@@ -32,7 +32,7 @@ module Wx
|
|
32
32
|
|
33
33
|
# Overload to provide Enumerator without block
|
34
34
|
wx_each_string = instance_method :each_string
|
35
|
-
|
35
|
+
wx_redefine_method :each_string do |&block|
|
36
36
|
if block
|
37
37
|
wx_each_string.bind(self).call(&block)
|
38
38
|
else
|
data/lib/wx/core/pen.rb
CHANGED
@@ -6,8 +6,28 @@
|
|
6
6
|
# Copyright 2004-2007, wxRuby development team
|
7
7
|
# released under the MIT-like wxRuby2 license
|
8
8
|
|
9
|
+
require_relative './enum'
|
10
|
+
|
9
11
|
module Wx
|
10
12
|
|
11
13
|
ThePenList = Wx::Pen
|
12
14
|
|
15
|
+
class PenStyle < Wx::Enum
|
16
|
+
|
17
|
+
set_non_distinct(%i[PENSTYLE_INVALID PENSTYLE_FIRST_HATCH PENSTYLE_LAST_HATCH])
|
18
|
+
|
19
|
+
end
|
20
|
+
|
21
|
+
class PenJoin < Wx::Enum
|
22
|
+
|
23
|
+
set_non_distinct(%i[JOIN_INVALID])
|
24
|
+
|
25
|
+
end
|
26
|
+
|
27
|
+
class PenCap < Wx::Enum
|
28
|
+
|
29
|
+
set_non_distinct(%i[CAP_INVALID])
|
30
|
+
|
31
|
+
end
|
32
|
+
|
13
33
|
end
|
data/lib/wx/core/pen_info.rb
CHANGED
@@ -22,12 +22,12 @@ module Wx
|
|
22
22
|
# Cache the global instance to keep it safe from GC
|
23
23
|
|
24
24
|
wx_get = instance_method :get
|
25
|
-
|
25
|
+
wx_redefine_method :get do
|
26
26
|
@the_manager ||= wx_get.bind(self).call
|
27
27
|
end
|
28
28
|
|
29
29
|
wx_set = instance_method :set
|
30
|
-
|
30
|
+
wx_redefine_method :set do |pman|
|
31
31
|
wx_set.bind(self).call(pman)
|
32
32
|
@the_manager = pman
|
33
33
|
end
|
data/lib/wx/core/real_point.rb
CHANGED
data/lib/wx/core/rect.rb
CHANGED
data/lib/wx/core/secret_store.rb
CHANGED
@@ -19,7 +19,7 @@ module Wx
|
|
19
19
|
|
20
20
|
# Redefine the initialize method to auto-convert UTF-16/-32 strings to UTF-8 if possible.
|
21
21
|
wx_init = self.instance_method(:initialize)
|
22
|
-
|
22
|
+
wx_redefine_method(:initialize) do | *args |
|
23
23
|
if args.size == 1 && ::String === args.first
|
24
24
|
unless args.first.encoding == ::Encoding::UTF_8 || args.first.encoding == ::Encoding::ASCII_8BIT
|
25
25
|
# convert in place unless frozen
|
data/lib/wx/core/sizer.rb
CHANGED
@@ -6,57 +6,184 @@
|
|
6
6
|
# Copyright 2004-2007, wxRuby development team
|
7
7
|
# released under the MIT-like wxRuby2 license
|
8
8
|
|
9
|
-
#
|
9
|
+
# Classes for automatically managing layouts
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
def add_item(item, *mixed_args)
|
11
|
+
module Wx
|
12
|
+
class Sizer
|
13
|
+
# Generic method to add items, supporting positional and named
|
14
|
+
# arguments
|
15
|
+
ADD_ITEM_PARAMS = [Wx::Parameter[:index, -1],
|
16
|
+
Wx::Parameter[:proportion, 0],
|
17
|
+
Wx::Parameter[:flag, 0],
|
18
|
+
Wx::Parameter[:border, 0]]
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
def add_item(item, *mixed_args)
|
21
|
+
|
22
|
+
begin
|
23
|
+
args = Wx::args_as_list(ADD_ITEM_PARAMS, *mixed_args)
|
24
|
+
rescue => err
|
25
|
+
err.set_backtrace(caller)
|
26
|
+
Kernel.raise err
|
27
|
+
end
|
28
|
+
|
29
|
+
full_args = []
|
30
|
+
|
31
|
+
# extract the width and the height in the case of a spacer
|
32
|
+
# defined as an array
|
33
|
+
if item.kind_of?(Array)
|
34
|
+
Kernel.raise ArgumentError,
|
35
|
+
"Invalid Sizer specification : [width, height] expected" if item.size != 2
|
36
|
+
full_args << item[0] << item[1]
|
37
|
+
else
|
38
|
+
full_args << item
|
39
|
+
end
|
40
|
+
|
41
|
+
# update the full arguments list with the optional arguments (except index)
|
42
|
+
idx = args.shift
|
43
|
+
full_args.concat(args)
|
44
|
+
|
45
|
+
# Call add to append if default position
|
46
|
+
if idx == -1
|
47
|
+
add(*full_args)
|
48
|
+
else
|
49
|
+
insert(idx, *full_args)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
# Overload to provide Enumerator without block
|
54
|
+
wx_each_child = instance_method :each_child
|
55
|
+
wx_redefine_method :each_child do |&block|
|
56
|
+
if block
|
57
|
+
wx_each_child.bind(self).call(&block)
|
58
|
+
else
|
59
|
+
::Enumerator.new { |y| wx_each_child.bind(self).call { |c| y << c } }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
end
|
64
|
+
|
65
|
+
class BoxSizer < Sizer
|
66
|
+
|
67
|
+
wx_initialize = instance_method :initialize
|
68
|
+
wx_redefine_method :initialize do |*args, &block|
|
69
|
+
wx_initialize.bind(self).call(*args)
|
70
|
+
if block
|
71
|
+
if block.arity == -1 or block.arity == 0
|
72
|
+
self.instance_eval(&block)
|
73
|
+
elsif block.arity == 1
|
74
|
+
block.call(self)
|
75
|
+
else
|
76
|
+
Kernel.raise ArgumentError,
|
77
|
+
"Block to initialize should accept a single argument or none"
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
class WrapSizer < BoxSizer
|
85
|
+
|
86
|
+
wx_initialize = instance_method :initialize
|
87
|
+
wx_redefine_method :initialize do |*args, &block|
|
88
|
+
wx_initialize.bind(self).call(*args)
|
89
|
+
if block
|
90
|
+
if block.arity == -1 or block.arity == 0
|
91
|
+
self.instance_eval(&block)
|
92
|
+
elsif block.arity == 1
|
93
|
+
block.call(self)
|
94
|
+
else
|
95
|
+
Kernel.raise ArgumentError,
|
96
|
+
"Block to initialize should accept a single argument or none"
|
97
|
+
end
|
98
|
+
end
|
26
99
|
end
|
27
100
|
|
28
|
-
|
101
|
+
end
|
102
|
+
|
103
|
+
class StaticBoxSizer < BoxSizer
|
29
104
|
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
105
|
+
wx_initialize = instance_method :initialize
|
106
|
+
wx_redefine_method :initialize do |*args, &block|
|
107
|
+
wx_initialize.bind(self).call(*args)
|
108
|
+
if block
|
109
|
+
if block.arity == -1 or block.arity == 0
|
110
|
+
self.instance_eval(&block)
|
111
|
+
elsif block.arity == 1
|
112
|
+
block.call(self)
|
113
|
+
else
|
114
|
+
Kernel.raise ArgumentError,
|
115
|
+
"Block to initialize should accept a single argument or none"
|
116
|
+
end
|
117
|
+
end
|
38
118
|
end
|
39
119
|
|
40
|
-
|
41
|
-
idx = args.shift
|
42
|
-
full_args.concat(args)
|
120
|
+
end
|
43
121
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
122
|
+
class StdDialogButtonSizer < BoxSizer
|
123
|
+
|
124
|
+
wx_initialize = instance_method :initialize
|
125
|
+
wx_redefine_method :initialize do |*args, &block|
|
126
|
+
wx_initialize.bind(self).call(*args)
|
127
|
+
if block
|
128
|
+
if block.arity == -1 or block.arity == 0
|
129
|
+
self.instance_eval(&block)
|
130
|
+
elsif block.arity == 1
|
131
|
+
block.call(self)
|
132
|
+
else
|
133
|
+
Kernel.raise ArgumentError,
|
134
|
+
"Block to initialize should accept a single argument or none"
|
135
|
+
end
|
136
|
+
end
|
49
137
|
end
|
138
|
+
|
50
139
|
end
|
51
140
|
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
::Enumerator.new { |y| wx_each_child.bind(self).call { |c| y << c } }
|
141
|
+
class GridSizer < Sizer
|
142
|
+
|
143
|
+
wx_initialize = instance_method :initialize
|
144
|
+
wx_redefine_method :initialize do |*args, &block|
|
145
|
+
wx_initialize.bind(self).call(*args)
|
146
|
+
self.instance_eval(&block) if block
|
59
147
|
end
|
148
|
+
|
149
|
+
end
|
150
|
+
|
151
|
+
class FlexGridSizer < GridSizer
|
152
|
+
|
153
|
+
wx_initialize = instance_method :initialize
|
154
|
+
wx_redefine_method :initialize do |*args, &block|
|
155
|
+
wx_initialize.bind(self).call(*args)
|
156
|
+
if block
|
157
|
+
if block.arity == -1 or block.arity == 0
|
158
|
+
self.instance_eval(&block)
|
159
|
+
elsif block.arity == 1
|
160
|
+
block.call(self)
|
161
|
+
else
|
162
|
+
Kernel.raise ArgumentError,
|
163
|
+
"Block to initialize should accept a single argument or none"
|
164
|
+
end
|
165
|
+
end
|
166
|
+
end
|
167
|
+
|
168
|
+
end
|
169
|
+
|
170
|
+
class GridBagSizer < FlexGridSizer
|
171
|
+
|
172
|
+
wx_initialize = instance_method :initialize
|
173
|
+
wx_redefine_method :initialize do |*args, &block|
|
174
|
+
wx_initialize.bind(self).call(*args)
|
175
|
+
if block
|
176
|
+
if block.arity == -1 or block.arity == 0
|
177
|
+
self.instance_eval(&block)
|
178
|
+
elsif block.arity == 1
|
179
|
+
block.call(self)
|
180
|
+
else
|
181
|
+
Kernel.raise ArgumentError,
|
182
|
+
"Block to initialize should accept a single argument or none"
|
183
|
+
end
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
60
187
|
end
|
61
188
|
|
62
189
|
end
|