Cairo__Matrix.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sun, 28 Dec 2014 22:38:24 +0100
changeset 29 6ba06265e543
parent 23 38ee47dbd976
child 40 28dfc583beb5
permissions -rw-r--r--
Bindinge updated to recent Cairo version. All primitives moved to a new class - Cairo::CPrimitives. Callouts selectors changed to reflect C function names closely.

"{ Package: 'stx:goodies/libcairo' }"

"{ NameSpace: Cairo }"

ExternalStructure subclass:#Matrix
	instanceVariableNames:''
	classVariableNames:''
	poolDictionaries:''
	category:'Cairo-Objects'
!


!Matrix class methodsFor:'accessing'!

dllPath

    OperatingSystem isMSWINDOWSlike ifTrue:[
        ^ #( 'C:\Windows' 'C:\Windows\System32' "Wild guess, should not harm" )
    ].

    OperatingSystem isUNIXlike ifTrue:[
        OperatingSystem getSystemType == #linux ifTrue:[
            | path |

            path := #( '/lib' '/usr/lib' '/usr/local/lib' ).
            (OperatingSystem getSystemInfo at:#machine) = 'x86_64' ifTrue:[
                "If the machine is 64bit, prepend standard path for 32bit libs.
                 Leave standard paths at the end, as the system might be completely 
                 32bit but running on 64bit-capable CPU.

                CAVEAT: This is bit dangerous, as on 64bit OS, if ia32 libs are
                not installed byt 64bit sqlite libs are, then 64bit libs are found
                and when a function is called, segfault will occur!!

                Q: Is there a way how to figure out if the OS itself is 32bit,
                regardles on CPU?"
                path := #( '/lib32' '/usr/lib32' '/usr/local/lib32' ) , path.
            ].
            ^path

        ].
    ].

    self error:'Unsupported operating system'

    "
        SqliteLibrary dllPath
    "

    "Created: / 31-08-2011 / 18:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!

libraryName

    OperatingSystem isUNIXlike ifTrue:[^'libcairo.so.2'].

    OperatingSystem isMSWINDOWSlike ifTrue:[^'cairo.dll'].

    self error:'Library name for host OS is not known'
!

sizeof
    "Returns size of undelaying structure in bytes"

    ^48
! !

!Matrix class methodsFor:'primitives'!

primInit: matrix xx: xx yx: yx xy: xy yy: yy x0: x0 y0: y0 

	<cdecl: const void "cairo_matrix_init" ( Cairo::Matrix double double double double double double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primInitIdentity: matrix 

	<cdecl: const void "cairo_matrix_init_identity" ( Cairo::Matrix ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primInitRotate: matrix radians: radians 

	<cdecl: const void "cairo_matrix_init_rotate" ( Cairo::Matrix double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primInitScale: matrix sx: sx sy: sy 

	<cdecl: const void "cairo_matrix_init_scale" ( Cairo::Matrix double double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primInitTranslate: matrix tx: tx ty: ty 

	<cdecl: const void "cairo_matrix_init_translate" ( Cairo::Matrix double double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primInvert: matrix 

	<cdecl: const int32 "cairo_matrix_invert" ( Cairo::Matrix ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primMultiply: result a: a b: b 

	<cdecl: const void "cairo_matrix_multiply" ( Cairo::Matrix Cairo::Matrix Cairo::Matrix ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primRotate: matrix radians: radians 

	<cdecl: const void "cairo_matrix_rotate" ( Cairo::Matrix double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primScale: matrix sx: sx sy: sy 

	<cdecl: const void "cairo_matrix_scale" ( Cairo::Matrix double double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primTransformDistance: matrix dx: dx dy: dy 

	<cdecl: const void "cairo_matrix_transform_distance" ( Cairo::Matrix pointer pointer ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:54 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primTransformPoint: matrix x: x y: y 

	<cdecl: const void "cairo_matrix_transform_point" ( Cairo::Matrix pointer pointer ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
!

primTranslate: matrix tx: tx ty: ty 

	<cdecl: const void "cairo_matrix_translate" ( Cairo::Matrix double double ) >
	self primitiveFailed

    "Modified: / 10-09-2008 / 18:19:55 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !

!Matrix methodsFor:'accessing'!

x0
    "Returns double"

    ^self doubleAt:1 + 32
!

x0: value

    self doubleAt:1 + 32 put:value
!

xx
    "Returns double"

    ^self doubleAt:1 + 0
!

xx: value

    self doubleAt:1 + 0 put:value
!

xy
    "Returns double"

    ^self doubleAt:1 + 16
!

xy: value

    self doubleAt:1 + 16 put:value
!

y0
    "Returns double"

    ^self doubleAt:1 + 40
!

y0: value

    self doubleAt:1 + 40 put:value
!

yx
    "Returns double"

    ^self doubleAt:1 + 8
!

yx: value

    self doubleAt:1 + 8 put:value
!

yy
    "Returns double"

    ^self doubleAt:1 + 24
!

yy: value

    self doubleAt:1 + 24 put:value
! !

!Matrix class methodsFor:'documentation'!

version
    ^'$Id$'
!

version_HG
    ^ '$Changeset: <not expanded> $'
! !