Cairo__GraphicsContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Sat, 13 Feb 2016 17:10:25 +0000
changeset 36 9b680e54aa94
parent 35 395689a88b32
child 40 28dfc583beb5
permissions -rw-r--r--
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context ...into two separate classes for cleaner responsibilities. Also, API of Smalltalk/X graphics contexts does not play well with Cairo's save/restore semantics.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     1
"{ Package: 'stx:goodies/libcairo' }"
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     2
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     3
"{ NameSpace: Cairo }"
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
     4
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
     5
CObject subclass:#GraphicsContext
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
     6
	instanceVariableNames:'surface'
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
     7
	classVariableNames:''
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
     8
	poolDictionaries:''
12
e5f0c18af8a9 - Cairo::Format
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 11
diff changeset
     9
	category:'Cairo-Objects'
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    10
!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    11
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    12
!GraphicsContext class methodsFor:'instance creation'!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    13
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    14
onSurface: surface
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    15
    | instance |
6
c1f387b40e3a regenerated using newer version of CFace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 5
diff changeset
    16
20
18a3e6b5f310 Added const modifier to FFI specs (required by recent STX)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 17
diff changeset
    17
    self
13
71529a6f007d - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 12
diff changeset
    18
        assert: (surface isKindOf: Cairo::Surface)
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    19
        message: 'surface is not valid Cairo surface'.
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    20
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    21
    instance := CPrimitives cairo_create: surface.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    22
    ^ instance initializeWithSurface: surface
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    23
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    24
    "Created: / 28-12-2014 / 23:45:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    25
    "Modified: / 13-02-2016 / 16:07:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    26
! !
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    27
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    28
!GraphicsContext methodsFor:'accessing'!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    29
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
    30
referenceCount
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
    31
    "Return value or reference counter"
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
    32
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    33
    ^ CPrimitives cairo_get_reference_count: self.
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
    34
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    35
    "Modified: / 13-02-2016 / 16:13:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
    36
!
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
    37
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
surface
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    39
    ^ surface
10
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    40
! !
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    41
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    42
!GraphicsContext methodsFor:'cairo api - paths'!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    43
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    44
arcNegativeX:x y:y radius:r from:startAngle to:stopAngle 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    45
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    46
        cairo_arc_negative:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    47
        _:x asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    48
        _:y asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    49
        _:r asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    50
        _:startAngle asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    51
        _:stopAngle asDouble
32
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    52
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    53
    "Created: / 07-01-2015 / 02:35:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    54
!
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    55
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    56
arcX:x y:y radius:r from:startAngle to:stopAngle 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    57
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    58
        cairo_arc:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    59
        _:x asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    60
        _:y asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    61
        _:r asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    62
        _:startAngle asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    63
        _:stopAngle asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    64
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    65
    "Created: / 17-06-2012 / 21:50:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    66
    "Modified: / 28-12-2014 / 22:00:18 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    67
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    68
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    69
closePath
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    70
    ^ CPrimitives cairo_close_path:self.
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    71
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    72
    "Created: / 01-01-2015 / 22:42:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    73
!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    74
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    75
lineCap: lc
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    76
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    77
    ^ CPrimitives cairo_set_line_cap: self _: lc
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    78
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    79
    "Created: / 17-06-2012 / 22:09:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    80
    "Modified: / 13-02-2016 / 16:42:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    81
!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    82
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    83
lineToX:x y:y 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    84
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    85
        cairo_line_to:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    86
        _:x asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    87
        _:y asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    88
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    89
    "Created: / 17-06-2012 / 22:15:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    90
    "Modified: / 28-12-2014 / 22:00:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    91
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    92
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    93
lineWidth: aNumber
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    94
    CPrimitives cairo_set_line_width: self _:aNumber asFloat
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    95
    .
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    96
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    97
    "Created: / 13-02-2016 / 16:45:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    98
!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    99
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   100
moveToX:x y:y 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   101
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   102
        cairo_move_to:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   103
        _:x asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   104
        _:y asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   105
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   106
    "Created: / 23-04-2009 / 17:21:00 / Jan Vrany <vranyj1@fel.cvut.cz>"
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   107
    "Modified: / 28-12-2014 / 22:00:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   108
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   109
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   110
rectangleX:x y:y width:w height:h 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   111
    | rx  ry  rw  rh |
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   112
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   113
    rx := x.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   114
    ry := y.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   115
    rw := w.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   116
    rh := h.
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   117
    rw < 0 ifTrue:[
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   118
        rx := rx + rw.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   119
        rw := rw abs.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   120
    ].
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   121
    rh < 0 ifTrue:[
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   122
        ry := ry + rh.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   123
        rh := rh abs.
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   124
    ].
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   125
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   126
        cairo_rectangle:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   127
        _:rx asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   128
        _:ry asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   129
        _:rw asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   130
        _:rh asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   131
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   132
    "Created: / 10-07-2008 / 09:41:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   133
    "Modified: / 02-01-2015 / 01:21:59 / Jan Vrany <jan.vrany@fit.cvut.cz>"
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   134
! !
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   135
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   136
!GraphicsContext methodsFor:'cairo api - patterns'!
26
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   137
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   138
setSourceSurface: aSurface
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   139
    ^ self setSourceSurface: aSurface x: 0.0 y: 0.0
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   140
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   141
    "Created: / 24-12-2014 / 23:12:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   142
!
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   143
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   144
setSourceSurface:aSyrface x:x y:y 
26
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   145
    "raise an error: this method should be implemented (TODO)"
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   146
    
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   147
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   148
        cairo_set_source_surface:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   149
        _:aSyrface
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   150
        _:x
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   151
        _:y
26
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   152
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   153
    "Created: / 24-12-2014 / 23:12:32 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   154
    "Modified: / 28-12-2014 / 21:59:20 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   155
! !
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   156
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   157
!GraphicsContext methodsFor:'cairo api - save & restore'!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   158
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   159
restore
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   160
    ^ CPrimitives cairo_restore:self
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   161
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   162
    "Created: / 17-06-2012 / 21:51:38 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   163
    "Modified: / 13-02-2016 / 16:14:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
10
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   164
!
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   165
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   166
save
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   167
    ^ CPrimitives cairo_save:self
10
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   168
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   169
    "Created: / 17-06-2012 / 21:51:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   170
    "Modified: / 13-02-2016 / 16:15:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   171
! !
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   172
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   173
!GraphicsContext methodsFor:'cairo api - source'!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   174
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   175
source: aCairoPatternOrColor
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   176
    aCairoPatternOrColor isColor ifTrue:[ 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   177
        self  sourceR: (aCairoPatternOrColor red / 100)  
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   178
                    G: (aCairoPatternOrColor green / 100)  
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   179
                    B: (aCairoPatternOrColor blue / 100)  
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   180
                    A: aCairoPatternOrColor alpha.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   181
        ^ self.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   182
    ].
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   183
    self notYetImplemented
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   184
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   185
    "Created: / 13-02-2016 / 16:52:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   186
!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   187
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   188
sourceR:r G:g B:b
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   189
    CPrimitives cairo_set_source_rgb: self 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   190
                                   _: r asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   191
                                   _: g asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   192
                                   _: b asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   193
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   194
    "Created: / 13-02-2016 / 16:55:28 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   195
!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   196
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   197
sourceR:r G:g B:b A:a
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   198
    CPrimitives cairo_set_source_rgba: self 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   199
                                    _: r asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   200
                                    _: g asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   201
                                    _: b asDouble
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   202
                                    _: a asDouble.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   203
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   204
    "Created: / 13-02-2016 / 16:54:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   205
! !
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   206
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   207
!GraphicsContext methodsFor:'cairo api - stroke & fill'!
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   208
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   209
fill
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   210
    ^ CPrimitives cairo_fill:self
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   211
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
    "Created: / 10-07-2008 / 09:42:50 / Jan Vrany <vranyj1@fel.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   213
    "Modified: / 28-12-2014 / 22:01:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   214
!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   215
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   216
fillAndPreserve
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   217
    ^ CPrimitives cairo_fill_preserve:self
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   218
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   219
    "Created: / 17-06-2012 / 21:52:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   220
    "Modified: / 28-12-2014 / 22:01:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   221
!
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   222
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   223
paint
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   224
    "A drawing operator that paints the current source everywhere within 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   225
     the current clip region."
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   226
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   227
    ^ CPrimitives cairo_paint:self.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   228
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   229
    "Created: / 13-02-2016 / 16:59:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   230
!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   231
15
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   232
showPage
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   233
    "Makes sense only for PDF surfaces"
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   234
    
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   235
    ^ CPrimitives cairo_show_page:self.
15
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   236
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   237
    "Created: / 17-06-2012 / 08:44:14 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   238
    "Modified: / 28-12-2014 / 22:02:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
15
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   239
!
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   240
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   241
stroke
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   242
    ^ CPrimitives cairo_stroke:self
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   243
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   244
    "Created: / 10-07-2008 / 09:42:43 / Jan Vrany <vranyj1@fel.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   245
    "Modified: / 28-12-2014 / 22:02:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   246
!
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   247
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   248
strokeAndPreserve
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   249
    ^ CPrimitives cairo_stroke_preserve:self
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   250
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   251
    "Created: / 17-06-2012 / 21:52:21 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   252
    "Modified: / 28-12-2014 / 22:15:40 / Jan Vrany <jan.vrany@fit.cvut.cz>"
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   253
! !
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   254
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   255
!GraphicsContext methodsFor:'cairo api - text'!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   256
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   257
font:family slant:slant weight:weight 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   258
    ^ CPrimitives 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   259
        cairo_select_font_face:self
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   260
        _:family asString
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   261
        _:slant asInteger
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   262
        _:weight asInteger
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   263
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   264
    "Created: / 29-12-2014 / 01:08:50 / Jan Vrany <jan.vrany@fit.cvut.cz>"
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   265
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   266
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   267
fontSize:sz 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   268
    ^ CPrimitives cairo_set_font_size:self _:sz asFloat
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   269
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   270
    "Created: / 23-04-2009 / 17:24:33 / Jan Vrany <vranyj1@fel.cvut.cz>"
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   271
    "Modified: / 02-01-2015 / 01:39:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   272
!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   273
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   274
showText:aString 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   275
    ^ CPrimitives cairo_show_text:self _:aString utf8Encoded
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   276
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   277
    "Created: / 23-04-2009 / 17:25:20 / Jan Vrany <vranyj1@fel.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   278
    "Modified: / 28-12-2014 / 22:02:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   279
! !
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   280
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   281
!GraphicsContext methodsFor:'cairo api - transformations & clipping'!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   282
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   283
clip
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   284
    ^ CPrimitives cairo_clip:self.
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   285
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   286
    "Created: / 17-06-2012 / 21:56:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
29
6ba06265e543 Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 26
diff changeset
   287
    "Modified: / 28-12-2014 / 22:02:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   288
!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   289
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   290
matrix: aCairoMatrix
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   291
    self notYetImplemented
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   292
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   293
    "Created: / 13-02-2016 / 19:51:57 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   294
!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   295
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   296
matrixReset
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   297
    "Resets the current transformation matrix (CTM) by setting it equal to the 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   298
     identity matrix. That is, the user-space and device-space axes will be 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   299
     aligned and one user-space unit will transform to one device-space unit."
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   300
    CPrimitives cairo_identity_matrix: self.
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   301
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   302
    "Created: / 13-02-2016 / 19:54:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
33
8a2e438b4363 To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 32
diff changeset
   303
!
8a2e438b4363 To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 32
diff changeset
   304
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   305
scale: aNumberOrPoint
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   306
    | sx sy |
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   307
    aNumberOrPoint isPoint ifTrue:[ 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   308
        sx := aNumberOrPoint x asFloat.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   309
        sy := aNumberOrPoint y asFloat.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   310
    ] ifFalse:[ 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   311
        sx := sy := aNumberOrPoint asFloat.
33
8a2e438b4363 To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 32
diff changeset
   312
    ].
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   313
    CPrimitives cairo_scale: self _: sx _: sy.
33
8a2e438b4363 To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 32
diff changeset
   314
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   315
    "Created: / 13-02-2016 / 16:40:13 / Jan Vrany <jan.vrany@fit.cvut.cz>"
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   316
!
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   317
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   318
translate: aNumberOrPoint
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   319
    | tx ty |
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   320
    aNumberOrPoint isPoint ifTrue:[ 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   321
        tx := aNumberOrPoint x asFloat.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   322
        ty := aNumberOrPoint y asFloat.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   323
    ] ifFalse:[ 
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   324
        tx := ty := aNumberOrPoint asFloat.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   325
    ].
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   326
    CPrimitives cairo_translate: self _: tx _: ty.
34
97705b5a9411 Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 33
diff changeset
   327
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   328
    "Created: / 13-02-2016 / 16:40:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
34
97705b5a9411 Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 33
diff changeset
   329
! !
97705b5a9411 Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 33
diff changeset
   330
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   331
!GraphicsContext methodsFor:'initialization & release'!
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   332
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   333
initializeWithSurface: aSurface
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   334
    surface := aSurface.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   335
    self registerForFinalization
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   336
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   337
    "Created: / 13-02-2016 / 16:08:34 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   338
! !
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   339
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   340
!GraphicsContext methodsFor:'private'!
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   341
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   342
destroy
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   343
    "Tell Cairo library to destroy the corresponding C object.
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   344
     Remember that object is physically destroyed only if internal
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   345
     refcounter goes to zero. However, after calling destroy,
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   346
     this instance should be treated as invalid."
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   347
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   348
    surface := nil.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   349
    CPrimitives cairo_destroy: self.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   350
    self setAddress: nil.
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   351
36
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
   352
    "Modified: / 13-02-2016 / 16:13:45 / Jan Vrany <jan.vrany@fit.cvut.cz>"
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   353
! !
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   354