home *** CD-ROM | disk | FTP | other *** search
- /************************************************************
- center.c By: Stephen Vermeulen
-
- Copyright (C) 1989 By Stephen Vermeulen
-
- Use this tool to rearrange an icon so its image overlaps
- the text description, the text being centered in the icon's image.
-
- It has the following syntax:
-
- center file
-
- when this is typed, center will load the file called "file.info"
- and change it and then resave it under
- the old name to the disk.
- ************************************************************/
-
- #include <intuition/intuition.h>
- #include <workbench/workbench.h>
- #include <stdio.h>
- #include <functions.h>
-
- #define NO_ICONS 4
-
- extern ULONG IconBase;
-
- /************************************************************
- The following routine just opens the libraries
- ************************************************************/
-
- short OpenLibs()
- {
- short flags; /* any libraries that do not open get recorded here */
-
- flags = 0;
- IconBase = (ULONG) OpenLibrary("icon.library", 0L);
- if (!IconBase) flags |= NO_ICONS;
- return(flags);
- }
-
- void CloseLibs(flags)
- short flags;
- {
- if (!(flags & NO_ICONS)) CloseLibrary(IconBase);
- }
-
- void main(argc, argv)
- short argc;
- char *argv[];
- {
- short lib_flags, icon_type;
- long xo, yo;
- struct DiskObject *dobj, *drawer_obj;
- struct DrawerData *dd_temp;
-
- if (argc >= 2)
- {
- lib_flags = OpenLibs();
- if (!lib_flags)
- {
- if (dobj = GetDiskObject(argv[1]))
- {
- /** ok to proceed **/
-
- if (argc == 3)
- {
- yo = ((struct Image *) dobj->do_Gadget.GadgetRender)->Height;
- dobj->do_Gadget.Height = yo + 1;
- }
- else
- {
- yo = ((struct Image *) dobj->do_Gadget.GadgetRender)->Height;
- dobj->do_Gadget.Height = (yo >> 1) - 4;
- }
- PutDiskObject(argv[1], dobj);
- FreeDiskObject(dobj);
- }
- }
- CloseLibs(lib_flags);
- }
- else
- {
- puts("Syntax is: center icon [c]");
- puts(" ... don't use the .icon suffix! Use the `c' flag to restore");
- puts("Written by: Stephen Vermeulen, PO Box 3295, Station B,");
- puts("Calgary, Alberta, CANADA, T2M 4L8.");
- }
- }
-