wxruby3 0.9.0.pre.rc.1 → 0.9.0.pre.rc.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (160) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +73 -22
  3. data/README.md +40 -8
  4. data/assets/hello_button-macos.png +0 -0
  5. data/assets/hello_button-msw.png +0 -0
  6. data/assets/hello_button_clicked-macos.png +0 -0
  7. data/assets/hello_button_clicked-msw.png +0 -0
  8. data/assets/hello_button_clicked_combi.png +0 -0
  9. data/assets/hello_world-macos.png +0 -0
  10. data/assets/hello_world-msw.png +0 -0
  11. data/assets/hello_world_combi.png +0 -0
  12. data/ext/wxruby3/swig/wx.i +2 -0
  13. data/lib/wx/core/brush.rb +6 -0
  14. data/lib/wx/core/event_loop.rb +7 -0
  15. data/lib/wx/core/evthandler.rb +12 -2
  16. data/lib/wx/core/font.rb +22 -14
  17. data/lib/wx/core/helpprovider.rb +2 -2
  18. data/lib/wx/core/image.rb +33 -0
  19. data/lib/wx/core/listctrl.rb +17 -13
  20. data/lib/wx/core/log.rb +90 -0
  21. data/lib/wx/core/menu.rb +5 -0
  22. data/lib/wx/core/pen.rb +6 -0
  23. data/lib/wx/core/window.rb +28 -1
  24. data/lib/wx/doc/app.rb +40 -0
  25. data/lib/wx/doc/bitmap.rb +11 -15
  26. data/lib/wx/doc/brush.rb +17 -0
  27. data/lib/wx/doc/event_loop.rb +7 -0
  28. data/lib/wx/doc/extra/00_starting.md +6 -6
  29. data/lib/wx/doc/extra/02_lifecycles.md +9 -8
  30. data/lib/wx/doc/extra/09_exceptions.md +1 -1
  31. data/lib/wx/doc/extra/11_drawing_and_dc.md +4 -4
  32. data/lib/wx/doc/font.rb +27 -0
  33. data/lib/wx/doc/functions.rb +51 -23
  34. data/lib/wx/doc/gc_dc.rb +1 -1
  35. data/lib/wx/doc/image.rb +42 -12
  36. data/lib/wx/doc/list_ctrl.rb +32 -0
  37. data/lib/wx/doc/log.rb +28 -0
  38. data/lib/wx/doc/pen.rb +17 -0
  39. data/lib/wx/doc/prt/printer_dc.rb +2 -2
  40. data/lib/wx/doc/radio_box.rb +20 -0
  41. data/lib/wx/doc/scaled_dc.rb +1 -1
  42. data/lib/wx/doc/text_validator.rb +12 -0
  43. data/lib/wx/doc/window.rb +27 -0
  44. data/lib/wx/keyword_defs.rb +77 -76
  45. data/lib/wx/prt/keyword_defs.rb +5 -1
  46. data/lib/wx/version.rb +1 -1
  47. data/rakelib/install.rb +17 -6
  48. data/rakelib/lib/config/linux.rb +4 -2
  49. data/rakelib/lib/config/macosx.rb +120 -1
  50. data/rakelib/lib/config/mingw.rb +6 -1
  51. data/rakelib/lib/config/unixish.rb +26 -11
  52. data/rakelib/lib/config.rb +15 -6
  53. data/rakelib/lib/core/mapping.rb +15 -10
  54. data/rakelib/lib/core/package.rb +4 -1
  55. data/rakelib/lib/core/spec.rb +23 -12
  56. data/rakelib/lib/core/spec_helper.rb +6 -0
  57. data/rakelib/lib/director/app.rb +30 -1
  58. data/rakelib/lib/director/aui_toolbar.rb +41 -0
  59. data/rakelib/lib/director/brush.rb +10 -1
  60. data/rakelib/lib/director/combobox.rb +1 -1
  61. data/rakelib/lib/director/context_help_button.rb +23 -0
  62. data/rakelib/lib/director/dialog.rb +33 -2
  63. data/rakelib/lib/director/event_loop.rb +26 -0
  64. data/rakelib/lib/director/font.rb +12 -3
  65. data/rakelib/lib/director/functions.rb +44 -48
  66. data/rakelib/lib/director/help_provider.rb +8 -10
  67. data/rakelib/lib/director/hyperlink_event.rb +22 -0
  68. data/rakelib/lib/director/image.rb +32 -0
  69. data/rakelib/lib/director/list_ctrl.rb +3 -2
  70. data/rakelib/lib/director/log.rb +64 -4
  71. data/rakelib/lib/director/menu.rb +0 -3
  72. data/rakelib/lib/director/menu_bar.rb +3 -0
  73. data/rakelib/lib/director/pen.rb +10 -1
  74. data/rakelib/lib/director/popup_window.rb +18 -0
  75. data/rakelib/lib/director/radio_box.rb +15 -4
  76. data/rakelib/lib/director/searchctrl.rb +2 -1
  77. data/rakelib/lib/director/static_box.rb +1 -1
  78. data/rakelib/lib/director/styled_text_ctrl.rb +1 -1
  79. data/rakelib/lib/director/text_entry.rb +30 -0
  80. data/rakelib/lib/director/text_validator.rb +8 -2
  81. data/rakelib/lib/director/textctrl.rb +1 -1
  82. data/rakelib/lib/director/variant.rb +17 -4
  83. data/rakelib/lib/director/window.rb +37 -1
  84. data/rakelib/lib/extractor/function.rb +7 -7
  85. data/rakelib/lib/extractor/variable.rb +6 -6
  86. data/rakelib/lib/generate/doc/aui_manager.yaml +21 -0
  87. data/rakelib/lib/generate/doc/context_help_button.yaml +16 -0
  88. data/rakelib/lib/generate/doc/event_blocker.yaml +27 -0
  89. data/rakelib/lib/generate/doc/event_filter.yaml +47 -0
  90. data/rakelib/lib/generate/doc/file_dialog.yaml +68 -0
  91. data/rakelib/lib/generate/doc/font.yaml +29 -0
  92. data/rakelib/lib/generate/doc/frame.yaml +23 -0
  93. data/rakelib/lib/generate/doc/fs_file.yaml +11 -0
  94. data/rakelib/lib/generate/doc/gdi_common.yaml +36 -0
  95. data/rakelib/lib/generate/doc/graphics_context.yaml +34 -0
  96. data/rakelib/lib/generate/doc/gui_event_loop.yaml +12 -0
  97. data/rakelib/lib/generate/doc/help_controller.yaml +24 -0
  98. data/rakelib/lib/generate/doc/icon.yaml +11 -0
  99. data/rakelib/lib/generate/doc/image.yaml +87 -0
  100. data/rakelib/lib/generate/doc/keyboard_state.yaml +19 -0
  101. data/rakelib/lib/generate/doc/list_ctrl.yaml +77 -0
  102. data/rakelib/lib/generate/doc/locale.yaml +12 -0
  103. data/rakelib/lib/generate/doc/log.yaml +86 -0
  104. data/rakelib/lib/generate/doc/mdi_frame.yaml +12 -0
  105. data/rakelib/lib/generate/doc/memory_dc.yaml +42 -0
  106. data/rakelib/lib/generate/doc/menu.yaml +17 -0
  107. data/rakelib/lib/generate/doc/menu_item.yaml +43 -0
  108. data/rakelib/lib/generate/doc/message_dialog.yaml +36 -0
  109. data/rakelib/lib/generate/doc/non_owned_window.yaml +14 -0
  110. data/rakelib/lib/generate/doc/notebook.yaml +18 -0
  111. data/rakelib/lib/generate/doc/pen.yaml +11 -0
  112. data/rakelib/lib/generate/doc/picker_base.yaml +19 -0
  113. data/rakelib/lib/generate/doc/platform_info.yaml +15 -0
  114. data/rakelib/lib/generate/doc/property_sheet_dialog.yaml +26 -0
  115. data/rakelib/lib/generate/doc/scroll_bar.yaml +11 -0
  116. data/rakelib/lib/generate/doc/scrolled_canvas.yaml +37 -0
  117. data/rakelib/lib/generate/doc/scrolled_control.yaml +37 -0
  118. data/rakelib/lib/generate/doc/scrolled_window.yaml +37 -0
  119. data/rakelib/lib/generate/doc/sizer.yaml +69 -0
  120. data/rakelib/lib/generate/doc/splash_screen.yaml +18 -0
  121. data/rakelib/lib/generate/doc/static_box.yaml +52 -0
  122. data/rakelib/lib/generate/doc/static_box_sizer.yaml +22 -0
  123. data/rakelib/lib/generate/doc/svg_file_dc.yaml +11 -0
  124. data/rakelib/lib/generate/doc/text_ctrl.yaml +19 -0
  125. data/rakelib/lib/generate/doc/text_entry.yaml +42 -0
  126. data/rakelib/lib/generate/doc/text_entry_dialog.yaml +17 -0
  127. data/rakelib/lib/generate/doc/timer_event.yaml +28 -0
  128. data/rakelib/lib/generate/doc/tool_bar.yaml +35 -0
  129. data/rakelib/lib/generate/doc/top_level_window.yaml +23 -0
  130. data/rakelib/lib/generate/doc/validator.yaml +12 -0
  131. data/rakelib/lib/generate/doc/variant.yaml +29 -0
  132. data/rakelib/lib/generate/doc/window.yaml +249 -0
  133. data/rakelib/lib/generate/doc/wizard_page_simple.yaml +14 -0
  134. data/rakelib/lib/generate/doc/xml_node.yaml +7 -0
  135. data/rakelib/lib/generate/doc/xml_resource.yaml +27 -0
  136. data/rakelib/lib/generate/doc.rb +36 -2
  137. data/rakelib/lib/generate/interface.rb +11 -10
  138. data/rakelib/lib/specs/interfaces.rb +5 -1
  139. data/rakelib/lib/swig_runner.rb +37 -0
  140. data/samples/aui/aui.rb +432 -363
  141. data/samples/propgrid/propgrid.rb +3 -0
  142. data/samples/sampler/editor.rb +33 -25
  143. data/samples/sampler/sample.rb +2 -2
  144. data/samples/sampler/stc_editor.rb +4 -2
  145. data/tests/lib/item_container_tests.rb +82 -0
  146. data/tests/lib/text_entry_tests.rb +80 -0
  147. data/tests/lib/wxapp_runner.rb +12 -0
  148. data/tests/lib/wxframe_runner.rb +89 -4
  149. data/tests/test_art.rb +9 -0
  150. data/tests/test_box_sizer.rb +161 -0
  151. data/tests/test_ext_controls.rb +28 -0
  152. data/tests/test_font.rb +239 -0
  153. data/tests/test_grid_sizer.rb +148 -0
  154. data/tests/test_intl.rb +5 -1
  155. data/tests/test_list_ctrl.rb +53 -0
  156. data/tests/test_log.rb +163 -0
  157. data/tests/test_std_controls.rb +321 -37
  158. data/tests/test_timer.rb +95 -0
  159. data/tests/test_window.rb +340 -0
  160. metadata +85 -2
@@ -0,0 +1,26 @@
1
+ ###
2
+ # wxRuby3 wxWidgets interface director
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ module WXRuby3
7
+
8
+ class Director
9
+
10
+ class GUIEventLoop < Director
11
+
12
+ def setup
13
+ super
14
+ spec.items << 'wxEventLoopBase'
15
+ spec.gc_as_untracked
16
+ spec.disable_proxies
17
+ spec.make_concrete 'wxGUIEventLoop'
18
+ spec.fold_bases 'wxGUIEventLoop' => 'wxEventLoopBase'
19
+ spec.ignore 'wxEventLoopBase::GetActive',
20
+ 'wxEventLoopBase::SetActive'
21
+ end
22
+ end # class GUIEventLoop
23
+
24
+ end # class Director
25
+
26
+ end # module WXRuby3
@@ -24,9 +24,7 @@ module WXRuby3
24
24
  'wxFont::GetDefaultEncoding',
25
25
  'wxFont::SetDefaultEncoding'
26
26
  spec.rename_for_ruby 'create' => 'wxFont::New'
27
- spec.ignore %w[
28
- wxFont::SetNativeFontInfo wxFont::GetNativeFontInfo wxFont::operator!=
29
- ]
27
+ spec.ignore [ 'wxFont::SetNativeFontInfo(const wxNativeFontInfo &)', 'wxFont::GetNativeFontInfo', 'wxFont::operator!=' ]
30
28
  spec.ignore 'wxFont::wxFont(const wxNativeFontInfo &)'
31
29
  if Config.instance.wx_port == :wxQT
32
30
  # not implemented
@@ -87,6 +85,17 @@ module WXRuby3
87
85
  return SWIG_NewPointerObj(new wxFont(font), SWIGTYPE_p_wxFont, SWIG_POINTER_OWN);
88
86
  }
89
87
  __HEREDOC
88
+ # implement wxTheFontList methods as static methods of Wx::Font
89
+ spec.add_extend_code 'wxFont', <<~__HEREDOC
90
+ static wxFont * find_or_create_font(int point_size, wxFontFamily family, wxFontStyle style, wxFontWeight weight, bool underline=false, const wxString &facename=wxEmptyString, wxFontEncoding encoding=wxFONTENCODING_DEFAULT)
91
+ {
92
+ return wxTheFontList->FindOrCreateFont(point_size, family, style, weight, underline, facename, encoding);
93
+ }
94
+ static wxFont * find_or_create_font(const wxFontInfo &fontInfo)
95
+ {
96
+ return wxTheFontList->FindOrCreateFont(fontInfo);
97
+ }
98
+ __HEREDOC
90
99
  spec.do_not_generate :functions
91
100
  end
92
101
 
@@ -30,93 +30,89 @@ module WXRuby3
30
30
  // sprintf in ruby, then pass the composed message directly to the
31
31
  // log. This also avoids format string attacks.
32
32
 
33
+ static WxRuby_ID __filename_id("filename");
34
+ static WxRuby_ID __line_id("line");
35
+ static WxRuby_ID __func_id("func");
36
+ static WxRuby_ID __comp_id("component");
37
+
38
+ static const char* __wxruby_component = "wxapp";
39
+
40
+ // As the wxw logger will only make synchronous use of the filename, func and component pointers while
41
+ // processing the log entry and never store them we simply gather pointers but no copies
42
+ static void do_log(wxLogLevel lvl, int argc, VALUE *argv, ...)
43
+ {
44
+ const char* filename = nullptr;
45
+ int line = 0;
46
+ const char* func = nullptr;
47
+ const char* component = __wxruby_component;
48
+
49
+ if (argc>1 && TYPE(argv[argc-1]) == T_HASH)
50
+ {
51
+ VALUE rb_hash = argv[--argc];
52
+ VALUE rb_fnm = rb_hash_aref(rb_hash, ID2SYM(__filename_id.get_id()));
53
+ if (!NIL_P(rb_fnm) && TYPE(rb_fnm) == T_STRING) filename = StringValuePtr(rb_fnm);
54
+ VALUE rb_ln = rb_hash_aref(rb_hash, ID2SYM(__line_id.get_id()));
55
+ if (!NIL_P(rb_ln) && TYPE(rb_ln) == T_FIXNUM) line = NUM2INT(rb_ln);
56
+ VALUE rb_func = rb_hash_aref(rb_hash, ID2SYM(__func_id.get_id()));
57
+ if (!NIL_P(rb_func) && TYPE(rb_func) == T_STRING) func = StringValuePtr(rb_func);
58
+ VALUE rb_comp = rb_hash_aref(rb_hash, ID2SYM(__comp_id.get_id()));
59
+ if (!NIL_P(rb_comp) && TYPE(rb_comp) == T_STRING) component = StringValuePtr(rb_comp);
60
+ }
61
+
62
+ VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
63
+ va_list list;
64
+ va_start(list, argv); // just a dummy to satisfy wxLogger::LogV
65
+ wxLogger(lvl, filename, line, func, component).LogV(RSTR_TO_WXSTR(log_msg), list);
66
+ }
67
+
33
68
  // Log a Wx message with the given level to the current Wx log output
34
69
  static VALUE log_generic(int argc, VALUE *argv, VALUE self)
35
70
  {
36
- if ( wxLog::IsEnabled() )
37
- {
38
- wxLogLevel lvl = static_cast<wxLogLevel> (NUM2INT(argv[0]));
39
- VALUE log_msg = argc==2 ? argv[1] : rb_f_sprintf(argc-1, &argv[1]);
40
- wxLog::OnLog( lvl,
41
- wxString(StringValuePtr(log_msg), wxConvUTF8),
42
- time(NULL) );
43
- }
71
+ wxLogLevel lvl = static_cast<wxLogLevel> (NUM2INT(argv[0]));
72
+ do_log(lvl, argc-1, &argv[1]);
44
73
  return Qnil;
45
74
  }
46
75
 
47
76
  // Log a Wx low prio Message to the current Wx log output
48
77
  static VALUE log_info(int argc, VALUE *argv, VALUE self)
49
78
  {
50
- if ( wxLog::IsEnabled() )
51
- {
52
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
53
- wxLog::OnLog( wxLOG_Info,
54
- wxString(StringValuePtr(log_msg), wxConvUTF8),
55
- time(NULL) );
56
- }
79
+ do_log(wxLOG_Info, argc, argv);
57
80
  return Qnil;
58
81
  }
59
82
 
60
83
  // Log a Wx verbose Message to the current Wx log output
61
84
  static VALUE log_verbose(int argc, VALUE *argv, VALUE self)
62
85
  {
63
- if ( wxLog::IsEnabled() && wxLog::GetVerbose () )
64
- {
65
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
66
- wxLog::OnLog( wxLOG_Info,
67
- wxString(StringValuePtr(log_msg), wxConvUTF8),
68
- time(NULL) );
69
- }
86
+ if (wxLog::GetVerbose ())
87
+ do_log(wxLOG_Info, argc, argv);
70
88
  return Qnil;
71
89
  }
72
90
 
73
91
  // Log a Wx Message to the current Wx log output
74
92
  static VALUE log_message(int argc, VALUE *argv, VALUE self)
75
93
  {
76
- if ( wxLog::IsEnabled() )
77
- {
78
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
79
- wxLog::OnLog( wxLOG_Message,
80
- wxString(StringValuePtr(log_msg), wxConvUTF8),
81
- time(NULL) );
82
- }
94
+ do_log(wxLOG_Message, argc, argv);
83
95
  return Qnil;
84
96
  }
85
97
 
86
98
  // Log a Wx Warning message to the current Wx log output
87
99
  static VALUE log_warning(int argc, VALUE *argv, VALUE self)
88
100
  {
89
- if ( wxLog::IsEnabled() )
90
- {
91
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
92
- wxLog::OnLog( wxLOG_Warning,
93
- wxString(StringValuePtr(log_msg), wxConvUTF8),
94
- time(NULL) );
95
- }
101
+ do_log(wxLOG_Warning, argc, argv);
96
102
  return Qnil;
97
103
  }
98
104
 
99
105
  // Log an error message to the current output
100
106
  static VALUE log_error(int argc, VALUE *argv, VALUE self)
101
107
  {
102
- if ( wxLog::IsEnabled() )
103
- {
104
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
105
- wxLog::OnLog( wxLOG_Error,
106
- wxString(StringValuePtr(log_msg), wxConvUTF8),
107
- time(NULL) );
108
- }
108
+ do_log(wxLOG_Error, argc, argv);
109
109
  return Qnil;
110
110
  }
111
111
 
112
112
  // Log a debug message
113
113
  static VALUE log_debug(int argc, VALUE *argv, VALUE self)
114
114
  {
115
- if (wxLog::IsLevelEnabled(wxLOG_Debug, wxASCII_STR(wxLOG_COMPONENT)))
116
- {
117
- VALUE log_msg = argc==1 ? argv[0] : rb_f_sprintf(argc, argv);
118
- wxLogDebug(wxString(StringValuePtr(log_msg), wxConvUTF8));
119
- }
115
+ do_log(wxLOG_Debug, argc, argv);
120
116
  return Qnil;
121
117
  }
122
118
 
@@ -27,7 +27,7 @@ module WXRuby3
27
27
  public:
28
28
  // This is pure virtual in base Wx class, so won't compile unless an
29
29
  // implementation is provided
30
- wxString GetHelp(const wxWindowBase* window)
30
+ wxString GetHelp(const wxWindowBase* window) override
31
31
  {
32
32
  static WxRuby_ID get_help_id("get_help");
33
33
 
@@ -50,7 +50,7 @@ module WXRuby3
50
50
  // RemoveHelp is called by Wx after the window deletion event has been
51
51
  // handled. A standard director here re-wraps the already destroyed
52
52
  // object, which will cause rapid segfaults when it is later marked.
53
- void RemoveHelp(wxWindowBase* window)
53
+ void RemoveHelp(wxWindowBase* window) override
54
54
  {
55
55
  static WxRuby_ID remove_help_id("remove_help");
56
56
 
@@ -64,13 +64,8 @@ module WXRuby3
64
64
  };
65
65
  __HEREDOC
66
66
  spec.add_swig_code <<~__HEREDOC
67
+ GC_MANAGE_AS_OBJECT(wxRubyHelpProvider);
67
68
  typedef wxWindow wxWindowBase;
68
-
69
- %ignore wxHelpProvider::GetHelp; // Must be supplied in Ruby
70
-
71
- // Need to avoid standard director as it will call with destroyed
72
- // objects
73
- %feature("nodirector") wxHelpProvider::RemoveHelp;
74
69
  __HEREDOC
75
70
  spec.map 'wxWindowBase' => 'Wx::Window', swig: false do
76
71
  map_in
@@ -88,8 +83,11 @@ module WXRuby3
88
83
  static wxRubyHelpProvider* Get();
89
84
  virtual void AddHelp(wxWindowBase* window, const wxString& text);
90
85
  virtual void AddHelp(wxWindowID id, const wxString& text);
91
- virtual wxString GetHelp(const wxWindowBase* window);
92
- virtual void RemoveHelp(wxWindowBase* window);
86
+ // we do not include the declaration of GetHelp here because
87
+ // we do not want a default implementation or director as we have
88
+ // a fixed director implementation above and the rest is pure Ruby
89
+ // virtual wxString GetHelp(const wxWindowBase* window);
90
+ void RemoveHelp(wxWindowBase* window); // no virtual as we have fixed director impl above
93
91
  virtual bool ShowHelp(wxWindowBase* window);
94
92
  virtual bool ShowHelpAtPoint(wxWindowBase* window, const wxPoint point,
95
93
  wxHelpEvent::Origin origin);
@@ -0,0 +1,22 @@
1
+ ###
2
+ # wxRuby3 wxWidgets interface director
3
+ # Copyright (c) M.J.N. Corino, The Netherlands
4
+ ###
5
+
6
+ require_relative './event'
7
+
8
+ module WXRuby3
9
+
10
+ class Director
11
+
12
+ class HyperlinkEvent < Event
13
+
14
+ def setup
15
+ super
16
+ spec.do_not_generate :variables, :enums, :defines, :functions # with HyperlinkCtrl
17
+ end
18
+ end # class HyperlinkEvent
19
+
20
+ end # class Director
21
+
22
+ end # module WXRuby3
@@ -77,6 +77,19 @@ module WXRuby3
77
77
  return ext_ary;
78
78
  }
79
79
 
80
+ static VALUE mime_types()
81
+ {
82
+ VALUE ext_ary = rb_ary_new();
83
+ wxList& hnd_lst = wxImage::GetHandlers();
84
+ for (wxList::compatibility_iterator node = hnd_lst.GetFirst();
85
+ node; node = node->GetNext())
86
+ {
87
+ wxImageHandler *handler = (wxImageHandler *) node->GetData();
88
+ rb_ary_push(ext_ary, WXSTR_TO_RSTR(handler->GetMimeType()));
89
+ }
90
+ return ext_ary;
91
+ }
92
+
80
93
  static VALUE handler_extensions()
81
94
  {
82
95
  VALUE ext_hash = rb_hash_new();
@@ -157,6 +170,25 @@ module WXRuby3
157
170
  return rb_str_new( (const char*)rgb_data, length);
158
171
  }
159
172
  __HEREDOC
173
+ # ignore this so we do not have to wrap wxImageHistogram
174
+ spec.ignore 'wxImage::ComputeHistogram'
175
+ # add custom method simply returning Hash; finish off in pure Ruby
176
+ spec.add_extend_code 'wxImage', <<~__HEREDOC
177
+ VALUE compute_histogram()
178
+ {
179
+ VALUE rb_img_hist = rb_hash_new();
180
+ wxImageHistogram img_hist;
181
+ $self->ComputeHistogram(img_hist);
182
+ for (auto pair : img_hist)
183
+ {
184
+ VALUE rb_hist_entry = rb_ary_new();
185
+ rb_ary_push(rb_hist_entry, ULL2NUM(pair.second.index));
186
+ rb_ary_push(rb_hist_entry, ULL2NUM(pair.second.value));
187
+ rb_hash_aset(rb_img_hist, ULL2NUM(pair.first), rb_hist_entry);
188
+ }
189
+ return rb_img_hist;
190
+ }
191
+ __HEREDOC
160
192
  spec.do_not_generate(:functions)
161
193
  end
162
194
  end # class Image
@@ -100,6 +100,7 @@ module WXRuby3
100
100
  VALUE items = rb_ary_new();
101
101
  rb_ary_push(items, (VALUE)item1);
102
102
  rb_ary_push(items, (VALUE)item2);
103
+ rb_ary_push(items, (VALUE)data);
103
104
  VALUE the_order = rb_yield(items);
104
105
  return NUM2INT(the_order);
105
106
  }
@@ -183,9 +184,9 @@ module WXRuby3
183
184
  return Qnil;
184
185
  }
185
186
 
186
- void sort_items()
187
+ void sort_items(VALUE data = Qnil)
187
188
  {
188
- self->SortItems(wxListCtrl_SortByYielding, 0);
189
+ $self->SortItems(wxListCtrl_SortByYielding, static_cast<wxIntPtr> (data));
189
190
  }
190
191
  __HEREDOC
191
192
  super
@@ -10,19 +10,79 @@ module WXRuby3
10
10
  class Log < Director
11
11
 
12
12
  def setup
13
- spec.gc_as_object
14
- spec.items.concat(%w[wxLogBuffer wxLogChain wxLogGui wxLogStderr wxLogStream wxLogTextCtrl wxLogInterposer wxLogInterposerTemp wxLogWindow])
15
- spec.no_proxy(%w[wxLogBuffer wxLogChain wxLogGui wxLogStderr wxLogTextCtrl wxLogInterposer wxLogInterposerTemp wxLogWindow])
13
+ spec.gc_as_object %w[wxLog wxLogChain wxLogInterposer wxLogInterposerTemp]
14
+ spec.items.concat(%w[wxLogBuffer wxLogChain wxLogGui wxLogStderr wxLogStream wxLogTextCtrl wxLogInterposer wxLogInterposerTemp wxLogWindow wxLogNull wxLogRecordInfo])
15
+ spec.no_proxy(%w[wxLogBuffer wxLogGui wxLogStderr wxLogTextCtrl wxLogWindow])
16
+ spec.force_proxy(%w[wxLogInterposer wxLogInterposerTemp])
17
+ spec.regard %w[wxLog::DoLogRecord wxLog::DoLogTextAtLevel wxLog::DoLogText]
16
18
  spec.ignore 'wxLogBuffer::Flush'
17
19
  spec.ignore 'wxLogGui::Flush'
18
20
  if Config.instance.features_set?(%w[wxUSE_STD_IOSTREAM])
19
21
  spec.ignore 'wxLogStream'
20
22
  end
23
+ # wxLogStderr
24
+ spec.ignore 'wxLogStderr::wxLogStderr'
25
+ spec.add_extend_code 'wxLogStderr', <<~__HEREDOC
26
+ wxLogStderr(int fh=2)
27
+ {
28
+ if (fh == 2)
29
+ { return new wxLogStderr(); }
30
+ else if (fh == 1)
31
+ { return new wxLogStderr(stdout); }
32
+ rb_raise(rb_eArgError, "Expected 1 (for stdout) or 2 (for stderr).");
33
+ }
34
+ __HEREDOC
35
+ # for wxLogChain
36
+ spec.disown 'wxLog *logger'
37
+ spec.ignore 'wxLogChain::DetachOldLog' # too much potential trouble
38
+ # add override decl missing from xml specs
39
+ spec.extend_interface 'wxLogChain',
40
+ 'virtual void DoLogRecord(wxLogLevel level, const wxString& msg, const wxLogRecordInfo& info) override',
41
+ visibility: 'protected'
42
+ # wxLogChain and derivatives need to be allocated disowned because new instances of these classes
43
+ # are installed as ActiveTarget on construction and so wxWidgets has ownership
44
+ spec.allocate_disowned 'wxLogChain'
45
+ spec.allocate_disowned 'wxLogInterposer'
46
+ spec.allocate_disowned 'wxLogInterposerTemp'
47
+ spec.allocate_disowned 'wxLogWindow'
48
+ # for ActiveTarget methods
21
49
  spec.ignore 'wxLog::SetThreadActiveTarget'
22
50
  spec.disown 'wxLog *logtarget'
51
+ spec.new_object 'wxLog::SetActiveTarget'
23
52
  spec.do_not_generate(:functions)
24
53
  spec.make_concrete('wxLog')
25
- spec.extend_interface('wxLog', ' virtual ~wxLog ();')
54
+ spec.extend_interface('wxLog', 'virtual ~wxLog ()')
55
+ spec.gc_as_untracked 'wxLogRecordInfo'
56
+ spec.add_extend_code 'wxLogRecordInfo', <<~__HEREDOC
57
+ VALUE filename()
58
+ {
59
+ return $self->filename ? WXSTR_TO_RSTR(wxString($self->filename)) : Qnil;
60
+ }
61
+ VALUE line()
62
+ {
63
+ return INT2NUM($self->line);
64
+ }
65
+ VALUE func()
66
+ {
67
+ return $self->func ? WXSTR_TO_RSTR(wxString($self->func)) : Qnil;
68
+ }
69
+ VALUE component()
70
+ {
71
+ return $self->component ? WXSTR_TO_RSTR(wxString($self->component)) : Qnil;
72
+ }
73
+ __HEREDOC
74
+ spec.make_abstract 'wxLogNull'
75
+ spec.ignore 'wxLogNull::wxLogNull'
76
+ spec.add_extend_code 'wxLogNull', <<~__HEREDOC__
77
+ static void no_log()
78
+ {
79
+ if (rb_block_given_p ())
80
+ {
81
+ wxLogNull noLog;
82
+ rb_yield(Qnil);
83
+ }
84
+ }
85
+ __HEREDOC__
26
86
  super
27
87
  end
28
88
  end # class Log
@@ -30,9 +30,6 @@ module WXRuby3
30
30
  __HEREDOC
31
31
  # make Ruby director and wrappers use custom implementation
32
32
  spec.use_class_implementation('wxMenu', 'wxRubyMenu')
33
- spec.rename_for_ruby(
34
- 'AppendItem' =>
35
- 'wxMenu::Append(wxMenuItem *item)')
36
33
  # ignore non-const version as that has no benefits in Ruby
37
34
  spec.ignore 'wxMenu::GetMenuItems()'
38
35
  # Fix for GetMenuItems - converts list of MenuItems to Array
@@ -19,6 +19,9 @@ module WXRuby3
19
19
  'wxMenuBar::GetLabelTop',
20
20
  'wxMenuBar::SetLabelTop',
21
21
  'wxMenuBar::Refresh')
22
+ unless Config.instance.wx_version >= '3.3' || Config.instance.wx_abi_version > '3.0.0'
23
+ spec.ignore 'wxMenuBar::OSXGetAppleMenu'
24
+ end
22
25
  super
23
26
  end
24
27
  end # class MenuBar
@@ -166,7 +166,16 @@ module WXRuby3
166
166
  # these are defined and loaded in RubyStockObjects.i
167
167
  spec.ignore %w[
168
168
  wxRED_PEN wxBLUE_PEN wxCYAN_PEN wxGREEN_PEN wxYELLOW_PEN wxBLACK_PEN wxWHITE_PEN
169
- wxTRANSPARENT_PEN wxBLACK_DASHED_PEN wxGREY_PEN wxMEDIUM_GREY_PEN wxLIGHT_GREY_PEN wxThePenList]
169
+ wxTRANSPARENT_PEN wxBLACK_DASHED_PEN wxGREY_PEN wxMEDIUM_GREY_PEN wxLIGHT_GREY_PEN]
170
+ # do not expose this
171
+ spec.ignore 'wxThePenList'
172
+ # provide it's functionality as a class method of Pen instead
173
+ spec.add_extend_code 'wxPen', <<~__HEREDOC
174
+ static wxPen* find_or_create_pen(const wxColour &colour, int width=1, wxPenStyle style=wxPENSTYLE_SOLID)
175
+ {
176
+ return wxThePenList->FindOrCreatePen(colour, width, style);
177
+ }
178
+ __HEREDOC
170
179
  end
171
180
  end # class Pen
172
181
 
@@ -14,6 +14,24 @@ module WXRuby3
14
14
  def setup
15
15
  spec.items << 'wxPopupTransientWindow'
16
16
  super
17
+ spec.items.each do |itm|
18
+ spec.no_proxy("#{itm}::ClearBackground",
19
+ "#{itm}::Enable",
20
+ "#{itm}::GetHelpTextAtPoint",
21
+ "#{itm}::GetMaxSize",
22
+ "#{itm}::GetMinSize",
23
+ "#{itm}::Refresh",
24
+ "#{itm}::Update")
25
+ end
26
+ # add these to the generated interface to be parsed by SWIG
27
+ # the wxWidgets docs are flawed in this respect that several reimplemented
28
+ # virtual methods are not documented at the reimplementing class as such
29
+ # that would cause them missing from the interface which would cause a problem
30
+ # for a SWIG director redirecting to the Ruby class as the SWIG wrappers
31
+ # redirect explicitly to the implementation at the same class level as the wrapper
32
+ # for upcalls
33
+ spec.extend_interface('wxPopupWindow',
34
+ 'virtual bool Show(bool show = true) override')
17
35
  end
18
36
 
19
37
  end # class PopupWindow
@@ -14,22 +14,33 @@ module WXRuby3
14
14
  spec.items << 'wxItemContainerImmutable'
15
15
  spec.fold_bases('wxRadioBox' => 'wxItemContainerImmutable')
16
16
  spec.override_inheritance_chain('wxRadioBox', %w[wxControl wxWindow wxEvtHandler wxObject])
17
- # ignore overload hiding common Window method
18
- spec.ignore('wxRadioBox::Enable')
17
+ # ignore overloads hiding common Window method
18
+ spec.ignore('wxRadioBox::Enable', 'wxRadioBox::Show')
19
19
  spec.add_extend_code 'wxRadioBox', <<~__HEREDOC
20
- // add custom method to reach common Window method
20
+ // add custom method to reach common Window method overload
21
21
  bool EnableWindow(bool enable=true)
22
22
  {
23
- return $self->wxWindow::Enable(enable);
23
+ return $self->Enable(enable);
24
24
  }
25
25
  // add right method to enable/disable items
26
26
  bool EnableItem(unsigned int n, bool enable=true)
27
27
  {
28
28
  return $self->Enable(n, enable);
29
29
  }
30
+ // add custom method to reach common Window method overload
31
+ bool ShowWindow(bool show=true)
32
+ {
33
+ return $self->Show(show);
34
+ }
35
+ // add right method to show/hide items
36
+ bool ShowItem(unsigned int n, bool show=true)
37
+ {
38
+ return $self->Show(n, show);
39
+ }
30
40
  __HEREDOC
31
41
  # rename common method
32
42
  spec.rename_for_ruby('Enable' => 'wxRadioBox::EnableWindow')
43
+ spec.rename_for_ruby('Show' => 'wxRadioBox::ShowWindow')
33
44
  super
34
45
  end
35
46
  end # class Window
@@ -14,7 +14,8 @@ module WXRuby3
14
14
  def setup
15
15
  super
16
16
  # mixin TextEntry
17
- spec.include_mixin 'wxSearchCtrl', 'Wx::TextEntry'
17
+ spec.include_mixin 'wxSearchCtrl', { 'Wx::TextEntry' => 'wxTextEntryBase' }
18
+ spec.suppress_warning(473, 'wxSearchCtrl::GetMenu')
18
19
  spec.override_inheritance_chain('wxSearchCtrl', %w[wxControl wxWindow wxEvtHandler wxObject])
19
20
  end
20
21
  end # class SearchCtrl
@@ -13,7 +13,7 @@ module WXRuby3
13
13
 
14
14
  def setup
15
15
  super
16
- if Config.instance.wx_port == :wxQT
16
+ if Config.instance.wx_port == :wxQT || Config.platform == :macosx
17
17
  # missing from implementation currently
18
18
  spec.ignore 'wxStaticBox::wxStaticBox(wxWindow *, wxWindowID, wxWindow *, const wxPoint &, const wxSize &, long, const wxString &)',
19
19
  'wxStaticBox::Create(wxWindow *, wxWindowID, wxWindow *, const wxPoint &, const wxSize &, long, const wxString &)'
@@ -15,7 +15,7 @@ module WXRuby3
15
15
  super
16
16
  spec.override_inheritance_chain('wxStyledTextCtrl', %w[wxControl wxWindow wxEvtHandler wxObject])
17
17
  # mixin TextEntry
18
- spec.include_mixin 'wxStyledTextCtrl', 'Wx::TextEntry'
18
+ spec.include_mixin 'wxStyledTextCtrl', { 'Wx::TextEntry' => 'wxTextEntryBase' }
19
19
  spec.map 'int *', 'long *', as: 'Integer' do
20
20
  map_in ignore: true, temp: '$*1_ltype a', code: '$1 = &a;'
21
21
  map_argout code: <<~__CODE
@@ -16,8 +16,38 @@ module WXRuby3
16
16
  spec.gc_as_untracked 'wxTextEntry' # actually no GC control necessary as this is a mixin only
17
17
  # turn wxTextEntry into a mixin module
18
18
  spec.make_mixin 'wxTextEntry'
19
+ # !!NOTE!!
20
+ # This is not very nice but it is the easiest way to work around the problem that
21
+ # what we actually want as native type is wxTextEntryBase (because of some bad implementation decisions in wxw)
22
+ # and what is documented is wxTextEntry.
23
+ spec.add_header_code '#define wxTextEntry wxTextEntryBase'
19
24
  spec.disown 'wxTextCompleter *completer' # managed by wxWidgets after passing in
20
25
  spec.map_apply 'long * OUTPUT' => 'long *' # for GetSelection
26
+ # for wxTextCompleterSimple::GetCompletions
27
+ spec.map 'wxArrayString &res' => 'Array<String>' do
28
+
29
+ map_in ignore: true, temp: 'wxArrayString tmp', code: '$1 = &tmp;'
30
+
31
+ map_argout code: <<~__CODE
32
+ $result = rb_ary_new();
33
+ for (size_t i = 0; i < $1->GetCount(); i++)
34
+ {
35
+ rb_ary_push($result,WXSTR_TO_RSTR( $1->Item(i) ) );
36
+ }
37
+ __CODE
38
+
39
+ map_directorargout code: <<~__CODE
40
+ if (result != Qnil && TYPE(result) == T_ARRAY)
41
+ {
42
+ for (int i = 0, n = RARRAY_LEN(result); i < n ;i++)
43
+ {
44
+ VALUE rb_comp = rb_ary_entry(result, i);
45
+ wxString comp = RSTR_TO_WXSTR(rb_comp);
46
+ $1.Add(comp);
47
+ }
48
+ }
49
+ __CODE
50
+ end
21
51
  end
22
52
  end # class TextEntry
23
53
 
@@ -20,8 +20,8 @@ module WXRuby3
20
20
  public:
21
21
  WXRubyTextValidator(const wxTextValidator& v)
22
22
  : wxTextValidator(v) {}
23
- WXRubyTextValidator(long style=wxFILTER_NONE, wxString *valPtr=NULL)
24
- : wxTextValidator(style, valPtr) {}
23
+ WXRubyTextValidator(long style=wxFILTER_NONE)
24
+ : wxTextValidator(style) {}
25
25
  virtual ~WXRubyTextValidator()
26
26
  {
27
27
  wxRuby_ReleaseEvtHandlerProcs(this);
@@ -29,6 +29,12 @@ module WXRuby3
29
29
  };
30
30
  __HEREDOC
31
31
  spec.use_class_implementation 'wxTextValidator', 'WXRubyTextValidator'
32
+ # ignore copy ctor doc
33
+ spec.regard 'wxTextValidator::wxTextValidator(const wxTextValidator&)', regard_doc: false
34
+ # ignore this ctor
35
+ spec.ignore 'wxTextValidator::wxTextValidator(long, wxString*)'
36
+ # add alternative
37
+ spec.extend_interface 'wxTextValidator', 'wxTextValidator(long style=wxFILTER_NONE)'
32
38
  spec.no_proxy 'wxTextValidator::Clone'
33
39
  spec.new_object 'wxTextValidator::Clone'
34
40
  # handle clone mapping
@@ -14,7 +14,7 @@ module WXRuby3
14
14
  def setup
15
15
  super
16
16
  # mixin TextEntry
17
- spec.include_mixin 'wxTextCtrl', 'Wx::TextEntry'
17
+ spec.include_mixin 'wxTextCtrl', { 'Wx::TextEntry' => 'wxTextEntryBase' }
18
18
  spec.override_inheritance_chain('wxTextCtrl', %w[wxControl wxWindow wxEvtHandler wxObject])
19
19
  spec.ignore 'wxTextCtrl::HitTest(const wxPoint &,long *)'
20
20
  if Config.instance.wx_port == :wxQT