home *** CD-ROM | disk | FTP | other *** search
/ MacFormat 1997 May / macformat-050.iso / Shareware Plus / Developers / Find_icon folder / Headers / Find_icon.h < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-25  |  3.4 KB  |  107 lines  |  [TEXT/CWIE]

  1. /*    ---------------------------------------------------------------------------------------------
  2.     Find_icon, code for constructing icon suites for files and folders
  3.     
  4.     by James W. Walker
  5.     preferred e-mail: <mailto:jwwalker@kagi.com>
  6.     alternate e-mail: <mailto:jwwalker@aol.com>, <jim@nisus-soft.com>
  7.     web: <http://users.aol.com/jwwalker/>
  8.     
  9.     File: Find_icon.h
  10.     
  11.     Copyright ©1997 by James W. Walker
  12.     
  13.     You may incorporate this sample code into your applications without
  14.     restriction, though the sample code has been provided "AS IS" and the
  15.     responsibility for its operation is 100% yours.
  16.     If you're going to re-distribute the source, please make it clear
  17.     that the code was descended from James W. Walker's code,
  18.     but that you've made changes.
  19.     
  20.     This library requires must be used with the MoreFiles library
  21.     by Jim Luther and Nitin Ganatra, which is used to get icons from
  22.     the desktop database or Desktop.  This version of Find_icon was
  23.     developed with MoreFiles 1.4.5.
  24.     ---------------------------------------------------------------------------------------------
  25. */
  26.  
  27. #ifndef __TYPES__
  28.     #include <Types.h>
  29. #endif
  30.  
  31. #ifndef __ICONS__
  32.     #include <Icons.h>
  33. #endif
  34.  
  35. #ifndef __FILES__
  36.     #include <Files.h>
  37. #endif
  38.  
  39. #ifndef    _H_MetaSelector_
  40.     #include "MetaSelector.h"
  41. #endif
  42.  
  43. enum {
  44.     uppFindIconProcInfo = kPascalStackBased
  45.          | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
  46.          | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec*)))
  47.          | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(MetaSelectorValue)))
  48.          | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle*)))
  49. };
  50.  
  51. typedef pascal OSErr (*Find_icon_procPtr)(
  52. /* --> */    const FSSpec *thing,
  53. /* --> */    MetaSelectorValue    icon_selector,
  54. /* <-- */    Handle *the_suite
  55. );
  56.  
  57. #if GENERATINGCFM
  58. typedef UniversalProcPtr    Find_icon_UPP;
  59. #else
  60. typedef Find_icon_procPtr    Find_icon_UPP;
  61. #endif
  62.  
  63. #if GENERATINGCFM
  64.     inline OSErr CallFindIcon( Find_icon_UPP userRoutine,
  65.         const FSSpec *thing, MetaSelectorValue    iconSelector, Handle *suite )
  66.     {
  67.         return CallUniversalProc( userRoutine, uppFindIconProcInfo,
  68.             thing, iconSelector, suite );
  69.     }
  70. //#define    CallFindIcon( userRoutine, thing, iconSelector, suite )    \
  71. //    CallUniversalProc((UniversalProcPtr)(userRoutine), uppFindIconProcInfo, \
  72. //        (thing), (iconSelector), (suite) )
  73. #else
  74.     #define    CallFindIcon( userRoutine, thing, iconSelector, suite )    \
  75.         (*(userRoutine))( (thing), (iconSelector), (suite) )
  76. #endif
  77.  
  78.  
  79. pascal OSErr Find_icon(
  80. /* --> */    const FSSpec *thing,
  81. /* --> */    MetaSelectorValue    icon_selector,
  82. /* <-- */    Handle *the_suite
  83. );
  84. /*    ¶ Given a file specification for a file, folder, or
  85.     volume, create an appropriate icon suite including
  86.     its label color.
  87.     The suite is returned as a newly created Handle. Your program is
  88.     responsible for disposing of the suite when it is done using the icon.
  89.     The icons in the suite will never be resource handles.
  90.     "Mini" (12x16) icons are not handled.
  91.     
  92.     thing            input:    File specification of file or directory.
  93.     icon_selector    input:    an icon type mask, as defined in <Icons.h>.
  94.                             You can also use the special masks from
  95.                             MetaSelector.h, for instance kSelectorLargeThenSmall
  96.                             means to first search for large icons, but
  97.                             if none are found, try for small icons.
  98.     the_suite        output:    The new icon suite.
  99.  
  100.     Result codes include:
  101.         noErr                0        No error
  102.         memFullErr            -108    iconHandle could not be duplicated
  103.         afpItemNotFound        -5012    Information not found
  104.         noMaskFoundErr        -1000    no 'ICN#' or 'ics#' was found
  105. */
  106.  
  107.