home *** CD-ROM | disk | FTP | other *** search
/ Dream 57 / Amiga_Dream_57.iso / Amiga / Programmation / c / Extensions / APPSource.lha / APlusPlus / libsource / RectObject.cxx < prev    next >
Encoding:
C/C++ Source or Header  |  1994-08-29  |  1.6 KB  |  75 lines

  1. /******************************************************************************
  2.  **
  3.  **   C++ Class Library for the Amiga⌐ system software.
  4.  **
  5.  **   Copyright (C) 1994 by Armin Vogt  **  EMail: armin@uni-paderborn.de
  6.  **   All Rights Reserved.
  7.  **
  8.  **   $Source: apphome:RCS/libsource/RectObject.cxx,v $
  9.  **   $Revision: 1.4 $
  10.  **   $Date: 1994/07/31 13:32:03 $
  11.  **   $Author: Armin_Vogt $
  12.  **
  13.  ******************************************************************************/
  14.  
  15.  
  16. #include <APlusPlus/environment/APPObject.h>
  17. #include <APlusPlus/graphics/RectObject.h>
  18.  
  19.  
  20. static const char rcs_id[] = "$Id: RectObject.cxx,v 1.4 1994/07/31 13:32:03 Armin_Vogt Exp Armin_Vogt $";
  21.  
  22.  
  23. RectObject::RectObject()
  24. {
  25.    setRect(0,0,0,0);
  26.    setBorders(0,0,0,0);
  27. }
  28.  
  29. RectObject::RectObject(XYVAL minx,XYVAL miny,XYVAL maxx,XYVAL maxy)
  30. {
  31.    setRect(minx,miny,maxx,maxy);
  32. }
  33.  
  34. RectObject::~RectObject()
  35. {
  36. }
  37.  
  38. void RectObject::setRect(XYVAL minx,XYVAL miny,XYVAL maxx,XYVAL maxy)
  39. {
  40.    MinX = minx; MinY = miny;
  41.    MaxX = max(maxx,minx);
  42.    MaxY = max(maxy,miny);
  43. }
  44. XYVAL RectObject::iLeft()
  45. {
  46.    return (MinX+leftBorder >= MaxX-rightBorder) ? MinX : MinX+leftBorder;
  47. }
  48. XYVAL RectObject::iTop()
  49. {
  50.    return (MinY+topBorder >= MaxY-bottomBorder) ? MinY : MinY+topBorder;
  51. }
  52. XYVAL RectObject::iRight()
  53. {
  54.    return (MinX+leftBorder >= MaxX-rightBorder) ? MaxX : MaxX-rightBorder;
  55. }
  56.  
  57. XYVAL RectObject::iBottom()
  58. {
  59.    return (MinY+topBorder >= MaxY-bottomBorder) ? MaxY : MaxY-bottomBorder;
  60. }
  61.  
  62. WHVAL RectObject::iWidth()
  63. {
  64.    if (iRight()>iLeft())
  65.       return iRight()-iLeft()+1;
  66.    else return 0;
  67. }
  68.  
  69. WHVAL RectObject::iHeight()
  70. {
  71.    if (iBottom()>iTop())
  72.       return iBottom()-iTop()+1;
  73.    else return 0;
  74. }
  75.