eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'PanelView':

Home

Documentation
www.exept.de
Everywhere
for:
[back]

Class: PanelView


Inheritance:

   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

Description:


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.

copyright

COPYRIGHT (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.

Instance protocol:

accessing
o  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.

o  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.

o  hierarchicalIndexOfChild: aView

o  horizontalLayout
not supported by this view

o  horizontalLayout: aLayoutSymbol
not supported by this view

o  horizontalLayout: layoutSymbolH verticalLayout: layoutSymbolV

o  horizontalSpace
return the horizontal space between elements on pixels (default is 1mm)

o  horizontalSpace: numberOfPixels
set the horizontal space between elements on pixels (default is 1mm)

o  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

o  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.

o  space: numberOfPixels
set the space between elements in pixels (default is 1mm) for both directions

o  verticalLayout
not supported by this view

o  verticalLayout: aLayoutSymbol
not supported by this view

o  verticalSpace
return the vertical space between elements on pixels (default is 1mm)

o  verticalSpace: numberOfPixels
set the vertical space between elements (in pixels).
The default is computed for 1mm spacing.

accessing-channels
o  backgroundChannel
return a valueHolder for background color

o  backgroundChannel: aValueHolder
set the backgroundChannel - a valueHolder holding a color

accessing-visibility
o  beVisible
after making the views visible check the vertical layout

Usage example(s):

self sensor enqueueMessage:#beVisiblePostUpdate for:self.

o  beVisiblePostUpdate
after making the views visible check the vertical layout; called by #beVisible

o  storePreferredWidthOrHeight: aWidthOrHeight for: aView
called by UISpecification #buildViewWithLayoutFor to setup up a specific view

adding & removing subviews
o  addComponent: aComponent
redefined to recompute layout when a component is added

o  addSubView: aView
redefined to recompute layout when a subview is added

o  addSubView: newView after: aViewOrNil
redefined to recompute layout when a subview is added

o  addSubView: newView before: aViewOrNil
redefined to recompute layout when a subview is added

o  removeSubView: aView
redefined to recompute layout when a subview is removed

change & update
o  update: something with: aParameter from: changedObject
an element changed its size

enumerating view hierarchy
o  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
o  backgroundColorChanged
called to update the background color

o  sizeChanged: how from: oldExtentOrNil
my size has changed - must rearrange elements

focus handling
o  wantsFocusWithButtonPress
no, do not catch the keyboard focus on button click

initialization & release
o  initialize
must be called if redefined

o  mapped
(comment from inherited method)
the view has been mapped (by some outside
action - i.e. window manager de-iconified me)

o  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

o  release
(comment from inherited method)
remove all dependencies from the receiver

o  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.

o  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
o  computePreferredExtent
return a good extent, one that makes subviews fit.
Note that width is considered as given, and compute height here.

o  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
o  addedView: aView
added a new element - rearrange components

o  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.

o  makeMyselfDependentOnSubviews

o  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
o  isHorizontal
are the subviews arranged horizontally

o  isLayoutWrapper
answer true, if this view defines the layout of it's subviews


Examples:


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


ST/X 7.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 21 Dec 2024 17:16:51 GMT