home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / misc / emu / AROSdev.lha / AROS / rom / intuition / intuitextlength.c < prev    next >
C/C++ Source or Header  |  1997-01-27  |  2KB  |  102 lines

  1. /*
  2.     (C) 1995-96 AROS - The Amiga Replacement OS
  3.     $Id: intuitextlength.c,v 1.5 1997/01/27 00:36:40 ldp Exp $
  4.     $Log: intuitextlength.c,v $
  5.     Revision 1.5  1997/01/27 00:36:40  ldp
  6.     Polish
  7.  
  8.     Revision 1.4  1996/12/10 14:00:04  aros
  9.     Moved #include into first column to allow makedepend to see it.
  10.  
  11.     Revision 1.3  1996/10/31 13:51:18  aros
  12.     Create and free the RastPort with the new functions
  13.  
  14.     Revision 1.2  1996/10/24 15:51:20  aros
  15.     Use the official AROS macros over the __AROS versions.
  16.  
  17.     Revision 1.1  1996/10/21 17:06:48  aros
  18.     A couple of new functions
  19.  
  20.  
  21.     Desc:
  22.     Lang: english
  23. */
  24. #include "intuition_intern.h"
  25. #include <string.h>
  26. #include <proto/graphics.h>
  27.  
  28. /*****************************************************************************
  29.  
  30.     NAME */
  31. #include <intuition/intuition.h>
  32. #include <proto/intuition.h>
  33.  
  34.     AROS_LH1(LONG, IntuiTextLength,
  35.  
  36. /*  SYNOPSIS */
  37.     AROS_LHA(struct IntuiText *, iText, A0),
  38.  
  39. /*  LOCATION */
  40.     struct IntuitionBase *, IntuitionBase, 55, Intuition)
  41.  
  42. /*  FUNCTION
  43.     Measure the length of the IntuiText passed to the function. Further
  44.     IntuiTexts in iText->NextText are ignored. The length is measured in
  45.     pixels.
  46.  
  47.     INPUTS
  48.     iText - The size of this text. If iText->ITextFont contains NULL,
  49.         the systems font is used (and *not* the font of the currently
  50.         active screen !).
  51.  
  52.     RESULT
  53.     The width of the text in pixels.
  54.  
  55.     NOTES
  56.  
  57.     EXAMPLE
  58.  
  59.     BUGS
  60.  
  61.     SEE ALSO
  62.  
  63.     INTERNALS
  64.  
  65.     HISTORY
  66.     29-10-95    digulla automatically created from
  67.                 intuition_lib.fd and clib/intuition_protos.h
  68.  
  69. *****************************************************************************/
  70. {
  71.     AROS_LIBFUNC_INIT
  72.     AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
  73.     struct RastPort * rp;
  74.     struct TextFont * newfont;
  75.     LONG width;
  76.  
  77.     rp = CreateRastPort ();
  78.  
  79.     if (rp)
  80.     {
  81.     if (iText->ITextFont)
  82.     {
  83.         newfont = OpenFont (iText->ITextFont);
  84.  
  85.         if (newfont)
  86.         SetFont (rp, newfont);
  87.     }
  88.  
  89.     width = TextLength (rp, iText->IText, strlen (iText->IText));
  90.  
  91.     if (iText->ITextFont)
  92.     {
  93.         if (newfont)
  94.         CloseFont (newfont);
  95.     }
  96.  
  97.     FreeRastPort (rp);
  98.     }
  99.  
  100.     AROS_LIBFUNC_EXIT
  101. } /* IntuiTextLength */
  102.