home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff229.lzh / AlarmingClock / isup.c < prev    next >
C/C++ Source or Header  |  1989-07-20  |  4KB  |  152 lines

  1. /************************************************************************/
  2. /*       isup.c        ::: Intuition supplement :::                     */
  3. /*    contains:                                                         */
  4. /*             open_libraries()  -- returns true if intuition and       */
  5. /*                                  graphics open up                    */
  6. /*             make_window()     -- returns a window pointer            */
  7. /*             make_screen()     -- returns a screen pointer            */
  8. /*             copy_chip()       -- allocates chip mem. and copies      */
  9. /*                                  data into it                        */
  10. /*             init_itext()      -- no frills IntuiText initialization  */
  11. /*       programmed by Brian Neal   - 3/4/89 & 5/23/89 & 6/4/89         */
  12. /************************************************************************/
  13.  
  14. #include <exec/types.h>
  15. #include <intuition/intuition.h>
  16. #include <exec/memory.h>
  17.  
  18. struct Library *OpenLibrary();
  19. struct Screen  *OpenScreen(), *make_screen();
  20. struct Window  *OpenWindow(), *make_window();
  21. BOOL open_libraries();
  22. void *AllocMem(), *copy_chip(), init_itext();
  23.  
  24.  
  25. extern struct IntuitionBase *IntuitionBase;     /*  declared elsewhere! */
  26. extern struct GfxBase       *GfxBase;
  27.  
  28.  
  29. BOOL open_libraries(int_rev, gra_rev)
  30. LONG int_rev, gra_rev;
  31. {
  32.       IntuitionBase = GfxBase = NULL;
  33.       if (!(IntuitionBase = (struct IntuitionBase *)
  34.                             OpenLibrary("intuition.library", int_rev)))
  35.          return (FALSE);
  36.       if (!(GfxBase = (struct GfxBase *)
  37.                       OpenLibrary("graphics.library", gra_rev)))
  38.          return (FALSE);
  39.  
  40.       return (TRUE);
  41. }
  42.  
  43.  
  44. struct Screen *make_screen(x, y, width, height, depth, fpen, bpen,
  45.                            viewmodes, font, title, gadgets, bitmap)
  46. SHORT x, y, width, height, depth;
  47. UBYTE fpen, bpen;
  48. ULONG viewmodes;
  49. struct TextAttr *font;
  50. UBYTE *title;
  51. struct Gadget *gadgets;
  52. struct BitMap *bitmap;
  53. {
  54.    struct NewScreen ns;
  55.  
  56.       ns.LeftEdge    = x;
  57.       ns.TopEdge     = y;
  58.       ns.Width       = width;
  59.       ns.Height      = height;
  60.       ns.Depth       = depth;
  61.       ns.DetailPen   = fpen;
  62.       ns.BlockPen    = bpen;
  63.       ns.ViewModes   = viewmodes;
  64.       ns.Type        = CUSTOMSCREEN;
  65.       ns.Font        = font;
  66.       ns.DefaultTitle= title;
  67.       ns.Gadgets     = gadgets;
  68.       ns.CustomBitMap= bitmap;
  69.       return (OpenScreen(&ns));
  70. }
  71.  
  72.  
  73. struct Window *make_window(x, y, width, height, fpen, bpen, iflags, flags,
  74.                            gadget, checkmark, title, screen, bitmap,
  75.                            minw, minh, maxw, maxh)
  76. SHORT x, y, width, height;
  77. UBYTE fpen, bpen;
  78. ULONG iflags, flags;
  79. struct Gadget *gadget;
  80. struct Image *checkmark;
  81. UBYTE *title;
  82. struct Screen *screen;
  83. struct BitMap *bitmap;
  84. SHORT minw, minh;
  85. USHORT maxw, maxh;
  86. {
  87.    struct NewWindow nw;
  88.  
  89.       nw.LeftEdge    = x;
  90.       nw.TopEdge     = y;
  91.       nw.Width       = width;
  92.       nw.Height      = height;
  93.       nw.DetailPen   = fpen;
  94.       nw.BlockPen    = bpen;
  95.       nw.Title       = title;
  96.       nw.Flags       = flags;
  97.       nw.IDCMPFlags  = iflags;
  98.       nw.Screen      = screen;
  99.       nw.Type        = (screen == NULL) ? WBENCHSCREEN : CUSTOMSCREEN;
  100.       nw.FirstGadget = gadget;
  101.       nw.CheckMark   = checkmark;
  102.       nw.BitMap      = bitmap;
  103.       nw.MinWidth    = minw;
  104.       nw.MinHeight   = minh;
  105.       nw.MaxWidth    = maxw;
  106.       nw.MaxHeight   = maxh;
  107.       return (OpenWindow(&nw));
  108. }
  109.  
  110.  
  111. void *copy_chip(dataptr, size)
  112. BYTE *dataptr;
  113. USHORT size;               /* size in bytes of requested CHIP mem */
  114. {
  115.    UCOUNT i;
  116.    BYTE *chipptr, *p;
  117.  
  118.       if (!(chipptr = (BYTE *) AllocMem((LONG) size, MEMF_CHIP)))
  119.          return ((void *) NULL);
  120.  
  121.       p = chipptr;
  122.  
  123.       for (i = 0; i < size; ++i)
  124.          *p++ = *dataptr++;
  125.  
  126.       return ((void *) chipptr);
  127. }
  128.  
  129.  
  130. /*
  131. **    init_itext() -
  132. **       A plain IntuiText initializer.  Assumes single pen color,
  133. **    JAM1 type display, using default font.  User must link IntuiTexts
  134. **    together, if desired.
  135. **/
  136.  
  137. void init_itext(itext, fpen, x, y, string)
  138. struct IntuiText *itext;
  139. UBYTE fpen;
  140. WORD x, y;
  141. char *string;
  142. {
  143.    itext -> FrontPen  = fpen;
  144.    itext -> BackPen   = 0;
  145.    itext -> DrawMode  = JAM1;
  146.    itext -> LeftEdge  = x;
  147.    itext -> TopEdge   = y;
  148.    itext -> ITextFont = NULL;
  149.    itext -> IText     = (UBYTE *) string;
  150.    itext -> NextText  = NULL;
  151. }
  152.