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
@@ -437,10 +437,6 @@ module WXRuby3
437
437
  return true;
438
438
  }
439
439
 
440
- //#if wxUSE_ANY
441
- // // Converts value to wxAny, if possible. Return true if successful.
442
- // virtual bool GetAsAny(wxAny* WXUNUSED(any)) const { return false; }
443
- //#endif
444
440
  protected:
445
441
  VALUE m_value;
446
442
  };
@@ -462,6 +458,21 @@ module WXRuby3
462
458
  }
463
459
  __HEREDOC
464
460
  spec.add_init_code 'wxRuby_AppendMarker(wxRuby_markRbValueVariants);'
461
+ # ignore GetType (not doc)
462
+ spec.ignore 'wxVariant::GetType', ignore_doc: false
463
+ # replace with custom implementation
464
+ spec.add_extend_code 'wxVariant', <<~__HEREDOC
465
+ VALUE get_type()
466
+ {
467
+ wxString ts = self->GetType();
468
+ if (ts == WXRBValueVariantData::type_name_)
469
+ {
470
+ VALUE klass = CLASS_OF(((WXRBValueVariantData*)self->GetData())->GetValue());
471
+ return rb_str_new2(rb_class2name(CLASS_OF(klass)));
472
+ }
473
+ return WXSTR_TO_RSTR(ts);
474
+ }
475
+ __HEREDOC
465
476
  # add custom extension methods 'assign' as replacement for operator=
466
477
  spec.add_extend_code 'wxVariant', <<~__HEREDOC
467
478
  void assign(const wxVariant& v)
@@ -504,6 +515,7 @@ module WXRuby3
504
515
  if (ts == wxS("ulonglong")) return ULL2NUM(self->GetULongLong().GetValue());
505
516
  if (ts == wxS("double")) return rb_funcall(SWIG_From_double(self->GetDouble()), to_i_id(), 0);
506
517
  if (ts == wxS("datetime")) return rb_funcall(wxRuby_wxDateTimeToRuby(self->GetDateTime()), to_i_id(), 0);
518
+ if (ts == WXRBValueVariantData::type_name_) return rb_funcall(((WXRBValueVariantData*)self->GetData())->GetValue(), to_i_id(), 0);
507
519
  rb_raise(rb_eTypeError, "Cannot convert Variant<%s> to Integer", (const char*)ts.ToAscii());
508
520
  return Qnil;
509
521
  }
@@ -519,6 +531,7 @@ module WXRuby3
519
531
  if (ts == wxS("ulonglong")) return rb_funcall(ULL2NUM(self->GetULongLong().GetValue()), to_f_id(), 0);
520
532
  if (ts == wxS("double")) return SWIG_From_double(self->GetDouble());
521
533
  if (ts == wxS("datetime")) return rb_funcall(wxRuby_wxDateTimeToRuby(self->GetDateTime()), to_f_id(), 0);
534
+ if (ts == WXRBValueVariantData::type_name_) return rb_funcall(((WXRBValueVariantData*)self->GetData())->GetValue(), to_f_id(), 0);
522
535
  rb_raise(rb_eTypeError, "Cannot convert Variant<%s> to Integer", (const char*)ts.ToAscii());
523
536
  return Qnil;
524
537
  }
@@ -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
@@ -109,7 +109,7 @@ module WXRuby3
109
109
  else
110
110
  rb_param_name(paramdef.name)
111
111
  end
112
- params << { name: pnm, type: arg.type }
112
+ params << { name: pnm, type: arg.type || xml_trans.type_to_doc(paramdef.type) }
113
113
  if paramdef.default
114
114
  defexp = rb_constant_expression(paramdef.default, xml_trans.constants_xref_db)
115
115
  # in case the default expression dereferences a pointer or passes an address clean it up
@@ -142,7 +142,7 @@ module WXRuby3
142
142
  params.each do |p|
143
143
  doclns << ('@param ' << p[:name] << ' [' << p[:type] << '] ' << (p[:doc] ? ' '+(p[:doc].split("\n").join("\n ")) : ''))
144
144
  end
145
- result = [rb_return_type(type_maps)]
145
+ result = [rb_return_type(type_maps, xml_trans)]
146
146
  result.concat(mapped_ret_args.collect { |mra| mra.type }) if mapped_ret_args
147
147
  result.compact! # remove nil values (possible ignored output)
148
148
  case result.size
@@ -156,9 +156,9 @@ module WXRuby3
156
156
  [rb_decl_name, paramlist, doclns]
157
157
  end
158
158
 
159
- def rb_return_type(type_maps)
160
- mapped_type = type_maps.map_output(type)
161
- (mapped_type.empty? || mapped_type == 'void') ? nil : mapped_type
159
+ def rb_return_type(type_maps, xml_trans)
160
+ mapped_type = type_maps.map_output(type) || xml_trans.type_to_doc(type)
161
+ mapped_type == 'void' ? nil : mapped_type
162
162
  end
163
163
 
164
164
  def argument_list
@@ -304,9 +304,9 @@ module WXRuby3
304
304
  end
305
305
  end
306
306
 
307
- def rb_return_type(type_maps)
307
+ def rb_return_type(type_maps, xml_trans)
308
308
  if is_ctor
309
- rb_wx_name(class_name)
309
+ xml_trans.type_to_doc(class_name)
310
310
  else
311
311
  super
312
312
  end
@@ -80,9 +80,9 @@ module WXRuby3
80
80
  ignore # ignore all member variables by default (trust on availability of accessor methods)
81
81
  end
82
82
 
83
- def rb_return_type(type_maps)
84
- mapped_type = type_maps.map_output(type)
85
- (mapped_type.empty? || mapped_type == 'void') ? nil : mapped_type
83
+ def rb_return_type(type_maps, xml_trans)
84
+ mapped_type = type_maps.map_output(type) || xml_trans.type_to_doc(type)
85
+ mapped_type == 'void' ? nil : mapped_type
86
86
  end
87
87
  private :rb_return_type
88
88
 
@@ -97,7 +97,7 @@ module WXRuby3
97
97
  doc = []
98
98
  # first document the reader
99
99
  doc << [var_doc.dup]
100
- doc.last << "@return [#{rb_return_type(type_maps)}]"
100
+ doc.last << "@return [#{rb_return_type(type_maps, xml_trans)}]"
101
101
  doc << "def #{is_static ? 'self.' : ''}#{rb_method_name(rb_name || name)}; end"
102
102
  # next document the writer (if any)
103
103
  unless no_setter
@@ -108,9 +108,9 @@ module WXRuby3
108
108
  array: false)]
109
109
  mapped_args, _ = type_maps.map_input(parms)
110
110
  if mapped_args.empty? # something went wrong!
111
- doc.last << "@param val [#{Typemap.wx_type_to_rb(type)}]"
111
+ doc.last << "@param val [#{xml_trans.type_to_doc(type)}]"
112
112
  else
113
- doc.last << "@param val [#{mapped_args.first.type}]"
113
+ doc.last << "@param val [#{mapped_args.first.type || xml_trans.type_to_doc(type)}]"
114
114
  end
115
115
  doc.last << "@return [void]"
116
116
  doc << "def #{is_static ? 'self.' : ''}#{rb_method_name(rb_name || name)}=(val); end"
@@ -0,0 +1,21 @@
1
+ ---
2
+ :wxAuiManager:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /AddPane/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ @text1 = Wx::TextCtrl.new(self, -1)
11
+ @text2 = Wx::TextCtrl.new(self, -1)
12
+ @mgr.add_pane(@text1, Wx::LEFT, 'Pane Caption')
13
+ @mgr.add_pane(@text2, Wx::BOTTOM, 'Pane Caption')
14
+ @mgr.update
15
+ ```
16
+ - :pattern: !ruby/regexp /GetPane/
17
+ :replace: |
18
+
19
+ ```ruby
20
+ @mgr.get_pane(@text1).float
21
+ ```
@@ -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
+ ```
@@ -0,0 +1,29 @@
1
+ ---
2
+ :wxFont.wxFont:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /wxFontInfo/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ font = Wx::Font.new(Wx::FontInfo.new(10).bold().underlined())
11
+ ```
12
+ - :pattern: !ruby/regexp /wxFONTFAMILY_DEFAULT/
13
+ :replace: |
14
+
15
+ ```ruby
16
+ font = Wx::Font.new(10, Wx::FontFamily::FONTFAMILY_DEFAULT,
17
+ Wx::FontStyle::FONTSTYLE_NORMAL,
18
+ Wx::FontWeight::FONTWEIGHT_BOLD, true)
19
+ ```
20
+ :wxFontInfo:
21
+ :detail:
22
+ :pre:
23
+ :programlisting:
24
+ - :pattern: !ruby/regexp /.*/
25
+ :replace: |
26
+
27
+ ```ruby
28
+ font = Wx::Font.new(Wx::FontInfo.new(12).face_name('Helvetica').italic())
29
+ ```
@@ -0,0 +1,23 @@
1
+ ---
2
+ :wxFrame:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ Wx::DEFAULT_FRAME_STYLE & ~(Wx::RESIZE_BORDER | Wx::MAXIMIZE_BOX)
11
+ ```
12
+ :wxFrame.MSWGetTaskBarButton:
13
+ :detail:
14
+ :pre:
15
+ :programlisting:
16
+ - :pattern: !ruby/regexp /.*/
17
+ :replace: |
18
+
19
+ ```ruby
20
+ if Wx::PLATFORM == 'WXMSW'
21
+ #...
22
+ end
23
+ ```
@@ -0,0 +1,11 @@
1
+ ---
2
+ :wxFSFile.wxFSFile:
3
+ :detail:
4
+ :pre:
5
+ :para:
6
+ - :pattern: !ruby/regexp /It is seldom used by the application programmer/
7
+ :replace: ''
8
+
9
+ :programlisting:
10
+ - :pattern: !ruby/regexp /.*/
11
+ :replace: ''
@@ -0,0 +1,36 @@
1
+ ---
2
+ :wxPoint.SetDefaults:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ if !pos.is_fully_specified
11
+ pos.set_defaults(get_default_position)
12
+ end
13
+ ```
14
+ :wxPoint.wxPoint:
15
+ :detail:
16
+ :pre:
17
+ :programlisting:
18
+ - :pattern: !ruby/regexp /.*/
19
+ :replace: |
20
+
21
+ ```ruby
22
+ real_point = ...
23
+ p = Wx::Point.new(real_point.x.round, real_point.y.round)
24
+ ```
25
+ :wxSize.SetDefaults:
26
+ :detail:
27
+ :pre:
28
+ :programlisting:
29
+ - :pattern: !ruby/regexp /.*/
30
+ :replace: |
31
+
32
+ ```ruby
33
+ if !size.is_fully_specified
34
+ size.set_defaults(get_default_size)
35
+ end
36
+ ```
@@ -0,0 +1,34 @@
1
+ ---
2
+ :wxGraphicsContext:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ class MyCanvas < Wx::ScrolledWindow
11
+
12
+ def on_paint(event)
13
+ # Create paint DC
14
+ self.paint do |dc|
15
+ # Create graphics context from it
16
+ Wx::GraphicsContext.draw_on(dc) do |gc|
17
+ # make a path that contains a circle and some lines
18
+ gc.set_pen(Wx::RED_PEN)
19
+ path = gc.create_path
20
+ path.add_circle(50.0, 50.0, 50.0)
21
+ path.move_to_point(0.0, 50.0)
22
+ path.add_line_to_point(100.0, 50.0)
23
+ path.move_to_point(50.0, 0.0)
24
+ path.add_line_to_point(50.0, 100.0)
25
+ path.close_sub_path
26
+ path.add_rectangle(25.0, 25.0, 50.0, 50.0)
27
+
28
+ gc.stroke_path(path)
29
+ end
30
+ end
31
+ end
32
+ end
33
+ end
34
+ ```
@@ -0,0 +1,12 @@
1
+ ---
2
+ :wxGUIEventLoop.Dispatch:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ while evt_loop.pending
11
+ evt_loop.dispatch
12
+ ```
@@ -0,0 +1,24 @@
1
+ ---
2
+ :wxHelpController.SetViewer:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ @help.set_viewer('kdehelp')
11
+ @help.set_viewer('gnome-help-browser')
12
+ @help.set_viewer('netscape', Wx::HELP_NETSCAPE)
13
+ ```
14
+ :wxHelpController:
15
+ :detail:
16
+ :pre:
17
+ :para:
18
+ - :pattern: !ruby/regexp /Note\s+that\s+if\s+you\s+use\s+\.zip.*application\s+initialization:/
19
+ :subst: 'Note that in Ruby the required filesystem handlers for .zip or .htb books are always loaded.'
20
+ - :pattern: !ruby/regexp / or\s+nothing\s+will\s+be\s+shown\s+in\s+your\s+help\s+window./
21
+ :subst: ''
22
+ :programlisting:
23
+ - :pattern: !ruby/regexp /.*/
24
+ :replace: ''
@@ -0,0 +1,11 @@
1
+ ---
2
+ :wxIcon.GetIcon:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ get_icon(Wx::Size.new(size,size))
11
+ ```
@@ -0,0 +1,87 @@
1
+ ---
2
+ :wxImage.Scale:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /.*/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ # get the bitmap from somewhere
11
+ bmp = ...
12
+
13
+ # rescale it to have size of 32*32
14
+ if bmp.width != 32 || bmp.height != 32
15
+ image = bmp.convert_to_image
16
+ bmp = Wx::Bitmap.new(image.scale(32, 32))
17
+
18
+ # another possibility:
19
+ image.rescale(32, 32)
20
+ bmp = image.to_bitmap
21
+ end
22
+ ```
23
+ :wxImage.LoadFile:
24
+ :detail:
25
+ :pre:
26
+ :programlisting:
27
+ - :pattern: !ruby/regexp /.*/
28
+ :replace: |
29
+
30
+ ```ruby
31
+ hotspot_x = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_X)
32
+ hotspot_y = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_Y)
33
+ ```
34
+ :wxImage.SaveFile:
35
+ :detail:
36
+ :pre:
37
+ :programlisting:
38
+ - :pattern: !ruby/regexp /.*/
39
+ :replace: |
40
+
41
+ ```ruby
42
+ image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_X, hotspot_x)
43
+ image.set_option(Wx::IMAGE_OPTION_CUR_HOTSPOT_Y, hotspot_y)
44
+ ```
45
+ :wxImage.SetLoadFlags:
46
+ :detail:
47
+ :pre:
48
+ :programlisting:
49
+ - :pattern: !ruby/regexp /.*/
50
+ :replace: |
51
+
52
+ ```ruby
53
+ image = Wx::Image.new
54
+ image.set_load_flags(image.get_load_flags & ~Wx::Image::Load_Verbose)
55
+ image.load_file(...)
56
+ ```
57
+ :wxImage.wxImage:
58
+ :detail:
59
+ :pre:
60
+ :programlisting:
61
+ - :pattern: !ruby/regexp /.*/
62
+ :replace: |
63
+
64
+ ```ruby
65
+ hotspot_x = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_X)
66
+ hotspot_y = image.get_option_int(Wx::IMAGE_OPTION_CUR_HOTSPOT_Y)
67
+ ```
68
+ :wxImage.GetImageExtWildcard:
69
+ :detail:
70
+ :pre:
71
+ :programlisting:
72
+ - :pattern: !ruby/regexp /.*/
73
+ :replace: |
74
+
75
+ ```ruby
76
+ Wx::FileDialog(self, 'Choose Image', Dir.getwd, '',
77
+ 'Image Files ' + Wx::Image.get_image_ext_wildcard,
78
+ Wx::FD_OPEN) do |file_dlg|
79
+ # ...
80
+ end
81
+ ```
82
+ :wxImage:
83
+ :detail:
84
+ :pre:
85
+ :para:
86
+ - :pattern: !ruby/regexp /To\s+use\s+other\s+image\s+formats,.*or\s+call\s+.*\./
87
+ :subst: 'In wxRuby all image handlers are loaded by default at startup by {init_all_image_handlers}.'
@@ -0,0 +1,19 @@
1
+ ---
2
+ :wxKeyboardState.GetModifiers:
3
+ :detail:
4
+ :pre:
5
+ :programlisting:
6
+ - :pattern: !ruby/regexp /ControlDown/
7
+ :replace: |
8
+
9
+ ```ruby
10
+ if control_down && !alt_down && !shift_down && !meta_down
11
+ ... handle Ctrl-XXX ...
12
+ ```
13
+ - :pattern: !ruby/regexp /GetModifiers/
14
+ :replace: |
15
+
16
+ ```ruby
17
+ if get_modifiers == Wx::MOD_CONTROL
18
+ ... handle Ctrl-XXX ...
19
+ ```