sgscan.h

Go to the documentation of this file.
00001 // $Id: sgscan.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 // Super Gallery Library scanning stuff
00099 
00100 #ifndef INC_SGSCAN
00101 #define INC_SGSCAN
00102 
00103 #include "ccfile.h"
00104 #include "thumb.h"
00105 
00106 class PathName;
00107 class KernelBitmap;
00108 class SuperGallery;
00109 class SGLibGroup;
00110 class LibraryGallery;
00111 class Progress;
00112 
00113 // A library index is a unique identifier for a given entry in a library. The library
00114 // generates it, and it is used as a handle to that entry by outside clients. The index
00115 // is NOT guaranteed to be a sequential number (in fact at present it is a file seek pos!)
00116 typedef INT32 LibraryIndex;
00117 
00118 struct SGFieldCache
00119 {
00120     LibraryIndex Offset;
00121     UINT32 Count;
00122     TCHAR *Field;
00123 };
00124 
00125 
00126 /***********************************************************************************************
00127 
00128 >   class Library : public ListItem
00129 
00130     Author:     Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
00131     Created:    18/2/95
00132     Purpose:    This is the main super gallery library group creation class...
00133                 Creating one of these will create a single group in your gallery. It will
00134                 contain items for each entry in the sub-lib.
00135     SeeAlso:    LibraryFile;
00136 
00137 ***********************************************************************************************/
00138 
00139 class Library : public ListItem
00140 {
00141     friend class LibClipartSGallery;
00142     friend class LibraryGallery;
00143 
00144     CC_DECLARE_DYNCREATE(Library)
00145 
00146 public:     // Construction/destruction
00147     Library();
00148     ~Library();
00149 
00150 
00151 public:     // Public interface
00152     // Given a path, scan the {sub}library, and create a supergallery display group
00153     // with a DisplayItem for each item in the library. Returns number of items found
00154     INT32 Init(SuperGallery *ParentGal, PathName *Path, String_64 *Title,
00155                 StringBase *IndexFile, SGLibType Type, BOOL Updated = FALSE,
00156                 BOOL AllowedToCreateVirtualised = FALSE);
00157 
00158     // This initialised all the library preference values - and should be called after the above
00159     static BOOL InitLibPrefs(void);
00160 
00161     // Called during preference wiping to allow us to squirrel away any settings that we desire
00162     // before they are wiped. Useful, if we want to retain newly installed preferences!
00163     static BOOL CacheLibPrefs(void);
00164     static BOOL RestoreLibPrefs(void);
00165 
00166     // Use for creating the items of a virtual library
00167     INT32 CreateItems(void);
00168 
00169 private:
00170     // Store for the cached settings
00171     static String_256 g_ClipartLibraryPath;
00172     static String_256 g_WebThemeLibraryPath;
00173     static String_256 g_FontLibraryPath;
00174     static String_256 g_FillsLibraryPath;
00175 
00176     // Setup various member variables - used by Init, and only Init
00177     BOOL SetUpMembers(SuperGallery *ParentGal, PathName *Path, String_64 *SLTitle,
00178             StringBase *SubI, SGLibType SLType);
00179 
00180     // Setup the QuickIndex member variables
00181     BOOL SetupQuickIndexMembers(PathName *Path, BOOL CheckTheyExist);
00182 
00183     // Read the no of items, field text and first line values
00184     INT32 ReadHeaderInfo(CCLexFile *pSubIndex);
00185 
00186     // Scan the rest of the file, creating items for each entry
00187     BOOL ScanRestOfFile(CCLexFile *pSubIndex);
00188 
00189 public:         // Public interface for getting at library information
00190     // Returns the title (as displayed in the gallery group) of this library
00191     void GetLibraryTitle(StringBase *ReturnedTitle);
00192 
00193     //>> webster (Adrian 2/01/97)
00194     // Returns the status of this library, can be one of the following values defined in inetop.h:
00195     // FOLDER_UNMODIFIED
00196     // FOLDER_UPDATED
00197     // FOLDER_NEW
00198     // (Meaningful only for web folders)
00199     inline UINT32 GetModified() { return m_nModified;}
00200 
00201     inline void SetModified(UINT32 nModified) { m_nModified = nModified;};
00202 
00203     // Return the type of this library
00204     inline SGLibType GetType() { return Type;}
00205     //<<webster
00206 
00207     // Return the Filename for line at offset
00208     BOOL GetFilename(LibraryIndex Offset, StringBase *File, BOOL FullPath = TRUE);
00209 
00210     // Return ptr to Filename (only works for memory cached indexes)
00211     BOOL GetFilename(LibraryIndex Offset, TCHAR **File);
00212     
00213     // Return the textual description for line at offset
00214     BOOL GetTextname(LibraryIndex Offset, StringBase *Text);
00215 
00216     // Return ptr to textual description (only works for memory cached indexes)
00217     BOOL GetTextname(LibraryIndex Offset, TCHAR **Text);
00218 
00219     // Return the ID for line at offset
00220     UINT32 GetID(LibraryIndex Offset);
00221 
00222     // Get the title from the index
00223     BOOL GetTitle(LibraryIndex Offset, StringBase *Title);
00224 
00225     // Get the title from the index (just ptr)
00226     BOOL GetTitle(LibraryIndex Offset, TCHAR **Title);
00227 
00228     // Return a pointer to the thumbnail for line at offset
00229     BOOL GetThumbnail(LibraryIndex Offset, SGThumbSize Size, BOOL Urgent,
00230                         KernelBitmap **Thumbnail);
00231 
00232     // Wipe clean the thumbnail cache and return all memory
00233     void KillAllThumbnails(void);
00234 
00235     // Return the default bitmap width (pixels)
00236     inline INT32 PreviewBMPWidth(SGThumbSize Size)
00237     {
00238         if((INT32)Size < 3) return PreviewX[(INT32)Size];
00239         else return 64;
00240     }
00241 
00242     // Return the default bitmap width (pixels)
00243     inline INT32 PreviewBMPHeight(SGThumbSize Size)
00244     {
00245         if((INT32)Size < 3) return PreviewY[(INT32)Size];
00246         else return 64;
00247     }
00248 
00249     // Return the full pathname of the index file
00250     inline PathName *ReturnIndexLocation(void) {return IndexFile;}
00251 
00252     // Return the full pathname of the sub index data directory
00253     inline PathName *ReturnSubLibraryLocation(void) {return SubLibPath;}
00254 
00255     // Return the full pathname of the index file
00256     inline PathName *ReturnSynonymFile(void) {return SynonymFile;}
00257 
00258     // Function to convert a PathName to an URL
00259     // The conversion is based on the base URL stored in URLBase
00260     BOOL LocalPath2URL(String_256* pLocalPath);
00261 
00262     // Return a single field from a line of text (start from field 1)
00263     // Use this for extracting the extended info fields...
00264     BOOL GetSingleField(LibraryIndex Offset, UINT32 Count, StringBase *Field);
00265 
00266     // Return a ptr to a single field from a line of text (start from field 1)
00267     BOOL GetSingleField(LibraryIndex Offset, UINT32 Count, TCHAR **Field);
00268 
00269     // Return a single field from a line of text
00270     // Field is referenced by field header text at start
00271     BOOL GetSingleField(LibraryIndex Offset, String_64 *FieldName, StringBase *Field);
00272 
00273     // Return a single field from a line of text
00274     // Field is referenced by field header text at start
00275     // Quicker, pointer version...
00276     BOOL GetSingleField(LibraryIndex Offset, String_64 *FieldName, TCHAR **Field);
00277 
00278     // Return field number for given field...
00279     INT32 FindField(String_64 *FieldName);
00280 
00281     // Check if a string is in the field description string...
00282     BOOL GotField(String_64 *FieldName);
00283 
00284     inline BOOL IsWebLibrary() {return m_bIsWebLib;} 
00285 
00286 
00287 public:
00288     // Save out an index file in the order the group is displayed
00289     // This is strictly a debug only function !
00290     BOOL SaveIndexInDisplayedOrder(PathName *IndexFile, BOOL NewIDs);
00291     // >>webster (adrian 17/12/96)
00292     static String_256 URLBase;
00293     
00294     BOOL m_bIsWebLib;
00295     // <<webster
00296 protected:      // Private data
00297 
00298     SGLibType Type;                         // Type of Sub-Library
00299 
00300     INT32 ItemCount;                            // Count of items in the sub-lib
00301 
00302     String_256 FieldString;                 // Field string found at the head of the sub-index
00303 
00304     
00305     LibraryIndex FirstLineOffset;           // For checking the Offsets...
00306     LibraryIndex LastLineOffset;
00307 
00308     INT32 PreviewX[3];                      // Widths of thumbnails
00309     INT32 PreviewY[3];                      // Heights of thumbnails
00310 
00311     UINT32 IndexDateStamp;                  // For recache checking
00312 
00313     //>> webster (Adrian 2/01/96)
00314     UINT32 m_nModified;
00315     INT32 m_lOldIndex;
00316     //<< webster
00317 
00318 public:
00319 
00320     // These need to be public for the GRM code...
00321     String_64 *Title;                       // Title text as given in main index file
00322 
00323     PathName *IndexFile;                    // Full Path of index file itself
00324     PathName *SubLibPath;                   // Full Path of the sub library
00325     PathName *SynonymFile;                  // Full Path of the synonym file
00326 
00327     // 'Remove' needs these public
00328     SuperGallery    *ParentGallery;         // Gallery we're attached to
00329     SGLibGroup      *ParentGroup;           // Group (within that gallery) we're displayed in
00330     
00331     // Resizing and deleting messages require access to this...
00332     SGThumbs *Thumbnails;                   // Thumbnail cache class
00333 
00334     // **** Speedup routines follow
00335 
00336 public:
00337 
00338     // Gallery open / close memory routines...
00339     BOOL FreeCachedIndexes();
00340     BOOL ReCacheIndexes();
00341 
00342 protected:  // Sub index file caching stuff
00343 
00344     // Cache for the subindex file
00345     BOOL CacheSubIndex(PathName *IndexFile);
00346 
00347     // After reading the header info out of the file, scan the rest (optionally) creating
00348     // items for each valid new line, and replacing all the commas with 0's...
00349     BOOL ScanRestOfFile(TCHAR *CachedIndex, INT32 Start, INT32 Finish, BOOL AddItems = TRUE);
00350 
00351     // Return a field from the cached version of the index file
00352     BOOL GetSingleFieldFromMemory(LibraryIndex Offset, UINT32 Count, StringBase *Field);
00353 
00354     // Return a pointer to a field from the cached version of the index file
00355     BOOL GetSingleFieldFromMemory(LibraryIndex Offset, UINT32 Count, TCHAR **Field);
00356 
00357     // Return a field using a diskfile for the index
00358     BOOL GetSingleFieldFromDisk(LibraryIndex Offset, UINT32 Count, StringBase *Field);
00359 
00360     // Buffer for the file itself
00361     TCHAR *CachedSubIndexBuf;
00362 
00363     // Size of Cached index file in buffer
00364     INT32 CachedBufLength;
00365 
00366 public:
00367     // If non-null, ProgressBar->Update() will be called during bits which could take time
00368     // such as de-virtualising a group
00369     static Progress *ProgressBar;
00370 
00371 protected:  // Field caching stuff
00372 
00373     BOOL CacheInit(INT32 Entries);
00374     BOOL CacheKill(void);
00375     INT32 CacheHashFunction(LibraryIndex Offset, UINT32 Count);
00376     BOOL CachePut(LibraryIndex Offset, UINT32 Count, StringBase *Field);
00377     BOOL CacheGet(LibraryIndex Offset, UINT32 Count, StringBase *Field);
00378 
00379     INT32   FieldCacheEntries;
00380     SGFieldCache *FieldCache;
00381 
00382 protected:  // Quick Index stuff
00383 
00384     BOOL QuickIndexEnabled;
00385     PathName *QuickIndexFile;
00386 
00387 public:
00388     // Maximum number of entries in the field cache
00389     static INT32 MaxFieldCacheEntries;
00390 
00391     // Should we background redraw the library galleries ?
00392     static BOOL BackgroundRedraw;
00393 
00394     // Should we cache sub index files ? Makes things go quite a bit quicker...
00395     static BOOL CacheIndexFile;
00396 
00397     // Enable 'remote' library indexes if target media is read-only...
00398     static BOOL RemoteIndexes;
00399 
00400     // Location for 'remote' library indexes (if empty, use temp)...
00401     static String_256 RemoteIndexLocation;
00402 
00403     // Quick index preference - use same indexes in ..\xarainfo, as opposed to \xarainfo
00404     static BOOL QuickIndex;
00405 };
00406 
00407 #endif

Generated on Sat Nov 10 03:46:58 2007 for Camelot by  doxygen 1.4.4