home *** CD-ROM | disk | FTP | other *** search
/ BCI NET 2 / BCI NET 2.iso / archives / programming / misc / xref_v1.1.lha / XRef / Tools / lib / saveicon.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-11-29  |  2.1 KB  |  78 lines

  1. /*
  2. ** $PROJECT: xrefsupport.lib
  3. **
  4. ** $VER: saveicon.c 1.2 (03.11.94)
  5. **
  6. ** by
  7. **
  8. ** Stefan Ruppert , Windthorststraße 5 , 65439 Flörsheim , GERMANY
  9. **
  10. ** (C) Copyright 1994
  11. ** All Rights Reserved !
  12. **
  13. ** $HISTORY:
  14. **
  15. ** 03.11.94 : 001.002 :  gadget width and height now correct
  16. ** 04.09.94 : 001.001 :  initial
  17. */
  18.  
  19. /* ------------------------------- include -------------------------------- */
  20.  
  21. #include "/source/Def.h"
  22.  
  23. #include "xrefsupport.h"
  24.  
  25. /* ------------------------------- function ------------------------------- */
  26.  
  27. void saveicon(STRPTR file,struct SaveDefIcon *def_icon)
  28. {
  29.    struct SaveDefIcon old;
  30.    struct DiskObject *dobj;
  31.    BOOL oldicon = FALSE;
  32.  
  33.    if(IconBase = OpenLibrary("icon.library",37))
  34.    {
  35.       if(!(dobj = GetDiskObject(file)))
  36.       {
  37.          if(!(dobj = GetDiskObject(def_icon->sdi_DefaultIcon)))
  38.             if(dobj = GetDefDiskObject(WBPROJECT))
  39.             {
  40.                old.sdi_Image       = dobj->do_Gadget.GadgetRender;
  41.                old.sdi_DefaultTool = dobj->do_DefaultTool;
  42.                old.sdi_ToolTypes   = dobj->do_ToolTypes;
  43.  
  44.                if(def_icon->sdi_Image)
  45.                {
  46.                   dobj->do_Gadget.GadgetRender = def_icon->sdi_Image;
  47.                   dobj->do_Gadget.Width        = def_icon->sdi_Image->Width;
  48.                   dobj->do_Gadget.Height       = def_icon->sdi_Image->Height;
  49.                   dobj->do_Gadget.Flags        = GFLG_GADGHCOMP | GFLG_GADGIMAGE;
  50.                }
  51.  
  52.                if(def_icon->sdi_DefaultTool)
  53.                   dobj->do_DefaultTool = def_icon->sdi_DefaultTool;
  54.                if(def_icon->sdi_ToolTypes)
  55.                   dobj->do_ToolTypes   = def_icon->sdi_ToolTypes;
  56.             }
  57.  
  58.          if(dobj)
  59.          {
  60.             PutDiskObject(file,dobj);
  61.  
  62.             if(oldicon)
  63.             {
  64.                dobj->do_Gadget.GadgetRender = old.sdi_Image;
  65.                dobj->do_DefaultTool         = old.sdi_DefaultTool;
  66.                dobj->do_ToolTypes           = old.sdi_ToolTypes;
  67.             }
  68.          }
  69.       }
  70.  
  71.       if(dobj)
  72.          FreeDiskObject(dobj);
  73.  
  74.       CloseLibrary(IconBase);
  75.    }
  76. }
  77.  
  78.