eXept Software AG Logo

Smalltalk/X Webserver

Documentation of class 'AlignmentOrigin':

Home

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

Class: AlignmentOrigin


Inheritance:

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

Package:
stx:libview2
Category:
Graphics-Geometry
Version:
rev: 1.32 date: 2019/07/17 08:16:40
user: cg
file: AlignmentOrigin.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. Like a LayoutOrigin, it controls the components origin
via a relative part plus offset. However, in contrast to LayoutOrigin
(in which the top-left corner is specified by fraction+offset, here any
reference point within the component is positioned.
The reference point itself is specified as fraction of the components size.

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:

    LayoutOrigin
    LayoutFrame
    Layout
    View

Instance protocol:

accessing
o  leftAlignmentFraction
return leftAlignmentFraction

o  leftAlignmentFraction: something
set leftAlignmentFraction

o  leftAlignmentFraction: lF topAlignmentFraction: tF
set both leftAlignmentFraction and topAlignmentFraction

o  topAlignmentFraction
return topAlignmentFraction

o  topAlignmentFraction: something
set topAlignmentFraction

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  fromLiteralArrayEncoding: encodingArray
read my values from an encoding.
The encoding is supposed to be of the form:
(AlignmentOrigin orgOffsX relOrgX orgOffsY relOrgY leftAlignFract topAlignFract)

usage example(s):

      AlignmentOrigin new fromLiteralArrayEncoding:#(#AlignmentOrigin 70 0 2 0 0.5 0.25)

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

initialization
o  initialize
must be called if redefined

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

queries
o  isAlignmentOrigin
return true, if this is an alignmentOrigin


Examples:


Although the examples below use a button as component, they work of course with any type of subview .... using a LayoutOrigin, to control the top-left origins position of a component (i.e. 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
using an AlignmentOrigin, to control the centers position of a component (i.e. center of component at:0.5@0.5):
    |top button|

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

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

    top open
using an AlignmentOrigin, to control the bottom-right position of a component (i.e. bottom-right of component at:0.5@0.5):
    |top button|

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

    button := Button label:'component'.
    top add:button in:(AlignmentOrigin new
                            leftFraction:0.5;
                            topFraction:0.5;
                            leftAlignmentFraction:1.0;
                            topAlignmentFraction:1.0).

    top open
four buttons around relative 0.75@0.75:
    |top button|

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

    button := Button label:'button1'.
    top add:button in:(AlignmentOrigin new
                            leftFraction:0.75;
                            topFraction:0.75;
                            leftAlignmentFraction:1.0;
                            topAlignmentFraction:1.0).

    button := Button label:'button2'.
    top add:button in:(AlignmentOrigin new
                            leftFraction:0.75;
                            topFraction:0.75;
                            leftAlignmentFraction:0.0;
                            topAlignmentFraction:1.0).

    button := Button label:'button3'.
    top add:button in:(AlignmentOrigin new
                            leftFraction:0.75;
                            topFraction:0.75;
                            leftAlignmentFraction:1.0;
                            topAlignmentFraction:0.0).

    button := Button label:'button4'.
    top add:button in:(AlignmentOrigin new
                            leftFraction:0.75;
                            topFraction:0.75;
                            leftAlignmentFraction:0.0;
                            topAlignmentFraction:0.0).
    top open


ST/X 7.2.0.0; WebServer 1.670 at bd0aa1f87cdd.unknown:8081; Thu, 25 Apr 2024 09:24:40 GMT