wxruby3 0.9.0 → 0.9.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (205) hide show
  1. checksums.yaml +4 -4
  2. data/.yardopts +1 -0
  3. data/ext/wxruby3/include/wxRubyApp.h +338 -0
  4. data/ext/wxruby3/include/wxruby-Config.h +6 -6
  5. data/ext/wxruby3/include/wxruby-runtime.h +3 -0
  6. data/ext/wxruby3/swig/common.i +22 -0
  7. data/ext/wxruby3/swig/custom/director.swg +296 -0
  8. data/ext/wxruby3/swig/custom/rubyapi.swg +19 -0
  9. data/ext/wxruby3/swig/custom/rubyerrors.swg +45 -0
  10. data/ext/wxruby3/swig/custom/rubyhead.swg +192 -0
  11. data/ext/wxruby3/swig/custom/rubyrun.swg +187 -0
  12. data/ext/wxruby3/swig/custom/swigrun.swg +363 -0
  13. data/ext/wxruby3/swig/custom/typemaps/swigtypemaps.swg +173 -0
  14. data/ext/wxruby3/swig/wx.i +50 -30
  15. data/lib/wx/aui/aui_tab_ctrl.rb +18 -0
  16. data/lib/wx/aui/auinotebook.rb +6 -2
  17. data/lib/wx/aui/require.rb +1 -0
  18. data/lib/wx/core/app.rb +2 -2
  19. data/lib/wx/core/collapsible_pane.rb +1 -1
  20. data/lib/wx/core/const.rb +83 -0
  21. data/lib/wx/core/controlwithitems.rb +8 -6
  22. data/lib/wx/core/menu.rb +10 -0
  23. data/lib/wx/core/notebook.rb +6 -2
  24. data/lib/wx/core/sizer.rb +11 -0
  25. data/lib/wx/core/task_bar_button.rb +19 -0
  26. data/lib/wx/core/textctrl.rb +11 -1
  27. data/lib/wx/core/{treectrl.rb → tree_ctrl.rb} +31 -12
  28. data/lib/wx/core/window.rb +10 -0
  29. data/lib/wx/doc/app.rb +48 -38
  30. data/lib/wx/doc/art_locator.rb +47 -43
  31. data/lib/wx/doc/aui/auimanager.rb +16 -8
  32. data/lib/wx/doc/aui/auinotebook.rb +20 -5
  33. data/lib/wx/doc/clipboard.rb +11 -7
  34. data/lib/wx/doc/colour_dialog.rb +14 -10
  35. data/lib/wx/doc/const.rb +66 -66
  36. data/lib/wx/doc/controlwithitems.rb +17 -7
  37. data/lib/wx/doc/data_object.rb +2 -2
  38. data/lib/wx/doc/event.rb +0 -6
  39. data/lib/wx/doc/evthandler.rb +113 -108
  40. data/lib/wx/doc/font.rb +1 -0
  41. data/lib/wx/doc/functions.rb +9 -9
  42. data/lib/wx/doc/gc_dc.rb +6 -1
  43. data/lib/wx/doc/graphics_context.rb +1 -0
  44. data/lib/wx/doc/grid/grid.rb +22 -1
  45. data/lib/wx/doc/help_controller.rb +11 -7
  46. data/lib/wx/doc/html/html_help_controller.rb +12 -4
  47. data/lib/wx/doc/list_ctrl.rb +33 -29
  48. data/lib/wx/doc/menu.rb +20 -0
  49. data/lib/wx/doc/notebook.rb +21 -0
  50. data/lib/wx/doc/pg/events.rb +13 -9
  51. data/lib/wx/doc/pg/pg_property.rb +18 -0
  52. data/lib/wx/doc/progress_dialog.rb +36 -32
  53. data/lib/wx/doc/prt/page_setup_dialog.rb +20 -12
  54. data/lib/wx/doc/prt/print_data.rb +13 -5
  55. data/lib/wx/doc/prt/print_dialog.rb +31 -23
  56. data/lib/wx/doc/prt/printer.rb +20 -12
  57. data/lib/wx/doc/radio_box.rb +19 -15
  58. data/lib/wx/doc/rbn/ribbon_bar.rb +13 -5
  59. data/lib/wx/doc/rbn/ribbon_button_bar.rb +13 -5
  60. data/lib/wx/doc/rbn/ribbon_gallery.rb +13 -5
  61. data/lib/wx/doc/rbn/ribbon_tool_bar.rb +13 -5
  62. data/lib/wx/doc/region_iterator.rb +32 -28
  63. data/lib/wx/doc/rtc/rich_text_composite_object.rb +24 -0
  64. data/lib/wx/doc/rtc/rich_text_ctrl.rb +24 -0
  65. data/lib/wx/doc/rtc/rich_text_paragraph.rb +24 -0
  66. data/lib/wx/doc/rtc/richtext_buffer.rb +27 -19
  67. data/lib/wx/doc/rtc/richtext_printing.rb +17 -9
  68. data/lib/wx/doc/rtc/richtext_style_sheet.rb +17 -9
  69. data/lib/wx/doc/sizer.rb +20 -0
  70. data/lib/wx/doc/stc/styled_text_ctrl.rb +24 -0
  71. data/lib/wx/doc/stream.rb +39 -35
  72. data/lib/wx/doc/system_settings.rb +30 -26
  73. data/lib/wx/doc/text_validator.rb +12 -8
  74. data/lib/wx/doc/textctrl.rb +16 -0
  75. data/lib/wx/doc/tree_ctrl.rb +95 -0
  76. data/lib/wx/doc/treebook.rb +9 -5
  77. data/lib/wx/doc/v_list_box.rb +9 -5
  78. data/lib/wx/doc/variant.rb +164 -160
  79. data/lib/wx/doc/window.rb +57 -42
  80. data/lib/wx/doc/window_disabler.rb +10 -6
  81. data/lib/wx/grid/grid.rb +27 -4
  82. data/lib/wx/keyword_defs.rb +43 -6
  83. data/lib/wx/pg/pg_property.rb +22 -0
  84. data/lib/wx/rtc/require.rb +3 -0
  85. data/lib/wx/rtc/rich_text_composite_object.rb +25 -0
  86. data/lib/wx/rtc/rich_text_ctrl.rb +25 -0
  87. data/lib/wx/rtc/rich_text_paragraph.rb +25 -0
  88. data/lib/wx/stc/require.rb +1 -0
  89. data/lib/wx/stc/styled_text_ctrl.rb +25 -0
  90. data/lib/wx/version.rb +1 -1
  91. data/rakelib/lib/config/linux.rb +0 -3
  92. data/rakelib/lib/config/macosx.rb +1 -1
  93. data/rakelib/lib/config/mingw.rb +1 -1
  94. data/rakelib/lib/config/unixish.rb +1 -1
  95. data/rakelib/lib/config.rb +14 -4
  96. data/rakelib/lib/core/include/funcall.inc +33 -14
  97. data/rakelib/lib/core/include/swigdirector.inc +384 -0
  98. data/rakelib/lib/core/include/swigrubyerrors.inc +161 -0
  99. data/{ext/wxruby3/swig/custom/swig4/rubyrun.swg → rakelib/lib/core/include/swigrubyrun.inc} +245 -120
  100. data/rakelib/lib/core/include/swigrun.inc +700 -0
  101. data/rakelib/lib/core/package.rb +19 -9
  102. data/rakelib/lib/core/parameter.rb +3 -0
  103. data/rakelib/lib/core/spec.rb +6 -1
  104. data/rakelib/lib/director/accelerator.rb +3 -4
  105. data/rakelib/lib/director/accessible.rb +47 -0
  106. data/rakelib/lib/director/animation.rb +1 -1
  107. data/rakelib/lib/director/animation_ctrl.rb +20 -0
  108. data/rakelib/lib/director/app.rb +15 -304
  109. data/rakelib/lib/director/app_traits.rb +10 -12
  110. data/rakelib/lib/director/art_provider.rb +1 -1
  111. data/rakelib/lib/director/ctrl_with_items.rb +17 -5
  112. data/rakelib/lib/director/data_format.rb +1 -1
  113. data/rakelib/lib/director/data_object_simple_base.rb +1 -2
  114. data/rakelib/lib/director/derived_dc.rb +1 -1
  115. data/rakelib/lib/director/dialog.rb +6 -0
  116. data/rakelib/lib/director/dialup_event.rb +44 -0
  117. data/rakelib/lib/director/dialup_manager.rb +45 -0
  118. data/rakelib/lib/director/drag_image.rb +2 -3
  119. data/rakelib/lib/director/event.rb +22 -4
  120. data/rakelib/lib/director/file_ctrl.rb +35 -0
  121. data/rakelib/lib/director/file_ctrl_event.rb +26 -0
  122. data/rakelib/lib/director/frame.rb +1 -3
  123. data/rakelib/lib/director/gdicommon.rb +27 -11
  124. data/rakelib/lib/director/graphics_context.rb +2 -4
  125. data/rakelib/lib/director/grid_cell_editor.rb +6 -6
  126. data/rakelib/lib/director/grid_ctrl.rb +34 -3
  127. data/rakelib/lib/director/help_controller.rb +1 -1
  128. data/rakelib/lib/director/icon.rb +5 -2
  129. data/rakelib/lib/director/list_ctrl.rb +5 -6
  130. data/rakelib/lib/director/locale.rb +1 -3
  131. data/rakelib/lib/director/log.rb +1 -4
  132. data/rakelib/lib/director/media_ctrl.rb +54 -0
  133. data/rakelib/lib/director/menu.rb +16 -1
  134. data/rakelib/lib/director/menu_item.rb +2 -2
  135. data/rakelib/lib/director/pgarray_editor_dialog.rb +0 -6
  136. data/rakelib/lib/director/pgeditor.rb +2 -2
  137. data/rakelib/lib/director/pgproperties.rb +3 -3
  138. data/rakelib/lib/director/pgproperty.rb +24 -1
  139. data/rakelib/lib/director/property_grid_interface.rb +5 -10
  140. data/rakelib/lib/director/richtext_buffer.rb +1 -1
  141. data/rakelib/lib/director/richtext_composite_object.rb +25 -0
  142. data/rakelib/lib/director/richtext_ctrl.rb +15 -5
  143. data/rakelib/lib/director/richtext_formatting_dialog.rb +7 -5
  144. data/rakelib/lib/director/richtext_paragraph_layout_box.rb +9 -7
  145. data/rakelib/lib/director/sash_event.rb +42 -0
  146. data/rakelib/lib/director/sizer.rb +79 -1
  147. data/rakelib/lib/director/sizer_item.rb +22 -0
  148. data/rakelib/lib/director/static_box.rb +4 -5
  149. data/rakelib/lib/director/styled_text_ctrl.rb +12 -0
  150. data/rakelib/lib/director/task_bar_button.rb +30 -0
  151. data/rakelib/lib/director/task_bar_icon.rb +6 -14
  152. data/rakelib/lib/director/textctrl.rb +12 -1
  153. data/rakelib/lib/director/tool_tip.rb +1 -1
  154. data/rakelib/lib/director/top_level_window.rb +4 -5
  155. data/rakelib/lib/director/tree_ctrl.rb +24 -50
  156. data/rakelib/lib/director/variant.rb +1 -1
  157. data/rakelib/lib/director/window.rb +24 -5
  158. data/rakelib/lib/director.rb +4 -4
  159. data/rakelib/lib/extractor/function.rb +6 -6
  160. data/rakelib/lib/extractor.rb +34 -5
  161. data/rakelib/lib/generate/analyzer.rb +8 -3
  162. data/rakelib/lib/generate/doc/animation_ctrl.yaml +15 -0
  163. data/rakelib/lib/generate/doc/busy_info.yaml +0 -2
  164. data/rakelib/lib/generate/doc/clipboard.yaml +0 -2
  165. data/rakelib/lib/generate/doc/cursor.yaml +0 -2
  166. data/rakelib/lib/generate/doc/events.yaml +10 -4
  167. data/rakelib/lib/generate/doc/panel.yaml +7 -0
  168. data/rakelib/lib/generate/doc/static_box.yaml +8 -0
  169. data/rakelib/lib/generate/doc/xml_resource.yaml +3 -0
  170. data/rakelib/lib/generate/doc.rb +89 -16
  171. data/rakelib/lib/generate/interface.rb +4 -3
  172. data/rakelib/lib/specs/interfaces.rb +161 -156
  173. data/rakelib/lib/swig_runner.rb +4 -50
  174. data/rakelib/lib/typemap/common.rb +54 -10
  175. data/rakelib/lib/typemap/data_format.rb +1 -1
  176. data/rakelib/lib/typemap/data_object_data.rb +2 -2
  177. data/rakelib/lib/typemap/pgprop_arg.rb +7 -2
  178. data/rakelib/lib/typemap/points_list.rb +5 -7
  179. data/rakelib/lib/util/string.rb +10 -8
  180. data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +74 -2
  181. data/rakelib/yard/templates/default/fulldoc/html/full_list.erb +38 -0
  182. data/rakelib/yard/templates/default/fulldoc/html/setup.rb +39 -0
  183. data/rakelib/yard/templates/default/tags/html/wxrb_require.erb +10 -0
  184. data/rakelib/yard/templates/default/tags/setup.rb +16 -0
  185. data/rakelib/yard/yard-custom-templates.rb +3 -0
  186. data/samples/text/richtext.rb +0 -30
  187. data/samples/treectrl/treectrl.rb +1 -1
  188. data/tests/media/beep_lo.wav +0 -0
  189. data/tests/test_app_exit_exception.rb +36 -0
  190. data/tests/test_app_init_exception.rb +20 -0
  191. data/tests/test_book_controls.rb +29 -0
  192. data/tests/test_exceptions.rb +41 -0
  193. data/tests/test_list_ctrl.rb +1 -1
  194. data/tests/test_media_ctrl.rb +38 -0
  195. data/tests/test_menu.rb +69 -0
  196. data/tests/test_pg.rb +27 -0
  197. data/tests/test_richtext.rb +45 -0
  198. data/tests/test_sizer.rb +59 -0
  199. data/tests/test_std_controls.rb +78 -1
  200. data/tests/test_styled_text_ctrl.rb +46 -0
  201. data/tests/test_tree_ctrl.rb +138 -0
  202. data/tests/test_window.rb +12 -0
  203. data/tests/testapp_noframe.rb +1 -1
  204. metadata +54 -5
  205. data/ext/wxruby3/swig/custom/swig3/rubyrun.swg +0 -456
@@ -0,0 +1,173 @@
1
+ /* -----------------------------------------------------------------------------
2
+ * swigtypemaps.swg
3
+ *
4
+ * Unified Typemap Library frontend
5
+ *
6
+ * Customized for wxRuby3.
7
+ * Copyright (c) 2023 M.J.N. Corino, The Netherlands
8
+ *
9
+ * This software is released under the MIT license.
10
+ * ----------------------------------------------------------------------------- */
11
+
12
+ /*
13
+ This file provides the frontend to the Unified Typemap Library.
14
+
15
+ When using this library in a SWIG target language, you need to
16
+ define a minimum set of fragments, specialize a couple of macros,
17
+ and then include this file.
18
+
19
+ Typically you will create a 'mytypemaps.swg' file in each target
20
+ language, where you will have the following sections:
21
+
22
+ === mytypemaps.swg ===
23
+
24
+ // Fragment section
25
+ %include <typemaps/fragments.swg>
26
+ <include target language fragments>
27
+
28
+ // Unified typemap section
29
+ <specialized the typemap library macros>
30
+ %include <typemaps/swigtypemaps.swg>
31
+
32
+ // Local typemap section
33
+ <add/replace extra target language typemaps>
34
+
35
+ === mytypemaps.swg ===
36
+
37
+ While we add more docs, please take a look at the following cases
38
+ to see how you specialized the unified typemap library for a new
39
+ target language:
40
+
41
+ Lib/python/pytypemaps.swg
42
+ Lib/tcl/tcltypemaps.swg
43
+ Lib/ruby/rubytypemaps.swg
44
+ Lib/perl5/perltypemaps.swg
45
+
46
+ */
47
+
48
+ #define SWIGUTL SWIGUTL
49
+
50
+ /* -----------------------------------------------------------------------------
51
+ * Language specialization section.
52
+ *
53
+ * Tune these macros for each language as needed.
54
+ * ----------------------------------------------------------------------------- */
55
+
56
+ /*
57
+ The SWIG target language object must be provided.
58
+ For example in python you define:
59
+
60
+ #define SWIG_Object PyObject *
61
+ */
62
+
63
+ #if !defined(SWIG_Object)
64
+ #error "SWIG_Object must be defined as the SWIG target language object"
65
+ #endif
66
+
67
+ /*==== flags for new/convert methods ====*/
68
+
69
+
70
+ #ifndef %convertptr_flags
71
+ %define %convertptr_flags 0 %enddef
72
+ #endif
73
+
74
+ #ifndef %newpointer_flags
75
+ %define %newpointer_flags 0 %enddef
76
+ #endif
77
+
78
+ #ifndef %newinstance_flags
79
+ %define %newinstance_flags 0 %enddef
80
+ #endif
81
+
82
+ /*==== set output ====*/
83
+
84
+ #ifndef %set_output
85
+ /* simple set output operation */
86
+ #define %set_output(obj) $result = obj
87
+ #endif
88
+
89
+ /*==== set variable output ====*/
90
+
91
+ #ifndef %set_varoutput
92
+ /* simple set varoutput operation */
93
+ #define %set_varoutput(obj) $result = obj
94
+ #endif
95
+
96
+ /*==== append output ====*/
97
+
98
+ #ifndef %append_output
99
+ #if defined(SWIG_AppendOutput)
100
+ /* simple append operation */
101
+ #define %append_output(obj) $result = SWIG_AppendOutput($result,obj)
102
+ #else
103
+ #error "Language must define SWIG_AppendOutput or %append_output"
104
+ #endif
105
+ #endif
106
+
107
+ /*==== set constant ====*/
108
+
109
+ #ifndef %set_constant
110
+ #if defined(SWIG_SetConstant)
111
+ /* simple set constant operation */
112
+ #define %set_constant(name,value) SWIG_SetConstant(name,value)
113
+ #else
114
+ #error "Language must define SWIG_SetConstant or %set_constant"
115
+ #endif
116
+ #endif
117
+
118
+ /*==== raise an exception ====*/
119
+
120
+ #ifndef %raise
121
+ #if defined(SWIG_Raise)
122
+ /* simple raise operation */
123
+ #define %raise(obj, type, desc) SWIG_Raise(obj, type, desc); SWIG_fail
124
+ #else
125
+ #error "Language must define SWIG_Raise or %raise"
126
+ #endif
127
+ #endif
128
+
129
+ /*==== director output exception ====*/
130
+
131
+ /* wxRuby : make sure to pass the object and method that caused the failure */
132
+ #if defined(SWIG_DIRECTOR_TYPEMAPS)
133
+ #ifndef SWIG_DirOutFail
134
+ #define SWIG_DirOutFail(self, method, code, msg) Swig::DirectorTypeMismatchException::raise(self, method, SWIG_ErrorType(code), msg)
135
+ #endif
136
+ #endif
137
+
138
+
139
+ /* -----------------------------------------------------------------------------
140
+ * Language independent definitions
141
+ * ----------------------------------------------------------------------------- */
142
+
143
+ #define %error_block(Block...) %block(Block)
144
+ #define %default_code(code) SWIG_ArgError(code)
145
+ #define %argument_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %argfail_fmt(type, name, argn))
146
+ #define %argument_nullref(type, name, argn) SWIG_exception_fail(SWIG_ValueError, %argnullref_fmt(type, name, argn))
147
+ #define %variable_fail(code, type, name) SWIG_exception_fail(%default_code(code), %varfail_fmt(type, name))
148
+ #define %variable_nullref(type, name) SWIG_exception_fail(SWIG_ValueError, %varnullref_fmt(type, name))
149
+ #define %releasenotowned_fail(code, type, name, argn) SWIG_exception_fail(%default_code(code), %releasenotownedfail_fmt(type, name, argn))
150
+
151
+ /* wxRuby : make sure to pass the object and method that caused the failure */
152
+ #if defined(SWIG_DIRECTOR_TYPEMAPS)
153
+ #define %dirout_fail(code, type) SWIG_DirOutFail(swig_get_self(), "$symname", %default_code(code), %outfail_fmt(type))
154
+ #define %dirout_nullref(type) SWIG_DirOutFail(swig_get_self(), "$symname", SWIG_ValueError, %outnullref_fmt(type))
155
+ #endif
156
+
157
+ /* -----------------------------------------------------------------------------
158
+ * All the typemaps
159
+ * ----------------------------------------------------------------------------- */
160
+
161
+
162
+ %include <typemaps/fragments.swg>
163
+ %include <typemaps/exception.swg>
164
+ %include <typemaps/swigtype.swg>
165
+ %include <typemaps/void.swg>
166
+ %include <typemaps/swigobject.swg>
167
+ %include <typemaps/valtypes.swg>
168
+ %include <typemaps/ptrtypes.swg>
169
+ %include <typemaps/inoutlist.swg>
170
+ %include <typemaps/primtypes.swg>
171
+ %include <typemaps/string.swg>
172
+ %include <typemaps/misctypes.swg>
173
+ %include <typemaps/enumint.swg>
@@ -35,11 +35,31 @@ WX_DECLARE_HASH_MAP(VALUE,
35
35
  RbClassToSwigTypeHash);
36
36
  RbClassToSwigTypeHash Global_Type_Map;
37
37
 
38
+ // Mapping of wxWidgets class names to Ruby classes
39
+ WX_DECLARE_STRING_HASH_MAP(VALUE,
40
+ WxClassnameToRbClassHash);
41
+ WxClassnameToRbClassHash Global_Class_Map;
42
+
43
+ // Record wxRuby class for a wxw class name
44
+ WXRUBY_EXPORT void wxRuby_SetRbClassForWxName(const wxString& wx_name, VALUE cls)
45
+ {
46
+ Global_Class_Map[wx_name] = cls;
47
+ }
48
+
49
+ // Retrieve wxRuby class for a wxw class name
50
+ WXRUBY_EXPORT VALUE wxRuby_GetRbClassForWxName(const wxString& wx_name)
51
+ {
52
+ return Global_Class_Map[wx_name];
53
+ }
54
+
38
55
  // Record swig_type_info for a wxRuby class; called in class
39
56
  // initialisation
40
57
  WXRUBY_EXPORT void wxRuby_SetSwigTypeForClass(VALUE cls, swig_type_info* ty)
41
58
  {
42
59
  Global_Type_Map[cls] = ty;
60
+ const char* swig_type_name = ty->name;
61
+ // skip '_p_' prefix and register class
62
+ wxRuby_SetRbClassForWxName(wxString(swig_type_name+3), cls);
43
63
  }
44
64
 
45
65
  // Retrieve swig_type_info for a ruby class - needed by functions which
@@ -141,41 +161,41 @@ WXRUBY_EXPORT VALUE wxRuby_WrapWxObjectInRuby(wxObject *wx_obj)
141
161
 
142
162
  // Get the wx class and the ruby class we are converting into
143
163
  wxString class_name( wx_obj->GetClassInfo()->GetClassName() );
144
- wxCharBuffer wx_classname = class_name.mb_str();
145
- VALUE r_class_name = rb_intern(wx_classname.data () + 2);
146
- VALUE r_class = Qnil;
147
-
148
- if ( class_name.Len() > 2 )
149
- {
150
- // lookup the class in the main module and any package submodules loaded
151
- if (rb_const_defined(mWxCore, r_class_name))
152
- r_class = rb_const_get(mWxCore, r_class_name);
153
- else
154
- {
155
- VALUE submod_ary = rb_ivar_get(mWxCore, rb_intern("@__pkgmods__"));
156
- for (long n=0; n<RARRAY_LEN(submod_ary); ++n)
157
- {
158
- VALUE submod = rb_ary_entry(submod_ary, n);
159
- if (rb_const_defined(submod, r_class_name))
160
- {
161
- r_class = rb_const_get(submod, r_class_name);
162
- break;
163
- }
164
- }
165
- }
166
- }
164
+ VALUE r_class = wxRuby_GetRbClassForWxName(class_name);
167
165
 
168
166
  // Handle classes (currently) unknown in wxRuby.
169
167
  // (could cause problems because class-specific methods won't be accessible).
170
- if ( r_class == Qnil )
168
+ if (r_class == 0 || NIL_P(r_class))
171
169
  {
172
- // map unknown wxWindow derivatives as basic window
170
+ // map unknown wxWindow derivatives as a mapped base class
171
+ // this solves issues with explicitly defined wxRuby custom
172
+ // DECLARE_DYNAMIC_CLASS classes like WxRubyTreeCtrl
173
173
  if (wxIsKindOf(wx_obj, wxWindow))
174
174
  {
175
- r_class = rb_const_get(mWxCore, window_id());
176
- // issue warning if $VERBOSE is true
177
- rb_warning("Cannot wrap exact window class as '%s' is not (yet) known in wxRuby; wrapping as base Window object.",
178
- (const char *)class_name.mb_str());
175
+ wxClassInfo* cls_info = wx_obj->GetClassInfo();
176
+ do
177
+ {
178
+ wxString base_name(wx_obj->GetClassInfo()->GetBaseClassName1());
179
+ r_class = wxRuby_GetRbClassForWxName(base_name);
180
+ if (r_class == 0 || NIL_P(r_class))
181
+ {
182
+ cls_info = wxClassInfo::FindClass(base_name);
183
+ if (!cls_info)
184
+ {
185
+ // map to basic Wx::Window
186
+ r_class = rb_const_get(mWxCore, window_id());
187
+ // issue warning if $VERBOSE is true
188
+ rb_warning("Cannot wrap exact window class as '%s' is not (yet) known in wxRuby; wrapping as base Wx::Window object.",
189
+ (const char *)class_name.mb_str());
190
+ }
191
+ }
192
+ else
193
+ {
194
+ // issue warning if $VERBOSE is true
195
+ rb_warning("Cannot wrap exact window class as '%s' is not (yet) known in wxRuby; wrapping as %s object.",
196
+ (const char *)class_name.mb_str(), rb_class2name(r_class));
197
+ }
198
+ } while (r_class == 0 || NIL_P(r_class));
179
199
  }
180
200
  else
181
201
  {
@@ -188,7 +208,7 @@ WXRUBY_EXPORT VALUE wxRuby_WrapWxObjectInRuby(wxObject *wx_obj)
188
208
  // Otherwise, retrieve the swig type info for this class and wrap it
189
209
  // in Ruby. wxRuby_GetSwigTypeForClass is defined in wx.i
190
210
  swig_type_info* swig_type = wxRuby_GetSwigTypeForClass(r_class);
191
- VALUE r_obj = SWIG_NewPointerObj(wx_obj, swig_type, 1);
211
+ VALUE r_obj = SWIG_NewPointerObj(wx_obj, swig_type, 0);
192
212
  return r_obj;
193
213
  }
194
214
 
@@ -0,0 +1,18 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+ class Wx::AUI::AuiTabCtrl
6
+
7
+ # Convenience method for iterating pages
8
+ def each_page
9
+ if block_given?
10
+ 0.upto(get_page_count - 1) do | i |
11
+ yield get_page(i)
12
+ end
13
+ else
14
+ ::Enumerator.new { |y| each_page { |pg| y << pg } }
15
+ end
16
+ end
17
+
18
+ end
@@ -19,8 +19,12 @@ class Wx::AUI::AuiNotebook
19
19
 
20
20
  # Convenience method for iterating pages
21
21
  def each_page
22
- 0.upto(get_page_count - 1) do | i |
23
- yield get_page(i)
22
+ if block_given?
23
+ 0.upto(get_page_count - 1) do | i |
24
+ yield get_page(i)
25
+ end
26
+ else
27
+ ::Enumerator.new { |y| each_page { |pg| y << pg } }
24
28
  end
25
29
  end
26
30
  end
@@ -9,5 +9,6 @@ require_relative './events/evt_list'
9
9
  require_relative './auimanager'
10
10
  require_relative './auinotebook'
11
11
  require_relative './auifloatframe'
12
+ require_relative './aui_tab_ctrl'
12
13
 
13
14
  Wx::Dialog.setup_dialog_functors(Wx::AUI)
data/lib/wx/core/app.rb CHANGED
@@ -79,8 +79,8 @@ class Wx::App
79
79
  # WxRuby. Such messages usually indicate that the API is being used
80
80
  # incorrectly; the file/line reference points to the place in the
81
81
  # WxWidgets source code where the assertion was made.
82
- define_method(:on_assert_failure) do | file, line, func, condition, message |
83
- warn "Wx WARNING: #{message} (#{func}@#{file}:#{line})"
82
+ def on_assert_failure(file, line, func, condition, message)
83
+ warn %Q{Wx WARNING: ASSERT #{condition} fired with "#{message}" at (#{func}@#{file}:#{line})}
84
84
  end
85
85
 
86
86
  # For use in development only, of no practical use in production code.
@@ -10,7 +10,7 @@
10
10
 
11
11
  module Wx
12
12
 
13
- if Wx.has_feature?(:USE_COLLPANE) && (!Wx.has_feature?(:WXGTK20) || Wx.has_feature?(:WXUNIVERSAL))
13
+ if Wx.has_feature?(:USE_COLLPANE)
14
14
 
15
15
  GenericCollapsiblePane = CollapsiblePane
16
16
 
@@ -0,0 +1,83 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+
6
+ module Wx
7
+
8
+ =begin
9
+ These constants are not documented in the wxWidgets interface headers
10
+ although they are referenced in various argument defaults which *are*
11
+ in the interface header declarations so.
12
+ =end
13
+
14
+ DEFAULT_DATE_TIME_FORMAT = '%c'
15
+ DEFAULT_TIME_SPAN_FORMAT = '%H:%M:%S'
16
+
17
+ CHOICE_NAME_STR = 'choice'
18
+ COLOUR_PICKER_CTRL_NAME_STR = 'colourpicker'
19
+ COLOUR_PICKER_WIDGET_NAME_STR = 'colourpickerwidget'
20
+ HYPERLINK_CTRL_NAME_STR = 'hyperlink'
21
+ PANEL_NAME_STR = 'panel'
22
+ LIST_BOX_NAME_STR = 'listBox'
23
+ FRAME_NAME_STR = 'frame'
24
+ STATUS_LINE_NAME_STR = 'status_line'
25
+ STATIC_BITMAP_NAME_STR = 'staticBitmap'
26
+ WEB_VIEW_NAME_STR = 'wxWebView'
27
+ ANIMATION_CTRL_NAME_STR = 'animationctrl'
28
+ TOOL_BAR_NAME_STR = 'toolbar'
29
+ TEXT_CTRL_NAME_STR = 'text'
30
+ LIST_CTRL_NAME_STR = 'listCtrl'
31
+ FILE_PICKER_CTRL_NAME_STR = 'filepicker'
32
+ FILE_PICKER_WIDGET_NAME_STR = 'filepickerwidget'
33
+ DIR_PICKER_CTRL_NAME_STR = 'dirpicker'
34
+ DIR_PICKER_WIDGET_NAME_STR = 'dirpickerwidget'
35
+ FILE_CTRL_NAME_STR = 'wxfilectrl'
36
+ FILE_SELECTOR_PROMPT_STR = 'Select a file'
37
+ STATIC_BOX_NAME_STR = 'groupBox'
38
+ BUTTON_NAME_STR = 'button'
39
+ RADIO_BOX_NAME_STR = 'radioBox'
40
+ STATIC_LINE_NAME_STR = 'staticLine'
41
+ RADIO_BUTTON_NAME_STR = 'radioButton'
42
+ BITMAP_RADIO_BUTTON_NAME_STR = 'radioButton'
43
+ GAUGE_NAME_STR = 'gauge'
44
+ DATA_VIEW_CTRL_NAME_STR = 'dataviewCtrl'
45
+ FONT_PICKER_CTRL_NAME_STR = 'fontpicker'
46
+ FONT_PICKER_WIDGET_NAME_STR = 'fontpickerwidget'
47
+ REARRANGE_LIST_NAME_STR = 'wxRearrangeList'
48
+ REARRANGE_DIALOG_NAME_STR = 'wxRearrangeDlg'
49
+ NOTEBOOK_NAME_STR = 'notebook'
50
+ CONTROL_NAME_STR = 'control'
51
+ SCROLL_BAR_NAME_STR = 'scrollBar'
52
+ STATUS_BAR_NAME_STR = 'statusBar'
53
+ SLIDER_NAME_STR = 'slider'
54
+ HEADER_CTRL_NAME_STR = 'wxHeaderCtrl'
55
+ BITMAP_COMBO_BOX_NAME_STR = 'bitmapComboBox'
56
+ CHECK_BOX_NAME_STR = 'check'
57
+ FILE_DIALOG_NAME_STR = 'filedlg'
58
+ ADD_REMOVE_CTRL_NAME_STR = 'wxAddRemoveCtrl'
59
+ STATIC_TEXT_NAME_STR = 'staticText'
60
+ COMBO_BOX_NAME_STR = 'comboBox'
61
+ SEARCH_CTRL_NAME_STR = 'searchCtrl'
62
+ TREE_CTRL_NAME_STR = 'treeCtrl'
63
+ DIALOG_NAME_STR = 'dialog'
64
+ COLLAPSIBLE_HEADER_CTRL_NAME_STR = 'collapsibleHeader'
65
+ COLLAPSIBLE_PANE_NAME_STR = 'collapsiblePane'
66
+ BANNER_WINDOW_NAME_STR = 'bannerwindow'
67
+ GRID_NAME_STR = 'grid'
68
+ TREE_LIST_CTRL_NAME_STR = 'wxTreeListCtrl'
69
+ HTML_LIST_BOX_NAME_STR = 'htmlListBox'
70
+ SIMPLE_HTML_LIST_BOX_NAME_STR = 'simpleHtmlListBox'
71
+ EDITABLE_LIST_BOX_NAME_STR = 'editableListBox'
72
+ V_LIST_BOX_NAME_STR = 'wxVListBox'
73
+
74
+ if Wx::PLATFORM == 'WXMSW'
75
+ # wxMSW only
76
+ MSW_HEADER_CTRL_NAME_STR = 'wxMSWHeaderCtrl'
77
+ end
78
+
79
+ PROPERTY_GRID_MANAGER_NAME_STR = 'wxPropertyGridManager'
80
+ PROPERTY_GRID_NAME_STR = 'wxPropertyGrid'
81
+ STC_NAME_STR = 'stcwindow'
82
+
83
+ end
@@ -11,12 +11,14 @@
11
11
 
12
12
  class Wx::ControlWithItems
13
13
 
14
- # Make these Ruby enumerables so find, find_all, map etc are available
15
- include Enumerable
16
-
17
- # Passes each valid item index into the passed block
18
- def each
19
- get_count.times { | i | yield i }
14
+ # Overload to provide Enumerator without block
15
+ wx_each_string = instance_method :each_string
16
+ define_method :each_string do |&block|
17
+ if block
18
+ wx_each_string.bind(self).call(&block)
19
+ else
20
+ ::Enumerator.new { |y| wx_each_string.bind(self).call { |ln| y << ln } }
21
+ end
20
22
  end
21
23
 
22
24
  # We need to cache client data in Ruby variables as we cannot access items
data/lib/wx/core/menu.rb CHANGED
@@ -26,6 +26,16 @@ class Wx::Menu
26
26
  end
27
27
  end
28
28
 
29
+ # Overload to provide Enumerator without block
30
+ wx_each_item = instance_method :each_item
31
+ define_method :each_item do |&block|
32
+ if block
33
+ wx_each_item.bind(self).call(&block)
34
+ else
35
+ ::Enumerator.new { |y| wx_each_item.bind(self).call { |mi| y << mi } }
36
+ end
37
+ end
38
+
29
39
  # In the standard WxWidgets API, the methods append, prepend, insert
30
40
  # (and their variants) require a constant integer id as the identifier
31
41
  # of the menu item. This is then used in event handling.
@@ -11,8 +11,12 @@
11
11
  class Wx::Notebook
12
12
  # Convenience method for iterating pages
13
13
  def each_page
14
- 0.upto(get_page_count - 1) do | i |
15
- yield get_page(i)
14
+ if block_given?
15
+ 0.upto(get_page_count - 1) do | i |
16
+ yield get_page(i)
17
+ end
18
+ else
19
+ ::Enumerator.new { |y| each_page { |pg| y << pg } }
16
20
  end
17
21
  end
18
22
  end
data/lib/wx/core/sizer.rb CHANGED
@@ -49,4 +49,15 @@ class Wx::Sizer
49
49
  insert(idx, *full_args)
50
50
  end
51
51
  end
52
+
53
+ # Overload to provide Enumerator without block
54
+ wx_each_child = instance_method :each_child
55
+ define_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
+
52
63
  end
@@ -0,0 +1,19 @@
1
+ # Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ #
3
+ # This software is released under the MIT license.
4
+
5
+
6
+ module Wx
7
+
8
+ if Wx::PLATFORM == 'WXMSW'
9
+ class TaskBarButton
10
+
11
+ wx_remove_thumb_bar_button = instance_method :remove_thumb_bar_button
12
+ define_method :remove_thumb_bar_button do |button|
13
+ button = button.get_id if button.is_a?(Wx::ThumbBarButton)
14
+ wx_remove_thumb_bar_button.bind(self).call(button)
15
+ end
16
+
17
+ end
18
+ end
19
+ end
@@ -59,10 +59,20 @@ module Wx
59
59
  class TextCtrl
60
60
  wx_op_append = instance_method :<<
61
61
  define_method :<< do |o|
62
- wx_op_append.bind(self).call(o)
62
+ wx_op_append.bind(self).call(o.to_s)
63
63
  self
64
64
  end
65
65
 
66
+ # Overload to provide Enumerator without block
67
+ wx_each_line = instance_method :each_line
68
+ define_method :each_line do |&block|
69
+ if block
70
+ wx_each_line.bind(self).call(&block)
71
+ else
72
+ ::Enumerator.new { |y| wx_each_line.bind(self).call { |ln| y << ln } }
73
+ end
74
+ end
75
+
66
76
  if Wx.has_feature?(:USE_SPELLCHECK)
67
77
 
68
78
  protected :do_enable_proof_check
@@ -9,22 +9,41 @@
9
9
  # Hierarchical control with items
10
10
 
11
11
  class Wx::TreeCtrl
12
- # Make these ruby enumerables so find, find_all, map etc are available
13
- include Enumerable
12
+
13
+ # Overload to provide Enumerator without block
14
+ wx_traverse = instance_method :traverse
15
+ define_method :traverse do |start_id=nil, &block|
16
+ if block
17
+ wx_traverse.bind(self).call(start_id, &block)
18
+ else
19
+ ::Enumerator.new { |y| wx_traverse.bind(self).call(start_id) { |c| y << c } }
20
+ end
21
+ end
22
+
14
23
  # Iterate over all items
15
24
  alias :each :traverse
16
25
 
17
- # Return the children of +parent+ as an array of TreeItemIDs.
18
- def get_children(parent)
19
- kids = []
20
- kid, _ = get_first_child(parent)
21
- return [] unless kid.ok?
22
- kids << kid
23
-
24
- while kid = get_next_sibling(kids.last) and kid.ok?
25
- kids << kid
26
+ # Make these ruby enumerables so find, find_all, map etc are available
27
+ include Enumerable
28
+
29
+ # Iterate all children of parent_id
30
+ def each_item_child(parent_id, &block)
31
+ if block
32
+ rc = nil
33
+ child_id, cookie = get_first_child(parent_id)
34
+ while child_id && child_id.ok?
35
+ rc = block.call(child_id)
36
+ child_id, cookie = get_next_child(parent_id, cookie)
37
+ end
38
+ rc
39
+ else
40
+ ::Enumerator.new { |y| each_item_child(parent_id) { |child_id| y << child_id } }
26
41
  end
27
- kids
42
+ end
43
+
44
+ # Return the children of +parent+ as an array of TreeItemIDs.
45
+ def get_item_children(parent_id)
46
+ each_item_child(parent_id).to_a
28
47
  end
29
48
 
30
49
  # Returns a Wx::Rect corresponding to the edges of an individual tree
@@ -79,6 +79,16 @@ class Wx::Window
79
79
  end
80
80
  end
81
81
 
82
+ # Overload to provide Enumerator without block
83
+ wx_each_child = instance_method :each_child
84
+ define_method :each_child do |&block|
85
+ if block
86
+ wx_each_child.bind(self).call(&block)
87
+ else
88
+ ::Enumerator.new { |y| wx_each_child.bind(self).call { |c| y << c } }
89
+ end
90
+ end
91
+
82
92
  # implement non-static variants of these
83
93
 
84
94
  def from_dip(*args)