home *** CD-ROM | disk | FTP | other *** search
/ Fish 'n' More 2 / fishmore-publicdomainlibraryvol.ii1991xetec.iso / dirs / intuitioned_377.lzh / IntuitionEd / DiskFont.c < prev    next >
C/C++ Source or Header  |  1990-10-10  |  4KB  |  136 lines

  1. /*-----------------------------------------------------------
  2. --   Program: DiskFont.c
  3. --    Author: Intuition Ed 
  4. --      Date: Thu May 24
  5. --  Funktion: Example of how to display a DiskFont.
  6. --            A 'ruby.font' is opend.
  7. --            Therefore it must be in the current Font directory.
  8. ------------------------------------------------------------*/
  9.  
  10.  
  11. #include <intuition/intuition.h>
  12.  
  13.  
  14.  
  15. void                   Open_All() ;
  16. void                   Close_All();
  17.  
  18.  
  19. struct IntuitionBase  *IntuitionBase;
  20. struct GfxBase        *GfxBase;
  21. ULONG                 *DiskfontBase;
  22. struct Window         *Window;
  23. struct Font           *Text1Font;
  24.  
  25.  
  26. struct TextAttr Text1TextAttr =
  27. {
  28.  (STRPTR) "ruby.font",                    /* ta_Name                   */
  29.   15,                                     /* ta_YSize                  */
  30.  NULL,                                    /* ta_Style                  */
  31.  FPF_DISKFONT ,                           /* ta_Flags                  */
  32. };
  33.  
  34. struct IntuiText Text1 =
  35. {
  36.   -1, -1,                                 /* FrontPen , BackPen        */
  37.  JAM1,                                    /* DrawMode                  */
  38.   20, 20,                                 /* LeftEdge , TopEdge        */
  39.  &Text1TextAttr ,                         /* TextAttr                  */
  40.  (UBYTE *) "ruby.font   (15)",            /* Text                      */
  41.  NULL,                                    /* Last Text !               */
  42. };
  43.  
  44. struct NewWindow NewWindow =
  45. {
  46.   10, 20,                                 /* LeftEdge , TopEdge        */
  47.  300, 50,                                 /* Width , Height            */
  48.    0,  1,                                 /* DetailPen , BlockPen      */
  49.  NULL,                                    /* IDCMP Flags               */
  50.  WINDOWSIZING                             /* Flags                     */
  51.  | WINDOWDRAG | WINDOWDEPTH | SMART_REFRESH | ACTIVATE,
  52.  NULL,                                    /* No Gadget                 */
  53.  NULL,                                    /* Check Mark                */
  54.  (UBYTE *) "Example of a DiskFont :",     /* Title                     */
  55.  NULL,                                    /* Screen                    */
  56.  NULL,                                    /* BitMap                    */
  57.  100, 20,                                 /* MinWidth , MinHeight      */
  58.  640,256,                                 /* MaxWidth , MaxHeight      */
  59.  WBENCHSCREEN,                            /* ScreenType                */
  60. };
  61.  
  62.  
  63. void main()
  64. {
  65. Open_All();
  66. Delay(1000L);
  67. Close_All();
  68. }
  69.  
  70.  
  71. void Open_All()
  72. {
  73.  void                  PrintIText();
  74.  struct Window        *OpenWindow();
  75.  struct Font          *OpenDiskFont();
  76.  void                 *OpenLibrary();
  77.  
  78.  if (NOT(IntuitionBase = (struct IntuitionBase *)
  79.        OpenLibrary ("intuition.library", 0L)))
  80.  {
  81.   printf("Where is my Intuition Library ??");
  82.   Close_All();
  83.   exit(FALSE);
  84.  }
  85.  
  86.  if (NOT(GfxBase = (struct GfxBase *)
  87.     OpenLibrary("graphics.library",0L)))
  88.  {
  89.   printf("No Grafik Library found.");
  90.   Close_All();
  91.   exit(FALSE);
  92.  }
  93.  
  94.  if (NOT(DiskfontBase = (ULONG *)
  95.     OpenLibrary("diskfont.library",0L)))
  96.  {
  97.   printf("No DiskFont Library found.");
  98.   Close_All();
  99.   exit(FALSE);
  100.  }
  101.  
  102.  if (NOT(Window = (struct Window *)
  103.        OpenWindow (&NewWindow )))
  104.  {
  105.   printf("Window -  WB-Window can't be displayed.\n");
  106.   Close_All();
  107.   exit(FALSE);
  108.  }
  109.  
  110.  if (NOT(Text1Font = (struct Font *)
  111.    OpenDiskFont (&Text1TextAttr)))
  112.  {
  113.   printf("The DiskFont Text1Font can't be opend.\n");
  114.   Close_All();
  115.   exit(FALSE);
  116.  }
  117.  
  118.  SetFont (Window->RPort,Text1Font);
  119.  
  120.  PrintIText (Window->RPort,&Text1,0L,0L);
  121. }
  122.  
  123.  
  124. void Close_All()
  125. {
  126.  void                  CloseWindow();
  127.  void                  CloseLibrary();
  128.  
  129.  if (Text1Font)  CloseFont(Text1Font);
  130.  if (Window)   CloseWindow (Window) ;
  131.  
  132.  if (GfxBase)           CloseLibrary(GfxBase);
  133.  if (DiskfontBase)      CloseLibrary(DiskfontBase);
  134.  if (IntuitionBase)     CloseLibrary(IntuitionBase);
  135. }
  136.