author | Jan Vrany <jan.vrany@fit.cvut.cz> |
Fri, 19 Feb 2016 14:25:58 +0000 | |
changeset 45 | 8ee53c41a084 |
parent 44 | ffe4882eb977 |
child 46 | e624554ca9a3 |
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 |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
6 |
instanceVariableNames:'cr' |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
7 |
classVariableNames:'Lobby' |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
8 |
poolDictionaries:'Cairo::FontSlant Cairo::FontWeight Cairo::Format Cairo::Status' |
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 |
|
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
22 |
"Modified: / 18-02-2016 / 22:51:03 / 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 |
|
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
30 |
cGC := self basicNew. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
31 |
1 to: DeviceGraphicsContext instSize do:[:i | |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
32 |
cGC instVarAt: i put: (dGC instVarAt: i). |
39
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:[ |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
35 |
cGC initGC. |
39
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 |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
38 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
39 |
"Created: / 15-02-2016 / 21:20:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
40 |
"Modified: / 18-02-2016 / 22:50:51 / 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
|
41 |
! ! |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
42 |
|
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
|
43 |
!CairoGraphicsContext class methodsFor:'accessing'! |
1 | 44 |
|
12 | 45 |
dllPath |
46 |
||
47 |
OperatingSystem isMSWINDOWSlike ifTrue:[ |
|
48 |
^ #( 'C:\Windows' 'C:\Windows\System32' "Wild guess, should not harm" ) |
|
49 |
]. |
|
50 |
||
51 |
OperatingSystem isUNIXlike ifTrue:[ |
|
52 |
OperatingSystem getSystemType == #linux ifTrue:[ |
|
53 |
| path | |
|
54 |
||
55 |
path := #( '/lib' '/usr/lib' '/usr/local/lib' ). |
|
56 |
(OperatingSystem getSystemInfo at:#machine) = 'x86_64' ifTrue:[ |
|
57 |
"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
|
58 |
Leave standard paths at the end, as the system might be completely |
12 | 59 |
32bit but running on 64bit-capable CPU. |
60 |
||
61 |
CAVEAT: This is bit dangerous, as on 64bit OS, if ia32 libs are |
|
62 |
not installed byt 64bit sqlite libs are, then 64bit libs are found |
|
63 |
and when a function is called, segfault will occur!! |
|
64 |
||
65 |
Q: Is there a way how to figure out if the OS itself is 32bit, |
|
66 |
regardles on CPU?" |
|
67 |
path := #( '/lib32' '/usr/lib32' '/usr/local/lib32' ) , path. |
|
68 |
]. |
|
69 |
^path |
|
70 |
||
71 |
]. |
|
72 |
]. |
|
73 |
||
74 |
self error:'Unsupported operating system' |
|
75 |
||
76 |
" |
|
77 |
SqliteLibrary dllPath |
|
78 |
" |
|
79 |
||
80 |
"Created: / 31-08-2011 / 18:02:17 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
|
81 |
! |
|
82 |
||
1 | 83 |
libraryName |
84 |
||
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
85 |
OperatingSystem isUNIXlike ifTrue:[^'libcairo.so.2']. |
1 | 86 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
87 |
OperatingSystem isMSWINDOWSlike ifTrue:[^'cairo.dll']. |
12 | 88 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
89 |
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
|
90 |
! |
c1f387b40e3a
regenerated using newer version of CFace
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
5
diff
changeset
|
91 |
|
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
|
92 |
sizeof |
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
93 |
"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
|
94 |
|
29
6ba06265e543
Bindinge updated to recent Cairo version.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
26
diff
changeset
|
95 |
^0 |
1 | 96 |
! ! |
97 |
||
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
|
98 |
!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
|
99 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
100 |
rectangleOnTranscript |
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 |
" |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
103 |
Cairo::GraphicsContext rectangleOnTranscript |
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 |
|
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 |
| gc | |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
108 |
gc := Transcript cairo. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
109 |
gc paint: Color black. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
110 |
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
|
111 |
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
|
112 |
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
|
113 |
gc fill. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
114 |
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
|
115 |
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
|
116 |
gc stroke. |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
117 |
|
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
118 |
"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
|
119 |
! ! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
120 |
|
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
|
121 |
!CairoGraphicsContext methodsFor:'accessing'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
122 |
|
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
123 |
basicFont:aFont |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
124 |
(aFont ~~ font) ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
125 |
super basicFont: aFont. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
126 |
font notNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
127 |
font := CairoScaledFont fromFontDescription: font onDevice: device. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
128 |
cr notNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
129 |
cr font: font scaledFont. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
130 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
131 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
132 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
133 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
134 |
"Created: / 16-02-2016 / 15:37:44 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
44
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
135 |
"Modified: / 23-02-2016 / 14:46:23 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
136 |
"Modified: / 21-02-2016 / 15:38:52 / jv" |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
137 |
! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
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 |
clippingBounds:aRectangleOrNil |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
140 |
"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
|
141 |
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
|
142 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
143 |
^ super clippingBounds:aRectangleOrNil |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
144 |
|
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
145 |
"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
|
146 |
! |
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
147 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
148 |
function:aFunctionSymbol |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
149 |
"set the drawing function" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
150 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
151 |
^ self shouldImplement |
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 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
154 |
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
|
155 |
super lineWidth: w. |
44
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
156 |
cr notNil ifTrue:[ |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
157 |
cr lineWidth: (w == 0 ifTrue:[ 1 ] ifFalse:[ w ]). |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
158 |
]. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
159 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
160 |
"Created: / 17-06-2012 / 21:55:05 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
44
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
161 |
"Modified: / 23-02-2016 / 11:29:43 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
162 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
163 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
164 |
mask:aForm |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
165 |
"set the drawing mask" |
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 |
^ self shouldImplement |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
168 |
! |
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 |
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
|
171 |
super paint: aColor. |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
172 |
cr notNil ifTrue:[ |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
173 |
cr source: paint. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
174 |
]. |
1 | 175 |
|
176 |
"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
|
177 |
"Modified: / 23-04-2009 / 17:31:33 / Jan Vrany <vranyj1@fel.cvut.cz>" |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
178 |
"Modified: / 18-02-2016 / 22:56:37 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
1 | 179 |
! ! |
180 |
||
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
|
181 |
!CairoGraphicsContext methodsFor:'accessing-transformation'! |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
182 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
183 |
transformation:aTransformation |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
184 |
"set the transformation" |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
185 |
|
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
186 |
super transformation: aTransformation. |
44
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
187 |
cr notNil ifTrue:[ |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
188 |
cr matrixReset. |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
189 |
transformation notNil ifTrue:[ |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
190 |
cr |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
191 |
scale: transformation scale; |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
192 |
transform: transformation translation. |
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
193 |
] |
39
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>" |
44
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
197 |
"Modified: / 23-02-2016 / 15:55:56 / 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 |
| angle1 angle2 | |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
204 |
|
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
205 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
206 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
207 |
]. |
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
|
208 |
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
|
209 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
210 |
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
|
211 |
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
|
212 |
]. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
213 |
|
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
|
214 |
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
|
215 |
angle2 := (360 - (start + angle)) \\ 360. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
216 |
|
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
|
217 |
(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
|
218 |
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
|
219 |
] 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
|
220 |
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
|
221 |
]. |
9b680e54aa94
Take a step 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 |
cr stroke. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
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 |
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
|
225 |
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
|
226 |
]. |
9b680e54aa94
Take a step 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 |
] 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
|
228 |
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
|
229 |
] |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
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:05:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
232 |
"Modified: / 21-02-2016 / 15:34:08 / jv" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
233 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
234 |
|
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
235 |
displayLineFromX:x0 y:y0 toX:x1 y:y1 |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
236 |
"draw a line from x0/y0 to x1/y1" |
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
237 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
238 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
239 |
]. |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
240 |
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
|
241 |
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
|
242 |
cr stroke. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
243 |
|
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
|
244 |
"Modified: / 13-02-2016 / 20:05:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
245 |
"Modified: / 21-02-2016 / 15:24:52 / jv" |
17 | 246 |
! |
247 |
||
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
248 |
displayPolygon:points |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
249 |
"draw a polygon |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
250 |
- this could be recoded to draw using displayLine" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
251 |
|
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
252 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
253 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
254 |
]. |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
255 |
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
|
256 |
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
|
257 |
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
|
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 |
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
|
260 |
cr stroke. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
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 |
"Modified: / 13-02-2016 / 20:04:45 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
263 |
"Modified: / 21-02-2016 / 15:34:19 / jv" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
264 |
! |
17 | 265 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
266 |
displayRectangleX:x y:y width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
267 |
"draw a rectangle |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
268 |
- this could be recoded to draw using displayLine" |
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
269 |
|
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
270 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
271 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
272 |
]. |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
273 |
(w > 0 and:[h > 0]) ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
274 |
cr rectangleX: x y: y width: w height: h. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
275 |
cr stroke. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
276 |
] |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
277 |
|
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
278 |
"Modified: / 18-02-2016 / 22:21:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
279 |
"Modified: / 21-02-2016 / 15:34:34 / jv" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
280 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
281 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
282 |
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
|
283 |
"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
|
284 |
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
|
285 |
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
|
286 |
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
|
287 |
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
|
288 |
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
|
289 |
|
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
290 |
| opaque string | |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
291 |
" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
292 |
if backgroundPaint color is nil, we assume |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
293 |
this is a non-opaque draw |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
294 |
" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
295 |
opaque := opaqueArg ? false. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
296 |
bgPaint isNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
297 |
opaque := false. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
298 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
299 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
300 |
gcId isNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
301 |
self initGC |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
302 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
303 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
304 |
(aStringArg isString not or:[aStringArg isText]) ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
305 |
" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
306 |
hook for non-strings (i.e. attributed text) |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
307 |
that 'thing' should know how to display itself ... |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
308 |
" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
309 |
aStringArg displayOn:self x:x y:y from:index1Arg to:index2Arg opaque:opaque. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
310 |
^ self |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
311 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
312 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
313 |
(index1Arg == 1 and:[ index2Arg == aStringArg size ]) ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
314 |
string := aStringArg |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
315 |
] ifFalse:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
316 |
string := aStringArg copyFrom: index1Arg to: index2Arg |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
317 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
318 |
|
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
|
319 |
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
|
320 |
[ |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
321 |
| extents | |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
322 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
323 |
extents := cr textExtents: string. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
324 |
cr rectangleX: x + extents xBearing ceiling y: y - font ascent ceiling width: extents xAdvance ceiling height: font height ceiling. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
325 |
cr lineWidth: 0. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
326 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
327 |
opaque ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
328 |
cr source: bgPaint. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
329 |
cr fill. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
330 |
] ifFalse:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
331 |
"/ I'm not sure why this is required but if not done, |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
332 |
"/ selected text is not rendered correcrtly... |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
333 |
cr stroke. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
334 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
335 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
336 |
self assert: cr status == CAIRO_STATUS_SUCCESS. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
337 |
cr source: paint. |
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 |
cr moveToX: x y: y. |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
339 |
cr showText: string. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
340 |
self assert: cr status == CAIRO_STATUS_SUCCESS. |
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
|
341 |
] 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
|
342 |
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
|
343 |
] |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
344 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
345 |
"Created: / 16-02-2016 / 10:51:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
346 |
"Modified: / 18-02-2016 / 21:12:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
347 |
"Modified: / 19-02-2016 / 21:04:49 / jv" |
17 | 348 |
! ! |
349 |
||
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
|
350 |
!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
|
351 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
352 |
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
|
353 |
| angle1 angle2 | |
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
354 |
|
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
355 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
356 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
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 |
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
|
359 |
[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
360 |
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
|
361 |
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
|
362 |
]. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
363 |
|
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
364 |
|
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
|
365 |
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
|
366 |
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
|
367 |
|
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
368 |
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
|
369 |
|
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 |
(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
|
371 |
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
|
372 |
] ifFalse:[ |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
373 |
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
|
374 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
375 |
cr closePath. |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
376 |
|
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
377 |
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
|
378 |
cr fill. |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
379 |
|
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
|
380 |
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
|
381 |
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
|
382 |
]. |
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
383 |
] 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
|
384 |
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
|
385 |
] |
32
fb983be8d2c0
To fold - support for display/fillArc...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
31
diff
changeset
|
386 |
|
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
|
387 |
"Modified: / 13-02-2016 / 20:03:39 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
388 |
"Modified: / 21-02-2016 / 15:34:47 / jv" |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
389 |
! |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
390 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
391 |
fillPolygon:points |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
392 |
"fill a polygon with current paint color" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
393 |
|
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
394 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
395 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
396 |
]. |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
397 |
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
|
398 |
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
|
399 |
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
|
400 |
]. |
36
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
401 |
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
|
402 |
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
|
403 |
cr fill. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
404 |
|
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 |
"Modified: / 13-02-2016 / 20:01:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
406 |
"Modified: / 21-02-2016 / 15:34:52 / jv" |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
407 |
! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
408 |
|
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
409 |
fillRectangleX:x y:y width:w height:h |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
410 |
"fill a rectangle with current paint color" |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
411 |
|
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
412 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
413 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
414 |
]. |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
415 |
(w > 0 and:[h > 0]) ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
416 |
cr lineWidth: 0. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
417 |
cr rectangleX: x y: y width: w height: h. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
418 |
cr fill. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
419 |
cr lineWidth: (lineWidth == 0 ifTrue:[1] ifFalse:[lineWidth]) |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
420 |
]. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
421 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
422 |
"/ cr save. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
423 |
"/ 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
|
424 |
"/ cr sourceR: 1 G: 0 B: 0. |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
425 |
"/ cr lineWidth: 1. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
426 |
"/ cr stroke. |
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
427 |
"/ cr restore. |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
428 |
|
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
429 |
"Modified: / 18-02-2016 / 22:20:48 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
430 |
"Modified: / 21-02-2016 / 15:34:56 / jv" |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
431 |
! ! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
432 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
433 |
!CairoGraphicsContext methodsFor:'bit blitting'! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
434 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
435 |
copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
436 |
"copy bits from a smalltalk byteArray. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
437 |
The bits found there are supposed to be in the devices native format (i.e. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
438 |
translated to allocated color indices on pseudoColor devices and padded as required. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
439 |
The byteOrder is MSB and will be converted as appropriate by the underlying devices |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
440 |
method to whatever the device needs." |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
441 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
442 |
cr notNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
443 |
cr surface flush |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
444 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
445 |
^ super copyBitsFrom:aByteArray bitsPerPixel:bpp depth:depth padding:pad width:srcW height:srcH x:srcX y:srcY toX:dstX y:dstY |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
446 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
447 |
"Created: / 18-02-2016 / 20:16:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
448 |
! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
449 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
450 |
copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:async |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
451 |
"copy from aDrawable into the receiver; |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
452 |
the source may be the receiver as well - in this case its a scroll. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
453 |
All coordinates are in device coordinates. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
454 |
If the receiver is a view AND async is true, the call returns immediately |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
455 |
- otherwise, it returns when the scroll operation is finished. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
456 |
(not all devices care for this). |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
457 |
If the receiver is a pixmap, the call always returns immediately." |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
458 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
459 |
cr notNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
460 |
cr surface flush |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
461 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
462 |
^ super copyFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h async:async |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
463 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
464 |
"Created: / 18-02-2016 / 20:17:26 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
465 |
! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
466 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
467 |
copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
468 |
"copy one plane from aDrawable into the receiver. 0's are drawn in |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
469 |
background, while 1's are drawn with foreground color. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
470 |
The depth of aDrawable must (should) be 1. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
471 |
The drawable must have been allocated on the same device. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
472 |
All coordinates are in device coordinates." |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
473 |
|
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
474 |
cr notNil ifTrue:[ |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
475 |
cr surface flush |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
476 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
477 |
^ super copyPlaneFrom:aDrawable x:srcX y:srcY toX:dstX y:dstY width:w height:h |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
478 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
479 |
"Created: / 18-02-2016 / 20:17:58 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
480 |
"Modified (format): / 21-02-2016 / 15:35:11 / jv" |
10
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
481 |
! ! |
dd5fece7c8d2
Few hacks before presentation at Smalltalk Jihlava 2009
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
8
diff
changeset
|
482 |
|
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
|
483 |
!CairoGraphicsContext methodsFor:'drawing'! |
17 | 484 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
485 |
displayForm:aFormOrImage x:x y:y |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
486 |
"draw a form (or image) at x/y; |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
487 |
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
|
488 |
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
|
489 |
If the form has depth ~~ 1, the current fg color setting is ignored." |
1 | 490 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
491 |
| image width height stride data image_surface | |
17 | 492 |
|
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
493 |
^ 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
|
494 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
495 |
image := aFormOrImage asImage. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
496 |
width := image width. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
497 |
height := image height. |
39
8af34937e1ec
More work for using CairoGrahicsContext for rendering views
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
36
diff
changeset
|
498 |
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
|
499 |
data := ExternalBytes basicNew allocateBytes: stride * height clear: false. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
500 |
[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
501 |
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
|
502 |
image_surface := Cairo::CPrimitives cairo_image_surface_create_for_data: data _: CAIRO_FORMAT_ARGB32 _: width _: height _: stride. |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
503 |
Cairo::CPrimitives cairo_set_source_surface: cr _: image_surface _: x asFloat _: y asFloat. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
504 |
Cairo::CPrimitives cairo_paint: cr. |
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
505 |
] ensure:[ |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
506 |
data finalize. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
507 |
image_surface release. |
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
508 |
]. |
1 | 509 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
510 |
"Created: / 31-12-2014 / 12:08:08 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
40
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
511 |
"Modified: / 17-02-2016 / 20:58:00 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
512 |
! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
513 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
514 |
displayLineFrom:p0 to:p1 |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
515 |
"draw a line (with current paint-color); apply transformation if nonNil" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
516 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
517 |
^ self displayLineFromX: p0 x y: p0 y toX: p1 x y: p1 y |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
518 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
519 |
"Created: / 18-02-2016 / 20:27:56 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
520 |
! |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
521 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
522 |
displayLineFromX:xStart y:yStart toX:xEnd y:yEnd brush:aForm |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
523 |
"draw a line using a brush. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
524 |
Here, a slow fallback is used, drawing into a |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
525 |
temporary bitmap first, which is then displayed" |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
526 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
527 |
cr notNil ifTrue:[ |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
528 |
cr surface flush |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
529 |
]. |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
530 |
^ super displayLineFromX:xStart y:yStart toX:xEnd y:yEnd brush:aForm |
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
531 |
|
28dfc583beb5
#displayString: in CairoGraphicsContext revamped
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
39
diff
changeset
|
532 |
"Created: / 18-02-2016 / 20:28:58 / 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
|
533 |
! |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
534 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
535 |
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
|
536 |
| r pi | |
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
537 |
|
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
538 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
539 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
540 |
]. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
541 |
wCorn ~~ hCorn ifTrue:[ |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
542 |
self notYetImplemented. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
543 |
]. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
544 |
r := wCorn / 2. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
545 |
pi := Float pi. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
546 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
547 |
"/ 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
|
548 |
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
|
549 |
"/ 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
|
550 |
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
|
551 |
"/ 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
|
552 |
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
|
553 |
"/ 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
|
554 |
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
|
555 |
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
|
556 |
cr stroke. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
557 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
558 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
559 |
|v| |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
560 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
561 |
(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
|
562 |
v cairo |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
563 |
lineWidth: 5; |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
564 |
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
|
565 |
release |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
566 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
567 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
568 |
"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
|
569 |
"Modified: / 13-02-2016 / 20:00:35 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
570 |
"Modified: / 21-02-2016 / 15:35:35 / jv" |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
571 |
! ! |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
572 |
|
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
|
573 |
!CairoGraphicsContext methodsFor:'filling'! |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
574 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
575 |
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
|
576 |
| r pi | |
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
577 |
|
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
578 |
gcId isNil ifTrue:[ |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
579 |
self initGC. |
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
580 |
]. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
581 |
wCorn ~~ hCorn ifTrue:[ |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
582 |
self notYetImplemented. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
583 |
]. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
584 |
r := wCorn / 2. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
585 |
pi := Float pi. |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
586 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
587 |
"/ 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
|
588 |
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
|
589 |
"/ 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
|
590 |
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
|
591 |
"/ 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
|
592 |
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
|
593 |
"/ 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
|
594 |
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
|
595 |
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
|
596 |
cr fill. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
597 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
598 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
599 |
|v| |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
600 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
601 |
(v := View new) extent:200@200; openAndWait. |
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
602 |
v cairoify |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
603 |
lineWidth: 5; |
42
475e93b10c8f
CairoGraphicsContext: Make sure native GC and Cairo context is initialized
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
41
diff
changeset
|
604 |
displayRoundRectangleX:10 y:10 width:100 height:100 wCorner:20 hCorner:20. |
33
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
605 |
" |
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
606 |
|
8a2e438b4363
To fold - better display/fill RoundedRectangle...
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
32
diff
changeset
|
607 |
"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
|
608 |
"Modified: / 13-02-2016 / 20:00:02 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
45
8ee53c41a084
Win32: Initial support for Cairo under Windows
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
44
diff
changeset
|
609 |
"Modified (comment): / 21-02-2016 / 15:58:59 / jv" |
1 | 610 |
! ! |
611 |
||
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
|
612 |
!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
|
613 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
614 |
executor |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
615 |
^ super executor |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
616 |
"/^ self shallowCopy |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
617 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
618 |
"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
|
619 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
620 |
|
34
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
621 |
finalization |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
622 |
self destroy |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
623 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
624 |
"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
|
625 |
! |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
626 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
627 |
finalizationLobby |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
628 |
"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
|
629 |
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
|
630 |
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
|
631 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
632 |
^ Lobby |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
633 |
|
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
634 |
"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
|
635 |
! ! |
97705b5a9411
Use Cairo's toy text API for text rendering.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
33
diff
changeset
|
636 |
|
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
|
637 |
!CairoGraphicsContext methodsFor:'initialization & release'! |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
638 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
639 |
createCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
640 |
"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
|
641 |
|
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
|
642 |
cr := self cairo. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
643 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
644 |
"Created: / 12-02-2016 / 16:59:03 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
645 |
"Modified: / 18-02-2016 / 22:53:24 / 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
|
646 |
! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
647 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
648 |
createGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
649 |
"physically create a device GC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
650 |
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
|
651 |
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
|
652 |
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
|
653 |
super createGC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
654 |
self createCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
655 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
656 |
"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
|
657 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
658 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
659 |
destroyCR |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
660 |
"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
|
661 |
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
|
662 |
refcounter goes to zero. However, after calling destroy, |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
663 |
this instance should be treated as invalid." |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
664 |
|
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
|
665 |
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
|
666 |
| 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
|
667 |
|
9b680e54aa94
Take a step back: separate Cairo's GraphicsContext (cairo_t) and Smalltalk/X's graphics context
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
35
diff
changeset
|
668 |
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
|
669 |
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
|
670 |
surface release. |
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
671 |
]. |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
672 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
673 |
"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
|
674 |
"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
|
675 |
! |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
676 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
677 |
destroyGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
678 |
self destroyCR. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
679 |
super destroyGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
680 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
681 |
"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
|
682 |
! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
683 |
|
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
684 |
initCR |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
685 |
| f | |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
686 |
|
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
687 |
cr isNil ifTrue:[ |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
688 |
self createCR. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
689 |
]. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
690 |
cr lineWidth: (lineWidth == 0 ifTrue:[ 1 ] ifFalse:[ lineWidth ]). |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
691 |
cr source: paint. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
692 |
cr matrixReset. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
693 |
transformation notNil ifTrue:[ |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
694 |
cr |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
695 |
scale: transformation scale; |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
696 |
transform: transformation translation. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
697 |
]. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
698 |
f := font. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
699 |
font := nil. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
700 |
self basicFont: f. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
701 |
|
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
702 |
"Created: / 18-02-2016 / 22:48:24 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
44
ffe4882eb977
Avoid excessive font object creation by cacheing in device
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
42
diff
changeset
|
703 |
"Modified: / 23-02-2016 / 15:55:32 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
41
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
704 |
! |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
705 |
|
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
706 |
initGC |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
707 |
super initGC. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
708 |
self initCR. |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
709 |
|
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
710 |
"Created: / 18-02-2016 / 22:48:15 / Jan Vrany <jan.vrany@fit.cvut.cz>" |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
711 |
! |
17bc740cbc2a
Fixed (lazy) initialization of CairoGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
40
diff
changeset
|
712 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
713 |
releaseCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
714 |
self destroyCR |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
715 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
716 |
"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
|
717 |
! |
30
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
718 |
|
35
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
719 |
releaseGC |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
720 |
"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
|
721 |
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
|
722 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
723 |
self releaseCR. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
724 |
super releaseGC. |
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
725 |
|
395689a88b32
Make Cairo::GraphicsContext to inherit from DeviceGraphicsContext
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
34
diff
changeset
|
726 |
"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
|
727 |
! ! |
c8fe298c8cc7
GraphicsContext refactoring (part 1)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
29
diff
changeset
|
728 |
|
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
|
729 |
!CairoGraphicsContext class methodsFor:'documentation'! |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
730 |
|
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
731 |
version |
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
732 |
^'$Id$' |
11 | 733 |
! |
734 |
||
23
38ee47dbd976
Added version_HG to make Mercurial happy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
735 |
version_HG |
38ee47dbd976
Added version_HG to make Mercurial happy
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
20
diff
changeset
|
736 |
^ '$Changeset: <not expanded> $' |
7
392289f92fab
- DLL path is set automatically.
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
6
diff
changeset
|
737 |
! ! |
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
|
738 |
|
31
26070c1e480e
GraphicsContext refactoring (part 2)
Jan Vrany <jan.vrany@fit.cvut.cz>
parents:
30
diff
changeset
|
739 |
|
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
|
740 |
CairoGraphicsContext initialize! |