home *** CD-ROM | disk | FTP | other *** search
- /* ---------------------------------------------------------------------------------------------
- Find_icon, code for constructing icon suites for files and folders
-
- by James W. Walker
- preferred e-mail: <mailto:jwwalker@kagi.com>
- alternate e-mail: <mailto:jwwalker@aol.com>, <jim@nisus-soft.com>
- web: <http://users.aol.com/jwwalker/>
-
- File: Find_icon.h
-
- Copyright ©1997 by James W. Walker
-
- You may incorporate this sample code into your applications without
- restriction, though the sample code has been provided "AS IS" and the
- responsibility for its operation is 100% yours.
- If you're going to re-distribute the source, please make it clear
- that the code was descended from James W. Walker's code,
- but that you've made changes.
-
- This library requires must be used with the MoreFiles library
- by Jim Luther and Nitin Ganatra, which is used to get icons from
- the desktop database or Desktop. This version of Find_icon was
- developed with MoreFiles 1.4.5.
- ---------------------------------------------------------------------------------------------
- */
-
- #ifndef __TYPES__
- #include <Types.h>
- #endif
-
- #ifndef __ICONS__
- #include <Icons.h>
- #endif
-
- #ifndef __FILES__
- #include <Files.h>
- #endif
-
- #ifndef _H_MetaSelector_
- #include "MetaSelector.h"
- #endif
-
- enum {
- uppFindIconProcInfo = kPascalStackBased
- | RESULT_SIZE(SIZE_CODE(sizeof(OSErr)))
- | STACK_ROUTINE_PARAMETER(1, SIZE_CODE(sizeof(FSSpec*)))
- | STACK_ROUTINE_PARAMETER(2, SIZE_CODE(sizeof(MetaSelectorValue)))
- | STACK_ROUTINE_PARAMETER(3, SIZE_CODE(sizeof(Handle*)))
- };
-
- typedef pascal OSErr (*Find_icon_procPtr)(
- /* --> */ const FSSpec *thing,
- /* --> */ MetaSelectorValue icon_selector,
- /* <-- */ Handle *the_suite
- );
-
- #if GENERATINGCFM
- typedef UniversalProcPtr Find_icon_UPP;
- #else
- typedef Find_icon_procPtr Find_icon_UPP;
- #endif
-
- #if GENERATINGCFM
- inline OSErr CallFindIcon( Find_icon_UPP userRoutine,
- const FSSpec *thing, MetaSelectorValue iconSelector, Handle *suite )
- {
- return CallUniversalProc( userRoutine, uppFindIconProcInfo,
- thing, iconSelector, suite );
- }
- //#define CallFindIcon( userRoutine, thing, iconSelector, suite ) \
- // CallUniversalProc((UniversalProcPtr)(userRoutine), uppFindIconProcInfo, \
- // (thing), (iconSelector), (suite) )
- #else
- #define CallFindIcon( userRoutine, thing, iconSelector, suite ) \
- (*(userRoutine))( (thing), (iconSelector), (suite) )
- #endif
-
-
- pascal OSErr Find_icon(
- /* --> */ const FSSpec *thing,
- /* --> */ MetaSelectorValue icon_selector,
- /* <-- */ Handle *the_suite
- );
- /* ¶ Given a file specification for a file, folder, or
- volume, create an appropriate icon suite including
- its label color.
- The suite is returned as a newly created Handle. Your program is
- responsible for disposing of the suite when it is done using the icon.
- The icons in the suite will never be resource handles.
- "Mini" (12x16) icons are not handled.
-
- thing input: File specification of file or directory.
- icon_selector input: an icon type mask, as defined in <Icons.h>.
- You can also use the special masks from
- MetaSelector.h, for instance kSelectorLargeThenSmall
- means to first search for large icons, but
- if none are found, try for small icons.
- the_suite output: The new icon suite.
-
- Result codes include:
- noErr 0 No error
- memFullErr -108 iconHandle could not be duplicated
- afpItemNotFound -5012 Information not found
- noMaskFoundErr -1000 no 'ICN#' or 'ics#' was found
- */
-
-