home *** CD-ROM | disk | FTP | other *** search
/ The CDPD Public Domain Collection for CDTV 3 / CDPDIII.bin / pd / programming / c / intuitionpp / ipp / cfont.cc next >
Encoding:
C/C++ Source or Header  |  1993-03-31  |  2.2 KB  |  84 lines

  1. ///////////////////////////////////////////////////////////////////////////////
  2. ///////////////////////////////////////////////////////////////////////////////
  3. ///////////////////                                        ////////////////////
  4. ///////////////////           file : cfont.cc              ////////////////////
  5. ///////////////////                                        ////////////////////
  6. ///////////////////////////////////////////////////////////////////////////////
  7. ///////////////////////////////////////////////////////////////////////////////
  8.  
  9. #include <intuition/intuitionbase.h>
  10. #include <graphics/gfxbase.h>
  11. #include <graphics/gfxmacros.h>
  12. #include <clib/graphics_protos.h>
  13. #include <clib/intuition_protos.h>
  14. #include <clib/diskfont_protos.h>
  15.  
  16. #include <string.h>
  17.  
  18. //extern struct Library *OpenLibrary(char *, long);
  19. //extern void *CloseLibrary(struct Library *);
  20. //struct IntuitionBase *IntuitionBase=NULL;
  21. //struct GfxBase *GfxBase=NULL;
  22. //struct DiskFontBase *DiskFontBase=NULL;
  23.  
  24.  
  25. #include "cfont.h"
  26.  
  27.  
  28. BOOL CFont :: initlibs()
  29. {
  30. //    IntuitionBase = (struct IntuitionBase *)OpenLibrary("intuition.library", 0);
  31. //    if (IntuitionBase == NULL) return FALSE;
  32. //    GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 0);
  33. //    if (GfxBase == NULL)
  34. //    {
  35. //        CloseLibrary((struct Library *)IntuitionBase);
  36. //        return FALSE;
  37. //    }
  38. //    DiskFontBase = (struct DiskFontBase *)OpenLibrary("diskfont.library", 0);
  39. //    if (DiskFontBase == NULL) return FALSE;
  40.     return TRUE;
  41. }
  42.  
  43. CFont :: CFont()
  44. {
  45.     if (!initlibs()) return;
  46.     font=NULL;
  47. }
  48.  
  49. CFont :: CFont(STRPTR fontname, UWORD fontsize, UBYTE style, UBYTE flags)
  50. {
  51.     if (!initlibs()) return;
  52.     font=NULL;
  53.     open(fontname, fontsize, style, flags);
  54. }
  55.  
  56. CFont :: ~CFont()
  57. {
  58.     if (font) CloseFont(font);
  59. //    if (DiskFontBase) CloseLibrary((struct Library *)DiskFontBase);
  60. }
  61.  
  62. BOOL CFont :: open(STRPTR fontname, UWORD fontsize, UBYTE style, UBYTE flags)
  63. {
  64.     if (isopen()) close();
  65.     fontattr.ta_Name=fontname;
  66.     fontattr.ta_YSize=fontsize;
  67.     fontattr.ta_Style=style;
  68.     fontattr.ta_Flags=flags;
  69.     font=OpenDiskFont(&fontattr);
  70.     return isopen();
  71. }
  72.  
  73. void CFont :: close(void)
  74. {
  75.     if (font) CloseFont(font);
  76.     font=NULL;
  77. }
  78.  
  79. BOOL CFont :: isopen()
  80. {
  81.     return (font!=NULL);
  82. }
  83.  
  84.