wxruby3 0.9.0 → 0.9.2

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 (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
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 59678c4c6766131dea4df3bb86f3b441bed72710a917b8d6b0372317f19569e5
4
- data.tar.gz: f69f9a17c668284d05adc75adde8e8b5d054a3af261d4ffbf868777226d8e2fe
3
+ metadata.gz: 94bf5f5a3d4107e4a77c02971756de87b044c3d9edfbedd0b0aa0fe3e95e6ae7
4
+ data.tar.gz: 83d78771dde19401cbb0e5f915c7eb86903bf76357f1a1d0be4d10edf1f0d4a7
5
5
  SHA512:
6
- metadata.gz: 8349245892666dd2af662e8239f5d2b5d36ba59938437b5c47376fb8222e88e659aefa67b6551f773e00900440402953550fd53b684193670a53fa3695ff9c34
7
- data.tar.gz: 4a827aa4999b34da4a240908edd356435a4b117562ccb2d3b3bb54d5c9358c64ca65c61d78b22f25c3191648b691288e89b109fc6c9666bc22ceef36abe2e39c
6
+ metadata.gz: f1ac191dac02b350104d6336d38af941126056f30da9d2bffa12d480592216f0059f7cc1e22fa4020898a26faeffbc64d71df09eefd2b3329956c5e70a97b23b
7
+ data.tar.gz: '08d86fdf568ef0b67d76c670ccd108194342c7c0d97710419f7e98e0c852d8a863540aa3c320052237c27adf1c37f4d92a7c927fb827fcbbc5d05a73789e40e1'
data/.yardopts CHANGED
@@ -3,6 +3,7 @@
3
3
  --charset UTF-8
4
4
  --markup markdown
5
5
  --readme README.md
6
+ --asset assets
6
7
  --title "wxRuby3 API Documentation"
7
8
  --output-dir rdoc
8
9
  --protected
@@ -0,0 +1,338 @@
1
+ // Copyright (c) 2023 M.J.N. Corino, The Netherlands
2
+ //
3
+ // This software is released under the MIT license.
4
+
5
+ #include <memory>
6
+
7
+ /*
8
+ * WxRuby3 App class
9
+ */
10
+
11
+ class wxRubyApp : public wxApp
12
+ {
13
+ private:
14
+ bool is_running_ = false;
15
+ VALUE self_ = Qnil;
16
+ public:
17
+ static wxRubyApp* GetInstance () { return dynamic_cast<wxRubyApp*> (wxApp::GetInstance()); }
18
+
19
+ virtual ~wxRubyApp()
20
+ {
21
+ #ifdef __WXTRACE__
22
+ std::wcout << "~wxRubyApp" << std::endl;
23
+ #endif
24
+ // unlink
25
+ if (this->self_ != Qnil)
26
+ {
27
+ DATA_PTR(this->self_) = 0;
28
+ }
29
+ this->self_ = Qnil;
30
+ }
31
+
32
+ // special event handler for destruction of windows which is done
33
+ // automatically by wxWidgets. Tag the object as having been destroyed
34
+ // by WxWidgets.
35
+ void OnWindowDestroy(wxWindowDestroyEvent &event)
36
+ {
37
+ wxObject* wx_obj = event.GetEventObject();
38
+ #ifdef __WXRB_DEBUG__
39
+ if (wxRuby_TraceLevel()>0)
40
+ std::wcout << "<= OnWindowDestroy [" << wx_obj << "]" << std::endl;
41
+ #endif
42
+ GC_SetWindowDeleted((void *)wx_obj);
43
+ event.Skip();
44
+ #ifdef __WXRB_DEBUG__
45
+ if (wxRuby_TraceLevel()>0)
46
+ std::wcout << "=> OnWindowDestroy [" << wx_obj << "]" << std::endl;
47
+ #endif
48
+ }
49
+
50
+ bool IsRunning() const { return this->is_running_; }
51
+
52
+ // When ruby's garbage collection runs, if the app is still active, it
53
+ // cycles through all currently known SWIG objects and calls this
54
+ // function on each to preserve still active Wx::Windows, and also
55
+ // pending Wx::Events which have been queued from the Ruby side (the
56
+ // only sort of events that will be in the tracking hash.
57
+ static void markIterate(void* ptr, VALUE rb_obj)
58
+ {
59
+ // Check if it's a valid object (sometimes SWIG doesn't return what we're
60
+ // expecting), a descendant of Wx::Window (but not a Dialog), and if it has not yet been
61
+ // deleted by WxWidgets; if so, mark it.
62
+ if ( TYPE(rb_obj) == T_DATA )
63
+ {
64
+ if ( rb_obj_is_kind_of(rb_obj, wxRuby_GetWindowClass()) )
65
+ {
66
+ rb_gc_mark(rb_obj);
67
+ }
68
+ else if (rb_obj_is_kind_of(rb_obj, wxRuby_GetDefaultEventClass()) )
69
+ rb_gc_mark(rb_obj);
70
+ }
71
+ else if (TYPE(rb_obj) == T_ARRAY )
72
+ {
73
+ VALUE proc = rb_ary_entry(rb_obj, 0);
74
+ if (rb_obj_is_kind_of(proc, rb_cProc) || rb_obj_is_kind_of(proc, rb_cMethod))
75
+ {
76
+ // keep the async call alive
77
+ rb_gc_mark(rb_obj);
78
+ }
79
+ }
80
+ }
81
+
82
+ // Implements GC protection across wxRuby. Always called because
83
+ // Wx::THE_APP is a constant so always checked in GC mark phase.
84
+ static void mark_wxRubyApp(void *ptr)
85
+ {
86
+
87
+ #ifdef __WXRB_DEBUG__
88
+ if (wxRuby_TraceLevel()>0)
89
+ std::wcout << "=== Starting App GC mark phase" << std::endl;
90
+ #endif
91
+
92
+ // If the App has ended, the ruby object will have been unlinked from
93
+ // the C++ one; this implies that all Windows have already been destroyed
94
+ // so there is no point trying to mark them, and doing so may cause
95
+ // errors.
96
+ if ( !wxRubyApp::GetInstance() || !wxRubyApp::GetInstance()->IsRunning() )
97
+ {
98
+ #ifdef __WXRB_DEBUG__
99
+ if (wxRuby_TraceLevel()>0)
100
+ std::wcout << "=== App not started yet or has ended, skipping mark phase" << std::endl;
101
+ #endif
102
+ return;
103
+ }
104
+
105
+ // Mark any active (tracked) log target
106
+ wxLog* curLog = wxLog::GetActiveTarget();
107
+ VALUE rb_cur_log = wxRuby_FindTracking(curLog);
108
+ if (!NIL_P(rb_cur_log))
109
+ {
110
+ rb_gc_mark(rb_cur_log);
111
+ }
112
+
113
+ // Mark evt handler procs associated with live windows - see
114
+ // classes/EvtHandler.i
115
+ wxRuby_MarkProtectedEvtHandlerProcs();
116
+
117
+ // run registered markers
118
+ for (wxVector<WXRBMarkFunction>::iterator it = WXRuby_Mark_List.begin();
119
+ it != WXRuby_Mark_List.end() ;++it)
120
+ {
121
+ (*it) ();
122
+ }
123
+
124
+ // To do the main marking, primarily of Windows, iterate over SWIG's
125
+ // list of tracked objects
126
+ wxRuby_IterateTracking(&wxRubyApp::markIterate);
127
+
128
+ #ifdef __WXRB_DEBUG__
129
+ if (wxRuby_TraceLevel()>0)
130
+ std::wcout << "=== App GC mark phase completed" << std::endl;
131
+ #endif
132
+ }
133
+
134
+ // This is the method run when main_loop is called in Ruby
135
+ // wxEntry calls the C++ App::OnInit method
136
+ int main_loop()
137
+ {
138
+ int rc = 0;
139
+
140
+ // There should ever only be only a single App instance running
141
+ if (rb_const_defined(mWxCore, rb_intern("THE_APP")))
142
+ {
143
+ rb_raise(rb_eRuntimeError, "There is already another App instance running");
144
+ return -1;
145
+ }
146
+
147
+ // Set self reference and global THE_APP constant
148
+ this->self_ = SWIG_RubyInstanceFor(this);
149
+ rb_define_const(mWxCore, "THE_APP", this->self_);
150
+ // Also cache the Ruby App reference on the stack here as after
151
+ // wxEntry returns the C++ App instance will have been destroyed
152
+ // and we cannot reference it (or it's members) anymore
153
+ VALUE the_app = this->self_;
154
+
155
+ this->Connect(wxEVT_DESTROY,
156
+ wxWindowDestroyEventHandler(wxRubyApp::OnWindowDestroy));
157
+
158
+ #ifdef __WXRB_DEBUG__
159
+ if (wxRuby_TraceLevel()>0)
160
+ std::wcout << "Calling wxEntry, this=" << this << std::endl;
161
+ #endif
162
+
163
+ // collect ruby app name and arguments array
164
+ VALUE rb_args = rb_get_argv();
165
+ int argc = 1 + RARRAY_LEN(rb_args);
166
+ std::unique_ptr<char*[]> argv_safe = std::make_unique<char*[]> (argc);
167
+ VALUE sval = rb_gv_get("$0");
168
+ argv_safe[0] = StringValuePtr(sval);
169
+ for (int i=0; i<RARRAY_LEN(rb_args) ;++i)
170
+ {
171
+ sval = rb_ary_entry(rb_args, i);
172
+ argv_safe[1+i] = StringValuePtr(sval);
173
+ }
174
+ // there is no need to copy the strings as we only need them until
175
+ // wxEntry returns
176
+
177
+ #ifdef __WXMSW__
178
+ wxApp::m_nCmdShow = SW_NORMAL;
179
+ #endif
180
+ rc = wxEntry(argc, argv_safe.get());
181
+
182
+ /*
183
+ At this point the C++ wxRubyApp instance has been destroyed so take care NOT to reference
184
+ it or any of it's members anymore but only unroll the callstack.
185
+ */
186
+
187
+ #ifdef __WXRB_DEBUG__
188
+ if (wxRuby_TraceLevel()>0)
189
+ std::wcout << "returned from wxEntry..." << std::endl;
190
+ #endif
191
+ rb_gc_start();
192
+ #ifdef __WXRB_DEBUG__
193
+ if (wxRuby_TraceLevel()>0)
194
+ std::wcout << "survived gc" << std::endl;
195
+ #endif
196
+
197
+ rb_const_remove(mWxCore, rb_intern("THE_APP"));
198
+
199
+ VALUE exc = rb_iv_get(the_app, "@exception");
200
+ if (!NIL_P(exc))
201
+ {
202
+ rb_exc_raise(exc);
203
+ }
204
+ return rc;
205
+ }
206
+
207
+ // This method initializes the stock objects (Pens, Brushes, Fonts)
208
+ // before yielding to ruby by calling the App's on_init method.
209
+ // Note that as of wxWidget 2.8, the stock fonts in particular cannot
210
+ // be initialized any earlier than this without crashing
211
+ bool OnInit() override
212
+ {
213
+ #ifdef __WXRB_DEBUG__
214
+ if (wxRuby_TraceLevel()>0)
215
+ std::wcout << "OnInit..." << std::endl;
216
+ #endif
217
+
218
+ if (!wxApp::OnInit())
219
+ return false;
220
+
221
+ // Signal that we've started
222
+ this->is_running_ = true;
223
+ // Set up the GDI objects
224
+ Init_wxRubyStockObjects();
225
+ // Get the ruby representation of the App object, and call the
226
+ // ruby on_init method to set up the initial window state
227
+ bool ex_caught = false;
228
+ VALUE result = wxRuby_Funcall(ex_caught, this->self_, rb_intern("on_ruby_init"), 0, 0);
229
+
230
+ if (ex_caught)
231
+ {
232
+ #ifdef __WXRB_DEBUG__
233
+ wxRuby_PrintException(result);
234
+ #endif
235
+ rb_iv_set(this->self_, "@exception", result);
236
+ result = Qfalse; // exit app
237
+ }
238
+
239
+ // If on_init return any (ruby) true value, signal to wxWidgets to
240
+ // enter the main event loop by returning true, else return false
241
+ // which will make wxWidgets exit.
242
+ if ( result == Qfalse || result == Qnil )
243
+ {
244
+ this->is_running_ = false;
245
+ return false;
246
+ }
247
+ else
248
+ {
249
+ return true;
250
+ }
251
+ }
252
+
253
+ int OnExit() override
254
+ {
255
+ #ifdef __WXRB_DEBUG__
256
+ if (wxRuby_TraceLevel()>0)
257
+ std::wcout << "OnExit..." << std::endl;
258
+ #endif
259
+
260
+ // Get the ruby representation of the App object, and call the
261
+ // ruby on_exit method (if any) for application level cleanup
262
+ ID on_exit_id = rb_intern("on_exit");
263
+ if (rb_funcall(this->self_, rb_intern("respond_to?"), 1, ID2SYM(on_exit_id)) == Qtrue)
264
+ {
265
+ bool ex_caught = false;
266
+ VALUE rc = wxRuby_Funcall(ex_caught, this->self_, on_exit_id, 0, 0);
267
+ if (ex_caught)
268
+ {
269
+ #ifdef __WXRB_DEBUG__
270
+ wxRuby_PrintException(rc);
271
+ #endif
272
+ rb_iv_set(this->self_, "@exception", rc);
273
+ }
274
+ }
275
+
276
+ // perform wxRuby cleanup
277
+ _wxRuby_Cleanup();
278
+
279
+ // execute base wxWidgets functionality
280
+ return this->wxApp::OnExit();
281
+ }
282
+
283
+ // actually implemented in ruby in classes/app.rb
284
+ virtual void OnAssertFailure(const wxChar *file, int line, const wxChar *func, const wxChar *cond, const wxChar *msg) override
285
+ {
286
+ if (rb_during_gc() || NIL_P(this->self_))
287
+ {
288
+ std::wcerr << file << "(" << line << "): ASSERT " << cond
289
+ << (NIL_P(this->self_) ? " fired without THE_APP in " : " fired during GC phase in ")
290
+ << func << "() with message [" << msg << "]" << std::endl;
291
+ }
292
+ else
293
+ {
294
+ VALUE obj0 = Qnil ;
295
+ VALUE obj1 = Qnil ;
296
+ VALUE obj2 = Qnil ;
297
+ VALUE obj3 = Qnil ;
298
+ VALUE obj4 = Qnil ;
299
+
300
+ obj0 = rb_str_new2((const char *)wxString(file).utf8_str());
301
+ obj1 = INT2NUM(line);
302
+ obj2 = rb_str_new2((const char *)wxString(func).utf8_str());
303
+ obj3 = rb_str_new2((const char *)wxString(cond).utf8_str());
304
+ obj4 = rb_str_new2((const char *)wxString(msg).utf8_str());
305
+ (void)wxRuby_Funcall(this->self_, rb_intern("on_assert_failure"), 5,obj0,obj1,obj2,obj3,obj4);
306
+ }
307
+ }
308
+
309
+ void _wxRuby_Cleanup()
310
+ {
311
+ #ifdef __WXRB_DEBUG__
312
+ if (wxRuby_TraceLevel()>0)
313
+ std::wcout << "wxRuby_Cleanup..." << std::endl;
314
+ #endif
315
+ // Note in a global variable that the App has ended, so that we
316
+ // can skip any GC marking later
317
+ this->is_running_ = false;
318
+
319
+ // if a Ruby implemented logger has been installed clean that up
320
+ // before we exit, otherwise let wxWidgets handle things
321
+ wxLog *oldlog = wxLog::GetActiveTarget();
322
+ if (wxRuby_FindTracking(oldlog) != Qnil)
323
+ {
324
+ oldlog = wxLog::SetActiveTarget(new wxLogStderr);
325
+ }
326
+ else
327
+ {
328
+ oldlog = 0;
329
+ }
330
+ SetTopWindow(0);
331
+ if ( oldlog )
332
+ {
333
+ SWIG_RubyUnlinkObjects(oldlog);
334
+ SWIG_RubyRemoveTracking(oldlog);
335
+ delete oldlog;
336
+ }
337
+ }
338
+ };
@@ -456,7 +456,7 @@ protected:
456
456
  }
457
457
 
458
458
  #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
459
- virtual bool DoReadLongLong(const wxString& key, wxLongLong_t *pll) const
459
+ virtual bool DoReadLongLong(const wxString& key, wxLongLong_t *pll) const override
460
460
  {
461
461
  wxConfigPathChanger path(this, key);
462
462
 
@@ -487,7 +487,7 @@ protected:
487
487
  }
488
488
  #endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
489
489
 
490
- virtual bool DoReadDouble(const wxString& key, double* val) const
490
+ virtual bool DoReadDouble(const wxString& key, double* val) const override
491
491
  {
492
492
  wxConfigPathChanger path(this, key);
493
493
 
@@ -517,7 +517,7 @@ protected:
517
517
  }
518
518
  }
519
519
 
520
- virtual bool DoReadBool(const wxString& key, bool* val) const
520
+ virtual bool DoReadBool(const wxString& key, bool* val) const override
521
521
  {
522
522
  wxConfigPathChanger path(this, key);
523
523
 
@@ -637,7 +637,7 @@ protected:
637
637
  }
638
638
 
639
639
  #ifdef wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
640
- virtual bool DoWriteLongLong(const wxString& key, wxLongLong_t value)
640
+ virtual bool DoWriteLongLong(const wxString& key, wxLongLong_t value) override
641
641
  {
642
642
  wxConfigPathChanger path(this, key);
643
643
  wxString strName = path.Name();
@@ -675,7 +675,7 @@ protected:
675
675
  }
676
676
  #endif // wxHAS_LONG_LONG_T_DIFFERENT_FROM_LONG
677
677
 
678
- virtual bool DoWriteDouble(const wxString& key, double value)
678
+ virtual bool DoWriteDouble(const wxString& key, double value) override
679
679
  {
680
680
  wxConfigPathChanger path(this, key);
681
681
  wxString strName = path.Name();
@@ -712,7 +712,7 @@ protected:
712
712
  return true;
713
713
  }
714
714
 
715
- virtual bool DoWriteBool(const wxString& key, bool value)
715
+ virtual bool DoWriteBool(const wxString& key, bool value) override
716
716
  {
717
717
  wxConfigPathChanger path(this, key);
718
718
  wxString strName = path.Name();
@@ -62,6 +62,9 @@ WXRUBY_EXPORT bool GC_IsWindowDeleted(void *ptr);
62
62
  WXRUBY_EXPORT swig_type_info* wxRuby_GetSwigTypeForClass(VALUE cls);
63
63
  WXRUBY_EXPORT swig_type_info* wxRuby_GetSwigTypeForClassName(const char* clsname);
64
64
  WXRUBY_EXPORT void wxRuby_SetSwigTypeForClass(VALUE cls, swig_type_info* ty);
65
+ // and wx class names -> Ruby class
66
+ WXRUBY_EXPORT void wxRuby_SetRbClassForWxName(const wxString& wx_name, VALUE cls);
67
+ WXRUBY_EXPORT VALUE wxRuby_GetRbClassForWxName(const wxString& wx_name);
65
68
 
66
69
  // Common wrapping functions
67
70
  WXRUBY_EXPORT VALUE wxRuby_WrapWxObjectInRuby(wxObject* obj);
@@ -13,6 +13,28 @@
13
13
  %feature("compactdefaultargs");
14
14
  %feature("flatnested");
15
15
 
16
+ %exception {
17
+ try {
18
+ $action
19
+ }
20
+ catch (const Swig::DirectorException& swigex) {
21
+ if (rb_obj_is_kind_of(swigex.getError(), rb_eException))
22
+ {
23
+ rb_exc_raise(swigex.getError());
24
+ }
25
+ else
26
+ {
27
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
28
+ }
29
+ }
30
+ catch (const std::exception& ex) {
31
+ rb_raise(rb_eRuntimeError, "Unexpected C++ exception: %s", ex.what());
32
+ }
33
+ catch (...) {
34
+ rb_raise(rb_eRuntimeError, "Unexpected UNKNOWN exception");
35
+ }
36
+ }
37
+
16
38
  %begin %{
17
39
  /*
18
40
  * Since SWIG does not provide readily usable export macros