thumb.cpp

Go to the documentation of this file.
00001 // $Id: thumb.cpp 1282 2006-06-09 09:46: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 // Thumb.cpp - Thumbnail handling class for the library system
00099 
00100 #include "camtypes.h"
00101 //#include "bitmap.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00102 #include "oilbitmap.h"
00103 //#include "dibutil.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00104 //#include "pngutil.h"
00105 //#include "thumb.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00106 //#include "sgscan.h"
00107 #include "bitfilt.h"
00108 #ifndef WEBSTER
00109 //#include "extfilts.h"
00110 #endif //WEBSTER
00111 //#include "errors.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00114 //#include "sgfonts.h"
00115 //#include "ccfile.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00116 #include "thumbmsg.h"
00117 #include "sgliboil.h"
00118 //#include "fontpgen.h"
00119 //#include "camfiltr.h" // BaseCamelotFilter - in camtypes.h [AUTOMATICALLY REMOVED]
00120 //#include "cmxifltr.h" // CMXImportFilter
00121 //#include "dialogop.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00122 
00123 // Implement the dynamic class bits...
00124 CC_IMPLEMENT_MEMDUMP(SGThumbs, CC_CLASS_MEMDUMP)
00125 
00126 // The thumb messages
00127 CC_IMPLEMENT_DYNAMIC(ThumbMessage, Msg)
00128 
00129 // This line mustn't go before any CC_IMPLEMENT_... macros
00130 #define new CAM_DEBUG_NEW
00131 
00132 /***********************************************************************/
00133 
00134 // MaxThumbnails is a static... it's read from the .ini file at some point
00135 INT32 SGThumbs::MaxThumbnails = 25;
00136 
00137 // Files larger than this won't be loaded and scaled for the bmp gallery
00138 const INT32 ThumbFileSizeThreshold = 50*1024;
00139 
00140 /***********************************************************************/
00141 
00142 // Which files should we be checking to load in the thumbnails
00143 //#define THUMB_CHECK_FILENAME_WITH_TIF
00144 //#define THUMB_CHECKTIFS
00145 
00146 // Check for reversed type endings -> .pmb instead of .bmp (in the thumbnails directory)
00147 #define THUMB_CHECK_REVERSED_FILENAME
00148 
00149 // Default thumbnails generated by the galleries use this naming convention
00150 #define THUMB_CHECK_FILENAME_WITH_BMP
00151 
00152 // Thumbnails generated for download use this naming convention
00153 #define THUMB_CHECK_FILENAME_WITH_PNG
00154 
00155 // Needed for font previews
00156 //#ifndef WEBSTER
00157 #define THUMB_CHECKBMPS
00158 //#endif //WEBSTER
00159 #define THUMB_CHECKPNGS
00160 
00161 /***********************************************************************************************
00162 
00163 >   SGThumbs::SGThumbs()
00164 
00165     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00166     Created:    21/2/95
00167     Inputs:     
00168     Purpose:    Default constructor - DO NOT USE !
00169     Notes:
00170     SeeAlso:    SGThumbs::SGThumbs
00171 
00172 ***********************************************************************************************/
00173 
00174 SGThumbs::SGThumbs()
00175 {
00176     ERROR3("WRONG SGThumb constructor called");
00177 }
00178 
00179 
00180 /***********************************************************************************************
00181 
00182 >   SGThumbs::~SGThumbs()
00183 
00184     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00185     Created:    21/2/95
00186     Inputs:     
00187     Purpose:    Destroys a thumbnail cache, freeing memory as it goes
00188     Notes:
00189     SeeAlso:    SGThumbs::SGThumbs
00190 
00191 ***********************************************************************************************/
00192                
00193 SGThumbs::~SGThumbs()
00194 {
00195     DeleteThumbnails();
00196 
00197     if(Thumbnails != NULL)
00198     {
00199         CCFree(Thumbnails);
00200         Thumbnails = NULL;
00201     }
00202 
00203     if(Directory != NULL)
00204     {
00205         delete Directory;
00206         Directory = NULL;
00207     }
00208 }
00209 
00210 /***********************************************************************************************
00211 
00212 >   SGThumbs::SGThumbs(PathName *Dir, SGLibType Type, SGThumbSize Size)
00213 
00214     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00215     Created:    21/2/95
00216     Inputs:     Dir - Pathname for thumbnail directory (should end in \XaraInfo) (see notes)
00217                 Type - Type of library we're dealing with
00218                 Size - Size of thumbnails to display (SGThumb_Small, SGThumb_Medium, or SGThumb_Large)
00219     Purpose:    Creates a new thumbnail cache for use by the SG library system
00220     Notes:      If the Dir is NULL then we assume the thumbnails need generating rather than
00221                 loading.
00222     SeeAlso:    SGThumbs::~SGThumbs
00223 
00224 ***********************************************************************************************/
00225 
00226 SGThumbs::SGThumbs(PathName *Dir, SGLibType Type, SGThumbSize Size)
00227 {
00228 /*  if(Type == SGLib_ClipArt)
00229     {
00230         String_256 D(Dir->GetPath());
00231         ERROR3_PF(("SGThumbs initialised with %s", (TCHAR *)D));
00232     }*/
00233     
00234     // Search directory for thumbnails
00235     if(Dir != NULL)
00236         Directory = new PathName(*Dir);
00237     else
00238         Directory = NULL;
00239     
00240     InitThumbnails(Type, Size);
00241 }
00242 
00243 /***********************************************************************************************
00244 
00245 >   BOOL SGThumbs::GetThumbnailName(UINT32 ID, String_8 *Filename)
00246 
00247     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00248     Created:    21/2/95
00249     Inputs:     ID - ID for the thumbnail
00250                 Path - pointer to a string_8 to return the thumbnail name
00251     Purpose:    Builds an encrypted thumbnail filename for an ID, size and type...
00252     Notes:      Size and type information are held internally in the SGThumbs class.
00253                 The extension isn't added here.
00254     SeeAlso:    SGThumbs::SGThumbs
00255 
00256 ***********************************************************************************************/
00257 
00258 BOOL SGThumbs::GetThumbnailName(UINT32 ID, String_8 *Filename)
00259 {
00260     ERROR3IF(Filename == NULL, "SGThumbs::GetThumbnailName passed a null ptr");
00261 
00262     TCHAR type;
00263     TCHAR size;
00264 
00265     switch(ThumbnailsLibType) {
00266         case SGLib_ClipArt:
00267         case SGLib_ClipArt_WebThemes:
00268             type = 'A';
00269             break;
00270         case SGLib_Bitmap:
00271             type = 'B';
00272             break;
00273         case SGLib_Colour:
00274             type = 'C';
00275             break;
00276         case SGLib_Font:
00277             type = 'F';
00278             break;
00279         case SGLib_Texture:
00280             type = 'T';
00281             break;
00282         default:
00283             type = ' ';
00284             break;
00285     }
00286 
00287     switch(ThumbnailsSize) {
00288         case SGThumb_Small:
00289             size = 'S';
00290             break;
00291         case SGThumb_Medium:
00292             size = 'M';
00293             break;
00294         case SGThumb_Large:
00295             size = 'L';
00296             break;
00297         default:
00298             size = ' ';
00299             break;
00300     }
00301 
00302     Filename->_MakeMsg(_T("%c%05d%c"), type, ID, size); 
00303 
00304     return TRUE;
00305 }
00306 
00307 /***********************************************************************************************
00308 
00309 >   BOOL SGThumbs::InitThumbnails(SGLibType Type, SGThumbSize Size)
00310 
00311     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00312     Created:    21/2/95
00313     Inputs:     Type - Type of library
00314                 Size - Initial size of thumbnail to use
00315     Purpose:    Sets the internal structures to sensible values
00316                 Assumes pointers not pointing to NULL are not pointing to memory
00317                 Allocates memory for thumbnail cache
00318     Notes:
00319 
00320 ***********************************************************************************************/
00321 
00322 BOOL SGThumbs::InitThumbnails(SGLibType Type, SGThumbSize Size)
00323 {   
00324 //  Read in value for MaxThumbnails here
00325 //  MaxThumbnails = 10;
00326 //  GetApplication()->DeclareSection(TEXT("Libraries"), 6);
00327 //  GetApplication()->DeclarePref(TEXT("Libraries"), TEXT("Thumbnails"), &MaxThumbnails, 1, 100);
00328 
00329     Entries = MaxThumbnails;
00330 
00331     Thumbnails = (struct TN*)CCMalloc(sizeof(struct TN) * Entries);
00332     if(Thumbnails != NULL)
00333     {
00334         INT32 i;
00335         ThumbnailsLibType = Type;
00336         ThumbnailsSize = Size;
00337 
00338         for(i=0; i<Entries; i++)
00339         {
00340             Thumbnails[i].ID = 0;
00341             Thumbnails[i].Usage = 0;
00342             Thumbnails[i].Valid = FALSE;
00343             Thumbnails[i].Size = ThumbnailsSize;
00344             Thumbnails[i].buffer = NULL;
00345         }
00346         ThumbnailsInitialised = TRUE;
00347         return TRUE;
00348     }
00349     else
00350     {
00351         ThumbnailsInitialised = TRUE;
00352         return FALSE;
00353     }
00354 }
00355 
00356 /***********************************************************************************************
00357 
00358 >   BOOL SGThumbs::DeleteThumbnails(void)
00359 
00360     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00361     Created:    21/2/95
00362     Inputs:
00363     Purpose:    Delete all thumbnail cache entries and return the memory
00364     Notes:
00365 
00366 ***********************************************************************************************/
00367 
00368 BOOL SGThumbs::DeleteThumbnails(void)
00369 {
00370     INT32 i;
00371     if(!ThumbnailsInitialised) return FALSE;
00372     for(i=0; i<Entries; i++)
00373     {
00374         Thumbnails[i].ID = 0;
00375         Thumbnails[i].Usage = 0;
00376         Thumbnails[i].Valid = FALSE;
00377         Thumbnails[i].Size = ThumbnailsSize;
00378         if(Thumbnails[i].buffer)
00379         {
00380             //delete (CWxBitmap *)(Thumbnails[i].buffer->ActualBitmap);
00381             //Thumbnails[i].buffer->ActualBitmap = NULL;
00382             delete Thumbnails[i].buffer;
00383             Thumbnails[i].buffer = NULL;
00384         }
00385     }
00386 
00387     return TRUE;
00388 }
00389 
00390 /***********************************************************************************************
00391 
00392 >   BOOL SGThumbs::OffsetInCache(UINT32 ID, UINT32 *Offset)
00393 
00394     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00395     Created:    21/2/95
00396     Inputs:     ID - Thumbnail ID
00397                 Offset - Offset in cache which is used
00398     Purpose:    Return TRUE and an offset if ID is in cache
00399     Notes:
00400 
00401 ***********************************************************************************************/
00402                    
00403 BOOL SGThumbs::OffsetInCache(UINT32 ID, UINT32 *Offset)
00404 {
00405     if(Offset == NULL)
00406     {
00407         ERROR3("SGThumbs::OffsetInCache given a null offset");
00408         return FALSE;
00409     }
00410 
00411     INT32 i;
00412     // Check if we're already in the buffer 
00413     for(i=0; i<Entries; i++)
00414     {
00415         if(Thumbnails[i].ID == ID && Thumbnails[i].Valid && Thumbnails[i].Size == ThumbnailsSize)
00416         {
00417             *Offset = i;
00418             return TRUE;
00419         }
00420     }
00421 
00422     return FALSE;
00423 }
00424 
00425 /***********************************************************************************************
00426 
00427 >   BOOL SGThumbs::FindNewSlotInBuffer(UINT32 *Slot)
00428 
00429     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00430     Created:    21/2/95
00431     Inputs:     Slot - Pointer to slot to use
00432     Purpose:    Find an unused slot, if there are non, use the one with the least Usage
00433     Notes:
00434 
00435 ***********************************************************************************************/
00436 
00437 BOOL SGThumbs::FindNewSlotInBuffer(UINT32 *Slot)
00438 {
00439     if(Slot == NULL)
00440     {
00441         ERROR3("SGThumbs::FindNewSlotInBuffer given a null slot");
00442         return FALSE;
00443     }
00444 
00445 //  BOOL found = FALSE;
00446     INT32 i;
00447 
00448     for(i=0; i<Entries; i++)
00449     {
00450         if(!Thumbnails[i].Valid || (Thumbnails[i].Size != ThumbnailsSize))
00451         {
00452             *Slot = i;
00453             return TRUE;
00454         }
00455     }
00456 
00457     UINT32 SmallestOffset = 0;
00458     UINT32 Smallest = Thumbnails[0].Usage;
00459 
00460     for(i=1; i<Entries; i++)
00461     {
00462         if(Thumbnails[i].Usage < Smallest)
00463         {
00464             SmallestOffset = i;
00465             Smallest = Thumbnails[i].Usage;
00466         }
00467     }
00468 
00469     *Slot = SmallestOffset;
00470     return TRUE;
00471 }
00472 
00473 
00474 /***********************************************************************************************
00475 
00476 >   BOOL SGThumbs::LoadThumbnailIntoSlot(UINT32 Slot, UINT32 ID, PathName *ActualFile = NULL)
00477 
00478     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00479     Created:    21/2/95
00480     Inputs:     Slot - Pointer to slot to use
00481                 ID - ID of thumbnail being put in slot
00482                 ActualFile - Filename of actual art or font file being referenced
00483     Purpose:    Load a thumbnail into a given slot
00484     Notes:      The way we find the thumbnail is currently a little non-obvious.
00485                 ...and changed on 02/04/97 Martin
00486                 First we check to see if the original file is a type that contains an internal
00487                 preview. art files start with a tiff, xar and web files have a tagged preview
00488                 of any type or possibly none, cmx and photoCD files have their own internal
00489                 formats. If the file does not exist (may not be downloaded yet) or it doesn't
00490                 have an internal preview or it is a font file we look for an external preview
00491                 testing for the most likely file extensions. All new previews have straight
00492                 forward extensions like png for png files, unlike the old system which did file
00493                 type reversal and who knows what else. Generally we try to use native Xara code
00494                 but we always give Accusoft the last chance if we failed. We still don't use the
00495                 filter system everywhere - this should be implemented sometime (instead of
00496                 calling DIBUtil or Accusoft etc. directly).
00497 
00498 ***********************************************************************************************/
00499 
00500 BOOL SGThumbs::LoadThumbnailIntoSlot(UINT32 Slot, UINT32 ID, PathName *ActualFile)
00501 {
00502 /*  String_256 P(ActualFile->GetPath());
00503     ERROR3_PF(("Actual file: %s", (TCHAR *)P));*/
00504 
00505     PORTNOTETRACE("dialog","SGThumbs::LoadThumbnailIntoSlot - do nothing");
00506 #ifndef EXCLUDE_FROM_XARALX
00507     if(Directory == NULL || ActualFile == NULL)
00508     {
00509         ERROR3("SGThumbs::LoadThumbnailIntoSlot Directory == NULL || ActualFile == NULL");
00510         return FALSE;
00511     }
00512 
00513     // Return any memory that would otherwise go down the toilet, and block the drains
00514     if(Thumbnails[Slot].Valid && Thumbnails[Slot].buffer)
00515     {
00516         delete Thumbnails[Slot].buffer;
00517         Thumbnails[Slot].buffer=NULL;
00518     }
00519 
00520     // Just in case we jump out in a state of unhappy rampantness
00521     Thumbnails[Slot].Valid = FALSE;
00522 
00523     BOOL CheckFilenameBmp = TRUE;
00524     BOOL CheckFilenamePng = TRUE;
00525     BOOL CheckFilenameReversed = TRUE;
00526     BOOL CheckFilenameTif = TRUE;
00527     BOOL CheckEncodedBmp = TRUE;
00528     BOOL CheckEncodedPng = TRUE;
00529     BOOL CheckEncodedTif = TRUE;
00530 
00531     BOOL UseActualFile = FALSE;
00532 
00533     BOOL IsRIFFTypeFile = FALSE;
00534     BOOL IsPCDTypeFile = FALSE;
00535 
00536     // Get lowercase filetype
00537     String_256 Type(ActualFile->GetType());
00538     Type.toLower();
00539 
00540     // Bodge to speed galleries up for art files - doesn't check or use external previews
00541     if( (Type.Sub((String_8)"art") != -1) ||
00542         (Type.Sub((String_8)"xar") != -1) )
00543     {
00544         UseActualFile = TRUE;
00545         CheckFilenameReversed = FALSE;
00546     }
00547     else if ( (Type.Sub((String_8)"web") != -1) ||
00548               (Type.Sub((String_8)"cxw") != -1) ||
00549               (Type.Sub((String_8)"cxn") != -1) )
00550     {
00551         // Check for our new version 2 native and web files
00552         //WEBSTER-Martin-23/01/97
00553         //force us to look for previews
00554         UseActualFile = TRUE;
00555         CheckFilenameReversed = FALSE;
00556     }
00557     else if ( (Type.Sub((String_8)"cdr") != -1) ||
00558               (Type.Sub((String_8)"cmx") != -1) )
00559     {
00560         IsRIFFTypeFile = TRUE;
00561         UseActualFile = TRUE;
00562         CheckFilenameReversed = FALSE;
00563     }
00564     else if( Type.Sub((String_8)"ttf") != -1 ||
00565              Type.Sub((String_8)"pfb") != -1)
00566     {
00567         // Bodge to speed font gallery up a bit - only checks encoded bmp file thumbnails
00568         CheckFilenamePng = 
00569             CheckFilenameBmp = 
00570             CheckFilenameReversed = 
00571             CheckFilenameTif = 
00572             CheckEncodedTif = FALSE;
00573 
00574         CheckEncodedBmp = TRUE;
00575         CheckEncodedPng = TRUE;
00576 
00577         UseActualFile = FALSE;
00578     }
00579     else if( Type.Sub((String_8)"pcd") != -1 )
00580     {
00581         IsPCDTypeFile = TRUE;
00582         UseActualFile = TRUE;
00583     }
00584 
00585     // Read the file into the bm yet ?
00586     BOOL Found = FALSE;
00587     CWxBitmap *pCWxBitmap = NULL;
00588     BOOL ReadOK = FALSE;
00589 
00590     // Don't error, just set exceptions... (changed 2/10/2000 by Jonathan to use
00591     // errors rather than exceptions to avoid a pile of messy first-change exceptions
00592     // when fills were not being found)
00593     CCDiskFile File(1024, FALSE, FALSE);
00594 
00595     // internal preview
00596     if(UseActualFile)
00597     {
00598         // Open file and check if it exists at the same time
00599         Found = OpenThumbnailFile( &File, *ActualFile );
00600 
00601         if(Found)
00602         {
00603 
00604             // Create an OILy bitmap object
00605             pCWxBitmap = new CWxBitmap;
00606             if (pCWxBitmap == NULL)
00607             {
00608                 ERROR3("Problem creating thumbnail bitmap");
00609                 return FALSE;
00610             }
00611         
00612             // files with internal preveiws
00613             // WEBSTER-Martin-08/01/97
00614             if(IsRIFFTypeFile)
00615             {
00616 #ifndef WEBSTER //WEBSTER-Martin-21/01/97
00617                 if ( AccusoftFilters::GetVersionNumber() > 0)
00618                 {
00619                     // search to see if we can find a thumbnail in this file
00620                     if ( CMXImportFilter::SkipToPreviewBitmap(&File) )
00621                     {
00622                         TRACEUSER( "Martin", _T("Accusoft read RIFF preview\n"));
00623                         ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE, NULL, NULL, TRUE );
00624                     }
00625                 }
00626                 else
00627                 {
00628                     TRACEUSER( "Martin", _T("Accusoft filter not loaded\n"));
00629                     ReadOK = FALSE;
00630                 }
00631 #endif //WEBSTER
00632             }
00633             else if(IsPCDTypeFile)
00634             {
00635 #ifndef WEBSTER //WEBSTER-Martin-21/01/97
00636                 if ( AccusoftFilters::GetVersionNumber() > 0)
00637                 {
00638                     TRACEUSER( "Martin", _T("Accusoft read PCD preview\n"));
00639                     // Use the tiny preview... (we're a friend of AccusoftFilters by the way)
00640                     AccusoftFilters::ImagePageToRead = 2;
00641                     ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE, NULL, NULL, TRUE );
00642                 }
00643                 else
00644                 {
00645                     TRACEUSER( "Martin", _T("Accusoft filter not loaded\n"));
00646                     ReadOK = FALSE;
00647                 }
00648 #endif //WEBSTER
00649             }
00650             else // new native file
00651             {
00652                 // First, check that we have a CX2/XaraX format file, and
00653                 // try to extract its preview bitmap at the same time.
00654                 BOOL IsNewFormat = FALSE;
00655                 UINT32 FilterId = FILTERID_NONE;
00656                 if (BaseCamelotFilter::SkipToPreviewBitmap(&File, &IsNewFormat, &FilterId))
00657                 {
00658                     // Get the preview!
00659                     if (FilterId != FILTERID_NONE)
00660                     {
00661                         Filter* pFilter = Filter::FindFilterFromID(FilterId);
00662                         if (pFilter != NULL)
00663                         {
00664                             ERROR3IF( !pFilter->IS_KIND_OF(BaseBitmapFilter), "Preview filter is not a BaseBitmapFilter\n" );
00665                             ReadOK = ((BaseBitmapFilter *)pFilter)->ReadFromFile( pCWxBitmap, NULL, &File, FALSE );
00666                         }
00667                     }
00668                     
00669                     // Couldn't find a preview bitmap, so we'll make a note to
00670                     // check for an external preview file instead.
00671                     else
00672                     {
00673                         UseActualFile   = FALSE;
00674                         Found           = FALSE;
00675                         File.close();
00676 
00677                         delete pCWxBitmap;
00678                         pCWxBitmap = NULL;
00679                     }
00680                 }
00681 
00682                 // SkipToPreviewBitmap failed, so we'll assume that it's an old-format file.
00683                 // In that case, we must try to load in its TIFF preview.
00684                 else
00685                 {
00686                     if (AccusoftFilters::GetVersionNumber() > 0)
00687                         ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );
00688                     else
00689                         ReadOK = FALSE;
00690                 }
00691             }
00692         }
00693         else
00694         {
00695             TRACEUSER( "Martin", _T("Failed to find original file %s\n"), (const TCHAR *)ActualFile->GetFileName(TRUE));
00696             Error::ClearError();
00697             // didn't find original so look for external preview
00698             UseActualFile = FALSE;
00699         }
00700     }
00701 
00702     //we test this again cos we can change our mind about UseActualFile
00703     if(!UseActualFile)
00704     {
00705 
00706 #ifdef THUMB_CHECK_FILENAME_WITH_PNG
00707         if(CheckFilenamePng && !Found)
00708         {
00709             // Check for c:\clipart\sublib\xarainfo\picture.png files (from picture.tif or whatever)
00710             String_256 FAP;
00711         
00712             FAP = Directory->GetPath(TRUE);
00713             FAP += ActualFile->GetFileName(FALSE);
00714             FAP += TEXT(".png");
00715 
00716 //          ERROR3_PF(("Looking for: %s", (TCHAR *)FAP));
00717 
00718             PathName ThumbPath(FAP);
00719 
00720             // <Filename>.png
00721             Found = OpenThumbnailFile( &File, ThumbPath );
00722 
00723             if(Found)
00724             {
00725                 // Create an OILy bitmap object
00726                 pCWxBitmap = new CWxBitmap;
00727                 if (pCWxBitmap == NULL)
00728                 {
00729                     ERROR3("Problem creating bitmap");
00730                     return FALSE;
00731                 }
00732 
00733                 // PNGs
00734                 INT32 TransColour;  // ignore value returned into this
00735                 ReadOK = PNGUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, &TransColour );
00736             }
00737         }
00738 #endif
00739 
00740 #ifdef THUMB_CHECK_FILENAME_WITH_BMP
00741         if(CheckFilenameBmp && !Found)
00742         {
00743             // Check for c:\clipart\sublib\xarainfo\picture.bmp files (from picture.tif or whatever)
00744             String_256 FAP;
00745         
00746             FAP = Directory->GetPath(TRUE);
00747             FAP += ActualFile->GetFileName(FALSE);
00748             FAP += TEXT(".bmp");
00749 
00750             PathName ThumbPath(FAP);
00751 
00752             // <Filename>.bmp
00753             Found = OpenThumbnailFile( &File, ThumbPath );
00754 
00755             if(Found)
00756             {
00757                 // Create an OILy bitmap object
00758                 pCWxBitmap = new CWxBitmap;
00759                 if (pCWxBitmap == NULL)
00760                 {
00761                     ERROR3("Problem creating bitmap");
00762                     return FALSE;
00763                 }
00764 
00765                 // BMPs
00766                 ReadOK = DIBUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );
00767 
00768                 if ( !ReadOK )
00769                 {
00770                     delete pCWxBitmap;
00771                     pCWxBitmap = NULL;
00772                     Found = FALSE;
00773                     Error::ClearError();
00774         
00775                     // Er, well, it might be monochrome, so use accusoft then...
00776                     // <Filename>.bmp
00777                     File.close();
00778                     Found = OpenThumbnailFile( &File, ThumbPath );
00779                 }
00780             }
00781         }
00782 #endif
00783 
00784 #ifdef THUMB_CHECK_REVERSED_FILENAME
00785         if( CheckFilenameReversed && !Found )
00786         {
00787             // Check for c:\clipart\sublib\xarainfo\picture.fit file from picture.tif, etc...
00788             String_256 FAP;
00789         
00790             FAP = Directory->GetPath(TRUE);
00791             FAP += ActualFile->GetFileName(FALSE);
00792             String_256 Ending(ActualFile->GetType());
00793             _tcsrev((TCHAR *)Ending);       // reverse the bmp to pmb
00794             FAP += TEXT(".");
00795             FAP += (TCHAR *)Ending;
00796 
00797             //ERROR3_PF(("Looking for: %s", (TCHAR *)FAP));
00798 
00799             PathName ThumbPath(FAP);
00800 
00801             // <Filename>.fit <Filename>.pmb etc.
00802             Found = OpenThumbnailFile( &File, ThumbPath );
00803 
00804             if(Found)
00805             {
00806                 // Create an OILy bitmap object
00807                 pCWxBitmap = new CWxBitmap;
00808                 if (pCWxBitmap == NULL)
00809                 {
00810                     return FALSE;
00811                 }
00812 
00813                 // BMPs
00814                 ReadOK = DIBUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );
00815 
00816                 if ( ReadOK )
00817                 {
00818                     // Set the name to the filename (without the .bmp)  
00819                     String_256 Name(ActualFile->GetFileName(FALSE));
00820                     pCWxBitmap->SetName(Name);
00821                 }
00822                 else
00823                 {
00824                     delete pCWxBitmap;
00825                     pCWxBitmap = NULL;
00826                     Found = FALSE;
00827                     Error::ClearError();
00828 
00829                     // Er, well, it might be monochrome, so use accusoft then...
00830                     // <Filename>.pmb
00831                     File.close();
00832                     Found = OpenThumbnailFile( &File, ThumbPath );
00833                 }
00834             }
00835         }
00836 
00837 #endif
00838 
00839 #ifdef THUMB_CHECK_FILENAME_WITH_TIF
00840         if( CheckFilenameTif && !Found )
00841         {
00842             // Check for normal tiff thumbnail file of the form <Filename>.TIF
00843             // Construct a full pathname for actual filename with a tif extension
00844             String_256 FullThumbnailPath(Directory->GetPath(TRUE));
00845             FullThumbnailPath += ActualFile->GetFileName(FALSE);
00846             FullThumbnailPath += TEXT(".tif");
00847 
00848             TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);
00849 
00850             PathName FileAndPath(FullThumbnailPath);
00851 
00852             // <Filename>.tif
00853             Found = OpenThumbnailFile( &File, FileAndPath );
00854         }
00855 #endif
00856 
00857         // Work out the encoded thumbnail name for use in multiple places below
00858         String_256 FullThumbnailPathWithoutExtension;
00859         if(!Found)
00860         {
00861             String_8 EncodedThumbnail;
00862     
00863             // Find encoded thumbnail path
00864             if(!GetThumbnailName(ID, &EncodedThumbnail))
00865                 return FALSE;
00866 
00867             // Construct a full pathname for the encoded thumbnail file
00868             FullThumbnailPathWithoutExtension =  Directory->GetPath(TRUE);
00869             FullThumbnailPathWithoutExtension += EncodedThumbnail;
00870         }
00871 
00872 
00873 #ifdef THUMB_CHECKBMPS
00874         if(CheckEncodedBmp && !Found)
00875         {
00876             // Check for standard bitmap thumbnail file of the form X00000X.BMP
00877             // And load it using internal Xara code rather than Accusoft
00878 
00879             // Construct a full pathname for the encoded thumbnail file
00880             String_256 FullThumbnailPath(FullThumbnailPathWithoutExtension);
00881             FullThumbnailPath += TEXT(".bmp");
00882             TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);
00883 
00884             PathName FileAndPath(FullThumbnailPath);
00885 
00886             // <Filename>.bmp
00887             Found = OpenThumbnailFile( &File, FileAndPath );
00888 
00889             if(Found)
00890             {
00891                 // Create an OILy bitmap object
00892                 pCWxBitmap = new CWxBitmap;
00893                 if (pCWxBitmap == NULL)
00894                 {
00895                     ERROR3("Problem creating bitmap");
00896                     return FALSE;
00897                 }
00898 
00899                 // Set the name to the thumbID name (without the .bmp)  
00900                 String_256 Name(FileAndPath.GetFileName(FALSE));
00901                 pCWxBitmap->SetName(Name);
00902 
00903                 // BMPs
00904                 ReadOK = DIBUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE );
00905 
00906                 if(!ReadOK)
00907                 {
00908                     delete pCWxBitmap;
00909                     pCWxBitmap = NULL;
00910                     Found = FALSE;
00911                     Error::ClearError();
00912 
00913                     // Er, well, it might be monochrome, so use accusoft then...
00914                     // <Filename>.bmp
00915                     File.close();
00916                     Found = OpenThumbnailFile( &File, FileAndPath );
00917                 }
00918             }
00919         }
00920 #endif
00921 
00922 #ifdef THUMB_CHECKPNGS
00923         if(CheckEncodedPng && !Found)
00924         {
00925             // Check for downloaded thumbnail file of the form X00000X.PNG
00926             // And load it using internal Xara code rather than Accusoft
00927 
00928             // Construct a full pathname for the encoded thumbnail file
00929             String_256 FullThumbnailPath(FullThumbnailPathWithoutExtension);
00930             FullThumbnailPath += TEXT(".png");
00931             TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);
00932 
00933             PathName FileAndPath(FullThumbnailPath);
00934 
00935             // <Filename>.png
00936             Found = OpenThumbnailFile( &File, FileAndPath );
00937 
00938             if(Found)
00939             {
00940                 // Create an OILy bitmap object
00941                 pCWxBitmap = new CWxBitmap;
00942                 if (pCWxBitmap == NULL)
00943                 {
00944                     ERROR3("Problem creating bitmap");
00945                     return FALSE;
00946                 }
00947 
00948                 // Set the name to the thumbID name (without the .png)  
00949                 String_256 Name(FileAndPath.GetFileName(FALSE));
00950                 pCWxBitmap->SetName(Name);
00951 
00952                 // PNGs
00953                 INT32 TransColour;  // ignore value returned into this
00954                 ReadOK = PNGUtil::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, &TransColour );
00955             }
00956         }
00957 #endif
00958 
00959 #ifdef THUMB_CHECKTIFS
00960         if(CheckEncodedTif && !Found)
00961         {
00962             // Check for encoded tiff thumbnail file of the form X00000X.TIF
00963 
00964             // Construct a full pathname for the encoded thumbnail file
00965             String_256 FullThumbnailPath(FullThumbnailPathWithoutExtension);
00966             FullThumbnailPath += TEXT(".tif");
00967             TRACEUSER( "Richard", _T("Filename: %s\n"), (TCHAR *)FullThumbnailPath);
00968 
00969             PathName FileAndPath(FullThumbnailPath);
00970 
00971             // X00000X.tif
00972             Found = OpenThumbnailFile( &File, FileAndPath );
00973         }
00974 #endif
00975 
00976 #ifndef WEBSTER //WEBSTER-Martin-21/01/97
00977         if ( Found && !ReadOK )
00978         {
00979             // this is Accusoft's last chance
00980             if ( AccusoftFilters::GetVersionNumber() > 0)
00981             {
00982                 ReadOK = AccusoftFilters::ReadFromFile( &File, &pCWxBitmap->BMInfo, &pCWxBitmap->BMBytes, TRUE, NULL, NULL, TRUE );
00983             }
00984             else
00985             {
00986                 TRACEUSER( "Martin", _T("Accusoft filter not loaded\n"));
00987                 ReadOK = FALSE;
00988             }
00989         }
00990 #endif //WEBSTER
00991     }
00992 
00993     if(!ReadOK || pCWxBitmap == NULL)
00994     {
00995         // Problems somewhere above
00996         TRACEUSER( "Richard", _T("Can't find/load thumbnail"));
00997 
00998         // We don't want error boxes popping up every time we can't find a thumbnail
00999         Error::ClearError();
01000 
01001         if(pCWxBitmap != NULL)
01002         {
01003             delete pCWxBitmap;
01004             pCWxBitmap = NULL;
01005         }
01006         return FALSE;
01007     }
01008 
01009     // Set the name to the file's name (without the .art .xar etc)  
01010     String_256 Name(ActualFile->GetFileName(FALSE));
01011     pCWxBitmap->SetName(Name);
01012 
01013     // create the kernel bitmap, attaching the OILy bitmap to it
01014     Thumbnails[Slot].buffer = new KernelBitmap(pCWxBitmap, TRUE);
01015     if (Thumbnails[Slot].buffer == NULL)
01016     {
01017         ERROR3("Problem creating kernel bitmap for thumbnail");
01018         delete pCWxBitmap;
01019         pCWxBitmap = NULL;
01020         return FALSE;
01021     }
01022 
01023     // Set the rest of the entries to sensible values
01024     Thumbnails[Slot].Valid = TRUE;
01025     Thumbnails[Slot].ID = ID;
01026     Thumbnails[Slot].Usage = 0;
01027     Thumbnails[Slot].Size = ThumbnailsSize;
01028 
01029     Error::ClearError();
01030 #endif
01031     // Well, looks like we got ourselves a thumbnail...
01032     return TRUE;
01033 }
01034 
01035 /**********************************************************************************************
01036 
01037 >   BOOL SGThumbs::OpenThumbnailFile( CCDiskFile* pFile, const PathName& ThumbFileName ) const
01038 
01039     Author:     Martin_Bell (Xara Group Ltd) <camelotdev@xara.com>
01040     Created:    24/01/97
01041 
01042     Inputs:     pFile - pointer to the file to try to open
01043                 ThumbFileName - the filename of the file to try
01044 
01045     Returns:    TRUE - if the file exists and was opened successfully
01046                 FALSE otherwise
01047 
01048     Scope:      private
01049 
01050     Purpose:    Check to see if the thumbnail file exists and open the file. The function simply
01051                 checks the filename given which may be a genuine thumbnail or a xara file with a
01052                 preview
01053 
01054 ***********************************************************************************************/
01055 
01056 BOOL SGThumbs::OpenThumbnailFile( CCDiskFile* pFile, const PathName& ThumbFileName ) const
01057 {
01058     ERROR3IF( pFile==NULL, "SGThumbs::OpenThumbnailFile passed a null ptr" );
01059     
01060     TRACEUSER( "Martin", _T("Open thumb file: %s\n"), (const TCHAR *)ThumbFileName.GetPath() );
01061 
01062     BOOL Found = FALSE;
01063 
01064     if(!ThumbFileName.IsValid())
01065     {
01066         // either xarainfo\<filename> or the actual clipart file
01067         ERROR3("SGThumbs::OpenThumbnailFile received an invalid xarainfo\\<filename> file");
01068         Error::ClearError();
01069         return FALSE;
01070     }
01071 
01072     // Open file and check if it exists at the same time
01073     if( !( Found = pFile->open( ThumbFileName, ios::in | ios::binary ) ) )
01074     {
01075         Found = FALSE;
01076         Error::ClearError();
01077     }
01078 
01079     return Found;
01080 }
01081 
01082                 
01083 /**********************************************************************************************
01084 
01085 >   BOOL SGThumbs::GetThumbnail(UINT32 ID, BOOL Urgent, KernelBitmap **Result, PathName *File = NULL,
01086                                                         LP_SGTHUMBS_MOREINFO MoreInfo = NULL)
01087 
01088     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01089     Created:    21/2/95
01090     Inputs:     ID - ID of thumbnail to get
01091                 Urgent - set to TRUE if we definitely want the thumbnail now, setting it
01092                          to FALSE will only return a bitmap if one's in the cache (This is
01093                          to support background redraw where only thumbs which can be 
01094                          retrieved fast will be drawn)
01095                 File - Filename of actual art or font file being referenced (can be null)
01096                 MoreInfo - usually a pointer to an object which will have a member capable of
01097                          generating a thumbnail if (Directory == NULL). Handy for installed fonts.
01098 
01099     Outputs:    Result - The value pointed to by Result will be filled in with
01100                 a pointer to a created thumbnail. This may be NULL if a thumb could
01101                 not be found/created (if Urgent == FALSE, then this will be NULL if the
01102                 thumb is not cached in memory)
01103 
01104     Purpose:    Get a thumbnail from disk, or hopefully from the cache 
01105 
01106 ***********************************************************************************************/
01107 
01108 BOOL SGThumbs::GetThumbnail(UINT32 ID, BOOL Urgent, KernelBitmap **Result, PathName *File, LP_SGTHUMBS_MOREINFO MoreInfo)
01109 {
01110     PORTNOTETRACE("dialog","SGThumbs::GetThumbnail - do nothing");
01111 #ifndef EXCLUDE_FROM_XARALX
01112 #ifndef EXCLUDE_GALS
01113     // File can be NULL, and signifies that we need to generate the thumbnail - fonts
01114     if(Result == NULL)
01115     {
01116         ERROR3("SGThumbs::GetThumbnail - NULL result parameters are illegal");
01117         return FALSE;
01118     }                                                                                
01119     
01120     *Result = NULL;
01121 
01122     if(!ThumbnailsInitialised) return FALSE;
01123 
01124     BOOL ok = TRUE;
01125     UINT32 Slot = 0;
01126 
01127     ok = OffsetInCache(ID, &Slot);
01128 
01129     // Not in cache and not urgent
01130     if(!ok && !Urgent)
01131         return FALSE;
01132 
01133     MonotonicTime TempTime;
01134 
01135     if(!ok) 
01136     {
01137         ok = FindNewSlotInBuffer(&Slot);
01138         if(!ok) return FALSE;
01139 
01140         if(Directory == NULL)
01141         {
01142             if(MoreInfo == NULL)
01143             {
01144                 ERROR3("SGThumbs::GetThumbnail MoreInfo is NULL as is Directory. Can't generate the thumbnail");
01145                 return FALSE;
01146             }
01147 
01148             if(Thumbnails[Slot].Valid && Thumbnails[Slot].buffer)
01149             {
01150                 delete Thumbnails[Slot].buffer;
01151                 Thumbnails[Slot].buffer=NULL;
01152             }
01153 
01154             // Just in case we jump out in a state of unhappy rampantness
01155             Thumbnails[Slot].Valid = FALSE;
01156 
01157             switch(ThumbnailsLibType)
01158             {
01159                 case SGLib_Font:
01160                     ok = ((SGDisplayPreviewFonts *)MoreInfo)->CreateThumbnail(&Thumbnails[Slot].buffer);                    
01161                     break;
01162                     
01163                 default:
01164                     TRACEUSER( "Richard", _T("Cannot create thumbnails of this type"));
01165                     return FALSE;
01166             }
01167 
01168             if(ok)
01169             {
01170                 // Set the cache entries so the thing works
01171                 Thumbnails[Slot].Valid = TRUE;
01172                 Thumbnails[Slot].ID = ID;
01173                 Thumbnails[Slot].Usage = 0;
01174                 Thumbnails[Slot].Size = ThumbnailsSize;
01175             }
01176         }
01177         else
01178         {
01179             if(File != NULL)
01180             {
01181                 ok = LoadThumbnailIntoSlot(Slot, ID, File);
01182                 if(!ok)
01183                 {
01184                     TRACEUSER( "Richard", _T("PROBLEMS loading thumbnail"));
01185                     return FALSE;
01186                 }
01187 
01188 // WEBSTER-Martin-09/01/97
01189 #ifndef WEBSTER
01190 #ifndef STANDALONE
01191                 if(ThumbnailsLibType == SGLib_Font)
01192                 {
01193                     StringToBitmap::ContoneFontBitmap(Thumbnails[Slot].buffer);
01194                 }
01195 #endif
01196 #endif //WEBSTER
01197             }
01198             else
01199             {
01200                 ERROR3("SGThumbs::GetThumbnail - No filename given for the thumbnail");
01201                 return FALSE;
01202             }
01203         }
01204     }
01205 
01206     // Adds the monotonic time to the cached item
01207     Thumbnails[Slot].Usage = TempTime.Sample();
01208     *Result = Thumbnails[Slot].buffer;  
01209 #endif
01210 #endif
01211     return TRUE;
01212 }
01213 
01214 /***********************************************************************************************
01215 
01216 >   BOOL SGThumbs::SetSize(SGThumbSize Size)
01217 
01218     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01219     Created:    21/2/95
01220     Inputs:     Size - Size to set... If this is the current size we just return straight away
01221                                       If not, we delete the entire cache and set this to the current
01222     Purpose:    Set thumbnail size - all returned thumbnails will be this size after this call
01223                 Note that this will also trash the contents of the thumbnail cache
01224     Notes:
01225 
01226 ***********************************************************************************************/
01227 
01228 BOOL SGThumbs::SetSize(SGThumbSize Size)
01229 {
01230     if(ThumbnailsSize == Size) return TRUE;
01231     ThumbnailsSize = Size;
01232     return(DeleteThumbnails());
01233 }
01234 
01235 /***********************************************************************************************
01236 
01237 >   BOOL SGThumbs::GetSize(SGThumbSize *Size)
01238 
01239     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01240     Created:    21/2/95
01241     Inputs:     Size - Pointer to a SGThumbSize for returning the current size
01242     Purpose:    Get current thumbnail size setting
01243     Notes:
01244 
01245 ***********************************************************************************************/
01246 
01247 BOOL SGThumbs::GetSize(SGThumbSize *Size)
01248 {
01249     if(Size == NULL)
01250     {
01251         ERROR3("SGThumbs::GetSize passed a null size");
01252         return FALSE;
01253     }
01254 
01255     *Size = ThumbnailsSize;
01256     return TRUE;
01257 }
01258 
01259 /***********************************************************************************************
01260 
01261 >   void SGThumbs::DumpCache(char *DumpFile)
01262 
01263     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01264     Created:    21/2/95
01265     Inputs:     DumpFile - Filename to use for a dumpfile
01266     Purpose:    Debugging stuff
01267     Notes:
01268 
01269 ***********************************************************************************************/
01270                
01271 void SGThumbs::DumpCache(char *DumpFile)
01272 {
01273 #if 0
01274     UINT32 i;
01275     if(!ThumbnailsInitialised)
01276     {
01277         _tprintf("Thumbnails not initialised\n");
01278         return;
01279     }
01280          
01281     FILE *fp;
01282     fp = _tfopen(DumpFile, "w");
01283 
01284     if(!fp)
01285     {
01286         _tprintf("Error opening %s\n", DumpFile);
01287         return;
01288     }
01289           
01290     _tprintf("Dumping's going OK\n");
01291 
01292     
01293     _ftprintf(fp, "Directory %s\n", Directory->GetPath());
01294     _ftprintf(fp, "Initialised %d\n", ThumbnailsInitialised);
01295     _ftprintf(fp, "Size %d\n", ThumbnailsSize);
01296     _ftprintf(fp, "LibType %d\n\n", ThumbnailsLibType);
01297 
01298     for(i=0; i<Entries; i++)
01299     {
01300         _ftprintf(fp, "Entry %d - Valid %d, ID %d, Usage %d, Size %d, buffer %d\n", i, Thumbnails[i].Valid, Thumbnails[i].ID, Thumbnails[i].Usage, Thumbnails[i].Size, (INT32)Thumbnails[i].buffer);
01301     }
01302 
01303     fclose(fp);
01304 #endif
01305 }
01306 
01307 /***********************************************************************************************
01308 
01309 >   static BOOL SGThumbs::ResizeAllThumbCaches(INT32 Entries)
01310 
01311     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
01312     Created:    21/2/95
01313     Inputs:     Size - Pointer to a SGThumbSize for returning the current size
01314     Returns:    FALSE if there was a problem
01315     Purpose:    To change the number of entries in all the thumbnail caches
01316     Notes:
01317 
01318 ***********************************************************************************************/
01319 
01320 BOOL SGThumbs::ResizeAllThumbCaches(INT32 Entries)
01321 {
01322     //TRACE( _T("Dynamic changing of thumbnail cache entries not yet implemented"));
01323     BROADCAST_TO_CLASS(ThumbMessage(ThumbMessage::CACHESIZECHANGED, Entries), DialogOp);
01324     return TRUE;
01325 }

Generated on Sat Nov 10 03:48:57 2007 for Camelot by  doxygen 1.4.4