wxruby3 1.3.1 → 1.4.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +16 -12
  3. data/README.md +4 -3
  4. data/ext/wxruby3/include/wxRubyApp.h +9 -9
  5. data/ext/wxruby3/swig/mark_free_impl.i +47 -11
  6. data/ext/wxruby3/swig/wx.i +30 -12
  7. data/lib/wx/aui/auifloatframe.rb +1 -1
  8. data/lib/wx/aui/auimanager.rb +5 -16
  9. data/lib/wx/aui/auinotebook.rb +1 -1
  10. data/lib/wx/aui/require.rb +0 -2
  11. data/lib/wx/core/acceleratortable.rb +1 -1
  12. data/lib/wx/core/animation.rb +2 -2
  13. data/lib/wx/core/app.rb +1 -1
  14. data/lib/wx/core/artprovider.rb +4 -4
  15. data/lib/wx/core/bitmap.rb +1 -1
  16. data/lib/wx/core/bitmap_combobox.rb +2 -2
  17. data/lib/wx/core/clientdc.rb +1 -1
  18. data/lib/wx/core/clipboard.rb +4 -4
  19. data/lib/wx/core/colour.rb +1 -1
  20. data/lib/wx/core/combobox.rb +1 -1
  21. data/lib/wx/core/config.rb +7 -7
  22. data/lib/wx/core/controlwithitems.rb +3 -3
  23. data/lib/wx/core/data_object.rb +4 -4
  24. data/lib/wx/core/dataformat.rb +9 -3
  25. data/lib/wx/core/dialog.rb +3 -2
  26. data/lib/wx/core/event.rb +3 -3
  27. data/lib/wx/core/evthandler.rb +317 -289
  28. data/lib/wx/core/file_dialog.rb +1 -1
  29. data/lib/wx/core/find_replace_dialog.rb +2 -2
  30. data/lib/wx/core/functions.rb +1 -1
  31. data/lib/wx/core/genericdirctrl.rb +1 -1
  32. data/lib/wx/core/geometry.rb +2 -2
  33. data/lib/wx/core/graphics_pen_info.rb +1 -1
  34. data/lib/wx/core/helpprovider.rb +1 -1
  35. data/lib/wx/core/icon.rb +1 -1
  36. data/lib/wx/core/image.rb +2 -2
  37. data/lib/wx/core/imagelist.rb +1 -1
  38. data/lib/wx/core/locale.rb +5 -5
  39. data/lib/wx/core/log.rb +8 -8
  40. data/lib/wx/core/menu.rb +3 -3
  41. data/lib/wx/core/module_ext.rb +16 -0
  42. data/lib/wx/core/owner_drawn_combobox.rb +3 -3
  43. data/lib/wx/core/pen_info.rb +1 -1
  44. data/lib/wx/core/persistence_manager.rb +2 -2
  45. data/lib/wx/core/rect.rb +1 -1
  46. data/lib/wx/core/secret_store.rb +1 -1
  47. data/lib/wx/core/simplehelpprovider.rb +1 -1
  48. data/lib/wx/core/sizer.rb +8 -8
  49. data/lib/wx/core/splash_screen.rb +1 -1
  50. data/lib/wx/core/standard_paths.rb +1 -1
  51. data/lib/wx/core/task_bar_button.rb +1 -1
  52. data/lib/wx/core/text_entry.rb +1 -1
  53. data/lib/wx/core/textctrl.rb +2 -2
  54. data/lib/wx/core/timer.rb +2 -2
  55. data/lib/wx/core/tree_ctrl.rb +1 -1
  56. data/lib/wx/core/v_list_box.rb +1 -1
  57. data/lib/wx/core/validator.rb +2 -2
  58. data/lib/wx/core/variant.rb +2 -2
  59. data/lib/wx/core/window.rb +48 -2
  60. data/lib/wx/core/xmlresource.rb +4 -4
  61. data/lib/wx/core.rb +2 -0
  62. data/lib/wx/doc/evthandler.rb +1 -0
  63. data/lib/wx/doc/tip_window.rb +22 -0
  64. data/lib/wx/grid/grid.rb +3 -3
  65. data/lib/wx/grid/require.rb +0 -2
  66. data/lib/wx/html/htmlhelpcontroller.rb +1 -1
  67. data/lib/wx/html/htmlwindow.rb +1 -1
  68. data/lib/wx/html/require.rb +0 -2
  69. data/lib/wx/html/simple_html_listbox.rb +3 -3
  70. data/lib/wx/keyword_ctors.rb +14 -7
  71. data/lib/wx/keyword_defs.rb +7 -7
  72. data/lib/wx/pg/pg_properties.rb +1 -1
  73. data/lib/wx/pg/pg_property.rb +3 -3
  74. data/lib/wx/pg/property_grid.rb +2 -2
  75. data/lib/wx/pg/property_grid_interface.rb +2 -2
  76. data/lib/wx/pg/require.rb +0 -2
  77. data/lib/wx/prt/previewframe.rb +1 -1
  78. data/lib/wx/prt/require.rb +0 -2
  79. data/lib/wx/rbn/ribbon_control.rb +1 -1
  80. data/lib/wx/rbn/ribbon_page.rb +1 -1
  81. data/lib/wx/rbn/ribbon_panel.rb +1 -1
  82. data/lib/wx/rtc/require.rb +0 -2
  83. data/lib/wx/rtc/rich_text_composite_object.rb +1 -1
  84. data/lib/wx/rtc/rich_text_ctrl.rb +1 -1
  85. data/lib/wx/rtc/rich_text_paragraph.rb +1 -1
  86. data/lib/wx/rtc/richtext_buffer.rb +3 -3
  87. data/lib/wx/rtc/richtext_formatting_dialog.rb +2 -2
  88. data/lib/wx/rtc/richtext_style_organiser_dialog.rb +1 -1
  89. data/lib/wx/rtc/symbol_picker_dialog.rb +1 -1
  90. data/lib/wx/stc/require.rb +0 -2
  91. data/lib/wx/stc/styled_text_ctrl.rb +1 -1
  92. data/lib/wx/version.rb +1 -1
  93. data/lib/wx/wxruby/base.rb +8 -2
  94. data/lib/wx/wxruby/cmd/setup.rb +61 -37
  95. data/rakelib/gem.rb +8 -4
  96. data/rakelib/lib/config/mingw.rb +1 -1
  97. data/rakelib/lib/director/about_dialog_info.rb +1 -0
  98. data/rakelib/lib/director/aui_manager.rb +63 -57
  99. data/rakelib/lib/director/aui_notebook.rb +7 -0
  100. data/rakelib/lib/director/colour.rb +1 -1
  101. data/rakelib/lib/director/data_format.rb +1 -1
  102. data/rakelib/lib/director/event.rb +1 -0
  103. data/rakelib/lib/director/event_handler.rb +82 -46
  104. data/rakelib/lib/director/functions.rb +0 -3
  105. data/rakelib/lib/director/list_ctrl.rb +14 -10
  106. data/rakelib/lib/director/locale.rb +2 -0
  107. data/rakelib/lib/director/num_validator.rb +7 -0
  108. data/rakelib/lib/director/tip_window.rb +34 -0
  109. data/rakelib/lib/director/window.rb +9 -1
  110. data/rakelib/lib/director.rb +0 -1
  111. data/rakelib/lib/generate/doc/evt_handler.yaml +31 -12
  112. data/rakelib/lib/specs/interfaces.rb +1 -0
  113. data/tests/test_combo_ctrl.rb +1 -0
  114. data/tests/test_event_handling.rb +158 -31
  115. metadata +6 -5
data/lib/wx/core.rb CHANGED
@@ -38,6 +38,8 @@ require 'wx/global_const'
38
38
  # ctor syntax sweeteners support
39
39
  require 'wx/keyword_ctors'
40
40
 
41
+ require 'wx/core/module_ext'
42
+
41
43
  # Load in all the class extension methods written in ruby
42
44
  # evthandler must be required first b/c it sets up methods modified elsewhere
43
45
  require 'wx/core/evthandler.rb'
@@ -143,6 +143,7 @@ module Wx
143
143
  def call_after(meth = nil, *args, &block) end
144
144
 
145
145
  # Process a {Wx::EVT_HOTKEY} event.
146
+ # @wxrb_require WXOSX|WXMSW
146
147
  # @param [Integer] id hotkey id
147
148
  # @param [String,Symbol,Method,Proc] meth (name of) method or handler proc
148
149
  # @yieldparam [Wx::KeyEvent] event the event to handle
@@ -0,0 +1,22 @@
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 TipWindow < Wx::Window
11
+
12
+ # Constructor.
13
+ #
14
+ # The tip is shown immediately after the window is constructed.
15
+ # @param [Wx::Window] parent The parent window, must be non-nil
16
+ # @param [String] text The text to show, may contain the new line characters
17
+ # @param [Integer] max_length The length of each line, in pixels. Set to a very large value to avoid wrapping lines.
18
+ def initialize(parent, text, max_length = 100); end
19
+
20
+ end
21
+
22
+ end
data/lib/wx/grid/grid.rb CHANGED
@@ -13,7 +13,7 @@ module Wx
13
13
  alias :table= :assign_table
14
14
 
15
15
  wx_each_selected_block = instance_method :each_selected_block
16
- define_method :each_selected_block do
16
+ wx_redefine_method :each_selected_block do
17
17
  if block_given?
18
18
  wx_each_selected_block.bind(self).call
19
19
  else
@@ -27,7 +27,7 @@ module Wx
27
27
  alias :selected_blocks :get_selected_blocks
28
28
 
29
29
  wx_each_selected_row_block = instance_method :each_selected_row_block
30
- define_method :each_selected_row_block do
30
+ wx_redefine_method :each_selected_row_block do
31
31
  if block_given?
32
32
  wx_each_selected_row_block.bind(self).call
33
33
  else
@@ -36,7 +36,7 @@ module Wx
36
36
  end
37
37
 
38
38
  wx_each_selected_col_block = instance_method :each_selected_col_block
39
- define_method :each_selected_col_block do
39
+ wx_redefine_method :each_selected_col_block do
40
40
  if block_given?
41
41
  wx_each_selected_col_block.bind(self).call
42
42
  else
@@ -8,5 +8,3 @@
8
8
  require_relative './events/evt_list'
9
9
  require_relative './keyword_defs'
10
10
  require_relative './grid'
11
-
12
- Wx::Dialog.setup_dialog_functors(Wx::GRID)
@@ -14,7 +14,7 @@ module Wx
14
14
 
15
15
  # cache any explicitly assigned config for GC protection
16
16
  wx_use_config = instance_method(:use_config)
17
- define_method :use_config do |cfg, *args|
17
+ wx_redefine_method :use_config do |cfg, *args|
18
18
  @configuration = cfg
19
19
  if get_help_window
20
20
  # also set config var for any associated help window (as wxWidgets propagates it too)
@@ -17,7 +17,7 @@ module Wx
17
17
  private :html_filters
18
18
 
19
19
  wx_add_filter = instance_method(:add_filter)
20
- define_method(:add_filter) do |filter|
20
+ wx_redefine_method(:add_filter) do |filter|
21
21
  html_filters << filter
22
22
  wx_add_filter.bind(self).call(filter)
23
23
  end
@@ -10,5 +10,3 @@ require_relative './keyword_defs'
10
10
  require_relative './htmlwindow'
11
11
  require_relative './htmlhelpcontroller'
12
12
  require_relative './simple_html_listbox'
13
-
14
- Wx::Dialog.setup_dialog_functors(Wx::HTML)
@@ -6,7 +6,7 @@ class Wx::HTML::SimpleHtmlListBox
6
6
 
7
7
  # make sure to honor the inherited common overloads
8
8
  wx_get_client_object = instance_method :get_client_object
9
- define_method :get_client_object do |*args|
9
+ wx_redefine_method :get_client_object do |*args|
10
10
  if args.empty?
11
11
  super()
12
12
  else
@@ -14,7 +14,7 @@ class Wx::HTML::SimpleHtmlListBox
14
14
  end
15
15
  end
16
16
  wx_set_client_object = instance_method :set_client_object
17
- define_method :set_client_object do |*args|
17
+ wx_redefine_method :set_client_object do |*args|
18
18
  if args.size < 2
19
19
  super(*args)
20
20
  else
@@ -30,7 +30,7 @@ class Wx::HTML::SimpleHtmlListBox
30
30
 
31
31
  # Overload to provide Enumerator without block
32
32
  wx_each_string = instance_method :each_string
33
- define_method :each_string do |&block|
33
+ wx_redefine_method :each_string do |&block|
34
34
  if block
35
35
  wx_each_string.bind(self).call(&block)
36
36
  else
@@ -70,6 +70,13 @@ module Wx
70
70
  # This module defines an inheritable class attribute like the ones defined
71
71
  # by the Rails #class_attribute method.
72
72
  module ParamSpec
73
+
74
+ if RUBY_VERSION < '2.7.0'
75
+ PARAM_SPEC_ARG = [:param_spec]
76
+ else
77
+ PARAM_SPEC_ARG = [:param_spec, false]
78
+ end
79
+
73
80
  def self.included(mod)
74
81
  mod.class_eval do
75
82
  def self.param_spec
@@ -82,9 +89,9 @@ module Wx
82
89
 
83
90
  def self.param_spec=(val)
84
91
  singleton_class.class_eval do
85
- if method_defined?(:param_spec) || private_method_defined?(:param_spec)
92
+ if method_defined?(*PARAM_SPEC_ARG) || private_method_defined?(*PARAM_SPEC_ARG)
86
93
  begin
87
- remove_method(:param_spec);
94
+ remove_method(:param_spec)
88
95
  rescue NameError;
89
96
  end
90
97
  end
@@ -93,9 +100,9 @@ module Wx
93
100
 
94
101
  if singleton_class?
95
102
  class_eval do
96
- if method_defined?(:param_spec) || private_method_defined?(:param_spec)
103
+ if method_defined?(*PARAM_SPEC_ARG) || private_method_defined?(*PARAM_SPEC_ARG)
97
104
  begin
98
- remove_method(:param_spec);
105
+ remove_method(:param_spec)
99
106
  rescue NameError;
100
107
  end
101
108
  end
@@ -108,9 +115,9 @@ module Wx
108
115
  val
109
116
  end
110
117
 
111
- if method_defined?(:param_spec) || private_method_defined?(:param_spec)
118
+ if method_defined?(*PARAM_SPEC_ARG) || private_method_defined?(*PARAM_SPEC_ARG)
112
119
  begin
113
- remove_method(:param_spec);
120
+ remove_method(:param_spec)
114
121
  rescue NameError;
115
122
  end
116
123
  end
@@ -191,7 +198,7 @@ module Wx
191
198
  # The new definition of initialize; accepts a parent arg
192
199
  # mixed_args, which may zero or more position args, optionally
193
200
  # terminated with hash keyword args, and an optional block
194
- def initialize(parent = :default_ctor, *mixed_args, &block)
201
+ wx_redefine_method :initialize do |parent = :default_ctor, *mixed_args, &block|
195
202
  # allow zero-args ctor for use with XRC
196
203
  if parent == :default_ctor
197
204
  pre_wx_kwctor_init
@@ -61,13 +61,13 @@ end
61
61
  # MISCELLANEOUS WINDOWS
62
62
 
63
63
  # OpenGL Canvas
64
- Wx::define_keyword_ctors('GLCanvas') do
65
- wx_ctor_params :id
66
- wx_ctor_params :pos, :size, :style => Wx::FULL_REPAINT_ON_RESIZE
67
- wx_ctor_params :name => 'GLCanvas'
68
- wx_ctor_params :attrib_list => [Wx::GL_RGBA, Wx::GL_DOUBLEBUFFER]
69
- wx_ctor_params :palette => Wx::NULL_PALETTE
70
- end
64
+ # Wx::define_keyword_ctors('GLCanvas') do
65
+ # wx_ctor_params :id
66
+ # wx_ctor_params :pos, :size, :style => Wx::FULL_REPAINT_ON_RESIZE
67
+ # wx_ctor_params :name => 'GLCanvas'
68
+ # wx_ctor_params :attrib_list => [Wx::GL_RGBA, Wx::GL_DOUBLEBUFFER]
69
+ # wx_ctor_params :palette => Wx::NULL_PALETTE
70
+ # end
71
71
 
72
72
  # A window whose colour changes according to current user settings
73
73
  Wx::define_keyword_ctors(Wx::Panel) do
@@ -10,7 +10,7 @@ module Wx::PG
10
10
 
11
11
  # add some 'smart' conversions
12
12
  wx_initialize = instance_method :initialize
13
- define_method :initialize do |label=Wx::PG_LABEL, name=Wx::PG_LABEL, value=Wx::PG::ColourPropertyValue.new|
13
+ wx_redefine_method :initialize do |label=Wx::PG_LABEL, name=Wx::PG_LABEL, value=Wx::PG::ColourPropertyValue.new|
14
14
  value = case value
15
15
  when Wx::Colour
16
16
  Wx::PG::ColourPropertyValue.new(value)
@@ -29,7 +29,7 @@ module Wx::PG
29
29
  class PGProperty
30
30
 
31
31
  wx_each_attribute = instance_method :each_attribute
32
- define_method :each_attribute do
32
+ wx_redefine_method :each_attribute do
33
33
  if block_given?
34
34
  wx_each_attribute.bind(self).call
35
35
  else
@@ -52,7 +52,7 @@ module Wx::PG
52
52
  class PGChoices
53
53
 
54
54
  wx_each_label = instance_method :each_label
55
- define_method :each_label do
55
+ wx_redefine_method :each_label do
56
56
  if block_given?
57
57
  wx_each_label.bind(self).call
58
58
  else
@@ -61,7 +61,7 @@ module Wx::PG
61
61
  end
62
62
 
63
63
  wx_each_entry = instance_method :each_entry
64
- define_method :each_entry do
64
+ wx_redefine_method :each_entry do
65
65
  if block_given?
66
66
  wx_each_entry.bind(self).call
67
67
  else
@@ -29,7 +29,7 @@ module Wx::PG
29
29
  private :property_editors
30
30
 
31
31
  wx_do_register_editor_class = self.instance_method(:do_register_editor_class)
32
- define_method(:do_register_editor_class) do |editor_class, name|
32
+ wx_redefine_method(:do_register_editor_class) do |editor_class, name|
33
33
  editor = wx_do_register_editor_class.bind(self).call(editor_class, name)
34
34
  property_editors[name] = editor # keep safe from GC and for lookup
35
35
  end
@@ -44,7 +44,7 @@ module Wx::PG
44
44
  end
45
45
 
46
46
  wx_set_sorter = instance_method :set_sorter
47
- define_method :set_sorter do |meth, &block|
47
+ wx_redefine_method :set_sorter do |meth, &block|
48
48
  h_sorter = if block and not meth
49
49
  block
50
50
  elsif meth and not block
@@ -20,7 +20,7 @@ module Wx::PG
20
20
  module PropertyGridInterface
21
21
 
22
22
  wx_each_property = instance_method :each_property
23
- define_method :each_property do |flags = Wx::PG::PG_ITERATE_DEFAULT, start = nil, reverse: false, &block|
23
+ wx_redefine_method :each_property do |flags = Wx::PG::PG_ITERATE_DEFAULT, start = nil, reverse: false, &block|
24
24
  if block
25
25
  wx_each_property.bind(self).call(flags.to_int, start, reverse, &block)
26
26
  else
@@ -35,7 +35,7 @@ module Wx::PG
35
35
  alias :properties_reversed :reverse_each_property
36
36
 
37
37
  wx_each_property_attribute = instance_method :each_property_attribute
38
- define_method :each_property_attribute do |id, &block|
38
+ wx_redefine_method :each_property_attribute do |id, &block|
39
39
  if block
40
40
  wx_each_property_attribute.bind(self).call(id, &block)
41
41
  else
data/lib/wx/pg/require.rb CHANGED
@@ -11,5 +11,3 @@ require_relative './property_grid'
11
11
  require_relative './pg_property'
12
12
  require_relative './pg_properties'
13
13
  require_relative './pg_editor'
14
-
15
- Wx::Dialog.setup_dialog_functors(Wx::PG)
@@ -11,7 +11,7 @@ class Wx::PRT::PreviewFrame
11
11
  # to assign it to an instance variable so it is marked correctly when
12
12
  # the frame displaying it is marked.
13
13
  wx_init = self.instance_method(:initialize)
14
- define_method(:initialize) do | *args |
14
+ wx_redefine_method(:initialize) do | *args |
15
15
  wx_init.bind(self).call(*args)
16
16
  @__preview = args[0]
17
17
  end
@@ -7,5 +7,3 @@
7
7
  require_relative './keyword_defs'
8
8
  require_relative './previewframe'
9
9
  require_relative './page_setup_dialog'
10
-
11
- Wx::Dialog.setup_dialog_functors(Wx::PRT)
@@ -6,7 +6,7 @@ class Wx::RBN::RibbonControl
6
6
 
7
7
  # manage RibbonArtProvider for GC
8
8
  wx_set_art_provider = instance_method :set_art_provider
9
- define_method :set_art_provider do |prov|
9
+ wx_redefine_method :set_art_provider do |prov|
10
10
  @art_provider = nil # clear any previously set
11
11
  wx_set_art_provider.bind(self).call(prov)
12
12
  if prov != get_ancestor_ribbon_bar.get_art_provider
@@ -6,7 +6,7 @@ class Wx::RBN::RibbonPage
6
6
 
7
7
  # manage RibbonArtProvider for GC
8
8
  wx_set_art_provider = instance_method :set_art_provider
9
- define_method :set_art_provider do |prov|
9
+ wx_redefine_method :set_art_provider do |prov|
10
10
  @art_provider = nil # clear any previously set
11
11
  wx_set_art_provider.bind(self).call(prov)
12
12
  if prov != get_ancestor_ribbon_bar.get_art_provider
@@ -6,7 +6,7 @@ class Wx::RBN::RibbonPanel
6
6
 
7
7
  # manage RibbonArtProvider for GC
8
8
  wx_set_art_provider = instance_method :set_art_provider
9
- define_method :set_art_provider do |prov|
9
+ wx_redefine_method :set_art_provider do |prov|
10
10
  @art_provider = nil # clear any previously set
11
11
  wx_set_art_provider.bind(self).call(prov)
12
12
  if prov != get_ancestor_ribbon_bar.get_art_provider
@@ -14,5 +14,3 @@ require_relative './rich_text_paragraph'
14
14
  require_relative './richtext_formatting_dialog'
15
15
  require_relative './symbol_picker_dialog'
16
16
  require_relative './richtext_style_organiser_dialog'
17
-
18
- Wx::Dialog.setup_dialog_functors(Wx::RTC)
@@ -10,7 +10,7 @@ module Wx
10
10
 
11
11
  # Overload to provide Enumerator without block
12
12
  wx_each_child = instance_method :each_child
13
- define_method :each_child do |&block|
13
+ wx_redefine_method :each_child do |&block|
14
14
  if block
15
15
  wx_each_child.bind(self).call(&block)
16
16
  else
@@ -10,7 +10,7 @@ module Wx
10
10
 
11
11
  # Overload to provide Enumerator without block
12
12
  wx_each_line = instance_method :each_line
13
- define_method :each_line do |&block|
13
+ wx_redefine_method :each_line do |&block|
14
14
  if block
15
15
  wx_each_line.bind(self).call(&block)
16
16
  else
@@ -10,7 +10,7 @@ module Wx
10
10
 
11
11
  # Overload to provide Enumerator without block
12
12
  wx_each_line = instance_method :each_line
13
- define_method :each_line do |&block|
13
+ wx_redefine_method :each_line do |&block|
14
14
  if block
15
15
  wx_each_line.bind(self).call(&block)
16
16
  else
@@ -6,7 +6,7 @@ class Wx::RTC::RichTextBuffer
6
6
 
7
7
  class << self
8
8
  wx_each_handler = instance_method :each_handler
9
- define_method :each_handler do |&block|
9
+ wx_redefine_method :each_handler do |&block|
10
10
  if block_given?
11
11
  wx_each_handler.bind(self).call(&block)
12
12
  else
@@ -15,7 +15,7 @@ class Wx::RTC::RichTextBuffer
15
15
  end
16
16
 
17
17
  wx_each_field_type = instance_method :each_field_type
18
- define_method :each_field_type do |&block|
18
+ wx_redefine_method :each_field_type do |&block|
19
19
  if block_given?
20
20
  wx_each_field_type.bind(self).call(&block)
21
21
  else
@@ -24,7 +24,7 @@ class Wx::RTC::RichTextBuffer
24
24
  end
25
25
 
26
26
  wx_each_drawing_handler = instance_method :each_drawing_handler
27
- define_method :each_drawing_handler do |&block|
27
+ wx_redefine_method :each_drawing_handler do |&block|
28
28
  if block_given?
29
29
  wx_each_drawing_handler.bind(self).call(&block)
30
30
  else
@@ -8,7 +8,7 @@ module Wx::RTC
8
8
  class << self
9
9
 
10
10
  wx_set_formatting_dialog_factory = instance_method :set_formatting_dialog_factory
11
- define_method :set_formatting_dialog_factory do |factory|
11
+ wx_redefine_method :set_formatting_dialog_factory do |factory|
12
12
  wx_set_formatting_dialog_factory.bind(self).call(factory)
13
13
  @factory = factory # cache here to prevent GC collection
14
14
  end
@@ -23,7 +23,7 @@ module Wx::RTC
23
23
  end
24
24
 
25
25
  # now redefine the overridden ctor to account for deviating arglist
26
- def initialize(flags = nil, parent = nil, *mixed_args, &block)
26
+ wx_redefine_method :initialize do |flags = nil, parent = nil, *mixed_args, &block|
27
27
  # allow zero-args ctor for use with XRC
28
28
  if flags.nil?
29
29
  pre_wx_kwctor_init
@@ -12,7 +12,7 @@ class Wx::RTC::RichTextStyleOrganiserDialog
12
12
  end
13
13
 
14
14
  # now redefine the overridden ctor to account for deviating arglist
15
- def initialize(flags, sheet, ctrl, parent = nil, *mixed_args, &block)
15
+ wx_redefine_method :initialize do |flags, sheet, ctrl, parent = nil, *mixed_args, &block|
16
16
  real_args = begin
17
17
  [ flags, sheet, ctrl, parent ] + self.class.args_as_list(*mixed_args)
18
18
  rescue => err
@@ -13,7 +13,7 @@ class Wx::RTC::SymbolPickerDialog
13
13
  end
14
14
 
15
15
  # now redefine the overridden ctor to account for deviating arglist
16
- def initialize(symbol, initialFont, normalTextFont, parent = nil, *mixed_args, &block)
16
+ wx_redefine_method :initialize do |symbol, initialFont, normalTextFont, parent = nil, *mixed_args, &block|
17
17
  real_args = begin
18
18
  [ symbol, initialFont, normalTextFont, parent ] + self.class.args_as_list(*mixed_args)
19
19
  rescue => err
@@ -7,5 +7,3 @@
7
7
  require_relative './events/evt_list'
8
8
  require_relative './keyword_defs'
9
9
  require_relative './styled_text_ctrl'
10
-
11
- Wx::Dialog.setup_dialog_functors(Wx::STC)
@@ -10,7 +10,7 @@ module Wx
10
10
 
11
11
  # Overload to provide Enumerator without block
12
12
  wx_each_line = instance_method :each_line
13
- define_method :each_line do |&block|
13
+ wx_redefine_method :each_line do |&block|
14
14
  if block
15
15
  wx_each_line.bind(self).call(&block)
16
16
  else
data/lib/wx/version.rb CHANGED
@@ -3,5 +3,5 @@
3
3
  # This software is released under the MIT license.
4
4
 
5
5
  module Wx
6
- WXRUBY_VERSION = '1.3.1'
6
+ WXRUBY_VERSION = '1.4.2'
7
7
  end
@@ -55,6 +55,10 @@ module WxRuby
55
55
  puts
56
56
  end
57
57
 
58
+ def show_version
59
+ system(%Q[#{RUBY} -r wx -e 'puts "wxRuby3 v\#{Wx::WXRUBY_VERSION} (wxWidgets v\#{Wx::WXWIDGETS_VERSION})"' 2> /dev/null])
60
+ end
61
+
58
62
  def run(cmdid, args)
59
63
  commands[cmdid.to_s].call(args)
60
64
  end
@@ -65,9 +69,11 @@ module WxRuby
65
69
  " COMMAND\t\t\t\tSpecifies wxruby command to execute."
66
70
  opts.separator ''
67
71
  opts.on('-v', '--verbose',
68
- 'Show verbose output') { |v| ::WxRuby::Commands.options[:verbose] = true }
72
+ 'Show verbose output') { |_| ::WxRuby::Commands.options[:verbose] = true }
73
+ opts.on('-V', '--version',
74
+ 'Show versions.') { |_| show_version } if setup_done?
69
75
  opts.on('-h', '--help',
70
- 'Show this message.') do |v|
76
+ 'Show this message.') do |_|
71
77
  puts opts
72
78
  puts
73
79
  describe_all
@@ -6,6 +6,7 @@
6
6
  #--------------------------------------------------------------------
7
7
 
8
8
  require 'fileutils'
9
+ require 'json'
9
10
 
10
11
  module WxRuby
11
12
  module Commands
@@ -55,6 +56,16 @@ module WxRuby
55
56
  opts.parse!(args) rescue ($stderr.puts $!.message; exit(127))
56
57
  end
57
58
 
59
+ class << self
60
+
61
+ private
62
+
63
+ def check_wx_config
64
+ !(`which #{@wx_config} 2>/dev/null`).chomp.empty?
65
+ end
66
+
67
+ end
68
+
58
69
  def self.run(argv)
59
70
  return description if argv == :describe
60
71
 
@@ -74,48 +85,61 @@ module WxRuby
74
85
  cfg_cmd = 'rake configure'
75
86
  cfg_cmd << "[#{cfg_args.join(',')}]" unless cfg_args.empty?
76
87
 
77
- result = false
78
- FileUtils.chdir(WxRuby::ROOT) do
79
- steps = 0
80
- actions_txt = if Setup.options['autoinstall'] != false
81
- steps = 1
82
- '(possibly) install required software'
83
- else
84
- ''
85
- end
86
- if Setup.options['with-wxwin'] || Setup.options['wxwin'].nil?
87
- actions_txt << ', ' if steps>0
88
- actions_txt << 'build the wxWidgets libraries (if needed), '
89
- actions_txt << "\n" if steps>0
90
- steps += 1
88
+ log_file = File.join(WxRuby::ROOT, 'setup.log')
89
+ if Setup.options['log']
90
+ if File.directory?(Setup.options['log']) && File.writable?(Setup.options['log'])
91
+ log_file = File.join(Setup.options['log'], 'setup.log')
91
92
  else
92
- actions_txt << ',' if steps>0
93
+ $stderr.puts "ERROR: cannot write log to #{Setup.options['log']}. Log path must exist and be writable."
94
+ exit(1)
93
95
  end
94
- actions_txt << 'build the native wxRuby3 extensions '
95
- actions_txt << "\n" if steps==1
96
- actions_txt << 'and generate the wxRuby3 reference documentation.'
97
- $stdout.puts <<~__INFO_TXT
98
-
99
- ---
100
- Now running wxRuby3 post-install setup.
101
- This will #{actions_txt}
102
- Please be patient as this may take quite a while depending on your system.
103
- ---
104
-
105
- __INFO_TXT
106
- log_file = File.join(WxRuby::ROOT, 'setup.log')
107
- if Setup.options['log']
108
- if File.directory?(Setup.options['log']) && File.writable?(Setup.options['log'])
109
- log_file = File.join(Setup.options['log'], 'setup.log')
96
+ end
97
+ run_env = {'WXRUBY_RUN_SILENT' => "#{log_file}"}
98
+ run_env['WXRUBY_VERBOSE'] = '1' if Setup.options[:verbose]
99
+
100
+ result = false
101
+
102
+ FileUtils.chdir(WxRuby::ROOT) do
103
+ # first run the configure command
104
+ result = system(run_env, "#{cfg_cmd}")
105
+
106
+ # if succeeded
107
+ if result
108
+ # load the wxRuby3 build config
109
+ build_cfg = ::JSON.load(File.read('.wxconfig'))
110
+
111
+ # now determine the steps to execute
112
+ steps = 0
113
+ actions_txt = if Setup.options['autoinstall'] != false
114
+ steps = 1
115
+ '(possibly) install required software'
116
+ else
117
+ ''
118
+ end
119
+ if build_cfg['with-wxwin'] || (!build_cfg['wxwin'].to_s.empty? && build_cfg['wxwin'].to_s != '@system')
120
+ actions_txt << ', ' if steps>0
121
+ actions_txt << 'build the wxWidgets libraries, '
122
+ actions_txt << "\n" if steps>0
123
+ steps += 1
110
124
  else
111
- $stderr.puts "ERROR: cannot write log to #{Setup.options['log']}. Log path must exist and be writable."
112
- exit(1)
125
+ actions_txt << ',' if steps>0
113
126
  end
127
+ actions_txt << 'build the native wxRuby3 extensions '
128
+ actions_txt << "\n" if steps==1
129
+ actions_txt << 'and generate the wxRuby3 reference documentation.'
130
+ $stdout.puts <<~__INFO_TXT
131
+
132
+ ---
133
+ Now running wxRuby3 post-install setup.
134
+ This will #{actions_txt}
135
+ Please be patient as this may take quite a while depending on your system.
136
+ (#{steps >= 2 ? '10-15' : '5-10'} min on a modern PC with multicore CPU but longer with older/slower CPUs)
137
+ ---
138
+
139
+ __INFO_TXT
140
+ # can't rely on FileUtils#chdir returning the block result (bug in older Rubies) so assign result here
141
+ result = system(run_env, "rake -m wxruby:gem:setup#{Setup.options['log'] ? '[:keep_log]' : ''} && gem rdoc wxruby3 --overwrite")
114
142
  end
115
- run_env = {'WXRUBY_RUN_SILENT' => "#{log_file}"}
116
- run_env['WXRUBY_VERBOSE'] = '1' if Setup.options[:verbose]
117
- # can't rely on FileUtils#chdir returning the block result (bug in older Rubies) so assign result here
118
- result = system(run_env, "#{cfg_cmd} && rake -m wxruby:gem:setup#{Setup.options['log'] ? '[:keep_log]' : ''} && gem rdoc wxruby3 --overwrite")
119
143
  end
120
144
  exit(result ? 0 : 1)
121
145
  end