author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Tue, 16 Feb 2016 07:46:52 +0000 | |
changeset 39 | 8af34937e1ec |
parent 36 | 9b680e54aa94 |
child 40 | 28dfc583beb5 |
permissions | -rw-r--r-- |
1 | 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 |
"{ NameSpace: Smalltalk }" |
1 | 4 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
5 |
DeviceGraphicsContext subclass:#CairoGraphicsContext |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
6 |
instanceVariableNames:'cr crId' |
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
7 |
classVariableNames:'Lobby' |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
8 |
poolDictionaries:'Cairo::FontSlant Cairo::FontWeight Cairo::Format' |
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
|
9 |
category:'Cairo-Compatibility' |
1 | 10 |
! |
11 |
||
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
12 |
|
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
|
13 |
!CairoGraphicsContext class methodsFor:'initialization'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
14 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
15 |
initialize |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
16 |
"Invoked at system start or when the class is dynamically loaded." |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
17 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
18 |
"/ please change as required (and remove this comment) |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
19 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
20 |
Lobby := Registry new. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
21 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
22 |
"Modified: / 09-01-2015 / 15:08:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
23 |
! ! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
24 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
25 |
!CairoGraphicsContext class methodsFor:'instance creation'! |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
26 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
27 |
onDeviceGraphicsContext: dGC |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
28 |
| cGC | |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
29 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
30 |
cGC := self onDevice: dGC device. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
31 |
1 to: DeviceGraphicsContext instSize do:[:i | |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
32 |
cGC instVarAt: i put: (dGC instVarAt: i). |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
33 |
]. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
34 |
dGC gcId notNil ifTrue:[ |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
35 |
cGC createCR. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
36 |
]. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
37 |
cGC lineWidth: dGC lineWidth. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
38 |
cGC font: dGC font. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
39 |
^ cGC |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
40 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
41 |
"Created: / 15-02-2016 / 21:20:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
42 |
"Modified: / 16-02-2016 / 10:44:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
43 |
! ! |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
44 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
45 |
!CairoGraphicsContext class methodsFor:'accessing'! |
1 | 46 |
|
12 | 47 |
dllPath |
48 |
||
49 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
50 |
^ #( 'C:\Windows' 'C:\Windows\System32' "Wild guess, should not harm" ) |
|
51 |
]. |
|
52 |
||
53 |
OperatingSystem isUNIXlike ifTrue:[ |
|
54 |
OperatingSystem getSystemType == #linux ifTrue:[ |
|
55 |
| path | |
|
56 |
||
57 |
path := #( '/lib' '/usr/lib' '/usr/local/lib' ). |
|
58 |
(OperatingSystem getSystemInfo at:#machine) = 'x86_64' ifTrue:[ |
|
59 |
"If the machine is 64bit, prepend standard path for 32bit libs. |
|
20
18a3e6b5f310
Added const modifier to FFI specs (required by recent STX)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
17
diff
changeset
|
60 |
Leave standard paths at the end, as the system might be completely |
12 | 61 |
32bit but running on 64bit-capable CPU. |
62 |
||
63 |
CAVEAT: This is bit dangerous, as on 64bit OS, if ia32 libs are |
|
64 |
not installed byt 64bit sqlite libs are, then 64bit libs are found |
|
65 |
and when a function is called, segfault will occur!! |
|
66 |
||
67 |
Q: Is there a way how to figure out if the OS itself is 32bit, |
|
68 |
regardles on CPU?" |
|
69 |
path := #( '/lib32' '/usr/lib32' '/usr/local/lib32' ) , path. |
|
70 |
]. |
|
71 |
^path |
|
72 |
||
73 |
]. |
|
74 |
]. |
|
75 |
||
76 |
self error:'Unsupported operating system' |
|
77 |
||
78 |
" |
|
79 |
SqliteLibrary dllPath |
|
80 |
" |
|
81 |
||
82 |
"Created: / 31-08-2011 / 18:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
83 |
! |
|
84 |
||
1 | 85 |
libraryName |
86 |
||
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
87 |
OperatingSystem isUNIXlike ifTrue:[^'libcairo.so.2']. |
1 | 88 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
89 |
OperatingSystem isMSWINDOWSlike ifTrue:[^'cairo.dll']. |
12 | 90 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
91 |
self error:'Library name for host OS is not known' |
6
c1f387b40e3a
regenerated using newer version of CFace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
92 |
! |
c1f387b40e3a
regenerated using newer version of CFace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
93 |
|
26
7f07a8c31e6d
Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
23
diff
changeset
|
94 |
sizeof |
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
95 |
"Returns size of undelaying structure in bytes" |
6
c1f387b40e3a
regenerated using newer version of CFace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
96 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
97 |
^0 |
1 | 98 |
! ! |
99 |
||
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
|
100 |
!CairoGraphicsContext class methodsFor:'examples'! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
101 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
102 |
rectangleOnTranscript |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
103 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
104 |
" |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
105 |
Cairo::GraphicsContext rectangleOnTranscript |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
106 |
" |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
107 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
108 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
109 |
| gc | |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
110 |
gc := Transcript cairo. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
111 |
gc paint: Color black. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
112 |
gc moveToX: 30 y: 50. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
113 |
gc paint: (Color red alpha: 0.5). |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
114 |
gc rectangleX: 10 y: 15 width: 150 height: 60. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
115 |
gc fill. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
116 |
gc paint: (Color red alpha: 0.75). |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
117 |
gc rectangleX: 10 y: 15 width: 150 height: 60. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
118 |
gc stroke. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
119 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
120 |
"Created: / 23-04-2009 / 17:33:57 / Jan Vrany <vranyj1@fel.cvut.cz>" |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
121 |
! ! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
122 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
123 |
!CairoGraphicsContext methodsFor:'accessing'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
124 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
125 |
clippingBounds:aRectangleOrNil |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
126 |
"set the clipping rectangle for drawing (in logical coordinates); |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
127 |
a nil argument turn off clipping (i.e. whole view is drawable)" |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
128 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
129 |
^ super clippingBounds:aRectangleOrNil |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
130 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
131 |
"Created: / 15-02-2016 / 21:38:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
132 |
! |
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
133 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
134 |
font:aFont |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
135 |
| family slant psize weight | |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
136 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
137 |
super font: aFont. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
138 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
139 |
family := font family. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
140 |
slant := SymbolicFontSlantToCairoFontSlantMap at: (font style ? 'roman'). |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
141 |
weight := SymbolicFontFaceToCairoFontWeightMap at: (font face ? 'regular'). |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
142 |
psize := font pixelSize. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
143 |
psize isNil ifTrue:[ |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
144 |
psize := (self device verticalPixelPerInch / 72) * font size. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
145 |
]. |
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
146 |
|
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
|
147 |
cr font: family slant: slant weight: weight. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
148 |
cr fontSize: psize . |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
149 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
150 |
"Modified: / 16-02-2016 / 10:55:51 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
151 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
152 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
153 |
function:aFunctionSymbol |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
154 |
"set the drawing function" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
155 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
156 |
^ self shouldImplement |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
157 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
158 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
159 |
lineWidth: w |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
160 |
super lineWidth: w. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
161 |
cr lineWidth: (w == 0 ifTrue:[ 1 ] ifFalse:[ w ]). |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
162 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
163 |
"Created: / 17-06-2012 / 21:55:05 / 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:
36
diff
changeset
|
164 |
"Modified: / 16-02-2016 / 10:13:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
165 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
166 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
167 |
mask:aForm |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
168 |
"set the drawing mask" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
169 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
170 |
^ self shouldImplement |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
171 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
172 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
173 |
paint: aColor |
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
|
174 |
super paint: aColor. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
175 |
cr source: paint. |
1 | 176 |
|
177 |
"Created: / 10-07-2008 / 11:18:13 / Jan Vrany <vranyj1@fel.cvut.cz>" |
|
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
178 |
"Modified: / 23-04-2009 / 17:31:33 / Jan Vrany <vranyj1@fel.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
|
179 |
"Modified: / 13-02-2016 / 17:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 180 |
! ! |
181 |
||
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
|
182 |
!CairoGraphicsContext methodsFor:'accessing-transformation'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
183 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
184 |
transformation:aTransformation |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
185 |
"set the transformation" |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
186 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
187 |
super transformation: aTransformation. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
188 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
189 |
cr matrixReset. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
190 |
transformation notNil ifTrue:[ |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
191 |
cr |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
192 |
scale: transformation scale; |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
193 |
transform: transformation translation. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
194 |
] |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
195 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
196 |
"Created: / 01-01-2015 / 12:07: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:
36
diff
changeset
|
197 |
"Modified: / 16-02-2016 / 10:59:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
198 |
! ! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
199 |
|
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
|
200 |
!CairoGraphicsContext methodsFor:'basic drawing'! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
201 |
|
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
202 |
displayArcX:x y:y width:w height:h from:start angle:angle |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
203 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
204 |
| angle1 angle2 | |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
205 |
|
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
|
206 |
cr save. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
207 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
208 |
w ~~ h 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
|
209 |
self notYetImplemented |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
210 |
]. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
211 |
|
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
|
212 |
angle1 := (360 - start) . |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
213 |
angle2 := (360 - (start + angle)) \\ 360. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
214 |
|
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
|
215 |
(angle2 < angle1) 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
|
216 |
cr arcNegativeX: (x + (w / 2)) y: (y + (h / 2)) radius: w / 2 from: angle1 * (Float pi / 180) to: angle2 * (Float pi / 180). |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
217 |
] ifFalse:[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
218 |
cr arcNegativeX: (x + (w / 2)) y: (y + (h / 2)) radius: w / 2 from: angle2 * (Float pi / 180) to: angle1 * (Float pi / 180). |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
219 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
220 |
cr stroke. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
221 |
|
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
|
222 |
w ~~ h 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
|
223 |
self notYetImplemented |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
224 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
225 |
] ensure:[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
226 |
cr restore. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
227 |
] |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
228 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
229 |
"Modified: / 13-02-2016 / 20:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
230 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
231 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
232 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
233 |
"draw a line from x0/y0 to x1/y1" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
234 |
|
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
|
235 |
cr moveToX: x0 y: y0. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
236 |
cr lineToX: x1 y: y1. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
237 |
cr stroke. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
238 |
|
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
|
239 |
"Modified: / 13-02-2016 / 20:05:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17 | 240 |
! |
241 |
||
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
242 |
displayPolygon:points |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
243 |
"draw a polygon |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
244 |
- this could be recoded to draw using displayLine" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
245 |
|
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
|
246 |
cr moveToX: points first x asFloat y: points first y asFloat. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
247 |
2 to: points size do:[:i | |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
248 |
cr lineToX: (points at: i) x asFloat y: (points at: i) y asFloat |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
249 |
]. |
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
|
250 |
cr closePath. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
251 |
cr stroke. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
252 |
|
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
|
253 |
"Modified: / 13-02-2016 / 20:04:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
254 |
! |
17 | 255 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
256 |
displayRectangleX:x y:y width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
257 |
"draw a rectangle |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
258 |
- this could be recoded to draw using displayLine" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
259 |
|
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
|
260 |
cr rectangleX: x y: y width: w height: h. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
261 |
cr stroke. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
262 |
|
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
|
263 |
"Modified: / 13-02-2016 / 20:04:31 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
264 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
265 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
266 |
displayString:aStringArg from:index1Arg to:index2Arg x:x y:y opaque:opaqueArg maxWidth:maxWidth |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
267 |
"draw a substring at the coordinate x/y - draw foreground pixels in |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
268 |
paint-color and (if opaque is true), background pixels in bgPaint-color. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
269 |
If the transformation involves scaling, the font's point-size is scaled as appropriate. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
270 |
Assuming that device can only draw in device colors, we have to handle |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
271 |
the case where paint and/or bgPaint are dithered colors. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
272 |
maxWidth is the maximum width of the string in pixels or nil if unknown." |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
273 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
274 |
cr save. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
275 |
[ |
9b680e54aa94
Take a step 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 |
cr moveToX: x y: y. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
277 |
(index1Arg == 1 and:[ index2Arg == aStringArg size ]) ifTrue:[ |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
278 |
cr showText: aStringArg |
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
|
279 |
] ifFalse:[ |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
280 |
cr showText: (aStringArg copyFrom: index1Arg to: index2Arg). |
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
|
281 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
282 |
] ensure:[ |
9b680e54aa94
Take a step 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 |
cr restore. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
284 |
] |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
285 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
286 |
"Created: / 16-02-2016 / 10:51:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17 | 287 |
! ! |
288 |
||
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
|
289 |
!CairoGraphicsContext methodsFor:'basic filling'! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
290 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
291 |
fillArcX:x y:y width:w height:h from:start angle:angle |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
292 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
293 |
| angle1 angle2 | |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
294 |
|
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
|
295 |
cr save. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
296 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
297 |
w ~~ h 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
|
298 |
self notYetImplemented |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
299 |
]. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
300 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
301 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
302 |
angle1 := (360 - start) . |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
303 |
angle2 := (360 - (start + angle)) \\ 360. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
304 |
|
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
305 |
cr moveToX: (x + (w / 2)) y: (y + (h / 2)). |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
306 |
|
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
|
307 |
(angle2 < angle1) ifTrue:[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
308 |
cr arcNegativeX: (x + (w / 2)) y: (y + (h / 2)) radius: w / 2 from: angle1 * (Float pi / 180) to: angle2 * (Float pi / 180). |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
309 |
] ifFalse:[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
310 |
cr arcNegativeX: (x + (w / 2)) y: (y + (h / 2)) radius: w / 2 from: angle2 * (Float pi / 180) to: angle1 * (Float pi / 180). |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
311 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
312 |
cr closePath. |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
313 |
|
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
|
314 |
cr strokeAndPreserve. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
315 |
cr fill. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
316 |
|
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
|
317 |
w ~~ h 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
|
318 |
self notYetImplemented |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
319 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
320 |
] ensure:[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
321 |
cr restore. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
322 |
] |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
323 |
|
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
|
324 |
"Modified: / 13-02-2016 / 20:03:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
325 |
! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
326 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
327 |
fillPolygon:points |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
328 |
"fill a polygon with current paint color" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
329 |
|
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
|
330 |
cr moveToX: points first x asFloat y: points first y asFloat. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
331 |
2 to: points size do:[:i | |
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
|
332 |
cr lineToX: (points at: i) x asFloat y: (points at: i) y asFloat |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
333 |
]. |
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
|
334 |
cr closePath. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
335 |
cr strokeAndPreserve. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
336 |
cr fill. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
337 |
|
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
|
338 |
"Modified: / 13-02-2016 / 20:01:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
339 |
! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
340 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
341 |
fillRectangleX:x y:y width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
342 |
"fill a rectangle with current paint color" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
343 |
|
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
|
344 |
cr rectangleX: x y: y width: w height: h. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
345 |
cr strokeAndPreserve. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
346 |
cr fill. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
347 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
348 |
"/ cr save. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
349 |
"/ cr rectangleX: x y: y width: w height: h. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
350 |
"/ cr sourceR: 1 G: 0 B: 0. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
351 |
"/ cr lineWidth: 3. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
352 |
"/ cr stroke. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
353 |
"/ cr restore. |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
354 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
355 |
"Modified: / 16-02-2016 / 07:58:46 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
356 |
! ! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
357 |
|
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
|
358 |
!CairoGraphicsContext methodsFor:'drawing'! |
17 | 359 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
360 |
displayForm:aFormOrImage x:x y:y |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
361 |
"draw a form (or image) at x/y; |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
362 |
if the form has depth 1, 1's in the form are |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
363 |
drawn in current paint color, 0's are ignored. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
364 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
1 | 365 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
366 |
| image width height stride data image_surface | |
17 | 367 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
368 |
^ super displayForm:aFormOrImage x:x y:y. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
369 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
370 |
image := aFormOrImage asImage. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
371 |
width := image width. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
372 |
height := image height. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
373 |
stride := Cairo::CPrimitives cairo_format_stride_for_width: CAIRO_FORMAT_ARGB32 _: width. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
374 |
data := ExternalBytes basicNew allocateBytes: stride * height clear: false. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
375 |
[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
376 |
image bitsARGB32Into: data stride: stride fg: self paint bg: self backgroundPaint. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
377 |
image_surface := Cairo::CPrimitives cairo_image_surface_create_for_data: data _: CAIRO_FORMAT_ARGB32 _: width _: height _: stride. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
378 |
Cairo::CPrimitives cairo_set_source_surface: crId _: image_surface _: x asFloat _: y asFloat. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
379 |
Cairo::CPrimitives cairo_paint: crId. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
380 |
] ensure:[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
381 |
data finalize. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
382 |
image_surface release. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
383 |
]. |
1 | 384 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
385 |
"Created: / 31-12-2014 / 12:08:08 / 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:
36
diff
changeset
|
386 |
"Modified: / 15-02-2016 / 21:32:16 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
387 |
! |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
388 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
389 |
displayRoundRectangleX:x y:y width:w height:h wCorner:wCorn hCorner:hCorn |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
390 |
| r pi | |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
391 |
wCorn ~~ hCorn ifTrue:[ |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
392 |
self notYetImplemented. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
393 |
]. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
394 |
r := wCorn / 2. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
395 |
pi := Float pi. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
396 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
397 |
"/ top-left arc |
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
|
398 |
cr arcX: x + r y: y + r radius: r from: pi to: (3/2) * pi. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
399 |
"/ top-right atc |
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
|
400 |
cr arcX: x + w - r y: y + r radius: r from: (3/2) * pi to: 0.0. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
401 |
"/ bottom-right atc |
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
|
402 |
cr arcX: x + w - r y: y + h - r radius: r from: 0.0 to: (1/2) * pi. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
403 |
"/ bottom-left atc |
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
|
404 |
cr arcX: x + r y: y + h - r radius: r from: (1/2) * pi to: pi. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
405 |
cr closePath. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
406 |
cr stroke. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
407 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
408 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
409 |
|v| |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
410 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
411 |
(v := View new) extent:200@200; openAndWait. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
412 |
v cairo |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
413 |
lineWidth: 5; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
414 |
displayRoundRectangleX:10 y:10 width:100 height:100 wCorner:20 hCorner:20; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
415 |
release |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
416 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
417 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
418 |
"Created: / 07-01-2015 / 20:41:47 / 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
|
419 |
"Modified: / 13-02-2016 / 20:00:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
420 |
! ! |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
421 |
|
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
|
422 |
!CairoGraphicsContext methodsFor:'filling'! |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
423 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
424 |
fillRoundRectangleX:x y:y width:w height:h wCorner:wCorn hCorner:hCorn |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
425 |
| r pi | |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
426 |
wCorn ~~ hCorn ifTrue:[ |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
427 |
self notYetImplemented. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
428 |
]. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
429 |
r := wCorn / 2. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
430 |
pi := Float pi. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
431 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
432 |
"/ top-left arc |
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
|
433 |
cr arcX: x + r y: y + r radius: r from: pi to: (3/2) * pi. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
434 |
"/ top-right atc |
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
|
435 |
cr arcX: x + w - r y: y + r radius: r from: (3/2) * pi to: 0.0. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
436 |
"/ bottom-right atc |
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
|
437 |
cr arcX: x + w - r y: y + h - r radius: r from: 0.0 to: (1/2) * pi. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
438 |
"/ bottom-left atc |
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
|
439 |
cr arcX: x + r y: y + h - r radius: r from: (1/2) * pi to: pi. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
440 |
cr closePath. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
441 |
cr fill. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
442 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
443 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
444 |
|v| |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
445 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
446 |
(v := View new) extent:200@200; openAndWait. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
447 |
v cairo |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
448 |
lineWidth: 5; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
449 |
displayRoundRectangleX:10 y:10 width:100 height:100 wCorner:20 hCorner:20; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
450 |
release |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
451 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
452 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
453 |
"Created: / 07-01-2015 / 21:33: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
|
454 |
"Modified: / 13-02-2016 / 20:00:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 455 |
! ! |
456 |
||
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
|
457 |
!CairoGraphicsContext methodsFor:'finalization'! |
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
458 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
459 |
executor |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
460 |
^ super executor |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
461 |
"/^ self shallowCopy |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
462 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
463 |
"Created: / 12-02-2016 / 17:04:29 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
464 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
465 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
466 |
finalization |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
467 |
self destroy |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
468 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
469 |
"Created: / 09-01-2015 / 10:20:47 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
470 |
! |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
471 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
472 |
finalizationLobby |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
473 |
"answer a Registry used for finalization. |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
474 |
Use a generic Registry for any object. |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
475 |
Subclasses using their own Registry should redefine this" |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
476 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
477 |
^ Lobby |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
478 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
479 |
"Created: / 09-01-2015 / 10:20:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
480 |
! ! |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
481 |
|
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
|
482 |
!CairoGraphicsContext methodsFor:'initialization & release'! |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
483 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
484 |
createCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
485 |
"Physically create a Cairo graphics context" |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
486 |
|
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
|
487 |
cr := self cairo. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
488 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
489 |
"Created: / 12-02-2016 / 16:59:03 / 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
|
490 |
"Modified: / 13-02-2016 / 19:56:36 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
491 |
! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
492 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
493 |
createGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
494 |
"physically create a device GC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
495 |
Since we do not need a gc-object for the drawable until something is |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
496 |
really drawn, none is created up to the first draw. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
497 |
This method is sent, when the first drawing happens" |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
498 |
super createGC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
499 |
self createCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
500 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
501 |
"Created: / 12-02-2016 / 16:58:30 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
502 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
503 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
504 |
destroyCR |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
505 |
"Tell Cairo library to destroy the corresponding C object. |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
506 |
Remember that object is physically destroyed only if internal |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
507 |
refcounter goes to zero. However, after calling destroy, |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
508 |
this instance should be treated as invalid." |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
509 |
|
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
|
510 |
cr 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
|
511 |
| surface | |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
512 |
|
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
513 |
surface := cr surface. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
514 |
cr release. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
515 |
surface release. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
516 |
]. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
517 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
518 |
"Created: / 12-02-2016 / 16:59:40 / 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
|
519 |
"Modified: / 13-02-2016 / 19:59:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
520 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
521 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
522 |
destroyGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
523 |
self destroyCR. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
524 |
super destroyGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
525 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
526 |
"Created: / 12-02-2016 / 17:01:01 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
527 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
528 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
529 |
releaseCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
530 |
self destroyCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
531 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
532 |
"Created: / 12-02-2016 / 17:02:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
533 |
! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
534 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
535 |
releaseGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
536 |
"destroy the associated device GC resource - can be done to be nice to the |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
537 |
display if you know that you are done with a drawable." |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
538 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
539 |
self releaseCR. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
540 |
super releaseGC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
541 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
542 |
"Created: / 12-02-2016 / 17:03:21 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
543 |
! ! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
544 |
|
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
|
545 |
!CairoGraphicsContext class methodsFor:'documentation'! |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
546 |
|
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
547 |
version |
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
548 |
^'$Id$' |
11 | 549 |
! |
550 |
||
23
38ee47dbd976
Added version_HG to make Mercurial happy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
551 |
version_HG |
38ee47dbd976
Added version_HG to make Mercurial happy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
552 |
^ '$Changeset: <not expanded> $' |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
553 |
! ! |
26
7f07a8c31e6d
Fixed flickring of Cairo::ClockView by rendering into an off-screen image.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
23
diff
changeset
|
554 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
555 |
|
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
|
556 |
CairoGraphicsContext initialize! |