equal
deleted
inserted
replaced
284 " |
284 " |
285 Rectangle originFromUser:50@50 |
285 Rectangle originFromUser:50@50 |
286 " |
286 " |
287 ! ! |
287 ! ! |
288 |
288 |
|
289 |
|
290 |
289 !Rectangle methodsFor:'Compatibility-Squeak'! |
291 !Rectangle methodsFor:'Compatibility-Squeak'! |
290 |
292 |
291 amountToTranslateWithin: aRectangle |
293 amountToTranslateWithin: aRectangle |
292 "Answer a Point, delta, such that self + delta is forced within aRectangle." |
294 "Answer a Point, delta, such that self + delta is forced within aRectangle." |
293 "Altered so as to prefer to keep self topLeft inside when all of self |
295 "Altered so as to prefer to keep self topLeft inside when all of self |
387 ! |
389 ! |
388 |
390 |
389 corner |
391 corner |
390 "return the corner" |
392 "return the corner" |
391 |
393 |
|
394 %{ /* NOCONTEXT */ |
|
395 OBJ _left = __INST(left); |
|
396 OBJ _top = __INST(top); |
|
397 OBJ _width = __INST(width); |
|
398 OBJ _height = __INST(height); |
|
399 |
|
400 if (__bothSmallInteger(_left, _top) |
|
401 && __bothSmallInteger(_width, _height)) { |
|
402 if (self == @global(Rectangle)) { |
|
403 if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */ |
|
404 OBJ newPoint; |
|
405 int spc; |
|
406 int cX = __intVal(_left) + __intVal(_width); |
|
407 int cY = __intVal(_top) + __intVal(_height); |
|
408 |
|
409 if (__ISVALIDINTEGER(cX) && __ISVALIDINTEGER(cY)) { |
|
410 __qCheckedAlignedNew(newPoint, sizeof(struct __Point)); |
|
411 __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self); |
|
412 __PointInstPtr(newPoint)->p_x = __MKSMALLINT(cX); |
|
413 __PointInstPtr(newPoint)->p_y = __MKSMALLINT(cY); |
|
414 RETURN ( newPoint ); |
|
415 } |
|
416 } |
|
417 } |
|
418 } |
|
419 %}. |
392 ^ (left + width) @ (top + height) |
420 ^ (left + width) @ (top + height) |
393 ! |
421 ! |
394 |
422 |
395 corner:aPoint |
423 corner:aPoint |
396 "set the bottom-right corner - warning: destructive" |
424 "set the bottom-right corner - warning: destructive" |
398 width := aPoint x - left. |
426 width := aPoint x - left. |
399 height := aPoint y - top |
427 height := aPoint y - top |
400 ! |
428 ! |
401 |
429 |
402 extent |
430 extent |
403 "return the extent as a point" |
431 "return the extent" |
404 |
432 |
|
433 %{ /* NOCONTEXT */ |
|
434 |
|
435 if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */ |
|
436 if (self == @global(Rectangle)) { |
|
437 OBJ newPoint; |
|
438 int spc; |
|
439 OBJ newX = __INST(width); |
|
440 OBJ newY = __INST(height); |
|
441 |
|
442 __qCheckedAlignedNew(newPoint, sizeof(struct __Point)); |
|
443 __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self); |
|
444 __PointInstPtr(newPoint)->p_x = newX; |
|
445 __PointInstPtr(newPoint)->p_y = newY; |
|
446 if (! __bothSmallInteger(newX, newY)) { |
|
447 spc = __qSpace(newPoint); |
|
448 __STORE_SPC(newPoint, newX, spc); |
|
449 __STORE_SPC(newPoint, newY, spc); |
|
450 } |
|
451 RETURN ( newPoint ); |
|
452 } |
|
453 } |
|
454 %}. |
405 ^ Point x:width y:height |
455 ^ Point x:width y:height |
406 ! |
456 ! |
407 |
457 |
408 extent:aPoint |
458 extent:aPoint |
409 "set the extent from the argument, aPoint with width taken from aPoint x |
459 "set the extent from the argument, aPoint with width taken from aPoint x |
497 ! |
547 ! |
498 |
548 |
499 origin |
549 origin |
500 "return the origin" |
550 "return the origin" |
501 |
551 |
|
552 %{ /* NOCONTEXT */ |
|
553 |
|
554 /* |
|
555 * claus: I am no longer certain, if this primitive is worth the effort |
|
556 */ |
|
557 if (__CanDoQuickNew(sizeof(struct __Point))) { /* OBJECT ALLOCATION */ |
|
558 if (self == @global(Rectangle)) { |
|
559 OBJ newPoint; |
|
560 int spc; |
|
561 OBJ newX = __INST(left); |
|
562 OBJ newY = __INST(top); |
|
563 |
|
564 __qCheckedAlignedNew(newPoint, sizeof(struct __Point)); |
|
565 __InstPtr(newPoint)->o_class = self; __qSTORE(newPoint, self); |
|
566 __PointInstPtr(newPoint)->p_x = newX; |
|
567 __PointInstPtr(newPoint)->p_y = newY; |
|
568 if (! __bothSmallInteger(newX, newY)) { |
|
569 spc = __qSpace(newPoint); |
|
570 __STORE_SPC(newPoint, newX, spc); |
|
571 __STORE_SPC(newPoint, newY, spc); |
|
572 } |
|
573 RETURN ( newPoint ); |
|
574 } |
|
575 } |
|
576 %}. |
502 ^ Point x:left y:top |
577 ^ Point x:left y:top |
503 ! |
578 ! |
504 |
579 |
505 origin:aPoint |
580 origin:aPoint |
506 "set the top-left origin. The corner remains unchanged. |
581 "set the top-left origin. The corner remains unchanged. |
1819 ! ! |
1894 ! ! |
1820 |
1895 |
1821 !Rectangle class methodsFor:'documentation'! |
1896 !Rectangle class methodsFor:'documentation'! |
1822 |
1897 |
1823 version |
1898 version |
1824 ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.87 2014-01-23 16:11:19 stefan Exp $' |
1899 ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.88 2014-12-21 20:15:53 cg Exp $' |
1825 ! |
1900 ! |
1826 |
1901 |
1827 version_CVS |
1902 version_CVS |
1828 ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.87 2014-01-23 16:11:19 stefan Exp $' |
1903 ^ '$Header: /cvs/stx/stx/libbasic/Rectangle.st,v 1.88 2014-12-21 20:15:53 cg Exp $' |
1829 ! ! |
1904 ! ! |
1830 |
1905 |