88
|
1 |
"
|
|
2 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
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 |
"
|
|
12 |
|
83
|
13 |
LayoutOrigin subclass:#AlignmentOrigin
|
|
14 |
instanceVariableNames:'leftAlignmentFraction topAlignmentFraction'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Graphics-Geometry'
|
|
18 |
!
|
|
19 |
|
88
|
20 |
!AlignmentOrigin class methodsFor:'documentation'!
|
|
21 |
|
|
22 |
copyright
|
|
23 |
"
|
|
24 |
COPYRIGHT (c) 1995 by Claus Gittinger
|
|
25 |
All Rights Reserved
|
|
26 |
|
|
27 |
This software is furnished under a license and may be used
|
|
28 |
only in accordance with the terms of that license and with the
|
|
29 |
inclusion of the above copyright notice. This software may not
|
|
30 |
be provided or otherwise made available to, or used by, any
|
|
31 |
other person. No title to or ownership of the software is
|
|
32 |
hereby transferred.
|
|
33 |
"
|
|
34 |
!
|
|
35 |
|
|
36 |
version
|
|
37 |
"
|
|
38 |
$Header: /cvs/stx/stx/libview2/Attic/AlignOrg.st,v 1.2 1995-08-10 18:43:06 claus Exp $
|
|
39 |
"
|
|
40 |
! !
|
|
41 |
|
83
|
42 |
!AlignmentOrigin methodsFor:'accessing'!
|
|
43 |
|
|
44 |
leftAlignmentFraction:something
|
|
45 |
"set leftAlignmentFraction"
|
|
46 |
|
|
47 |
leftAlignmentFraction := something.
|
|
48 |
!
|
|
49 |
|
|
50 |
leftAlignmentFraction
|
|
51 |
"return leftAlignmentFraction"
|
|
52 |
|
|
53 |
^ leftAlignmentFraction
|
|
54 |
!
|
|
55 |
|
|
56 |
topAlignmentFraction:something
|
|
57 |
"set topAlignmentFraction"
|
|
58 |
|
|
59 |
topAlignmentFraction := something.
|
|
60 |
!
|
|
61 |
|
|
62 |
topAlignmentFraction
|
|
63 |
"return topAlignmentFraction"
|
|
64 |
|
|
65 |
^ topFraction
|
|
66 |
! !
|
|
67 |
|
|
68 |
!AlignmentOrigin methodsFor:'printing & storing'!
|
|
69 |
|
|
70 |
displayString
|
|
71 |
^ 'LayoutOrigin('
|
|
72 |
, 'l: ' , leftFraction displayString
|
|
73 |
, '+' , leftOffset displayString
|
|
74 |
, ' t: ' , topFraction displayString
|
|
75 |
, '+' , topOffset displayString
|
|
76 |
, ' a: ' , leftAlignmentFraction displayString
|
|
77 |
, '@' , topAlignmentFraction displayString
|
|
78 |
, ')'
|
|
79 |
! !
|
|
80 |
|
|
81 |
|
|
82 |
!AlignmentOrigin methodsFor:'queries'!
|
|
83 |
|
|
84 |
rectangleRelativeTo:superRectangle preferred:prefRect
|
|
85 |
|x y|
|
|
86 |
|
|
87 |
leftOffset isNil ifTrue:[
|
|
88 |
x := 0
|
|
89 |
] ifFalse:[
|
|
90 |
x := leftOffset
|
|
91 |
].
|
|
92 |
topOffset isNil ifTrue:[
|
|
93 |
y := 0
|
|
94 |
] ifFalse:[
|
|
95 |
y := topOffset
|
|
96 |
].
|
|
97 |
leftFraction notNil ifTrue:[
|
|
98 |
x := x + (superRectangle width * leftFraction)
|
|
99 |
].
|
|
100 |
topFraction notNil ifTrue:[
|
|
101 |
y := y + (superRectangle height * topFraction)
|
|
102 |
].
|
|
103 |
leftAlignmentFraction ~~ 0 ifTrue:[
|
|
104 |
x := x - (prefRect width * leftAlignmentFraction)
|
|
105 |
].
|
|
106 |
topAlignmentFraction ~~ 0 ifTrue:[
|
|
107 |
y := y - (prefRect height * topAlignmentFraction)
|
|
108 |
].
|
|
109 |
^ Rectangle origin:x@y extent:prefRect extent
|
|
110 |
|
|
111 |
"
|
|
112 |
|superRect aO|
|
|
113 |
|
|
114 |
superRect := 0@0 corner:100@100.
|
|
115 |
aO := (AlignmentOrigin new).
|
|
116 |
aO leftFraction:0.5;
|
|
117 |
topFraction:0.5;
|
|
118 |
leftAlignmentFraction:0.5;
|
|
119 |
topAlignmentFraction:0.5.
|
|
120 |
aO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30)
|
|
121 |
"
|
|
122 |
! !
|
|
123 |
|
|
124 |
!AlignmentOrigin methodsFor:'initialization'!
|
|
125 |
|
|
126 |
initialize
|
|
127 |
super initialize.
|
|
128 |
leftAlignmentFraction := topAlignmentFraction := 0.
|
|
129 |
! !
|