AlignmentOrigin.st
author Claus Gittinger <cg@exept.de>
Wed, 08 May 1996 21:54:36 +0200
changeset 244 74c365cb546a
parent 243 dfbfd389ec48
child 379 62b71a8294a3
permissions -rw-r--r--
checkin from browser
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
88
claus
parents: 83
diff changeset
     1
"
claus
parents: 83
diff changeset
     2
 COPYRIGHT (c) 1995 by Claus Gittinger
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
     3
	      All Rights Reserved
88
claus
parents: 83
diff changeset
     4
claus
parents: 83
diff changeset
     5
 This software is furnished under a license and may be used
claus
parents: 83
diff changeset
     6
 only in accordance with the terms of that license and with the
claus
parents: 83
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
claus
parents: 83
diff changeset
     8
 be provided or otherwise made available to, or used by, any
claus
parents: 83
diff changeset
     9
 other person.  No title to or ownership of the software is
claus
parents: 83
diff changeset
    10
 hereby transferred.
claus
parents: 83
diff changeset
    11
"
claus
parents: 83
diff changeset
    12
83
claus
parents:
diff changeset
    13
LayoutOrigin subclass:#AlignmentOrigin
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    14
	instanceVariableNames:'leftAlignmentFraction topAlignmentFraction'
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    15
	classVariableNames:''
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    16
	poolDictionaries:''
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    17
	category:'Graphics-Geometry'
83
claus
parents:
diff changeset
    18
!
claus
parents:
diff changeset
    19
88
claus
parents: 83
diff changeset
    20
!AlignmentOrigin class methodsFor:'documentation'!
claus
parents: 83
diff changeset
    21
claus
parents: 83
diff changeset
    22
copyright
claus
parents: 83
diff changeset
    23
"
claus
parents: 83
diff changeset
    24
 COPYRIGHT (c) 1995 by Claus Gittinger
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    25
	      All Rights Reserved
88
claus
parents: 83
diff changeset
    26
claus
parents: 83
diff changeset
    27
 This software is furnished under a license and may be used
claus
parents: 83
diff changeset
    28
 only in accordance with the terms of that license and with the
claus
parents: 83
diff changeset
    29
 inclusion of the above copyright notice.   This software may not
claus
parents: 83
diff changeset
    30
 be provided or otherwise made available to, or used by, any
claus
parents: 83
diff changeset
    31
 other person.  No title to or ownership of the software is
claus
parents: 83
diff changeset
    32
 hereby transferred.
claus
parents: 83
diff changeset
    33
"
claus
parents: 83
diff changeset
    34
!
claus
parents: 83
diff changeset
    35
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    36
documentation
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    37
"
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    38
    This class is provided to make porting of existing ST-80 applications
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    39
    easier. Instances can be used to control the geometry of a subview, within
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    40
    its superview. Like a LayoutOrigin, it controls the components origin
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    41
    via a relative part plus offset. However, in contrast to LayoutOrigin
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    42
    (in which the top-left corner is specified by fraction+offset, here any
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    43
    reference point within the component is positioned.
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    44
    The reference point itself is specified as fraction of the components size.
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    45
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    46
    Notice: 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    47
        this class was implemented using protocol information
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    48
        from alpha testers - it may not be complete or compatible to
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    49
        the corresponding ST-80 class. 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    50
        If you encounter any incompatibilities, please forward a note 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    51
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
216
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    52
219
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    53
    [author:]
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    54
        Claus Gittinger
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 216
diff changeset
    55
216
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    56
    [See also:]
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    57
        LayoutOrigin LayoutFrame Layout
a5f97668e99a commentary
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    58
        View
94
8888ddd11323 *** empty log message ***
claus
parents: 93
diff changeset
    59
"
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    60
!
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    61
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    62
examples
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    63
"
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    64
    Although the examples below use a button as component,
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    65
    they work of course with any type of subview ....
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    66
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    67
    using a LayoutOrigin, to control the top-left origins position of
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    68
    a component (i.e. origin at:0.5@0.5):
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    69
                                                                        [exBegin]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    70
        |top button|
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    71
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    72
        top := StandardSystemView new.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    73
        top extent:300@300.
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    74
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    75
        button := Button label:'component'.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    76
        top add:button in:(LayoutOrigin new
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    77
                                leftFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    78
                                topFraction:0.5).
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    79
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    80
        top open
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    81
                                                                        [exEnd]
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    82
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    83
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    84
    using an AlignmentOrigin, to control the centers position of
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    85
    a component (i.e. center of component at:0.5@0.5):
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    86
                                                                        [exBegin]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    87
        |top button|
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    88
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    89
        top := StandardSystemView new.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    90
        top extent:300@300.
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    91
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    92
        button := Button label:'component'.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    93
        top add:button in:(AlignmentOrigin new
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    94
                                leftFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    95
                                topFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    96
                                leftAlignmentFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    97
                                topAlignmentFraction:0.5).
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    98
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    99
        top open
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   100
                                                                        [exEnd]
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   101
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   102
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   103
    using an AlignmentOrigin, to control the bottom-right position of
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   104
    a component (i.e. bottom-right of component at:0.5@0.5):
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   105
                                                                        [exBegin]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   106
        |top button|
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   107
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   108
        top := StandardSystemView new.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   109
        top extent:300@300.
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   110
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   111
        button := Button label:'component'.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   112
        top add:button in:(AlignmentOrigin new
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   113
                                leftFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   114
                                topFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   115
                                leftAlignmentFraction:1.0;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   116
                                topAlignmentFraction:1.0).
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   117
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   118
        top open
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   119
                                                                        [exEnd]
243
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   120
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   121
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   122
    four buttons around relative 0.75@0.75:
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   123
                                                                        [exBegin]
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   124
        |top button|
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   125
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   126
        top := StandardSystemView new.
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   127
        top extent:300@300.
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   128
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   129
        button := Button label:'button1'.
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   130
        top add:button in:(AlignmentOrigin new
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   131
                                leftFraction:0.75;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   132
                                topFraction:0.75;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   133
                                leftAlignmentFraction:1.0;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   134
                                topAlignmentFraction:1.0).
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   135
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   136
        button := Button label:'button2'.
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   137
        top add:button in:(AlignmentOrigin new
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   138
                                leftFraction:0.75;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   139
                                topFraction:0.75;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   140
                                leftAlignmentFraction:0.0;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   141
                                topAlignmentFraction:1.0).
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   142
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   143
        button := Button label:'button3'.
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   144
        top add:button in:(AlignmentOrigin new
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   145
                                leftFraction:0.75;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   146
                                topFraction:0.75;
244
74c365cb546a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   147
                                leftAlignmentFraction:1.0;
243
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   148
                                topAlignmentFraction:0.0).
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   149
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   150
        button := Button label:'button4'.
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   151
        top add:button in:(AlignmentOrigin new
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   152
                                leftFraction:0.75;
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   153
                                topFraction:0.75;
244
74c365cb546a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   154
                                leftAlignmentFraction:0.0;
243
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   155
                                topAlignmentFraction:0.0).
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   156
        top open
dfbfd389ec48 another example
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   157
                                                                        [exEnd]
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   158
"
88
claus
parents: 83
diff changeset
   159
! !
claus
parents: 83
diff changeset
   160
83
claus
parents:
diff changeset
   161
!AlignmentOrigin methodsFor:'accessing'!
claus
parents:
diff changeset
   162
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   163
leftAlignmentFraction
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   164
    "return leftAlignmentFraction"
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   165
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   166
    ^ leftAlignmentFraction
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   167
!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   168
83
claus
parents:
diff changeset
   169
leftAlignmentFraction:something
claus
parents:
diff changeset
   170
    "set leftAlignmentFraction"
claus
parents:
diff changeset
   171
claus
parents:
diff changeset
   172
    leftAlignmentFraction := something.
claus
parents:
diff changeset
   173
!
claus
parents:
diff changeset
   174
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   175
topAlignmentFraction
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   176
    "return topAlignmentFraction"
83
claus
parents:
diff changeset
   177
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   178
    ^ topFraction
83
claus
parents:
diff changeset
   179
!
claus
parents:
diff changeset
   180
claus
parents:
diff changeset
   181
topAlignmentFraction:something
claus
parents:
diff changeset
   182
    "set topAlignmentFraction"
claus
parents:
diff changeset
   183
claus
parents:
diff changeset
   184
    topAlignmentFraction := something.
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   185
! !
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   186
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   187
!AlignmentOrigin methodsFor:'converting'!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   188
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   189
fromLiteralArrayEncoding:encoding
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   190
    "read my values from an encoding.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   191
     The encoding is supposed to be of the form: 
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   192
	(AlignmentOrigin orgOffsX relOrgX orgOffsY relOrgY leftAlignFract topAlignFract)"
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   193
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   194
    leftOffset := encoding at:2.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   195
    leftFraction := encoding at:3.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   196
    topOffset := encoding at:4.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   197
    topFraction := encoding at:5.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   198
    leftAlignmentFraction := encoding at:6.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   199
    topAlignmentFraction := encoding at:7.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   200
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   201
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   202
    "
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   203
      AlignmentOrigin new fromLiteralArrayEncoding:#(#AlignmentOrigin 70 0 2 0 0.5 0.25)
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   204
    "
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   205
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   206
    "Modified: 1.9.1995 / 02:23:53 / claus"
83
claus
parents:
diff changeset
   207
!
claus
parents:
diff changeset
   208
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   209
literalArrayEncoding
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   210
    "encode myself as an array, from which a copy of the receiver
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   211
     can be reconstructed with #decodeAsLiteralArray.
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   212
     The encoding is: 
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   213
        (#AlignmentOrigin orgOffsX relOrgX orgOffsY relOrgY leftAlignFract topAlignFract)"
83
claus
parents:
diff changeset
   214
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   215
    ^ super literalArrayEncoding
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   216
      , (Array
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   217
            with:leftAlignmentFraction
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   218
            with:topAlignmentFraction)
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   219
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   220
    "Modified: 1.9.1995 / 02:43:35 / claus"
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   221
    "Modified: 22.4.1996 / 12:59:56 / cg"
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   222
! !
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   223
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   224
!AlignmentOrigin methodsFor:'initialization'!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   225
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   226
initialize
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   227
    super initialize.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   228
    leftAlignmentFraction := topAlignmentFraction := 0.
83
claus
parents:
diff changeset
   229
! !
claus
parents:
diff changeset
   230
claus
parents:
diff changeset
   231
!AlignmentOrigin methodsFor:'printing & storing'!
claus
parents:
diff changeset
   232
claus
parents:
diff changeset
   233
displayString
claus
parents:
diff changeset
   234
    ^ 'LayoutOrigin(' 
claus
parents:
diff changeset
   235
	, 'l: ' , leftFraction displayString
claus
parents:
diff changeset
   236
	, '+' , leftOffset displayString
claus
parents:
diff changeset
   237
	, ' t: ' , topFraction displayString
claus
parents:
diff changeset
   238
	, '+' , topOffset displayString
claus
parents:
diff changeset
   239
	, ' a: ' , leftAlignmentFraction displayString
claus
parents:
diff changeset
   240
	, '@' , topAlignmentFraction displayString
claus
parents:
diff changeset
   241
	, ')'
claus
parents:
diff changeset
   242
! !
claus
parents:
diff changeset
   243
claus
parents:
diff changeset
   244
!AlignmentOrigin methodsFor:'queries'!
claus
parents:
diff changeset
   245
claus
parents:
diff changeset
   246
rectangleRelativeTo:superRectangle preferred:prefRect
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   247
    "compute the rectangle represented by the receiver,
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   248
     given the superViews rectangle and the views preferredExtent."
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   249
83
claus
parents:
diff changeset
   250
    |x y|
claus
parents:
diff changeset
   251
claus
parents:
diff changeset
   252
    leftOffset isNil ifTrue:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   253
        x := 0
83
claus
parents:
diff changeset
   254
    ] ifFalse:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   255
        x := leftOffset
83
claus
parents:
diff changeset
   256
    ].
claus
parents:
diff changeset
   257
    topOffset isNil ifTrue:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   258
        y := 0
83
claus
parents:
diff changeset
   259
    ] ifFalse:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   260
        y := topOffset
83
claus
parents:
diff changeset
   261
    ].
claus
parents:
diff changeset
   262
    leftFraction notNil ifTrue:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   263
        x := x + (superRectangle width * leftFraction)
83
claus
parents:
diff changeset
   264
    ].
claus
parents:
diff changeset
   265
    topFraction notNil ifTrue:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   266
        y := y + (superRectangle height * topFraction)
83
claus
parents:
diff changeset
   267
    ].
claus
parents:
diff changeset
   268
    leftAlignmentFraction ~~ 0 ifTrue:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   269
        x := x - (prefRect width * leftAlignmentFraction)
83
claus
parents:
diff changeset
   270
    ].
claus
parents:
diff changeset
   271
    topAlignmentFraction ~~ 0 ifTrue:[
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   272
        y := y - (prefRect height * topAlignmentFraction)
83
claus
parents:
diff changeset
   273
    ].
242
5b7f59450c65 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 229
diff changeset
   274
    ^ Rectangle left:x top:y extent:prefRect extent
83
claus
parents:
diff changeset
   275
claus
parents:
diff changeset
   276
    "
claus
parents:
diff changeset
   277
     |superRect aO|
claus
parents:
diff changeset
   278
claus
parents:
diff changeset
   279
     superRect := 0@0 corner:100@100.
claus
parents:
diff changeset
   280
     aO := (AlignmentOrigin new).
claus
parents:
diff changeset
   281
     aO leftFraction:0.5;
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   282
        topFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   283
        leftAlignmentFraction:0.5;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   284
        topAlignmentFraction:0.5.
83
claus
parents:
diff changeset
   285
     aO rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) 
claus
parents:
diff changeset
   286
    "
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   287
242
5b7f59450c65 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 229
diff changeset
   288
    "Modified: 8.5.1996 / 20:57:09 / cg"
83
claus
parents:
diff changeset
   289
! !
claus
parents:
diff changeset
   290
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   291
!AlignmentOrigin class methodsFor:'documentation'!
100
claus
parents: 96
diff changeset
   292
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   293
version
244
74c365cb546a checkin from browser
Claus Gittinger <cg@exept.de>
parents: 243
diff changeset
   294
    ^ '$Header: /cvs/stx/stx/libview2/AlignmentOrigin.st,v 1.15 1996-05-08 19:54:36 cg Exp $'
100
claus
parents: 96
diff changeset
   295
! !