main.cpp

Go to the documentation of this file.
00001 // $Id: main.cpp 1464 2006-07-18 12:32:26Z gerry $
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 // contains the general initialisation and deinitialisation of the kernel
00100 
00101 /*
00102 */
00103 
00104 #include "camtypes.h"
00105 
00106 //#include "clipext.h"
00107 #include "clipint.h"
00108 //#include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00109 //#include "tool.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00110 #include "module.h"
00111 #include "bfxbase.h"
00112 #include "printing.h"
00113 #include "csrstack.h"
00114 //#include "ctrlhelp.h"
00115 //#include "fonts.h"
00116 #include "hotkeys.h"
00117 #include "fntcache.h"
00118 #include "sginit.h"
00119 #include "sgliboil.h"
00120 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00121 #include "oilmenus.h"
00122 #include "oilruler.h"
00123 #include "layer.h"
00124 //#include "atminst.h"
00125 #include "progress.h"
00126 //#include "registry.h"
00127 #include "scunit.h"
00128 //#include "prnmks.h"
00129 #include "valfunc.h"
00130 //#include "grndbmp.h"
00131 #include "strkcomp.h"
00132 #include "brshcomp.h"
00133 //#include "dlgcthlp.h"
00134 //#include "xpehost.h"
00135 #include "opfeathr.h"
00136 #include "appprefs.h"
00137 
00138 BOOL InitPreTools();
00139 BOOL InitPostTools1();
00140 BOOL InitPostTools2();
00141 
00142 // Declare smart memory handling in Debug builds
00143 #define new CAM_DEBUG_NEW
00144 
00145 DECLARE_SOURCE("$Revision: 1464 $");
00146 
00147 
00148 /*******************************************************************
00149 
00150 >   BOOL InitKernel()
00151 
00152     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00153     Created:    23/4/93
00154     Inputs:     None
00155     Outputs:    None
00156     Returns:    TRUE if worked OK, FALSE if failed (program will not start)
00157     Purpose:    Calls all Initxxx functions for everyone else
00158     Errors:     None
00159 
00160 *******************************************************************/
00161 
00162 BOOL InitKernel()
00163 {
00164     bool    fSuccess = true;
00165     if( !InitPreTools() ||
00166         !Tool::InitTools() ||               // Init Modules and tools (keep last) 
00167         !InitPostTools1() ||
00168         !InitPostTools2()
00169         )
00170     {
00171         if( 0 == Error::GetErrorNumber() )
00172             Error::SetError( _R(IDS_INITIALISATION_ERROR) );
00173 
00174         InformError();
00175         TRACE( _T("InitKernel failed - will exit very soon\n"));
00176         fSuccess = false;
00177     }
00178 
00179     return fSuccess;
00180 }
00181 
00182 /*******************************************************************
00183 
00184 >   BOOL InitKernelPostSplash()
00185 
00186     Author:     Gerry_Iles (Xara Group Ltd) <camelotdev@xara.com>
00187     Created:    25/07/2005
00188     Inputs:     None
00189     Outputs:    None
00190     Returns:    TRUE if worked OK, FALSE if failed (program will not start)
00191     Purpose:    Initialises various things that should be done after the 
00192                 splash screen has been shown
00193     Errors:     None
00194 
00195 *******************************************************************/
00196 
00197 BOOL InitKernelPostSplash()
00198 {
00199     if (
00200 #if !defined(PROD_XS) && !defined(EXCLUDE_FROM_XARALX)
00201         // disabled for XS builds
00202         PluginOILFilter::AutoRegisterFilters() &&
00203 #endif
00204 
00205         Filter::InitFilters()
00206         )
00207         return TRUE;
00208     else
00209     {
00210         InformError();
00211         TRACE( _T("InitKernelPostSplash failed - will exit very soon\n"));
00212         return FALSE;
00213     }
00214 }
00215 
00216 
00217 
00218 /*******************************************************************
00219 
00220 >   BOOL DeinitKernel()
00221 
00222     Author:     Andy_Pennell (Xara Group Ltd) <camelotdev@xara.com>
00223     Created:    23/4/93
00224     Inputs:     None
00225     Outputs:    None
00226     Returns:    None
00227     Purpose:    Calls all Deinitxxx functions for everyone else
00228     Errors:     None
00229 
00230 *******************************************************************/
00231 
00232 void DeinitKernel()
00233 {
00234     // Needs to happen before any major systems disappear (namely the message handler system)
00235     Layer::Deinit();
00236 
00237 // Neville 5/8/97 remove Stroking code
00238 #ifdef VECTOR_STROKING
00239     // Deinit ValueFunction classes
00240     ValueFunction::DeInit();
00241 #endif
00242 
00243 PORTNOTE("extClipboard", "Do no call ExternalClipboard::Deinit")
00244 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00245     ExternalClipboard::Deinit();                    // Destroy clipboard manager
00246 //  InternalClipboard::Deinit();                    // Destroy internal clipboard cache
00247 #else
00248     InternalClipboard::Deinit();                    // Destroy internal clipboard cache
00249 #endif
00250 
00251     // Remove all the OpDescriptors from their internal static list
00252     OpDescriptor::DestroyAll();
00253     MessageHandler::Destroy(); // Remove MessageHandler class lists
00254 
00255     AttributeManager::Deinit();
00256 
00257 #if !defined(EXCLUDE_FROM_RALPH)
00258     #ifndef STANDALONE
00259         // Write out the preferences, only if the user has requested this
00260         if ( AppPrefsDlg::IsSaveOnExitSet() )
00261             Camelot.WritePreferences();
00262     #else
00263         Camelot.WritePreferences();
00264     #endif
00265 #else
00266     Camelot.WritePreferences();
00267 #endif
00268 
00269 PORTNOTE("other","Removed XPEHost usage")
00270 #ifndef EXCLUDE_FROM_XARALX
00271     XPEEditOp::DeInit();
00272     XPEHost::EndXPE3Connection();
00273 #endif
00274 
00275     // Always de-init the tools before the modules!
00276     Tool::DeinitTools();        // NB. tool function is also called prior to this
00277     Module::DeinitModules();    // by CMainFrame::OnDestroy() !!
00278 
00279 #ifndef EXCLUDE_BFX
00280 #if !defined(EXCLUDE_FROM_RALPH)
00281     BitmapEffectBase::DeInit();
00282 #endif
00283 #endif
00284 //WEBSTER-ranbirr-12/11/96
00285 #ifndef WEBSTER
00286 #ifndef STANDALONE
00287     // no printing on Viewer version 
00288     // defined as a blank nothing function
00289     OpPrint::Deinitialise();
00290 #endif
00291 #endif  // WEBSTER
00292 
00293 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00294 #ifndef STANDALONE
00295     // Make sure we throw away all marks before the memory manager is deinitialised
00296     if (Camelot.GetMarksManager())
00297         Camelot.GetMarksManager()->InvalidateCache();
00298 #endif
00299 #endif
00300 
00301 // Neville 5/8/97 remove Stroking code
00302 #ifdef VECTOR_STROKING
00303     // Make sure any Stroke provider stuff is deinitialised
00304     StrokeComponentClass::DeInit();
00305 #endif
00306     // get rid of any stored brushes
00307     BrushComponentClass::DeInit();
00308 
00309     OpChangeFeatherSize::DeInit();
00310     
00311     DeinitMemory();                     // Must be before deinithandles, as it it uses handles
00312     DeinitHandles();
00313 //  DeinitHotKeySystem();
00314 
00315     CursorStack::DeInit();
00316 
00317 #if !defined(EXCLUDE_FROM_RALPH)
00318     Progress::Deinit();
00319     StandardUnit::DeInit();
00320 #endif
00321 
00322 #ifndef STANDALONE
00323     AppPrefsDlg::Deinit();              // Deinit the application preference/options dialog
00324 #endif
00325     Filter::DeinitFilters();
00326 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00327     ControlHelper::DeInit();
00328     DialogControlHelper::DeInit();
00329 #endif
00330 PORTNOTE("other","Removed FontFactory usage")
00331 #ifndef EXCLUDE_FROM_XARALX
00332     FontFactory::Deinit();
00333 #endif
00334 PORTNOTE("other","Removed ATMInstall usage")
00335 #ifndef EXCLUDE_FROM_XARALX
00336     ATMInstall::AliasList.DeInit();
00337     DeinitButtonBar();
00338 #endif
00339 #if !defined(EXCLUDE_FROM_RALPH)
00340 // && !defined(EXCLUDE_FROM_XARALX)
00341     DeinitMenuSystem();
00342 #endif
00343     DimScale::Deinit();
00344     Unit::Deinit();
00345     DocUnitList::Deinit();
00346     GlobalBitmapList::DeInit();
00347     GlobalFractalList::DeInit();
00348     OILBitmap::Deinit();
00349 #if !defined(EXCLUDE_FROM_RALPH)
00350 // && !defined(EXCLUDE_FROM_XARALX)
00351     HotKey::Deinit(); 
00352 #endif
00353 #ifndef DISABLE_TEXT_RENDERING
00354     FontCache::DeInit();
00355 #endif
00356 #ifndef EXCLUDE_GALS
00357     SGInit::DeInit();       // De-init the galleries
00358 #endif
00359     View::Deinit();
00360 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00361     SGLibOil::TidyUp();
00362 //  DeInitRegistry();
00363 #endif
00364 // WEBSTER - markn 15/1/97
00365 // No rulers in Webster
00366 #ifndef WEBSTER
00367     OILRuler::Deinit();
00368 #endif
00369 
00370     // Deinit static rendering stuff
00371 PORTNOTE("other","Removed GRenderBitmap usage")
00372 #ifndef EXCLUDE_FROM_XARALX
00373     GRenderBitmap::Deinit();
00374 #endif
00375 
00376     // Close down the kernel application object (including preferences system)
00377     Camelot.Deinit();
00378 
00379 #if !defined(EXCLUDE_FROM_RALPH) && !defined(EXCLUDE_FROM_XARALX)
00380     // do this last now as we use the key to save out some preference data
00381     DeInitRegistry();
00382 #endif
00383 }

Generated on Sat Nov 10 03:45:39 2007 for Camelot by  doxygen 1.4.4