wxruby3 0.9.1 → 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 (153) 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/swig/common.i +1 -1
  6. data/lib/wx/aui/aui_tab_ctrl.rb +18 -0
  7. data/lib/wx/aui/auinotebook.rb +6 -2
  8. data/lib/wx/aui/require.rb +1 -0
  9. data/lib/wx/core/app.rb +2 -2
  10. data/lib/wx/core/collapsible_pane.rb +1 -1
  11. data/lib/wx/core/controlwithitems.rb +8 -6
  12. data/lib/wx/core/menu.rb +10 -0
  13. data/lib/wx/core/notebook.rb +6 -2
  14. data/lib/wx/core/sizer.rb +11 -0
  15. data/lib/wx/core/task_bar_button.rb +19 -0
  16. data/lib/wx/core/textctrl.rb +11 -1
  17. data/lib/wx/core/{treectrl.rb → tree_ctrl.rb} +31 -12
  18. data/lib/wx/core/window.rb +10 -0
  19. data/lib/wx/doc/app.rb +48 -38
  20. data/lib/wx/doc/art_locator.rb +47 -43
  21. data/lib/wx/doc/aui/auimanager.rb +16 -8
  22. data/lib/wx/doc/aui/auinotebook.rb +20 -5
  23. data/lib/wx/doc/clipboard.rb +11 -7
  24. data/lib/wx/doc/colour_dialog.rb +14 -10
  25. data/lib/wx/doc/controlwithitems.rb +17 -7
  26. data/lib/wx/doc/data_object.rb +2 -2
  27. data/lib/wx/doc/evthandler.rb +113 -108
  28. data/lib/wx/doc/font.rb +1 -0
  29. data/lib/wx/doc/gc_dc.rb +6 -1
  30. data/lib/wx/doc/graphics_context.rb +1 -0
  31. data/lib/wx/doc/grid/grid.rb +22 -1
  32. data/lib/wx/doc/help_controller.rb +11 -7
  33. data/lib/wx/doc/html/html_help_controller.rb +12 -4
  34. data/lib/wx/doc/list_ctrl.rb +33 -29
  35. data/lib/wx/doc/menu.rb +20 -0
  36. data/lib/wx/doc/notebook.rb +21 -0
  37. data/lib/wx/doc/pg/events.rb +13 -9
  38. data/lib/wx/doc/pg/pg_property.rb +18 -0
  39. data/lib/wx/doc/progress_dialog.rb +36 -32
  40. data/lib/wx/doc/prt/page_setup_dialog.rb +20 -12
  41. data/lib/wx/doc/prt/print_data.rb +13 -5
  42. data/lib/wx/doc/prt/print_dialog.rb +31 -23
  43. data/lib/wx/doc/prt/printer.rb +20 -12
  44. data/lib/wx/doc/radio_box.rb +19 -15
  45. data/lib/wx/doc/rbn/ribbon_bar.rb +13 -5
  46. data/lib/wx/doc/rbn/ribbon_button_bar.rb +13 -5
  47. data/lib/wx/doc/rbn/ribbon_gallery.rb +13 -5
  48. data/lib/wx/doc/rbn/ribbon_tool_bar.rb +13 -5
  49. data/lib/wx/doc/region_iterator.rb +32 -28
  50. data/lib/wx/doc/rtc/rich_text_composite_object.rb +24 -0
  51. data/lib/wx/doc/rtc/rich_text_ctrl.rb +24 -0
  52. data/lib/wx/doc/rtc/rich_text_paragraph.rb +24 -0
  53. data/lib/wx/doc/rtc/richtext_buffer.rb +27 -19
  54. data/lib/wx/doc/rtc/richtext_printing.rb +17 -9
  55. data/lib/wx/doc/rtc/richtext_style_sheet.rb +17 -9
  56. data/lib/wx/doc/sizer.rb +20 -0
  57. data/lib/wx/doc/stc/styled_text_ctrl.rb +24 -0
  58. data/lib/wx/doc/stream.rb +39 -35
  59. data/lib/wx/doc/system_settings.rb +30 -26
  60. data/lib/wx/doc/text_validator.rb +12 -8
  61. data/lib/wx/doc/textctrl.rb +16 -0
  62. data/lib/wx/doc/tree_ctrl.rb +95 -0
  63. data/lib/wx/doc/treebook.rb +9 -5
  64. data/lib/wx/doc/v_list_box.rb +9 -5
  65. data/lib/wx/doc/variant.rb +164 -160
  66. data/lib/wx/doc/window.rb +57 -47
  67. data/lib/wx/doc/window_disabler.rb +10 -6
  68. data/lib/wx/grid/grid.rb +27 -4
  69. data/lib/wx/pg/pg_property.rb +22 -0
  70. data/lib/wx/rtc/require.rb +3 -0
  71. data/lib/wx/rtc/rich_text_composite_object.rb +25 -0
  72. data/lib/wx/rtc/rich_text_ctrl.rb +25 -0
  73. data/lib/wx/rtc/rich_text_paragraph.rb +25 -0
  74. data/lib/wx/stc/require.rb +1 -0
  75. data/lib/wx/stc/styled_text_ctrl.rb +25 -0
  76. data/lib/wx/version.rb +1 -1
  77. data/rakelib/lib/config/linux.rb +0 -3
  78. data/rakelib/lib/config/macosx.rb +2 -2
  79. data/rakelib/lib/config/mingw.rb +1 -1
  80. data/rakelib/lib/config/unixish.rb +1 -1
  81. data/rakelib/lib/config.rb +14 -4
  82. data/rakelib/lib/core/package.rb +14 -7
  83. data/rakelib/lib/core/spec.rb +6 -1
  84. data/rakelib/lib/director/accelerator.rb +2 -3
  85. data/rakelib/lib/director/accessible.rb +47 -0
  86. data/rakelib/lib/director/app.rb +12 -319
  87. data/rakelib/lib/director/app_traits.rb +10 -12
  88. data/rakelib/lib/director/ctrl_with_items.rb +17 -5
  89. data/rakelib/lib/director/data_format.rb +1 -1
  90. data/rakelib/lib/director/derived_dc.rb +1 -1
  91. data/rakelib/lib/director/dialog.rb +1 -0
  92. data/rakelib/lib/director/drag_image.rb +2 -3
  93. data/rakelib/lib/director/event.rb +2 -2
  94. data/rakelib/lib/director/frame.rb +1 -3
  95. data/rakelib/lib/director/gdicommon.rb +8 -10
  96. data/rakelib/lib/director/graphics_context.rb +2 -4
  97. data/rakelib/lib/director/grid_ctrl.rb +34 -3
  98. data/rakelib/lib/director/icon.rb +5 -2
  99. data/rakelib/lib/director/list_ctrl.rb +5 -6
  100. data/rakelib/lib/director/locale.rb +1 -3
  101. data/rakelib/lib/director/log.rb +1 -4
  102. data/rakelib/lib/director/media_ctrl.rb +54 -0
  103. data/rakelib/lib/director/menu.rb +16 -1
  104. data/rakelib/lib/director/menu_item.rb +2 -2
  105. data/rakelib/lib/director/pgproperties.rb +1 -1
  106. data/rakelib/lib/director/pgproperty.rb +24 -1
  107. data/rakelib/lib/director/property_grid_interface.rb +5 -10
  108. data/rakelib/lib/director/richtext_composite_object.rb +25 -0
  109. data/rakelib/lib/director/richtext_ctrl.rb +14 -4
  110. data/rakelib/lib/director/richtext_formatting_dialog.rb +7 -5
  111. data/rakelib/lib/director/richtext_paragraph_layout_box.rb +9 -7
  112. data/rakelib/lib/director/sizer.rb +15 -0
  113. data/rakelib/lib/director/static_box.rb +4 -5
  114. data/rakelib/lib/director/styled_text_ctrl.rb +12 -0
  115. data/rakelib/lib/director/task_bar_button.rb +30 -0
  116. data/rakelib/lib/director/task_bar_icon.rb +5 -13
  117. data/rakelib/lib/director/textctrl.rb +12 -1
  118. data/rakelib/lib/director/tool_tip.rb +1 -1
  119. data/rakelib/lib/director/top_level_window.rb +4 -5
  120. data/rakelib/lib/director/tree_ctrl.rb +5 -6
  121. data/rakelib/lib/director/variant.rb +1 -1
  122. data/rakelib/lib/director/window.rb +24 -5
  123. data/rakelib/lib/director.rb +4 -4
  124. data/rakelib/lib/extractor/function.rb +6 -6
  125. data/rakelib/lib/extractor.rb +34 -5
  126. data/rakelib/lib/generate/analyzer.rb +8 -3
  127. data/rakelib/lib/generate/doc/busy_info.yaml +0 -2
  128. data/rakelib/lib/generate/doc/clipboard.yaml +0 -2
  129. data/rakelib/lib/generate/doc/cursor.yaml +0 -2
  130. data/rakelib/lib/generate/doc/panel.yaml +7 -0
  131. data/rakelib/lib/generate/doc.rb +76 -14
  132. data/rakelib/lib/specs/interfaces.rb +161 -160
  133. data/rakelib/lib/typemap/common.rb +30 -1
  134. data/rakelib/yard/templates/default/fulldoc/html/css/wxruby3.css +74 -2
  135. data/rakelib/yard/templates/default/fulldoc/html/full_list.erb +38 -0
  136. data/rakelib/yard/templates/default/fulldoc/html/setup.rb +39 -0
  137. data/rakelib/yard/templates/default/tags/html/wxrb_require.erb +10 -0
  138. data/rakelib/yard/templates/default/tags/setup.rb +16 -0
  139. data/rakelib/yard/yard-custom-templates.rb +3 -0
  140. data/samples/treectrl/treectrl.rb +1 -1
  141. data/tests/media/beep_lo.wav +0 -0
  142. data/tests/test_list_ctrl.rb +1 -1
  143. data/tests/test_media_ctrl.rb +38 -0
  144. data/tests/test_menu.rb +69 -0
  145. data/tests/test_pg.rb +27 -0
  146. data/tests/test_richtext.rb +45 -0
  147. data/tests/test_sizer.rb +16 -0
  148. data/tests/test_std_controls.rb +42 -1
  149. data/tests/test_styled_text_ctrl.rb +46 -0
  150. data/tests/test_tree_ctrl.rb +138 -0
  151. data/tests/test_window.rb +12 -0
  152. data/tests/testapp_noframe.rb +1 -1
  153. metadata +31 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8b5236fc5965ca7cb7f44f6ffa69c74af04529217c2ac85178b04b719781407c
4
- data.tar.gz: 745d4f4b7b6168a764d47dfa640128666a57922bf90c9d43757a7726ae4d3c75
3
+ metadata.gz: 94bf5f5a3d4107e4a77c02971756de87b044c3d9edfbedd0b0aa0fe3e95e6ae7
4
+ data.tar.gz: 83d78771dde19401cbb0e5f915c7eb86903bf76357f1a1d0be4d10edf1f0d4a7
5
5
  SHA512:
6
- metadata.gz: 613f0bce684a98834ddc99031b1dbe0cb4aa04448d8f88aa20dd1cf71c938d3539e0e26ec46a096373a83fc2c542f73d9163ca0e1be2428c3854a583f3e974da
7
- data.tar.gz: 888271b35ed4a18bd776c8249ae5bc83ec51ec7930d1b58954e829da508ceb500fcf14e0340009a0410c2e009a5ffbf99109a5a22a447ca52b00982d722800e3
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();
@@ -24,7 +24,7 @@
24
24
  }
25
25
  else
26
26
  {
27
- rb_raise(swigex.getError(), swigex.what());
27
+ rb_exc_raise(rb_exc_new_cstr(swigex.getError(), swigex.what()));
28
28
  }
29
29
  }
30
30
  catch (const std::exception& ex) {
@@ -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
 
@@ -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)