home *** CD-ROM | disk | FTP | other *** search
/ Amiga ISO Collection / AmigaUtilCD2.iso / Misc / HYPERBOOK2.DMS / in.adf / Macros / CenterObject < prev    next >
Encoding:
Text File  |  1990-09-23  |  630 b   |  33 lines

  1. /* CenterObject - Horizontally center an object with respect to the page,
  2.    or another object.
  3. */
  4.  
  5. row = getclickrow('Click on the object you want to center')
  6. col = getcolumn()
  7. par = getobjectat(col, row)
  8.  
  9. child = par
  10.  
  11. do until gettype(par) ~= 'Group'
  12.    child = par
  13.    par   = parent(child)
  14.    end
  15.  
  16. ob1 = child
  17.  
  18. if length(ob1) > 0 then do
  19.  
  20.    row = getclickrow('Click on the reference object (or the page)')
  21.    col = getcolumn()
  22.    ob2 = getobjectat(col, row)
  23.  
  24.  
  25.    if length(ob2) = 0 then ob2 = ':'
  26.  
  27.    left = getleft(ob2) + (getwidth(ob2) - getwidth(ob1)) % 2
  28.    top  = gettop(ob1)
  29.  
  30.    call setposition(ob1, left, top)
  31.  
  32.    end
  33.