00001 // $Id: thumb.h 751 2006-03-31 15:43:49Z alex $ 00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE 00003 ================================XARAHEADERSTART=========================== 00004 00005 Xara LX, a vector drawing and manipulation program. 00006 Copyright (C) 1993-2006 Xara Group Ltd. 00007 Copyright on certain contributions may be held in joint with their 00008 respective authors. See AUTHORS file for details. 00009 00010 LICENSE TO USE AND MODIFY SOFTWARE 00011 ---------------------------------- 00012 00013 This file is part of Xara LX. 00014 00015 Xara LX is free software; you can redistribute it and/or modify it 00016 under the terms of the GNU General Public License version 2 as published 00017 by the Free Software Foundation. 00018 00019 Xara LX and its component source files are distributed in the hope 00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the 00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 00022 See the GNU General Public License for more details. 00023 00024 You should have received a copy of the GNU General Public License along 00025 with Xara LX (see the file GPL in the root directory of the 00026 distribution); if not, write to the Free Software Foundation, Inc., 51 00027 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 00028 00029 00030 ADDITIONAL RIGHTS 00031 ----------------- 00032 00033 Conditional upon your continuing compliance with the GNU General Public 00034 License described above, Xara Group Ltd grants to you certain additional 00035 rights. 00036 00037 The additional rights are to use, modify, and distribute the software 00038 together with the wxWidgets library, the wxXtra library, and the "CDraw" 00039 library and any other such library that any version of Xara LX relased 00040 by Xara Group Ltd requires in order to compile and execute, including 00041 the static linking of that library to XaraLX. In the case of the 00042 "CDraw" library, you may satisfy obligation under the GNU General Public 00043 License to provide source code by providing a binary copy of the library 00044 concerned and a copy of the license accompanying it. 00045 00046 Nothing in this section restricts any of the rights you have under 00047 the GNU General Public License. 00048 00049 00050 SCOPE OF LICENSE 00051 ---------------- 00052 00053 This license applies to this program (XaraLX) and its constituent source 00054 files only, and does not necessarily apply to other Xara products which may 00055 in part share the same code base, and are subject to their own licensing 00056 terms. 00057 00058 This license does not apply to files in the wxXtra directory, which 00059 are built into a separate library, and are subject to the wxWindows 00060 license contained within that directory in the file "WXXTRA-LICENSE". 00061 00062 This license does not apply to the binary libraries (if any) within 00063 the "libs" directory, which are subject to a separate license contained 00064 within that directory in the file "LIBS-LICENSE". 00065 00066 00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS 00068 ---------------------------------------------- 00069 00070 Subject to the terms of the GNU Public License (see above), you are 00071 free to do whatever you like with your modifications. However, you may 00072 (at your option) wish contribute them to Xara's source tree. You can 00073 find details of how to do this at: 00074 http://www.xaraxtreme.org/developers/ 00075 00076 Prior to contributing your modifications, you will need to complete our 00077 contributor agreement. This can be found at: 00078 http://www.xaraxtreme.org/developers/contribute/ 00079 00080 Please note that Xara will not accept modifications which modify any of 00081 the text between the start and end of this header (marked 00082 XARAHEADERSTART and XARAHEADEREND). 00083 00084 00085 MARKS 00086 ----- 00087 00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara 00089 designs are registered or unregistered trademarks, design-marks, and/or 00090 service marks of Xara Group Ltd. All rights in these marks are reserved. 00091 00092 00093 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK. 00094 http://www.xara.com/ 00095 00096 =================================XARAHEADEREND============================ 00097 */ 00098 00099 // Thumbnail cache class for the library system 00100 // Cheap 'n' Cheesy version knocked up by Richard 00101 /***********************************************************************/ 00102 00103 #ifndef INC_THUMB 00104 #define INC_THUMB 00105 00106 #include "bitmap.h" 00107 //#include "pathname.h" 00108 00109 typedef void * LP_SGTHUMBS_MOREINFO; 00110 00111 /***********************************************************************/ 00112 00113 class Library; 00114 class PathName; 00115 00116 // All the types of library 00117 enum SGLibType 00118 { 00119 SGLib_Blank = 0, // Unknown library type 00120 SGLib_ClipArt, // Clipart libraries 00121 SGLib_Font, // Font libraries 00122 SGLib_Bitmap, // Bitmap libs 00123 SGLib_Texture, // Texture libs 00124 SGLib_Colour, // Colour libs 00125 SGLib_Fractal, // Fractal fill libs 00126 SGLib_ClipArt_WebThemes 00127 }; 00128 00129 // All thumbnail sizes 00130 enum SGThumbSize 00131 { 00132 SGThumb_Small = 0, // Small thumbnails 00133 SGThumb_Medium, 00134 SGThumb_Large 00135 }; 00136 00137 00138 /***********************************************************************/ 00139 00140 class SGThumbs : public CC_CLASS_MEMDUMP 00141 { 00142 CC_DECLARE_MEMDUMP(SGThumbs) 00143 00144 public: 00145 00146 SGThumbs(); 00147 00148 // Destructor - calls DeleteThumbnails() - returns all memory 00149 ~SGThumbs(); 00150 00151 // Constructor which sets the Size of thumbnails as well 00152 SGThumbs(PathName *Dir, SGLibType Type, SGThumbSize Size); 00153 00154 // Get a thumbnail from the cache, disk, or if Directory == NULL try and generate it. 00155 BOOL GetThumbnail(UINT32 ID, BOOL Urgent, KernelBitmap **Result, PathName *File = NULL, LP_SGTHUMBS_MOREINFO MoreInfo = NULL); 00156 00157 // Set thumbnail size - all returned thumbnails will be this size after this call 00158 BOOL SetSize(SGThumbSize Size); 00159 00160 // Get current thumbnail size setting 00161 BOOL GetSize(SGThumbSize *Size); 00162 00163 // Delete all thumbnail cache entries and return the memory 00164 BOOL DeleteThumbnails(void); 00165 00166 // Debugging stuff - do not call 00167 void DumpCache(char *DumpFile); 00168 00169 // Called when we want to change MaxThumbnails; 00170 static BOOL ResizeAllThumbCaches(INT32 Entries); 00171 00172 // Access to the protected members 00173 inline PathName *GetDirectory() {return Directory;} 00174 inline SGLibType GetType() {return ThumbnailsLibType;} 00175 00176 protected: 00177 00178 // Return encrypted thumbnail filename 00179 BOOL GetThumbnailName(UINT32 ID, String_8 *Result); 00180 00181 // Sets the internal structures to sensible values 00182 // Assumes pointers not pointing to NULL are not pointing to memory 00183 BOOL InitThumbnails(SGLibType Type, SGThumbSize Size); 00184 00185 // Return TRUE and an offset if ID is in cache 00186 BOOL OffsetInCache(UINT32 ID, UINT32 *Offset); 00187 00188 // Find an unused slot, if there are non, use the one with the least Usage 00189 BOOL FindNewSlotInBuffer(UINT32 *Slot); 00190 00191 // Load a thumbnail into a given slot 00192 BOOL LoadThumbnailIntoSlot(UINT32 Slot, UINT32 ID, PathName *ActualFile = NULL); 00193 00194 private: 00195 00196 // Implementation helper function to check file existence 00197 BOOL OpenThumbnailFile( CCDiskFile* pFile, const PathName& ThumbFileName ) const; 00198 00199 protected: 00200 00201 // Use a more fabby data-structure when we've got CCList access 00202 struct TN { 00203 UINT32 ID; // ID for thumbnail held below 00204 UINT32 Usage; // Usage count - used for finding new slots 00205 BOOL Valid; // Are buffer and ID valid ? 00206 SGThumbSize Size; // Size of thumbnail 00207 KernelBitmap *buffer; // Pointer to actual data 00208 }; 00209 00210 // Array of thumbnails 00211 TN *Thumbnails; 00212 00213 // Number of thumbnails in array 00214 INT32 Entries; 00215 00216 // Place where all the thumbnails are being stored 00217 PathName *Directory; 00218 00219 // Have we initialised the data-structures yet ? 00220 BOOL ThumbnailsInitialised; 00221 00222 // Size of thumbnail to load, cache and return 00223 SGThumbSize ThumbnailsSize; 00224 00225 // Type of library we're dealing with here 00226 SGLibType ThumbnailsLibType; 00227 00228 public: 00229 // Maximum number of entries in thumbnail cache 00230 static INT32 MaxThumbnails; 00231 }; 00232 00233 /***********************************************************************/ 00234 00235 #endif