Cairo__GraphicsContext.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Wed, 17 Feb 2016 06:43:31 +0000
changeset 40 28dfc583beb5
parent 36 9b680e54aa94
child 43 1006839761af
permissions -rw-r--r--
#displayString: in CairoGraphicsContext revamped Introduced a CairoScaledFont, a kind of FontDescription for Cairo fonts (Cairo::ScaledFont / cairo_scaled_font_t). CairoScaledFont provides a bridge between Smalltalk/X font API and Cairo the same way CairoGraphicsContext provides a bridge bewtween Smalltalk/X drawing API and Cairo. Don't use Cairo's "toy" text API to select font. Under X11, use FontConfig to select a proper font. However, for actual text rendering and measurements, Cairo's "toy" API is still used - it seems to be good enough, certainly as good as Core X11 / Xft text rendering for Latin-based left-to-right languages. At this point a TextEditView can be rendered using Cairo.
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
40
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    38
status
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    39
    ^ CPrimitives cairo_status: self
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    40
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    41
    "Created: / 18-02-2016 / 20:01:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    42
!
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    43
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    44
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
    45
    ^ surface
10
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    46
! !
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    47
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    48
!GraphicsContext methodsFor:'cairo api - paths'!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    49
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
    50
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
    51
    ^ 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
    52
        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
    53
        _: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
    54
        _: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
    55
        _: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
    56
        _: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
    57
        _:stopAngle asDouble
32
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    58
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    59
    "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
    60
!
fb983be8d2c0 To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
    61
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
    62
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
    63
    ^ 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
    64
        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
    65
        _: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
    66
        _: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
    67
        _: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
    68
        _: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
    69
        _:stopAngle asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    70
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    71
    "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
    72
    "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
    73
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    74
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    75
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
    76
    ^ CPrimitives cairo_close_path:self.
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    77
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    78
    "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
    79
!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    80
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
    81
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
    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
    ^ CPrimitives cairo_set_line_cap: self _: lc
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    84
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
    85
    "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
    86
    "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
    87
!
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
    88
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
    89
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
    90
    ^ 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
    91
        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
    92
        _: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
    93
        _:y asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    94
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    95
    "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
    96
    "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
    97
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
    98
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
    99
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
   100
    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
   101
    .
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   102
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
   103
    "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
   104
!
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
   105
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
   106
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
   107
    ^ 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
   108
        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
   109
        _: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
   110
        _:y asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   111
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   112
    "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
   113
    "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
   114
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   115
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
   116
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
   117
    | rx  ry  rw  rh |
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   118
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   119
    rx := x.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   120
    ry := y.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   121
    rw := w.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   122
    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
   123
    rw < 0 ifTrue:[
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   124
        rx := rx + rw.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   125
        rw := rw abs.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   126
    ].
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
   127
    rh < 0 ifTrue:[
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   128
        ry := ry + rh.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   129
        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
   130
    ].
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
   131
    ^ 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
   132
        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
   133
        _: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
   134
        _: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
   135
        _: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
   136
        _:rh asDouble
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   137
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   138
    "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
   139
    "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
   140
! !
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   141
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   142
!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
   143
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   144
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
   145
    ^ 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
   146
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   147
    "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
   148
!
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   149
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
   150
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
   151
    "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
   152
    
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
   153
    ^ 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
   154
        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
   155
        _: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
   156
        _: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
   157
        _: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
   158
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   159
    "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
   160
    "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
   161
! !
7f07a8c31e6d Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 23
diff changeset
   162
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   163
!GraphicsContext methodsFor:'cairo api - save & restore'!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   164
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   165
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
   166
    ^ CPrimitives cairo_restore:self
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   167
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   168
    "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
   169
    "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
   170
!
dd5fece7c8d2 Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   171
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   172
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
   173
    ^ 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
   174
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   175
    "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
   176
    "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
   177
! !
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
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
!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
   180
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
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
   182
    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
   183
        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
   184
                    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
   185
                    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
   186
                    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
   187
        ^ 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
   188
    ].
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
    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
   190
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
    "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
   192
!
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
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
   195
    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
   196
                                   _: 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
   197
                                   _: 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
   198
                                   _: 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
   199
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
    "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
   201
!
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
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
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
   204
    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
   205
                                    _: 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
   206
                                    _: 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
   207
                                    _: 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
   208
                                    _: 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
   209
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
    "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
   211
! !
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   212
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   213
!GraphicsContext methodsFor:'cairo api - stroke & fill'!
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
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
   216
    ^ CPrimitives cairo_fill:self
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   217
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   218
    "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
   219
    "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
   220
!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   221
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   222
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
   223
    ^ CPrimitives cairo_fill_preserve:self
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   224
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   225
    "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
   226
    "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
   227
!
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   228
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
   229
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
   230
    "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
   231
     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
   232
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
   233
    ^ 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
   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
    "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
   236
!
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
   237
15
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   238
showPage
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   239
    "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
   240
    
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
   241
    ^ CPrimitives cairo_show_page:self.
15
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   242
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   243
    "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
   244
    "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
   245
!
c1db2c8aa2ed - stx_goodies_libcairo
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 13
diff changeset
   246
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   247
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
   248
    ^ CPrimitives cairo_stroke:self
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   249
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   250
    "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
   251
    "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
   252
!
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
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
   255
    ^ CPrimitives cairo_stroke_preserve:self
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   256
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   257
    "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
   258
    "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
   259
! !
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   260
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   261
!GraphicsContext methodsFor:'cairo api - text'!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   262
40
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   263
font
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   264
    ^ CPrimitives cairo_get_scaled_font: self
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   265
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   266
    "Created: / 17-02-2016 / 21:02:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   267
!
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   268
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   269
font: scaledFont
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   270
    CPrimitives cairo_set_scaled_font: self _: scaledFont
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   271
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   272
    "Created: / 17-02-2016 / 21:01:47 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   273
!
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   274
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
   275
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
   276
    ^ 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
   277
        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
   278
        _: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
   279
        _: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
   280
        _:weight asInteger
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   281
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   282
    "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
   283
!
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   284
40
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   285
fontMatrix
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   286
    | matrix |
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   287
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   288
    matrix := Matrix new.
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   289
    CPrimitives cairo_get_font_matrix: self _: matrix.
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   290
    ^ matrix
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   291
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   292
    "Created: / 18-02-2016 / 10:09:30 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   293
!
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   294
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   295
fontMatrix: matrix
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   296
    "Sets the current font matrix to matrix . The font matrix gives a transformation from 
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   297
     the design space of the font (in this space, the em-square is 1 unit by 1 unit) 
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   298
     to user space. Normally, a simple scale is used (see #fontSize:), but a more complex 
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   299
     font matrix can be used to shear the font or stretch it unequally along the two axes"
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   300
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   301
    CPrimitives cairo_set_font_matrix: self _: matrix.
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   302
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   303
    "Created: / 18-02-2016 / 10:11:00 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   304
!
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   305
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
   306
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
   307
    ^ 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
   308
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   309
    "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
   310
    "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
   311
!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
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
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
   314
    ^ CPrimitives cairo_show_text:self _:aString utf8Encoded
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   315
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   316
    "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
   317
    "Modified: / 28-12-2014 / 22:02:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
40
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   318
!
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   319
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   320
textExtents:aString
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   321
    | extents |
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   322
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   323
    extents := TextExtents new.
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   324
    CPrimitives cairo_text_extents:self _:aString utf8Encoded _: extents.
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   325
    ^ extents.
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   326
28dfc583beb5 #displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   327
    "Created: / 18-02-2016 / 08:55:12 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   328
! !
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   329
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   330
!GraphicsContext methodsFor:'cairo api - transformations & clipping'!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   331
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   332
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
   333
    ^ CPrimitives cairo_clip:self.
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   334
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   335
    "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
   336
    "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
   337
!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   338
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
   339
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
   340
    self notYetImplemented
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
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
    "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
   343
!
17
5f943c05c028 - Cairo::GraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 15
diff changeset
   344
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
   345
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
   346
    "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
   347
     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
   348
     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
   349
    CPrimitives cairo_identity_matrix: self.
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   350
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
   351
    "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
   352
!
8a2e438b4363 To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 32
diff changeset
   353
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
   354
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
   355
    | 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
   356
    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
   357
        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
   358
        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
   359
    ] 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
   360
        sx := sy := aNumberOrPoint asFloat.
33
8a2e438b4363 To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 32
diff changeset
   361
    ].
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
   362
    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
   363
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
   364
    "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
   365
!
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   366
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
   367
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
   368
    | 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
   369
    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
   370
        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
   371
        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
   372
    ] 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
   373
        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
   374
    ].
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
   375
    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
   376
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
   377
    "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
   378
! !
97705b5a9411 Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 33
diff changeset
   379
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   380
!GraphicsContext methodsFor:'initialization & release'!
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   381
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
   382
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
   383
    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
   384
    self registerForFinalization
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   385
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
   386
    "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
   387
! !
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   388
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
   389
!GraphicsContext methodsFor:'private'!
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 34
diff changeset
   390
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
   391
destroy
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   392
    "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
   393
     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
   394
     refcounter goes to zero. However, after calling destroy,
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   395
     this instance should be treated as invalid."
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   396
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
   397
    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
   398
    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
   399
    self setAddress: nil.
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   400
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
   401
    "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
   402
! !
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 29
diff changeset
   403