|
Class: PanelView
Object
|
+--GraphicsMedium
|
+--DisplaySurface
|
+--SimpleView
|
+--PanelView
|
+--GridBagLayoutView
|
+--HorizontalPanelView
|
+--MultiColumnPanelView
|
+--VerticalPanelView
- Package:
- stx:libwidg
- Category:
- Views-Layout
- Version:
- rev:
1.59
date: 2019/05/30 09:20:59
- user: cg
- file: PanelView.st directory: libwidg
- module: stx stc-classLibrary: libwidg
- Author:
- Claus Gittinger
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.
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
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
enumerating subviews
-
changeSequenceOrderFor: aSubView to: anIndex
-
change a subview's position in the subviews collection.
This affects the arrangement of the views.
event handling
-
backgroundColorChanged
-
called to update the background color
-
sizeChanged: how
-
my size has changed - must rearrange elements
-
update: something with: aParameter from: changedObject
-
an element changed its size
focus handling
-
wantsFocusWithButtonPress
-
no, do not catch the keyboard focus on button click
initialization & release
-
initialize
-
must be called if redefined
-
mapped
-
-
realize
-
-
release
-
(comment from inherited method)
remove all dependencies from the receiver
-
resize
-
-
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.
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
-
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
|
|