author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Sat, 13 Feb 2016 17:10:25 +0000 | |
changeset 36 | 9b680e54aa94 |
parent 35 | Cairo__GraphicsContext.st@395689a88b32 |
child 39 | 8af34937e1ec |
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 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
25 |
!CairoGraphicsContext class methodsFor:'accessing'! |
1 | 26 |
|
12 | 27 |
dllPath |
28 |
||
29 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
30 |
^ #( 'C:\Windows' 'C:\Windows\System32' "Wild guess, should not harm" ) |
|
31 |
]. |
|
32 |
||
33 |
OperatingSystem isUNIXlike ifTrue:[ |
|
34 |
OperatingSystem getSystemType == #linux ifTrue:[ |
|
35 |
| path | |
|
36 |
||
37 |
path := #( '/lib' '/usr/lib' '/usr/local/lib' ). |
|
38 |
(OperatingSystem getSystemInfo at:#machine) = 'x86_64' ifTrue:[ |
|
39 |
"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
|
40 |
Leave standard paths at the end, as the system might be completely |
12 | 41 |
32bit but running on 64bit-capable CPU. |
42 |
||
43 |
CAVEAT: This is bit dangerous, as on 64bit OS, if ia32 libs are |
|
44 |
not installed byt 64bit sqlite libs are, then 64bit libs are found |
|
45 |
and when a function is called, segfault will occur!! |
|
46 |
||
47 |
Q: Is there a way how to figure out if the OS itself is 32bit, |
|
48 |
regardles on CPU?" |
|
49 |
path := #( '/lib32' '/usr/lib32' '/usr/local/lib32' ) , path. |
|
50 |
]. |
|
51 |
^path |
|
52 |
||
53 |
]. |
|
54 |
]. |
|
55 |
||
56 |
self error:'Unsupported operating system' |
|
57 |
||
58 |
" |
|
59 |
SqliteLibrary dllPath |
|
60 |
" |
|
61 |
||
62 |
"Created: / 31-08-2011 / 18:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
63 |
! |
|
64 |
||
1 | 65 |
libraryName |
66 |
||
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
67 |
OperatingSystem isUNIXlike ifTrue:[^'libcairo.so.2']. |
1 | 68 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
69 |
OperatingSystem isMSWINDOWSlike ifTrue:[^'cairo.dll']. |
12 | 70 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
71 |
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
|
72 |
! |
c1f387b40e3a
regenerated using newer version of CFace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
73 |
|
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
|
74 |
sizeof |
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
75 |
"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
|
76 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
77 |
^0 |
1 | 78 |
! ! |
79 |
||
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
|
80 |
!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
|
81 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
82 |
rectangleOnTranscript |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
83 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
84 |
" |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
85 |
Cairo::GraphicsContext rectangleOnTranscript |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
86 |
" |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
87 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
88 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
89 |
| gc | |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
90 |
gc := Transcript cairo. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
91 |
gc paint: Color black. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
92 |
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
|
93 |
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
|
94 |
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
|
95 |
gc fill. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
96 |
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
|
97 |
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
|
98 |
gc stroke. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
99 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
100 |
"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
|
101 |
! ! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
102 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
103 |
!CairoGraphicsContext methodsFor:'accessing'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
104 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
105 |
font:aFont |
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
106 |
| dfont family slant psize weight | |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
107 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
108 |
dfont := aFont onDevice: device. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
109 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
110 |
family := dfont family. |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
111 |
slant := SymbolicFontSlantToCairoFontSlantMap at: (dfont style ? 'roman'). |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
112 |
weight := SymbolicFontFaceToCairoFontWeightMap at: (dfont face ? 'regular'). |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
113 |
|
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
|
114 |
cr font: family slant: slant weight: weight. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
115 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
116 |
psize := dfont pixelSize. |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
117 |
psize isNil ifTrue:[ |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
118 |
psize := (self device verticalPixelPerInch / 72) * dfont size. |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
119 |
]. |
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
|
120 |
cr fontSize: psize . |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
121 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
122 |
font := ScaledFont family: dfont family face: dfont face style: dfont style size: dfont size. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
123 |
font handle: (CPrimitives cairo_get_scaled_font: crId). |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
124 |
|
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
|
125 |
"Modified: / 13-02-2016 / 21:17:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
126 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
127 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
128 |
function:aFunctionSymbol |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
129 |
"set the drawing function" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
130 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
131 |
^ self shouldImplement |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
132 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
133 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
134 |
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
|
135 |
super lineWidth: w. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
136 |
cr lineWidth: w. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
137 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
138 |
"Created: / 17-06-2012 / 21:55:05 / 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
|
139 |
"Modified: / 13-02-2016 / 17:38:55 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
140 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
141 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
142 |
mask:aForm |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
143 |
"set the drawing mask" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
144 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
145 |
^ self shouldImplement |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
146 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
147 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
148 |
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
|
149 |
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
|
150 |
cr source: paint. |
1 | 151 |
|
152 |
"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
|
153 |
"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
|
154 |
"Modified: / 13-02-2016 / 17:39:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 155 |
! ! |
156 |
||
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
|
157 |
!CairoGraphicsContext methodsFor:'accessing-transformation'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
158 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
159 |
transformation:aTransformation |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
160 |
"set the transformation" |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
161 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
162 |
super transformation: aTransformation. |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
163 |
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
|
164 |
matrixReset; |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
165 |
scale: transformation scale; |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
166 |
transform: transformation translation. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
167 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
168 |
"Created: / 01-01-2015 / 12:07:07 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
169 |
"Modified: / 13-02-2016 / 19:55: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
|
170 |
! ! |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
171 |
|
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
|
172 |
!CairoGraphicsContext methodsFor:'basic drawing'! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
173 |
|
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
174 |
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
|
175 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
176 |
| angle1 angle2 | |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
177 |
|
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
|
178 |
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
|
179 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
180 |
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
|
181 |
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
|
182 |
]. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
183 |
|
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
|
184 |
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
|
185 |
angle2 := (360 - (start + angle)) \\ 360. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
186 |
|
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
|
187 |
(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
|
188 |
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
|
189 |
] 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
|
190 |
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
|
191 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
192 |
cr stroke. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
193 |
|
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
|
194 |
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
|
195 |
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
|
196 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
197 |
] 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
|
198 |
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
|
199 |
] |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
200 |
|
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
|
201 |
"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
|
202 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
203 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
204 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
205 |
"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
|
206 |
|
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
|
207 |
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
|
208 |
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
|
209 |
cr stroke. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
210 |
|
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
|
211 |
"Modified: / 13-02-2016 / 20:05:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17 | 212 |
! |
213 |
||
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
214 |
displayOpaqueString:aString from:index1 to:index2 x:x y:y maxWitdh:maxWidth |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
215 |
"draw part of a string with both fg and bg at x/y in current font" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
216 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
217 |
^ self shouldImplement |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
218 |
! |
17 | 219 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
220 |
displayPolygon:points |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
221 |
"draw a polygon |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
222 |
- this could be recoded to draw using displayLine" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
223 |
|
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
|
224 |
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
|
225 |
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
|
226 |
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
|
227 |
]. |
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
|
228 |
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
|
229 |
cr stroke. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
230 |
|
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
|
231 |
"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
|
232 |
! |
17 | 233 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
234 |
displayRectangleX:x y:y width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
235 |
"draw a rectangle |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
236 |
- this could be recoded to draw using displayLine" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
237 |
|
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
|
238 |
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
|
239 |
cr stroke. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
240 |
|
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
|
241 |
"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
|
242 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
243 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
244 |
displayString:aString from:index1 to:index2 x:x y:y |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
245 |
"draw part of a string with fg at x/y in current font" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
246 |
|
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
|
247 |
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
|
248 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
249 |
cr moveToX: x y: y. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
250 |
(index1 == 1 and:[ index2 == aString size ]) 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
|
251 |
cr showText: aString |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
252 |
] 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
|
253 |
cr showText: (aString copyFrom: index1 to: index2). |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
254 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
255 |
] 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
|
256 |
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
|
257 |
] |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
258 |
|
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
|
259 |
"Modified: / 13-02-2016 / 20:04:22 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17 | 260 |
! ! |
261 |
||
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
|
262 |
!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
|
263 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
264 |
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
|
265 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
266 |
| angle1 angle2 | |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
267 |
|
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
|
268 |
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
|
269 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
270 |
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
|
271 |
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
|
272 |
]. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
273 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
274 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
275 |
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
|
276 |
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
|
277 |
|
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
278 |
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
|
279 |
|
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
|
280 |
(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
|
281 |
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
|
282 |
] 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
|
283 |
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
|
284 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
285 |
cr closePath. |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
286 |
|
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
|
287 |
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
|
288 |
cr fill. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
289 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
290 |
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
|
291 |
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
|
292 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
293 |
] 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
|
294 |
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
|
295 |
] |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
296 |
|
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
|
297 |
"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
|
298 |
! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
299 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
300 |
fillPolygon:points |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
301 |
"fill a polygon with current paint color" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
302 |
|
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
|
303 |
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
|
304 |
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
|
305 |
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
|
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 |
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
|
308 |
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
|
309 |
cr fill. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
310 |
|
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
|
311 |
"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
|
312 |
! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
313 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
314 |
fillRectangleX:x y:y width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
315 |
"fill a rectangle with current paint color" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
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 |
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
|
318 |
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
|
319 |
cr fill. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
320 |
|
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
|
321 |
"Modified: / 13-02-2016 / 20:01:14 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
322 |
! ! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
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 |
!CairoGraphicsContext methodsFor:'bit blitting'! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
325 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
326 |
copyFrom:aGC x:srcX y:srcY toX:dstX y:dstY width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
327 |
"copy from a drawable - maybe self" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
328 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
329 |
^ self shouldImplement |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
330 |
! ! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
331 |
|
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 |
!CairoGraphicsContext methodsFor:'drawing'! |
17 | 333 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
334 |
displayForm:aFormOrImage x:x y:y |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
335 |
"draw a form (or image) at x/y; |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
336 |
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
|
337 |
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
|
338 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
1 | 339 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
340 |
| image width height stride data image_surface | |
17 | 341 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
342 |
image := aFormOrImage asImage. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
343 |
width := image width. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
344 |
height := image height. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
345 |
stride := CPrimitives cairo_format_stride_for_width: CAIRO_FORMAT_ARGB32 _: width. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
346 |
data := ExternalBytes basicNew allocateBytes: stride * height clear: false. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
347 |
[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
348 |
image bitsARGB32Into: data stride: stride fg: self paint bg: self backgroundPaint. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
349 |
image_surface := CPrimitives cairo_image_surface_create_for_data: data _: CAIRO_FORMAT_ARGB32 _: width _: height _: stride. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
350 |
CPrimitives cairo_set_source_surface: crId _: image_surface _: x asFloat _: y asFloat. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
351 |
CPrimitives cairo_paint: crId. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
352 |
] ensure:[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
353 |
data finalize. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
354 |
image_surface release. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
355 |
]. |
1 | 356 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
357 |
"Created: / 31-12-2014 / 12:08:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
358 |
"Modified: / 01-01-2015 / 02:48:32 / 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
|
359 |
! |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
360 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
361 |
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
|
362 |
| r pi | |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
363 |
wCorn ~~ hCorn ifTrue:[ |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
364 |
self notYetImplemented. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
365 |
]. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
366 |
r := wCorn / 2. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
367 |
pi := Float pi. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
368 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
369 |
"/ 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
|
370 |
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
|
371 |
"/ 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
|
372 |
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
|
373 |
"/ 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
|
374 |
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
|
375 |
"/ 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
|
376 |
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
|
377 |
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
|
378 |
cr stroke. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
379 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
380 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
381 |
|v| |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
382 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
383 |
(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
|
384 |
v cairo |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
385 |
lineWidth: 5; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
386 |
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
|
387 |
release |
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 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
390 |
"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
|
391 |
"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
|
392 |
! ! |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
393 |
|
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
|
394 |
!CairoGraphicsContext methodsFor:'filling'! |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
395 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
396 |
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
|
397 |
| r pi | |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
398 |
wCorn ~~ hCorn ifTrue:[ |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
399 |
self notYetImplemented. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
400 |
]. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
401 |
r := wCorn / 2. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
402 |
pi := Float pi. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
403 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
404 |
"/ 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
|
405 |
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
|
406 |
"/ 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
|
407 |
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
|
408 |
"/ 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
|
409 |
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
|
410 |
"/ 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
|
411 |
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
|
412 |
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
|
413 |
cr fill. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
414 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
415 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
416 |
|v| |
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 |
(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
|
419 |
v cairo |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
420 |
lineWidth: 5; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
421 |
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
|
422 |
release |
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 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
425 |
"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
|
426 |
"Modified: / 13-02-2016 / 20:00:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 427 |
! ! |
428 |
||
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
|
429 |
!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
|
430 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
431 |
executor |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
432 |
^ super executor |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
433 |
"/^ self shallowCopy |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
434 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
435 |
"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
|
436 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
437 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
438 |
finalization |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
439 |
self destroy |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
440 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
441 |
"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
|
442 |
! |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
443 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
444 |
finalizationLobby |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
445 |
"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
|
446 |
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
|
447 |
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
|
448 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
449 |
^ Lobby |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
450 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
451 |
"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
|
452 |
! ! |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
453 |
|
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 |
!CairoGraphicsContext methodsFor:'initialization & release'! |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
455 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
456 |
createCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
457 |
"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
|
458 |
|
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
|
459 |
cr := self cairo. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
460 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
461 |
"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
|
462 |
"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
|
463 |
! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
464 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
465 |
createGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
466 |
"physically create a device GC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
467 |
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
|
468 |
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
|
469 |
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
|
470 |
super createGC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
471 |
self createCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
472 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
473 |
"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
|
474 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
475 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
476 |
destroyCR |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
477 |
"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
|
478 |
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
|
479 |
refcounter goes to zero. However, after calling destroy, |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
480 |
this instance should be treated as invalid." |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
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 |
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
|
483 |
| 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
|
484 |
|
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
485 |
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
|
486 |
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
|
487 |
surface release. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
488 |
]. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
489 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
490 |
"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
|
491 |
"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
|
492 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
493 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
494 |
destroyGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
495 |
self destroyCR. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
496 |
super destroyGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
497 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
498 |
"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
|
499 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
500 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
501 |
releaseCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
502 |
self destroyCR |
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 |
"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
|
505 |
! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
506 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
507 |
releaseGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
508 |
"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
|
509 |
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
|
510 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
511 |
self releaseCR. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
512 |
super releaseGC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
513 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
514 |
"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
|
515 |
! ! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
516 |
|
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
|
517 |
!CairoGraphicsContext class methodsFor:'documentation'! |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
518 |
|
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
519 |
version |
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
520 |
^'$Id$' |
11 | 521 |
! |
522 |
||
23
38ee47dbd976
Added version_HG to make Mercurial happy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
523 |
version_HG |
38ee47dbd976
Added version_HG to make Mercurial happy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
524 |
^ '$Changeset: <not expanded> $' |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
525 |
! ! |
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
|
526 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
527 |
|
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
|
528 |
CairoGraphicsContext initialize! |