Skip to content

Commit

Permalink
Merge pull request #267 from mcorino/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
mcorino authored Apr 4, 2024
2 parents b4b5a2f + a9a0127 commit ebfa518
Show file tree
Hide file tree
Showing 7 changed files with 435 additions and 30 deletions.
112 changes: 112 additions & 0 deletions lib/wx/core/geometry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

module Wx
class Point2DInt

alias :x :get_x
alias :x= :set_x
alias :y :get_y
alias :y= :set_y

# make wrappers private
private :add, :sub, :mul, :div

wx_assign = instance_method :assign
define_method :assign do |pt|
wx_assign.bind(self).call(pt)
self
end

def add!(pt)
add(pt)
self
end

def sub!(pt)
sub(pt)
self
end

def mul!(v)
mul(v)
self
end

def div!(v)
div(v)
self
end

def +(pt)
Point2DInt.new(self).add!(pt)
end

def -(pt)
Point2DInt.new(self).sub!(pt)
end

def *(v)
Point2DInt.new(self).mul!(v)
end

def /(v)
Point2DInt.new(self).div!(v)
end

end
class Point2DDouble

alias :x :get_x
alias :x= :set_x
alias :y :get_y
alias :y= :set_y

# make wrappers private
private :add, :sub, :mul, :div

wx_assign = instance_method :assign
define_method :assign do |pt|
wx_assign.bind(self).call(pt)
self
end

def add!(pt)
add(pt)
self
end

def sub!(pt)
sub(pt)
self
end

def mul!(v)
mul(v)
self
end

def div!(v)
div(v)
self
end

def +(pt)
Point2DDouble.new(self).add!(pt)
end

def -(pt)
Point2DDouble.new(self).sub!(pt)
end

def *(v)
Point2DDouble.new(self).mul!(v)
end

def /(v)
Point2DDouble.new(self).div!(v)
end

end
end
125 changes: 125 additions & 0 deletions lib/wx/doc/geometry.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
# :stopdoc:
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.


###
# wxRuby3 2D geometry classes
###
# :startdoc:


module Wx
class Point2DInt

# @return [Integer]
def get_x; end
alias :x :get_x
# @param [Integer] v
# @return [Integer]
def set_x(v) end
alias :x= :set_x

# @return [Integer]
def get_y; end
alias :y :get_y
# @param [Integer] v
# @return [Integer]
def set_y(v) end
alias :y= :set_y

# @param [Wx::Point2DInt] pt
# @return [self]
def assign(pt) end

# @param [Wx::Point2DInt] pt
# @return [self]
def add!(pt) end

# @param [Wx::Point2DInt] pt
# @return [self]
def sub!(pt) end

# @param [Wx::Point2DInt,Integer,Float] v
# @return [self]
def mul!(v) end

# @param [Wx::Point2DInt,Integer,Float] v
# @return [self]
def div!(v) end

# @param [Wx::Point2DInt] pt
# @return [Wx::Point2DInt]
def +(pt) end

# @param [Wx::Point2DInt] pt
# @return [Wx::Point2DInt]
def -(pt) end

# @param [Wx::Point2DInt,Integer,Float] v
# @return [Wx::Point2DInt]
def *(v) end

# @param [Wx::Point2DInt,Integer,Float] v
# @return [Wx::Point2DInt]
def /(v) end

end

class Point2DDouble

# @return [Integer]
def get_x; end
alias :x :get_x
# @param [Integer] v
# @return [Integer]
def set_x(v) end
alias :x= :set_x

# @return [Integer]
def get_y; end
alias :y :get_y
# @param [Integer] v
# @return [Integer]
def set_y(v) end
alias :y= :set_y

# @param [Wx::Point2DInt] pt
# @return [self]
def assign(pt) end

# @param [Wx::Point2DDouble] pt
# @return [self]
def add!(pt) end

# @param [Wx::Point2DDouble] pt
# @return [self]
def sub!(pt) end

# @param [Wx::Point2DDouble,Integer,Float] v
# @return [self]
def mul!(v) end

# @param [Wx::Point2DDouble,Integer,Float] v
# @return [self]
def div!(v) end

# @param [Wx::Point2DDouble] pt
# @return [Wx::Point2DDouble]
def +(pt) end

# @param [Wx::Point2DDouble] pt
# @return [Wx::Point2DDouble]
def -(pt) end

# @param [Wx::Point2DDouble,Integer,Float] v
# @return [Wx::Point2DDouble]
def *(v) end

# @param [Wx::Point2DDouble,Integer,Float] v
# @return [Wx::Point2DDouble]
def /(v) end

end
end
51 changes: 51 additions & 0 deletions rakelib/lib/director/affine_matrix.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# Copyright (c) 2023 M.J.N. Corino, The Netherlands
#
# This software is released under the MIT license.

###
# wxRuby3 wxWidgets interface director
###

module WXRuby3

class Director

class AffineMatrix2D < Director

def setup
spec.items.unshift('wxAffineMatrix2DBase') << 'wxMatrix2D'

spec.make_abstract 'wxAffineMatrix2DBase'
spec.disable_proxies

spec.map_apply 'int * OUTPUT' => ['wxDouble *']
spec.map 'wxPoint2DDouble *' => 'Wx::Point2DDouble' do
map_in ignore: true, temp: 'wxPoint2DDouble tmp', code: '$1 = &tmp;'

map_argout code: <<~__CODE
$result = SWIG_Ruby_AppendOutput($result, SWIG_NewPointerObj(new wxPoint2DDouble(tmp$argnum), SWIGTYPE_p_wxPoint2DDouble, SWIG_POINTER_OWN));
__CODE
end
spec.map 'wxMatrix2D *' => 'Wx::Matrix2D' do
map_in ignore: true, temp: 'wxMatrix2D tmp', code: '$1 = &tmp;'

map_argout code: <<~__CODE
$result = SWIG_Ruby_AppendOutput($result, SWIG_NewPointerObj(new wxMatrix2D(tmp$argnum), SWIGTYPE_p_wxPoint2DDouble, SWIG_POINTER_OWN));
__CODE
end

spec.ignore 'wxAffineMatrix2D::Mirror',
'wxAffineMatrix2D::TransformPoint',
'wxAffineMatrix2D::TransformDistance',
'wxAffineMatrix2D::IsEqual'

spec.regard 'wxMatrix2D::m_11', 'wxMatrix2D::m_12',
'wxMatrix2D::m_21', 'wxMatrix2D::m_22'

end

end

end

end
8 changes: 1 addition & 7 deletions rakelib/lib/director/dc.rb
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,7 @@ def setup
'wxDC::GetLogicalOrigin(wxCoord *,wxCoord *) const',
'wxDC::GetHandle'
]
# ignore Matrix Transformation methods until someone asks for them
# TODO : possibly wrap at a later time
spec.ignore 'wxDC::SetTransformMatrix',
'wxDC::GetTransformMatrix',
'wxDC::ResetTransformMatrix',
'wxDC::CanUseTransformMatrix'
spec.disable_proxies
spec.disable_proxies
spec.rename_for_ruby({
'GetDimensions' => 'wxDC::GetSize(wxCoord *, wxCoord *) const',
'GetDimensionsMM' => 'wxDC::GetSizeMM(wxCoord *, wxCoord *) const',
Expand Down
Loading

0 comments on commit ebfa518

Please sign in to comment.