home *** CD-ROM | disk | FTP | other *** search
/ DP Tool Club 16 / CD_ASCQ_16_0994.iso / news / 4611 / fw16d.ins / SOURCE / FUNCTION / XPAD.PRG < prev   
Text File  |  1994-05-04  |  1KB  |  48 lines

  1. // They are like Clipper's PadL(), PadC() and PadR() but based on pixels!!!
  2.  
  3. #include "FiveWin.ch"
  4.  
  5. #define PADCHAR  Chr(32)
  6.  
  7. //----------------------------------------------------------------------------//
  8.  
  9. function xPadR( cText, nPixels, cChar )
  10.  
  11.    DEFAULT cChar := PADCHAR
  12.  
  13.    while GetTextWidth( 0, cText ) < nPixels
  14.       cText += cChar
  15.    end
  16.  
  17. return cText
  18.  
  19. //----------------------------------------------------------------------------//
  20.  
  21. function xPadL( cText, nPixels, cChar )
  22.  
  23.    DEFAULT cChar := PADCHAR
  24.  
  25.    while GetTextWidth( 0, cText ) < nPixels
  26.       cText = cChar + cText
  27.    end
  28.  
  29. return cText
  30.  
  31. //----------------------------------------------------------------------------//
  32.  
  33. function xPadC( cText, nPixels, cChar )
  34.  
  35.    local cRet    := If( ValType( cText ) == "C", AllTrim( cText ), "" )
  36.    local nLen    := Len( cText )
  37.    local nPixLen := GetTextWidth( 0, cText )
  38.    local nPad    := GetTextWidth( 0, If( cChar != nil, cChar, PADCHAR ) )
  39.  
  40.    if nPixels > nPixLen
  41.       cRet = PadC( cRet, nLen + ( nPixels - nPixLen ) / nPad,;
  42.                    If( cChar != nil, cChar, PADCHAR ) )
  43.    endif
  44.  
  45. return cRet
  46.  
  47. //----------------------------------------------------------------------------//
  48.