author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sun, 28 Feb 2016 14:53:56 +0000 | |
changeset 51 | 5293f2b851ab |
parent 50 | 239120c68187 |
child 57 | 2c9a342e1f2a |
permissions | -rw-r--r-- |
11 | 1 |
"{ Package: 'stx:goodies/libcairo' }"! |
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 |
| 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
|
8 |
|
9b680e54aa94
Take a step 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 |
cr := Cairo::GraphicsContext onSurface: self cairoSurface. |
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
10 |
^ cr. |
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
|
11 |
|
9b680e54aa94
Take a step 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 |
"Created: / 26-12-2014 / 23:28:49 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
13 |
"Modified: / 25-02-2016 / 11:05:41 / 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
|
14 |
! ! |
9b680e54aa94
Take a step 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 |
|
38
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
16 |
!DeviceGraphicsContext methodsFor:'accessing'! |
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
17 |
|
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
18 |
cairoSurface |
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
19 |
| surface | |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
20 |
|
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
21 |
device isX11Platform ifTrue:[ |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
22 |
| view width height | |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
23 |
|
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
24 |
drawableType == #window ifTrue:[ |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
25 |
view := device viewFromId:drawableId. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
26 |
width := view width. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
27 |
height := view height. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
28 |
] ifFalse:[ |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
29 |
| extent | |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
30 |
|
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
31 |
extent := (device getGeometryOf: drawableId) at: #extent. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
32 |
width := extent x. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
33 |
height := extent y. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
34 |
]. |
38
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
35 |
|
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
36 |
surface := Cairo::Surface newXlibWithDisplay: device displayId |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
37 |
drawable: drawableId address |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
38 |
visual: device queryDefaultVisual |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
39 |
width: width |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
40 |
height: height. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
41 |
surface setView: view. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
42 |
^ surface |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
43 |
]. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
44 |
device isWindowsPlatform ifTrue:[ |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
45 |
gcId isNil ifTrue:[ |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
46 |
self initGC |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
47 |
]. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
48 |
surface := Cairo::Surface newWin32WithHDC: (device hdcForGC: gcId). |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
49 |
^ surface |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
50 |
]. |
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
51 |
self error: '(Yet) unsupported device type' |
38
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
52 |
|
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
53 |
"Modified: / 25-02-2016 / 11:13:51 / 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
|
54 |
! ! |
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
55 |
|
1 | 56 |
!DeviceGraphicsContext methodsFor:'cairo support'! |
57 |
||
58 |
drawableId |
|
59 |
||
60 |
^drawableId |
|
61 |
||
62 |
"Created: / 10-07-2008 / 10:20:04 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
63 |
! ! |
|
11 | 64 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
65 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
66 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
67 |
displayDeviceLineFromX:x1 y:y1 toX:x2 y:y2 |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
68 |
"draw a line in device coordinates" |
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 |
|sav| |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
71 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
72 |
sav := transformation. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
73 |
self transformation: nil. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
74 |
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
|
75 |
self transformation: sav |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
76 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
77 |
"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
|
78 |
! ! |
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 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
81 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
82 |
displayDeviceRectangleX:x y:y width:w height:h |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
83 |
"draw a rectangle in device coordinates" |
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 |
|sav| |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
86 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
87 |
sav := transformation. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
88 |
self transformation: nil. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
89 |
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
|
90 |
self transformation: sav |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
91 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
92 |
"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
|
93 |
! ! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
94 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
95 |
!GraphicsContext methodsFor:'drawing in device coordinates'! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
96 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
97 |
fillDeviceRectangleX:x y:y width:w height:h |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
98 |
"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
|
99 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
100 |
|sav| |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
101 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
102 |
sav := transformation. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
103 |
self transformation: nil. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
104 |
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
|
105 |
self transformation: sav |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
106 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
107 |
"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
|
108 |
! ! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
109 |
|
1 | 110 |
!GraphicsDevice methodsFor:'cairo support'! |
111 |
||
112 |
cairoSurfaceFor: view |
|
113 |
||
114 |
self error:'Graphics device not supported' |
|
115 |
||
116 |
"Created: / 10-07-2008 / 10:16:21 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
117 |
! ! |
|
11 | 118 |
|
1 | 119 |
!GraphicsDevice methodsFor:'accessing'! |
120 |
||
121 |
displayId |
|
122 |
^ displayId |
|
123 |
||
124 |
"Created: / 04-07-2008 / 12:58:56 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
125 |
! ! |
|
11 | 126 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
127 |
!GraphicsMedium methodsFor:'misc'! |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
128 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
129 |
cairoify |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
130 |
"Change to use Cairo for rendering" |
47
061f23d91383
CairoScaledFont: fixed drawing of CairoScaledFont on plain old DeviceGraphicsContext.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
131 |
gc class == CairoGraphicsContext ifFalse:[ |
061f23d91383
CairoScaledFont: fixed drawing of CairoScaledFont on plain old DeviceGraphicsContext.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
132 |
gc := CairoGraphicsContext onDeviceGraphicsContext:gc. |
061f23d91383
CairoScaledFont: fixed drawing of CairoScaledFont on plain old DeviceGraphicsContext.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
133 |
]. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
134 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
135 |
"Created: / 15-02-2016 / 21:24:41 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
47
061f23d91383
CairoScaledFont: fixed drawing of CairoScaledFont on plain old DeviceGraphicsContext.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
136 |
"Modified: / 24-02-2016 / 17:17:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
137 |
! ! |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
38
diff
changeset
|
138 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
139 |
!Image methodsFor:'inspecting'! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
140 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
141 |
inspector2TabImageCairo |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
142 |
<inspector2Tab> |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
143 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
144 |
| view | |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
145 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
146 |
view := PluggableView new. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
147 |
view redrawAction:[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
148 |
| cr | |
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 |
cr := view cairo. |
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 |
self displayOn: cr |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
153 |
] ensure:[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
154 |
cr release. |
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 |
^self newInspector2Tab |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
158 |
label: 'Image (Cairo)'; |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
159 |
priority: 49; |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
160 |
view: (HVScrollableView forView: view); |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
161 |
yourself |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
162 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
163 |
"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
|
164 |
! ! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
165 |
|
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
166 |
!SimpleView methodsFor:'accessing - cairo'! |
2
c2f163833877
Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
167 |
|
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
168 |
cairo |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
169 |
"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
|
170 |
^ gc cairo |
2
c2f163833877
Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
171 |
|
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
172 |
"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
|
173 |
"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
|
174 |
! ! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
175 |
|
50
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
176 |
!SimpleView methodsFor:'accessing - cairo'! |
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
177 |
|
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
178 |
cairoSurface |
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
179 |
"Return a Cairo Surface representing the receiver." |
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
180 |
^ gc cairoSurface |
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
181 |
|
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
182 |
"Created: / 26-02-2016 / 22:24:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
183 |
! ! |
239120c68187
Added classes with examples and example viewers
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
48
diff
changeset
|
184 |
|
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
185 |
!SimpleView methodsFor:'misc'! |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
186 |
|
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
187 |
cairoify |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
188 |
super cairoify. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
189 |
self subViews do:[:each | each cairoify ]. |
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
190 |
self invalidate. |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
191 |
|
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
192 |
"Created: / 18-02-2016 / 22:43:04 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
48
2a66aee0a9b3
Added support for creating surfaces for X11 pixmaps
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
47
diff
changeset
|
193 |
"Modified: / 25-02-2016 / 11:12:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
194 |
! ! |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
195 |
|
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
196 |
!SimpleView methodsFor:'redrawing - cairo'! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
197 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
198 |
redrawWithCairo |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
199 |
| cr | |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
200 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
201 |
cr := self cairo. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
202 |
[ |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
203 |
self redrawWithCairo: cr |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
204 |
] ensure:[ |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
205 |
cr ~~ gc ifTrue:[ cr release ]. |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
206 |
]. |
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 |
"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
|
209 |
"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
|
210 |
! ! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
211 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
212 |
!SimpleView methodsFor:'redrawing - cairo'! |
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 |
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
|
215 |
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
|
216 |
cr clip. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
217 |
self redrawWithCairo: cr |
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 |
"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
|
220 |
! ! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
221 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
222 |
!SimpleView methodsFor:'redrawing - cairo'! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
223 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
224 |
redrawWithCairoBuffered |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
225 |
| cr | |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
226 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
227 |
cr := self cairo. |
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 |
self redrawWithCairoBuffered: cr |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
230 |
] ensure:[ |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
231 |
cr ~~ gc ifTrue:[ cr release ]. |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
232 |
]. |
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 |
"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
|
235 |
"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
|
236 |
! ! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
237 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
238 |
!SimpleView methodsFor:'redrawing - cairo'! |
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 |
redrawWithCairoBuffered: view_cr |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
241 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
242 |
| image_surface image_cr | |
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 |
[ |
51
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
245 |
image_surface := Cairo::Surface newImageWithFormat: Cairo::Format CAIRO_FORMAT_ARGB32 width:self width |
38
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
246 |
height:self height. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
28
diff
changeset
|
247 |
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
|
248 |
self redrawWithCairo: image_cr. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
249 |
view_cr setSourceSurface: image_surface. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
250 |
view_cr draw. |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
251 |
] ensure:[ |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
252 |
image_surface notNil ifTrue:[ image_surface release ]. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
253 |
image_cr notNil ifTrue:[ image_cr release ] |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
254 |
]. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
255 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
256 |
"Created: / 27-12-2014 / 00:13:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
51
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
257 |
"Modified: / 27-02-2016 / 16:01:29 / 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
|
258 |
! ! |
11 | 259 |
|
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
260 |
!SimpleView methodsFor:'redrawing - cairo'! |
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 |
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
|
263 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
264 |
| image_surface image_cr | |
2
c2f163833877
Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
265 |
|
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
266 |
[ |
51
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
267 |
image_surface := Cairo::Surface newImageWithFormat: Cairo::Format CAIRO_FORMAT_ARGB32 width:self width |
38
9c94e463018a
Split classes for individual surfaces
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
268 |
height:self height. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
28
diff
changeset
|
269 |
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
|
270 |
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
|
271 |
image_cr clip. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
272 |
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
|
273 |
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
|
274 |
view_cr clip. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
275 |
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
|
276 |
view_cr paint. |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
277 |
] ensure:[ |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
278 |
image_surface notNil ifTrue:[ image_surface release ]. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
279 |
image_cr notNil ifTrue:[ image_cr release ] |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
280 |
]. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
281 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
282 |
"Created: / 27-12-2014 / 00:28:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
51
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
283 |
"Modified: / 27-02-2016 / 16:01:42 / 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
|
284 |
! ! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
285 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
286 |
!SimpleView methodsFor:'redrawing - cairo'! |
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 |
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
|
289 |
| cr | |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
290 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
291 |
cr := self cairo. |
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 |
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
|
294 |
] ensure:[ |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
295 |
cr ~~ gc ifTrue:[ cr release ]. |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
296 |
]. |
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 |
"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
|
299 |
"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
|
300 |
! ! |
2
c2f163833877
Xlib surfaces are dependents of associated view
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
1
diff
changeset
|
301 |
|
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
302 |
!SimpleView methodsFor:'redrawing - cairo'! |
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 |
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
|
305 |
| cr | |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
306 |
|
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
307 |
cr := self cairo. |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
308 |
[ |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
309 |
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
|
310 |
] ensure:[ |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
311 |
cr ~~ gc ifTrue:[ cr release ]. |
28
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
312 |
]. |
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 |
"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
|
315 |
"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
|
316 |
! ! |
1bd3d147cd77
Added utility methods to SimpleView...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
22
diff
changeset
|
317 |
|
51
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
318 |
!stx_libbasic class methodsFor:'documentation'! |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
319 |
|
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
320 |
version_HG |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
321 |
^ '$Changeset: <not expanded> $' |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
322 |
! ! |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
323 |
|
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
324 |
!stx_libview2 class methodsFor:'documentation'! |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
325 |
|
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
326 |
version_HG |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
327 |
^ '$Changeset: <not expanded> $' |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
328 |
! ! |
5293f2b851ab
CairGraphicsContext: added support for displaying images with alpha channel
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
50
diff
changeset
|
329 |
|
11 | 330 |
!stx_goodies_libcairo class methodsFor:'documentation'! |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
331 |
|
21
34bf952f3f60
Fixes for recent Smalltalk/X
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
332 |
extensionsVersion_HG |
34bf952f3f60
Fixes for recent Smalltalk/X
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
333 |
|
34bf952f3f60
Fixes for recent Smalltalk/X
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
334 |
^ '$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
|
335 |
! ! |