eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'LayoutOrigin':

Home

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

Class: LayoutOrigin


Inheritance:

   Object
   |
   +--Layout
      |
      +--LayoutOrigin
         |
         +--AlignmentOrigin
         |
         +--LayoutFrame

Package:
stx:libview2
Category:
Graphics-Geometry
Version:
rev: 1.32 date: 2019/07/17 08:16:05
user: cg
file: LayoutOrigin.st directory: libview2
module: stx stc-classLibrary: libview2
Author:
Claus Gittinger

Description:


This class is provided to make porting of existing ST-80 applications
easier. Instances can be used to control the geometry of a subview, within
its superview. It provides the same functionality as a relative origin
combined with insets.
A layoutOrigin controls the origin of a subcomponent, given a fractional
component and an offset component.

Notice: 
    this class was implemented using protocol information
    from alpha testers - it may not be complete or compatible to
    the corresponding ST-80 class. 
    If you encounter any incompatibilities, please forward a note 
    describing the incompatibility verbal (i.e. no code) to the ST/X team.


Related information:

    View
    LayoutFrame
    AlignmentOrigin
    Layout
    Rectangle
    Point

Class protocol:

instance creation
o  fractionalFromPoint: aPoint
given a point, create a layoutOrigin representing the same
relative origin.

usage example(s):

     LayoutOrigin fractionalFromPoint:0.5@0.5

o  fromPoint: aPoint
return a new LayoutOrigin from aPoint.
If the coordinates are between 0 and 1,
take them as fractional parts (relative to superview).
Otherwise, treat them as absolute offsets.

usage example(s):

     LayoutOrigin fromPoint:100@100
     LayoutOrigin fromPoint:0.5@0.5
     LayoutOrigin fromPoint:0.5@100

o  offsetFromPoint: aPoint
given a point, create a layoutOrigin representing the same
absolute (pixel) origin.

usage example(s):

     LayoutOrigin offsetFromPoint:100@100


Instance protocol:

accessing
o  leftFraction
return leftFraction

o  leftFraction: something
set leftFraction

o  leftFraction: something offset: o
set leftFraction and offset

o  leftFraction: lF offset: lO topFraction: tF offset: tO
set leftFraction, leftOffset, topFraction and topOffset

o  leftFraction: newLeft topFraction: newTop
set leftFraction and topFraction

o  leftInset: pixels
set leftOffset for an inset at the left

o  leftOffset
return leftOffset

o  leftOffset: something
set leftOffset

o  leftOffset: newLeft topOffset: newTop
set leftOffset and topOffset

o  topFraction
return topFraction

o  topFraction: something
set topFraction

o  topFraction: something offset: o
set topFraction and offset

o  topInset: pixels
set topOffset for an inset at the top

o  topOffset
return topOffset

o  topOffset: something
set topOffset

comparing
o  = anObject

o  hash

computing
o  rectangleRelativeTo: superRectangle preferred: prefRectHolder
compute the rectangle represented by the receiver,
given the superView's rectangle and the view's preferredExtent.

converting
o  asAlignmentOrigin
return an equivalent alignmentOrigin

o  fromLiteralArrayEncoding: encoding
read my values from an encoding.
The encoding is supposed to be of the form:
(#LayoutOrigin orgOffsX relOrgX orgOffsY relOrgY)
This is the reverse operation to #literalArrayEncoding.

usage example(s):

      LayoutOrigin new fromLiteralArrayEncoding:#(#LayoutOrigin 70 0 2 0)

o  literalArrayEncoding
encode myself as an array, from which a copy of the receiver
can be reconstructed with #decodeAsLiteralArray.
The encoding is:
(#LayoutOrigin orgOffsX relOrgX orgOffsY relOrgY)

usage example(s):

      LayoutOrigin new fromLiteralArrayEncoding:#(#LayoutOrigin 70 0 2 0)
      (LayoutOrigin new leftOffset:10; leftFraction:0.2;
                       topOffset:20; topFraction:0.4) literalArrayEncoding 

initialization
o  initialize
(comment from inherited method)
setup the instance - to be redefined by concrete subclasses

printing & storing
o  displayOn: aGCOrStream
return a printed representation of the receiver for displaying

queries
o  isLayoutOrigin
return true, if this is a layoutOrigin

o  origin


Examples:


Although the examples below use a button as component, they work of course with any type of subview .... using a LayoutOrigin, to arrange for the TOPLEFT of a component be positions at the center (i.e. buttons origin at:0.5 @ 0.5):
    |top button|

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

    button := Button label:'component'.
    top add:button in:(LayoutOrigin new
                            leftFraction:0.5;
                            topFraction:0.5).

    top open
like above, but adds an additional offset: (i.e. center of button at:0.5 @ 0.5 OFFSET by 10 @ 20):
    |top button|

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

    button := Button label:'component'.
    top add:button in:(LayoutOrigin new
                            leftFraction:0.5;
                            topFraction:0.5;
                            leftOffset:10;
                            topOffset:20).

    top open


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Sun, 19 Jan 2020 17:02:25 GMT