home *** CD-ROM | disk | FTP | other *** search
/ The Fred Fish Collection 1.5 / ffcollection-1-5-1992-11.iso / ff_disks / 200-299 / ff284.lzh / IconTools / center.c < prev    next >
C/C++ Source or Header  |  1989-11-27  |  2KB  |  89 lines

  1. /************************************************************
  2.   center.c  By: Stephen Vermeulen
  3.  
  4.   Copyright (C) 1989 By Stephen Vermeulen
  5.  
  6.   Use this tool to rearrange an icon so its image overlaps
  7.   the text description, the text being centered in the icon's image.
  8.  
  9.   It has the following syntax:
  10.  
  11.       center file
  12.  
  13.   when this is typed, center will load the file called "file.info"
  14.   and change it and then resave it under
  15.   the old name to the disk.
  16. ************************************************************/
  17.  
  18. #include <intuition/intuition.h>
  19. #include <workbench/workbench.h>
  20. #include <stdio.h>
  21. #include <functions.h>
  22.  
  23. #define NO_ICONS       4
  24.  
  25. extern ULONG IconBase;
  26.  
  27. /************************************************************
  28.   The following routine just opens the libraries
  29. ************************************************************/
  30.  
  31. short OpenLibs()
  32. {
  33.   short flags; /* any libraries that do not open get recorded here */
  34.  
  35.   flags = 0;
  36.   IconBase = (ULONG) OpenLibrary("icon.library", 0L);
  37.   if (!IconBase) flags |= NO_ICONS;
  38.   return(flags);
  39. }
  40.  
  41. void CloseLibs(flags)
  42. short flags;
  43. {
  44.   if (!(flags & NO_ICONS))     CloseLibrary(IconBase);
  45. }
  46.  
  47. void main(argc, argv)
  48. short argc;
  49. char *argv[];
  50. {
  51.   short lib_flags, icon_type;
  52.   long xo, yo;
  53.   struct DiskObject *dobj, *drawer_obj;
  54.   struct DrawerData *dd_temp;
  55.  
  56.   if (argc >= 2)
  57.   {
  58.     lib_flags  = OpenLibs();
  59.     if (!lib_flags)
  60.     {
  61.       if (dobj = GetDiskObject(argv[1]))
  62.       {
  63.           /** ok to proceed **/
  64.  
  65.         if (argc == 3)
  66.         {
  67.           yo = ((struct Image *) dobj->do_Gadget.GadgetRender)->Height;
  68.           dobj->do_Gadget.Height = yo + 1;
  69.         }
  70.         else
  71.         {
  72.           yo = ((struct Image *) dobj->do_Gadget.GadgetRender)->Height;
  73.           dobj->do_Gadget.Height = (yo >> 1) - 4;
  74.         }
  75.         PutDiskObject(argv[1], dobj);
  76.         FreeDiskObject(dobj);
  77.       }
  78.     }
  79.     CloseLibs(lib_flags);
  80.   }
  81.   else
  82.   {
  83.     puts("Syntax is: center icon [c]");
  84.     puts("  ... don't use the .icon suffix!  Use the `c' flag to restore");
  85.     puts("Written by: Stephen Vermeulen, PO Box 3295, Station B,");
  86.     puts("Calgary, Alberta, CANADA, T2M 4L8.");
  87.   }
  88. }
  89.