home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1995 May / macformat-024.iso / Shareware City / Developers / GetFileIcon ƒ / GetFileIcon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-01-02  |  7.9 KB  |  332 lines  |  [TEXT/KAHL]

  1. #include <exceptions.h>
  2. #include <Finder.h>
  3. #include <Folders.h>
  4. #include <Types.h>
  5. #include <Icons.h>
  6. #include <Resources.h>
  7.  
  8.  
  9.  
  10.  
  11.  
  12. /*    Custom icons numbered -16496 appear in aliases to volumes and
  13.     servers.  I don't know where this is documented.    */
  14. #define    kVolumeAliasIconResource    -16496
  15.  
  16. typedef struct 
  17. {
  18.     OSType        fileCreator;
  19.     OSType        fileType;
  20.     short        DTRefNum;
  21. } GetIconData;
  22.  
  23.  
  24. /*  alignment type values  */
  25. typedef short    IconAlignmentType;
  26.  
  27. enum {
  28.     atNone                = 0x0,
  29.     atVerticalCenter    = 0x1,
  30.     atTop                = 0x2,
  31.     atBottom            = 0x3,
  32.     atHorizontalCenter    = 0x4,
  33.     atAbsoluteCenter    = (atVerticalCenter | atHorizontalCenter),
  34.     atCenterTop            = (atTop | atHorizontalCenter),
  35.     atCenterBottom        = (atBottom | atHorizontalCenter),
  36.     atLeft                = 0x8,
  37.     atCenterLeft        = (atVerticalCenter | atLeft),
  38.     atTopLeft            = (atTop | atLeft),
  39.     atBottomLeft        = (atBottom | atLeft),
  40.     atRight                = 0xC,
  41.     atCenterRight        = (atVerticalCenter | atRight),
  42.     atTopRight            = (atTop | atRight),
  43.     atBottomRight        = (atBottom | atRight)
  44. };
  45.  
  46. /*  transform type values  */
  47. typedef short    IconTransformType;
  48.  
  49. enum {
  50.     ttNone                = 0x0,
  51.     ttDisabled            = 0x1,
  52.     ttOffline            = 0x2,
  53.     ttOpen                = 0x3,
  54.     ttLabel1            = 0x0100,
  55.     ttLabel2            = 0x0200,
  56.     ttLabel3            = 0x0300,
  57.     ttLabel4            = 0x0400,
  58.     ttLabel5            = 0x0500,
  59.     ttLabel6            = 0x0600,
  60.     ttLabel7            = 0x0700,
  61.     ttSelected            = 0x4000,
  62.     ttSelectedDisabled    = (ttSelected | ttDisabled),
  63.     ttSelectedOffline    = (ttSelected | ttOffline),
  64.     ttSelectedOpen        = (ttSelected | ttOpen)
  65. };
  66.  
  67. /*  Selector mask values  */
  68. typedef unsigned long    IconSelectorValue;    
  69.  
  70. enum {
  71.     svLarge1Bit            = 0x00000001,
  72.     svLarge4Bit            = 0x00000002,
  73.     svLarge8Bit            = 0x00000004,
  74.     svSmall1Bit            = 0x00000100,
  75.     svSmall4Bit            = 0x00000200,
  76.     svSmall8Bit            = 0x00000400,
  77.     svMini1Bit            = 0x00010000,
  78.     svMini4Bit            = 0x00020000,
  79.     svMini8Bit            = 0x00040000,
  80.     svAllLargeData        = 0x000000ff,
  81.     svAllSmallData        = 0x0000ff00,
  82.     svAllMiniData        = 0x00ff0000,
  83.     svAll1BitData        = (svLarge1Bit | svSmall1Bit | svMini1Bit),
  84.     svAll4BitData        = (svLarge4Bit | svSmall4Bit | svMini4Bit),
  85.     svAll8BitData        = (svLarge8Bit | svSmall8Bit | svMini8Bit),
  86.     svAllAvailableData    = 0xffffffff
  87. };
  88.  
  89. typedef pascal OSErr (*IconAction)(ResType theType, Handle *theIcon, void *yourDataPtr);
  90. typedef pascal Handle (*IconGetter)(ResType theType, void *yourDataPtr);
  91.  
  92. #ifdef __cplusplus
  93. extern "C" {
  94. #endif
  95.  
  96. pascal OSErr PlotIconID(const Rect *theRect,
  97.                             IconAlignmentType align,
  98.                             IconTransformType transform,
  99.                             short theResID)
  100.     = {0x303C, 0x0500, 0xABC9};
  101.     
  102. pascal OSErr NewIconSuite(Handle *theIconSuite)
  103.     = {0x303C, 0x0207, 0xABC9};
  104.     
  105. pascal OSErr AddIconToSuite(Handle theIconData,
  106.                             Handle theSuite,
  107.                             ResType theType)
  108.     = {0x303C, 0x0608, 0xABC9};
  109.     
  110. pascal OSErr GetIconFromSuite(Handle *theIconData,
  111.                             Handle theSuite,
  112.                             ResType theType)
  113.     = {0x303C, 0x0609, 0xABC9};
  114.     
  115. pascal OSErr ForEachIconDo(Handle theSuite,
  116.                             IconSelectorValue selector,
  117.                             IconAction action,
  118.                             void *yourDataPtr)
  119.     = {0x303C, 0x080A, 0xABC9};
  120.     
  121. pascal OSErr GetIconSuite(Handle *theIconSuite,
  122.                             short theResID,
  123.                             IconSelectorValue selector)
  124.     = {0x303C, 0x0501, 0xABC9};
  125.     
  126. pascal OSErr DisposeIconSuite(Handle theIconSuite,
  127.                             Boolean disposeData)
  128.     = {0x303C, 0x0302, 0xABC9};
  129.     
  130. pascal OSErr PlotIconSuite(const Rect *theRect,
  131.                             IconAlignmentType align,
  132.                             IconTransformType transform,
  133.                             Handle theIconSuite)
  134.     = {0x303C, 0x0603, 0xABC9};
  135.     
  136. pascal OSErr MakeIconCache(Handle *theHandle,
  137.                             IconGetter makeIcon,
  138.                             void *yourDataPtr)
  139.     = {0x303C, 0x0604, 0xABC9};
  140.     
  141. pascal OSErr LoadIconCache(const Rect *theRect,
  142.                             IconAlignmentType align,
  143.                             IconTransformType transform,
  144.                             Handle theIconCache)
  145.     = {0x303C, 0x0606, 0xABC9};
  146.  
  147. pascal OSErr PlotIconMethod(const Rect *theRect,
  148.                             IconAlignmentType align,
  149.                             IconTransformType transform,
  150.                             IconGetter theMethod,
  151.                             void *yourDataPtr)
  152.     = {0x303C, 0x0805, 0xABC9};
  153.     
  154. pascal OSErr GetLabel(short labelNumber,
  155.                             RGBColor *labelColor,
  156.                             Str255 labelString)
  157.     = {0x303c, 0x050B, 0xABC9};
  158.     
  159. pascal Boolean PtInIconID(Point testPt,
  160.                             Rect *iconRect,
  161.                             IconAlignmentType alignment,
  162.                             short iconID)
  163.     = {0x303c, 0x060D, 0xABC9};
  164.     
  165. pascal Boolean PtInIconSuite(Point testPt,
  166.                             Rect *iconRect,
  167.                             IconAlignmentType alignment,
  168.                             Handle theIconSuite)
  169.     = {0x303c, 0x070E, 0xABC9};
  170.     
  171. pascal Boolean PtInIconMethod(Point testPt,
  172.                             Rect *iconRect,
  173.                             IconAlignmentType alignment,
  174.                             IconGetter theMethod,
  175.                             void *yourDataPtr)
  176.     = {0x303c, 0x090F, 0xABC9};
  177.     
  178. pascal Boolean RectInIconID(Rect *testRect,
  179.                             Rect *iconRect,
  180.                             IconAlignmentType alignment,
  181.                             short iconID)
  182.     = {0x303c, 0x0610, 0xABC9};
  183.     
  184. pascal Boolean RectInIconSuite(Rect *testRect,
  185.                             Rect *iconRect,
  186.                             IconAlignmentType alignment,
  187.                             Handle theIconSuite)
  188.     = {0x303c, 0x0711, 0xABC9};
  189.     
  190. pascal Boolean RectInIconMethod(Rect *testRect,
  191.                             Rect *iconRect,
  192.                             IconAlignmentType alignment,
  193.                             IconGetter theMethod,
  194.                             void *yourDataPtr)
  195.     = {0x303c, 0x0912, 0xABC9};
  196.     
  197. pascal OSErr IconIDToRgn(RgnHandle theRgn,
  198.                             Rect *iconRect,
  199.                             IconAlignmentType alignment,
  200.                             short iconID)
  201.     = {0x303c, 0x0613, 0xABC9};
  202.     
  203. pascal OSErr IconSuiteToRgn(RgnHandle theRgn,
  204.                             Rect *iconRect,
  205.                             IconAlignmentType alignment,
  206.                             Handle theIconSuite)
  207.     = {0x303c, 0x0714, 0xABC9};
  208.     
  209. pascal OSErr IconMethodToRgn(RgnHandle theRgn,
  210.                             Rect *iconRect,
  211.                             IconAlignmentType alignment,
  212.                             IconGetter theMethod,
  213.                             void *yourDataPtr)
  214.     = {0x303c, 0x0915, 0xABC9};
  215.     
  216. pascal OSErr SetSuiteLabel(Handle theSuite, short theLabel)
  217.     = {0x303C, 0x0316, 0xABC9};
  218.  
  219. pascal short GetSuiteLabel(Handle theSuite)
  220.     = {0x303C, 0x0217, 0xABC9};
  221.  
  222. pascal OSErr GetIconCacheData(Handle theCache, void **theData)
  223.     = {0x303C, 0x0419, 0xABC9};
  224.         
  225. pascal OSErr SetIconCacheData(Handle theCache, void *theData)
  226.     = {0x303C, 0x041A, 0xABC9};
  227.         
  228. pascal OSErr GetIconCacheProc(Handle theCache, IconGetter *theProc)
  229.     = {0x303C, 0x041B, 0xABC9};
  230.         
  231. pascal OSErr SetIconCacheProc(Handle theCache, IconGetter theProc)
  232.     = {0x303C, 0x041C, 0xABC9};
  233.     
  234. pascal OSErr PlotIconHandle(const Rect *theRect,
  235.                             IconAlignmentType align,
  236.                             IconTransformType transform,
  237.                             Handle theIcon)
  238.     = {0x303C, 0x061D, 0xABC9};
  239.     
  240. pascal OSErr PlotSICNHandle(const Rect *theRect,
  241.                             IconAlignmentType align,
  242.                             IconTransformType transform,
  243.                             Handle theSICN)
  244.     = {0x303C, 0x061E, 0xABC9};
  245.     
  246. pascal OSErr PlotCIconHandle(const Rect *theRect,
  247.                             IconAlignmentType align,
  248.                             IconTransformType transform,
  249.                             CIconHandle theCIcon)
  250.     = {0x303C, 0x061F, 0xABC9};
  251.     
  252. #ifdef __cplusplus
  253. }
  254. #endif
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267. pascal OSErr GetFileIcon(
  268. /* --> */    FSSpec                *thing,
  269. /* --> */    IconSelectorValue    iconSelector,
  270. /* <-- */    Handle                *theSuite);
  271.  
  272. Boolean    IsVolEjected( short vRefNum );
  273.  
  274. OSErr    GetCustomFileIcon(
  275. /* --> */    FSSpec                *filespec,
  276. /* --> */    IconSelectorValue    iconSelector,
  277. /* <-- */    Handle                *theSuite);
  278.  
  279. OSErr    GetNormalFileIcon(
  280. /* --> */    CInfoPBRec            *cpb,
  281. /* --> */    IconSelectorValue    iconSelector,
  282. /* <-- */    Handle                *theSuite);
  283.  
  284. static    pascal OSErr GetIconProc(ResType theType, Handle *theIcon, void *yourDataPtr);
  285.  
  286. static    short    FindDesktopDatabase(
  287. /* --> */    short    firstVRefNum,
  288. /* --> */    OSType    fileCreator);
  289.  
  290. static    Boolean    InOneDesktop(
  291. /* --> */    short    vRefNum,
  292. /* --> */    OSType    fileCreator,
  293. /* <-- */    short    *dtRefNum);
  294.  
  295. pascal OSErr GetResourceIcons(
  296. /* <-- */    Handle    *theSuite,
  297. /* --> */    short    theID,
  298. /* --> */    long    theSelector);
  299.  
  300. OSErr CopyEachIcon(
  301. /* <-> */    Handle theSuite);
  302.  
  303. static pascal OSErr CopyOneIcon(
  304. /* --> */    ResType        theType,
  305. /* <-> */    Handle        *theIcon,
  306. /* --- */    void        *yourDataPtr);
  307.  
  308. short    FindGenericIconID(
  309. /* --> */    OSType theType,
  310. /* <-- */    Boolean    *inFinder);
  311.  
  312. pascal OSErr Get1IconSuite(
  313. /* <-- */    Handle    *theSuite,
  314. /* --> */    short    theID,
  315. /* --> */    long    theSelector);
  316.  
  317. static pascal OSErr Get1Icon(
  318. /* --> */    ResType    theType,
  319. /* <-> */    Handle    *theIcon,
  320. /* --> */    short    *resID);
  321.  
  322. static pascal OSErr TestHandle(ResType theType, Handle *theIcon, void *yourDataPtr);
  323.  
  324. Boolean IsSuiteEmpty( Handle theSuite );
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.