wxruby3 0.9.0.pre.rc.1 → 0.9.0.pre.rc.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (77) hide show
  1. checksums.yaml +4 -4
  2. data/INSTALL.md +51 -22
  3. data/README.md +38 -6
  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/lib/wx/core/brush.rb +6 -0
  13. data/lib/wx/core/evthandler.rb +12 -2
  14. data/lib/wx/core/font.rb +22 -14
  15. data/lib/wx/core/helpprovider.rb +2 -2
  16. data/lib/wx/core/menu.rb +5 -0
  17. data/lib/wx/core/pen.rb +6 -0
  18. data/lib/wx/core/window.rb +28 -1
  19. data/lib/wx/doc/app.rb +40 -0
  20. data/lib/wx/doc/brush.rb +17 -0
  21. data/lib/wx/doc/font.rb +27 -0
  22. data/lib/wx/doc/pen.rb +17 -0
  23. data/lib/wx/doc/radio_box.rb +20 -0
  24. data/lib/wx/doc/window.rb +27 -0
  25. data/lib/wx/keyword_defs.rb +77 -76
  26. data/lib/wx/prt/keyword_defs.rb +5 -1
  27. data/lib/wx/version.rb +1 -1
  28. data/rakelib/install.rb +17 -6
  29. data/rakelib/lib/config/linux.rb +4 -2
  30. data/rakelib/lib/config/macosx.rb +120 -1
  31. data/rakelib/lib/config/mingw.rb +6 -1
  32. data/rakelib/lib/config/unixish.rb +26 -11
  33. data/rakelib/lib/config.rb +15 -6
  34. data/rakelib/lib/core/package.rb +1 -1
  35. data/rakelib/lib/core/spec.rb +2 -2
  36. data/rakelib/lib/director/app.rb +30 -1
  37. data/rakelib/lib/director/aui_toolbar.rb +41 -0
  38. data/rakelib/lib/director/brush.rb +10 -1
  39. data/rakelib/lib/director/combobox.rb +1 -1
  40. data/rakelib/lib/director/context_help_button.rb +23 -0
  41. data/rakelib/lib/director/dialog.rb +8 -2
  42. data/rakelib/lib/director/font.rb +12 -3
  43. data/rakelib/lib/director/help_provider.rb +8 -10
  44. data/rakelib/lib/director/hyperlink_event.rb +22 -0
  45. data/rakelib/lib/director/menu.rb +0 -3
  46. data/rakelib/lib/director/menu_bar.rb +3 -0
  47. data/rakelib/lib/director/pen.rb +10 -1
  48. data/rakelib/lib/director/popup_window.rb +18 -0
  49. data/rakelib/lib/director/radio_box.rb +15 -4
  50. data/rakelib/lib/director/searchctrl.rb +2 -1
  51. data/rakelib/lib/director/static_box.rb +1 -1
  52. data/rakelib/lib/director/styled_text_ctrl.rb +1 -1
  53. data/rakelib/lib/director/text_entry.rb +5 -0
  54. data/rakelib/lib/director/textctrl.rb +1 -1
  55. data/rakelib/lib/director/window.rb +37 -1
  56. data/rakelib/lib/generate/doc/context_help_button.yaml +16 -0
  57. data/rakelib/lib/generate/doc/event_blocker.yaml +27 -0
  58. data/rakelib/lib/generate/doc/event_filter.yaml +47 -0
  59. data/rakelib/lib/generate/doc/file_dialog.yaml +68 -0
  60. data/rakelib/lib/generate/doc.rb +1 -1
  61. data/rakelib/lib/generate/interface.rb +11 -10
  62. data/rakelib/lib/specs/interfaces.rb +4 -1
  63. data/samples/aui/aui.rb +432 -363
  64. data/samples/propgrid/propgrid.rb +3 -0
  65. data/samples/sampler/editor.rb +33 -25
  66. data/samples/sampler/sample.rb +2 -2
  67. data/samples/sampler/stc_editor.rb +4 -2
  68. data/tests/lib/item_container_tests.rb +82 -0
  69. data/tests/lib/text_entry_tests.rb +80 -0
  70. data/tests/lib/wxapp_runner.rb +12 -0
  71. data/tests/lib/wxframe_runner.rb +89 -4
  72. data/tests/test_ext_controls.rb +28 -0
  73. data/tests/test_font.rb +239 -0
  74. data/tests/test_intl.rb +5 -1
  75. data/tests/test_std_controls.rb +263 -37
  76. data/tests/test_window.rb +340 -0
  77. metadata +28 -2
@@ -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,6 +16,11 @@ 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
21
26
  end
@@ -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
@@ -132,8 +132,28 @@ module WXRuby3
132
132
  'wxWindow::GetTextExtent(const wxString &,int *,int *,int *,int *,const wxFont *)',
133
133
  'wxWindow::SendIdleEvents',
134
134
  'wxWindow::ClientToScreen(int*,int*)', # no need; prefer the wxPoint version
135
- 'wxWindow::ScreenToClient(int*,int*)' # no need; prefer the wxPoint version
135
+ 'wxWindow::ScreenToClient(int*,int*)', # no need; prefer the wxPoint version
136
136
  ]
137
+ # redefine these so a nil parent is accepted
138
+ spec.ignore %w[wxWindow::FindWindowById wxWindow::FindWindowByLabel wxWindow::FindWindowByName], ignore_doc: false
139
+ # overrule common typemap to allow default NULL
140
+ spec.map 'wxWindow* find_from_parent' do
141
+ map_check code: ''
142
+ end
143
+ spec.add_extend_code 'wxWindow', <<~__HEREDOC
144
+ static wxWindow* find_window_by_id(long id, const wxWindow *find_from_parent=0)
145
+ {
146
+ return wxWindow::FindWindowById(id, find_from_parent);
147
+ }
148
+ static wxWindow* find_window_by_label(const wxString &label, const wxWindow *find_from_parent=0)
149
+ {
150
+ return wxWindow::FindWindowByLabel(label, find_from_parent);
151
+ }
152
+ static wxWindow* find_window_by_name(const wxString &name, const wxWindow *find_from_parent=0)
153
+ {
154
+ return wxWindow::FindWindowByName(name, find_from_parent);
155
+ }
156
+ __HEREDOC
137
157
  if Config.instance.wx_port == :wxQT
138
158
  # protected for wxQT; ignore for now
139
159
  spec.ignore 'wxWindow::EnableTouchEvents'
@@ -257,6 +277,22 @@ module WXRuby3
257
277
  # update generated code for all windows
258
278
  spec.post_processors << :update_window
259
279
  end
280
+
281
+ def process(gendoc: false)
282
+ defmod = super
283
+ if spec.module_name == 'wxWindow'
284
+ # special processing to ignore the non-static versions of methods FromDIP,ToDIP,FromPhys,ToPhys
285
+ # as SWIG cannot handle identically named static & non-static methods
286
+ # will handle that in pure Ruby
287
+ %w[FromDIP ToDIP FromPhys ToPhys].each do |mtd|
288
+ if (item = defmod.find("wxWindow::#{mtd}"))
289
+ item.all.each { |ovl| ovl.ignore(true, ignore_doc: false) unless ovl.is_static }
290
+ end
291
+ end
292
+ end
293
+ defmod
294
+ end
295
+
260
296
  end # class Window
261
297
 
262
298
  end # class Director
@@ -0,0 +1,16 @@
1
+ ---
2
+ :wxContextHelp:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ # puts the application into a 'context-sensitive help mode' for my_window
11
+ context_help = Wx::ContextHelp.new(my_window)
12
+ ...
13
+ ...
14
+ # ends the 'context-sensitive help mode' for my_window
15
+ context_help.end_context_help
16
+ ```
@@ -0,0 +1,27 @@
1
+ ---
2
+ :wxEventBlocker:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ class MyWindow
11
+
12
+ ...
13
+
14
+ def do_something
15
+ # block all events directed to this window
16
+ Wx::EventBlocker.blocked_for(self) do
17
+ # while we do 1000 function_that_sends_events calls
18
+ 1000.times { |i| function_that_sends_events(i) }
19
+ end
20
+ # old event handler restored; generated event(s) from next call will be processed
21
+ function_that_sends_events(0)
22
+ end
23
+
24
+ ...
25
+
26
+ end
27
+ ```
@@ -0,0 +1,47 @@
1
+ ---
2
+ :wxEventFilter:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ # This class allows determining the last time the user has worked with
11
+ # this application:
12
+ class LastActivityTimeDetector < Wx::EventFilter
13
+ def initialize
14
+ Wx::EvtHandler.add_filter(self)
15
+
16
+ @last = Time.now
17
+ end
18
+
19
+ def clear
20
+ Wx::EvtHandler.remove_filter(self)
21
+ end
22
+
23
+ def filter_event(event)
24
+ # Update the last user activity
25
+ t = event.get_event_type
26
+ case t
27
+ when Wx::EVT_KEY_DOWN,
28
+ Wx::EVT_MOTION,
29
+ Wx::EVT_LEFT_DOWN,
30
+ Wx::EVT_RIGHT_DOWN,
31
+ Wx::EVT_MIDDLE_DOWN
32
+ @last = Time.now
33
+ end
34
+
35
+ # Continue processing the event normally as well.
36
+ Event_Skip
37
+ end
38
+
39
+ # This function could be called periodically from some timer to
40
+ # do something (e.g. hide sensitive data or log out from remote
41
+ # server) if the user has been inactive for some time period.
42
+ def is_inactive_for?(diff)
43
+ (Time.now - diff) > @last
44
+ end
45
+
46
+ end
47
+ ```
@@ -0,0 +1,68 @@
1
+ ---
2
+ :wxFileDialog:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /MyFrame::OnOpen/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ class MyFrame
11
+ ...
12
+ def on_open(event)
13
+ if (...current content has not been saved...)
14
+ if Wx.message_box('Current content has not been saved! Proceed?', 'Please confirm',
15
+ Wx::ICON_QUESTION | Wx::YES_NO, self) == Wx::NO
16
+ return
17
+ #else: proceed asking to the user the new file to open
18
+ end
19
+ end
20
+
21
+ Wx::FileDialog(self, "Open XYZ file", "", "",
22
+ "XYZ files (*.xyz)|*.xyz", Wx::FD_OPEN|Wx::FD_FILE_MUST_EXIST) do |dlg|
23
+ return if dlg.show_modal == Wx::ID_CANCEL # the user changed idea...?
24
+
25
+ # proceed loading the file chosen by the user
26
+ file = File.open(dlg.path, 'r') rescue nil
27
+ unless file
28
+ Wx.log_error("Cannot open file '#{dlg.path}'.")
29
+ return
30
+ end
31
+ ...
32
+ end
33
+ end
34
+
35
+ end
36
+ ```
37
+ - :pattern: !ruby/regexp /MyFrame::OnSaveAs/
38
+ :replace: |
39
+
40
+ ```ruby
41
+ class MyFrame
42
+ ...
43
+ def on_save_as(event)
44
+ Wx::FileDialog(self, "Save XYZ file", "", "",
45
+ "XYZ files (*.xyz)|*.xyz", Wx::FD_SAVE|Wx::FD_OVERWRITE_PROMPT) do |dlg|
46
+ return if dlg.show_modal == Wx::ID_CANCEL # the user changed idea...?
47
+
48
+ # save the current contents in the file
49
+ begin
50
+ File.open(dlg.path, 'w+') do |f|
51
+ # save to file
52
+ end
53
+ rescue
54
+ Wx.log_error("Cannot save current contents in file '#{dlg.path}'.")
55
+ return
56
+ end
57
+ end
58
+ ...
59
+ end
60
+
61
+ end
62
+ ```
63
+ - :pattern: !ruby/regexp /wxSystemOptions::SetOption/
64
+ :replace: |
65
+
66
+ ```ruby
67
+ Wx::SystemOptions.set_option(Wx::OSX_FILEDIALOG_ALWAYS_SHOW_TYPES, 1)
68
+ ```
@@ -860,7 +860,7 @@ module WXRuby3
860
860
 
861
861
  # mixin includes
862
862
  if included_mixins.has_key?(item.name)
863
- included_mixins[item.name].each { |mod| fdoc.iputs "include #{mod}" }
863
+ included_mixins[item.name].keys.each { |mod| fdoc.iputs "include #{mod}" }
864
864
  fdoc.puts
865
865
  end
866
866
 
@@ -99,18 +99,19 @@ module WXRuby3
99
99
  __HEREDOC
100
100
  end
101
101
 
102
- def gen_mixin_convert_code(fout, cls, mod)
102
+ def gen_mixin_convert_code(fout, cls, mod, ctype)
103
103
  rb_mod_name = mod.split('::').last
104
+ ctype ||= "wx#{rb_mod_name}"
104
105
  decl_flag = (mod.start_with?(package.fullname) ? 'WXRB_EXPORT_FLAG' : 'WXRB_IMPORT_FLAG') # same package (dll) or import?
105
106
  fout.puts
106
107
  fout << <<~__HEREDOC
107
- // Mixin converter for wx#{rb_mod_name} included in #{cls}
108
- typedef wx#{rb_mod_name}* (*wx_#{underscore(rb_mod_name)}_convert_fn)(void*);
108
+ // Mixin converter for #{ctype} (#{mod}) included in #{cls}
109
+ typedef #{ctype}* (*wx_#{underscore(rb_mod_name)}_convert_fn)(void*);
109
110
  #{decl_flag} void wxRuby_Register_#{rb_mod_name}_Include(swig_class* cls_info,
110
111
  wx_#{underscore(rb_mod_name)}_convert_fn converter);
111
- static wx#{rb_mod_name}* wxRuby_ConvertTo_#{rb_mod_name}(void* ptr)
112
+ static #{ctype}* wxRuby_ConvertTo_#{rb_mod_name}(void* ptr)
112
113
  {
113
- return ((wx#{rb_mod_name}*) static_cast<#{cls}*> (ptr));
114
+ return ((#{ctype}*) static_cast<#{cls}*> (ptr));
114
115
  }
115
116
  __HEREDOC
116
117
  end
@@ -147,7 +148,7 @@ module WXRuby3
147
148
  mixins.each { |name| gen_mixin_code(fout, name) }
148
149
  end
149
150
  unless included_mixins.empty?
150
- included_mixins.each_pair {|cls, mods| mods.each { |mod| gen_mixin_convert_code(fout, cls, mod) } }
151
+ included_mixins.each_pair {|cls, mods| mods.each_pair { |mod, ctype| gen_mixin_convert_code(fout, cls, mod, ctype) } }
151
152
  end
152
153
  fout.puts "%}"
153
154
  end
@@ -215,8 +216,8 @@ module WXRuby3
215
216
  end
216
217
  unless included_mixins.empty?
217
218
  fout.puts
218
- included_mixins.each_pair do |cls, module_names|
219
- module_names.each { |m| fout.puts %Q{%mixin #{cls} "#{m}";} }
219
+ included_mixins.each_pair do |cls, modules|
220
+ modules.keys.each { |m| fout.puts %Q{%mixin #{cls} "#{m}";} }
220
221
  end
221
222
  end
222
223
  end
@@ -240,8 +241,8 @@ module WXRuby3
240
241
  end
241
242
  unless included_mixins.empty?
242
243
  fout.puts
243
- included_mixins.each_pair do |cls, module_names|
244
- module_names.each do |modname|
244
+ included_mixins.each_pair do |cls, modules|
245
+ modules.keys.each do |modname|
245
246
  m = modname.split('::').last
246
247
  fout.puts %Q{wxRuby_Register_#{m}_Include(&SwigClassWx#{rb_wx_name(cls)}, wxRuby_ConvertTo_#{m});}
247
248
  end
@@ -177,7 +177,7 @@ module WXRuby3
177
177
  Director.Spec(pkg, 'wxDataObjectSimpleBase', requirements: %w[wxUSE_CLIPBOARD])
178
178
  Director.Spec(pkg, 'wxClipboard', requirements: %w[wxUSE_CLIPBOARD])
179
179
  Director.Spec(pkg, 'wxDragDrop', requirements: %w[wxUSE_DRAG_AND_DROP])
180
- Director.Spec(pkg, 'wxContextHelpButton', director: Director::Button, requirements: %w[wxUSE_HELP])
180
+ Director.Spec(pkg, 'wxContextHelpButton', requirements: %w[wxUSE_HELP])
181
181
  Director.Spec(pkg, 'wxHelpProvider', requirements: %w[wxUSE_HELP])
182
182
  Director.Spec(pkg, 'wxHelpController', requirements: %w[wxUSE_HELP])
183
183
  Director.Spec(pkg, 'wxExtHelpController', director: Director::HelpController, requirements: %w[wxUSE_HELP])
@@ -200,6 +200,9 @@ module WXRuby3
200
200
  Director.Spec(pkg, 'wxPlatformInfo')
201
201
  Director.Spec(pkg, 'wxSplashScreen', requirements: %w[wxUSE_SPLASH])
202
202
  Director.Spec(pkg, 'wxUIActionSimulator', requirements: %w[wxUSE_UIACTIONSIMULATOR])
203
+ Director.Spec(pkg, 'wxActivityIndicator', director: Director::Window, requirements: %w[wxUSE_ACTIVITYINDICATOR])
204
+ Director.Spec(pkg, 'wxHyperlinkCtrl', director: Director::Window, requirements: %w[wxUSE_HYPERLINKCTRL])
205
+ Director.Spec(pkg, 'wxHyperlinkEvent', requirements: %w[wxUSE_HYPERLINKCTRL])
203
206
  }
204
207
 
205
208
  Director.Package('Wx::PRT', 'wxUSE_PRINTING_ARCHITECTURE') do |pkg|