Skip to content

Commit

Permalink
Merge pull request #178 from mcorino/develop
Browse files Browse the repository at this point in the history
various type mapping and doc example fixes
  • Loading branch information
mcorino committed Sep 19, 2023
2 parents b385731 + 85daaf0 commit bbf01ba
Show file tree
Hide file tree
Showing 9 changed files with 175 additions and 10 deletions.
8 changes: 6 additions & 2 deletions rakelib/lib/director/grid_cell_attr.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,13 @@ def setup
map_check code: 'wxRuby_RegisterGridCellRenderer($1, argv[$argnum-2]);'
end
# argout type mappings
spec.map_apply 'int* OUTPUT' => ['int *hAlign', 'int *vAlign', 'int *num_rows', 'int *num_cols']
spec.map_apply 'int* OUTPUT' => ['int *num_rows', 'int *num_cols']
spec.map 'int *hAlign', 'int *vAlign', as: 'Integer' do
map_in ignore: true, temp: 'int tmp', code: 'tmp = wxALIGN_INVALID; $1 = &tmp;'
map_argout code: '$result = SWIG_Ruby_AppendOutput($result, INT2NUM(*$1));'
end
# for docs only
spec.map ['int *hAlign', 'int *vAlign', 'int *num_rows', 'int *num_cols'] => 'Integer', swig: false do
spec.map 'int *num_rows', 'int *num_cols', as: 'Integer', swig: false do
map_in ignore: true
map_argout
end
Expand Down
8 changes: 0 additions & 8 deletions rakelib/lib/director/html_window.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,14 +36,6 @@ def setup
spec.ignore 'wxHtmlWindow::OnLinkClicked'
spec.no_proxy 'wxHtmlWindow::SendAutoScrollEvents'
spec.add_header_code 'typedef wxHtmlWindow::HTMLCursor HTMLCursor;'
# type mapping for LoadFile, SetFonts and OnOpeningURL
spec.map 'const wxFileName &filename' => 'String' do
# Deal with wxFileName
map_in temp: 'wxFileName tmp', code: <<~__CODE
tmp = wxFileName(RSTR_TO_WXSTR($input));
$1 = &tmp;
__CODE
end
# Deal with sizes argument to SetFonts
spec.map 'const int *sizes' => 'Array(Integer,Integer,Integer,Integer,Integer,Integer,Integer), nil' do
map_in temp: 'int tmp[7]', code: <<~__CODE
Expand Down
21 changes: 21 additions & 0 deletions rakelib/lib/generate/doc/grid_cell_attr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
:wxGridCellAttr.GetNonDefaultAlignment:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
h_align, v_align = attr.get_non_default_alignment
h_align = Wx::ALIGN_RIGHT if h_align == Wx::ALIGN_INVALID
```
:post:
- :pattern: !ruby/regexp /Unlike\s.*\{Wx::Alignment::ALIGN_INVALID\}\./
:subst: 'Unlike {Wx::GRID::GridCellAttr#get_alignment} this function only returns hAlign and vAlign if this attribute does define a non-default alignment. Otherwise the returned value will be {Wx::ALIGN_INVALID}.'
:wxGridCellAttr.GetAlignment:
:detail:
:post:
- :pattern: !ruby/regexp /Notice\s.*desirable\./
:subst: 'Notice that valid hAlign and vAlign values (default or non-default) are always returned by this function, use {Wx::GRID::GridCellAttr#get_non_default_alignment} if this is not desirable.'
25 changes: 25 additions & 0 deletions rakelib/lib/generate/doc/grid_ctrl.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
---
:wxGrid.GetRowGridLinePen:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
class MidiGrid < Wx::GRID::Grid
# ...
# in a grid displaying music notation, use a solid black pen between
# octaves (C0=row 127, C1=row 115 etc.)
def get_row_grid_line_pen(row)
if row % 12 == 7
Wx::Pen.new(Wx::BLACK, 1, Wx::PENSTYLE_SOLID)
else
get_default_grid_line_pen
end
end
end
```
11 changes: 11 additions & 0 deletions rakelib/lib/generate/doc/html_cell.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
:wxHtmlContainerCell.SetWidthFloat.w:
:brief:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
set_width_float(-50, Wx::HTML::HTML_UNITS_PIXELS)
```
23 changes: 23 additions & 0 deletions rakelib/lib/generate/doc/html_help_controller.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
---
:wxHtmlHelpController.AddBook:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
add_book('help.zip')
```
:wxHtmlHelpController.SetViewer:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
@help.set_viewer('kdehelp')
@help.set_viewer('gnome-help-browser')
@help.set_viewer('netscape', Wx::HELP_NETSCAPE)
```
21 changes: 21 additions & 0 deletions rakelib/lib/generate/doc/html_help_window.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
---
:wxHtmlHelpWindow:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
# @embeddedHelpWindow is a wxHtmlHelpWindow
# @embeddedHtmlHelp is a wxHtmlHelpController
#
# Create embedded HTML Help window
@embeddedHelpWindow = Wx::HTML::HtmlHelpWindow.new
@embeddedHtmlHelp.use_config(config, rootPath) # Set your own config object here
@embeddedHtmlHelp.set_help_window(@embeddedHelpWindow)
@embeddedHelpWindow.create(self, Wx::ID_ANY,
size: get_client_size,
style: Wx::TAB_TRAVERSAL|Wx::BORDER_NONE)
@embeddedHtmlHelp.add_book('doc.zip')
```
47 changes: 47 additions & 0 deletions rakelib/lib/generate/doc/html_window.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
---
:wxHtmlFilter.CanRead:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
class MyFilter < Wx::HTML::HtmlFilter
# ...
def can_read(file)
file.get_mime_type == 'application/x-ugh'
end
# ...
end
```
:wxHtmlFilter.ReadFile:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
class MyFilter < Wx::HTML::HtmlFilter
# ...
def read_file(file)
'<html><body><img src="' + file.get_location + '"></body></html>'
end
# ...
end
```
:wxHtmlWindow.SetPage:
:detail:
:pre:
:programlisting:
- :pattern: !ruby/regexp /.*/
:replace: |
```ruby
htmlwin.set_page('<html><body>Hello, world!</body></html>')
```
21 changes: 21 additions & 0 deletions rakelib/lib/typemap/common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -625,6 +625,27 @@ module Common
map_in code: '$1 = wxRuby_ConvertRbValue2Variant($input);'
end

# add type mapping for wxFileName input args
map 'const wxFileName&' => 'String' do
# Deal with wxFileName
map_in temp: 'wxFileName tmp', code: <<~__CODE
tmp = wxFileName(RSTR_TO_WXSTR($input));
$1 = &tmp;
__CODE
map_typecheck precedence: 'POINTER', code: <<~__CODE
$1 = TYPE($input) == T_STRING;
__CODE
map_directorin code: <<~__CODE
$input = WXSTR_TO_RSTR($1.GetFullPath());
__CODE
end

# add type mapping for wxFileName output
map 'wxFileName' => 'String' do
map_out code: '$result = WXSTR_TO_RSTR($1.GetFullPath());'
map_directorout code: '$result = RSTR_TO_WXSTR($input);'
end

end # define

end # Common
Expand Down

0 comments on commit bbf01ba

Please sign in to comment.