Skip to content

Commit

Permalink
Merge pull request #139 from mcorino/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mcorino committed Jul 27, 2023
2 parents 70013ab + 2d75656 commit 96acfb9
Show file tree
Hide file tree
Showing 7 changed files with 320 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ If you know of a feature in wxWidgets that you would like to see
supported in wxRuby3 you are free to ask but do not **EXPECT** unconditional
agreement or immediate response.

### How does wxRuby3 relate to the wxRuby 2.0 (and even older 0.6.0 release)?
### How does wxRuby3 relate to the wxRuby 2.0 (and even older 0.6.0) release?

wxRuby 0.6.0 was the last in a series of releases developed using a
different approach in the early days of wxRuby. Work on this series
Expand Down
2 changes: 1 addition & 1 deletion rakelib/lib/generate/doc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ def _is_static_method?(clsnm, mtdname)

def _ident_str_to_doc(s, ref_scope = nil)
return s if no_idents?
return s if s.start_with?('wxRuby')
return s if %w[wxRuby wxMSW wxOSX wxGTK wxX11].any? { |w| s.start_with?(w) }
nmlist = s.split('::')
nm_str = nmlist.shift.to_s
constnm = rb_wx_name(nm_str)
Expand Down
21 changes: 21 additions & 0 deletions rakelib/lib/generate/doc/aui_manager.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
:wxAuiManager:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /AddPane/
:replace: |
```ruby
@text1 = Wx::TextCtrl.new(self, -1)
@text2 = Wx::TextCtrl.new(self, -1)
@mgr.add_pane(@text1, Wx::LEFT, 'Pane Caption')
@mgr.add_pane(@text2, Wx::BOTTOM, 'Pane Caption')
@mgr.update
```
- :pattern: !ruby/regexp /GetPane/
:replace: |
```ruby
@mgr.get_pane(@text1).float
```
249 changes: 249 additions & 0 deletions rakelib/lib/generate/doc/window.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,249 @@
---
:wxWindow.SetScrollbar:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
set_scrollbar(Wx::VERTICAL, 0, 16, 50)
```
:wxWindow.FromDIP:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
bmp = Wx::Bitmap.new(from_dip(Wx::Size.new(32, 32)))
```
:wxWindow.ToDIP:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
pt = Wx::Point.new(to_dip(get_position))
size = Wx::Size.new(to_dip(get_size))
```
:wxWindow.SetMaxClientSize:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
set_max_size(client_to_window_size(size))
```
:wxWindow.SetMinClientSize:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
set_min_size(client_to_window_size(size))
```
:wxWindow.Move:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
set_size(x, y, Wx::DEFAULT_COORD, Wx::DEFAULT_COORD, Wx::SIZE_USE_EXISTING)
```
:wxWindow.ConvertDialogToPixels:
:detail:
:pre:
:para:
- :pattern: !ruby/regexp /A\s+convenience\s+macro\s+is\s+defined:/
:subst: ''
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: ''
:wxWindow.SetBackgroundStyle:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
class MyWidget < Wx::Window
def initialize(parent, ...)
super() # Use default ctor here!
# Do this first:
set_background_style(Wx::BG_STYLE_TRANSPARENT)
# And really create the window afterwards:
create(parent, ...)
end
end
```
:wxWindow.HandleWindowEvent:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
get_event_handler.safely_process_event(event)
```
:wxWindow.ProcessWindowEvent:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
get_event_handler.process_event(event)
```
:wxWindow.PushEventHandler:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
W.push_event_handler(A)
W.push_event_handler(B)
```
:wxWindow.Enable:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
w = MyWindow.new # Note: default ctor is used here.
w.enable(false)
w.create(parent, ... all the usual non-default ctor arguments ...)
```
:wxWindow.EnableTouchEvents:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
enable_touch_events(Wx::TOUCH_ZOOM_GESTURE | Wx::TOUCH_ROTATE_GESTURE)
```
:wxWindow.DoUpdateWindowUI:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
# do the window-specific processing after processing the update event
def Wx::TopLevelWindow.do_update_window_ui(event)
if event.get_set_enabled
enable(event.get_enabled)
end
if event.get_set_text
if event.get_text != get_title
set_title(event.get_text)
end
end
end
```
:wxWindow.UpdateWindowUI:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
class MyWindow
...
def on_internal_idle
update_window_ui(Wx::UPDATE_UI_FROMIDLE) if Wx::UpdateUIEvent.can_update(self)
end
...
end
```
:wxWindow.Create:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /wxPanel/
:replace: |
```ruby
panel = Wx::Panel.new # Note: default constructor used.
panel.hide # Can be called before actually creating it.
panel.create(parent, Wx::ID_ANY, ...) # Won't be shown yet.
... create all the panel children ...
panel.show # Now everything will be shown at once.
```
- :pattern: !ruby/regexp /MyCreateWindowObjectFunction/
:replace: |
```ruby
# Suppose we have this function (which would typically be in a
# different file from the rest of the code).
def my_create_window_object_function
MyCustomClassDerivingFromWindow.new
end
# Then we can create a window of MyCustomClassDerivingFromWindow
# class without really knowing about this type, as we would have
# to do if we wanted to use the non-default constructor, like this:
# First create the C++ object using the factory function.
window = my_create_window_object_function
# And now create the underlying window.
#
# This should call the base Wx::Window#create.
# In C++ (wxWidgets) this method is not virtual and cannot be overloaded
# so the derived class can't customize this part.
# In wxRuby however this method can be overloaded as long as the following
# is kept in mind:
# 1. the overloaded version will **NOT** be called when using a non-default
# constructor (Create will than be called from C++ which will always be
# the base Wx::Window version);
# 2. when calling the overloaded version from Ruby understand that the window
# will not actually be created until after the `super` version has been called.
# In general it's best not to overload this method but to define a different method
# if a custom initializer is needed.
window.create(parent, Wx::ID_ANY, ...)
```
:wxWindow.MSWDisableComposited:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
class MyFrame < Wx::Frame
def initialize(...)
...
p = Wx::Panel.new(self)
if Wx::PLATFORM == 'WXMSW'
p.msw_disable_composited
end
# Using Wx::ClientDC will work now with this panel in wxMSW --
# although it still won't with wxOSX nor wxGTK under Wayland.
end
...
end
```
14 changes: 14 additions & 0 deletions rakelib/lib/generate/doc/wizard_page_simple.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---
:wxWizardPageSimple.Chain:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
firstPage = FirstPage.new # derived from Wx::WizardPageSimple
firstPage.chain(SecondPage.new)
.chain(ThirdPage.new)
.chain(LastPage.new)
```
7 changes: 7 additions & 0 deletions rakelib/lib/generate/doc/xml_node.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
:wxXmlNode.GetNodeContent:
:detail:
:pre:
:para:
- :pattern: !ruby/regexp /tagnametagcontent\/tagname/
:subst: '&lt;tagname&gt;tagcontent&lt;/tagname&gt;'
27 changes: 27 additions & 0 deletions rakelib/lib/generate/doc/xml_resource.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
---
:wxXmlResource.Load:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
if !Wx::XmlResource.get.load('rc/*.xrc')
Wx.log_error("Couldn't load resources!")
end
```
:wxXmlResource.LoadDialog:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
dlg = MyDialog.new
Wx::XmlResource.get.load_dialog_subclass(dlg, main_frame, 'my_dialog')
dlg.show_modal
dlg.destroy
```

0 comments on commit 96acfb9

Please sign in to comment.