extensions.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Thu, 18 Feb 2016 23:16:17 +0000
changeset 41 17bc740cbc2a
parent 39 8af34937e1ec
child 47 061f23d91383
permissions -rw-r--r--
Fixed (lazy) initialization of CairoGraphicsContext A CairoGraphicsContext may exist without a GC / Cairo created. Once GC and Cairo is initialized for given drawable, all properties like font, linewidth, colors and so on has to be set in Cairo. Like with native GC, this is done in #initCR. SimleView>>cairoify now cairoifies view and all its children.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
11
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
     1
"{ Package: 'stx:goodies/libcairo' }"!
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
     2
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
     3
!DeviceGraphicsContext methodsFor:'accessing'!
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
     4
9b680e54aa94 Take a step 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
cairo
9b680e54aa94 Take a step 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
    "Return a Cairo context for drawing onto this GC" 
9b680e54aa94 Take a step 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
9b680e54aa94 Take a step 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
    | cr |
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
     9
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    10
    cr := Cairo::GraphicsContext onSurface: self cairoSurface.
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    11
    transformation notNil 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
    12
        cr transformation: transformation
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    13
    ].
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    14
    ^ cr
9b680e54aa94 Take a step 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
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    16
    "Created: / 26-12-2014 / 23:28:49 / 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
    17
    "Modified: / 13-02-2016 / 15:59:05 / 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
    18
! !
9b680e54aa94 Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 35
diff changeset
    19
38
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    20
!DeviceGraphicsContext methodsFor:'accessing'!
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    21
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    22
cairoSurface
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    23
    | view surface |
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    24
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    25
    view := device viewFromId:drawableId.
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    26
    surface := Cairo::Surface onView: view.
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    27
    ^ surface
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    28
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    29
    "Modified: / 14-02-2016 / 00:10:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    30
! !
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
    31
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    32
!DeviceGraphicsContext methodsFor:'cairo support'!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    33
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    34
drawableId
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    35
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    36
    ^drawableId
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    37
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    38
    "Created: / 10-07-2008 / 10:20:04 / Jan Vrany <vranyj1@fel.cvut.cz>"
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    39
! !
11
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    40
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    41
!GraphicsContext methodsFor:'drawing in device coordinates'!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    42
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    43
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    44
    "draw a line in device coordinates"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    45
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    46
    |sav|
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    47
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    48
    sav := transformation.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    49
    self transformation: nil.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    50
    self displayLineFromX:x1 y:y1 toX:x2 y:y2.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    51
    self transformation: sav
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    52
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    53
    "Created: / 01-01-2015 / 22:50:49 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    54
! !
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    55
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    56
!GraphicsContext methodsFor:'drawing in device coordinates'!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    57
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    58
displayDeviceRectangleX:x y:y width:w height:h
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    59
    "draw a rectangle in device coordinates"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    60
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    61
    |sav|
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    62
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    63
    sav := transformation.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    64
    self transformation: nil.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    65
    self displayRectangleX:x y:y width:w height:h.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    66
    self transformation: sav
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    67
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    68
    "Created: / 01-01-2015 / 22:51:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    69
! !
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    70
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    71
!GraphicsContext methodsFor:'drawing in device coordinates'!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    72
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    73
fillDeviceRectangleX:x y:y width:w height:h
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    74
    "fill a rectangle with current paint color (device coordinates)"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    75
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    76
    |sav|
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
    sav := transformation.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    79
    self transformation: nil.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    80
    self fillRectangleX:x y:y width:w height:h.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    81
    self transformation: sav
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    82
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    83
    "Created: / 01-01-2015 / 22:51:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    84
! !
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
    85
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    86
!GraphicsDevice methodsFor:'cairo support'!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    87
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    88
cairoSurfaceFor: view
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    89
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    90
    self error:'Graphics device not supported'
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    91
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    92
    "Created: / 10-07-2008 / 10:16:21 / Jan Vrany <vranyj1@fel.cvut.cz>"
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    93
! !
11
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
    94
1
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    95
!GraphicsDevice methodsFor:'accessing'!
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    96
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    97
displayId
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    98
    ^ displayId
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
    99
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   100
    "Created: / 04-07-2008 / 12:58:56 / Jan Vrany <vranyj1@fel.cvut.cz>"
2439fb18f3dc Initial commit.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
diff changeset
   101
! !
11
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   102
39
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   103
!GraphicsMedium methodsFor:'misc'!
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   104
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   105
cairoify
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   106
    "Change to use Cairo for rendering"
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   107
    
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   108
    gc := CairoGraphicsContext onDeviceGraphicsContext:gc.
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   109
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   110
    "Created: / 15-02-2016 / 21:24:41 / Jan Vrany <jan.vrany@fit.cvut.cz>"
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   111
! !
8af34937e1ec More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 38
diff changeset
   112
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   113
!Image methodsFor:'accessing'!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   114
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   115
bitsARGB32Into: buffer stride: stride fg: fg bg: bg
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   116
    | aOffset rOffset gOffset bOffset |
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   117
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   118
    UninterpretedBytes isBigEndian ifTrue:[
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   119
        aOffset := 1.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   120
        rOffset := 2.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   121
        gOffset := 3.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   122
        bOffset := 4.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   123
    ] ifFalse:[ 
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   124
        aOffset := 4.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   125
        rOffset := 3.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   126
        gOffset := 2.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   127
        bOffset := 1.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   128
    ].
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   129
    0 to: height - 1 do:[:y |  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   130
        | base |
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   131
        base := y * stride.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   132
        0 to: width - 1 do:[:x |  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   133
            | pixel color offset |    
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   134
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   135
            offset := base + (x * 4).
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   136
            (mask isNil or:[ (mask pixelAtX: x y:y) == 1 ]) ifTrue:[ 
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   137
                pixel := self pixelAtX: x y: y.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   138
                color := self colorFromValue: pixel.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   139
                buffer at: (offset + rOffset) put: color redByte.  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   140
                buffer at: (offset + gOffset) put: color greenByte.  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   141
                buffer at: (offset + bOffset) put: color blueByte.  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   142
                buffer at: (offset + aOffset) put: 16rFF.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   143
            ] ifFalse:[ 
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   144
                buffer at: (offset + rOffset) put: 0.  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   145
                buffer at: (offset + gOffset) put: 0.  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   146
                buffer at: (offset + bOffset) put: 0.  
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   147
                buffer at: (offset + aOffset) put: 0.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   148
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   149
            ].
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   150
        ]
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   151
    ]
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   152
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   153
    "Created: / 31-12-2014 / 13:08:46 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   154
    "Modified: / 01-01-2015 / 11:41:31 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   155
! !
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   156
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   157
!Image methodsFor:'inspecting'!
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   158
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   159
inspector2TabImageCairo
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   160
    <inspector2Tab>
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   161
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   162
    | view |
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   163
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   164
    view := PluggableView new.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   165
    view redrawAction:[
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   166
        | cr |
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   167
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   168
        cr := view cairo.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   169
        [
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   170
            self displayOn: cr
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   171
        ] ensure:[ 
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   172
            cr release.
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   173
        ].
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   174
    ].
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   175
    ^self newInspector2Tab
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   176
        label: 'Image (Cairo)';
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   177
        priority: 49;
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   178
        view: (HVScrollableView forView: view);
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   179
        yourself
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   180
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   181
    "Created: / 31-12-2014 / 12:01:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   182
! !
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   183
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   184
!SimpleView methodsFor:'accessing - cairo'!
2
c2f163833877 Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
   185
7
392289f92fab - DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   186
cairo
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   187
    "Return a Cairo context for drawing onto this view"           
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   188
    ^ gc cairo
2
c2f163833877 Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
   189
7
392289f92fab - DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   190
    "Created: / 10-09-2008 / 18:23:11 / Jan Vrany <vranyj1@fel.cvut.cz>"
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   191
    "Modified (comment): / 26-12-2014 / 23:29:09 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   192
! !
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   193
41
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   194
!SimpleView methodsFor:'misc'!
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   195
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   196
cairoify
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   197
    super cairoify.
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   198
    self subViews do:[:each | each cairoify ].
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   199
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   200
    "Created: / 18-02-2016 / 22:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>"
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   201
! !
17bc740cbc2a Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 39
diff changeset
   202
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   203
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   204
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   205
redrawWithCairo
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   206
    | cr |
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   207
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   208
    cr := self cairo.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   209
    [  
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   210
        self redrawWithCairo: cr
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   211
    ] ensure:[
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   212
        cr ~~ gc ifTrue:[ cr release ].
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   213
    ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   214
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   215
    "Created: / 27-12-2014 / 00:30:15 / Jan Vrany <jan.vrany@fit.cvut.cz>"
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   216
    "Modified: / 12-02-2016 / 16:38:36 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   217
! !
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   218
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   219
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   220
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   221
redrawWithCairo: cr x: x y: y width: w height: h
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   222
    cr rectangleX: x  y: y width: w height: h. 
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   223
    cr clip.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   224
    self redrawWithCairo: cr
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   225
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   226
    "Created: / 27-12-2014 / 00:29:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   227
! !
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   228
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   229
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   230
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   231
redrawWithCairoBuffered
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   232
    | cr |
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   233
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   234
    cr := self cairo.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   235
    [  
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   236
        self redrawWithCairoBuffered: cr
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   237
    ] ensure:[ 
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   238
        cr ~~ gc ifTrue:[ cr release ].
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   239
    ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   240
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   241
    "Created: / 27-12-2014 / 00:30:27 / Jan Vrany <jan.vrany@fit.cvut.cz>"
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   242
    "Modified: / 12-02-2016 / 16:38:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   243
! !
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   244
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   245
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   246
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   247
redrawWithCairoBuffered: view_cr
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   248
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   249
    | image_surface image_cr |
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   250
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   251
    [     
38
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   252
        image_surface := Cairo::Surface newImageWithFormatARGB32width:self width
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   253
                               height:self height.
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 28
diff changeset
   254
        image_cr := Cairo::GraphicsContext onSurface: image_surface. 
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   255
        self redrawWithCairo: image_cr.  
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   256
        view_cr setSourceSurface: image_surface. 
31
26070c1e480e GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 30
diff changeset
   257
        view_cr draw.
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   258
    ] ensure:[ 
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   259
        image_surface notNil ifTrue:[ image_surface release ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   260
        image_cr notNil ifTrue:[ image_cr release ]
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   261
    ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   262
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   263
    "Created: / 27-12-2014 / 00:13:29 / Jan Vrany <jan.vrany@fit.cvut.cz>"
38
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   264
    "Modified: / 14-02-2016 / 00:13:11 / Jan Vrany <jan.vrany@fit.cvut.cz>"
2
c2f163833877 Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
   265
! !
11
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   266
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   267
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   268
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   269
redrawWithCairoBuffered: view_cr x: x y: y width: w height: h
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   270
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   271
    | image_surface image_cr |
2
c2f163833877 Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
   272
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   273
    [     
38
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   274
        image_surface := Cairo::Surface newImageWithFormatARGB32width:self width
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   275
                               height:self height.
30
c8fe298c8cc7 GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 28
diff changeset
   276
        image_cr := Cairo::GraphicsContext onSurface: image_surface. 
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   277
        image_cr rectangleX: x  y: y width: w height: h. 
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   278
        image_cr clip.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   279
        self redrawWithCairo: image_cr x: x y: y width: w height: h.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   280
        view_cr rectangleX: x  y: y width: w height: h. 
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   281
        view_cr clip.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   282
        view_cr setSourceSurface: image_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
   283
        view_cr paint.
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   284
    ] ensure:[ 
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   285
        image_surface notNil ifTrue:[ image_surface release ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   286
        image_cr notNil ifTrue:[ image_cr release ]
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   287
    ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   288
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   289
    "Created: / 27-12-2014 / 00:28:37 / Jan Vrany <jan.vrany@fit.cvut.cz>"
38
9c94e463018a Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 36
diff changeset
   290
    "Modified: / 14-02-2016 / 00:12:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   291
! !
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   292
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   293
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   294
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   295
redrawWithCairoBufferedX: x y: y width: w height: h     
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   296
    | cr |
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   297
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   298
    cr := self cairo.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   299
    [  
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   300
        self redrawWithCairoBuffered: cr x: x y: y width: w height: h     
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   301
    ] ensure:[ 
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   302
        cr ~~ gc ifTrue:[ cr release ].
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   303
    ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   304
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   305
    "Created: / 27-12-2014 / 00:31:33 / Jan Vrany <jan.vrany@fit.cvut.cz>"
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   306
    "Modified: / 12-02-2016 / 16:38:10 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   307
! !
2
c2f163833877 Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 1
diff changeset
   308
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   309
!SimpleView methodsFor:'redrawing - cairo'!
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   310
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   311
redrawWithCairoX: x y: y width: w height: h     
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   312
    | cr |
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   313
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   314
    cr := self cairo.
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   315
    [  
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   316
        self redrawWithCairo: cr x: x y: y width: w height: h     
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   317
    ] ensure:[ 
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   318
        cr ~~ gc ifTrue:[ cr release ].
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   319
    ].
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   320
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   321
    "Created: / 27-12-2014 / 00:31:22 / Jan Vrany <jan.vrany@fit.cvut.cz>"
35
395689a88b32 Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 31
diff changeset
   322
    "Modified: / 12-02-2016 / 16:38:58 / Jan Vrany <jan.vrany@fit.cvut.cz>"
28
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   323
! !
1bd3d147cd77 Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 22
diff changeset
   324
11
fdc697f4f190 - Cairo::SvgVersion
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 8
diff changeset
   325
!stx_goodies_libcairo class methodsFor:'documentation'!
7
392289f92fab - DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 6
diff changeset
   326
21
34bf952f3f60 Fixes for recent Smalltalk/X
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 20
diff changeset
   327
extensionsVersion_HG
34bf952f3f60 Fixes for recent Smalltalk/X
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 20
diff changeset
   328
34bf952f3f60 Fixes for recent Smalltalk/X
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 20
diff changeset
   329
    ^ '$Changeset: <not expanded> $'
20
18a3e6b5f310 Added const modifier to FFI specs (required by recent STX)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents: 16
diff changeset
   330
! !