home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / yacl-012.zip / ui / interval.cxx < prev    next >
C/C++ Source or Header  |  1995-04-04  |  2KB  |  116 lines

  1.  
  2.  
  3.  
  4.  
  5.  
  6. /*
  7.  *
  8.  *          Copyright (C) 1994, M. A. Sridhar
  9.  *  
  10.  *
  11.  *     This software is Copyright M. A. Sridhar, 1994. You are free
  12.  *     to copy, modify or distribute this software  as you see fit,
  13.  *     and to use  it  for  any  purpose, provided   this copyright
  14.  *     notice and the following   disclaimer are included  with all
  15.  *     copies.
  16.  *
  17.  *                        DISCLAIMER
  18.  *
  19.  *     The author makes no warranties, either expressed or implied,
  20.  *     with respect  to  this  software, its  quality, performance,
  21.  *     merchantability, or fitness for any particular purpose. This
  22.  *     software is distributed  AS IS.  The  user of this  software
  23.  *     assumes all risks  as to its quality  and performance. In no
  24.  *     event shall the author be liable for any direct, indirect or
  25.  *     consequential damages, even if the  author has been  advised
  26.  *     as to the possibility of such damages.
  27.  *
  28.  */
  29.  
  30.  
  31.  
  32. #if defined(__GNUC__)
  33. #pragma implementation
  34. #endif
  35.  
  36.  
  37. #include "ui/interval.h"
  38.  
  39.  
  40. CL_Interval::CL_Interval (long start,long end)
  41. {
  42.     _low = start;
  43.     _hi = end;
  44. }
  45.  
  46. CL_Interval::CL_Interval ()
  47. {
  48.     _low = -1;
  49.     _hi = -1;
  50. }
  51.  
  52. CL_Interval::CL_Interval (const CL_Interval& i)
  53. {
  54.     _low = i._low;
  55.     _hi = i._hi;
  56. }
  57.  
  58.  
  59.  
  60. bool CL_Interval::operator== (const CL_Object& i) const
  61. {
  62.  
  63.     if (_low == ((const CL_Interval&)i)._low &&
  64.         _hi  == ((const CL_Interval&)i)._hi)
  65.         return TRUE;
  66.     return FALSE;
  67. }
  68.  
  69.  
  70. void CL_Interval::operator= (const CL_Interval& i) 
  71. {
  72.     if (!PrepareToChange())
  73.         return;
  74.     _low = i._low;
  75.     _hi = i._hi;
  76.     Notify ();
  77. }
  78.  
  79.  
  80. void CL_Interval::Low (long v)
  81. {
  82.     if (!PrepareToChange())
  83.         return;
  84.     _low = minl (_hi, v);
  85.     Notify ();
  86. }
  87.  
  88.  
  89. void CL_Interval::High (long v)
  90. {
  91.     if (!PrepareToChange())
  92.         return;
  93.     _hi = maxl (_low, v);
  94.     Notify ();
  95. }
  96.  
  97.  
  98. CL_String CL_Interval::AsString() const
  99. {
  100.     return CL_String ("(") + CL_String (_low) + "," + CL_String(_hi) + ")";
  101. }
  102.  
  103.  
  104. CL_Interval CL_Interval::operator+ (long n) const
  105. {
  106.     return CL_Interval (_low + n, _hi + n);
  107. }
  108.  
  109.  
  110. CL_Interval CL_Interval::operator- (long n) const
  111. {
  112.     return CL_Interval (_low - n, _hi - n);
  113. }
  114.  
  115.  
  116.