wxruby3 1.2.1 → 1.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (66) hide show
  1. checksums.yaml +4 -4
  2. data/ext/wxruby3/swig/custom/director.swg +16 -22
  3. data/ext/wxruby3/swig/custom/rubyapi.swg +15 -1
  4. data/lib/wx/aui/auimanager.rb +61 -14
  5. data/lib/wx/core/animation.rb +35 -14
  6. data/lib/wx/core/array_ext.rb +1 -0
  7. data/lib/wx/core/brush.rb +8 -0
  8. data/lib/wx/core/choicedlg.rb +7 -10
  9. data/lib/wx/core/colour.rb +10 -0
  10. data/lib/wx/core/defs.rb +49 -0
  11. data/lib/wx/core/dialog.rb +2 -2
  12. data/lib/wx/core/enum.rb +16 -3
  13. data/lib/wx/core/event.rb +7 -0
  14. data/lib/wx/core/file_dialog.rb +25 -0
  15. data/lib/wx/core/font.rb +14 -0
  16. data/lib/wx/core/gdi_object.rb +24 -0
  17. data/lib/wx/core/hboxsizer.rb +24 -4
  18. data/lib/wx/core/object.rb +26 -11
  19. data/lib/wx/core/pen.rb +20 -0
  20. data/lib/wx/core/real_point.rb +1 -0
  21. data/lib/wx/core/sizer.rb +166 -39
  22. data/lib/wx/core/variant.rb +108 -51
  23. data/lib/wx/core/vboxsizer.rb +24 -4
  24. data/lib/wx/doc/array_ext.rb +1 -0
  25. data/lib/wx/doc/aui/auimanager.rb +2 -0
  26. data/lib/wx/doc/colour.rb +12 -0
  27. data/lib/wx/doc/enum.rb +26 -0
  28. data/lib/wx/doc/evthandler.rb +6 -0
  29. data/lib/wx/doc/functions.rb +35 -3
  30. data/lib/wx/doc/gdi_common.rb +1 -0
  31. data/lib/wx/doc/gdi_object.rb +22 -0
  32. data/lib/wx/doc/object.rb +24 -0
  33. data/lib/wx/doc/variant.rb +8 -0
  34. data/lib/wx/helpers.rb +2 -3
  35. data/lib/wx/keyword_defs.rb +7 -0
  36. data/lib/wx/version.rb +1 -1
  37. data/rakelib/lib/config.rb +1 -1
  38. data/rakelib/lib/core/include/funcall.inc +9 -24
  39. data/rakelib/lib/core/include/swigdirector.inc +29 -11
  40. data/rakelib/lib/core/include/swigrubyrun.inc +2 -2
  41. data/rakelib/lib/director/animation_ctrl.rb +6 -0
  42. data/rakelib/lib/director/aui_manager.rb +118 -3
  43. data/rakelib/lib/director/defs.rb +3 -0
  44. data/rakelib/lib/director/dialog.rb +17 -7
  45. data/rakelib/lib/director/file_dialog_customize_hook.rb +77 -1
  46. data/rakelib/lib/director/functions.rb +0 -12
  47. data/rakelib/lib/director/pgproperties.rb +2 -2
  48. data/rakelib/lib/director/property_grid_interface.rb +4 -3
  49. data/rakelib/lib/director/textctrl.rb +7 -0
  50. data/rakelib/lib/director/validator.rb +7 -42
  51. data/rakelib/lib/director/variant.rb +2 -2
  52. data/rakelib/lib/extractor/function.rb +5 -0
  53. data/rakelib/lib/generate/doc/credential_entry_dialog.yaml +10 -0
  54. data/rakelib/lib/generate/doc/generic_about_dialog.yaml +46 -0
  55. data/rakelib/lib/specs/interfaces.rb +2 -0
  56. data/rakelib/lib/swig_runner.rb +6 -3
  57. data/rakelib/lib/typemap/common.rb +2 -2
  58. data/rakelib/lib/util/string.rb +7 -6
  59. data/samples/animate/anitest.rb +13 -9
  60. data/samples/dialogs/dialogs.rb +1 -1
  61. data/tests/lib/leaked_overload_exception_test.rb +25 -0
  62. data/tests/lib/leaked_process_event_exception_test.rb +33 -0
  63. data/tests/lib/leaked_queued_event_exception_test.rb +34 -0
  64. data/tests/lib/overload_type_exception_test.rb +25 -0
  65. data/tests/test_exceptions.rb +24 -24
  66. metadata +13 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c44502717c4bc43863f96c826432224a7cc81063d3768dcffa8a92c7bbead181
4
- data.tar.gz: c002fc5f501cba71fa127585102916daca951424e986a265e740e7ca9cbc6e9e
3
+ metadata.gz: c43cace6f097af04e2d856782258313acd4e340719cf7794db36534e6d5e644b
4
+ data.tar.gz: 2f93d3489b95ca1a49ce2734222088aab5574841dd337d19fef58ec7a84587fb
5
5
  SHA512:
6
- metadata.gz: bdd8149612a7ef5637362c5e27a821afe3cd6f1f03c92c00529ab3df12e427a73af97aa1ffa6f89281e7ff259861aed925f3b737ff49bc7564f92b6369b97550
7
- data.tar.gz: dcce12022c263d4b5955b2417ab415460f38e5d0418e0c53d64d677c9c9352de5e1ff3b53a7318066b8e8c0b4ff47bf6fefb27ae194e0955801aac0edf99cd59
6
+ metadata.gz: 1db323073fdde9896d9ea6d8ffb9dee71e3f52f52d2836603ff5e6f7274003bb252bc4cff832574454ad4390686a79b1ef01467d5e3b7362aad36d464c67f5ac
7
+ data.tar.gz: 0057e4f8462c5b4e2dd79e736ca417cea70305b38efdc796bcc32a8f22fd12d178824ebe92e5d4cca219e1e1dbcafcb9200b5d00d7052d89ddd8f905729af4a0
@@ -147,20 +147,14 @@ namespace Swig {
147
147
 
148
148
  DirectorTypeMismatchException(VALUE self, const char *method, VALUE error, const char *msg="");
149
149
 
150
- static inline void raise(VALUE error, const char *msg)
151
- {
152
- throw DirectorTypeMismatchException(error, msg);
153
- }
150
+ static void raise(VALUE error, const char *msg);
154
151
 
155
- static inline void raise(const char *msg)
156
- {
157
- throw DirectorTypeMismatchException(msg);
158
- }
152
+ static void raise(const char *msg);
159
153
 
160
- static inline void raise(VALUE self, const char* method, VALUE error, const char *msg)
161
- {
162
- throw DirectorTypeMismatchException(self, method, error, msg);
163
- }
154
+ static void raise(VALUE self, const char* method, VALUE error, const char *msg);
155
+
156
+ private:
157
+ static void print(const DirectorTypeMismatchException& ex);
164
158
  };
165
159
 
166
160
  /* Any Ruby exception that occurs during a director method call */
@@ -195,13 +189,8 @@ namespace Swig {
195
189
  }
196
190
  };
197
191
 
198
- /* wxRuby customization */
199
- class WXRUBY_EXPORT DirectorRubyException : public DirectorException
200
- {
201
- public:
202
- DirectorRubyException(VALUE error, VALUE rcvr, ID fn_id);
203
-
204
- };
192
+ // SWIG < 4.3.0
193
+ #if SWIG_VERSION < 0x040300
205
194
 
206
195
  /* Simple thread abstraction for pthreads on win32 */
207
196
  #ifdef __THREAD__
@@ -233,8 +222,14 @@ namespace Swig {
233
222
  }
234
223
  };
235
224
  # define SWIG_GUARD(mutex) Guard _guard(mutex)
225
+ # define SWIG_GUARD_DEFINITION(_cls, _mutex) pthread_mutex_t _cls::_mutex
226
+ # define SWIG_GUARD_DECLARATION(_mutex) static pthread_mutex_t _mutex
236
227
  #else
237
228
  # define SWIG_GUARD(mutex)
229
+ # define SWIG_GUARD_DEFINITION(_cls, _mutex)
230
+ # define SWIG_GUARD_DECLARATION(_mutex)
231
+ #endif
232
+
238
233
  #endif
239
234
 
240
235
  /* director base class */
@@ -272,9 +267,7 @@ namespace Swig {
272
267
  private:
273
268
  typedef std::map<void *, GCItem_var> swig_ownership_map;
274
269
  mutable swig_ownership_map swig_owner;
275
- #ifdef __PTHREAD__
276
- static pthread_mutex_t swig_mutex_own;
277
- #endif
270
+ SWIG_GUARD_DECLARATION(swig_mutex_own);
278
271
 
279
272
  public:
280
273
  template <typename Type>
@@ -301,4 +294,5 @@ namespace Swig {
301
294
 
302
295
  swig_ruby_owntype swig_release_ownership(void *vptr) const;
303
296
  };
297
+ SWIG_GUARD_DEFINITION(Director, swig_mutex_own);
304
298
  }
@@ -12,8 +12,22 @@ extern "C" {
12
12
  #endif
13
13
 
14
14
  WXRUBY_EXPORT VALUE
15
- SWIG_Ruby_AppendOutput(VALUE target, VALUE o);
15
+ SWIG_wxRuby_AppendOutput(VALUE target, VALUE o, int is_void);
16
16
 
17
17
  #ifdef __cplusplus
18
18
  }
19
19
  #endif
20
+
21
+ /* SWIG >= 4.3.0 version */
22
+ inline VALUE
23
+ SWIG_Ruby_AppendOutput(VALUE target, VALUE o, int is_void)
24
+ {
25
+ return SWIG_wxRuby_AppendOutput(target, o, is_void);
26
+ }
27
+
28
+ /* SWIG < 4.3.0 version */
29
+ inline VALUE
30
+ SWIG_Ruby_AppendOutput(VALUE target, VALUE o)
31
+ {
32
+ return SWIG_wxRuby_AppendOutput(target, o, -1);
33
+ }
@@ -2,19 +2,66 @@
2
2
  #
3
3
  # This software is released under the MIT license.
4
4
 
5
- class Wx::AUI::AuiManager
6
- def get_all_panes
7
- ::Enumerator.new { |y| each_pane { |p| y << p } }
8
- end
9
- alias :all_panes :get_all_panes
10
-
11
- unless Wx::EvtHandler.event_type_for_name(:evt_aui_find_manager)
12
- # missing from XML API refs
13
- Wx::EvtHandler.register_event_type Wx::EvtHandler::EventType[
14
- 'evt_aui_find_manager', 0,
15
- Wx::AUI::EVT_AUI_FIND_MANAGER,
16
- Wx::AUI::AuiManagerEvent
17
- ] if Wx::AUI.const_defined?(:EVT_AUI_FIND_MANAGER)
18
- end
5
+ module Wx
6
+ module AUI
7
+
8
+ class AuiManager
9
+
10
+ wx_each_pane = instance_method(:each_pane)
11
+ define_method(:each_pane) do |&block|
12
+ if block
13
+ wx_each_pane.bind(self).call(&block)
14
+ else
15
+ ::Enumerator.new { |y| wx_each_pane.bind(self).call { |p| y << p } }
16
+ end
17
+ end
18
+
19
+ def get_all_panes
20
+ each_pane.to_a
21
+ end
22
+ alias :all_panes :get_all_panes
23
+
24
+ unless Wx::EvtHandler.event_type_for_name(:evt_aui_find_manager)
25
+ # missing from XML API refs
26
+ Wx::EvtHandler.register_event_type Wx::EvtHandler::EventType[
27
+ 'evt_aui_find_manager', 0,
28
+ Wx::AUI::EVT_AUI_FIND_MANAGER,
29
+ Wx::AUI::AuiManagerEvent
30
+ ] if Wx::AUI.const_defined?(:EVT_AUI_FIND_MANAGER)
31
+ end
32
+ end
33
+
34
+ if WXWIDGETS_VERSION >= '3.3.0'
35
+
36
+ class AuiDockInfo
19
37
 
38
+ wx_each_pane = instance_method(:each_pane)
39
+ define_method(:each_pane) do |&block|
40
+ if block
41
+ wx_each_pane.bind(self).call(&block)
42
+ else
43
+ ::Enumerator.new { |y| wx_each_pane.bind(self).call { |p| y << p } }
44
+ end
45
+ end
46
+
47
+ def get_panes
48
+ each_pane.to_a
49
+ end
50
+ alias :panes :get_panes
51
+
52
+ end
53
+
54
+ class AuiDeserializer
55
+
56
+ wx_initialize = instance_method(:initialize)
57
+ define_method(:initialize) do |manager|
58
+ wx_initialize.bind(self).call(manager)
59
+ @manager = manager # prevent GC for lifetime of deserializer
60
+ end
61
+
62
+ end
63
+
64
+ end
65
+
66
+ end
20
67
  end
@@ -6,21 +6,42 @@
6
6
  # Copyright 2004-2007, wxRuby development team
7
7
  # released under the MIT-like wxRuby2 license
8
8
 
9
- class Wx::Animation
10
- # Redefine the initialize method so it raises an exception if a
11
- # non-existent file is given to the constructor; otherwise, wx Widgets
12
- # just carries on with an empty bitmap, which may cause faults later
13
- wx_init = self.instance_method(:initialize)
14
- define_method(:initialize) do | *args |
15
- if args[0].kind_of? String
16
- if not File.exist?( File.expand_path(args[0]) )
17
- Kernel.raise( ArgumentError,
18
- "Animation file does not exist: #{args[0]}" )
9
+ module Wx
10
+
11
+ class Animation
12
+ # Redefine the initialize method so it raises an exception if a
13
+ # non-existent file is given to the constructor; otherwise, wx Widgets
14
+ # just carries on with an empty bitmap, which may cause faults later
15
+ wx_init = self.instance_method(:initialize)
16
+ define_method(:initialize) do | *args |
17
+ if args[0].kind_of? String
18
+ if not File.exist?( File.expand_path(args[0]) )
19
+ Kernel.raise( ArgumentError,
20
+ "Animation file does not exist: #{args[0]}" )
21
+ end
22
+ res = wx_init.bind(self).call()
23
+ res.load_file(args[0], args[1] || Wx::ANIMATION_TYPE_ANY)
24
+ else
25
+ wx_init.bind(self).call(*args)
26
+ end
27
+ end
28
+ end
29
+
30
+ if Wx::WXWIDGETS_VERSION >= '3.3.0'
31
+
32
+ class AnimationCtrl
33
+
34
+ # Redefine this method to accept either a single animation or an animation bundle
35
+ wx_set_animation = self.instance_method(:set_animation)
36
+ define_method(:set_animation) do | arg |
37
+ if Wx::Animation === arg
38
+ arg = Wx::AnimationBundle.new(arg)
39
+ end
40
+ wx_set_animation.bind(self).call(arg)
19
41
  end
20
- res = wx_init.bind(self).call()
21
- res.load_file(args[0], args[1] || Wx::ANIMATION_TYPE_ANY)
22
- else
23
- wx_init.bind(self).call(*args)
42
+
24
43
  end
44
+
25
45
  end
46
+
26
47
  end
@@ -25,6 +25,7 @@ module Wx
25
25
  x, y = self
26
26
  Wx::RealPoint.new(x || Wx::DEFAULT_COORD, y || Wx::DEFAULT_COORD)
27
27
  end
28
+ alias :to_real :to_real_point
28
29
 
29
30
  end
30
31
 
data/lib/wx/core/brush.rb CHANGED
@@ -6,8 +6,16 @@
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
  TheBrushList = Wx::Brush
12
14
 
15
+ class BrushStyle < Wx::Enum
16
+
17
+ set_non_distinct(%i[BRUSHSTYLE_INVALID BRUSHSTYLE_FIRST_HATCH BRUSHSTYLE_LAST_HATCH])
18
+
19
+ end
20
+
13
21
  end
@@ -14,9 +14,8 @@ module Wx
14
14
  choices,
15
15
  parent = nil,
16
16
  initial_selection: 0,
17
- x: Wx::DEFAULT_COORD,
18
- y: Wx::DEFAULT_COORD)
19
- dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, nil, Wx::CHOICEDLG_STYLE, [x, y])
17
+ pos: Wx::DEFAULT_POSITION)
18
+ dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, pos)
20
19
 
21
20
  dialog.selection = initial_selection
22
21
  return dialog.show_modal == Wx::ID_OK ? dialog.get_string_selection : ''
@@ -28,9 +27,8 @@ module Wx
28
27
  choices,
29
28
  parent = nil,
30
29
  initial_selection: 0,
31
- x: Wx::DEFAULT_COORD,
32
- y: Wx::DEFAULT_COORD)
33
- dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, nil, Wx::CHOICEDLG_STYLE, [x, y])
30
+ pos: Wx::DEFAULT_POSITION)
31
+ dialog = Wx::SingleChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, pos)
34
32
 
35
33
  dialog.selection = initial_selection
36
34
  return dialog.show_modal == Wx::ID_OK ? dialog.get_selection : -1
@@ -43,16 +41,15 @@ module Wx
43
41
  choices,
44
42
  parent = nil,
45
43
  initial_selections: [],
46
- x: Wx::DEFAULT_COORD,
47
- y: Wx::DEFAULT_COORD)
48
- dialog = Wx::MultiChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, [x, y])
44
+ pos: Wx::DEFAULT_POSITION)
45
+ dialog = Wx::MultiChoiceDialog.new(parent, message, caption, choices, Wx::CHOICEDLG_STYLE, pos)
49
46
 
50
47
  # call this even if selections array is empty and this then (correctly)
51
48
  # deselects the first item which is selected by default
52
49
  dialog.selections = initial_selections
53
50
 
54
51
  if dialog.show_modal != Wx::ID_OK
55
- return []
52
+ return nil
56
53
  end
57
54
 
58
55
  dialog.get_selections
@@ -45,6 +45,16 @@ module Wx
45
45
  def to_s
46
46
  "#<Wx::Colour: (#{red}, #{green}, #{blue} *#{alpha})>"
47
47
  end
48
+
49
+ # Copy ctor available.
50
+ def dup
51
+ self.class.new(self)
52
+ end
53
+
54
+ def clone
55
+ dup
56
+ end
57
+
48
58
  end
49
59
 
50
60
  end
@@ -0,0 +1,49 @@
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
8
+
9
+ require_relative './enum'
10
+
11
+ module Wx
12
+
13
+ class Orientation < Wx::Enum
14
+
15
+ set_non_distinct(%i[ORIENTATION_MASK])
16
+
17
+ end
18
+
19
+ class Direction < Wx::Enum
20
+
21
+ set_non_distinct(%i[TOP BOTTOM NORTH SOUTH WEST EAST ALL DIRECTION_MASK])
22
+
23
+ end
24
+
25
+ class Alignment < Wx::Enum
26
+
27
+ set_non_distinct(%i[ALIGN_INVALID ALIGN_CENTRE_HORIZONTAL ALIGN_LEFT ALIGN_TOP ALIGN_CENTRE_VERTICAL ALIGN_CENTER ALIGN_MASK])
28
+
29
+ end
30
+
31
+ class SizerFlagBits < Wx::Enum
32
+
33
+ set_non_distinct(%i[SIZER_FLAG_BITS_MASK])
34
+
35
+ end
36
+
37
+ class Stretch < Wx::Enum
38
+
39
+ set_non_distinct(%i[GROW STRETCH_MASK])
40
+
41
+ end
42
+
43
+ class Border < Wx::Enum
44
+
45
+ set_non_distinct(%i[BORDER_THEME BORDER_MASK])
46
+
47
+ end
48
+
49
+ end
@@ -25,8 +25,8 @@ class Wx::Dialog
25
25
  scope = klass.name.split('::')
26
26
  functor_nm = scope.pop
27
27
  code = <<~__CODE
28
- def #{functor_nm}(*args, &block)
29
- dlg = #{klass.name}.new(*args)
28
+ def #{functor_nm}(*args, **kwargs, &block)
29
+ dlg = #{klass.name}.new(*args, **kwargs)
30
30
  begin
31
31
  if block_given?
32
32
  return block.call(dlg)
data/lib/wx/core/enum.rb CHANGED
@@ -10,10 +10,23 @@ class Wx::Enum
10
10
 
11
11
  class << self
12
12
 
13
- def enumerators
13
+ def set_non_distinct(lst)
14
+ raise TypeError, 'Expected Array of Symbols' unless lst.is_a?(Array) && lst.all? { |e| e.is_a?(Symbol) }
15
+ @non_distinct = lst
16
+ end
17
+ alias :non_distinct= :set_non_distinct
18
+
19
+ def non_distinct
20
+ @non_distinct || []
21
+ end
22
+
23
+ def enumerators(excludes = nil)
24
+ excludes ||= self.non_distinct
14
25
  self.constants(false).inject({}) do |tbl, cn|
15
- cv = self.const_get(cn)
16
- tbl[cv.to_i] = cn if self === cv
26
+ unless excludes&.include?(cn)
27
+ cv = self.const_get(cn)
28
+ tbl[cv.to_i] = cn if self === cv
29
+ end
17
30
  tbl
18
31
  end
19
32
  end
data/lib/wx/core/event.rb CHANGED
@@ -58,4 +58,11 @@ module Wx
58
58
  Wx::EVT_NC_PAINT,
59
59
  Wx::NcPaintEvent
60
60
  ]
61
+ if Wx.const_defined?(:EVT_HOTKEY)
62
+ EvtHandler.register_event_type EvtHandler::EventType[
63
+ 'evt_hotkey', 1,
64
+ Wx::EVT_HOTKEY,
65
+ Wx::KeyEvent
66
+ ]
67
+ end
61
68
  end
@@ -20,4 +20,29 @@ module Wx
20
20
 
21
21
  end
22
22
 
23
+ class FileDialogCustomizeHook
24
+
25
+ # prevent construction of abstract base
26
+ if RUBY_VERSION < '2.7.0'
27
+ def self.new(*)
28
+ raise NotImplementedError, 'Wx::FileDialogCustomizeHook is an abstract class.' if self == Wx::FileDialogCustomizeHook
29
+ super
30
+ end
31
+ else
32
+ def self.new(*, **)
33
+ raise NotImplementedError, 'Wx::FileDialogCustomizeHook is an abstract class.' if self == Wx::FileDialogCustomizeHook
34
+ super
35
+ end
36
+ end
37
+
38
+ # provide default no-ops
39
+
40
+ def add_custom_controls(customizer) end
41
+
42
+ def update_custom_controls; end
43
+
44
+ def transfer_data_from_custom_controls; end
45
+
46
+ end
47
+
23
48
  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
@@ -0,0 +1,24 @@
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
8
+
9
+ module Wx
10
+
11
+ class GDIObject < Object
12
+
13
+ # GDIObjects have safe, working (and relatively cheap) copy ctors.
14
+ def dup
15
+ self.class.new(self)
16
+ end
17
+
18
+ def clone
19
+ dup
20
+ end
21
+
22
+ end
23
+
24
+ end
@@ -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
@@ -8,16 +8,31 @@
8
8
 
9
9
  # The root class for most (not all) WxRuby classes
10
10
 
11
- class Wx::Object
12
- # Massage the output of inspect to show the public module name (Wx),
13
- # instead of the internal name (Wxruby2)
14
- # def to_s
15
- # super.sub('ruby2', '')
16
- # end
17
-
18
- # Returns a string containing the C++ pointer address of this
19
- # object. Only useful for debugging.
20
- def ptr_addr
21
- Wx::ptr_addr(self)
11
+ module Wx
12
+
13
+ class Object
14
+ # Massage the output of inspect to show the public module name (Wx),
15
+ # instead of the internal name (Wxruby2)
16
+ # def to_s
17
+ # super.sub('ruby2', '')
18
+ # end
19
+
20
+ # Returns a string containing the C++ pointer address of this
21
+ # object. Only useful for debugging.
22
+ def ptr_addr
23
+ Wx::ptr_addr(self)
24
+ end
25
+
26
+ # By default Wx:::Object derived class instances cannot be #dup-licated.
27
+ def dup
28
+ nil
29
+ end
30
+
31
+ # By default Wx::Object derived class instances cannot be cloned but instead return self.
32
+ def clone
33
+ self
34
+ end
35
+
22
36
  end
37
+
23
38
  end
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
@@ -111,6 +111,7 @@ class Wx::RealPoint
111
111
  def to_real_point
112
112
  self
113
113
  end
114
+ alias :to_real :to_real_point
114
115
 
115
116
  def dup
116
117
  Wx::RealPoint.new(self.x, self.y)