home *** CD-ROM | disk | FTP | other *** search
/ Liren Large Software Subsidy 5 / 05.iso / a / a066 / 1.img / CURSOR.PRG < prev    next >
Encoding:
Text File  |  1992-03-20  |  1.9 KB  |  108 lines

  1. /*
  2.     cursor.prg
  3.  
  4.     Copyright (c) 1991 Anton van Straaten
  5.  
  6.     Definition of class cursor
  7. */
  8.  
  9. #command    if <cond> then <expr>   =>  if <cond> ; <expr> ; end
  10.  
  11. #include "class(y).ch"
  12.  
  13.  
  14. create class cursor
  15.         instvar row
  16.         instvar col
  17.         instvar shape
  18.         instvar color
  19.  
  20. export:
  21.         method  show
  22.         method  hide
  23.         method  update
  24.         method  up
  25.         method  down
  26.         method  left  = cursleft        // left() and right() are reserved
  27.         method  right = cursright       // function names in Clipper.
  28. endclass
  29.  
  30.  
  31.  
  32. constructor new (row, col, shape, color)
  33.     self:update()
  34.     if row <> NIL   then self:row := row
  35.     if col <> NIL   then self:col := col
  36.     if shape <> NIL then self:shape := shape
  37.     if color <> NIL then self:color := color
  38. return
  39.  
  40.  
  41.  
  42. method procedure update
  43.     self:row   := row()
  44.     self:col   := col()
  45.     self:shape := setcursor()
  46.     self:color := setcolor()
  47. return
  48.  
  49.  
  50.  
  51. method procedure show
  52.     setpos(self:row, self:col)
  53.     setcursor(self:shape)
  54.     setcolor(self:color)
  55. return
  56.  
  57.  
  58.  
  59. method procedure hide(lNoUpdate)
  60.     if lNoUpdate == NIL .or. !lNoUpdate
  61.         self:update()
  62.     end
  63.     setcursor(0)
  64. return
  65.  
  66.  
  67.  
  68. method procedure up(n)
  69.     self:row -= if(n == NIL, 1, n)
  70.     if self:row < 0
  71.         self:row := 0
  72.     end
  73.     setpos(self:row, self:col)
  74. return
  75.  
  76.  
  77.  
  78. method procedure down(n)
  79.     self:row += if(n == NIL, 1, n)
  80.     if self:col > maxrow()
  81.         self:col := maxrow()
  82.     end
  83.     setpos(self:row, self:col)
  84. return
  85.  
  86.  
  87.  
  88. method procedure cursleft(n)
  89.     self:col -= if(n == NIL, 1, n)
  90.     if self:col < 0
  91.         self:col := 0
  92.     end
  93.     setpos(self:row, self:col)
  94. return
  95.  
  96.  
  97.  
  98. method procedure cursright(n)
  99.     self:col += if(n == NIL, 1, n)
  100.     if self:col > maxcol()
  101.         self:col := maxcol()
  102.     end
  103.     setpos(self:row, self:col)
  104. return
  105.  
  106.  
  107. // eof cursor.prg
  108.