00001 // $Id: camdoc.h 1009 2006-05-11 15:52:04Z phil $ 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 /* 00100 camdoc.h : interface of the CCamDoc class 00101 */ 00102 00103 #ifndef INC_CAMDOC_H 00104 #define INC_CAMDOC_H 00105 00106 // Forward references. 00107 class Document; 00108 class DocRect; 00109 class PathName; 00110 class CCamApp; 00111 class CCLexFile; 00112 00113 /********************************************************************************** 00114 > class CCamDoc : public COleServerDoc (MFC 2.5) 00115 00116 Author: Luke_Hart (Xara Group Ltd) <camelotdev@xara.com> (originally from samples\docvwmdi) with mods. 00117 Created: 01/07/05 00118 00119 Purpose: This is the wxWidgets class for a document type object in the OIL (it was 00120 originally part of wxWidgets example app. docvwmdi). It is very simple - 00121 its main use is getting hold of the relevant Document object from the kernel 00122 layer. wxWidgets calls various member functions when processing commands 00123 from the File menu. This class calls down into the kernel to do 00124 the actual work. 00125 00126 SeeAlso: Document 00127 ***********************************************************************************/ 00128 00129 class CCamDoc : 00130 public wxDocument 00131 { 00132 public: 00133 CCamDoc( Document *pKernelDoc = NULL ); 00134 ~CCamDoc(); 00135 00136 // Returns a pointer to the kernel document associated with this. 00137 Document *GetKernelDoc() const; 00138 00139 // Serialization support 00140 virtual bool OnNewDocument(); 00141 virtual bool OnSaveDocument(const wxString& filename); 00142 virtual bool OnOpenDocument(const wxString& filename); 00143 00144 // override wxDocument::SaveAs 00145 virtual bool SaveAs(); 00146 00147 // Some CDocument emulation stuff 00148 void SetModifiedFlag( BOOL fMod = TRUE ) { Modify( FALSE != fMod ); } 00149 00150 // Framwwork titles, paths, & filenames. 00151 virtual void SetTitle(LPCTSTR lpszTitle); 00152 virtual void SetPathName(LPCTSTR lpszPathName, BOOL bAddToMRU = TRUE); 00153 void SetPathNameEmpty(); 00154 void SetDocName(LPCTSTR lpszTitle); 00155 00156 // Kernel titles, paths, and filenames. 00157 String_256 GetKernelTitle(); 00158 String_256 GetKernelPathName(UINT32 MaxSize = 0); 00159 String_256 GetKernelDocName(BOOL IncludeFileType = TRUE); 00160 String_256 GetKernelLocation(UINT32 MaxSize = 0); 00161 00162 // The original file that this Camelot doc was based on, if they still correspond. 00163 String_256 GetOriginalPath() const; 00164 void SetOriginalPath(const String_256& strPath); 00165 00166 // Sets or clears the document's flags. 00167 void SetModified(bool fState); 00168 void SetReadOnly(bool fState); 00169 void SetCopy(bool fState); 00170 00171 // Test the above flags (note that MFC defines the IsModified() function). 00172 bool IsReadOnly() const; 00173 bool IsACopy() const; 00174 bool IsUntouched() const; 00175 bool IsModifiable() const; 00176 00177 // Call this to set the document flags MFC uses to decide if a save is Save, Save As, 00178 // or Save Copy As. 00179 void SetSaveFlags(BOOL fSameAsLoad, BOOL fRememberName) 00180 { 00181 #if (_OLE_VER >= 0x200) 00182 m_bSameAsLoad = fSameAsLoad; m_bRemember = fRememberName; 00183 #endif 00184 } 00185 00186 // This returns the file-name of the template document for this kind of 00187 // document (normally 'template.xar', for embedded documents it's 'embedded.xar' 00188 //virtual void GetTemplateFilename(String_256* pstr) const; 00189 00190 //Graham 21/10/97: New template stuff 00191 public: 00192 PathName GetTemplate() const; 00193 void SetTemplate( const PathName &pathToSet = PathName() ); 00194 00195 static PathName GetNextTemplateToUse(); 00196 static void SetNextTemplateToUse(const PathName& pathToSet=PathName()); 00197 00198 protected: 00199 PathName m_pathTemplate; 00200 static PathName ms_pathNextTemplateToUse; 00201 00202 protected: 00203 // This creates a CCOleStream or a CCDiskFile for OnOpenDocument and 00204 // OnSaveDocument, according to their role (server doc or normal doc). 00205 virtual CCLexFile* CreateCCFile(LPCTSTR lpcszPath, INT32 nOpenMode); 00206 00207 // Useful helper functions. 00208 // Functions to help with the opening of documents 00209 virtual bool DefaultDocumentRequired(CCLexFile* pFile, UINT32 nPrefFilter); 00210 virtual bool LoadDefaultDocument(); 00211 virtual bool GeneralOpenDocument(CCLexFile* pFile, UINT32 nPrefFilter); 00212 virtual bool OnSaveModified(); 00213 virtual bool DoSave(LPCTSTR lpszPathName, BOOL bReplace = TRUE); 00214 virtual bool DeleteContents(); 00215 00216 BOOL RemoveExistingDocs(); 00217 00218 // These perform the actual loading and saving of the document, without 00219 // touching the doc's flags etc. 00220 virtual bool DoNewDocument(); 00221 virtual bool DoOpenDocument( const wxString &strFilename ); 00222 virtual bool DoSaveDocument( const wxString &strFilename ); 00223 00225 // Implementation. 00226 00227 public: 00228 00229 // Public so that Document can get at it (?) 00230 static BOOL s_RemoveExistingOnNewDoc; 00231 00232 // Don't want or need a stinking wxCommandProcessor, we do our own undo\redo handling 00233 virtual wxCommandProcessor *OnCreateCommandProcessor() { return NULL; } 00234 00235 static BOOL EnableRemoveUntouchedDocs(); 00236 // static BOOL RemoveUntouchedDocs(); 00237 // static BOOL IdleDocumentProcess(); 00238 // static BOOL MarkAllDocsUntouched(CWinApp* pApp); 00239 00240 private: 00241 // Helpers. 00242 void UpdateTitle(); 00243 // BOOL AnotherIsMaximised(); // TRUE is a view onto another doc is maximised. 00244 00245 // Data members. 00246 Document *m_pKernelDoc; // points to this object's alter-ego 00247 bool m_fIsReadOnly; // "is modified" flag and functions. 00248 bool m_fIsACopy; 00249 bool m_fIsUntouched; // ...by human hand. 00250 String_256 m_TitlePrefix; // essentially the document name 00251 String_256 m_strOriginalPath; // the file that this doc was loaded from if 00252 // it wasn't from a .ART file or the default document, 00253 // empty if this doc is new or no longer corresponds 00254 bool m_bIsModifiable; // Is this doc modifiable? 00255 LPTSTR m_lpszInitialZoomOp; // the initial zoom Op to perform, if any 00256 bool m_fDoneNewDoc; // bodge-flag to stop OLE calling OnNewDoc twice (??) 00257 00258 // static BOOL s_fRunIdleProcessing; // Do some Document work on next idle event 00259 static Document *s_pForceDocument; 00260 00261 public: 00262 // Originaly OLE related, hardcoded to true now 00263 bool IsVisible() const { return true; } 00264 00265 private: 00266 DECLARE_DYNAMIC_CLASS(CCamDoc) 00267 }; 00268 00269 #endif