0
|
1 |
"
|
3
|
2 |
COPYRIGHT (c) 1989-93 by Claus Gittinger
|
0
|
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 |
|
|
13 |
View subclass:#PanelView
|
|
14 |
instanceVariableNames:'layout verticalSpace horizontalSpace mustRearrange'
|
|
15 |
classVariableNames:''
|
|
16 |
poolDictionaries:''
|
|
17 |
category:'Views-Layout'
|
|
18 |
!
|
|
19 |
|
|
20 |
PanelView comment:'
|
|
21 |
|
3
|
22 |
COPYRIGHT (c) 1989-93 by Claus Gittinger
|
0
|
23 |
All Rights Reserved
|
|
24 |
|
3
|
25 |
this is a view for holding subviews. (layout-widget ?!!)
|
0
|
26 |
|
|
27 |
this one just tries to get everything into its space -
|
|
28 |
if you dont like its layout, define a subclass ...
|
|
29 |
|
|
30 |
HorizontalPanelView and VerticalPanelView are two of them.
|
|
31 |
|
3
|
32 |
$Header: /cvs/stx/stx/libwidg/PanelView.st,v 1.2 1993-10-13 01:03:04 claus Exp $
|
0
|
33 |
|
|
34 |
written spring/summer 89 by claus
|
|
35 |
'!
|
|
36 |
|
|
37 |
!PanelView methodsFor:'initialization'!
|
|
38 |
|
|
39 |
initialize
|
|
40 |
super initialize.
|
|
41 |
|
|
42 |
layout := #center.
|
|
43 |
verticalSpace := ViewSpacing.
|
|
44 |
horizontalSpace := ViewSpacing.
|
|
45 |
mustRearrange := false
|
|
46 |
!
|
|
47 |
|
|
48 |
realize
|
|
49 |
mustRearrange ifTrue:[
|
|
50 |
self setChildPositions
|
|
51 |
].
|
|
52 |
super realize
|
|
53 |
! !
|
|
54 |
|
|
55 |
!PanelView methodsFor:'accessing'!
|
|
56 |
|
|
57 |
verticalSpace:numberOfPixels
|
|
58 |
"set the space between elements (default is 1mm)"
|
|
59 |
|
|
60 |
verticalSpace := numberOfPixels
|
|
61 |
!
|
|
62 |
|
|
63 |
horizontalSpace:numberOfPixels
|
|
64 |
"set the space between elements (default is 1mm)"
|
|
65 |
|
|
66 |
horizontalSpace := numberOfPixels
|
|
67 |
!
|
|
68 |
|
|
69 |
space:numberOfPixels
|
|
70 |
"set the space between elements (default is 1mm)"
|
|
71 |
|
|
72 |
horizontalSpace := numberOfPixels.
|
|
73 |
verticalSpace := numberOfPixels
|
|
74 |
!
|
|
75 |
|
|
76 |
layout:aSymbol
|
|
77 |
"change the layout - the argument, aSymbol is interpreted in subclasses
|
|
78 |
HorizontalPanelView and VerticalPanelView;
|
|
79 |
it may be: #left / #top; #spread; #center or #right / #bottom"
|
|
80 |
|
|
81 |
(layout ~~ aSymbol) ifTrue:[
|
|
82 |
layout := aSymbol.
|
|
83 |
self layoutChanged
|
|
84 |
]
|
|
85 |
!
|
|
86 |
|
|
87 |
addSubView:aView
|
|
88 |
super addSubView:aView.
|
|
89 |
self layoutChanged
|
|
90 |
! !
|
|
91 |
|
|
92 |
!PanelView methodsFor:'event processing'!
|
|
93 |
|
|
94 |
sizeChanged:how
|
|
95 |
super sizeChanged:how.
|
|
96 |
self setChildPositions
|
|
97 |
! !
|
|
98 |
|
|
99 |
!PanelView methodsFor:'private'!
|
|
100 |
|
|
101 |
layoutChanged
|
|
102 |
(shown and:[realized]) ifTrue:[
|
|
103 |
self setChildPositions
|
|
104 |
] ifFalse:[
|
|
105 |
mustRearrange := true
|
|
106 |
]
|
|
107 |
!
|
|
108 |
|
|
109 |
setChildPositions
|
|
110 |
"(re)compute position of every child"
|
|
111 |
|
|
112 |
|first xpos ypos maxHeightInRow|
|
|
113 |
|
|
114 |
subViews notNil ifTrue:[
|
|
115 |
xpos := horizontalSpace.
|
|
116 |
ypos := verticalSpace.
|
|
117 |
|
|
118 |
maxHeightInRow := 0.
|
|
119 |
first := true.
|
|
120 |
subViews do:[:child |
|
|
121 |
"go to next row, if this subview won't fit"
|
|
122 |
first ifFalse: [
|
|
123 |
(xpos + child widthIncludingBorder + horizontalSpace) > width
|
|
124 |
ifTrue: [
|
|
125 |
ypos := ypos + verticalSpace + maxHeightInRow.
|
|
126 |
xpos := horizontalSpace.
|
|
127 |
maxHeightInRow := 0
|
|
128 |
]
|
|
129 |
].
|
|
130 |
child origin:(xpos@ypos).
|
|
131 |
xpos := xpos + (child widthIncludingBorder) + horizontalSpace.
|
|
132 |
(maxHeightInRow < (child heightIncludingBorder)) ifTrue:[
|
|
133 |
maxHeightInRow := child heightIncludingBorder
|
|
134 |
].
|
|
135 |
first := false
|
|
136 |
]
|
|
137 |
].
|
|
138 |
mustRearrange := false
|
|
139 |
! !
|