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 / lift.c < prev    next >
C/C++ Source or Header  |  1989-11-27  |  2KB  |  87 lines

  1. /************************************************************
  2.   lift.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.       lift file y_amount
  12.  
  13.   when this is typed, lift will load the file called "file.info"
  14.   and change it and then resave it under the old name to the disk.
  15.   Just a bit more general a version of "Center".
  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 == 3)
  57.   {
  58.     lib_flags  = OpenLibs();
  59.     if (!lib_flags)
  60.     {
  61.       if (dobj = GetDiskObject(argv[1]))
  62.       {
  63.           /** ok to proceed **/
  64.  
  65.         yo = ((struct Image *) dobj->do_Gadget.GadgetRender)->Height;
  66.         if ((argv[2][0] == '-') || (argv[2][0] == '+'))
  67.           dobj->do_Gadget.Height -= atoi(argv[2]);
  68.         else
  69.           dobj->do_Gadget.Height = yo - 9 - atoi(argv[2]);
  70.         PutDiskObject(argv[1], dobj);
  71.         FreeDiskObject(dobj);
  72.       }
  73.     }
  74.     CloseLibs(lib_flags);
  75.   }
  76.   else
  77.   {
  78.     puts("Syntax is: lift icon y_amount");
  79.     puts("  ... don't use the .icon suffix!");
  80.     puts("If y_amount is SIGNED (ie. +10 or -5 etc.) then the text is moved");
  81.     puts("relative to its current position.  If y_amount does not have a sign");
  82.     puts("then the text is raised by y_amount above the BOTTOM edge of the image.");
  83.     puts("Written by: Stephen Vermeulen, PO Box 3295, Station B,");
  84.     puts("Calgary, Alberta, CANADA, T2M 4L8.");
  85.   }
  86. }
  87.