eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'ViewScroller':

Home

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

Class: ViewScroller


Inheritance:

   Object
   |
   +--GraphicsMedium
      |
      +--DisplaySurface
         |
         +--SimpleView
            |
            +--ViewScroller

Package:
stx:libwidg2
Category:
Views-Basic
Version:
rev: 1.50 date: 2018/06/14 09:34:53
user: cg
file: ViewScroller.st directory: libwidg2
module: stx stc-classLibrary: libwidg2
Author:
Claus Gittinger

Description:


This wrapper view allows scrolling of views (in contrast to scrolling
of contents which can be done by any view).

Normally, scrolling is done by putting a view into a ScrollableView (which
simply wraps the scrollbars around) and have the scrollbars send scrollUp:/
scrollDown: etc. send to the scrolledView.
The default implementation of scrolling (in View) modifies the transformation,
and does a bit-copy of the contents with redraw of the exposed area.

However, there are situations, where you want to scroll a view itself.
For example, if you need many buttons in a panel, which do not fit.

This class provides the basic mechanism to implement this.
It is a wrapper, which implements scrolling by modifying the origin of its
single subview when asked to scroll. Thus, it can be put into a ScrollableView
like any other, but will move its subview when asked to scroll instead.
(i.e. reimplement all scroll messages by manipulating its subviews origin
 instead of its contents' transformation offset)

The subview should have a constant extent, which will be taken for the
scrollbar position/height computation.
Since the subview is represented directly by the underlying window systems view
implementation, there may be a limit on the maximum size of that view. For
example, in X, dimensions may not be larger than 32767 pixels.

[Instance variables:]
    model                <ValueHolder>      the model which keeps the current scrolledView.

    keepViewsChannel     <ValueHolder>      boolean holder; if the value is false (the default),
                                            the previous scrolled view is destroyed, whenever a
                                            new scrolled view is set. If true, it is unmapped and
                                            kept.
                                            Set this flag, if the application changes the scrolled
                                            view but wants them to be kept for fast switching.

    horizontalScrollStep <SmallInteger>     amount to scroll when stepping left/right in pixels
    verticalScrollStep   <SmallInteger>     amount to scroll when stepping up/down    in pixels

    frame                <SimpleView>       the one and only container of the visible scrolledView
                                            and all invisible scrolledViews if existent.

    scrolledView         <SimpleView | nil> the current scrolled view or nil


Related information:

    ScrollableView
    HVScrollableView

Instance protocol:

accessing
o  destroyAllClientViews
destroy all client views

o  keepViews
returns the value of the boolean channel: keepViewsChannel.
for more information see: #keepViewsChannel

o  keepViews: aBool
set the value of the boolean channel: keepViewsChannel.
for more information see: #keepViewsChannel:

o  resizeScrolledViewHorizontal

o  resizeScrolledViewHorizontal: aBoolean
if true, the scrolled view is actually NOT scrolled horizontally,
but instead always resized to fit.
Set this, if only vertical scrollability is wanted (i.e. the view
itself does adjust its size horizontally (for example, in a settings dialog,
the subcanvas to be enbedded has a horizontal panel, taking all of the space)

o  resizeScrolledViewVertical

o  resizeScrolledViewVertical: aBoolean
if true, the scrolled view is actually NOT scrolled vertically,
but instead always resized to fit.
Set this, if only horizontal scrollability is wanted (i.e. the view
itself does adjust its size vertically (for example, in a settings dialog,
the subcanvas to be enbedded has a vertical panel, taking all of the space)

o  scrolledView
return the view which is scrolled

o  scrolledView: aView
set a new scolled view; dependent on the #keepViewsChannel
the old scolled view will be destroyed or unmapped.

o  scrolledViews
Returns the collection of all scrolled views including the current scrolled view
and all unmapped scrolled views.

accessing-channels
o  keepViewsChannel
boolean holder; if the value is false (the default), the previous scrolled view is
destroyed, whenever a new scrolled view is set. if true, it is unmapped and kept.
Set this flag, if the application changes the scrolled view but wants
them to be kept for fast switching.

o  keepViewsChannel: aHolder
boolean holder; if the value is false (the default), the previous scrolled view is
destroyed, whenever a new scrolled view is set. if true, it is unmapped and kept.
Set this flag, if the application changes the scrolled view but wants
them to be kept for fast switching.

o  model
value holder, which keeps the current scrolledView or nil

o  model: aHolder
value holder, which keeps the current scrolledView or nil

accessing-look
o  horizontalScrollStep: something
set the value of the instance variable 'horizontalScrollStep' (automatically generated)

o  verticalScrollStep: something
set the value of the instance variable 'verticalScrollStep' (automatically generated)

change & update
o  resizeScrolledView
forces a recomputation of the scrolled view's size

o  update: something with: aParameter from: changedObject
update possible scrollers

delegation
o  viewBackground: aColor

event handling
o  processEvent: anEvent
return true, if the event was eaten

o  repositionScrolledView
Reposition the scrolledView, if required

o  sizeChanged: how
my size changed. Reposition the scrolledView, if required

focus handling
o  canTab

initialization & release
o  initialize
initialize all models of the view

o  realize

o  release
release all dependencies

queries-contents
o  heightOfContents
return my contents' height; this is the scrolledViews height

o  viewOrigin
the viewOrigin (for scrollBars) is based upon the scrolledView's origin

o  widthOfContents
return my contents' width; this is the scrolledViews width

scrolling
o  horizontalScrollStep
return the amount by which to step-scroll horizontally

o  scrollTo: aPoint redraw: doRedraw
change origin of scrolledView to scroll to aPoint

o  verticalScrollStep
return the amount by which to step-scroll vertically


Examples:


scroll a panel of buttons:
  |top frame vscroller v panel|

  top := StandardSystemView new.
  top extent:100@400.

  frame := ScrollableView for:ViewScroller in:top.
  frame origin:0.0 @ 0.0 corner:1.0 @ 1.0.

  vscroller := frame scrolledView.
  panel := VerticalPanelView new.
  panel horizontalLayout:#fit.
  1 to:100 do:[:i |
      Button label:(i printString) in:panel
  ].
  vscroller scrolledView:panel.
  top open.
same, defining what a scroll step is:
  |top frame vscroller v panel|

  top := StandardSystemView new.
  top extent:100@400.

  frame := ScrollableView for:ViewScroller in:top.
  frame origin:0.0 @ 0.0 corner:1.0 @ 1.0.

  vscroller := frame scrolledView.
  vscroller verticalScrollStep:20.
  panel := VerticalPanelView new.
  panel horizontalLayout:#fit.
  1 to:100 do:[:i |
      Button label:(i printString) in:panel
  ].
  vscroller scrolledView:panel.
  top open.
same, horizontally. Also change layout in panel for nicer look and make panel adjust its height: (since the buttons are defined to fill vertically, the vertical scrollbar is useless here - its here as example; not for its function)
  |top frame vscroller v panel|

  top := StandardSystemView new.
  top extent:300@100.

  frame := HVScrollableView for:ViewScroller in:top.
  frame origin:0.0 @ 0.0 corner:1.0 @ 1.0.

  vscroller := frame scrolledView.
  panel := HorizontalPanelView new.
  panel verticalLayout:#fit.
  panel horizontalLayout:#fit.
  1 to:100 do:[:i |
      Button label:(i printString) in:panel
  ].
  vscroller scrolledView:panel.
  panel height:1.0.
  top open.
scroll a panel of buttons and other views: (not good looking, but a demo that it can be done ...)
  |top frame vscroller v panel textView1 textView2|

  top := StandardSystemView new.

  frame := HVScrollableView for:ViewScroller in:top.
  frame origin:0.0 @ 0.0 corner:1.0 @ 1.0.

  vscroller := frame scrolledView.

  panel := VerticalPanelView new.
  panel horizontalLayout:#leftSpace.
  panel extent:1.0@1.0.

  textView1 := ScrollableView for:EditTextView in:panel.
  textView1 extent:1.0 @ 300.
  textView1 scrolledView contents:('keyboard.rc' asFilename readStream contents).

  textView2 := ScrollableView for:EditTextView in:panel.
  textView2 extent:500 @ 300.
  textView2 scrolledView contents:('Make.proto' asFilename readStream contents).

  1 to:100 do:[:i |
      Button label:(i printString) in:panel
  ].
  vscroller resizeScrolledViewHorizontal:true.
  vscroller scrolledView:panel.
  
  top open.


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Fri, 06 Dec 2019 07:53:37 GMT