1 /* 2 Open Tracker License 3 4 Terms and Conditions 5 6 Copyright (c) 1991-2000, Be Incorporated. All rights reserved. 7 8 Permission is hereby granted, free of charge, to any person obtaining a copy of 9 this software and associated documentation files (the "Software"), to deal in 10 the Software without restriction, including without limitation the rights to 11 use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 12 of the Software, and to permit persons to whom the Software is furnished to do 13 so, subject to the following conditions: 14 15 The above copyright notice and this permission notice applies to all licensees 16 and shall be included in all copies or substantial portions of the Software. 17 18 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF TITLE, MERCHANTABILITY, 20 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 21 BE INCORPORATED BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN 22 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF, OR IN CONNECTION 23 WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. 24 25 Except as contained in this notice, the name of Be Incorporated shall not be 26 used in advertising or otherwise to promote the sale, use or other dealings in 27 this Software without prior written authorization from Be Incorporated. 28 29 Tracker(TM), Be(R), BeOS(R), and BeIA(TM) are trademarks or registered trademarks 30 of Be Incorporated in the United States and other countries. Other brand product 31 names are registered trademarks or trademarks of their respective holders. 32 All rights reserved. 33 */ 34 35 #ifndef __BITS__ 36 #define __BITS__ 37 38 39 #include <Locker.h> 40 #include <Resources.h> 41 #include <Mime.h> 42 #include <image.h> 43 44 #include "TrackerIcons.h" 45 46 class BBitmap; 47 48 namespace BPrivate { 49 50 // This maps the old tracker resource ID definitions to the new ones 51 // generated by QuickRes. Somebody want to go through the code and 52 // get rid of all these? 53 enum { 54 kResAppIcon = R_AppIcon, 55 kResFileIcon = R_FileIcon, 56 kResFolderIcon = 1, 57 kResTrashIcon = R_TrashIcon, 58 kResTrashFullIcon = R_TrashFullIcon, 59 kResQueryIcon = 2, 60 kResQueryTemplateIcon = 4, 61 kResPrinterIcon = R_PrinterIcon, 62 kResBarberPoleBitmap = R_BarberPoleBitmap, 63 kResFloppyIcon = R_FloppyIcon, 64 kResHardDiskIcon = 3, 65 kResCDIcon = R_CDIcon, 66 kResRootIcon = R_RootIcon, 67 kResBookmarkIcon = R_BookmarkIcon, 68 kResPersonIcon = R_PersonIcon, 69 kResBrokenLinkIcon = R_BrokenLinkIcon, 70 kResDeskIcon = R_DeskIcon, 71 kResHomeDirIcon = R_HomeDirIcon, 72 kResBeosFolderIcon = R_BeosFolderIcon, 73 kResBootVolumeIcon = R_BootVolumeIcon, 74 kResFontDirIcon = R_FontDirIcon, 75 kResAppsDirIcon = R_AppsDirIcon, 76 kResPrefsDirIcon = R_PrefsDirIcon, 77 kResMailDirIcon = R_MailDirIcon, 78 kResQueryDirIcon = R_QueryDirIcon, 79 kResSpoolFileIcon = R_SpoolFileIcon, 80 kResGenericPrinterIcon = R_GenericPrinterIcon, 81 kResDevelopDirIcon = R_DevelopDirIcon, 82 kResDownloadDirIcon = R_DownloadDirIcon, 83 kResPersonDirIcon = R_PersonDirIcon, 84 kResUtilDirIcon = R_UtilDirIcon, 85 kResConfigDirIcon = R_ConfigDirIcon, 86 kResMoveStatusBitmap = R_MoveStatusBitmap, 87 kResCopyStatusBitmap = R_CopyStatusBitmap, 88 kResTrashStatusBitmap = R_TrashStatusBitmap, 89 kResBackNavActive = R_ResBackNavActive, 90 kResBackNavInactive = R_ResBackNavInactive, 91 kResForwNavActive = R_ResForwNavActive, 92 kResForwNavInactive = R_ResForwNavInactive, 93 kResUpNavActive = R_ResUpNavActive, 94 kResUpNavInactive = R_ResUpNavInactive, 95 kResBackNavActiveSel = R_ResBackNavActiveSel, 96 kResForwNavActiveSel = R_ResForwNavActiveSel, 97 kResUpNavActiveSel = R_ResUpNavActiveSel, 98 kResShareIcon = R_ShareIcon 99 }; 100 101 102 class BImageResources 103 { 104 // convenience class for accessing 105 public: 106 BImageResources(void *memAddr); 107 ~BImageResources(); 108 109 BResources *ViewResources(); 110 const BResources *ViewResources() const; 111 112 status_t FinishResources(BResources *) const; 113 114 const void *LoadResource(type_code type, int32 id, 115 size_t *outSize) const; 116 const void *LoadResource(type_code type, const char *name, 117 size_t *outSize) const; 118 // load a resource from the Tracker executable, just like the 119 // corresponding functions in BResources. These methods are 120 // thread-safe. 121 122 status_t GetIconResource(int32 id, icon_size size, BBitmap *dest) const; 123 // this is a wrapper around LoadResource(), for retrieving 124 // B_LARGE_ICON and B_MINI_ICON ('ICON' and 'MICN' respectively) 125 // resources. this does sanity checking on the found data, 126 // and if all is okay blasts it into the 'dest' bitmap. 127 128 status_t GetIconResource(int32 id, const uint8** iconData, 129 size_t* iconSize) const; 130 // this is a wrapper around LoadResource(), for retrieving 131 // the vector icon data 132 133 status_t GetBitmapResource(type_code type, int32 id, BBitmap **out) const; 134 // this is a wrapper around LoadResource(), for retrieving 135 // arbitrary bitmaps. the resource with the given type and 136 // id is looked up, and a BBitmap created from it and returned 137 // in <out>. currently it can only create bitmaps from data 138 // that is an archived bitmap object. 139 140 private: 141 image_id find_image(void *memAddr) const; 142 143 mutable BLocker fLock; 144 BResources fResources; 145 }; 146 147 148 149 extern 150 #ifdef _IMPEXP_TRACKER 151 _IMPEXP_TRACKER 152 #endif 153 BImageResources* GetTrackerResources(); 154 155 } // namespace BPrivate 156 157 using namespace BPrivate; 158 159 #endif // __BITS__ 160