|
Class: PanelView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--PanelView
|
+--GridBagLayoutView
|
+--HorizontalPanelView
|
+--MultiColumnPanelView
|
+--VerticalPanelView
- Package:
- stx:libwidg
- Category:
- Views-Layout
- Version:
- rev:
1.71
date: 2023/04/21 13:45:04
- user: matilk
- file: PanelView.st directory: libwidg
- module: stx stc-classLibrary: libwidg
this is a view for holding subviews. (layout-widget ?)
Instances of PanelView try to get all their subviews into them,
arranging subviews left-to-right, top-to-bottom.
If you don't like its layout, define a new subclass or use one of
the existing subclasses: HorizontalPanelView and VerticalPanelView.
The panel assumes, that the elements do not resize themselfes, after it
became visible. This is not true for all widgets (buttons or labels may
like to change). If you have changing elements, tell this to the panel
with 'aPanel elementsChangeSize:true'. In that case, the panel will react
to size changes, and reorganize things.
PanelViews normally delay the actual positioning/sizing of their elements,
until actually displayed. This is useful, if more elements are to
be added, to avoid repeated configuration of the elements.
If you want to query for the relative position of an element BEFORE
the view is visible, you have to send #setChildPositionsIfChanged before
doing so (otherwise, you may get invalid origins from the subviews). As
an example, the modalBoxes do so before showing themselfes to ask for the
position of the ok-button relative to the top-left box-origin, in order to
position the ok-button under the mouse-pointer.
[Instance variables:]
hLayout <Symbol> controls horizontal layout; ignored in this
class, but used in Horizontal- and
VerticalPanelViews. See more info there.
vLayout <Symbol> controls vertical layout; ignored in this
class, but used in Horizontal- and
VerticalPanelViews. See more info there.
horizontalSpace <Integer> number of pixels to use as space between elements
defaults to ViewSpacing, which is 1mm
verticalSpace <Integer> number of pixels to use as space between elements
defaults to ViewSpacing, which is 1mm
mustRearrange <Boolean> internal flag, if rearrangement is needed
elementsChangeSize
<Boolean> if true, the panel takes care of this situation.
By default, this is false.
ignoreInvisibleComponents
<Boolean> if true, invisible (i.e. hidden) views
are not considered in the layout computation.
If false, they will lead to additional space
between visible components.
The default is false.
copyrightCOPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
accessing
-
elementsChangeSize
-
tell the panel if elements are to change their size by themselfes
(for example, Labels or Buttons may do so if their contents changes).
Setting this flag will make the panel reorganize the elements whenever
any element changes its size.
-
elementsChangeSize: aBoolean
-
tell the panel if elements are to change their size by themselfes
(for example, Labels or Buttons may do so if their contents changes).
Setting this flag will make the panel reorganize the elements whenever
any element changes its size.
-
hierarchicalIndexOfChild: aView
-
-
horizontalLayout
-
not supported by this view
-
horizontalLayout: aLayoutSymbol
-
not supported by this view
-
horizontalLayout: layoutSymbolH verticalLayout: layoutSymbolV
-
-
horizontalSpace
-
return the horizontal space between elements on pixels (default is 1mm)
-
horizontalSpace: numberOfPixels
-
set the horizontal space between elements on pixels (default is 1mm)
-
ignoreInvisibleComponents
-
return the flag which controls if invisible (unrealized)
components should be ignored in the layout computation.
By default, it is false, which means that invisible components will
lead to a visible space between visible components
-
ignoreInvisibleComponents: aBoolean
-
set/clears the flag which controls if invisible (unrealized)
components should be ignored in the layout computation.
By default, it is false, which means that invisible components will
lead to a visible space between visible components.
-
space: numberOfPixels
-
set the space between elements in pixels (default is 1mm) for both directions
-
verticalLayout
-
not supported by this view
-
verticalLayout: aLayoutSymbol
-
not supported by this view
-
verticalSpace
-
return the vertical space between elements on pixels (default is 1mm)
-
verticalSpace: numberOfPixels
-
set the vertical space between elements (in pixels).
The default is computed for 1mm spacing.
accessing-channels
-
backgroundChannel
-
return a valueHolder for background color
-
backgroundChannel: aValueHolder
-
set the backgroundChannel - a valueHolder holding a color
accessing-visibility
-
beVisible
-
after making the views visible check the vertical layout
Usage example(s):
self sensor enqueueMessage:#beVisiblePostUpdate for:self.
|
-
beVisiblePostUpdate
-
after making the views visible check the vertical layout; called by #beVisible
-
storePreferredWidthOrHeight: aWidthOrHeight for: aView
-
called by UISpecification #buildViewWithLayoutFor to setup up a specific view
adding & removing subviews
-
addComponent: aComponent
-
redefined to recompute layout when a component is added
-
addSubView: aView
-
redefined to recompute layout when a subview is added
-
addSubView: newView after: aViewOrNil
-
redefined to recompute layout when a subview is added
-
addSubView: newView before: aViewOrNil
-
redefined to recompute layout when a subview is added
-
removeSubView: aView
-
redefined to recompute layout when a subview is removed
change & update
-
update: something with: aParameter from: changedObject
-
an element changed its size
enumerating view hierarchy
-
changeSequenceOrderFor: aSubView to: anIndex
-
change a subview's position in the subviews collection.
This affects the arrangement of the views.
Usage example(s):
|panel comp1 comp2 comp3|
panel := HorizontalPanelView new.
comp1 := Label label:'one' in:panel.
comp2 := Label label:'two' in:panel.
comp3 := Label label:'three' in:panel.
panel open.
Delay waitForSeconds:3.
panel changeSequenceOrderFor:comp2 to:3.
Delay waitForSeconds:3.
panel changeSequenceOrderFor:comp2 to:1.
|
event handling
-
backgroundColorChanged
-
called to update the background color
-
sizeChanged: how from: oldExtentOrNil
-
my size has changed - must rearrange elements
focus handling
-
wantsFocusWithButtonPress
-
no, do not catch the keyboard focus on button click
initialization & release
-
initialize
-
must be called if redefined
-
mapped
-
(comment from inherited method)
the view has been mapped (by some outside
action - i.e. window manager de-iconified me)
-
realize
-
(comment from inherited method)
realize - make visible;
realizing is done very late (after layout is fixed) to avoid
visible rearranging of windows on the screen
-
release
-
(comment from inherited method)
remove all dependencies from the receiver
-
resize
-
(comment from inherited method)
resize myself to make everything fit into me.
Here, nothing special is done (except for setting my extent to the
preferredExtent), but may be redefined in some subclasses.
-
setChildPositionsIfChanged
-
set all of my child positions - this is usually delayed,
until the panel is actually shown (since we do not know, if more
elements are to be added) thus avoiding repositioning the elements
over and over. However, sometimes it is necessary to force positioning
the elements, for example, before querying the relative position of
an element (modalBoxes do so, to position the OK-button under the mouse
pointer).
layout
-
computePreferredExtent
-
return a good extent, one that makes subviews fit.
Note that width is considered as given, and compute height here.
-
setChildPositions
-
(re)compute position of every child.
This method is redefined for different layout characteristics - you may
even create subclasses with completely different geometry management.
Here, subviews are simply arranged in rows,
left to right, top to bottom,
starting a new row if the next child does not fit into the current row
(i.e. a rectangular grid, if all have the same height)
private
-
addedView: aView
-
added a new element - rearrange components
-
layoutChanged
-
called whenever repositioning is required.
If the panel view is already visible, reposition elements right now.
Otherwise, remember that a repositioning is needed to do so
when the view eventually becomes visible.
-
makeMyselfDependentOnSubviews
-
-
subViewsToConsider
-
return a collection of subviews which are to be considered in
the layout. If ignoreInvisibleComponents is true, only visible
components are considered; otherwise, all are considered.
queries
-
isHorizontal
-
are the subviews arranged horizontally
-
isLayoutWrapper
-
answer true, if this view defines the layout of it's subviews
The generic panelView simply tries to get its
components arranged for fitting them all into
its area. No special layout is done, except for
horizontal/vertical spacings.
The view is filled top-left to bottom-right
with subcomponents. Subcomponents are not resized.
example:
|v p b1 b2 b3|
v := StandardSystemView new.
v label:'panel'.
p := PanelView in:v.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
b1 := Button label:'button1' in:p.
b2 := Button label:'button2' in:p.
b3 := Button label:'button3' in:p.
v extent:300 @ 100.
v open
|
invisible component not considered in layout:
|v p b1 b2 b3|
v := StandardSystemView new.
v label:'panel'.
p := PanelView in:v.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
b1 := Button label:'button1' in:p.
b2 := Button label:'button2' in:p.
b2 beInvisible.
b3 := Button label:'button3' in:p.
v extent:300 @ 100.
v open
|
invisible component considered in layout:
|v p b1 b2 b3|
v := StandardSystemView new.
v label:'panel'.
p := PanelView in:v.
p origin:(0.0 @ 0.0) corner:(1.0 @ 1.0).
p ignoreInvisibleComponents:false.
b1 := Button label:'button1' in:p.
b2 := Button label:'button2' in:p.
b2 beInvisible.
b3 := Button label:'button3' in:p.
v extent:300 @ 100.
v open
|
|