Rectangle.st
author Stefan Vogel <sv@exept.de>
Fri, 19 Jan 2018 10:40:24 +0100
changeset 22453 5935c74b8ca0
parent 22378 0f034b43ac9b
child 23156 85e585250a3c
permissions -rw-r--r--
add class: CharacterEncoderImplementations::VariableBytesEncoder
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     1
"
5
67342904af11 *** empty log message ***
claus
parents: 3
diff changeset
     2
 COPYRIGHT (c) 1989 by Claus Gittinger
186
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
     3
	      All Rights Reserved
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
     4
a27a279701f8 Initial revision
claus
parents:
diff changeset
     5
 This software is furnished under a license and may be used
a27a279701f8 Initial revision
claus
parents:
diff changeset
     6
 only in accordance with the terms of that license and with the
a27a279701f8 Initial revision
claus
parents:
diff changeset
     7
 inclusion of the above copyright notice.   This software may not
a27a279701f8 Initial revision
claus
parents:
diff changeset
     8
 be provided or otherwise made available to, or used by, any
a27a279701f8 Initial revision
claus
parents:
diff changeset
     9
 other person.  No title to or ownership of the software is
a27a279701f8 Initial revision
claus
parents:
diff changeset
    10
 hereby transferred.
a27a279701f8 Initial revision
claus
parents:
diff changeset
    11
"
5552
31b5cc144476 category changes
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
    12
"{ Package: 'stx:libbasic' }"
31b5cc144476 category changes
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
    13
18820
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
    14
"{ NameSpace: Smalltalk }"
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
    15
356
claus
parents: 329
diff changeset
    16
Geometric subclass:#Rectangle
1149
69b30e3494fa added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    17
	instanceVariableNames:'left top width height'
69b30e3494fa added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    18
	classVariableNames:''
69b30e3494fa added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
    19
	poolDictionaries:''
7582
279c8f991809 category
Claus Gittinger <cg@exept.de>
parents: 7297
diff changeset
    20
	category:'Graphics-Geometry-Objects'
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    21
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    22
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    23
!Rectangle class methodsFor:'documentation'!
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    24
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    25
copyright
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    26
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    27
 COPYRIGHT (c) 1989 by Claus Gittinger
186
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
    28
	      All Rights Reserved
88
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    29
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    30
 This software is furnished under a license and may be used
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    31
 only in accordance with the terms of that license and with the
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    32
 inclusion of the above copyright notice.   This software may not
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    33
 be provided or otherwise made available to, or used by, any
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    34
 other person.  No title to or ownership of the software is
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    35
 hereby transferred.
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    36
"
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    37
!
81dacba7a63a *** empty log message ***
claus
parents: 77
diff changeset
    38
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    39
documentation
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    40
"
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    41
    Rectangles represent a rectangular area in 2D space.
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    42
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    43
    notice, my implementation does not use origin/corner as instance objects
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    44
    but left/top/width/height to save space and allocations. This means, that my
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    45
    Rectangles cannot be used to represent Rectangles in a higher than 2D
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    46
    space. (i.e. only valid if origin/corner are 2D Points)
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    47
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    48
    (aside from that, you will not see any difference from the outside)
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    49
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    50
    Instance variables:
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    51
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    52
	left           <Number>        the left coordinate (i.e origin x)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    53
	top            <Number>        the top coordinate (i.e origin y)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    54
	width          <Number>        the width of the rectangle
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    55
	height         <Number>        the height of the rectangle
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    56
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    57
    I am not certain, if implementing Rectangle different was a good idea -
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    58
    subclasses may expect things to be different ...
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    59
    Therefore, this may change.
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    60
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    61
    [author:]
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    62
	Claus Gittinger
1290
15ba3221b89b documentation
Claus Gittinger <cg@exept.de>
parents: 1245
diff changeset
    63
1314
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
    64
    [see also:]
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    65
	Point Polygon Circle EllipticalArc Spline
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    66
	LayoutOrigin LayoutFrame AlignmentOrigin Layout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    67
	View GraphicsContext StrokingWrapper FillingWrapper
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    68
"
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    69
! !
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
    70
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
    71
!Rectangle class methodsFor:'instance creation'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
    72
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    73
center:centerPoint extent:extentPoint
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    74
    "return an instance of me whose center is centerPoint and width
4890
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
    75
     by height is extentPoint."
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
    76
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    77
    ^ self
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    78
	origin:centerPoint - (extentPoint//2)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    79
	extent:extentPoint
4890
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
    80
!
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
    81
3239
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    82
decodeFromLiteralArray:anArray
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    83
    "create & return a new instance from information encoded in anArray.
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    84
     Redefined for faster creation."
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    85
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    86
    |l t w h|
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    87
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    88
    l := anArray at:2.
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    89
    t := anArray at:3.
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    90
    w := (anArray at:4) - l.
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    91
    h := (anArray at:5) - t.
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    92
    ^ self left:l top:t width:w height:h
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    93
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    94
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
    95
     Rectangle decodeFromLiteralArray:#(Rectangle 100 200 300 500)
3239
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    96
    "
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    97
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    98
    "Created: / 28.1.1998 / 17:46:52 / cg"
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
    99
!
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   100
4864
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   101
encompassing:listOfPoints
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   102
    "Return a rectangle, which encompasses all of the given points."
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   103
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   104
    |topLeft bottomRight|
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   105
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   106
    topLeft := bottomRight := nil.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   107
    listOfPoints do:[:p |
21311
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   108
        topLeft isNil
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   109
            ifTrue: [topLeft := bottomRight := p]
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   110
            ifFalse: [topLeft := topLeft min: p.
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   111
                      bottomRight := bottomRight max: p]
4864
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   112
    ].
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   113
    ^ topLeft corner: bottomRight
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   114
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   115
    "
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   116
     Rectangle encompassing:(Array with:10@10 with:50@0 with:0@50)
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   117
    "
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   118
!
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
   119
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   120
left:left right:right top:top bottom:bottom
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   121
    "create and return a new Rectangle giving left, top, right and bottom coordinates"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   122
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   123
    ^ (self basicNew) left:left right:right top:top bottom:bottom
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   124
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   125
1356
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   126
left:left top:top extent:extent
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   127
    "create and return a new Rectangle giving left, top, and
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   128
     an extent point."
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   129
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   130
    ^ (self basicNew) left:left top:top extent:extent
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   131
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   132
    "Created: 8.5.1996 / 20:56:29 / cg"
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   133
!
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   134
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   135
left:left top:top right:right bottom:bottom
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   136
    "create and return a new Rectangle giving left, top, right and bottom coordinates"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   137
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   138
    ^ (self basicNew) left:left top:top right:right bottom:bottom
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   139
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   140
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   141
left:left top:top width:w height:h
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   142
    "create and return a new Rectangle giving left and top coordinates
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   143
     and width, height"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   144
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   145
%{  /* NOCONTEXT */
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   146
    REGISTER OBJ newRect;
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   147
    OBJ t;
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   148
    int spc;
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   149
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7582
diff changeset
   150
    if (__CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {   /* OBJECT ALLOCATION */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   151
	if (self == Rectangle) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   152
	    /*
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   153
	     * short cut - rectangles are created so often ...
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   154
	     */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   155
	    __qCheckedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7582
diff changeset
   156
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   157
	    __InstPtr(newRect)->o_class = Rectangle;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   158
	    __qSTORE(newRect, Rectangle);
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   159
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   160
	    __InstPtr(newRect)->i_instvars[0] = left;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   161
	    __InstPtr(newRect)->i_instvars[1] = top;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   162
	    __InstPtr(newRect)->i_instvars[2] = w;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   163
	    __InstPtr(newRect)->i_instvars[3] = h;
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   164
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   165
	    if (! (__bothSmallInteger(left, top) &&
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   166
		   __bothSmallInteger(w, h))) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   167
		spc = __qSpace(newRect);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   168
		__STORE_SPC(newRect, left, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   169
		__STORE_SPC(newRect, top, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   170
		__STORE_SPC(newRect, w, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   171
		__STORE_SPC(newRect, h, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   172
	    }
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   173
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   174
	    RETURN ( newRect );
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   175
	}
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   176
    }
1507
ac16087c0e95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1454
diff changeset
   177
%}.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   178
    ^ (self basicNew) left:left top:top width:w height:h
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   179
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   180
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   181
merging: listOfRects
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   182
    "return the merge of a number of rectangles.
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   183
     Avoids creation of temp garbage."
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   184
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   185
    | topLeft bottomRight |
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   186
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   187
    topLeft := bottomRight := nil.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   188
    listOfRects do:[:r |
21311
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   189
        topLeft isNil ifTrue: [
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   190
            topLeft := r topLeft.
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   191
            bottomRight := r bottomRight
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   192
        ] ifFalse: [
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   193
            topLeft := topLeft min: r topLeft.
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   194
            bottomRight := bottomRight max: r bottomRight
faf1ec6afec6 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21269
diff changeset
   195
        ]
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   196
    ].
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   197
    ^ topLeft corner: bottomRight
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   198
!
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   199
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   200
origin:origin corner:corner
a27a279701f8 Initial revision
claus
parents:
diff changeset
   201
    "create and return a new Rectangle giving top-left and bottom-right points"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   202
a27a279701f8 Initial revision
claus
parents:
diff changeset
   203
    ^ (self basicNew) origin:origin corner:corner
a27a279701f8 Initial revision
claus
parents:
diff changeset
   204
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   205
a27a279701f8 Initial revision
claus
parents:
diff changeset
   206
origin:origin extent:extent
a27a279701f8 Initial revision
claus
parents:
diff changeset
   207
    "create and return a new Rectangle giving top-left point and extent point"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   208
a27a279701f8 Initial revision
claus
parents:
diff changeset
   209
%{  /* NOCONTEXT */
59
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   210
    REGISTER OBJ newRect;
293
31df3850e98c *** empty log message ***
claus
parents: 259
diff changeset
   211
    OBJ t;
31df3850e98c *** empty log message ***
claus
parents: 259
diff changeset
   212
    int spc;
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   213
7859
837f47feba96 Have to call __STORE(), when assigning class.
Stefan Vogel <sv@exept.de>
parents: 7582
diff changeset
   214
    if (__CanDoQuickNew(OHDR_SIZE + 4*sizeof(OBJ))) {   /* OBJECT ALLOCATION */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   215
	/*
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   216
	 * short cut - rectangles are created so often ...
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   217
	 */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   218
	if (self == Rectangle) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   219
	    if (__isPoint(origin) && __isPoint(extent)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   220
		__qCheckedNew(newRect, OHDR_SIZE + 4*sizeof(OBJ));
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   221
		__InstPtr(newRect)->o_class = Rectangle;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   222
		__qSTORE(newRect, Rectangle);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   223
		spc = __qSpace(newRect);
59
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   224
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   225
		t = __PointInstPtr(origin)->p_x;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   226
		__InstPtr(newRect)->i_instvars[0] = t;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   227
		__STORE_SPC(newRect, t, spc);
293
31df3850e98c *** empty log message ***
claus
parents: 259
diff changeset
   228
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   229
		t = __PointInstPtr(origin)->p_y;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   230
		__InstPtr(newRect)->i_instvars[1] = t;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   231
		__STORE_SPC(newRect, t, spc);
59
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   232
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   233
		t = __PointInstPtr(extent)->p_x;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   234
		__InstPtr(newRect)->i_instvars[2] = t;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   235
		__STORE_SPC(newRect, t, spc);
293
31df3850e98c *** empty log message ***
claus
parents: 259
diff changeset
   236
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   237
		t = __PointInstPtr(extent)->p_y;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   238
		__InstPtr(newRect)->i_instvars[3] = t;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   239
		__STORE_SPC(newRect, t, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   240
		RETURN ( newRect );
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   241
	    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   242
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   243
    }
1507
ac16087c0e95 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1454
diff changeset
   244
%}.
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   245
    ^ (self basicNew) origin:origin extent:extent
1356
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   246
!
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   247
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   248
origin:origin width:w height:h
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   249
    "create and return a new Rectangle giving top-left and extent
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   250
     as individual width/height"
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   251
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   252
    ^ (self basicNew) origin:origin width:w height:h
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   253
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   254
    "Created: 8.5.1996 / 20:55:53 / cg"
2372
9a98e1acd063 added #vertex:vertex: - ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 2274
diff changeset
   255
!
9a98e1acd063 added #vertex:vertex: - ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 2274
diff changeset
   256
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   257
vertex:vertex1Point vertex:vertex2Point
2372
9a98e1acd063 added #vertex:vertex: - ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 2274
diff changeset
   258
    "create and return a new instance of the receiver,
3239
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   259
     given two diagonally opposite vertices."
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   260
1114c37ca259 faster decodeFromLiteralEncoding
Claus Gittinger <cg@exept.de>
parents: 2894
diff changeset
   261
    ^ self
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   262
	origin: (vertex1Point min: vertex2Point)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   263
	corner: (vertex1Point max: vertex2Point)
2372
9a98e1acd063 added #vertex:vertex: - ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 2274
diff changeset
   264
9a98e1acd063 added #vertex:vertex: - ST-80 compatibility.
Claus Gittinger <cg@exept.de>
parents: 2274
diff changeset
   265
    "Created: 10.2.1997 / 12:14:32 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   266
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   267
7297
165148714132 category
Claus Gittinger <cg@exept.de>
parents: 7261
diff changeset
   268
!Rectangle class methodsFor:'instance creation-interactive'!
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   269
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   270
fromUser
15842
7a59e7b8df00 class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15730
diff changeset
   271
    "let user specify a rectangle on the screen, return it.
15900
ef5a31a78db8 AbortSignal -> AbortOperationRequest
Stefan Vogel <sv@exept.de>
parents: 15842
diff changeset
   272
     If the user presses ESC, an AbortOperationRequest is raised."
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   273
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   274
    ^ Screen current rectangleFromUser
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   275
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   276
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   277
     Rectangle fromUser
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   278
    "
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   279
!
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   280
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   281
originFromUser:extent
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   282
    "let user specify an origin on the screen, return it"
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   283
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   284
    ^ Screen current originFromUser:extent
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   285
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   286
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   287
     Rectangle originFromUser:50@50
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   288
    "
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   289
! !
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
   290
7261
f35fc9cee675 method category rename
Claus Gittinger <cg@exept.de>
parents: 7176
diff changeset
   291
!Rectangle methodsFor:'Compatibility-Squeak'!
4976
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   292
4990
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   293
amountToTranslateWithin: aRectangle
6065
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   294
    "Answer a Point, delta, such that self + delta is forced within aRectangle."
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   295
    "Altered so as to prefer to keep self topLeft inside when all of self
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   296
     cannot be made to fit 7/27/96 di"
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   297
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   298
    | dx dy |
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   299
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   300
    dx := 0.  dy := 0.
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   301
    self right > aRectangle right ifTrue: [dx := aRectangle right - self right].
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   302
    self bottom > aRectangle bottom ifTrue: [dy := aRectangle bottom - self bottom].
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   303
    (self left + dx) < aRectangle left ifTrue: [dx := aRectangle left - self left].
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   304
    (self top + dy) < aRectangle top ifTrue: [dy := aRectangle top - self top].
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   305
    ^ dx@dy
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   306
!
4990
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   307
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   308
containsRect:aRect
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   309
    "Answer whether aRect is within the receiver (OK to coincide)."
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   310
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   311
    ^ self contains:aRect
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   312
!
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   313
5007
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   314
isTall
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   315
    "return true, if the receiver is higher then its width"
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   316
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   317
    ^ self height > self width
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   318
!
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   319
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   320
isWide
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   321
    "return true, if the receiver is wider then its height"
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   322
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   323
    ^ self width > self height
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   324
!
18336cbe1d1b checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4990
diff changeset
   325
4990
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   326
translatedToBeWithin: aRectangle
6065
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   327
    "Answer a copy of the receiver that does not extend beyond aRectangle.  7/8/96 sw"
4990
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   328
6065
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   329
    ^ self translateBy: (self amountToTranslateWithin: aRectangle)
f30cdb1edc0c comment
Claus Gittinger <cg@exept.de>
parents: 5552
diff changeset
   330
!
4990
0916c1395e59 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4976
diff changeset
   331
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   332
withHeight:height
4976
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   333
    "Return a copy of me with a different height"
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   334
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   335
    |origin corner|
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   336
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   337
    origin := self origin.
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   338
    corner := self corner.
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   339
    ^ origin corner:(corner x @ (origin y + height))
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   340
! !
1d685a9d0a84 checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4894
diff changeset
   341
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   342
!Rectangle methodsFor:'accessing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   343
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   344
area
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   345
    "return the area
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   346
     - for screen Rectangles this is the number of pixels"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   347
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   348
    ^ width * height
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   349
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   350
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   351
bottom
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   352
    "return the y coordinate of the bottom"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   353
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   354
    ^ (top + height)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   355
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   356
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   357
bottom:aNumber
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   358
    "set the bottom edge - warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   359
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   360
    height := aNumber - top
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   361
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   362
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   363
bottomCenter
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   364
    "return the bottom center point"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   365
1453
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   366
    ^ (left + (width / 2)) @ (top + height)
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   367
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   368
    "Modified: 4.6.1996 / 16:04:08 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   369
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   370
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   371
bottomLeft
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   372
    "return the bottom-left point"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   373
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   374
    ^ left @ (top + height)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   375
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   376
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   377
bottomRight
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   378
    "return the bottom-right point"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   379
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   380
    ^ (left + width) @ (top + height)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   381
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   382
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   383
center
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   384
    "return the point in the center of the receiver"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   385
1453
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   386
    ^ (left + (width / 2)) @ (top + (height / 2))
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   387
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   388
    "Modified: 4.6.1996 / 16:03:53 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   389
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   390
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   391
corner
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   392
    "return the corner"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   393
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   394
%{  /* NOCONTEXT */
17239
6f71da3ffaea class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 17238
diff changeset
   395
    if (self == @global(Rectangle)) {
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   396
	OBJ _tleft = __INST(left);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   397
	OBJ _ttop = __INST(top);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   398
	OBJ _twidth = __INST(width);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   399
	OBJ _theight = __INST(height);
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   400
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   401
	if (__bothSmallInteger(_tleft, _ttop)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   402
	 && __bothSmallInteger(_twidth, _theight)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   403
	    if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   404
		OBJ newPoint;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   405
		int spc;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   406
		int cX = __intVal(_tleft) + __intVal(_twidth);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   407
		int cY = __intVal(_ttop) + __intVal(_theight);
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   408
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   409
		if (__ISVALIDINTEGER(cX) && __ISVALIDINTEGER(cY)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   410
		    __qCheckedNew(newPoint, sizeof(struct __Point));
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   411
		    __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   412
		    __PointInstPtr(newPoint)->p_x = __MKSMALLINT(cX);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   413
		    __PointInstPtr(newPoint)->p_y = __MKSMALLINT(cY);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   414
		    RETURN ( newPoint );
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   415
		}
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   416
	    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   417
	}
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   418
    }
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   419
%}.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   420
    ^ (left + width) @ (top + height)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   421
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   422
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   423
corner:aPoint
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   424
    "set the bottom-right corner - warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   425
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   426
    width := aPoint x - left.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   427
    height := aPoint y - top
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   428
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   429
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   430
extent
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   431
    "return the extent"
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   432
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   433
%{  /* NOCONTEXT */
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   434
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   435
    if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   436
	if (self == @global(Rectangle)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   437
	    OBJ newPoint;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   438
	    int spc;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   439
	    OBJ newX = __INST(width);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   440
	    OBJ newY = __INST(height);
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   441
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   442
	    __qCheckedNew(newPoint, sizeof(struct __Point));
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   443
	    __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   444
	    __PointInstPtr(newPoint)->p_x = newX;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   445
	    __PointInstPtr(newPoint)->p_y = newY;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   446
	    if (! __bothSmallInteger(newX, newY)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   447
		spc = __qSpace(newPoint);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   448
		__STORE_SPC(newPoint, newX, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   449
		__STORE_SPC(newPoint, newY, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   450
	    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   451
	    RETURN ( newPoint );
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   452
	}
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   453
    }
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   454
%}.
8076
de72537a061e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   455
    ^ Point x:width y:height
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   456
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   457
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   458
extent:aPoint
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
   459
    "set the extent from the argument, aPoint 
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
   460
     with width taken from aPoint x and height taken from aPoint y.
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   461
     warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   462
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   463
    width := aPoint x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   464
    height := aPoint y
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
   465
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
   466
    "Modified (comment): / 27-11-2017 / 10:57:46 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   467
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   468
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   469
height
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   470
    "return the height of the rectangle"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   471
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   472
    ^ height
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   473
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   474
2441
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   475
height:aNumber
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   476
    "change the height of the rectangle.
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   477
     logically, this changes the corner to get the given height.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   478
     warning: destructive"
2441
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   479
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   480
    height := aNumber
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   481
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   482
    "Created: 3.3.1997 / 16:33:22 / cg"
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   483
!
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   484
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   485
left
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   486
    "return the x-coordinate of the top-left origin"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   487
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   488
    ^ left
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   489
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   490
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   491
left:aNumber
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   492
    "set the left edge, adjust width - warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   493
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   494
    left notNil ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   495
	"adjust width"
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   496
	width := width + (left - aNumber).
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   497
    ].
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   498
    left := aNumber
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   499
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   500
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   501
left:newLeft right:right top:newTop bottom:bottom
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   502
    "set the rectangle given left, top, right and bottom coordinates.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   503
     warning: destructive"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   504
a27a279701f8 Initial revision
claus
parents:
diff changeset
   505
    left := newLeft.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   506
    top := newTop.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   507
    width := right - left.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   508
    height := bottom - top
a27a279701f8 Initial revision
claus
parents:
diff changeset
   509
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   510
1356
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   511
left:newLeft top:newTop extent:extent
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   512
    "set the rectangle given left, top, coordinates and an extent.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   513
     warning: destructive"
1356
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   514
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   515
    left := newLeft.
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   516
    top := newTop.
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   517
    width := extent x.
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   518
    height := extent y
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   519
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   520
    "Created: 8.5.1996 / 20:55:10 / cg"
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   521
!
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   522
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   523
left:newLeft top:newTop right:right bottom:bottom
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   524
    "set the rectangle given left, top, right and bottom coordinates.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   525
     warning: destructive"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   526
a27a279701f8 Initial revision
claus
parents:
diff changeset
   527
    left := newLeft.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   528
    top := newTop.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   529
    width := right - left.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   530
    height := bottom - top
a27a279701f8 Initial revision
claus
parents:
diff changeset
   531
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   532
a27a279701f8 Initial revision
claus
parents:
diff changeset
   533
left:newLeft top:newTop width:newWidth height:newHeight
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   534
    "set the rectangle given left, top coordinates and width, height.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   535
     warning: destructive"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   536
a27a279701f8 Initial revision
claus
parents:
diff changeset
   537
    left := newLeft.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   538
    top := newTop.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   539
    width := newWidth.
a27a279701f8 Initial revision
claus
parents:
diff changeset
   540
    height := newHeight
a27a279701f8 Initial revision
claus
parents:
diff changeset
   541
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   542
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   543
leftCenter
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   544
    "return the left center point"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   545
1453
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   546
    ^ left @ (top + (height / 2))
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   547
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   548
    "Modified: 4.6.1996 / 16:04:01 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   549
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   550
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   551
origin
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   552
    "return the origin"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   553
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   554
%{  /* NOCONTEXT */
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   555
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   556
    /*
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   557
     * claus: I am no longer certain, if this primitive is worth the effort
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   558
     */
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   559
    if (__CanDoQuickNew(sizeof(struct __Point))) {      /* OBJECT ALLOCATION */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   560
	if (self == @global(Rectangle)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   561
	    OBJ newPoint;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   562
	    int spc;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   563
	    OBJ newX = __INST(left);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   564
	    OBJ newY = __INST(top);
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   565
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   566
	    __qCheckedNew(newPoint, sizeof(struct __Point));
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   567
	    __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   568
	    __PointInstPtr(newPoint)->p_x = newX;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   569
	    __PointInstPtr(newPoint)->p_y = newY;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   570
	    if (! __bothSmallInteger(newX, newY)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   571
		spc = __qSpace(newPoint);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   572
		__STORE_SPC(newPoint, newX, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   573
		__STORE_SPC(newPoint, newY, spc);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   574
	    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   575
	    RETURN ( newPoint );
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   576
	}
17238
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   577
    }
94b805b727cf class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 15900
diff changeset
   578
%}.
8076
de72537a061e *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8002
diff changeset
   579
    ^ Point x:left y:top
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   580
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   581
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   582
origin:aPoint
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   583
    "set the top-left origin. The corner remains unchanged.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   584
     warning: destructive"
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   585
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   586
    |newTop newLeft|
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   587
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   588
    newLeft := aPoint x.
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   589
    newTop := aPoint y.
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   590
    left notNil ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   591
	width := width + (left - newLeft).
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   592
    ].
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   593
    top notNil ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   594
	height := height + (top - newTop).
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   595
    ].
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   596
    left := newLeft.
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   597
    top := newTop
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   598
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   599
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   600
origin:origin corner:corner
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   601
    "set both origin and corner - warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   602
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   603
    left := origin x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   604
    top := origin y.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   605
    width := corner x - left.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   606
    height := corner y - top
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   607
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   608
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   609
origin:origin extent:extent
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   610
    "set both origin and extent - warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   611
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   612
    left := origin x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   613
    top := origin y.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   614
    width := extent x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   615
    height := extent y
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   616
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   617
1356
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   618
origin:origin width:w height:h
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   619
    "set both origin and extent;
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   620
     the extent is given as individual width and height.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   621
     warning: destructive"
1356
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   622
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   623
    left := origin x.
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   624
    top := origin y.
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   625
    width := w.
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   626
    height := h
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   627
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   628
    "Created: 8.5.1996 / 20:53:53 / cg"
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   629
!
a37a6ac34caf checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1355
diff changeset
   630
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   631
right
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   632
    "return the x coordinate of the right"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   633
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   634
    ^ (left + width)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   635
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   636
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   637
right:aNumber
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   638
    "set the right edge - warning: destructive"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   639
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   640
    width := aNumber - left
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   641
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   642
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   643
rightCenter
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   644
    "return the right center point"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   645
1453
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   646
    ^ (left + width) @ (top + (height / 2))
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   647
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   648
    "Modified: 4.6.1996 / 16:09:05 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   649
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   650
3269
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   651
setLeft:newLeft
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   652
    "set left without adjusting width - warning: destructive"
3269
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   653
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   654
    left := newLeft.
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   655
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   656
    "Modified: / 22.1.1998 / 09:40:35 / av"
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   657
    "Created: / 3.2.1998 / 19:01:06 / cg"
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   658
!
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   659
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   660
setOrigin:newOrigin corner:newCorner
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   661
    "set the rectangles dimensions - warning: destructive"
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   662
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   663
    self origin:newOrigin corner:newCorner
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   664
!
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   665
3269
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   666
setTop:newTop
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   667
    "set top without adjusting height - warning: destructive"
3269
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   668
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   669
    top := newTop.
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   670
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   671
    "Modified: / 20.1.1998 / 18:25:35 / av"
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   672
    "Created: / 3.2.1998 / 19:01:01 / cg"
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   673
!
6e3c86ce2a51 added #setTop: & #setLeft:
Claus Gittinger <cg@exept.de>
parents: 3239
diff changeset
   674
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   675
top
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   676
    "return the y-coordinate of the top-left"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   677
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   678
    ^ top
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   679
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   680
a27a279701f8 Initial revision
claus
parents:
diff changeset
   681
top:aNumber
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   682
    "set the top edge, adjust height - warning: destructive"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   683
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   684
    top notNil ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   685
	"adjust height"
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   686
	height := height + (top - aNumber).
7176
d61fa308f4c4 care for as-yet-uninitialized instvars in left:/top:
Claus Gittinger <cg@exept.de>
parents: 6065
diff changeset
   687
    ].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   688
    top := aNumber
a27a279701f8 Initial revision
claus
parents:
diff changeset
   689
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   690
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   691
topCenter
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   692
    "return the top center point"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   693
1453
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   694
    ^ (left + (width / 2)) @ top
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   695
eb73ecdb25ab center methods should not use //
Claus Gittinger <cg@exept.de>
parents: 1443
diff changeset
   696
    "Modified: 4.6.1996 / 16:09:09 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   697
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   698
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   699
topLeft
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   700
    "return the top-left point - the same as origin"
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   701
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   702
    ^ left @ top
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   703
!
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   704
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   705
topLeft:aPoint
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   706
    "Set the top and left edges.
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   707
     The bottom right remains unchanged.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   708
     warning: destructive"
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   709
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   710
    |newTop|
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   711
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   712
    newTop := aPoint y.
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   713
    height := height + (top - newTop).
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   714
    top := newTop.
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   715
    width := aPoint x - left
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   716
!
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   717
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   718
topRight
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   719
    "return the top-right point"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   720
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   721
    ^ (left + width) @ top
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   722
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   723
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   724
topRight:aPoint
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   725
    "Set the top and right edges.
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   726
     The bottom left remains unchanged.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   727
     warning: destructive"
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   728
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   729
    |newTop|
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   730
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   731
    newTop := aPoint y.
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   732
    height := height + (top - newTop).
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   733
    top := newTop.
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   734
    width := aPoint x - left
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   735
!
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   736
12946
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   737
vertices
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   738
    "return the array containing my points as a closed polygon (for Polygon compatibility)"
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   739
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   740
    ^ Array
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   741
	with:(self topLeft)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   742
	with:(self topRight)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   743
	with:(self bottomRight)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   744
	with:(self bottomLeft)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   745
	with:(self topLeft)
12946
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   746
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   747
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   748
     (Rectangle origin:100@100 extent:20@30) vertices
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   749
     (Rectangle origin:100@100 extent:20@30) asPolygon vertices
12946
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   750
    "
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   751
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   752
    "Modified: / 16-07-2010 / 16:59:16 / cg"
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   753
!
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
   754
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   755
width
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   756
    "return the width of the rectangle"
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   757
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
   758
    ^ width
2441
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   759
!
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   760
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   761
width:aNumber
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   762
    "change the width of the rectangle.
4860
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   763
     logically, this changes the corner to get the given width.
ac3a625492b2 comments
Claus Gittinger <cg@exept.de>
parents: 4859
diff changeset
   764
     warning: destructive"
2441
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   765
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   766
    width := aNumber
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   767
9ca4dbc0dc64 added #width: and #height:
Claus Gittinger <cg@exept.de>
parents: 2426
diff changeset
   768
    "Created: 3.3.1997 / 16:33:48 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   769
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   770
a27a279701f8 Initial revision
claus
parents:
diff changeset
   771
!Rectangle methodsFor:'comparing'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
   772
a27a279701f8 Initial revision
claus
parents:
diff changeset
   773
= aRectangle
a27a279701f8 Initial revision
claus
parents:
diff changeset
   774
    "return true, if the argument aRectangle represents the same
a27a279701f8 Initial revision
claus
parents:
diff changeset
   775
     rectangle as the receiver"
a27a279701f8 Initial revision
claus
parents:
diff changeset
   776
a27a279701f8 Initial revision
claus
parents:
diff changeset
   777
%{  /* NOCONTEXT */
59
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   778
    /*
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   779
     * because rectangles are often compared in the graphics code,
59
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   780
     * handle the common case quickly
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   781
     */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   782
    if (__isNonNilObject(aRectangle)
329
claus
parents: 326
diff changeset
   783
     && __qClass(aRectangle) == Rectangle) {
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   784
	if ((__InstPtr(self)->i_instvars[0] == __InstPtr(aRectangle)->i_instvars[0])
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   785
	 && (__InstPtr(self)->i_instvars[1] == __InstPtr(aRectangle)->i_instvars[1])
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   786
	 && (__InstPtr(self)->i_instvars[2] == __InstPtr(aRectangle)->i_instvars[2])
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   787
	 && (__InstPtr(self)->i_instvars[3] == __InstPtr(aRectangle)->i_instvars[3])) {
186
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
   788
	    RETURN ( true );
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
   789
	}
1133
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   790
	if (__bothSmallInteger(__InstPtr(self)->i_instvars[0], __InstPtr(aRectangle)->i_instvars[0])
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   791
	 && __bothSmallInteger(__InstPtr(self)->i_instvars[1], __InstPtr(aRectangle)->i_instvars[1])
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   792
	 && __bothSmallInteger(__InstPtr(self)->i_instvars[2], __InstPtr(aRectangle)->i_instvars[2])
961f2b095c22 underline cleanup
Claus Gittinger <cg@exept.de>
parents: 1124
diff changeset
   793
	 && __bothSmallInteger(__InstPtr(self)->i_instvars[3], __InstPtr(aRectangle)->i_instvars[3])) {
325
claus
parents: 308
diff changeset
   794
	    RETURN ( false );
claus
parents: 308
diff changeset
   795
	}
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   796
    }
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   797
%}.
259
   798
    (aRectangle species ~~ self species) ifTrue:[^ false].
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   799
a27a279701f8 Initial revision
claus
parents:
diff changeset
   800
    left = aRectangle left ifFalse:[^ false].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   801
    top = aRectangle top ifFalse:[^ false].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   802
    width = aRectangle width ifFalse:[^ false].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   803
    height = aRectangle height ifFalse:[^ false].
a27a279701f8 Initial revision
claus
parents:
diff changeset
   804
    ^ true
59
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   805
!
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   806
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   807
hash
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   808
    "return an integer useful for hashing -
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   809
     redefined since = is redefined here"
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   810
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   811
    ^ ((left hash bitShift:16) bitXor:(top hash bitShift:16))
4a86aad06603 *** empty log message ***
claus
parents: 32
diff changeset
   812
      + ((width hash) bitXor:(height hash))
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
   813
! !
a27a279701f8 Initial revision
claus
parents:
diff changeset
   814
356
claus
parents: 329
diff changeset
   815
!Rectangle methodsFor:'converting'!
claus
parents: 329
diff changeset
   816
claus
parents: 329
diff changeset
   817
asFractionalLayout
claus
parents: 329
diff changeset
   818
    "return a layoutFrame in which fractions (top, left, bottom, right)
claus
parents: 329
diff changeset
   819
     are taken from corresponding edges of the receiver.
claus
parents: 329
diff changeset
   820
     You have to make certain that those are in 0..1."
claus
parents: 329
diff changeset
   821
claus
parents: 329
diff changeset
   822
    |l|
claus
parents: 329
diff changeset
   823
claus
parents: 329
diff changeset
   824
    l := LayoutFrame new.
claus
parents: 329
diff changeset
   825
    l
20606
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   826
        leftFraction:(self left);
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   827
        rightFraction:(self right);
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   828
        topFraction:(self top);
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   829
        bottomFraction:(self bottom).
356
claus
parents: 329
diff changeset
   830
    ^ l
claus
parents: 329
diff changeset
   831
claus
parents: 329
diff changeset
   832
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   833
     (0.5@0.5 corner:0.75@0.75) asFractionalLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   834
     (0.5@0.5 corner:0.75@0.75) asOffsetLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   835
     (0.5@0.5 corner:0.75@0.75) asLayout
20606
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   836
     (0@0 corner:1@1) asLayout
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   837
     (0@0 corner:1@1) asFractionalLayout
12764db7d3a4 #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 20308
diff changeset
   838
     (0@0 corner:1@1) asOffsetLayout
356
claus
parents: 329
diff changeset
   839
    "
claus
parents: 329
diff changeset
   840
!
claus
parents: 329
diff changeset
   841
claus
parents: 329
diff changeset
   842
asLayout
claus
parents: 329
diff changeset
   843
    "return a layoutFrame in which offsets (top, left, bottom, right)
claus
parents: 329
diff changeset
   844
     are taken from corresponding edges of the receiver.
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   845
     If all values are between 0.0 .. 1.0, a fractionalLayout is created,
356
claus
parents: 329
diff changeset
   846
     otherwise, an offsetLayout"
claus
parents: 329
diff changeset
   847
1454
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   848
    |newLayout l r t b|
356
claus
parents: 329
diff changeset
   849
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   850
    newLayout := LayoutFrame new.
1454
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   851
    l := left.
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   852
    r := (self right).
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   853
    t := top.
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   854
    b := (self bottom).
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   855
    ((l between:0.0 and:1.0)
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   856
    and:[(r between:0.0 and:1.0)
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   857
    and:[(t between:0.0 and:1.0)
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   858
    and:[(b between:0.0 and:1.0)]]]) ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   859
	newLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   860
	    leftFraction:l;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   861
	    rightFraction:r;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   862
	    topFraction:t;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   863
	    bottomFraction:b.
356
claus
parents: 329
diff changeset
   864
    ] ifFalse:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   865
	newLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   866
	    leftOffset:l;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   867
	    rightFraction:0 offset:r;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   868
	    topOffset:t;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   869
	    bottomFraction:0 offset:b.
356
claus
parents: 329
diff changeset
   870
    ].
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   871
    ^ newLayout
356
claus
parents: 329
diff changeset
   872
claus
parents: 329
diff changeset
   873
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   874
     (0.5@0.5 corner:0.75@0.75) asFractionalLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   875
     (0.5@0.5 corner:0.75@0.75) asOffsetLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   876
     (0.5@0.5 corner:0.75@0.75) asLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   877
     (0@0 corner:1@1) asLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   878
     (0@0 corner:1@1) asFractionalLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   879
     (0@0 corner:1@1) asOffsetLayout
356
claus
parents: 329
diff changeset
   880
    "
1454
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   881
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   882
    "Modified: 5.6.1996 / 00:45:46 / cg"
356
claus
parents: 329
diff changeset
   883
!
claus
parents: 329
diff changeset
   884
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   885
asOffsetLayout
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   886
    "return a layoutFrame in which offsets (top, left, bottom, right)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   887
     are taken from corresponding edges of the receiver.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   888
     You have to make certain that those are in 0..1."
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   889
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   890
    |newLayout|
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   891
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   892
    newLayout := LayoutFrame new.
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   893
    newLayout
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   894
	leftOffset:(self left);
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   895
	rightFraction:0 offset:(self right);
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   896
	topOffset:(self top);
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   897
	bottomFraction:0 offset:(self bottom).
1151
7991d983b17d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1149
diff changeset
   898
    ^ newLayout
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   899
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   900
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   901
     (0.5@0.5 corner:0.75@0.75) asFractionalLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   902
     (0.5@0.5 corner:0.75@0.75) asOffsetLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   903
     (0.5@0.5 corner:0.75@0.75) asLayout
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   904
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   905
     (10@10 corner:20@20) asFractionalLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   906
     (10@10 corner:20@20) asOffsetLayout
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   907
     (10@10 corner:20@20) asLayout
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   908
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   909
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   910
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   911
356
claus
parents: 329
diff changeset
   912
asPointArray
claus
parents: 329
diff changeset
   913
    "return an array containing my corners (clockwise) and
claus
parents: 329
diff changeset
   914
     the origin again as 5th element. Can be used to convert
claus
parents: 329
diff changeset
   915
     a rectangle into a polygon."
claus
parents: 329
diff changeset
   916
claus
parents: 329
diff changeset
   917
    |org|
claus
parents: 329
diff changeset
   918
claus
parents: 329
diff changeset
   919
    ^ Array with:(org := self origin)
claus
parents: 329
diff changeset
   920
	    with:self topRight
claus
parents: 329
diff changeset
   921
	    with:self corner
claus
parents: 329
diff changeset
   922
	    with:self bottomLeft
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   923
	    with:org
356
claus
parents: 329
diff changeset
   924
claus
parents: 329
diff changeset
   925
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   926
     (10@10 corner:100@100) asPointArray
356
claus
parents: 329
diff changeset
   927
    "
claus
parents: 329
diff changeset
   928
!
claus
parents: 329
diff changeset
   929
1354
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   930
asPolygon
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   931
    "return a polygon from the receiver"
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   932
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   933
    ^ Polygon vertices:self asPointArray
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   934
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   935
    "
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   936
     (10@10 corner:100@100) asPolygon
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   937
    "
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   938
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   939
    "Modified: 8.5.1996 / 20:14:44 / cg"
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   940
!
Claus Gittinger <cg@exept.de>
parents: 1349
diff changeset
   941
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   942
fromLiteralArrayEncoding:encoding
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   943
    "read my values from an encoding.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   944
     The encoding is supposed to be of the form: (Rectangle orgX orgY cornX cornY)"
356
claus
parents: 329
diff changeset
   945
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   946
    left := encoding at:2.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   947
    top := encoding at:3.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   948
    width := (encoding at:4) - left.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   949
    height := (encoding at:5) - top
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   950
356
claus
parents: 329
diff changeset
   951
claus
parents: 329
diff changeset
   952
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   953
     Rectangle new fromLiteralArrayEncoding:#(Rectangle 100 200 300 500)
356
claus
parents: 329
diff changeset
   954
    "
379
5b5a130ccd09 revision added
claus
parents: 362
diff changeset
   955
!
5b5a130ccd09 revision added
claus
parents: 362
diff changeset
   956
421
claus
parents: 384
diff changeset
   957
literalArrayEncoding
1245
c8afea3d5af0 commentary
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   958
    "encode myself as an array, from which a copy of the receiver
c8afea3d5af0 commentary
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   959
     can be reconstructed with #decodeAsLiteralArray.
421
claus
parents: 384
diff changeset
   960
     The encoding is: (Rectangle orgX orgY cornX cornY)"
claus
parents: 384
diff changeset
   961
claus
parents: 384
diff changeset
   962
    ^ Array
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   963
	with:#Rectangle
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   964
	with:left
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   965
	with:top
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   966
	with:(left + width)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   967
	with:(top + height)
421
claus
parents: 384
diff changeset
   968
claus
parents: 384
diff changeset
   969
claus
parents: 384
diff changeset
   970
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   971
     Rectangle new fromLiteralArrayEncoding:#(Rectangle 100 200 300 500)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   972
     (100@200 corner:300@500) literalArrayEncoding
421
claus
parents: 384
diff changeset
   973
    "
claus
parents: 384
diff changeset
   974
claus
parents: 384
diff changeset
   975
    "Modified: 1.9.1995 / 02:16:54 / claus"
1245
c8afea3d5af0 commentary
Claus Gittinger <cg@exept.de>
parents: 1151
diff changeset
   976
    "Modified: 22.4.1996 / 13:00:36 / cg"
421
claus
parents: 384
diff changeset
   977
!
claus
parents: 384
diff changeset
   978
3488
6e1feb9ead68 prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents: 3269
diff changeset
   979
rectangleRelativeTo:aRectangle preferred:prefRectHolder
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   980
    "compute a displayRectangle, treating the receiver like a
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   981
     layoutFrame.
1454
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   982
     This allows rectangles to be used interchangable with Layouts."
379
5b5a130ccd09 revision added
claus
parents: 362
diff changeset
   983
3488
6e1feb9ead68 prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents: 3269
diff changeset
   984
    ^ (self asLayout) rectangleRelativeTo:aRectangle preferred:prefRectHolder
379
5b5a130ccd09 revision added
claus
parents: 362
diff changeset
   985
5b5a130ccd09 revision added
claus
parents: 362
diff changeset
   986
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   987
     (10@20 corner:20@30) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
   988
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
   989
     (0.5@0.5) rectangleRelativeTo:(0@0 corner:100@100) preferred:(0@0 corner:50@50)
379
5b5a130ccd09 revision added
claus
parents: 362
diff changeset
   990
    "
1454
17ff61f7f34e layout stuff & comment
Claus Gittinger <cg@exept.de>
parents: 1453
diff changeset
   991
3488
6e1feb9ead68 prefRect may now be a valueHolder or block
Claus Gittinger <cg@exept.de>
parents: 3269
diff changeset
   992
    "Modified: / 27.5.1998 / 10:20:20 / cg"
356
claus
parents: 329
diff changeset
   993
! !
claus
parents: 329
diff changeset
   994
186
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
   995
!Rectangle methodsFor:'destructive rectangle operations'!
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
   996
356
claus
parents: 329
diff changeset
   997
expandBy:delta
claus
parents: 329
diff changeset
   998
    "destructively expanded the receiver in all directions
claus
parents: 329
diff changeset
   999
     by amount, a Point, Rectangle or Number.
claus
parents: 329
diff changeset
  1000
     Warning: this is a destructive operation, modifying the receiver
claus
parents: 329
diff changeset
  1001
     NOT returning a copy. You have to be certain to be the exclusive
claus
parents: 329
diff changeset
  1002
     owner of the receiver to avoid side effects. See also: #expandedBy:"
claus
parents: 329
diff changeset
  1003
claus
parents: 329
diff changeset
  1004
    |amountPoint deltaLeft deltaTop deltaWidth deltaHeight|
claus
parents: 329
diff changeset
  1005
claus
parents: 329
diff changeset
  1006
    delta isNumber ifTrue:[
claus
parents: 329
diff changeset
  1007
	deltaLeft := deltaTop := delta.
claus
parents: 329
diff changeset
  1008
	deltaWidth := deltaHeight := delta * 2.
claus
parents: 329
diff changeset
  1009
    ] ifFalse:[
claus
parents: 329
diff changeset
  1010
	delta isRectangle ifTrue:[
claus
parents: 329
diff changeset
  1011
	    deltaLeft := delta left.
claus
parents: 329
diff changeset
  1012
	    deltaTop := delta top.
claus
parents: 329
diff changeset
  1013
	    deltaWidth := deltaLeft + delta right.
claus
parents: 329
diff changeset
  1014
	    deltaHeight := deltaTop + delta bottom
claus
parents: 329
diff changeset
  1015
	] ifFalse:[
claus
parents: 329
diff changeset
  1016
	    amountPoint := delta asPoint.
claus
parents: 329
diff changeset
  1017
	    deltaLeft := amountPoint x.
claus
parents: 329
diff changeset
  1018
	    deltaTop := amountPoint y.
claus
parents: 329
diff changeset
  1019
	    deltaWidth := deltaLeft * 2.
claus
parents: 329
diff changeset
  1020
	    deltaHeight := deltaTop * 2.
claus
parents: 329
diff changeset
  1021
	]
claus
parents: 329
diff changeset
  1022
    ].
claus
parents: 329
diff changeset
  1023
claus
parents: 329
diff changeset
  1024
    left := (left - deltaLeft).
claus
parents: 329
diff changeset
  1025
    top := (top - deltaTop).
claus
parents: 329
diff changeset
  1026
    width := (width + deltaWidth).
claus
parents: 329
diff changeset
  1027
    height := (height + deltaHeight).
claus
parents: 329
diff changeset
  1028
claus
parents: 329
diff changeset
  1029
    "
claus
parents: 329
diff changeset
  1030
     |r|
claus
parents: 329
diff changeset
  1031
     r := Rectangle origin:10@10 corner:100@100.
claus
parents: 329
diff changeset
  1032
     r expandBy:5.
claus
parents: 329
diff changeset
  1033
claus
parents: 329
diff changeset
  1034
     r := Rectangle origin:10@10 corner:100@100.
claus
parents: 329
diff changeset
  1035
     r expandBy:(5 @ 0).
claus
parents: 329
diff changeset
  1036
claus
parents: 329
diff changeset
  1037
     r := Rectangle origin:10@10 corner:100@100.
claus
parents: 329
diff changeset
  1038
     r expandBy:(10 @ 10).
claus
parents: 329
diff changeset
  1039
claus
parents: 329
diff changeset
  1040
     r := Rectangle origin:10@10 corner:100@100.
claus
parents: 329
diff changeset
  1041
     r expandBy:( 10@10 corner:20@20 )
claus
parents: 329
diff changeset
  1042
    "
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1043
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1044
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1045
moveBy:aPoint
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1046
    "destructively translate the rectangle by some distance (keeping extent unchanged).
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1047
     sorry for the name inconsistency - but GNU-ST named it that way"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1048
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1049
    left := left + aPoint x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1050
    top := top + aPoint y
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1051
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1052
    "Modified (comment): / 27-11-2017 / 10:42:54 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1053
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1054
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1055
moveTo:aPoint
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1056
    "destructively translate the rectangle to have its origin at aPoint (keeping extent unchanged)."
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1057
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1058
    |diff|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1059
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1060
    diff := aPoint - self origin.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1061
    self origin:aPoint corner:self corner + diff
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1062
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1063
    "Modified (comment): / 27-11-2017 / 10:42:48 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1064
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1065
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1066
scaleBy:scale
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1067
    "scale the receiver rectangle by scale (a Number or Point).
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1068
     This is destructive (modifies the receiver, not a copy) and
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1069
     should only be used if you know, that you are the exclusive owner
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1070
     of the receiver. (use scaledBy if in doubt)"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1071
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1072
    |scalePoint sx sy|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1073
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1074
    (scale isMemberOf:Point) ifTrue:[  "type hint to stc"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1075
	sx := scale x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1076
	sy := scale y
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1077
    ] ifFalse:[
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1078
	scalePoint := scale asPoint.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1079
	sx := scalePoint x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1080
	sy := scalePoint y
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1081
    ].
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1082
    width := width * sx.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1083
    height := height * sy.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1084
    left := left * sx.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1085
    top := top * sy
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1086
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1087
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1088
     (Rectangle origin:10@10 corner:50@50) scaleBy:2
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1089
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1090
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1091
    "its destructive:"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1092
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1093
     |r1 r2|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1094
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1095
     r1 := Rectangle origin:10@10 corner:50@50.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1096
     r2 := r1 scaleBy:2.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1097
     r1
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1098
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1099
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1100
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1101
translateBy:amount
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1102
    "translate (i.e. move) the receiver rectangle
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1103
     by amount, a Point or Number (keeping extent unchanged).
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1104
     This is destructive (modifies the receiver, not a copy) and
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1105
     should only be used if you know, that you are the exclusive owner
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1106
     of the receiver. (use translatedBy if in doubt)"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1107
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1108
    |amountPoint|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1109
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1110
    (amount isMemberOf:Point) ifTrue:[  "type hint to stc"
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1111
        left := left + amount x.
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1112
        top := top + amount y
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1113
    ] ifFalse:[
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1114
        amountPoint := amount asPoint.
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1115
        left := left + amountPoint x.
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1116
        top := top + amountPoint y
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1117
    ]
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1118
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1119
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1120
     (Rectangle origin:10@10 corner:50@50) translateBy:10
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1121
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1122
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1123
    "its destructive:"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1124
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1125
     |r1 r2|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1126
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1127
     r1 := Rectangle origin:10@10 corner:50@50.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1128
     r2 := r1 translateBy:10.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1129
     r1
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1130
    "
22378
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1131
0f034b43ac9b #DOCUMENTATION by cg
Claus Gittinger <cg@exept.de>
parents: 22206
diff changeset
  1132
    "Modified (comment): / 27-11-2017 / 10:43:12 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1133
! !
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1134
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1135
!Rectangle methodsFor:'displaying'!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1136
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1137
displayFilledOn:aGC
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1138
    "display a filled rectangle as represented by the receiver in
1314
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1139
     the graphicsContext, aGC"
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1140
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1141
    aGC fillRectangleX:left y:top width:width height:height
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1142
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1143
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1144
     |v|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1145
1349
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1146
     v := View new openAndWait.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1147
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1148
     (Rectangle origin:10@10 corner:50@50) displayFilledOn:v
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1149
    "
1314
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1150
1349
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1151
    "Modified: 8.5.1996 / 14:40:42 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1152
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1153
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1154
displayStrokedOn:aGC
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1155
    "display an unfilled rectangle as represented by the receiver in
1314
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1156
     the graphicsContext, aGC"
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1157
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1158
    aGC displayRectangleX:left y:top width:width height:height
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1159
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1160
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1161
     |v|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1162
1349
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1163
     v := View new openAndWait.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1164
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1165
     (Rectangle origin:10@10 corner:50@50) displayStrokedOn:v
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1166
    "
1314
18fabbc0e0a6 examples
Claus Gittinger <cg@exept.de>
parents: 1290
diff changeset
  1167
1349
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1168
    "Modified: 8.5.1996 / 14:40:53 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1169
! !
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1170
15730
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  1171
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1172
!Rectangle methodsFor:'printing & storing'!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1173
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1174
printOn:aStream
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1175
    "print the receiver on aStream"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1176
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1177
    aStream nextPutAll:(self class name).
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1178
    aStream nextPutAll:' origin:'.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1179
    (self origin) printOn:aStream.
1443
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1180
    aStream nextPutAll:' extent:'.
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1181
    (self extent) printOn:aStream
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1182
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1183
    "Modified: 29.5.1996 / 00:17:39 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1184
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1185
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1186
storeOn:aStream
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1187
    "store the receiver on aStream; i.e. print an expression which will
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1188
     reconstruct the receiver"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1189
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1190
    aStream nextPut:$(.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1191
    aStream nextPutAll:(self class name).
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1192
    aStream nextPutAll:' origin:'.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1193
    (self origin) storeOn:aStream.
1443
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1194
    aStream nextPutAll:' extent:'.
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1195
    (self extent) storeOn:aStream.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1196
    aStream nextPut:$)
1443
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1197
d747d574e26d checkin from browser
Claus Gittinger <cg@exept.de>
parents: 1390
diff changeset
  1198
    "Modified: 29.5.1996 / 00:17:42 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1199
! !
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1200
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1201
!Rectangle methodsFor:'queries'!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1202
1349
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1203
bounds
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1204
    "return the smallest enclosing rectangle"
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1205
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1206
    ^ self
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1207
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1208
    "Created: 8.5.1996 / 13:56:24 / cg"
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1209
    "Modified: 8.5.1996 / 14:06:38 / cg"
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1210
!
275388fd5271 comments & more Geometric functionality
Claus Gittinger <cg@exept.de>
parents: 1314
diff changeset
  1211
2381
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1212
computeBounds
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1213
    "return the smallest enclosing rectangle"
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1214
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1215
    ^ self
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1216
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1217
    "Modified: 8.5.1996 / 14:06:38 / cg"
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1218
    "Created: 12.2.1997 / 11:44:45 / cg"
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1219
!
10af98758a49 added dummy Scale & InverseScale classVars.
Claus Gittinger <cg@exept.de>
parents: 2373
diff changeset
  1220
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1221
contains:aRectangle
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1222
    "return true, if the argument, aRectangle is equal to or
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1223
     is contained fully within the receiver"
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1224
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1225
%{  /* NOCONTEXT */
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1226
    /*
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1227
     * claus: this may be often called by objectView
19960
32fa5617bd7a #DOCUMENTATION by mawalch
mawalch
parents: 18895
diff changeset
  1228
     * the primitive code below (although looking ugly)
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1229
     * speeds that up by almost a factor of 2 ...
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1230
     */
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1231
    OBJ slf = self;
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1232
    OBJ rct = aRectangle;
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1233
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1234
    if (__isNonNilObject(rct)
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1235
     && __qClass(rct) == Rectangle) {
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1236
	OBJ r_l, r_w, r_t, r_h, l, w, t, h;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1237
	INT r_ir, r_il, r_ib, r_it;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1238
	INT il, it, ir, ib, iw, ih;
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1239
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1240
	r_l = __OINST(rct, left);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1241
	l = __OINST(slf, left);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1242
	if (__bothSmallInteger(r_l, l)) {
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1243
#ifndef POSITIVE_ADDRESSES      /* tag in low-bit */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1244
	    il = (INT)(l);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1245
	    r_il = (INT)(r_l);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1246
#else
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1247
	    il = __intVal(l);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1248
	    r_il = __intVal(r_l);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1249
#endif
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1250
	    if (il > r_il) { RETURN (false); }   /* left > aRectangle left */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1251
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1252
	    r_t = __OINST(rct, top);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1253
	    t = __OINST(slf, top);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1254
	    if (__bothSmallInteger(r_t, t)) {
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1255
#ifndef POSITIVE_ADDRESSES      /* tag in low-bit */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1256
		it = (INT)(t);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1257
		r_it = (INT)(r_t);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1258
#else
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1259
		it = __intVal(t);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1260
		r_it = __intVal(r_t);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1261
#endif
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1262
		if (it > r_it) { RETURN (false); }   /* top > aRectangle top */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1263
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1264
		r_w = __OINST(rct, width);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1265
		w = __OINST(slf, width);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1266
		if (__bothSmallInteger(r_w, w)) {
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1267
#ifndef POSITIVE_ADDRESSES      /* tag in low-bit */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1268
		    ir = il + (INT)(w);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1269
		    r_ir = r_il + (INT)(r_w);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1270
#else
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1271
		    ir = il + __intVal(w);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1272
		    r_ir = r_il + __intVal(r_w);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1273
#endif
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1274
		    if (ir < r_ir) { RETURN (false); }   /* (left + width) < aRectangle right */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1275
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1276
		    r_h = __OINST(rct, height);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1277
		    h = __OINST(slf, height);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1278
		    if (__bothSmallInteger(r_h, h)) {
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1279
#ifndef POSITIVE_ADDRESSES      /* tag in low-bit */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1280
			ib = it + (INT)(h);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1281
			r_ib = r_it + (INT)(r_h);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1282
#else
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1283
			ib = it + __intVal(h);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1284
			r_ib = r_it + __intVal(r_h);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1285
#endif
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1286
			if (ib < r_ib) { RETURN (false); }   /* (top + height) < aRectangle bottom */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1287
			RETURN (true);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1288
		    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1289
		}
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1290
	    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1291
	}
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1292
    }
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1293
%}.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1294
    (left <= aRectangle left) ifTrue:[
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1295
      ((left + width) >= aRectangle right) ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1296
	(top <= aRectangle top) ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1297
	  ((top + height) >= aRectangle bottom) ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1298
	    ^ true
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1299
	  ]
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1300
	]
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1301
      ]
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1302
    ].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1303
    ^ false
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1304
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1305
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1306
     (0@0 corner:100@100) contains:(10@10 corner:90@90)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1307
     (0@0 corner:100@100) contains:(10@10 corner:100@100)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1308
     (0@0 corner:100@100) contains:(10@10 corner:110@100)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1309
     (0@0 corner:100@100) contains:(10@10 corner:100@110)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1310
     (10@10 corner:100@100) contains:(0@10 corner:100@100)
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1311
    "
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1312
!
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1313
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1314
containsPoint:aPoint
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1315
    "return true, if the argument, aPoint is contained in the receiver"
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1316
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1317
    |px py|
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1318
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1319
    px := aPoint x.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1320
    (px < left)           ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1321
    (px > (left + width)) ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1322
    py := aPoint y.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1323
    (py < top)            ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1324
    (py > (top + height)) ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1325
    ^ true
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1326
!
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1327
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1328
containsPointX:x y:y
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1329
    "return true, if the point defined by x@y is contained in the receiver.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1330
     This is the same as containsPoint:, but can be used if the coordinates
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1331
     are already available as separate numbers to avoid useless creation of a
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1332
     temporary point."
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1333
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1334
    (x < left)           ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1335
    (x > (left + width)) ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1336
    (y < top)            ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1337
    (y > (top + height)) ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1338
    ^ true
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1339
!
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1340
4890
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1341
corners
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1342
    "Return an array of corner points"
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1343
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1344
    ^ Array
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1345
	with: self topLeft
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1346
	with: self bottomLeft
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1347
	with: self bottomRight
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1348
	with: self topRight
4890
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1349
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1350
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1351
!
fa9abaa225ef checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4869
diff changeset
  1352
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1353
innerCorners
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1354
    "Return an array of inner corner points,
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1355
     ie, the most extreme pixels included.
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1356
     Added for Aqueak compatibility."
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1357
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1358
    ^ (self topLeft corner:(self bottomRight - (1@1))) corners
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1359
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1360
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1361
     (10@10 corner:100@100) corners
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1362
     (10@10 corner:100@100) innerCorners
4894
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1363
    "
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1364
!
e017cd6402bb checkin from browser
Claus Gittinger <cg@exept.de>
parents: 4890
diff changeset
  1365
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1366
intersects:aRectangle
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1367
    "return true, if the intersection between the argument, aRectangle
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1368
     and the receiver is not empty"
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1369
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1370
    |b r|
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1371
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1372
%{  /* NOCONTEXT */
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1373
    /*
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1374
     * claus: this is one of the mostly called methods in
19960
32fa5617bd7a #DOCUMENTATION by mawalch
mawalch
parents: 18895
diff changeset
  1375
     * the objectView - the primitive code below (although looking ugly)
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1376
     * speeds up drawing by almost a factor of 2 ...
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1377
     */
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1378
    OBJ slf = self;
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1379
    OBJ rct = aRectangle;
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1380
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1381
    if (__isNonNilObject(rct)
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1382
     && __qClass(rct) == Rectangle) {
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1383
	OBJ r_l, r_w, r_t, r_h, l, w, t, h;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1384
	INT r_ir, r_il, r_ib, r_it;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1385
	INT il, it, ir, ib, iw, ih;
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1386
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1387
	r_l = __OINST(rct, left);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1388
	r_w = __OINST(rct, width);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1389
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1390
	if (__bothSmallInteger(r_l, r_w)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1391
	    r_t = __OINST(rct, top);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1392
	    r_h = __OINST(rct, height);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1393
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1394
	    l = __OINST(slf, left);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1395
	    w = __OINST(slf, width);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1396
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1397
	    if (__bothSmallInteger(l, w)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1398
		t = __OINST(slf, top);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1399
		h = __OINST(slf, height);
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1400
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1401
#ifndef POSITIVE_ADDRESSES      /* tag in low-bit */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1402
		r_il = (INT)(r_l);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1403
		r_ir = r_il + (INT)(r_w) - 1;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1404
		il = (INT)(l);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1405
		if (r_ir < il) { RETURN (false); }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1406
		ir = il + (INT)(w) - 1;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1407
		if (r_il > ir) { RETURN (false); }
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1408
#else                           /* tag in hi-bit */
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1409
		r_il = __intVal(r_l);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1410
		r_ir = r_il + __intVal(r_w);        /* aRectangle right */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1411
		il = __intVal(l);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1412
		if (r_ir < il) { RETURN (false); }  /* (aRectangle right) < left */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1413
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1414
		ir = il + __intVal(w);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1415
		if (r_il > ir) { RETURN (false); }   /* (aRectangle left) > r */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1416
#endif
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1417
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1418
		if (__bothSmallInteger(r_t, r_h)) {
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1419
		    if (__bothSmallInteger(t, h)) {
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1420
#ifndef POSITIVE_ADDRESSES
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1421
			r_it = (INT)(r_t);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1422
			r_ib = r_it + (INT)(r_h) - 1; /* aRectangle bottom */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1423
			it = (INT)(t);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1424
			if (r_ib < it) { RETURN (false); } /* (aRectangle bottom) < top */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1425
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1426
			ib = it + (INT)(h) - 1;
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1427
			if (r_it > ib) { RETURN (false); } /* (aRectangle top) > b */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1428
#else
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1429
			r_it = __intVal(r_t);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1430
			r_ib = r_it + __intVal(r_h); /* aRectangle bottom */
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1431
			it = __intVal(t);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1432
			if (r_ib < it) { RETURN (false); } /* (aRectangle bottom) < top */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1433
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1434
			ib = it + __intVal(h);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1435
			if (r_it > ib) { RETURN (false); } /* (aRectangle top) > b */
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1436
#endif
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1437
			RETURN (true);
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1438
		    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1439
		}
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1440
	    }
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1441
	}
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1442
    }
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1443
%}.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1444
    (aRectangle right)  < left ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1445
    (aRectangle bottom) < top  ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1446
    r := left + width.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1447
    (aRectangle left)   > r    ifTrue:[^ false].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1448
    b := top + height.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1449
    (aRectangle top)    > b    ifTrue:[^ false].
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1450
    ^ true
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1451
!
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1452
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1453
isContainedIn:aRectangle
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1454
    "return true, if the receiver is fully contained within
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1455
     the argument, aRectangle"
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1456
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1457
    (aRectangle left <= left) ifTrue:[
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1458
      (aRectangle right >= (left + width)) ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1459
	(aRectangle top <= top) ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1460
	  (aRectangle bottom >= (top + height)) ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1461
	    ^ true
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1462
	  ]
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1463
	]
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1464
      ]
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1465
    ].
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1466
    ^ false
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1467
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1468
    "
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1469
     |r|
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1470
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1471
     r := Rectangle origin:10@10 corner:100@100.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1472
     r isContainedIn: (Rectangle origin:10@10 corner:100@100).
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1473
     r isContainedIn: (Rectangle origin:11@10 corner:100@100).
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1474
     r isContainedIn: (Rectangle origin:9@10 corner:100@100).
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  1475
    "
186
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
  1476
! !
a4c3032fc825 *** empty log message ***
claus
parents: 93
diff changeset
  1477
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1478
!Rectangle methodsFor:'rectangle operations'!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1479
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1480
+ aPoint
356
claus
parents: 329
diff changeset
  1481
    "return a new rectangle with same extent as receiver but
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1482
     origin translated by the argument, aPoint"
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1483
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1484
    ^ self translatedBy:aPoint
217
a0400fdbc933 *** empty log message ***
claus
parents: 208
diff changeset
  1485
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1486
    "Modified: / 24-08-2017 / 12:22:52 / cg"
2274
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1487
!
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1488
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1489
- aPoint
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1490
    "return a new rectangle with same extent as receiver but
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1491
     origin translated by the argument, aPoint"
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1492
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1493
    |amountPoint|
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1494
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1495
    (aPoint isMemberOf:SmallInteger) ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1496
        "/ this is an stc optimization (isMemberOf:SmallInteger is a hint to inline addition!!)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1497
        ^ Rectangle
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1498
            left:(left - aPoint)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1499
            top:(top - aPoint)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1500
            width:width
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1501
            height:height
2274
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1502
    ].
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1503
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1504
    amountPoint := aPoint asPoint.
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1505
    ^ Rectangle left:(left - amountPoint x)
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1506
                 top:(top - amountPoint y)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1507
               width:width
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1508
              height:height
2274
891194fa4b17 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 1507
diff changeset
  1509
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1510
    "Created: / 25-01-1997 / 17:30:21 / cg"
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1511
    "Modified (format): / 24-08-2017 / 12:23:53 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1512
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1513
21269
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1514
areasOutside:aRectangle
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1515
    "Answer an Array of Rectangles comprising the parts of the receiver 
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1516
     not intersecting aRectangle.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1517
     That is all areas with no common pixels."
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1518
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1519
    |areas|
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1520
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1521
    "Make sure the intersection is non-empty"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1522
    (self origin <= aRectangle corner and: [aRectangle origin <= self corner]) ifFalse: [
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1523
        ^ Array with: self
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1524
    ].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1525
    areas := OrderedCollection new.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1526
    self areasOutside:aRectangle do:[:r | areas add:r].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1527
    ^ areas asArray
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1528
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1529
    "/ cg: the old code below was wrong ...
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1530
21269
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1531
"/    "----------------------------------------------------------------
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1532
"/    | added for GNU-ST compatibility
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1533
"/    |
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1534
"/    | author: Doug McCallum <uunet!!ico.isc.com!!dougm>
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1535
"/    |
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1536
"/    |areasOutside: aRectangle
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1537
"/    | most complicated of the Rectangle primitives
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1538
"/    | The basic methodology is to first determine that there is an
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1539
"/    | intersection by finding the overlapping rectangle.  From the
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1540
"/    | overlapping rectangle, first determine if it runs along an edge.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1541
"/    | If it doesn't, extend the rectangle up to the top edge and add
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1542
"/    | the new rectangle to the collection and start the rest of the
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1543
"/    | process.  If the left edge does not touch the left edge of self,
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1544
"/    | extend it to the edge saving the new rectangle.  Then do the
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1545
"/    | same to the right edge.  Then check top and bottom edges.  Most
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1546
"/    | of the time only 2 or 3 rectangles get formed, occasionally 4.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1547
"/    | It should be possible to never get more than 3 but requires more
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1548
"/    | work.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1549
"/     ----------------------------------------------------------------"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1550
"/
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1551
"/    | collect iRect tmp |
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1552
"/
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1553
"/    iRect := self intersect: aRectangle.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1554
"/    iRect isNil ifTrue: [^nil]. "case of no intersection"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1555
"/                                "the collect collection gathers Rectangles"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1556
"/    collect := OrderedCollection new: 4.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1557
"/                                "is it floating or on the edge?"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1558
"/    (((((iRect top) ~= self top)
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1559
"/         and: [ (iRect bottom) ~= self bottom ])
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1560
"/         and: [ (iRect left) ~= self left ])
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1561
"/         and: [ (iRect right) ~= self right ] )
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1562
"/        ifTrue: "entirely in the center."
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1563
"/            [tmp := Rectangle origin: (Point x: iRect left y: self top)
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1564
"/                              corner: iRect bottomRight.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1565
"/             collect add: tmp.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1566
"/             iRect := iRect merge: tmp].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1567
"/    ((iRect left) ~= self left)
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1568
"/        ifTrue:                 "doesn't touch left edge so make it touch"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1569
"/            [tmp := Rectangle origin: (Point x: self left y: iRect top)
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1570
"/                              corner: iRect bottomLeft.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1571
"/                 collect add: tmp.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1572
"/                                "merge new (tmp) with overlap to keep track"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1573
"/                 iRect := iRect merge: tmp].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1574
"/    ((iRect right) ~= self right)
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1575
"/        ifTrue:                 "doesn't touch right edge so extend it"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1576
"/            [tmp := Rectangle origin: iRect topRight
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1577
"/                              corner: (Point x: self right y: iRect bottom).
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1578
"/                 collect add: tmp.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1579
"/                 iRect := iRect merge: tmp].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1580
"/    (((iRect left) ~= self left) or: [(iRect top) ~= self top])
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1581
"/        ifTrue:                 "whole top part can be taken now"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1582
"/            [tmp := Rectangle origin: self origin corner: iRect topRight.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1583
"/                 collect add: tmp].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1584
"/    (((iRect right) ~= self right) or: [(iRect bottom) ~= self bottom])
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1585
"/        ifTrue:                 "whole bottom open and can be taken"
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1586
"/            [tmp := Rectangle origin: iRect bottomLeft corner: self corner.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1587
"/                 collect add: tmp].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1588
"/    ^collect
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1589
!
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1590
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1591
areasOutside:aRectangle do:aBlock
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1592
    "evaluate aBlock for Rectangles comprising the parts of the receiver 
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1593
     not intersecting aRectangle.
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1594
     That is all areas with no common pixels."
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1595
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1596
    |yOrigin yCorner origin corner rectOrigin rectCorner|
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1597
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1598
    origin := self origin.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1599
    corner := self corner.
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1600
    rectOrigin := aRectangle origin.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1601
    rectCorner := aRectangle corner.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1602
    
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1603
    "Make sure the intersection is non-empty"
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1604
    (origin <= rectCorner and: [rectOrigin <= corner]) ifFalse: [ 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1605
        aBlock value:self. 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1606
        ^ self
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1607
    ].
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1608
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1609
    rectOrigin y > origin y ifTrue: [ 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1610
        aBlock value: (origin corner: corner x @ (yOrigin := rectOrigin y)) 
21269
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1611
    ] ifFalse: [ 
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1612
        yOrigin := origin y 
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1613
    ].
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1614
    rectCorner y < corner y ifTrue: [ 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1615
        aBlock value: (origin x @ (yCorner := rectCorner y) corner: corner) 
21269
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1616
    ] ifFalse: [
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1617
        yCorner := corner y
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1618
    ].
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1619
    rectOrigin x > origin x ifTrue: [ 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1620
        aBlock value: (origin x @ yOrigin corner: rectOrigin x @ yCorner) 
21269
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1621
    ].
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1622
    rectCorner x < corner x ifTrue: [ 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1623
        aBlock value: (rectCorner x @ yOrigin corner: corner x @ yCorner) 
21269
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1624
    ].
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1625
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1626
    "
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1627
     self assert:
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1628
            ((0@0 corner:100@100) areasOutside:(0@0 corner:50@50)) asArray
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1629
            = { (Rectangle origin:0@50 extent:100@50) . (Rectangle origin:50@0 extent:50@50) }
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1630
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1631
     self assert:
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1632
            ((0@0 corner:150@100) areasOutside:(0@0 corner:100@100)) asArray
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1633
            = { (Rectangle origin:100@0 extent:50@100) }
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1634
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1635
     self assert:
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1636
            ((0@0 corner:100@150) areasOutside:(0@0 corner:100@100)) asArray
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1637
            = { (Rectangle origin:0@100 extent:100@50) }
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1638
    "
a12e4696432c #FEATURE by cg
Claus Gittinger <cg@exept.de>
parents: 20606
diff changeset
  1639
    
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1640
    "/ cg: the old code below was wrong ...
1124
53f6970d9d7d *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 867
diff changeset
  1641
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1642
"/    "----------------------------------------------------------------
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1643
"/    | added for GNU-ST compatibility
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1644
"/    |
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1645
"/    | author: Doug McCallum <uunet!!ico.isc.com!!dougm>
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1646
"/    |
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1647
"/    |areasOutside: aRectangle
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1648
"/    | most complicated of the Rectangle primitives
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1649
"/    | The basic methodology is to first determine that there is an
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1650
"/    | intersection by finding the overlapping rectangle.  From the
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1651
"/    | overlapping rectangle, first determine if it runs along an edge.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1652
"/    | If it doesn't, extend the rectangle up to the top edge and add
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1653
"/    | the new rectangle to the collection and start the rest of the
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1654
"/    | process.  If the left edge does not touch the left edge of self,
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1655
"/    | extend it to the edge saving the new rectangle.  Then do the
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1656
"/    | same to the right edge.  Then check top and bottom edges.  Most
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1657
"/    | of the time only 2 or 3 rectangles get formed, occasionally 4.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1658
"/    | It should be possible to never get more than 3 but requires more
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1659
"/    | work.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1660
"/     ----------------------------------------------------------------"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1661
"/
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1662
"/    | collect iRect tmp |
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1663
"/
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1664
"/    iRect := self intersect: aRectangle.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1665
"/    iRect isNil ifTrue: [^nil]. "case of no intersection"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1666
"/                                "the collect collection gathers Rectangles"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1667
"/    collect := OrderedCollection new: 4.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1668
"/                                "is it floating or on the edge?"
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1669
"/    (((((iRect top) ~= self top)
4863
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1670
"/         and: [ (iRect bottom) ~= self bottom ])
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1671
"/         and: [ (iRect left) ~= self left ])
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1672
"/         and: [ (iRect right) ~= self right ] )
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1673
"/        ifTrue: "entirely in the center."
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1674
"/            [tmp := Rectangle origin: (Point x: iRect left y: self top)
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1675
"/                              corner: iRect bottomRight.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1676
"/             collect add: tmp.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1677
"/             iRect := iRect merge: tmp].
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1678
"/    ((iRect left) ~= self left)
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1679
"/        ifTrue:                 "doesn't touch left edge so make it touch"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1680
"/            [tmp := Rectangle origin: (Point x: self left y: iRect top)
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1681
"/                              corner: iRect bottomLeft.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1682
"/                 collect add: tmp.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1683
"/                                "merge new (tmp) with overlap to keep track"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1684
"/                 iRect := iRect merge: tmp].
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1685
"/    ((iRect right) ~= self right)
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1686
"/        ifTrue:                 "doesn't touch right edge so extend it"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1687
"/            [tmp := Rectangle origin: iRect topRight
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1688
"/                              corner: (Point x: self right y: iRect bottom).
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1689
"/                 collect add: tmp.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1690
"/                 iRect := iRect merge: tmp].
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1691
"/    (((iRect left) ~= self left) or: [(iRect top) ~= self top])
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1692
"/        ifTrue:                 "whole top part can be taken now"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1693
"/            [tmp := Rectangle origin: self origin corner: iRect topRight.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1694
"/                 collect add: tmp].
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1695
"/    (((iRect right) ~= self right) or: [(iRect bottom) ~= self bottom])
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1696
"/        ifTrue:                 "whole bottom open and can be taken"
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1697
"/            [tmp := Rectangle origin: iRect bottomLeft corner: self corner.
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1698
"/                 collect add: tmp].
9544c9e5c17e fixed #areasOutside:
Claus Gittinger <cg@exept.de>
parents: 4861
diff changeset
  1699
"/    ^collect
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1700
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1701
    "Modified: / 24-08-2017 / 12:32:42 / cg"
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
  1702
!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  1703
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1704
encompass:aPoint
4864
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
  1705
    "return a Rectangle that contains both the receiver and aPoint."
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
  1706
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1707
    ^ Rectangle
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1708
	origin: (self origin min: aPoint)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1709
	corner: (self corner max: aPoint)
4864
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
  1710
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
  1711
!
3ff21a7f977d more rectangle functions.
Claus Gittinger <cg@exept.de>
parents: 4863
diff changeset
  1712
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1713
expandedBy:delta
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1714
    "return a new rectangle which is expanded in all directions
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1715
     by amount, a Point, Rectangle or Number"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1716
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1717
    ^ self copy expandBy:delta
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1718
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1719
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1720
     |r|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1721
     r := Rectangle origin:10@10 corner:100@100.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1722
     r expandedBy:5.
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1723
     r expandedBy:(5 @ 0).
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1724
     r expandedBy:(10 @ 10).
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1725
     r expandedBy:( 10@10 corner:20@20 )
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1726
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1727
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1728
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1729
insetBy: delta
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1730
    "return a new rectangle which is inset in all directions
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1731
     by delta, a Point, Rectangle or Number"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1732
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1733
    |amountPoint deltaLeft deltaTop deltaWidth deltaHeight|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1734
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1735
    delta isNumber ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1736
        deltaLeft := deltaTop := delta.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1737
        deltaWidth := deltaHeight := delta * 2.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1738
    ] ifFalse:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1739
        delta isRectangle ifTrue:[
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1740
            deltaLeft := delta left.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1741
            deltaTop := delta top.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1742
            deltaWidth := deltaLeft + delta right.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1743
            deltaHeight := deltaTop + delta bottom
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1744
        ] ifFalse:[
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1745
            amountPoint := delta asPoint.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1746
            deltaLeft := amountPoint x.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1747
            deltaTop := amountPoint y.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1748
            deltaWidth := deltaLeft * 2.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1749
            deltaHeight := deltaTop * 2.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1750
        ]
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1751
    ].
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1752
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1753
    ^ Rectangle 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1754
        left:(left + deltaLeft) top:(top + deltaTop)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1755
        width:(width - deltaWidth) height:(height - deltaHeight)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1756
        
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1757
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1758
     |r|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1759
     r := Rectangle origin:10@10 corner:100@100.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1760
     r insetBy:5.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1761
     r insetBy:(5 @ 0).
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1762
     r insetBy:(10 @ 10).
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1763
     r insetBy:( 10@10 corner:20@20 )
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1764
    "
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1765
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1766
    "Modified (format): / 24-08-2017 / 12:27:04 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1767
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1768
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1769
insetOriginBy:originDelta cornerBy:cornerDelta
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1770
    "return a new rectangle which is inset by originDelta
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1771
     and cornerDelta; both may be instances of Point or Number"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1772
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1773
    ^ Rectangle
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1774
	origin:(left @ top) + originDelta asPoint
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1775
	corner:(self corner - cornerDelta asPoint)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1776
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1777
     |r|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1778
     r := Rectangle origin:10@10 corner:100@100.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1779
     r insetOriginBy:5 cornerBy:10.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1780
     r insetOriginBy:10@5 cornerBy:10.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1781
     r insetOriginBy:10 cornerBy:10@5.
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1782
     r insetOriginBy:10@10 cornerBy:20@20.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1783
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1784
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1785
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1786
intersect:aRectangle
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1787
    "return a new rectangle covering the intersection of the receiver
5016
887f22f2fde3 comment
Claus Gittinger <cg@exept.de>
parents: 5007
diff changeset
  1788
     and the argument, aRectangle (i.e. the area covered by both).
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1789
     the rectangles must intersect for a valid return"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1790
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1791
    ^ Rectangle 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1792
        left:(left max:(aRectangle left))
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1793
        right:((left + width) min:(aRectangle right))
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1794
        top:(top max:(aRectangle top))
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1795
        bottom:((top + height) min:(aRectangle bottom))
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1796
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1797
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1798
     |r1 r2|
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1799
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1800
     r1 := Rectangle origin:10@10 corner:100@100.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1801
     r2 := Rectangle origin:50@50 corner:150@75.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1802
     r1 intersect:r2
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1803
    "
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1804
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1805
    "Modified (format): / 24-08-2017 / 12:26:42 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1806
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1807
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1808
merge:aRectangle
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1809
    "return a new rectangle covering both the receiver
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1810
     and the argument, aRectangle"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1811
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1812
    ^ Rectangle 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1813
        left:(left min:(aRectangle left))
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1814
        right:((left + width) max:(aRectangle right))
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1815
        top:(top min:(aRectangle top))
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1816
        bottom:((top + height) max:(aRectangle bottom))
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1817
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1818
    "
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1819
     (Rectangle origin:10@10 corner:100@100)
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1820
         merge:(Rectangle origin:20@20 corner:110@110)
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1821
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1822
     (Rectangle origin:10@10 corner:100@100)
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1823
         merge:(Rectangle origin:20@20 corner:100@100)
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1824
    "
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1825
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1826
    "Modified (comment): / 24-08-2017 / 12:26:28 / cg"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1827
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1828
77
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
  1829
nonIntersections:aRectangle
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
  1830
    "this is the same as areasOutside: - for ST/V compatibility only"
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
  1831
6c38ca59927f *** empty log message ***
claus
parents: 59
diff changeset
  1832
    ^ self areasOutside:aRectangle
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1833
!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1834
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1835
quickMerge: aRectangle
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1836
    "return the receiver if it encloses the given rectangle,
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1837
     or the merge of the two rectangles if it doesn't.
8884
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1838
     This method is an optimized version of merge: to reduce extra rectangle creations."
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1839
4869
45bae3b31eef Complete previous fix. (Stefan)
Claus Gittinger <cg@exept.de>
parents: 4868
diff changeset
  1840
    | useRcvr rLeft rTop rRight rBottom minX maxX minY maxY |
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1841
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1842
    useRcvr := true.
8884
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1843
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1844
    rLeft := aRectangle left.
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1845
    rTop := aRectangle top.
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1846
    rRight := aRectangle right.
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1847
    rBottom := aRectangle bottom.
8001
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1848
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1849
    minX := left.
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1850
    rLeft < minX ifTrue: [useRcvr := false. minX := rLeft].
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1851
    maxX := self right.
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1852
    rRight > maxX ifTrue: [useRcvr := false. maxX := rRight].
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1853
    minY := top.
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1854
    rTop < minY ifTrue: [useRcvr := false. minY := rTop].
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1855
    maxY := self bottom.
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1856
    rBottom > maxY ifTrue: [useRcvr := false. maxY := rBottom].
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1857
8884
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1858
    useRcvr ifTrue: [
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1859
	^ self
8884
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1860
    ].
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1861
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1862
    minX = rLeft ifTrue:[
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1863
	maxX = rRight ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1864
	    minY = rTop ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1865
		maxY = rBottom ifTrue:[
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1866
		    ^ aRectangle
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1867
		].
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1868
	    ].
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1869
	].
8884
c864e1e7d7f7 *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8076
diff changeset
  1870
    ].
8001
7d81fbff74ad *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 7859
diff changeset
  1871
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1872
    ^ Rectangle left:minX top:minY right:maxX bottom:maxY.
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1873
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1874
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1875
     (Rectangle origin:10@10 corner:100@100)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1876
	 quickMerge:(Rectangle origin:20@20 corner:110@110)
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1877
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1878
     (Rectangle origin:10@10 corner:100@100)
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1879
	 quickMerge:(Rectangle origin:20@20 corner:100@100)
4859
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1880
    "
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1881
!
592f07591ca2 added #quickMerge:;
Claus Gittinger <cg@exept.de>
parents: 3488
diff changeset
  1882
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1883
scaledBy:scale
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1884
    "return a new rectangle which is the receiver
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1885
     scaled by scale"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1886
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1887
    |scalePoint sx sy|
356
claus
parents: 329
diff changeset
  1888
18820
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
  1889
    (scale isMemberOf:SmallInteger) ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1890
        "/ this is an stc optimization (a hint to inline)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1891
        ^ Rectangle 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1892
            left:(left * scale) top:(top * scale)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1893
            width:(width * scale) height:(height * scale)
18820
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
  1894
    ].
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
  1895
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1896
    scalePoint := scale asPoint.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1897
    sx := scalePoint x.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1898
    sy := scalePoint y.
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1899
    ^ Rectangle 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1900
        left:(left * sx) top:(top * sy)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1901
        width:(width * sx) height:(height * sy)
356
claus
parents: 329
diff changeset
  1902
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1903
     (Rectangle origin:10@10 corner:50@50) scaledBy:2
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1904
    "
356
claus
parents: 329
diff changeset
  1905
20018
374cd31838c4 #DOCUMENTATION by mawalch
mawalch
parents: 19960
diff changeset
  1906
    "it is NOT destructive:"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1907
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1908
     |r1 r2|
356
claus
parents: 329
diff changeset
  1909
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1910
     r1 := Rectangle origin:10@10 corner:50@50.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1911
     r2 := r1 scaledBy:2.
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1912
     r1
356
claus
parents: 329
diff changeset
  1913
    "
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1914
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1915
    "Modified (comment): / 24-08-2017 / 12:28:45 / cg"
356
claus
parents: 329
diff changeset
  1916
!
claus
parents: 329
diff changeset
  1917
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1918
scaledBy:scale translatedBy:translation
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1919
    "return a new rectangle which is translated (i.e. moved)
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1920
     by translation, aPoint or Number and scaled by scale, aPoint or number."
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1921
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1922
    |x y w h translationPoint scalePoint sx sy|
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1923
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1924
    (translation isNil and:[scale isNil]) ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1925
        ^ self.
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1926
    ].
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1927
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1928
    x := left.
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1929
    y := top.
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1930
    w := width.
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1931
    h := height.
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1932
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1933
    scale notNil ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1934
        (scale isMemberOf:SmallInteger) ifTrue:[
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1935
            "/ this is an stc optimization (a hint to inline)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1936
            x := x * scale.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1937
            y := y * scale.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1938
            w := w * scale.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1939
            h := h * scale.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1940
        ] ifFalse:[
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1941
            scalePoint := scale asPoint.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1942
            sx := scalePoint x.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1943
            sy := scalePoint y.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1944
            x := x * sx.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1945
            y := y * sy.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1946
            w := w * sx.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1947
            h := h * sy.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1948
        ].
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1949
    ].
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1950
    translation notNil ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1951
        (translation isMemberOf:SmallInteger) ifTrue:[
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1952
            "/ this is an stc optimization (to inline)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1953
            x := x + translation.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1954
            y := y + translation.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1955
        ] ifFalse:[
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1956
            translationPoint := translation asPoint.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1957
            x := x + translationPoint x.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1958
            y := y + translationPoint y.
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1959
        ].
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1960
    ].
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1961
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1962
    ^ Rectangle left:x top:y width:w height:h.
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1963
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1964
    "
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1965
     (Rectangle origin:10@10 corner:50@50) scaledBy:2 translatedBy:10
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1966
    "
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1967
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1968
    "Modified (format): / 24-08-2017 / 12:25:54 / cg"
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1969
!
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1970
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1971
translatedBy:amount
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1972
    "return a new rectangle which is translated (i.e. moved)
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1973
     by amount, aPoint or Number"
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1974
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1975
    |amountPoint|
356
claus
parents: 329
diff changeset
  1976
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1977
    (amount isMemberOf:SmallInteger) ifTrue:[
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1978
        "/ this is an stc optimization (a hint to inline)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1979
        ^ Rectangle
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1980
            left:(left + amount) top:(top + amount)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1981
            width:width height:height
18892
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1982
    ].
89fe764ff616 #FEATURE
Stefan Vogel <sv@exept.de>
parents: 18820
diff changeset
  1983
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1984
    amountPoint := amount asPoint.
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1985
    ^ Rectangle 
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1986
        left:(left + amountPoint x) top:(top + amountPoint y)
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1987
        width:width height:height
356
claus
parents: 329
diff changeset
  1988
    "
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1989
     (Rectangle origin:10@10 corner:50@50) translatedBy:10
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1990
    "
356
claus
parents: 329
diff changeset
  1991
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  1992
    "it's NOT destructive:"
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1993
    "
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1994
     |r1 r2|
356
claus
parents: 329
diff changeset
  1995
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1996
     r1 := Rectangle origin:10@10 corner:50@50.
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  1997
     r2 := r1 translatedBy:10.
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  1998
     r1
356
claus
parents: 329
diff changeset
  1999
    "
22206
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  2000
f281a8473915 #REFACTORING by cg
Claus Gittinger <cg@exept.de>
parents: 21311
diff changeset
  2001
    "Modified (format): / 24-08-2017 / 12:27:46 / cg"
356
claus
parents: 329
diff changeset
  2002
! !
claus
parents: 329
diff changeset
  2003
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2004
!Rectangle methodsFor:'testing'!
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2005
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2006
canBeFilled
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2007
    "return true, if the receiver can be drawn as a filled geometric.
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2008
     Always true here."
1149
69b30e3494fa added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  2009
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2010
    ^ true
1149
69b30e3494fa added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  2011
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2012
    "Created: 8.5.1996 / 08:16:47 / cg"
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2013
!
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2014
11743
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2015
isRectangle
49253690b8bd *** empty log message ***
Claus Gittinger <cg@exept.de>
parents: 8884
diff changeset
  2016
    "return true, if the receiver is some kind of rectangle"
1149
69b30e3494fa added specially tuned code for #intersects: & #contains: (for objectView performance)
Claus Gittinger <cg@exept.de>
parents: 1133
diff changeset
  2017
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2018
    ^ true
1
a27a279701f8 Initial revision
claus
parents:
diff changeset
  2019
! !
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2020
15730
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2021
!Rectangle methodsFor:'transformations'!
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2022
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2023
align:offset with:someCoordinate
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2024
    "return a new rectangle which is translated (i.e. moved)
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2025
     such that the point offset in mySelf is placed on someCoordinate."
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2026
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2027
    ^ Rectangle origin:(someCoordinate - offset + self origin)
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2028
		extent:(self extent)
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2029
    "
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2030
     |r|
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2031
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2032
     r := Rectangle origin:10@10 corner:50@50.
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2033
     r align:(r center) with:100@100.
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2034
    "
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2035
! !
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2036
5552
31b5cc144476 category changes
Claus Gittinger <cg@exept.de>
parents: 5016
diff changeset
  2037
!Rectangle methodsFor:'truncation & rounding'!
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2038
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2039
rounded
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2040
    "return a copy of the receiver with rounded coordinates.
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2041
     Return the receiver if its coordinates are already integral."
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2042
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2043
    (left isInteger
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2044
    and:[top isInteger
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2045
    and:[width isInteger
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2046
    and:[height isInteger]]])
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2047
	ifTrue: [^ self].
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2048
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2049
    ^ Rectangle left:(left rounded)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2050
		 top:(top rounded)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2051
	       width:(width rounded)
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2052
	      height:(height rounded)
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2053
!
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2054
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2055
truncated
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2056
    "return a Rectangle whose origin and corner have any fractional parts removed.
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2057
     Return the receiver if its coordinates are already integral."
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2058
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2059
    (left isInteger
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2060
    and:[top isInteger
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2061
    and:[width isInteger
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2062
    and:[height isInteger]]])
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2063
	ifTrue: [^ self].
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2064
20308
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2065
    ^ Rectangle
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2066
	left:left truncated
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2067
	top:top truncated
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2068
	width:width truncated
9110f117d260 ALIGNMENT code clean up
Claus Gittinger <cg@exept.de>
parents: 20018
diff changeset
  2069
	height:height truncated.
4861
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2070
! !
117905eec712 added #truncated;
Claus Gittinger <cg@exept.de>
parents: 4860
diff changeset
  2071
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2072
!Rectangle class methodsFor:'documentation'!
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2073
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2074
version
18820
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
  2075
    ^ '$Header$'
12946
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
  2076
!
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
  2077
4ee94a18811c added: #vertices
Claus Gittinger <cg@exept.de>
parents: 11743
diff changeset
  2078
version_CVS
18820
8f1b263c8435 #REFACTORING
Stefan Vogel <sv@exept.de>
parents: 17240
diff changeset
  2079
    ^ '$Header$'
637
f71df465819c version at the end
Claus Gittinger <cg@exept.de>
parents: 530
diff changeset
  2080
! !
15730
4013efc6649a class: Rectangle
Claus Gittinger <cg@exept.de>
parents: 12946
diff changeset
  2081