LayoutFrame.st
author Claus Gittinger <cg@exept.de>
Sun, 25 Oct 2009 02:21:08 +0200
changeset 2777 4cdef981fdb3
parent 2765 827160ff9feb
child 2839 8fd092da727e
permissions -rw-r--r--
changed: #initiateHelpFor:at:now:
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
"
1594
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
    12
"{ Package: 'stx:libview2' }"
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
    13
77
claus
parents:
diff changeset
    14
LayoutOrigin subclass:#LayoutFrame
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    15
	instanceVariableNames:'rightFraction bottomFraction rightOffset bottomOffset'
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    16
	classVariableNames:''
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    17
	poolDictionaries:''
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
    18
	category:'Graphics-Geometry'
77
claus
parents:
diff changeset
    19
!
claus
parents:
diff changeset
    20
88
claus
parents: 83
diff changeset
    21
!LayoutFrame class methodsFor:'documentation'!
claus
parents: 83
diff changeset
    22
claus
parents: 83
diff changeset
    23
copyright
claus
parents: 83
diff changeset
    24
"
claus
parents: 83
diff changeset
    25
 COPYRIGHT (c) 1995 by Claus Gittinger
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    26
	      All Rights Reserved
88
claus
parents: 83
diff changeset
    27
claus
parents: 83
diff changeset
    28
 This software is furnished under a license and may be used
claus
parents: 83
diff changeset
    29
 only in accordance with the terms of that license and with the
claus
parents: 83
diff changeset
    30
 inclusion of the above copyright notice.   This software may not
claus
parents: 83
diff changeset
    31
 be provided or otherwise made available to, or used by, any
claus
parents: 83
diff changeset
    32
 other person.  No title to or ownership of the software is
claus
parents: 83
diff changeset
    33
 hereby transferred.
claus
parents: 83
diff changeset
    34
"
claus
parents: 83
diff changeset
    35
!
claus
parents: 83
diff changeset
    36
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    37
documentation
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    38
"
2763
519c58d279d9 changed: #documentation
Claus Gittinger <cg@exept.de>
parents: 2762
diff changeset
    39
    This class is provided to make porting of existing ST-80/Squeak applications
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    40
    easier. Instances can be used to control the geometry of a subview, within
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    41
    its superview. Like a layoutOrigin, it controls the origin of a component
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    42
    by given fraction and offset dimensions; in addition, the bottom-right
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    43
    corner is also controlled by corresponding values. Therefore, the components
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    44
    preferredExtent is ignored.
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    45
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    46
    See also:
219
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    47
        LayoutOrigin AlignmentOrigin Layout
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    48
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    49
    Notice: 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    50
        this class was implemented using protocol information
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    51
        from alpha testers - it may not be complete or compatible to
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    52
        the corresponding ST-80 class. 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    53
        If you encounter any incompatibilities, please forward a note 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    54
        describing the incompatibility verbal (i.e. no code) to the ST/X team.
219
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    55
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    56
    [author:]
106b86ca81da documentation
Claus Gittinger <cg@exept.de>
parents: 191
diff changeset
    57
        Claus Gittinger
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    58
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    59
    [see also:]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    60
        View
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    61
        LayoutOrigin AlignmentOrigin Layout 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    62
        Rectangle Point
94
8888ddd11323 *** empty log message ***
claus
parents: 93
diff changeset
    63
"
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    64
!
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    65
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    66
examples
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    67
"
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    68
    Although the examples below use a button as component,
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    69
    they work of course with any type of subview ....
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    70
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    71
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    72
    arrange for the button to be in 0.25 @ 0.25 -> 0.75 @ 0.75.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    73
    This is the same as with relative origin/corner.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    74
                                                                        [exBegin]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    75
        |top button|
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    76
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    77
        top := StandardSystemView new.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    78
        top extent:300@300.
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    79
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    80
        button := Button label:'component'.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    81
        top add:button in:(LayoutFrame new
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    82
                                leftFraction:0.25;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    83
                                topFraction:0.25;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    84
                                rightFraction:0.75;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    85
                                bottomFraction:0.75).
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    86
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    87
        top open
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    88
                                                                        [exEnd]
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    89
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    90
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    91
    like above, but adds additional offset to the origin:
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    92
    This is the same as with relative origin/corner
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    93
    and setting left & right insets.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    94
                                                                        [exBegin]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    95
        |top button|
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    96
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    97
        top := StandardSystemView new.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
    98
        top extent:300@300.
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
    99
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   100
        button := Button label:'component'.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   101
        top add:button in:(LayoutFrame new
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   102
                                leftFraction:0.25; leftOffset:10;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   103
                                topFraction:0.25;  topOffset:-20;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   104
                                rightFraction:0.75;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   105
                                bottomFraction:0.75).
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   106
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   107
        top open
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   108
                                                                        [exEnd]
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   109
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   110
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   111
    like above, with offsets on all edges, 
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   112
    actually simulating a constant inset on all four edges:
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   113
                                                                        [exBegin]
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   114
        |top button|
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   115
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   116
        top := StandardSystemView new.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   117
        top extent:300@300.
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   118
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   119
        button := Button label:'component'.
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   120
        top add:button in:(LayoutFrame new
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   121
                                leftFraction:0.0; leftOffset:10;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   122
                                topFraction:0.0;  topOffset:10;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   123
                                rightFraction:1.0; rightOffset:-10;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   124
                                bottomFraction:1.0; bottomOffset:-10).
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   125
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   126
        top open
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   127
                                                                        [exEnd]
93
f2389560b8eb *** empty log message ***
claus
parents: 88
diff changeset
   128
"
88
claus
parents: 83
diff changeset
   129
! !
claus
parents: 83
diff changeset
   130
426
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   131
!LayoutFrame class methodsFor:'instance creation'!
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   132
2762
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   133
fractions:fractionRectangle offsets:offsetRectangle
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   134
    "create a new layoutFrame"
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   135
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   136
    ^ self new
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   137
        fractions:fractionRectangle offsets:offsetRectangle
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   138
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   139
    "
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   140
     LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 0 corner:0 @ 0)
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   141
    "
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   142
!
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   143
2221
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   144
inset:pixels
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   145
    "create a new layoutFrame which insets the child by some pixels"
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   146
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   147
    ^ self
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   148
        leftFraction:0 offset:pixels
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   149
        rightFraction:1 offset:pixels negated
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   150
        topFraction:0 offset:pixels 
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   151
        bottomFraction:1 offset:pixels negated 
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   152
!
52803ae96560 *** empty log message ***
fm
parents: 2123
diff changeset
   153
426
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   154
leftFraction:lF offset:lO rightFraction:rF offset:rO topFraction:tF offset:tO bottomFraction:bF offset:bO
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   155
    "create a new layoutFrame"
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   156
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   157
    ^ self new
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   158
        leftFraction:lF offset:lO 
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   159
        rightFraction:rF offset:rO 
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   160
        topFraction:tF offset:tO 
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   161
        bottomFraction:bF offset:bO
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   162
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   163
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   164
545
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   165
!
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   166
2765
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   167
leftFraction:lF rightFraction:rF topFraction:tF bottomFraction:bF
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   168
    "create a new layoutFrame"
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   169
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   170
    ^ self new
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   171
        leftFraction:lF offset:0 
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   172
        rightFraction:rF offset:0 
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   173
        topFraction:tF offset:0 
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   174
        bottomFraction:bF offset:0
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   175
!
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   176
545
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   177
leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   178
    "create a new layoutFrame"
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   179
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   180
    ^ self new
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   181
        leftOffset:lO 
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   182
        rightOffset:rO 
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   183
        topOffset:tO 
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   184
        bottomOffset:bO
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   185
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   186
    "Created: 18.4.1997 / 20:14:44 / cg"
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   187
!
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   188
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   189
leftOffset:lO topOffset:tO rightOffset:rO bottomOffset:bO
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   190
    "create a new layoutFrame"
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   191
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   192
    ^ self leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   193
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   194
    "Modified: 18.4.1997 / 20:15:23 / cg"
1795
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   195
!
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   196
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   197
origin:origin corner:corner
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   198
    "create a new layoutFrame from an oldStyle origin-corner rectangle.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   199
     Added to make migration from Rectangles to LayoutFrames easier."
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   200
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   201
    |leftFraction leftOffset rightFraction rightOffset
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   202
     topFraction topOffset bottomFraction bottomOffset
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   203
     orgX orgY cornerX cornerY|
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   204
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   205
    orgX := origin x.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   206
    orgY := origin y.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   207
    cornerX := corner x.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   208
    cornerY := corner y.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   209
    leftFraction := leftOffset := 0.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   210
    orgX isInteger ifTrue:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   211
        leftOffset := orgX
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   212
    ] ifFalse:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   213
        leftFraction := orgX.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   214
    ].
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   215
    orgY isInteger ifTrue:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   216
        topOffset := orgY
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   217
    ] ifFalse:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   218
        topFraction := orgY.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   219
    ].
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   220
    cornerX isInteger ifTrue:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   221
        rightOffset := cornerX
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   222
    ] ifFalse:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   223
        rightFraction := cornerX.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   224
    ].
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   225
    cornerY isInteger ifTrue:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   226
        bottomOffset := cornerY
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   227
    ] ifFalse:[
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   228
        bottomFraction := cornerY.
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   229
    ].
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   230
    ^ self
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   231
        leftFraction:leftFraction offset:leftOffset
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   232
        rightFraction:rightFraction offset:rightOffset
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   233
        topFraction:topFraction offset:rightOffset 
19dee5013803 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1601
diff changeset
   234
        bottomFraction:bottomFraction offset:bottomOffset 
426
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   235
! !
45859f8a2044 checkin from browser
ca
parents: 425
diff changeset
   236
77
claus
parents:
diff changeset
   237
!LayoutFrame methodsFor:'accessing'!
claus
parents:
diff changeset
   238
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   239
bottomFraction
2123
5247deafa7ef comments
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
   240
    "Return the y-coordinate of the bottom of the relative rectangle as a percentage of the height of the reference rectangle."
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   241
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   242
    ^ bottomFraction
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   243
!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   244
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   245
bottomFraction:something
2123
5247deafa7ef comments
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
   246
    "Set the y-coordinate of the bottom of the relative rectangle to be a fraction of the height of the reference rectangle."
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   247
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   248
    bottomFraction := something.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   249
!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   250
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   251
bottomFraction:something offset:o
2123
5247deafa7ef comments
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
   252
    "set both bottomFraction and offset"
77
claus
parents:
diff changeset
   253
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   254
    bottomFraction := something.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   255
    bottomOffset := o
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   256
!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   257
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   258
bottomInset:pixels
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   259
    "set bottomOffset for an inset at the bottom"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   260
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   261
    bottomOffset := pixels negated.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   262
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   263
    "Created: 26.5.1996 / 17:38:30 / cg"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   264
!
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   265
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   266
bottomOffset
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   267
    "return bottomOffset"
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   268
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   269
    ^ bottomOffset
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   270
!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   271
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   272
bottomOffset:something
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   273
    "set bottomOffset"
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   274
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   275
    bottomOffset := something.
77
claus
parents:
diff changeset
   276
!
claus
parents:
diff changeset
   277
2762
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   278
fractions:fractionRectangle offsets:offsetRectangle
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   279
    "LayoutFrame fractions:(0 @ 0 corner:1.0 @ 1.0) offsets:(0 @ 0 corner:0 @ 0)"
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   280
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   281
    self
2765
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   282
        leftFraction:(fractionRectangle left) offset:(offsetRectangle left)
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   283
        rightFraction:(fractionRectangle right) offset:(offsetRectangle right)
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   284
        topFraction:(fractionRectangle top) offset:(offsetRectangle top)
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   285
        bottomFraction:(fractionRectangle bottom) offset:(offsetRectangle bottom)
2762
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   286
!
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   287
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   288
horizontalInset:aNumber
2123
5247deafa7ef comments
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
   289
    "setup the offsets for insetting horizontally the frame aNumber pixels at all sides"
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   290
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   291
    leftOffset := aNumber.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   292
    rightOffset := aNumber negated.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   293
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   294
    "Created: 26.5.1996 / 17:39:35 / cg"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   295
!
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   296
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   297
inset:aNumber
2123
5247deafa7ef comments
Claus Gittinger <cg@exept.de>
parents: 1795
diff changeset
   298
    "setup the offsets for insetting the frame aNumber pixels at all sides"
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   299
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   300
    topOffset := leftOffset := aNumber.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   301
    rightOffset := bottomOffset := aNumber negated.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   302
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   303
    "Created: 26.5.1996 / 17:36:49 / cg"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   304
!
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   305
425
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   306
leftFraction:lF offset:lO rightFraction:rF offset:rO topFraction:tF offset:tO bottomFraction:bF offset:bO
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   307
    "set all fields"
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   308
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   309
    leftFraction := lF.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   310
    rightFraction := rF.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   311
    topFraction := tF.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   312
    bottomFraction := bF.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   313
    leftOffset := lO.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   314
    rightOffset := rO.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   315
    topOffset := tO.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   316
    bottomOffset := bO.
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   317
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   318
!
54077a8586f0 checkin from browser
ca
parents: 416
diff changeset
   319
1597
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   320
leftOffset:lO rightOffset:rO
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   321
    "set the horizontal offset fields"
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   322
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   323
    leftOffset := lO.
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   324
    rightOffset := rO.
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   325
!
7f14cbd5b7ba *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1594
diff changeset
   326
545
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   327
leftOffset:lO rightOffset:rO topOffset:tO bottomOffset:bO
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   328
    "set all offset fields"
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   329
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   330
    leftOffset := lO.
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   331
    rightOffset := rO.
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   332
    topOffset := tO.
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   333
    bottomOffset := bO.
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   334
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   335
    "Created: 18.4.1997 / 20:16:08 / cg"
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   336
!
0b9d704baeae more access & inst-creation methods
Claus Gittinger <cg@exept.de>
parents: 498
diff changeset
   337
77
claus
parents:
diff changeset
   338
rightFraction
claus
parents:
diff changeset
   339
    "return rightFraction"
claus
parents:
diff changeset
   340
claus
parents:
diff changeset
   341
    ^ rightFraction
claus
parents:
diff changeset
   342
!
claus
parents:
diff changeset
   343
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   344
rightFraction:something
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   345
    "set rightFraction"
77
claus
parents:
diff changeset
   346
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   347
    rightFraction := something.
77
claus
parents:
diff changeset
   348
!
claus
parents:
diff changeset
   349
claus
parents:
diff changeset
   350
rightFraction:something offset:o
claus
parents:
diff changeset
   351
    "set rightFraction and offset"
claus
parents:
diff changeset
   352
claus
parents:
diff changeset
   353
    rightFraction := something.
claus
parents:
diff changeset
   354
    rightOffset := o
claus
parents:
diff changeset
   355
!
claus
parents:
diff changeset
   356
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   357
rightInset:pixels
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   358
    "set rightOffset for an inset at the right"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   359
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   360
    rightOffset := pixels negated.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   361
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   362
    "Created: 26.5.1996 / 17:38:38 / cg"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   363
!
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   364
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   365
rightOffset
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   366
    "return rightOffset"
77
claus
parents:
diff changeset
   367
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   368
    ^ rightOffset
77
claus
parents:
diff changeset
   369
!
claus
parents:
diff changeset
   370
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   371
rightOffset:something
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   372
    "set rightOffset"
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   373
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   374
    rightOffset := something.
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   375
!
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   376
1594
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
   377
topOffset:newTopOffset bottomOffset:newBottomOffset
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
   378
    topOffset := newTopOffset.
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
   379
    bottomOffset := newBottomOffset.
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
   380
!
1b87b322f268 accessor added
Claus Gittinger <cg@exept.de>
parents: 1039
diff changeset
   381
275
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   382
verticalInset:aNumber
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   383
    "setup the offsets for insetting vertically the frame aNumber pixels
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   384
     at all sides"
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   385
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   386
    topOffset := aNumber.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   387
    bottomOffset := aNumber negated.
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   388
d500c08871ab added inset methods
Claus Gittinger <cg@exept.de>
parents: 242
diff changeset
   389
    "Created: 26.5.1996 / 17:39:50 / cg"
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   390
! !
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   391
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   392
!LayoutFrame methodsFor:'converting'!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   393
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   394
fromLiteralArrayEncoding:encoding
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   395
    "read my values from an encoding.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   396
     The encoding is supposed to be of the form: 
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   397
	(LayoutFrame orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY)
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   398
     This is the reverse to literalArrayEncoding."
77
claus
parents:
diff changeset
   399
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   400
    leftOffset := encoding at:2.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   401
    leftFraction := encoding at:3.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   402
    topOffset := encoding at:4.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   403
    topFraction := encoding at:5.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   404
    rightOffset := encoding at:6.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   405
    rightFraction := encoding at:7.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   406
    bottomOffset := encoding at:8.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   407
    bottomFraction := encoding at:9.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   408
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   409
    "
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   410
      LayoutFrame new fromLiteralArrayEncoding:#(#LayoutFrame 70 0 2 0 0 1 25 0 )
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   411
      #(#LayoutFrame 70 0 2 0 0 1 25 0 ) decodeAsLiteralArray 
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   412
    "
77
claus
parents:
diff changeset
   413
!
claus
parents:
diff changeset
   414
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   415
literalArrayEncoding
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   416
    "encode myself as an array, from which a copy of the receiver
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   417
     can be reconstructed with #decodeAsLiteralArray.
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   418
     The encoding is: 
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   419
        (#LayoutOrigin orgOffsX relOrgX orgOffsY relOrgY cornOffsX relCornX cornOffsY relCornY)"
77
claus
parents:
diff changeset
   420
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   421
    ^ super literalArrayEncoding
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   422
      , (Array
2618
fb52a0f3e1e8 Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents: 2221
diff changeset
   423
            with:rightOffset value          "take care of blocks (dynamic preferred extent)"
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   424
            with:rightFraction
2618
fb52a0f3e1e8 Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents: 2221
diff changeset
   425
            with:bottomOffset value
fb52a0f3e1e8 Fix preferred and dynamic preferred sizes
Stefan Vogel <sv@exept.de>
parents: 2221
diff changeset
   426
            with:bottomFraction)            "take care of blocks (dynamic preferred extent)"
77
claus
parents:
diff changeset
   427
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   428
    "Modified: 1.9.1995 / 02:43:35 / claus"
191
cb2815b77100 commentary
Claus Gittinger <cg@exept.de>
parents: 126
diff changeset
   429
    "Modified: 22.4.1996 / 13:00:17 / cg"
77
claus
parents:
diff changeset
   430
! !
claus
parents:
diff changeset
   431
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   432
!LayoutFrame methodsFor:'initialization'!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   433
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   434
initialize
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   435
    leftOffset := rightOffset := bottomOffset := topOffset := 0.
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   436
    leftFraction := topFraction := 0.
468
bb4100d09a18 default frame is 0/0 -> 0/0
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   437
    "/ bottomFraction := rightFraction := 1.
bb4100d09a18 default frame is 0/0 -> 0/0
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   438
    bottomFraction := rightFraction := 0.
bb4100d09a18 default frame is 0/0 -> 0/0
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   439
bb4100d09a18 default frame is 0/0 -> 0/0
Claus Gittinger <cg@exept.de>
parents: 426
diff changeset
   440
    "Modified: 1.3.1997 / 16:12:50 / cg"
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   441
! !
77
claus
parents:
diff changeset
   442
83
claus
parents: 77
diff changeset
   443
!LayoutFrame methodsFor:'printing & storing'!
claus
parents: 77
diff changeset
   444
claus
parents: 77
diff changeset
   445
displayString
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   446
    "return a printed representation of the receiver for displaying"
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   447
83
claus
parents: 77
diff changeset
   448
    ^ (self class name) , '(' 
700
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   449
        , 'l: ' , leftFraction displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   450
        , '+' , leftOffset displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   451
        , ' t: ' , topFraction displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   452
        , '+' , topOffset displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   453
        , ' r: ' , rightFraction displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   454
        , '+' , rightOffset displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   455
        , ' b: ' , bottomFraction displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   456
        , '+' , bottomOffset displayString
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   457
        , ')'
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   458
67f1dccb8333 comments
Claus Gittinger <cg@exept.de>
parents: 695
diff changeset
   459
    "Modified: 20.9.1997 / 11:40:14 / cg"
83
claus
parents: 77
diff changeset
   460
! !
claus
parents: 77
diff changeset
   461
77
claus
parents:
diff changeset
   462
!LayoutFrame methodsFor:'queries'!
claus
parents:
diff changeset
   463
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   464
corner
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   465
    ^ rightFraction asFloat @ bottomFraction asFloat
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   466
!
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   467
416
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   468
isLayoutFrame
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   469
    "return true, if this is a layoutFrame"
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   470
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   471
    ^ true
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   472
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   473
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   474
!
83ab2c5c7ec4 checkin from browser
ca
parents: 275
diff changeset
   475
949
0eb888b21192 prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   476
rectangleRelativeTo:superRectangle preferred:prefRectHolder
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   477
    "compute the rectangle represented by the receiver,
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   478
     given the superViews rectangle and the views preferredExtent."
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   479
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   480
    |x1 y1 x2 y2 superWidth superHeight|
77
claus
parents:
diff changeset
   481
1039
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   482
    x1 := x2 := superRectangle left.
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   483
    y1 := y2 := superRectangle top.
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   484
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   485
    leftOffset notNil ifTrue:[
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   486
        x1 := x1 + leftOffset value
77
claus
parents:
diff changeset
   487
    ].
1039
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   488
    topOffset notNil ifTrue:[
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   489
        y1 := y1 + topOffset value
77
claus
parents:
diff changeset
   490
    ].
1039
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   491
    rightOffset notNil ifTrue:[
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   492
        x2 := x2 + rightOffset value
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   493
    ].
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   494
    bottomOffset notNil ifTrue:[
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   495
        y2 := y2 + bottomOffset value
77
claus
parents:
diff changeset
   496
    ].
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   497
77
claus
parents:
diff changeset
   498
    leftFraction notNil ifTrue:[
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   499
        superWidth := superRectangle width.
1601
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
   500
        x1 := x1 + (superWidth * leftFraction value) 
77
claus
parents:
diff changeset
   501
    ].
claus
parents:
diff changeset
   502
    topFraction notNil ifTrue:[
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   503
        superHeight := superRectangle height.
1601
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
   504
        y1 := y1 + (superHeight * topFraction value) 
77
claus
parents:
diff changeset
   505
    ].
claus
parents:
diff changeset
   506
    rightFraction notNil ifTrue:[
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   507
        superWidth isNil ifTrue:[superWidth := superRectangle width].
1601
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
   508
        x2 := x2 + (superWidth * rightFraction value) 
77
claus
parents:
diff changeset
   509
    ].
claus
parents:
diff changeset
   510
    bottomFraction notNil ifTrue:[
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   511
        superHeight isNil ifTrue:[superHeight := superRectangle height].
1601
Claus Gittinger <cg@exept.de>
parents: 1600
diff changeset
   512
        y2 := y2 + (superHeight * bottomFraction value) 
77
claus
parents:
diff changeset
   513
    ].
242
5b7f59450c65 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 229
diff changeset
   514
    ^ Rectangle left:x1 top:y1 right:x2 bottom:y2
83
claus
parents: 77
diff changeset
   515
claus
parents: 77
diff changeset
   516
    "
claus
parents: 77
diff changeset
   517
     |superRect lF|
claus
parents: 77
diff changeset
   518
498
a9f922ab2050 avoid 2 sends if possible
Claus Gittinger <cg@exept.de>
parents: 468
diff changeset
   519
     superRect := 0@0 corner:99@99.
83
claus
parents: 77
diff changeset
   520
     lF := (LayoutFrame new).
claus
parents: 77
diff changeset
   521
     lF leftFraction:0.25;
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   522
        topFraction:0.25;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   523
        rightFraction:0.75;
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   524
        bottomFraction:0.75.
83
claus
parents: 77
diff changeset
   525
     lF rectangleRelativeTo:superRect preferred:(0@0 corner:30@30) 
claus
parents: 77
diff changeset
   526
    "
229
612861ef768a examples
Claus Gittinger <cg@exept.de>
parents: 219
diff changeset
   527
949
0eb888b21192 prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents: 700
diff changeset
   528
    "Created: / 6.3.1997 / 21:07:51 / cg"
1039
4095e7721dad fixed framedBox computation.
Claus Gittinger <cg@exept.de>
parents: 949
diff changeset
   529
    "Modified: / 13.8.1998 / 18:33:59 / cg"
77
claus
parents:
diff changeset
   530
! !
100
claus
parents: 96
diff changeset
   531
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   532
!LayoutFrame class methodsFor:'documentation'!
100
claus
parents: 96
diff changeset
   533
126
25df58661f32 version at the end
Claus Gittinger <cg@exept.de>
parents: 114
diff changeset
   534
version
2765
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   535
    ^ '$Header: /cvs/stx/stx/libview2/LayoutFrame.st,v 1.36 2009-10-19 09:28:12 cg Exp $'
2762
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   536
!
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   537
80249bee736b added: #fractions:offsets: for squeak compatibility
Claus Gittinger <cg@exept.de>
parents: 2618
diff changeset
   538
version_CVS
2765
827160ff9feb added: #leftFraction:rightFraction:topFraction:bottomFraction:
Claus Gittinger <cg@exept.de>
parents: 2763
diff changeset
   539
    ^ '$Header: /cvs/stx/stx/libview2/LayoutFrame.st,v 1.36 2009-10-19 09:28:12 cg Exp $'
100
claus
parents: 96
diff changeset
   540
! !