Skip to content

Commit

Permalink
Merge pull request #350 from mcorino/develop
Browse files Browse the repository at this point in the history
update wxw master support
  • Loading branch information
mcorino authored Jan 11, 2025
2 parents c7acbc7 + b0ede65 commit 8eb1ad4
Show file tree
Hide file tree
Showing 6 changed files with 131 additions and 4 deletions.
2 changes: 2 additions & 0 deletions rakelib/lib/director/html_printout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Director

class HtmlPrintout < Director

include Typemap::PrintPageRange

def setup
super
spec.override_inheritance_chain('wxHtmlPrintout', {'wxPrintout' => 'wxPrinter'}, 'wxObject')
Expand Down
7 changes: 7 additions & 0 deletions rakelib/lib/director/print_data.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Director

class PrintData < Director

include Typemap::PrintPageRange

def setup
super
spec.gc_as_untracked
Expand All @@ -21,6 +23,11 @@ def setup
# only keep the const version
spec.ignore 'wxPageSetupDialogData::GetPrintData'
spec.regard 'wxPageSetupDialogData::GetPrintData() const'
if Config.instance.wx_version >= '3.3.0'
# new since 3.3.0
spec.items << 'wxPrintPageRange'
spec.regard 'wxPrintPageRange::fromPage', 'wxPrintPageRange::toPage' # include public attributes
end
# for GetPrintData methods
spec.map 'wxPrintData&' => 'Wx::PrintData' do
map_out code: '$result = SWIG_NewPointerObj(SWIG_as_voidptr(new wxPrintData(*$1)), SWIGTYPE_p_wxPrintData, SWIG_POINTER_OWN);'
Expand Down
2 changes: 2 additions & 0 deletions rakelib/lib/director/printer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Director

class Printer < Director

include Typemap::PrintPageRange

def setup
super
spec.items << 'wxPrintout' << 'wxPrintPreview'
Expand Down
2 changes: 2 additions & 0 deletions rakelib/lib/director/richtext_printing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ class Director

class RichTextPrinting < Director

include Typemap::PrintPageRange

def setup
spec.items << 'wxRichTextPrintout'
super
Expand Down
25 changes: 21 additions & 4 deletions rakelib/lib/director/textctrl.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,28 @@ def setup
spec.ignore 'wxTextCtrl::GTKGetTextBuffer',
'wxTextCtrl::GTKGetEditable'
end
if Config.instance.wx_version >= '3.3.0' && Config.instance.wx_port == :wxmsw
if Config.instance.wx_version >= '3.3.0' && Config.instance.wx_port != :wxosx
spec.items << 'wxTextSearch' << 'wxTextSearchResult'
spec.regard 'wxTextSearchResult::m_start', 'wxTextSearchResult::m_end'
spec.make_readonly 'wxTextSearchResult::m_start', 'wxTextSearchResult::m_end'
spec.rename_for_ruby 'start' => 'wxTextSearchResult::m_start',
spec.regard 'wxTextSearch::m_searchValue',
'wxTextSearch::m_startingPosition',
'wxTextSearch::m_matchCase',
'wxTextSearch::m_wholeWord',
'wxTextSearch::m_direction',
'wxTextSearchResult::m_start',
'wxTextSearchResult::m_end'
spec.make_readonly 'wxTextSearch::m_searchValue',
'wxTextSearch::m_startingPosition',
'wxTextSearch::m_matchCase',
'wxTextSearch::m_wholeWord',
'wxTextSearch::m_direction',
'wxTextSearchResult::m_start',
'wxTextSearchResult::m_end'
spec.rename_for_ruby 'get_search_value' => 'wxTextSearch::m_searchValue',
'get_starting_position' => 'wxTextSearch::m_startingPosition',
'match_case?' => 'wxTextSearch::m_matchCase',
'whole_word?' => 'wxTextSearch::m_wholeWord',
'get_direction' => 'wxTextSearch::m_direction',
'start' => 'wxTextSearchResult::m_start',
'end' => 'wxTextSearchResult::m_end'
end
if Config.instance.wx_port == :wxqt
Expand Down
97 changes: 97 additions & 0 deletions rakelib/lib/typemap/print_page_range.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

###
# wxRuby3 PrintPageRange array typemap definition
###

require_relative '../core/mapping'

module WXRuby3

module Typemap

# Typemaps for converting returned PGCell references to
# either the correct wxRuby class
module PrintPageRange

include Typemap::Module

define do

if Config.instance.wx_version >= '3.3.0'
map 'const std::vector<wxPrintPageRange> &' => 'Array<Wx::PRT::PrintPageRange>' do
map_out code: <<~__CODE
$result = rb_ary_new();
for (const wxPrintPageRange& range : *$1)
{
VALUE r_range = SWIG_NewPointerObj(new wxPrintPageRange(range), SWIGTYPE_p_wxPrintPageRange, SWIG_POINTER_OWN);
rb_ary_push($result, r_range);
}
__CODE
map_in temp: 'std::vector<wxPrintPageRange> tmp', code: <<~__CODE
if (TYPE($input) == T_ARRAY)
{
$1 = &tmp;
for (int i = 0; i < RARRAY_LEN($input); i++)
{
void *ptr;
VALUE r_range = rb_ary_entry($input, i);
int res = SWIG_ConvertPtr(r_range, &ptr, SWIGTYPE_p_wxPrintPageRange, 0);
if (!SWIG_IsOK(res) || !ptr) {
rb_raise(rb_eTypeError, "Expected Array of Wx::PRT::PrintPageRange for 1");
}
wxPrintPageRange *range = reinterpret_cast< wxPrintPageRange * >(ptr);
$1->push_back(*range);
}
}
else {
rb_raise(rb_eArgError, "Expected Array of Wx::PRT::PrintPageRange for 1");
}
__CODE
end

map 'std::vector<wxPrintPageRange> &' => 'Array<Wx::PRT::PrintPageRange>' do

map_in temp: 'std::vector<wxPrintPageRange> tmp_vector', code: '$1 = &tmp_vector;'

map_argout code: <<~__CODE
for (const wxPrintPageRange& range : *$1)
{
VALUE r_range = SWIG_NewPointerObj(new wxPrintPageRange(range), SWIGTYPE_p_wxPrintPageRange, SWIG_POINTER_OWN);
rb_ary_push($input, r_range);
}
__CODE

map_directorin code: '$input = rb_ary_new();'

map_directorargout code: <<~__CODE
for (int i = 0; i < RARRAY_LEN($result); i++)
{
void *ptr;
VALUE r_range = rb_ary_entry($result, i);
int res = SWIG_ConvertPtr(r_range, &ptr, SWIGTYPE_p_wxPrintPageRange, 0);
if (!SWIG_IsOK(res) || !ptr) {
Swig::DirectorTypeMismatchException::raise(swig_get_self(), "$symname", rb_eTypeError,
"expected Array of Wx::PRT::PrintPageRange in argument 1");
}
wxPrintPageRange *range = reinterpret_cast< wxPrintPageRange * >(ptr);
$1.push_back(*range);
}
__CODE

end
end
# Doc only mapping def
map 'std::vector<wxPrintPageRange> &' => 'Array<Wx::PRT::PrintPageRange>', swig: false do
map_in
end

end

end

end

end

0 comments on commit 8eb1ad4

Please sign in to comment.