5462
|
1 |
"
|
7936
|
2 |
COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
|
5462
|
3 |
All Rights Reserved
|
|
4 |
|
|
5 |
This software is furnished under a license and may be used
|
|
6 |
only in accordance with the terms of that license and with the
|
|
7 |
inclusion of the above copyright notice. This software may not
|
|
8 |
be provided or otherwise made available to, or used by, any
|
|
9 |
other person. No title to or ownership of the software is
|
|
10 |
hereby transferred.
|
|
11 |
"
|
5396
|
12 |
"{ Package: 'stx:libview' }"
|
|
13 |
|
7936
|
14 |
"{ NameSpace: Smalltalk }"
|
|
15 |
|
5396
|
16 |
AbstractBackground subclass:#ImageBackground
|
6689
|
17 |
instanceVariableNames:'image align cachedMagnifiedImage'
|
5396
|
18 |
classVariableNames:''
|
|
19 |
poolDictionaries:''
|
|
20 |
category:'Graphics-Support'
|
|
21 |
!
|
|
22 |
|
5462
|
23 |
!ImageBackground class methodsFor:'documentation'!
|
|
24 |
|
|
25 |
copyright
|
|
26 |
"
|
7936
|
27 |
COPYRIGHT (c) 2009 by Claus Gittinger / eXept Software AG
|
5462
|
28 |
All Rights Reserved
|
|
29 |
|
|
30 |
This software is furnished under a license and may be used
|
|
31 |
only in accordance with the terms of that license and with the
|
|
32 |
inclusion of the above copyright notice. This software may not
|
|
33 |
be provided or otherwise made available to, or used by, any
|
|
34 |
other person. No title to or ownership of the software is
|
|
35 |
hereby transferred.
|
|
36 |
"
|
6689
|
37 |
!
|
|
38 |
|
|
39 |
examples
|
|
40 |
"
|
|
41 |
[exBegin]
|
|
42 |
|v|
|
|
43 |
|
|
44 |
v := View new.
|
|
45 |
v viewBackground:(ImageBackground new image:(Image fromFile:'~/work/stx/hsv.png')).
|
|
46 |
v open.
|
|
47 |
[exEnd]
|
|
48 |
|
|
49 |
[exBegin]
|
|
50 |
|v|
|
|
51 |
|
|
52 |
v := View new.
|
|
53 |
v viewBackground:(ImageBackground new
|
|
54 |
image:(Image fromFile:'~/work/stx/hsv.png');
|
|
55 |
align:#fit).
|
|
56 |
v open.
|
|
57 |
[exEnd]
|
|
58 |
"
|
|
59 |
! !
|
|
60 |
|
|
61 |
!ImageBackground methodsFor:'accessing'!
|
|
62 |
|
|
63 |
align:something
|
|
64 |
align := something.
|
|
65 |
!
|
|
66 |
|
|
67 |
image:something
|
|
68 |
image := something.
|
|
69 |
! !
|
|
70 |
|
|
71 |
!ImageBackground methodsFor:'drawing'!
|
|
72 |
|
|
73 |
fillRectangleX:x y:y width:w height:h in:aView
|
|
74 |
align == #right ifTrue:[
|
|
75 |
image displayOn:aView x:(aView right - image width) y:0.
|
|
76 |
^ self
|
|
77 |
].
|
|
78 |
align == #center ifTrue:[
|
|
79 |
image displayOn:aView x:(aView right - image width)//2 y:(aView bottom - image height)//2.
|
|
80 |
^ self
|
|
81 |
].
|
|
82 |
align == #fit ifTrue:[
|
|
83 |
(cachedMagnifiedImage notNil
|
|
84 |
and:[ cachedMagnifiedImage width == aView width
|
|
85 |
and:[ cachedMagnifiedImage height == aView height ]]) ifFalse:[
|
|
86 |
cachedMagnifiedImage := image magnifiedTo:aView extent.
|
|
87 |
aView invalidate.
|
|
88 |
^ self.
|
|
89 |
].
|
|
90 |
cachedMagnifiedImage displayOn:aView x:0 y:0.
|
|
91 |
^ self
|
|
92 |
].
|
|
93 |
|
|
94 |
"/ align == #left
|
|
95 |
x < image width ifTrue:[
|
|
96 |
y < image height ifTrue:[
|
|
97 |
image displayOn:aView x:0 y:0
|
|
98 |
]
|
|
99 |
]
|
5462
|
100 |
! !
|
5396
|
101 |
|
|
102 |
!ImageBackground class methodsFor:'documentation'!
|
|
103 |
|
|
104 |
version_CVS
|
7936
|
105 |
^ '$Header$'
|
5396
|
106 |
! !
|
6689
|
107 |
|