home *** CD-ROM | disk | FTP | other *** search
/ Microsoft Programmer's Library 1.3 / Microsoft-Programers-Library-v1.3.iso / sampcode / os2sdk / os2sdk11 / petzold / chap16 / hdrlib.c < prev    next >
Encoding:
C/C++ Source or Header  |  1989-02-20  |  1.4 KB  |  52 lines

  1. /*-----------------------------------------------------------
  2.    HDRLIB.C -- "Handy Drawing Routines" Dynamic Link Library
  3.   -----------------------------------------------------------*/
  4.  
  5. #define INCL_GPI
  6. #include <os2.h>
  7. #include <stdio.h>
  8. #include <stdarg.h>
  9. #include <stdlib.h>
  10. #include <string.h>
  11. #include "hdrlib.h"
  12.  
  13. SHORT APIENTRY HdrPuts (HPS hps, PPOINTL pptl, PCHAR szText)
  14.      {
  15.      SHORT sLength = strlen (szText) ;
  16.  
  17.      if (pptl == NULL)
  18.           GpiCharString (hps, (LONG) sLength, szText) ;
  19.      else
  20.           GpiCharStringAt (hps, pptl, (LONG) sLength, szText) ;
  21.  
  22.      return sLength ;
  23.      }
  24.  
  25. SHORT cdecl FAR HdrPrintf (HPS hps, PPOINTL pptl, PCHAR szFormat, ...)
  26.      {
  27.      static CHAR chBuffer [1024] ;
  28.      SHORT       sLength ;
  29.      va_list     pArguments ;
  30.  
  31.      va_start (pArguments, szFormat) ;
  32.      sLength = vsprintf (chBuffer, szFormat, pArguments) ;
  33.  
  34.      if (pptl == NULL)
  35.           GpiCharString (hps, (LONG) sLength, chBuffer) ;
  36.      else
  37.           GpiCharStringAt (hps, pptl, (LONG) sLength, chBuffer) ;
  38.  
  39.      va_end (pArguments) ;
  40.      return sLength ;
  41.      }
  42.  
  43. LONG APIENTRY HdrEllipse (HPS hps, LONG lOption, PPOINTL pptl)
  44.      {
  45.      POINTL ptlCurrent ;
  46.  
  47.      GpiQueryCurrentPosition (hps, &ptlCurrent) ;
  48.  
  49.      return GpiBox (hps, lOption, pptl, labs (pptl->x - ptlCurrent.x),
  50.                                         labs (pptl->y - ptlCurrent.y)) ;
  51.      }
  52.