Bugfix : Zooming works correct, no more errors on screen.
[xara-cairo.git] / wxOil / sgindgen.h
blobb09ffd4c8fe4c4900461f2c0df90a1a2eff4688f
1 // $Id: sgindgen.h 1282 2006-06-09 09:46:49Z alex $
2 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
3 ================================XARAHEADERSTART===========================
5 Xara LX, a vector drawing and manipulation program.
6 Copyright (C) 1993-2006 Xara Group Ltd.
7 Copyright on certain contributions may be held in joint with their
8 respective authors. See AUTHORS file for details.
10 LICENSE TO USE AND MODIFY SOFTWARE
11 ----------------------------------
13 This file is part of Xara LX.
15 Xara LX is free software; you can redistribute it and/or modify it
16 under the terms of the GNU General Public License version 2 as published
17 by the Free Software Foundation.
19 Xara LX and its component source files are distributed in the hope
20 that it will be useful, but WITHOUT ANY WARRANTY; without even the
21 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
22 See the GNU General Public License for more details.
24 You should have received a copy of the GNU General Public License along
25 with Xara LX (see the file GPL in the root directory of the
26 distribution); if not, write to the Free Software Foundation, Inc., 51
27 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
30 ADDITIONAL RIGHTS
31 -----------------
33 Conditional upon your continuing compliance with the GNU General Public
34 License described above, Xara Group Ltd grants to you certain additional
35 rights.
37 The additional rights are to use, modify, and distribute the software
38 together with the wxWidgets library, the wxXtra library, and the "CDraw"
39 library and any other such library that any version of Xara LX relased
40 by Xara Group Ltd requires in order to compile and execute, including
41 the static linking of that library to XaraLX. In the case of the
42 "CDraw" library, you may satisfy obligation under the GNU General Public
43 License to provide source code by providing a binary copy of the library
44 concerned and a copy of the license accompanying it.
46 Nothing in this section restricts any of the rights you have under
47 the GNU General Public License.
50 SCOPE OF LICENSE
51 ----------------
53 This license applies to this program (XaraLX) and its constituent source
54 files only, and does not necessarily apply to other Xara products which may
55 in part share the same code base, and are subject to their own licensing
56 terms.
58 This license does not apply to files in the wxXtra directory, which
59 are built into a separate library, and are subject to the wxWindows
60 license contained within that directory in the file "WXXTRA-LICENSE".
62 This license does not apply to the binary libraries (if any) within
63 the "libs" directory, which are subject to a separate license contained
64 within that directory in the file "LIBS-LICENSE".
67 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
68 ----------------------------------------------
70 Subject to the terms of the GNU Public License (see above), you are
71 free to do whatever you like with your modifications. However, you may
72 (at your option) wish contribute them to Xara's source tree. You can
73 find details of how to do this at:
74 http://www.xaraxtreme.org/developers/
76 Prior to contributing your modifications, you will need to complete our
77 contributor agreement. This can be found at:
78 http://www.xaraxtreme.org/developers/contribute/
80 Please note that Xara will not accept modifications which modify any of
81 the text between the start and end of this header (marked
82 XARAHEADERSTART and XARAHEADEREND).
85 MARKS
86 -----
88 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
89 designs are registered or unregistered trademarks, design-marks, and/or
90 service marks of Xara Group Ltd. All rights in these marks are reserved.
93 Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
94 http://www.xara.com/
96 =================================XARAHEADEREND============================
98 // SGindgen.h - Index generation code
100 #ifndef INC_SGINDGEN
101 #define INC_SGINDGEN
103 //#include "pathname.h" - in camtypes.h [AUTOMATICALLY REMOVED]
104 //#include "thumb.h" - in camtypes.h [AUTOMATICALLY REMOVED]
105 //#include "ccfile.h" - in camtypes.h [AUTOMATICALLY REMOVED]
107 /********************************************************************************************
109 > class IndGenFileBuffer : public CCObject
111 Author: Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
112 Created: 15/05/95
113 Purpose: Since MSDOS seems happy returning filenames of files in a directory in a
114 completely random fashion, we need to have some way of storing all the ones
115 it returns us and sorting them alphabetically, so we can generate index files
116 in a nice alphabetical order.
118 The data structure used below is basically an array of TCHAR *'s pointed to
119 by Buffer. These TCHAR *'s are CCMalloced and given variable length C style
120 strings by AddItem. The destructor handles the memory tidying up.
122 ********************************************************************************************/
124 class IndGenFileBuffer : public CCObject
126 CC_DECLARE_DYNCREATE( IndGenFileBuffer )
128 public:
129 IndGenFileBuffer();
130 ~IndGenFileBuffer();
131 BOOL Init(INT32 Count);
132 BOOL AddItem(TCHAR *String);
133 BOOL Sort(void);
134 TCHAR *GetItem(INT32 Count);
135 INT32 ItemCount(void) {return Items;}
137 protected:
138 static INT32 __cdecl SortComparator(const void *Item1, const void *Item2);
140 protected:
141 TCHAR **Buffer;
142 INT32 Items;
143 INT32 Position;
147 /********************************************************************************************
149 > class GenerateIndexFile : public CCObject
151 Author: Richard_Millican (Xara Group Ltd) <camelotdev@xara.com>
152 Created: 09/04/95
153 Purpose: For generating of index files
155 ********************************************************************************************/
157 class GenerateIndexFile : public CCObject
159 CC_DECLARE_DYNCREATE( GenerateIndexFile )
161 public:
163 // Constructor
164 GenerateIndexFile();
166 // Destructor
167 ~GenerateIndexFile() {}
169 // Actually generate the index
170 BOOL Generate(PathName *IndexFile, PathName *LibDirPath, String_64 *Author,
171 SGLibType Type, BOOL Thumbnails);
173 protected:
175 // Close the search handle
176 BOOL CloseSearchHandle(void);
178 // Close the file handle
179 BOOL CloseIndexFileHandle(void);
181 // Create the index file and keywords file then add headers to them
182 BOOL CreateIndexFile(void);
184 // Count the number of files that will be added to the index file in the directory
185 INT32 CountValidFiles(void);
187 // If the normal place for the index is read only, sir might consider a more remote location, oui ?
188 BOOL RemoteIndexSetup(PathName *FilesPath);
190 // Check if the given index has a remote pointer, and return the location if it has
191 BOOL CheckExistingIndexForRemoteness(PathName *IndexFile, PathName *FilesPath);
193 public:
195 // Returns true if the directory is read only
196 static BOOL IsDirectoryReadOnly(PathName *Directory);
198 // Check to see if we've already got a remote directory for a FilesDirectory, or at
199 // least return the location for the remote directory
200 static BOOL CheckForRemote(PathName *FilesDirectory, String_256 *RemoteDirectory);
202 // Given a random collection of garbage as an input string, return a valid directory path on output
203 static BOOL GiveMeAValidDirectoryName(String_256 *Input, String_256 *Output);
205 protected:
207 // Add all the header data to an index file
208 BOOL DoIndexHeader(void);
210 // Scan the directory for files and add them to the index file
211 BOOL AddToSubLibrary(void);
213 // Poke the count field with the correct value
214 BOOL FixSubLibraryNumber(void);
216 protected:
218 // Add a file to the index
219 BOOL AddFile(PathName *FileName);
221 // Return true if a file should be associated with the index
222 static BOOL IsFileType(PathName *FileName, const SGLibType Type);
224 protected:
225 // Get a 16bit value from the file
226 INT16 GetShort(FILE *fp);
228 // Return the integer part of a 16.16 fixed only
229 INT16 GetFixed(FILE *fp);
231 // Return a full 32 bit number from a file
232 INT32 GetLONG(FILE *fp);
234 // Rip out the full TTF typeface name from a font file
235 BOOL RipTrueTypeNameFromFile(PathName *FileName, String_256 *Name);
237 // Rip out the full ATM typeface and styles from a font file
238 BOOL RipATMNameFromFile(PathName *FileName, String_256 *RetName, BOOL *Bold, BOOL *Italic);
240 protected:
241 // This will check that creating the thumbnail won't cause us to go BANG !
242 static BOOL PreCreateThumbnail(PathName *InFile);
244 // Given an input filename and output filename, generate a thumbnail of specified dimensions
245 BOOL CreateThumbnail(PathName *InFile, PathName *OutFile, UINT16 XSize, UINT16 YSize);
247 /* Create the thumbnails for the specified file */
248 BOOL CreateThumbnails(PathName *FileName, BOOL NewSystem = TRUE);
250 protected:
252 // Scan the given file and try and work out a description and keywords for it
253 BOOL RipDescriptionFromFile(PathName *FileName,
254 String_256 *Text, String_256 *Keywords = NULL, String_256 *Title = NULL);
256 // Try and work out a description and keywords given an EPS/ART filename (uses comments in file)
257 BOOL RipDescriptionFromEPSFile(PathName *FileName,
258 String_256 *Text, String_256 *Keywords = NULL, String_256 *Title = NULL);
260 // Try and work out a description and keywords given a CDR filename
261 BOOL RipDescriptionFromCDRFile(PathName *FileName,
262 String_256 *Text, String_256 *Keywords = NULL, String_256 *Title = NULL);
264 // Try and work out a description and keywords given a version 2 native/web filename
265 BOOL RipDescriptionFromNativeV2File(PathName *FileName,
266 String_256 *Text, String_256 *Keywords = NULL, String_256 *Title = NULL,
267 BOOL *FileIsNewNative = NULL);
270 // Scan an old index file looking for the description of the given filename
271 BOOL RipDescriptionFromIndex(PathName *IndexFile, PathName *FileName,
272 FilePos Start, INT32 DescriptionField, INT32 KeywordField, INT32 TitleField,
273 String_256 *Text, String_256 *Keywords = NULL, String_256 *Title = NULL);
275 BOOL PrePassIndex(PathName *IndexFile, FilePos *Start,
276 INT32 *DescriptionField, INT32 *KeywordField, INT32 *TitleField, String_256 *Description);
278 public:
279 // General utilities for the ripping functions
280 static BOOL ReplaceCharacters(StringBase *Source, TCHAR Search, TCHAR Replace);
281 static INT32 CountCommas(StringBase *Source, StringBase &SearchFor);
282 static BOOL GetToken(StringBase *Source, INT32 Count, String_256 *Result);
284 protected:
285 // Adds the given text to the index file
286 BOOL AddLineToIndex(String_256 *Text);
288 protected:
289 PathName Index;
290 PathName LibPath;
291 SGLibType LibType;
292 BOOL DoThumbnails;
293 String_64 Author;
295 // Disk file for index file
296 CCDiskFile *IndexFile;
298 // Offset into index for the 'Number of files' data
299 FilePos IndexCountOff;
301 // Search handle for directory scan
302 HANDLE hSearch;
304 // ID of current item and number of items in file
305 UINT32 ID;
307 // Pre-counted number of files to add to index
308 INT32 TotalFiles;
310 // Location of old index file (if there was one)
311 PathName *TmpIndexFile;
313 // Sorted buffer containing all the filenames in the directory
314 // ( Initialised by CountValidFiles() )
315 IndGenFileBuffer FileNameBuffer;
317 // Vars to speed up ripping old data from existing indexes
318 FilePos OldIndexStart;
319 INT32 OldIndexDescriptionField;
320 INT32 OldIndexKeywordField;
321 INT32 OldIndexTitleField;
322 BOOL OldIndexOK;
323 String_256 OldIndexDescription;
325 // Remote indexes
326 BOOL IndexIsRemote;
327 String_256 RemoteLocationOfIndex;
328 String_256 RemoteLocationOfFiles;
331 // Automatic index update functions
332 public:
333 static UINT32 GetDirectoryChecksum(String_256 *Directory, SGLibType Type = SGLib_Blank);
334 static BOOL UseAutomaticUpdate;
336 public:
337 // Preference setting saying whether thumbnail generation is required
338 static BOOL CreateFontIndexes;
340 // Preferences to use old index files / rip doc comments out
341 static BOOL UseOldIndexes;
342 static BOOL UseDocComments;
346 #endif