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.35 date: 2022/01/12 17:32:51
user: cg
file: LayoutOrigin.st directory: libview2
module: stx stc-classLibrary: libview2

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.

copyright

COPYRIGHT (c) 1995 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.

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: aFraction
set leftFraction (0..1)

o  leftFraction: aFraction offset: o
set leftFraction (0..1) and offset in pixels

o  leftFraction: lF offset: lO topFraction: tF offset: tO
set leftFraction (0..1), leftOffset, topFraction (0..1) and topOffset

o  leftFraction: newLeft topFraction: newTop
set leftFraction (0..1) and topFraction (0..1)

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  offset: aPoint
set both left and top offsets

o  topFraction
return topFraction

o  topFraction: aFraction
set topFraction (0..1)

o  topFraction: aFraction offset: o
set topFraction (0..1) 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
(comment from inherited method)
return true if the receiver and the arg have the same structure.
Notice:
This method is partially open coded (inlined) by the compiler(s)
identical objects are always considered equal.
redefining it may not work as expected.

o  hash
(comment from inherited method)
return an Integer useful as a hash key for the receiver.
This hash should return same values for objects with same
contents (i.e. use this to hash on structure)

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

Usage example(s):

     |superRect lO|

     superRect := 0@0 corner:100@100.
     lO := (LayoutOrigin new).
     lO leftFraction:0.5;
        topFraction:0.5.
     lO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30)

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.7.0.0; WebServer 1.702 at 20f6060372b9.unknown:8081; Sat, 27 Jul 2024 04:14:40 GMT