|
Class: LayoutOrigin
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
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.
View
LayoutFrame
AlignmentOrigin
Layout
Rectangle
Point
instance creation
-
fractionalFromPoint: aPoint
-
given a point, create a layoutOrigin representing the same
relative origin.
usage example(s):
LayoutOrigin fractionalFromPoint:0.5@0.5
|
-
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
|
-
offsetFromPoint: aPoint
-
given a point, create a layoutOrigin representing the same
absolute (pixel) origin.
usage example(s):
LayoutOrigin offsetFromPoint:100@100
|
accessing
-
leftFraction
-
return leftFraction
-
leftFraction: something
-
set leftFraction
-
leftFraction: something offset: o
-
set leftFraction and offset
-
leftFraction: lF offset: lO topFraction: tF offset: tO
-
set leftFraction, leftOffset, topFraction and topOffset
-
leftFraction: newLeft topFraction: newTop
-
set leftFraction and topFraction
-
leftInset: pixels
-
set leftOffset for an inset at the left
-
leftOffset
-
return leftOffset
-
leftOffset: something
-
set leftOffset
-
leftOffset: newLeft topOffset: newTop
-
set leftOffset and topOffset
-
topFraction
-
return topFraction
-
topFraction: something
-
set topFraction
-
topFraction: something offset: o
-
set topFraction and offset
-
topInset: pixels
-
set topOffset for an inset at the top
-
topOffset
-
return topOffset
-
topOffset: something
-
set topOffset
comparing
-
= anObject
-
-
hash
-
computing
-
rectangleRelativeTo: superRectangle preferred: prefRectHolder
-
compute the rectangle represented by the receiver,
given the superView's rectangle and the view's preferredExtent.
converting
-
asAlignmentOrigin
-
return an equivalent alignmentOrigin
-
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)
|
-
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
-
initialize
-
(comment from inherited method)
setup the instance - to be redefined by concrete subclasses
printing & storing
-
displayOn: aGCOrStream
-
return a printed representation of the receiver for displaying
queries
-
isLayoutOrigin
-
return true, if this is a layoutOrigin
-
origin
-
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
|
|