CCamApp Class Reference

#include <camelot.h>

List of all members.

Public Member Functions

 CCamApp ()
bool OnInit ()
INT32 OnExit ()
void OnAppExit ()
wxMDIChildFrame * CreateChildFrame (wxDocument *doc, wxView *view)
wxDocManager * GetDocumentManager () const
bool OnRecentFile (INT32 RecentFileNumber)
 Loads in one of the recently opened documents that are in the 'Recent File List' near the bottom of the File Menu.
bool GetRecentFileText (INT32 Index, String_256 *pszText)
 Gets the text suitable for the menu text for a given recent file. If there is an available file the Text param will hold the abbreviated filename (eg. c:\....art). If the function returns FALSE, then the Text param is left alone.
void OnIdle (wxIdleEvent &event)
void OnTimer (wxTimerEvent &event)
bool HandleKeyPress (wxKeyEvent &event)
 Central handler for key and char events, using KeyPress class to route events to the areas of code that need to handle them.
void OnHelpIndex ()
void GiveActiveCanvasFocus ()
int FilterEvent (wxEvent &event)
 This function is used to collect the key press information for handling by applictaion. It passes event unmolested for controls that are allowed focus and controls within modal dialogs. It also has code to make sure that key events that are passed on aren't checked again, based on the event timestamp. All other keys are passed into application keypress handling code.
void OnFatalException ()
 This function is called whenever a fatal exception has occurred.
void OnFileOpen ()
 Displays the File Open dialog and opens whichever file was selected.
void OnFilePrintSetup ()
BOOL OnSecondInstance (wxChar **argv, INT32 argc=0)

Static Public Member Functions

static void DisableSystem (CWindowID WindowID=NULL)
 This function sets a flag which disables all rendering and processing of user messages in the system.
static void EnableSystem ()
 This function restores system functionality.
static bool IsDisabled ()
static void DoAboutBox ()
static DialogManagerGetDlgManager ()
 For obtaining a pointer to the dialog manager.
static BOOL LaunchWebBrowser (const wxString &strUrl)
 Launch a web browser referring to a given URL.
static bool LaunchMediaApp (const wxString &strUrl)
 This function attempts to replay a movie using configured player (or ask user to specify one if not already setup).
static bool SelectMediaApp ()
 This function allows a user to select which media replay app. they'd like to use to replay the help movies.
static StringBaseGetResourceDirectory ()
static void NeedMoreIdles ()

Public Attributes

BOOL allowRegistryWrite

Static Public Attributes

static BOOL MainWndMaximized = FALSE
 If non-zero then main window defaults to maximized, else normal position. This default will be overridden if the user explicitly asked for a mode when starting the app (e.g. minimized). If the user exits while maximized, the flag will be set ready for next time.
static BOOL MainWndMinimized = FALSE
 If non-zero then main window defaults to minimized, else normal position. This default will be overridden if the user explicitly asked for a mode when starting the app (e.g. minimized). If the user exits while minimized, the flag will be set ready for next time.
static String_256 MainWndPosString
 Remembers users last 'normal' window position for them. Also remembers the screen size so can be scaled if next time runs in different screen mode.
static BOOL bFirstRun = TRUE
 If 1 then this is the first time this application has been run with this set of preferences If 0 then it has been run before.

Protected Attributes

std::auto_ptr< wxDocManager > m_docManager
CCamFramem_pMainFrame
wxTimer m_Timer
wxSingleInstanceChecker * m_pSingleInstanceChecker
wxServerBase * m_pServer

Static Protected Attributes

static bool s_bIsDisabled
static wxString m_strResourcePath
static String_256 m_strResourceDirPath
static String_256 m_strResourceDirPathOverride
static String_256 m_strMediaApplication

Private Member Functions

INT32 RunFalseMainLoop ()
wxDocument * OpenDocumentFile (PCTSTR lpcszFileName)
 We override this implementation function so that when the user tries to load a document that is already loaded, we can display a dialog box with various load options, instead of simply bringing the document's view to the front.
void AddToRecentFileList (LPCTSTR pPathName)
 Adds the file to the recent file list.
BOOL MakeDocumentNative (wxDocument *pDoc, PathName *Path)
 If you attemp to open a BMP or any other non native file, it will have a bad document name (ending in .bmp or whatever, instead of .art). It also causes problems when pressing save, as the original non native file can be overwritten with a native file version. This makes sure that the user will always be asked where they want to save it when it comes to saving time by throwing away the know path info.

Static Private Member Functions

static BOOL LaunchBrowserApp (const wxString &strAppName, wxString strCommand)

Static Private Attributes

static DialogManager m_DlgMgr
static BOOL InInitOrDeInit


Detailed Description

Definition at line 107 of file camelot.h.


Constructor & Destructor Documentation

CCamApp::CCamApp  ) 
 


Member Function Documentation

void CCamApp::AddToRecentFileList LPCTSTR  pPathName  )  [private]
 

Adds the file to the recent file list.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
8/5/95
Parameters:
pPathName - the full path name of the file to add to the list [INPUTS]

Definition at line 1439 of file camelot.cpp.

01440 {
01441     // Make sure we have not been passed a load of junk
01442     ERROR3IF(pPathName==NULL, "NULL path name in AddToRecentFilelist\n");
01443 
01444     wxFileHistory*      pFileHist = m_docManager->GetFileHistory();
01445     pFileHist->AddFileToHistory( pPathName );
01446 }

wxMDIChildFrame * CCamApp::CreateChildFrame wxDocument *  doc,
wxView *  view
 

/ /* Centralised code for creating a document frame. Called from view.cpp, when a view is created.

Definition at line 1839 of file camelot.cpp.

01840 {
01842     CCamDocMDIChildFrame *subframe = 
01843         new CCamDocMDIChildFrame(doc, view, GetMainFrame(), wxID_ANY, _T("Child Frame"), 
01844             wxPoint(10, 10), wxSize(600, 450),
01845             wxDEFAULT_FRAME_STYLE |
01846             wxNO_FULL_REPAINT_ON_RESIZE);
01847 
01848 #ifdef __WXMSW__
01849     subframe->SetIcon(wxString(_T("chart")));
01850 #endif
01851 #ifdef __X__
01852     subframe->SetIcon(wxIcon(_T("doc.xbm")));
01853 #endif
01854 
01855 #if !defined(XARA_MENUGEN)
01856 
01857     wxMenu*    file_menu = new wxMenu;
01858     wxMenu*    edit_menu = new wxMenu;
01859     wxMenu*    zoom_menu = new wxMenu;
01860     wxMenu* quality_menu = new wxMenu;
01861     wxMenu*   other_menu = new wxMenu;
01862     wxMenu*    help_menu = new wxMenu;
01863 
01864     file_menu->Append( wxID_NEW,                        wxT("&New..."           ) );
01865     file_menu->Append( wxID_OPEN,                       wxT("&Open..."          ) );
01866     file_menu->Append( wxID_CLOSE,                      wxT("&Close"            ) );
01867     file_menu->Append( wxID_SAVE,                       wxT("&Save"             ) );
01868     file_menu->Append( wxID_SAVEAS,                     wxT("Save &As..."       ) );
01869 
01870 #if defined(FILELIST)
01871     wxMenu* pRecentFilesMenu = new wxMenu;
01872     m_docManager->FileHistoryUseMenu(pRecentFilesMenu);
01873     m_docManager->FileHistoryAddFilesToMenu(pRecentFilesMenu);
01874 
01875     file_menu->AppendSeparator();
01876     file_menu->Append( -1,                              wxT("&Recent files"),   pRecentFilesMenu );
01877 #endif
01878 
01879     file_menu->AppendSeparator();
01880     file_menu->Append( wxID_PRINT,                      wxT("&Print..."         "\tCtrl+P") );
01881     file_menu->Append( wxID_PRINT_SETUP,                wxT("Print &Setup..."   ) );
01882     file_menu->Append( wxID_PREVIEW,                    wxT("Print Pre&view"    ) );
01883     file_menu->AppendSeparator();
01884     file_menu->Append( wxID_EXIT,                       wxT("E&xit"             ) );
01885 
01886     edit_menu->Append( wxID_UNDO,                       wxT("&Undo"             ) );
01887     edit_menu->Append( wxID_REDO,                       wxT("&Redo"             ) );
01888 //  edit_menu->AppendSeparator();
01889 //  edit_menu->Append( DOCVIEW_CUT, _T("&Cut last segment") );
01890     if( NULL != doc->GetCommandProcessor() )
01891         doc->GetCommandProcessor()->SetEditMenu( edit_menu );
01892 
01893     zoom_menu->Append( _R(DOCVIEW_ZOOMIN),              wxT("Zoom &in"          ) );
01894     zoom_menu->Append( _R(DOCVIEW_ZOOMOUT),             wxT("Zoom &out"         ) );
01895     zoom_menu->Append( _R(DOCVIEW_ZOOMDRAWING),         wxT("Zoom to &drawing"  ) );
01896     zoom_menu->Append( _R(DOCVIEW_ZOOMSPREAD),          wxT("Zoom to &page"     ) );
01897     zoom_menu->Append( _R(DOCVIEW_ZOOMPREVIOUS),        wxT("Previous &zoom"    ) );
01898 
01899     quality_menu->Append( _R(DOCVIEW_QUALITYANTIALIASED),   wxT("&Antialiased"  ),  wxT(""),wxITEM_RADIO );
01900     quality_menu->Append( _R(DOCVIEW_QUALITYNORMAL),        wxT("&Normal"       ),  wxT(""),wxITEM_RADIO );
01901     quality_menu->Append( _R(DOCVIEW_QUALITYSIMPLE),        wxT("&Simple"       ),  wxT(""),wxITEM_RADIO );
01902     quality_menu->Append( _R(DOCVIEW_QUALITYOUTLINE),       wxT("&Outline"      ),  wxT(""),wxITEM_RADIO );
01903 
01904     other_menu->Append( _R(DOCVIEW_BACKGROUNDRENDER),       wxT("&Background render"),  wxT(""),wxITEM_CHECK );
01905     other_menu->Append( _R(DOCVIEW_CACHING),                wxT("&Caching"),                wxT(""),wxITEM_CHECK );
01906 #ifdef __WXGTK__
01907     other_menu->Append( _R(DOCVIEW_DOUBLEBUFFER),           wxT("&Double buffer\tHmmm"),        wxT(""),wxITEM_CHECK );
01908 #endif
01909 //#if _DEBUG
01910     other_menu->Append( _R(DOCVIEW_TIMEREDRAW),             wxT("&Time redraw"      "\tCtrl+Shift+T") );
01911 //#endif
01912 //#if _DEBUG
01913     other_menu->Append( _R(DOCVIEW_BLOBBYDLG),              wxT("B&lobby Dialog"    "\tHmmm") );
01914     other_menu->Append( _R(DOCVIEW_BLOBBYBAR),              wxT("Blobb&y Bar"       "\tHmmm") );
01915     other_menu->Append( _R(DEBUG_TREEVIEWDLG),              wxT("Document Tree"     "\tHmmm") );
01916 //#endif
01917 
01918 
01919     other_menu->Append( _R(IDD_BUTTBAR_STATUS),             _T("Status Bar"         "\tHmmm"), wxT(""),wxITEM_CHECK  );
01920     other_menu->Append( _R(IDD_BUTTBAR_GENERAL),            _T("General Bar"        "\tHmmm"), wxT(""),wxITEM_CHECK );
01921     other_menu->Append( _R(IDD_BUTTBAR_IMAGESETTING),       _T("ImageSetting Bar"   "\tHmmm"), wxT(""),wxITEM_CHECK  );
01922     other_menu->Append( _R(IDD_BUTTBAR_WINDOW),             _T("Window Bar"         "\tHmmm"), wxT(""),wxITEM_CHECK  );
01923     other_menu->Append( _R(IDD_BUTTBAR_ARRANGE),            _T("Arrange Bar"        "\tHmmm"), wxT(""),wxITEM_CHECK  );
01924     other_menu->Append( _R(IDD_BUTTBAR_EDIT),               _T("Edit Bar"           "\tHmmm"), wxT(""),wxITEM_CHECK  );
01925     other_menu->Append( _R(IDD_BUTTBAR_FILE),               _T("File Bar"           "\tHmmm"), wxT(""),wxITEM_CHECK  );
01926     other_menu->Append( _R(IDD_BUTTBAR_GALLERIES),          _T("Galleries Bar"      "\tHmmm"), wxT(""),wxITEM_CHECK  );
01927     other_menu->Append( _R(IDD_BUTTBAR_STANDARD),           _T("Standard Bar"       "\tHmmm"), wxT(""),wxITEM_CHECK  );
01928     other_menu->Append( _R(IDD_BUTTBAR_TOOLBAR),            _T("Toolbar Bar"        "\tHmmm"), wxT(""),wxITEM_CHECK  );
01929     other_menu->Append( _R(IDD_BUTTBAR_ANIMATION),          _T("Animation Bar"      "\tHmmm"), wxT(""),wxITEM_CHECK  );
01930     other_menu->Append( _R(IDD_BUTTBAR_FEATHER),            _T("Feather Bar"        "\tHmmm"), wxT(""),wxITEM_CHECK  );
01931 
01932 
01933     help_menu->Append( _R(DOCVIEW_ABOUT),                   wxT("&About..."         "\tF1"));
01934 
01935     wxMenuBar* menu_bar = new wxMenuBar;
01936 
01937     menu_bar->Append(   file_menu, _T("File"    ));
01938     menu_bar->Append(   edit_menu, _T("Edit"    ));
01939     menu_bar->Append(   zoom_menu, _T("Zoom"    ));
01940     menu_bar->Append(quality_menu, _T("Quality"));
01941     menu_bar->Append(  other_menu, _T("Other"   ));
01942     menu_bar->Append(   help_menu, _T("Help"    ));
01943 
01944     // Associate the menu bar with the frame
01945     subframe->SetMenuBar(menu_bar);
01946 #endif
01947 
01948     // Luke: This seems to be needed to enable accelerator on GTK
01949     // Gavin: No, this is a bad idea. It mucks up the creation of the
01950     // "Window" submenu, and perhaps other things as well.
01951 //  subframe->SetFocus();
01952 
01953 #if WX_ACCEL
01954     wxAcceleratorEntry entries[1];
01955     entries[ 0].Set(wxACCEL_CTRL|wxACCEL_SHIFT, 'T',    _R(DOCVIEW_TIMEREDRAW)          );
01956 /*  //
01957     // Not necessary since the accelerator is automatically
01958     // built from the menu accelerator text.
01959     //
01960     entries[ 1].Set(wxNORMAL,                   '=',    _R(DOCVIEW_ZOOMIN)              );
01961     entries[ 2].Set(wxNORMAL,                   '+',    _R(DOCVIEW_ZOOMIN)              );
01962     entries[ 3].Set(wxNORMAL,                   '-',    _R(DOCVIEW_ZOOMOUT)             );
01963     entries[ 4].Set(wxNORMAL,                   'D',    _R(DOCVIEW_ZOOMDRAWING)         );
01964     entries[ 5].Set(wxNORMAL,                   'P',    _R(DOCVIEW_ZOOMSPREAD)          );
01965     entries[ 6].Set(wxNORMAL,                   'Z',    _R(DOCVIEW_ZOOMPREVIOUS)        );
01966     entries[ 7].Set(wxNORMAL,                   '1',    _R(DOCVIEW_QUALITYOUTLINE)      );
01967     entries[ 8].Set(wxNORMAL,                   '2',    _R(DOCVIEW_QUALITYSIMPLE)       );
01968     entries[ 9].Set(wxNORMAL,                   '3',    _R(DOCVIEW_QUALITYNORMAL)       );
01969     entries[10].Set(wxNORMAL,                   '4',    _R(DOCVIEW_QUALITYANTIALIASED)  );
01970     entries[11].Set(wxNORMAL,                   'B',    _R(DOCVIEW_BACKGROUNDRENDER)    );
01971     entries[12].Set(wxNORMAL,                   'B',    _R(DOCVIEW_CACHING)             );
01972 */  wxAcceleratorTable accel(1,entries);
01973     subframe->SetAcceleratorTable(accel);
01974 #else
01975     // We don't want auto-accelerators, this is done using our hotkeys
01976     // I don't know how to do this yet, but I'm looking....
01977 #endif
01978 
01979     return subframe;
01980 }

void CCamApp::DisableSystem CWindowID  WindowID = NULL  )  [static]
 

This function sets a flag which disables all rendering and processing of user messages in the system.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: -

See also:
-

Definition at line 2020 of file camelot.cpp.

02021 {
02022 // RALPH
02023 #ifdef RALPH
02024     return;
02025 #endif
02026 
02027     // Disable camelot's main window. This disables the menu bar, button bar etc. 
02028     // It does not disable the tool bar however. This will be disabled in the tool bar code 
02029     // by testing the DisableSystem flag. 
02030     wxApp              *pWinApp;
02031     wxWindow           *pWnd;
02032 
02033     if ( ( pWinApp = &AfxGetApp() ) != NULL )       // Note assignment using = not == on both lines
02034                                                     // Don't disabled if the TLW is the error box we
02035                                                     // are disabling in favour of
02036         if ( (( pWnd = pWinApp->GetTopWindow() ) !=NULL ) && (pWnd != WindowID))
02037             pWnd->Enable(FALSE);                    // Only perform operation if no pointers are NULL
02038     s_bIsDisabled = true; // The flags value will be tested in the rendering and tool bar
02039                           // code etc. When TRUE functionality will be disabled.    
02040 }

void CCamApp::DoAboutBox  )  [static]
 

Definition at line 1772 of file camelot.cpp.

01773 {
01774     wxString            strMessage;
01775 
01776 #if defined(__WXMSW__)
01777     strMessage = wxString::Format( wxT("Xara Xtreme\nVersion: %s\nCDraw Version: %d.%03d\nUsage: XaraLX.exe [xar-file...]"), 
01778         g_pszAppVersion, HIWORD(GDraw_GetVersion()), LOWORD(GDraw_GetVersion()) );
01779 #else
01780 #if FALSE == wxUSE_UNICODE
01781     TCHAR*          pszCDrawVer = GDraw_GetSvnVersion();
01782 #else
01783     TCHAR           pszCDrawVer[32];
01784     camMbstowcs( pszCDrawVer, GDraw_GetSvnVersion(), 31 );
01785 #endif
01786     strMessage = wxString::Format( wxT("Xara Xtreme\nVersion: %s (%s)\nBuild date: %s\nBuilt against: " wxVERSION_STRING "\n" /*"wxWidgets linked to %s\n" */ "Usage: xaralx [xar-file...]"), 
01787         g_pszAppVersion, g_pszSvnVersion, CAMELOT_BUILD_DATE /*,_T("Unknown")*/ );
01788 #endif
01789 
01790     (void)wxMessageBox( strMessage, wxT("About Xara Xtreme") );
01791 }

void CCamApp::EnableSystem  )  [static]
 

This function restores system functionality.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
28/10/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: An ENSURE failure will occur if the DisableSys flag was not set when this function was called.

See also:
CCamApp::DisableSystem

Definition at line 2058 of file camelot.cpp.

02059 {
02060     wxApp              *pWinApp;
02061     wxWindow           *pWnd;
02062 
02063     ENSURE( s_bIsDisabled, "Trying to enable system which is already enabled" );
02064     // Enable Camelot's main window. 
02065     if ( ( pWinApp = &AfxGetApp() ) != NULL )       // Note assignment using = not == on both lines
02066         if ( ( pWnd = pWinApp->GetTopWindow() ) !=NULL )
02067             pWnd->Enable(TRUE);                     // Only perform operation if no pointers are NULL
02068     s_bIsDisabled = false; // Enable system functionality
02069 }

int CCamApp::FilterEvent wxEvent &  event  ) 
 

This function is used to collect the key press information for handling by applictaion. It passes event unmolested for controls that are allowed focus and controls within modal dialogs. It also has code to make sure that key events that are passed on aren't checked again, based on the event timestamp. All other keys are passed into application keypress handling code.

/

Timer used for background redraw. For now we have gone back to using the idle system for redraw as it does seem to work The background redraw may be changed to use a timer or some other method

define CAM_TIMER_ID 42 define CAM_TIMER_FREQUENCY 100

/*!/

IMPLEMENT_APP( CCamApp ) BEGIN_EVENT_TABLE( CCamApp, wxApp ) EVT_IDLE( CCamApp::OnIdle ) EVT_TIMER( CAM_TIMER_ID, CCamApp::OnTimer ) END_EVENT_TABLE()

DialogManager CCamApp::m_DlgMgr; bool CCamApp::s_bIsDisabled = false; // Initially system is not disabled. wxString CCamApp::m_strResourcePath; String_256 CCamApp::m_strResourceDirPath; String_256 CCamApp::m_strResourceDirPathOverride; String_256 CCamApp::m_strMediaApplication;

/*!/

CCamApp::CCamApp() { }

/*!

Author:
Luke_Hart (Xara Group Ltd) <LukeH@xara.com>
Date:
09/05/06
Parameters:
A reference to the event to filter [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: - Scope: Protected

See also:
The focus handling document

Definition at line 266 of file camelot.cpp.

00266               : Correct*/ CCamApp::FilterEvent( wxEvent& event )
00267 {
00268     static /*TYPENOTE: Correct*/ long   lLastTimeStamp = 0;
00269 
00270     wxObject* pEventObject = event.GetEventObject();
00271 
00272     if (( event.GetEventType() == wxEVT_DESTROY ) && pEventObject->IsKindOf(CLASSINFO(wxWindow)))
00273     {
00274         // Register window destruction
00275         wxWindowDeletionWatcher::RegisterWindowDeletion((wxWindow *)pEventObject);
00276     }
00277 
00278     if (PrintMonitor::IsPrintingNow())
00279     {
00280         // Disable processing of paint messages for various controls which may use GDraw or GBrush to paint, as this
00281         // appears to upset printing
00282         if (event.IsKindOf(CLASSINFO(wxPaintEvent)))
00283         {
00284             if (!pEventObject->IsKindOf(CLASSINFO(wxCamArtControl)))
00285             {   
00286                 // TRACEUSER("amb", _T("CCamApp::FilterEvent caught paint for %s"), pEventObject->GetClassInfo()->GetClassName());
00287                 return false;
00288             }
00289         }
00290     }
00291 
00292     if( event.GetEventType() == wxEVT_ACTIVATE )
00293     {
00294         TRACEUSER("luke", _T("CCamApp::FilterEvent activate to %s"), pEventObject->GetClassInfo()->GetClassName());
00295 
00296         if( pEventObject->IsKindOf( CLASSINFO(wxAuiFloatingFrame) ) )
00297         {
00298             wxClassInfo* pClassInfo = pEventObject->GetClassInfo();
00299             while( NULL != pClassInfo )
00300             {
00301                 TRACEUSER( "luke", _T("Class = %s"), (PCTSTR)pClassInfo->GetClassName() );
00302 
00303                 const wxChar* pszBaseClass = pClassInfo->GetBaseClassName1();
00304                 pClassInfo = NULL == pszBaseClass ? NULL : wxClassInfo::FindClass( pszBaseClass );
00305             }
00306             TRACEUSER( "luke", _T("Parent = %x, %x"), ((wxWindow*)pEventObject)->GetParent(), m_pMainFrame );
00307             TRACEUSER( "luke", _T("Active = %x"), ((wxTopLevelWindow*)pEventObject)->IsActive() );
00308 
00309             GiveActiveCanvasFocus();
00310             return 1;               // Don't let the recipent know it was activated
00311         } 
00312     }
00313 
00314 // useful code to see where focus events originate from. Set a breakpoint below and look
00315 // at the call stack
00316     if ( event.GetEventType() == wxEVT_SET_FOCUS )
00317     {
00318         TRACEUSER("luke", _T("CCamApp::FilterEvent focus to %s"), pEventObject->GetClassInfo()->GetClassName());
00319 /*      if (pEventObject->IsKindOf(CLASSINFO(CRenderWnd)))
00320         {
00321             INT32 i=1;
00322         } */
00323     }
00324 
00325     if ( event.GetEventType() == wxEVT_KILL_FOCUS )
00326     {
00327 #if defined(_DEBUG)
00328         wxFocusEvent&   FocusEvent = (wxFocusEvent&)event;
00329         TRACEUSER( "luke", _T("CCamApp::FilterEvent kill focus to %016x from 0x%016x"), FocusEvent.GetWindow(), 
00330                 FocusEvent.GetEventObject() );
00331 #endif
00332 
00333         // Any loss of focus could well a good time to kill cursor
00334         wxSetCursor( *wxSTANDARD_CURSOR );
00335     }
00336 
00337     if (( event.GetEventType() == wxEVT_CREATE )
00338         && pEventObject
00339         && (pEventObject->IsKindOf(CLASSINFO(wxTopLevelWindow)))
00340         && !(pEventObject->IsKindOf(CLASSINFO(wxAdvSplashScreen))) // Don't trigger this on the creation of the splash screen itself
00341         && !(pEventObject->IsKindOf(CLASSINFO(wxSplashScreen)))
00342         )
00343     {
00344         // a top level window is about to be created. End the splash screen if it is up as it may obscure it
00345         CamResource::DoneInit(FALSE);   
00346     }
00347 
00348 #if defined(_DEBUG)
00349     if( event.GetEventType() == wxEVT_CHAR )
00350     {
00351         if (pEventObject)
00352         {
00353             TRACEUSER( "jlh92", _T("KeyEvent 4 %s CH\n"),
00354                 ((wxWindow*)pEventObject)->GetClassInfo()->GetClassName() );
00355         }
00356     }
00357 #endif
00358 
00359     if( event.GetEventType() == wxEVT_KEY_DOWN ||
00360         event.GetEventType() == wxEVT_KEY_UP )
00361     {
00362         // Use timestamp to detect events which are passing
00363         // down the chain (which we've tested)
00364         if( lLastTimeStamp == event.GetTimestamp() )
00365             return -1;
00366         lLastTimeStamp = event.GetTimestamp();
00367 
00368         TRACEUSER( "jlh92", _T("KeyEvent 4 %s %s\n"),
00369             ((wxWindow*)pEventObject)->GetClassInfo()->GetClassName(),
00370             event.GetEventType() == wxEVT_KEY_DOWN ? _T("KD") : _T("KU") );
00371         
00372         // Is the object allowed to recieve keys? We have to go done the object hierarchy
00373         // since some control (notably Combos) will produce temporary windows which can get
00374         // key events.
00375         wxWindow* pScanObj = (wxWindow*)pEventObject;
00376         while( NULL != pScanObj )
00377         {
00378             wxClassInfo* pClassInfo = pScanObj->GetClassInfo();
00379 #if defined(DEBUG_KEYPRESS_SPEW)
00380             {
00381                 wxClassInfo *pTmpInfo = pClassInfo;
00382                 while( NULL != pTmpInfo )
00383                 {
00384                     TRACEUSER( "jlh92", _T("Class %s\n"), PCTSTR(pTmpInfo->GetClassName()) );
00385         
00386                     PCTSTR  pszName = pTmpInfo->GetBaseClassName1();
00387                     pTmpInfo = NULL == pszName ? NULL : wxClassInfo::FindClass( pszName );
00388                 }
00389                 TRACEUSER( "jlh92", _T("----------------------\n") );
00390             }
00391 #endif
00392             TRACEUSER("amb", _T("CCamApp::FilterEvent key for %s"), pClassInfo->GetClassName());
00393 
00394             if( pClassInfo->IsKindOf( CLASSINFO(wxTextCtrl) ) ||
00395                 pClassInfo->IsKindOf( CLASSINFO(wxComboBox) ) ||
00396                 pClassInfo->IsKindOf( CLASSINFO(wxSliderCombo) ) ||
00397                 pClassInfo->IsKindOf( CLASSINFO(wxOwnerDrawnComboBox) ) ||
00398                 pClassInfo->IsKindOf( CLASSINFO(wxComboCtrl) )
00399                 )
00400             {
00401                 TRACEUSER("amb", _T("CCamApp::FilterEvent gets keys as special"));
00402                 TRACEUSER( "jlh92", _T("Control gets keys") );
00403                 // Yes, pass on as usual
00404                 return -1;
00405             }
00406 
00407             pScanObj = pScanObj->GetParent();
00408         }
00409 
00410         // Scan down ancestors looking for either wxPanels (always non-modal) and
00411         // wxDailogs (can be modal, so we check)
00412         wxWindow *pWnd = (wxWindow*)pEventObject;
00413         while( NULL != pWnd && !pWnd->IsKindOf( CLASSINFO(wxPanel) ) )
00414         {
00415             // Dialogs may-be modal so check
00416             if( pWnd->IsKindOf( CLASSINFO(wxDialog) ) )
00417             {
00418                 // Pass event down chain if modal
00419                 if( ((wxDialog*)pWnd)->IsModal() )
00420                 {
00421                     TRACEUSER( "jlh92", _T("Modal dialog\n") );
00422                     TRACEUSER("amb", _T("CCamApp::FilterEvent gets keys as modal"));
00423                     return -1;
00424                 }
00425 
00426                 // Non-modal dialog so do focus handling
00427                 break;
00428             }
00429 
00430             pWnd = pWnd->GetParent();
00431         }
00432 
00433         TRACEUSER("amb", _T("CCamApp::FilterEvent handle"));
00434         TRACEUSER( "jlh92", _T("Handled!\n") );
00435 
00436         // Do our best to see if the object is deleted.
00437         wxWindowDeletionWatcher * wd = NULL;
00438         if (pEventObject->IsKindOf(CLASSINFO(wxWindow)))
00439         {
00440             wd = new wxWindowDeletionWatcher((wxWindow*)pEventObject);
00441             if (!wd)
00442                 return -1;
00443         }
00444 
00445         // Process keyboard messages (and mark event as handled)
00446         if( HandleKeyPress( (wxKeyEvent&)event ) )
00447         {
00448             BOOL deleted = wd && wd->HasBeenDeleted();
00449             if (wd)
00450                 delete wd;
00451             if (deleted)
00452                 return 1; // event handled. Do NOT anything else here as the object may by now
00453                         // have been deleted (e.g. FileClose hotkey).
00454             else
00455                 return -1;
00456         }
00457         if (wd)
00458             delete wd;
00459     }
00460     
00461     return -1;
00462 }

DialogManager * CCamApp::GetDlgManager  )  [static]
 

For obtaining a pointer to the dialog manager.

Author:
Simon_Maneggio (Xara Group Ltd) <camelotdev@xara.com>
Date:
19/8/93
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
A pointer to the dialog manager

Errors: -

See also:
-

Definition at line 1997 of file camelot.cpp.

01998 {
01999     return( &m_DlgMgr ); 
02000 }

wxDocManager* CCamApp::GetDocumentManager  )  const [inline]
 

Definition at line 130 of file camelot.h.

00131     {
00132         return m_docManager.get();
00133     }

bool CCamApp::GetRecentFileText INT32  Index,
String_256 pszText
 

Gets the text suitable for the menu text for a given recent file. If there is an available file the Text param will hold the abbreviated filename (eg. c:\....art). If the function returns FALSE, then the Text param is left alone.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/95
Parameters:
Index - The index into the recent file list that we are interested in [INPUTS]
Text - the file name of the recent file. This will be abbreviated it is [OUTPUTS] too long. This param is only changed if this function returns TRUE.
Returns:
TRUE if it found and entry, FALSE if it did not

Definition at line 1756 of file camelot.cpp.

01757 {
01758     wxFileHistory*      pFileHist = m_docManager->GetFileHistory();
01759 
01760     if( Index < INT32(pFileHist->GetCount()) )
01761     {
01762         wxFileName  deconstruct( pFileHist->GetHistoryFile( Index ) );
01763         *pszText = deconstruct.GetFullName();
01764         return true;
01765     }
01766 
01767     // Failed to find an entry for this item
01768     return false;   
01769 }

StringBase & CCamApp::GetResourceDirectory  )  [static]
 

Definition at line 1793 of file camelot.cpp.

01794 {
01795     return m_strResourceDirPath;
01796 }

void CCamApp::GiveActiveCanvasFocus  ) 
 

Definition at line 1798 of file camelot.cpp.

01799 {
01800     CCamView* pView = dynamic_cast<CCamView*>( m_docManager->GetCurrentView() );
01801     if( NULL != pView )
01802     {
01803         pView->Activate( true );
01804         pView->GetRenderWindow()->SetFocus();
01805     }
01806 }

bool CCamApp::HandleKeyPress wxKeyEvent &  event  ) 
 

Central handler for key and char events, using KeyPress class to route events to the areas of code that need to handle them.

/

Deinitialisation.

INT32 CCamApp::OnExit( void ) { InInitOrDeInit = TRUE; // Don't allow them to save their work on a SEGV We can no longer stop the closedown, so flag this fact Camelot.ShuttingDown(TRUE);

Dump the file history (9 entries as for Xtreme 4 Win) wxFileHistory* pFileHist = m_docManager->GetFileHistory(); UINT32 cRecent = UINT32(pFileHist->GetCount()); for( UINT32 ord = 0; ord < 9; ++ord ) { This is safe since we control all variables! TCHAR pszTag[8]; camSprintf( pszTag, _T("File%d"), ord );

if( ord < cRecent ) { wxString strFileName( pFileHist->GetHistoryFile( ord ) ); Camelot.SetPrefDirect( _T("Recent File list"), pszTag, PCTSTR(strFileName), TRUE ); } else Camelot.SetPrefDirect( _T("Recent File list"), pszTag, _T(""), TRUE ); }

we can't load documents any more - delete IPC server if (m_pServer) { delete m_pServer; m_pServer = NULL; }

delete single instance checked if (m_pSingleInstanceChecker) { delete m_pSingleInstanceChecker; m_pSingleInstanceChecker = NULL; }

Rendering is back on idle events for now as it actually works m_Timer.Stop();

if defined(FILELIST) { m_docManager->FileHistorySave(Preferences::GetOilPrefs()); } endif m_docManager = std::auto_ptr<wxDocManager>( NULL );

bFirstRun = FALSE;

Now deinit everything

CXMLUtils::DeInitialise();

DeinitKernel();

if CUSTOM_INONE == 2 DLLControlClass::DeinitAllControls(); endif

GRenderRegion::DeInit(); // tidy up GDraw

PORTNOTE("other","Removed GDI+, filelist and profilename support") ifndef EXCLUDE_FROM_XARALX Gdiplus::GdiplusShutdown(gdiplusToken);

Finished with preferences/registry so remove the allocated ProfileName. Was not here before 18/2/97 if (m_pszProfileName != NULL) { free((void *) m_pszProfileName); m_pszProfileName = NULL; } endif

ControlList::DeInit(); DialogEventHandler::DeInit(); Kill of art provider CamArtProvider::DeInit(); wxPlatformDependent::DeInit(); Kill of resources CamResource::DeInit();

Kill off profiling CamProfile::ActivateProfiling(FALSE);

if DUMP_MEM_AT_END MemoryState.DumpAllObjectsSince(); endif

We want a memory dump on Debug builds only ifdef _DEBUG SimpleCCObject::MemoryDump(); DumpCCMallocTrace(); endif

PORTNOTE("other","Removed 3D, Extras and UserHelp support") ifndef EXCLUDE_FROM_XARALX For fabby 3D if (Is3dWanted()) pCtl3dUnregister(AfxGetInstanceHandle());

OILModule::DeinitExtras(); // free all DLLs (e.g. ctl3d)

Last of all, deinit the help system now that there's very little else to go wrong. DeInitUserHelp(); endif

zap this after we know all windows have gone wxWindowDeletionWatcher::DeInit();

wxHandleFatalExceptions(FALSE); return wxApp::OnExit(); }

WEBSTER-ranbirr-12/11/96 ifndef WEBSTER void CCamApp::OnFilePrintSetup() { ifndef STANDALONE Document *pDoc = Document::GetSelected(); DocView *pDocView = DocView::GetSelected();

if (pDoc && pDocView && pDocView->GetConnectionToOilView()) { Inform the user if we have switched to using the default printer on the system before opening the print setup dlg. CCPrintDialog::InformResetToDefaultPrinter(FALSE);

This no longer calls the base class OnFilePrint() function. Instead, we involke the print dlg ourselves so that we can update our printer settings when the dlg is closed via the user clicking on OK (7/4/95 - Markn)

CCPrintInfo printinfo(pDoc, pDocView->GetConnectionToOilView()); printinfo.OnPreparePrinting(TRUE); }

endif } endif

void CCamApp::OnAppExit() { PORTNOTE("other","Removed multi-instance flag stuff") ifndef EXCLUDE_FROM_XARALX remove the flag that prevents camelot starting more than once; BUT only if were the camelot that set it!

HWND mainWindow = m_pMainWnd->m_hWnd;

if (mainWindow) { BOOL* ret = (BOOL*) RemoveProp (m_pMainWnd->m_hWnd, "Xara X sfs");

if (ret) delete (ret); } endif

Now close the main frame m_pMainFrame->Close();

}

/*!

Author:
Luke_Hart (Xara Group Ltd) <lukeh@xara.com>
Date:
22/05/06
Parameters:
event - The key \ char event to handle [INPUTS]
Returns:
true if handled else false

Definition at line 1323 of file camelot.cpp.

01324 {
01325     // Make sure the kernel knows which view/doc the event applies to, if any.
01326     if( NULL != Document::GetSelected() )
01327         Document::GetSelected()->SetCurrent();
01328     if( NULL != DocView::GetSelected() )
01329         DocView::GetSelected()->SetCurrent();
01330 
01331     // Process keyboard messages (returning true if it was)
01332     return !CCamFrame::GetMainFrame()->IsIconized() && KeyPress::TranslateMessage( (wxKeyEvent*)&event );
01333 }

static bool CCamApp::IsDisabled void   )  [inline, static]
 

Definition at line 121 of file camelot.h.

00121 {return s_bIsDisabled;}

BOOL CCamApp::LaunchBrowserApp const wxString &  strAppName,
wxString  strCommand
[static, private]
 

Definition at line 2249 of file camelot.cpp.

02250 {
02251     strCommand.Prepend(_T(" "));
02252     strCommand.Prepend(strAppName);
02253 
02254     CamLaunchProcess* plp = new CamLaunchProcess();
02255     if (plp==NULL)
02256         return FALSE;
02257 
02258     BOOL ok = plp->Execute(strCommand);
02259 
02260     if (ok)
02261     {
02262         // Let this process run free!
02263         plp->Disconnect();
02264 //      delete plp;                             // This object will allegedly delete itself when the process dies
02265     }
02266     else
02267     {
02268         // Make sure we don't leave any zombie processes lying around
02269         wxKillError e = plp->Terminate();       // This should result in a call to OnTerminate
02270         TRACEUSER("Phil", _T("Terminating bad process returned %d\n"), e);
02271 //      delete plp;                             // This object will allegedly delete itself when the process dies
02272     }
02273 
02274     return ok;
02275 }

bool CCamApp::LaunchMediaApp const wxString &  strUrl  )  [static]
 

This function attempts to replay a movie using configured player (or ask user to specify one if not already setup).

Author:
Luke_Hart (Xara Group Ltd) <camelotdev@xara.com> <luke.hartΩxara.com>
Date:
23/08/06
Parameters:
strUrl - The path to the file conbtaining the movie to play (could even be [INPUTS] web address)
- [OUTPUTS]
Returns:
true if player launched successfully

Errors: - Scope: Public

See also:
-

Definition at line 2892 of file camelot.cpp.

02893 {
02894     // Move array into a helpful structure
02895     SelMediaDlgParam::CMediaAppList mapMediaApp;
02896     FillMediaAppMap( &mapMediaApp );
02897 
02898     // First we see if the replay app. is present
02899     CMediaReplayDetect  Detect;
02900     if( !Detect.IsAppPresent( m_strMediaApplication ) )
02901     {
02902         // Setup param and open replay app selection dialog
02903         SelMediaDlgParam    Param;
02904         Param.m_pAppList = &mapMediaApp;
02905         OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor( CC_RUNTIME_CLASS(SelMediaDlg) ); 
02906         if( NULL != pOpDesc )
02907         {
02908             pOpDesc->Invoke( &Param );
02909         
02910             if( Param.m_fValid )
02911                 m_strMediaApplication = Param.m_strSel;
02912         }
02913 
02914         // User canceled, bomb out
02915         if( !Param.m_fValid )
02916             return true;
02917     }
02918 
02919     // Check to see if we can control the selected app. (maybe one day....)
02920     SelMediaDlgParam::CMediaAppListIter iter = mapMediaApp.find( (PCTSTR)m_strMediaApplication );
02921     bool                fMPlayer = false;
02922     if( mapMediaApp.end() != iter )
02923         fMPlayer = iter->second;
02924 
02925     // Build the command line and execute it
02926     wxString            strCommand;
02927     strCommand = PCTSTR(m_strMediaApplication);
02928     if( fMPlayer )
02929         strCommand.append( _T(" -quiet ") );
02930     strCommand.Append( _T(" \"") );
02931     strCommand.Append( strUrl );
02932     strCommand.Append( _T("\"") );
02933 
02934     CamLaunchProcess*   plp = new CamLaunchProcess();
02935     if (plp==NULL)
02936         return false;
02937 
02938     bool                ok = FALSE != plp->Execute( strCommand );
02939     if (ok)
02940     {
02941         // Let this process run free!
02942         plp->Disconnect();
02943     }
02944     else
02945     {
02946         // Make sure we don't leave any zombie processes lying around
02947         wxKillError e = plp->Terminate();       // This should result in a call to OnTerminate
02948         TRACEUSER("Phil", _T("Terminating bad process returned %d\n"), e);
02949     }
02950 
02951     return ok;
02952 }

BOOL CCamApp::LaunchWebBrowser const wxString &  strUrl  )  [static]
 

Launch a web browser referring to a given URL.

/

void CCamApp::OnIdle( wxIdleEvent &event ) { TRACEUSER("Gerry", _T("CCamApp::OnIdle\n"));

if ( IsDisabled() || PrintMonitor::IsPrintingNow() ) { TRACEUSER("Gerry", _T("Disabled - Is this a bad thing????????\n")); event.Skip(); return; }

First thing we will clean up any "temporary" DCs CCDC::CleanUpDCs();

ControlList::Idle();

if ( Camelot.OnIdle(true) ) { event.RequestMore(); }

TRACEUSER("Gerry", _T("MoreRequested = %s\n"), event.MoreRequested() ? _T("true") : _T("false"));

We *MUST* call Skip() here or you can't exit the program! event.Skip(); }

/*!/

void CCamApp::OnTimer( wxTimerEvent& WXUNUSED(event) ) { if (!PrintMonitorIsPrintingNow() ) { TRACEUSER("Gerry", _T("Disabled - Is this a bad thing????????\n"));

This should also exit the while loop if there are messages in the message queue.

while ( Camelot.ServiceRendering() ) ; } PORTNOTE("other","CCamApp::OnTimer - needs completing") }

/*!/

void CCamApp::OnHelpIndex() { Get the locale id wxString strLocale( setlocale( LC_MESSAGES, NULL ), wxConvUTF8 ); INT32 ordSep = strLocale.Find( _T('_' ) ); if ( -1 != ordSep ) strLocale = strLocale.Left( ordSep ); TRACEUSER( "jlh92", _T("Locale = %s\n"), PCTSTR(strLocale) );

Locale C is considered a synonym for en if( strLocale == _T("C") ) strLocale = _T("en");

Check the help dir exists, if not bomb out wxString strHelpPath( (TCHAR*)m_strResourceDirPath ); strHelpPath += _T("/doc/"); TRACEUSER( "jlh92", _T("Using filter discovery directory \"s\"\n"), PCTSTR(strHelpPath + strLocale) ); if( wxDir::Exists( strHelpPath + strLocale ) ) strHelpPath += strLocale + _T("/"); else { if( wxDir::Exists( strHelpPath + _T("en") ) ) strHelpPath += _T("en/"); if defined(_DEBUG) else { We'll try default location under debug to make life easier strHelpPath = _T("/usr/share/xaralx/doc/en/"); TRACEUSER( "jlh92", _T("Try = \"s\"\n"), PCTSTR(strHelpPath) ); } endif }

Build full path wxString strUrl; strUrl = strHelpPath; strUrl += _T("xaralx.htm"); if (!wxFileExists(strUrl)) { Complete failure to find any local help files So go to the web site... strUrl = _T("http://www.xaralx.org"); } else { Build the complete URL and launch browser strUrl.Prepend(_T("file://")); }

LaunchWebBrowser(strUrl);

}

/*!

Author:
Phil_Martin (Xara Group Ltd) <camelotdev@xara.com>
Date:
22/May/2006
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Definition at line 2195 of file camelot.cpp.

02196 {
02197     // --------------------------------------------------------------------------------------
02198     // Attempt to launch common browsers to cope with our rich, Javascripted, HTML help files
02199     //
02200     // There are long-winded reasons for doing it this way which were discussed on the
02201     // dev@xaraxtreme.org mailing list.
02202     //
02203     BOOL ok;
02204 
02205     // http://portland.freedesktop.org/wiki/TaskOpenURL
02206     // ok = LaunchBrowserApp(_T("xdg-open"), strUrl);
02207     // if (ok) return ok;
02208 
02209     // http://lists.freedesktop.org/pipermail/xdg/2004-August/004489.html
02210     ok = LaunchBrowserApp(_T("desktop-launch"), strUrl);
02211     if (ok) return ok;
02212 
02213     ok = LaunchBrowserApp(_T("gnome-open"), strUrl);
02214     if (ok) return ok;
02215 
02216     ok = LaunchBrowserApp(_T("htmlview"), strUrl);
02217     if (ok) return ok;
02218 
02219     ok = LaunchBrowserApp(_T("firefox"), strUrl);
02220     if (ok) return ok;
02221 
02222     ok = LaunchBrowserApp(_T("mozilla"), strUrl);
02223     if (ok) return ok;
02224 
02225     ok = LaunchBrowserApp(_T("konqueror"), strUrl);
02226     if (ok) return ok;
02227 
02228     ok = LaunchBrowserApp(_T("gnome-www-browser"), strUrl);
02229     if (ok) return ok;
02230 
02231     ok = LaunchBrowserApp(_T("epiphany"), strUrl);
02232     if (ok) return ok;
02233 
02234     ok = LaunchBrowserApp(_T("opera"), strUrl);
02235     if (ok) return ok;
02236 
02237     ok = LaunchBrowserApp(_T("iexplore"), strUrl);
02238     if (ok) return ok;
02239 
02240     ok = LaunchBrowserApp(_T("safari"), strUrl);
02241     if (ok) return ok;
02242 
02243     ok = wxLaunchDefaultBrowser(strUrl);
02244 
02245     return ok;
02246 }

BOOL CCamApp::MakeDocumentNative wxDocument *  pDoc,
PathName Path
[private]
 

If you attemp to open a BMP or any other non native file, it will have a bad document name (ending in .bmp or whatever, instead of .art). It also causes problems when pressing save, as the original non native file can be overwritten with a native file version. This makes sure that the user will always be asked where they want to save it when it comes to saving time by throwing away the know path info.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/2/95
Parameters:
pDoc - The document to test and change [INPUTS] Path - the path of the original document name
Path - This will have the extension modified if the function returned TRUE [OUTPUTS]
Returns:
TRUE if it changed the document, FALSE if it did not
See also:
CCamApp::OnRecentFile; CCamApp::OnFileOpen

Definition at line 1656 of file camelot.cpp.

01657 {
01658     // Only bother if the was actually a document to process
01659     if (pDoc==NULL)
01660         return FALSE;
01661 
01662     // Set the extension of the file to be .xar
01663     String_256 Extension( _R(IDS_DEFAULT_EXTENSION) );
01664     String_256 OldExtension = Path->GetType();
01665     // make sure they are of the same case
01666     Extension.toLower();
01667     OldExtension.toLower();
01668 #if NEW_NATIVE_FILTER
01669     String_256 NewExtension(_R(IDS_DEFAULT_EXTENSION));
01670     NewExtension.toLower();
01671     // see if the extension is .xar or .cxn
01672     if (Extension != OldExtension && OldExtension != NewExtension)
01673 #else
01674     // see if the extension is .xar
01675     if (Extension != OldExtension)
01676 #endif
01677     {
01678         Path->SetType(Extension);
01679 
01680         // Find out some of the details about the filename
01681         String_256 FileName = Path->GetFileName();
01682 
01683         // Set the title of and path of the document
01684         // we set the path to blank, so that we will always be prompted for a real filename
01685         ((CCamDoc*)pDoc)->SetTitle( FileName );
01686         pDoc->SetFilename( FileName, true );
01687         ((CCamDoc*)pDoc)->SetPathNameEmpty();
01688 
01689         TRACEUSER( "luke", _T("New name %s"), PCTSTR(FileName) );
01690 
01691         // Tell 'em we changed things
01692         return TRUE;
01693     }
01694 
01695     // Nothing changed
01696     return FALSE;
01697 }

static void CCamApp::NeedMoreIdles  )  [inline, static]
 

Definition at line 210 of file camelot.h.

00210 { ::wxWakeUpIdle(); }

void CCamApp::OnAppExit  ) 
 

INT32 CCamApp::OnExit  ) 
 

void CCamApp::OnFatalException  ) 
 

This function is called whenever a fatal exception has occurred.

/

//////////////////////////////////////////////////////////////////////////////

if 0

This code needs to be put into wx.cpp

The accelerators of menu strings are decoded and accelerators are automatically built from them. This works well most of the time but numeric keypad accelerators must be added in a rather ugly format such as "Ctrl+KP_ADD". This code enables them to be included in a format such as "Ctrl+Num +", ie Num (and Numpad) are used as modifiers in the same way as Shift, Ctrl and Alt.

Could probably do with further improvement.

static inline bool CompareAccelString(const wxString& str, const wxChar *accel) { if wxUSE_INTL return str == accel || str == wxGetTranslation(accel); else return str == accel; endif }

wxAcceleratorEntry *wxGetAccelFromString(const wxString& label) { wxPrintf( wxT("label %s\n"), label.c_str() );

check for accelerators: they are given after '' INT32 posTab = label.Find(wxT('')); if ( posTab != wxNOT_FOUND ) { parse the accelerator string INT32 keyCode = 0; INT32 accelFlags = wxACCEL_NORMAL; wxString current; bool bNumPad = false; for ( size_t n = (size_t)posTab + 1; n < label.Len(); n++ ) { if ( (label[n] == '+') || (label[n] == '-') ) { if ( CompareAccelString(current, wxTRANSLATE("ctrl")) ) accelFlags |= wxACCEL_CTRL; else if ( CompareAccelString(current, wxTRANSLATE("alt")) ) accelFlags |= wxACCEL_ALT; else if ( CompareAccelString(current, wxTRANSLATE("shift")) ) accelFlags |= wxACCEL_SHIFT; else if ( CompareAccelString(current, wxTRANSLATE("numpad")) || CompareAccelString(current, wxTRANSLATE("num")) ) bNumPad = true; else { we may have "Ctrl-+", for example, but we still want to catch typos like "Crtl-A" so only give the warning if we have something before the current '+' or '-', else take it as a literal symbol if ( current.empty() ) { current += label[n];

skip clearing it below continue; } else { wxLogDebug(wxT("Unknown accel modifier: '%s'"), current.c_str()); } }

current.clear(); } else { current += (wxChar) wxTolower(label[n]); } }

if ( current.empty() ) { wxLogDebug(wxT("No accel key found, accel string ignored.")); } else { if ( current.Len() == 1 && !bNumPad ) { it's a letter keyCode = current[0U];

Only call wxToupper if control, alt, or shift is held down, otherwise lower case accelerators won't work. if (accelFlags != wxACCEL_NORMAL) { keyCode = wxToupper(keyCode); } } else { is it a function key? if ( current[0U] == 'f' && wxIsdigit(current[1U]) && (current.Len() == 2 || (current.Len() == 3 && wxIsdigit(current[2U]))) ) { keyCode = CAMKEY(F1) + wxAtoi(current.c_str() + 1) - 1; } else { several special cases current.MakeUpper(); if ( current == wxT("DEL") ) keyCode = CAMKEY(DELETE); else if ( current == wxT("DELETE") ) keyCode = CAMKEY(DELETE); else if ( current == wxT("BACK") ) keyCode = CAMKEY(BACK); else if ( current == wxT("INS") ) keyCode = CAMKEY(INSERT); else if ( current == wxT("INSERT") ) keyCode = CAMKEY(INSERT); else if ( current == wxT("ENTER") || current == wxT("RETURN") ) keyCode = CAMKEY(RETURN); else if ( current == wxT("PGUP") ) keyCode = CAMKEY(PRIOR); else if ( current == wxT("PGDN") ) keyCode = CAMKEY(NEXT); else if ( current == wxT("LEFT") ) keyCode = CAMKEY(LEFT); else if ( current == wxT("RIGHT") ) keyCode = CAMKEY(RIGHT); else if ( current == wxT("UP") ) keyCode = CAMKEY(UP); else if ( current == wxT("DOWN") ) keyCode = CAMKEY(DOWN); else if ( current == wxT("HOME") ) keyCode = CAMKEY(HOME); else if ( current == wxT("END") ) keyCode = CAMKEY(END); else if ( current == wxT("SPACE") ) keyCode = CAMKEY(SPACE); else if ( current == wxT("TAB") ) keyCode = CAMKEY(TAB); else if ( current == wxT("ESC") || current == wxT("ESCAPE") ) keyCode = CAMKEY(ESCAPE); else if ( current == wxT("CANCEL") ) keyCode = CAMKEY(CANCEL); else if ( current == wxT("CLEAR") ) keyCode = CAMKEY(CLEAR); else if ( current == wxT("MENU") ) keyCode = CAMKEY(MENU); else if ( current == wxT("PAUSE") ) keyCode = CAMKEY(PAUSE); else if ( current == wxT("CAPITAL") ) keyCode = CAMKEY(CAPITAL); else if ( current == wxT("SELECT") ) keyCode = CAMKEY(SELECT); else if ( current == wxT("PRINT") ) keyCode = CAMKEY(PRINT); else if ( current == wxT("EXECUTE") ) keyCode = CAMKEY(EXECUTE); else if ( current == wxT("SNAPSHOT") ) keyCode = CAMKEY(SNAPSHOT); else if ( current == wxT("HELP") ) keyCode = CAMKEY(HELP); else if ( current == wxT("ADD") ) keyCode = CAMKEY(ADD); else if ( current == wxT("SEPARATOR") ) keyCode = CAMKEY(SEPARATOR); else if ( current == wxT("SUBTRACT") ) keyCode = CAMKEY(SUBTRACT); else if ( current == wxT("DECIMAL") ) keyCode = CAMKEY(DECIMAL); else if ( current == wxT("DIVIDE") ) keyCode = CAMKEY(DIVIDE); else if ( current == wxT("NUM_LOCK") ) keyCode = CAMKEY(NUMLOCK); else if ( current == wxT("SCROLL_LOCK") ) keyCode = CAMKEY(SCROLL); else if ( current == wxT("PAGEUP") ) keyCode = CAMKEY(PAGEUP); else if ( current == wxT("PAGEDOWN") ) keyCode = CAMKEY(PAGEDOWN); else if ( current == wxT("KP_SPACE") ) keyCode = CAMKEY(NUMPAD_SPACE); else if ( current == wxT("KP_TAB") ) keyCode = CAMKEY(NUMPAD_TAB); else if ( current == wxT("KP_ENTER") ) keyCode = CAMKEY(NUMPAD_ENTER); else if ( current == wxT("KP_HOME") ) keyCode = CAMKEY(NUMPAD_HOME); else if ( current == wxT("KP_LEFT") ) keyCode = CAMKEY(NUMPAD_LEFT); else if ( current == wxT("KP_UP") ) keyCode = CAMKEY(NUMPAD_UP); else if ( current == wxT("KP_RIGHT") ) keyCode = CAMKEY(NUMPAD_RIGHT); else if ( current == wxT("KP_DOWN") ) keyCode = CAMKEY(NUMPAD_DOWN); else if ( current == wxT("KP_PRIOR") ) keyCode = CAMKEY(NUMPAD_PRIOR); else if ( current == wxT("KP_PAGEUP") ) keyCode = CAMKEY(NUMPAD_PAGEUP); else if ( current == wxT("KP_NEXT;") ) keyCode = CAMKEY(NUMPAD_NEXT); else if ( current == wxT("KP_PAGEDOWN") ) keyCode = CAMKEY(NUMPAD_PAGEDOWN); else if ( current == wxT("KP_END") ) keyCode = CAMKEY(NUMPAD_END); else if ( current == wxT("KP_BEGIN") ) keyCode = CAMKEY(NUMPAD_BEGIN); else if ( current == wxT("KP_INSERT") ) keyCode = CAMKEY(NUMPAD_INSERT); else if ( current == wxT("KP_DELETE") ) keyCode = CAMKEY(NUMPAD_DELETE); else if ( current == wxT("KP_EQUAL") ) keyCode = CAMKEY(NUMPAD_EQUAL); else if ( current == wxT("KP_MULTIPLY") || current == wxT("*") && bNumPad ) keyCode = CAMKEY(NUMPAD_MULTIPLY); else if ( current == wxT("KP_ADD") || current == wxT("+") && bNumPad ) keyCode = CAMKEY(NUMPAD_ADD); else if ( current == wxT("KP_SEPARATOR") ) keyCode = CAMKEY(NUMPAD_SEPARATOR); else if ( current == wxT("KP_SUBTRACT") || current == wxT("-") && bNumPad ) keyCode = CAMKEY(NUMPAD_SUBTRACT); else if ( current == wxT("KP_DECIMAL") || current == wxT(".") && bNumPad ) keyCode = CAMKEY(NUMPAD_DECIMAL); else if ( current == wxT("KP_DIVIDE") || current == wxT("/") && bNumPad ) keyCode = CAMKEY(NUMPAD_DIVIDE); else if ( current == wxT("WINDOWS_LEFT") ) keyCode = CAMKEY(WINDOWS_LEFT); else if ( current == wxT("WINDOWS_RIGHT") ) keyCode = CAMKEY(WINDOWS_RIGHT); else if ( current == wxT("WINDOWS_MENU") ) keyCode = CAMKEY(WINDOWS_MENU); else if ( current == wxT("COMMAND") ) keyCode = CAMKEY(COMMAND); else if ( bNumPad && current.Len()==1 && wxIsdigit(current[0U]) ) keyCode = CAMKEY(NUMPAD0) + wxAtoi(current.c_str()); else if ( current.Left(3) == wxT("KP_") && wxIsdigit(current[3U]) ) keyCode = CAMKEY(NUMPAD0) + wxAtoi(current.c_str() + 3); else if ( current.Left(7) == wxT("SPECIAL") && wxIsdigit(current[7U]) ) keyCode = CAMKEY(SPECIAL1) + wxAtoi(current.c_str() + 7) - 1; else { wxLogDebug(wxT("Unrecognized accel key '%s', accel string ignored."), current.c_str()); return NULL; } } } }

if ( keyCode ) { we do have something return new wxAcceleratorEntry(accelFlags, keyCode); } }

return (wxAcceleratorEntry *)NULL; }

endif

//////////////////////////////////////////////////////////////////////////////

/*!

Author:
Alex Bligh <alex@alex.org.uk>
Date:
09/05/06
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
-

Errors: - Scope: Public

See also:
-

Definition at line 2558 of file camelot.cpp.

02559 {
02560     static INT32 recursionguard = 0;
02561 
02562     if (recursionguard)
02563     {   
02564         // Oh dear, an error occurred whilst we had our box up. Exit immediately
02565         if (recursionguard++ > 1)
02566         {
02567             abort(); // do not even try to go through wx
02568             _exit(1); // how did we get here?
02569         }
02570 
02571         // switch fatal exception handling off
02572         ::wxHandleFatalExceptions(FALSE);
02573         TRACE(_T("CCamApp::OnFatalException() called recursively - dying now"));
02574         return; // this quits the app
02575     }
02576 
02577     recursionguard++;
02578 
02579     // Put this bit in a block so strings etc. allocated are deallocated before we go generate our own stack frame
02580     do
02581     {
02582         // Ensure we are reinstated as the signal handler
02583         ::wxHandleFatalExceptions(FALSE);
02584         ::wxHandleFatalExceptions(TRUE);
02585 
02586 // This bit of code is currently not operative - looking into wxDebugReport instead
02587 #ifdef EXCEPTION_LOCATION
02588         String_256 location(_R(IDS_DOOMUNKNOWN));
02589         // On platforms that support it, we try and find the appropriate error
02590 #if !defined(__WXMAC__) && !defined(__FreeBSD__)
02591 #define SWMAXLEVEL 200
02592         class StackWalker : public wxStackWalker
02593         {
02594         public:
02595             wxArrayString ArrayOfRefs;
02596             wxArrayString ArrayOfDetails;
02597             StackWalker() {ArrayOfRefs.SetCount(SWMAXLEVEL);ArrayOfDetails.SetCount(SWMAXLEVEL);}
02598             virtual void OnStackFrame(const wxStackFrame & frame)
02599             {
02600                 wxString details;
02601                 wxString fn=frame.GetFileName();
02602                 UINT32 line=frame.GetLine();
02603                 UINT32 level=frame.GetLevel();
02604                 details.Printf(_T("%d %s:%d %s"), level, fn.c_str(),
02605                             line, frame.GetName().c_str());
02606 #ifdef _DEBUG
02607                 wxLogDebug(details);
02608 #endif
02609                 if (level<SWMAXLEVEL)
02610                 {
02611                     ArrayOfDetails[level]=details;
02612                     details.Printf(_T("%s:%d"), fn.c_str(), line);
02613                     ArrayOfRefs[level]=details;
02614                 }
02615             }
02616         };
02617 
02618         TRACE(_T("Debug trace"));
02619         StackWalker s;
02620         s.Walk();
02621         // look 4 deep into the stack frame
02622         if (s.ArrayOfRefs[5].Length() >= 3)
02623             location=(const TCHAR *)(s.ArrayOfRefs[5]);
02624 #endif
02625 #endif
02626 
02627         DisableSystem();
02628     
02629         Progress::Smash(TRUE); // smash the progress bar
02630         
02631         // Relase the mouse if captured
02632         wxWindow *pCapture=wxWindow::GetCapture();
02633         if (pCapture)
02634             pCapture->ReleaseMouse();
02635     
02636         if (Error::ErrorBoxRecurse)
02637         {
02638             INT32 result=wxYES;
02639 
02640             // We're in an error box - don't ask the error system to put up the box, do it manually
02641             if (InInitOrDeInit)
02642             {
02643             // We'll try and get the string for the message box from resources. If the resource system is dead,
02644                 // they won't be able to carry on working anyway.
02645                 String_256 PortentOfDoom(_R(IDS_DOOMMESSAGE2));
02646                 String_256 TitleOfDoom(_R(IDS_DOOMTITLE));
02647                 result = ::wxMessageBox(wxString((TCHAR *)PortentOfDoom), wxString((TCHAR *)TitleOfDoom), wxICON_ERROR); // this will be wxOK, not wxYES
02648             }
02649             else
02650             {
02651                 // We'll try and get the string for the message box from resources. If the resource system is dead,
02652                 // they won't be able to carry on working anyway.
02653                 String_256 PortentOfDoom(_R(IDS_DOOMMESSAGE));
02654                 String_256 TitleOfDoom(_R(IDS_DOOMTITLE));
02655                 result = ::wxMessageBox(wxString((TCHAR *)PortentOfDoom), wxString((TCHAR *)TitleOfDoom), wxICON_ERROR | wxYES_NO);
02656             }
02657         
02658             if (InInitOrDeInit || (result != wxYES))
02659             {
02660                 recursionguard--;
02661                 return; // drop back into exception handler so as to quit.
02662             }
02663         }
02664         else
02665         {
02666             // Use InformGeneral - this gives us the chance to produce a debug report
02667             BOOL Quit=TRUE;
02668 
02669             if (InInitOrDeInit)
02670                 Quit = ::InformGeneral(ERRORTYPE_SERIOUS, 0, _R(IDS_DOOMMESSAGE2),
02671                                         _R(IDS_DOOMQUITNOW), 0, 0, 0,
02672                                         1, 1);
02673             else
02674                 Quit = (::InformGeneral(ERRORTYPE_SERIOUS, 0, _R(IDS_DOOMMESSAGE),
02675                                         _R(IDS_DOOMSAVEWORK), _R(IDS_DOOMQUITNOW), 0, 0,
02676                                         1, 1) != 1);
02677 
02678             if (InInitOrDeInit || Quit)
02679             {
02680                 recursionguard--;
02681                 return; // drop back into exception handler so as to quit.
02682             }
02683         }
02684 
02685     
02686         if ( Error::IsInRenderThread() )
02687         {
02688             TRACE( _T("In RenderThread so clearing up system"));
02689             Error::RenderThreadReset();
02690             CamProfile::AtBase(CAMPROFILE_OTHER);
02691         }
02692     
02693         GBrush::ResetOnFatalError(); // this clears an annoying ensure
02694     
02695         if (IsDisabled()) // Error box routines can enable it
02696             EnableSystem();
02697 
02698         recursionguard--;
02699     
02700         // Zap out main loop pointer
02701 #if !defined(__WXMAC__)
02702         m_mainLoop=NULL;
02703 #endif
02704 
02705     } while(0);
02706     
02707     // We'd like to jump back into the main loop. We can't throw() as allegedly this doesn't work through
02708     // gtk's stack frames (being C not C++) on some compilers sometimes. And destroying things might
02709     // be bad. We don't do setjmp/longjmp as that would leave objects on the stack in a state where they
02710     // are allocated but would be trampled on. So what we do is run another stack frame inside ourselves
02711     // which is a little nasty. We simulate the wx event loop from wxEntryReal.
02712     // Do not return, as this will do an abort().
02713     exit(RunFalseMainLoop());
02714 }

void CCamApp::OnFileOpen  ) 
 

Displays the File Open dialog and opens whichever file was selected.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
14/2/95

Definition at line 1346 of file camelot.cpp.

01347 {
01348 #ifndef EXCLUDE_FROM_RALPH
01349     // Build the list of filters
01350     INT32 NativeFilterPos = 0;
01351     TCHAR* pFilters = OpenFileDialog::BuildFilterString(&NativeFilterPos);
01352 
01353     TRACEUSER( "luke", _T("Filters = %s"), pFilters );
01354 
01355     // Set up the dialog
01356     OpenFileDialog OpenDialog(pFilters);
01357     OpenDialog.NativeFilterPos = NativeFilterPos;
01358     OpenDialog.PrepareDialog();     
01359     
01360     // Display the dialog and get the filename we require
01361     BOOL Result = OpenDialog.OpenAndGetFileName();
01362 
01363     // Free up the memory allocated by BuildFilterString
01364     CCFree(pFilters);
01365 
01366     // If they did not click on OK then stop right now
01367     if (!Result)
01368         return;
01369 
01370     // Remember the filter for later in the opening sequence
01371     OpenDialog.SelectedFilter = OpenDialog.GetSelectedFilterIndex();
01372 
01373     // Get the filename, ensuring that the path is valid
01374     PathName Path;
01375     OpenDialog.GetChosenFileName(&Path);
01376     String_256 Str = Path.GetPath();
01377 
01378     // Extract directory name (minus terminating backslash) and remember for next time.
01379     OpenDialog.SetDefaultPath(Path.GetLocation(FALSE));
01380 
01381     // Andy Hills, 05-02-2001
01382     // Fix for bug 6712:
01383 
01384     // Delete the preview bitmap, if present.
01385     // If we don't delete it here, when we call OpenDocumentFile (below)
01386     // all global bitmaps are deleted (as part of the process of closing all
01387     // existing documents), including the preview bitmap.
01388     // Unfortunately, the OILBitmap is deleted without deleting the
01389     // KernelBitmap which owns it; thus, at the end of this function, when the
01390     // file dialogue is destructed, Camelot tries to destruct the preview
01391     // bitmap even though its ActualBitmap has already been deleted, causing
01392     // an access violation.
01393     // It is safer to destroy both the kernel bitmap and (implicitly) its
01394     // OILBitmap here.
01395 
01396 PORTNOTE( "other" ,"Removed open preview clean-up" )
01397 #ifndef EXCLUDE_FROM_XARALX
01398     // There is a more general problem, in that when we close all documents
01399     // we get rid of all global bitmaps. I don't believe it is safe to assume
01400     // that all global bitmaps belong to the documents which are being closed.
01401     // I.e. I think we should only delete bitmaps which we are sure belong to
01402     // the documents.
01403     if (OpenDialog.pBitmapToUse != NULL)
01404     {
01405         delete OpenDialog.pBitmapToUse;
01406         OpenDialog.pBitmapToUse = NULL;
01407     }
01408 #endif
01409 
01410     // and open the file. if returns NULL, the user has already been alerted
01411     wxDocument* pDoc = OpenDocumentFile( Str );
01412     if (pDoc!=NULL)
01413     {
01414         // Make sure that the files name is sensible
01415         MakeDocumentNative(pDoc, &Path);
01416         
01417         // add it to the recent file list
01418         AddToRecentFileList( PCTSTR(Str) );
01419 
01420         // ... and set the path as the "original" path to the doc.  This will be used to 
01421         // "restore" the doc when we next run, if it was open when we shut down.
01422         ((CCamDoc*) pDoc)->SetOriginalPath(Str);
01423     }
01424 #endif
01425 }

void CCamApp::OnFilePrintSetup  ) 
 

void CCamApp::OnHelpIndex  ) 
 

void CCamApp::OnIdle wxIdleEvent &  event  ) 
 

bool CCamApp::OnInit  ) 
 

Definition at line 600 of file camelot.cpp.

00601 {
00602     InInitOrDeInit = TRUE; // Don't allow the user to try carrying on working
00603     ::wxHandleFatalExceptions(TRUE);
00604 
00605     //
00606     // Parse command line. We do this early so we get flags which
00607     // are useful for init, such as -u
00608     //
00609     wxCmdLineParser parser(argc,argv);
00610     parser.SetDesc(cmdLineDesc);
00611     if (parser.Parse()) // Handles help automatically
00612     {
00613         return FALSE;
00614     }
00615 
00616     wxString ResourceDir = _T("");
00617     if (parser.Found(_T("r"), &ResourceDir))
00618     {
00619         if (!ResourceDir.IsEmpty())
00620         {
00621             CamResource::SetResourceFilePath(ResourceDir);
00622         }
00623 
00624         if ( parser.Found( _T("x") ) )
00625         {
00626             CamResource::SetGenerateXRCCheck(TRUE);
00627         }
00628     }
00629 
00630     if( parser.Found( _T("v") ) )
00631     {
00632         wxString            strMessage;
00633 
00634 #if defined(__WXMSW__)
00635         strMessage = wxString::Format( wxT("Xara Xtreme\nVersion: %s\nCDraw Version: %d.%03d\n"), 
00636             g_pszAppVersion, HIWORD(GDraw_GetVersion()), LOWORD(GDraw_GetVersion()) );
00637 #else
00638 #if FALSE == wxUSE_UNICODE
00639         TCHAR*          pszCDrawVer = GDraw_GetSvnVersion();
00640 #else
00641         TCHAR           pszCDrawVer[32];
00642         camMbstowcs( pszCDrawVer, GDraw_GetSvnVersion(), 31 );
00643 #endif
00644         strMessage = wxString::Format( wxT("Xara Xtreme\nVersion: %s (%s)\nCDraw Version: %d.%03d (%s)\nBuild date: %s\n"), 
00645             g_pszAppVersion, g_pszSvnVersion, HIWORD(GDraw_GetVersion()), LOWORD(GDraw_GetVersion()), pszCDrawVer, CAMELOT_BUILD_DATE );
00646 #endif
00647 
00648         camPrintf( strMessage.c_str() );
00649         
00650         return FALSE;
00651     }
00652     
00653 #if defined(_DEBUG)
00654     if (parser.Found(_T("m"))) SimpleCCObject::CheckMemoryFlag=1;
00655 
00656     long listlevel; // TYPENOTE: Correct - wxWidgets doesn't know about INT32 etc.
00657     if (parser.Found(_T("l"), &listlevel))
00658     {
00659         List::ListDebugLevel = listlevel;
00660     }
00661 
00662     // Set up the username for tracing
00663     // We should default this to the environment setting for (say) LOGNAME
00664     wxString Username = _T("");
00665 
00666     // Overwrite with LOGNAME if it is set
00667     wxGetEnv(_T("LOGNAME"), &Username);
00668 
00669     // Overwrite with -u option if it is set
00670     parser.Found(_T("u"), &Username);
00671 
00672     Error::SetUserName(Username);
00673 
00674     if (Username==_T(""))
00675     {
00676         TRACEUSER("ALL", _T("No user specific trace output\n"));
00677     }
00678     else
00679     {
00680 //      TRACEUSER("ALL",_T("Tracing output where user is %s\n"),(const char *)Username.mb_str(wxConvUTF8));
00681         TRACEUSER("ALL",_T("Tracing output where user is %s\n"),(const TCHAR *)Username.c_str());
00682     }
00683 
00684     TRACEUSER("ALL",_T("Memory debugging %d, List debugging %d\n"), SimpleCCObject::CheckMemoryFlag, List::ListDebugLevel);
00685 
00686 #endif
00687 
00688     // OK, now we've handled the help case, and some VERY early init, we should see if another instance
00689     // is running.
00690 
00691     // Set and check for single instance running
00692     wxString SIname = wxString(_T(".XARA-XTREME-WX-"))  +GetAppName()+wxString::Format(_T("-%s"), wxGetUserId().c_str());
00693     wxFileName IPCfn(wxGetHomeDir(),SIname+_T(".ipc"));
00694     wxString IPCname = IPCfn.GetFullPath();
00695 
00696     m_pSingleInstanceChecker = NULL;
00697     m_pServer = NULL;
00698 
00699 #ifdef _DEBUG
00700     BOOL SingleInstanceCheck = FALSE;
00701 #else
00702     BOOL SingleInstanceCheck = TRUE;
00703 #endif
00704 
00705     if (SingleInstanceCheck)
00706     {
00707         // Create a single instance checker at that location
00708         m_pSingleInstanceChecker = new wxSingleInstanceChecker(SIname);
00709         if (!m_pSingleInstanceChecker)
00710         {
00711             ERROR2(FALSE, "Failed to create single instance checker");
00712         }
00713     
00714         // Now see if another is running
00715         if (m_pSingleInstanceChecker->IsAnotherRunning())
00716         {
00717             wxClient Client;
00718             wxConnectionBase * Connection = Client.MakeConnection(wxEmptyString, IPCname, camIPC_START);
00719     
00720             // If there is no connection, perhaps the other end is dead. We will start up anyway.
00721             if (Connection)
00722             {
00723                 INT32 len=1; // terminating null
00724                 INT32 i;
00725     
00726                 wxArrayString docs;
00727                 INT32 doccount = parser.GetParamCount()+1; // add one for the dummy
00728     
00729                 // Add all docs with a dummy argv[0]
00730                 for ( i=0 ; i<doccount; i++ )
00731                 {
00732                     wxString docname;
00733                     if (i)
00734                     {
00735                         docname = parser.GetParam(i-1);
00736                         wxFileName fn(docname);
00737                         fn.Normalize(wxPATH_NORM_ALL);
00738                         docname=fn.GetFullPath();
00739                     }
00740                     else
00741                     {
00742                         docname=argv[0];
00743                     }
00744                     len+=docname.length()+1; // include the trailing zero
00745                     docs.Add(docname);
00746                 }
00747     
00748                 wxChar * Data = new wxChar[len];
00749                 if (!Data)
00750                 {
00751                     ERROR2(FALSE, "Failed to create single instance checker data");
00752                 }
00753     
00754                 // Copy the 
00755                 wxChar * p = Data;
00756                 for (i = 0; i < doccount; i++)
00757                 {
00758                     wxStrcpy(p, docs[i]);
00759                     p+=docs[i].length()+1; // move past string and terminating NULL
00760                 }
00761                 *p = _T('\0'); // add a final terminating NULL
00762     
00763                 // Now send the data over the connection
00764                 if (Connection->Execute (Data, len*sizeof(wxChar)))
00765                 {
00766                     delete [] Data;
00767                     delete Connection;
00768     
00769                     //.Free up the single instance checker
00770                     delete m_pSingleInstanceChecker;
00771                     m_pSingleInstanceChecker = NULL;
00772     
00773                     // We're out of here...
00774                     return FALSE;
00775                 }
00776     
00777                 // Hmmmm, it didn't want to execute it. perhaps the other process is stuck. We'll run anyway
00778                 delete [] Data;
00779                 delete Connection;
00780             }
00781         }
00782     }
00783 
00784     // OK, we are the only instance running. Delete any stale socket (ours has not been created yet).
00785     ::wxRemoveFile(IPCname);
00786 
00787     // Register the image handler which loads CURs (used for Cursors, obviously)
00788     wxImage::AddHandler( new wxCURHandler );
00789 
00790     // Register the image handler which loads PNGs (used for TBs)
00791     wxImage::AddHandler( new wxPNGHandler );
00792 
00793     // Init the BinReloc stuff (we don't really care if this fails, since it
00794     // fails safe)
00795     BrInitError error;
00796     br_init( &error );
00797     
00798     // Useful debug tracing enablers, left here for next debug session...
00799 //  wxLog::AddTraceMask( _T("focus") );
00800 //  wxLog::AddTraceMask( _T("keyevent") );
00801 
00802     // Initialise the MonotonicTime class
00803     MonotonicTime::Init();
00804 
00805     // We initialize profiling here to allow the rest of the app to be profiled
00806     CamProfile::Init();
00807     // Don't start profiling until Alex has finished the code!
00808     CamProfile::ActivateProfiling(TRUE);
00809     // Indicate time from now on should be assigned to "OTHER"
00810     CamProfile::AtBase(CAMPROFILE_OTHER);
00811 
00812     TRACET(_T("CCamApp::OnInit first available time to trace"));
00813 
00814     // Initialize resources system
00815     if (!CamResource::Init()) return FALSE;
00816     // Initialize the art provider - needed for dialogs
00817     wxPlatformDependent::Init(CLASSINFO(CamPlatformDependent));
00818     if (!CamArtProvider::Init()) return FALSE;
00819     // We need this pretty early so we can handle ERROR boxes etc
00820     if (!DialogEventHandler::Init()) return FALSE;
00821     if (!ControlList::Init()) return FALSE;
00822 
00823     TRACET(_T("CCamApp::Calling Camelot.Init"));
00824 
00825     // Initialise the kernel application object & Prefs
00826     if( !Camelot.Init() )
00827         return false;
00828 
00829     // --------------------------------------------------------------------------
00830     // Detect first-time run and make Open File dialog default to Examples folder
00831     if (Camelot.DeclareSection(TEXT("Preferences"), 10))
00832     {
00833         Camelot.DeclarePref(NULL, TEXT("FirstRun"), &bFirstRun, 0, 1);
00834     }
00835 
00836     // Check the resource dir exists
00837     Camelot.DeclarePref( NULL, TEXT("ResourceDirOverride"), &m_strResourceDirPathOverride );
00838     m_strResourceDirPath = m_strResourceDirPathOverride; // this way, the path we find never gets put within the preferences
00839     if( /*bFirstRun ||*/ m_strResourceDirPath == _T("") || !wxDir::Exists( (PCTSTR)m_strResourceDirPath ) ) // AB: don't need to do this on first run especially
00840     {
00841 #if !defined(RESOURCE_DIR)
00842         // we can't use auto pointers here because they free using delete but BR allocates using malloc (strdup actually)
00843         char * pszDataPath = br_find_data_dir( "/usr/share" );
00844         if (pszDataPath)
00845         {
00846             m_strResourceDirPath = wxString( pszDataPath, wxConvFile );
00847             free(pszDataPath);
00848             m_strResourceDirPath += _T("/xaralx");
00849             TRACEUSER( "luke", _T("Using resource directory \"%s\"\n"), PCTSTR(m_strResourceDirPath) );
00850 #if defined(_DEBUG)
00851             if( !wxDir::Exists( PCTSTR(m_strResourceDirPath) ) )
00852             {
00853                 // We'll try default location under debug to make life easier
00854                 m_strResourceDirPath = _T("/usr/share/xaralx");
00855                 TRACEUSER( "luke", _T("Try = \"%s\"\n"), PCTSTR(m_strResourceDirPath) );
00856             }
00857 #endif
00858         }
00859 #else
00860         // The "" is needed to stop the macro expanding to LRESOURCE_DIR
00861         m_strResourceDirPath = _T(""RESOURCE_DIR);
00862 #endif
00863     }
00864     TRACEUSER( "luke", _T("ResDir = %s\n"), PCTSTR(m_strResourceDirPath) );
00865 
00866     // Get the media replay application setting
00867     Camelot.DeclarePref( NULL, TEXT("MediaApplication"), &m_strMediaApplication );
00868 
00869     TRACET(_T("CCamApp::Calling InitKernel"));
00870     // then initialise the kernel (and almost everything else)  
00871     if( !InitKernel() )
00872         return false;
00873 
00874     if( !Camelot.LateInit() )
00875         return false;
00876 
00877     TRACET(_T("CCamApp::Calling GRenderRegion::Init"));
00878     if (!GRenderRegion::Init(true))
00879         return false;
00880 
00881     // Declare the prefs for the window size and state
00882     if (Camelot.DeclareSection(TEXT("Windows"), 10))
00883     {
00884         Camelot.DeclarePref(NULL, TEXT("MainWndMax"), &MainWndMaximized, 0, 1);
00885         Camelot.DeclarePref(NULL, TEXT("MainWndMin"), &MainWndMinimized, 0, 1);
00886         Camelot.DeclarePref(NULL, TEXT("MainWndPos"), &MainWndPosString);
00887     }
00888 
00889     TRACET(_T("CCamApp::Making Doc Manager"));
00890     
00891     // Create the document manager and register our doc template
00892     m_docManager = std::auto_ptr<wxDocManager>( new wxDocManager() );
00893 
00894     wxDocTemplate      *pDocTemplate;
00895     pDocTemplate = new CCamDocTemplate(
00896         m_docManager.get(), wxT("Xara"), wxT("*.xar;*.web"), wxT(""), wxT("xar"), wxT("Xara document"), 
00897         wxT("Text View"),
00898         CLASSINFO(CCamDoc),
00899         CLASSINFO(CCamView) );
00900 //  pDocTemplate = new CCamDocTemplate(
00901 //      m_docManager.get(), wxT("Xara"), wxT("*.web"), wxT(""), wxT("web"), wxT("Xara document"), 
00902 //      wxT("Text View"),
00903 //      CLASSINFO(CCamDoc),
00904 //      CLASSINFO(ScreenCamView) );
00905 
00906     // Reload the file history (9 entries)
00907     wxFileHistory*      pFileHist = m_docManager->GetFileHistory();
00908     for( UINT32 ord = 0; ord < 9; ++ord )
00909     {
00910         // This is safe since we control all variables!
00911         TCHAR           pszTag[8];
00912         camSprintf( pszTag, _T("File%d"), ord );
00913 
00914         String_256      strFileName;
00915         Camelot.GetPrefDirect( _T("Recent File list"), pszTag, &strFileName );
00916         
00917         if( strFileName != _T("") )
00918             pFileHist->AddFileToHistory( PCTSTR(strFileName) );
00919     }
00920 
00921     if (bFirstRun)
00922     {
00923         // Set File Open dialog location to our Examples folder
00924         wxString    strConfigPath( (TCHAR*)m_strResourceDirPath );
00925         strConfigPath += _T("/Examples");
00926 
00927 #if defined(_DEBUG)
00928         // Debug-only fallback
00929         if (!wxDir::Exists(strConfigPath))
00930             strConfigPath = _T("/usr/share/xaralx/Examples");
00931 #endif
00932 
00933         if (wxDir::Exists(strConfigPath))
00934             BaseFileDialog::DefaultOpenFilePath = strConfigPath;
00935     }
00936 
00937     // NOTE! Set bFirstRun = FALSE in OnExit handler below
00938     // --------------------------------------------------------------------------
00939 
00940     // Set idles to only get sent to windows that want them
00941     wxIdleEvent::SetMode(wxIDLE_PROCESS_SPECIFIED); 
00942 
00943     // Create the Frame window
00944     //
00945     // get user preference info for main window
00946     wxSize ScreenSize = ::wxGetDisplaySize();
00947     wxRect WndRect;
00948     wxSize OldScreenSize;
00949     if ((camSscanf(MainWndPosString, _T("%d %d %d %d %d %d"),
00950             &WndRect.x, &WndRect.y, &WndRect.width, &WndRect.height, &OldScreenSize.x, &OldScreenSize.y) == 6) &&
00951             (WndRect.width > 0) && (WndRect.height > 0))
00952     {
00953         // numbers scanned OK, scale them to fit current screen size
00954         if (OldScreenSize.x != ScreenSize.x)
00955         {
00956             // if screen size different from last time, them scale them
00957             WndRect.x = MulDiv(WndRect.x, ScreenSize.x, OldScreenSize.x);
00958             WndRect.width = MulDiv(WndRect.width, ScreenSize.x, OldScreenSize.x);
00959         }
00960         if (OldScreenSize.y != ScreenSize.y)
00961         {
00962             WndRect.y = MulDiv(WndRect.y, ScreenSize.y, OldScreenSize.y);
00963             WndRect.height = MulDiv(WndRect.height, ScreenSize.y, OldScreenSize.y);
00964         }
00965     }
00966     else
00967     {
00968         // make up a sensible default position for the window, inset five percent
00969         // in x and 10 percent in y to avoid taskbars on linux
00970         WndRect.x = ScreenSize.x / 20;
00971         WndRect.width = ScreenSize.x - WndRect.x * 2;
00972         WndRect.y = ScreenSize.y / 10;
00973         WndRect.height = ScreenSize.y - WndRect.y * 2;
00974     }
00975 
00976     TRACET(_T("CCamApp::Making Frame Window"));
00977     m_pMainFrame = new CCamFrame( m_docManager.get(), (wxFrame *)NULL, wxT("Xara Xtreme"), 
00978         WndRect.GetPosition(), WndRect.GetSize(), wxDEFAULT_FRAME_STYLE);
00979 
00980     m_pMainFrame->Show(FALSE); // Don't show it yet
00981 
00982 #if !defined(XARA_MENUGEN)
00983     TRACET(_T("CCamApp::Making Menu structure"));
00984     //
00985     // Build the MDI style file menu
00986     // This is just a simple menu. The full menu is created
00987     // after loading a document.
00988     //
00989     wxMenu* pFileMenu = new wxMenu;
00990 
00991     pFileMenu->Append( wxID_NEW,  wxT("&New...") );
00992     pFileMenu->Append( wxID_OPEN, wxT("&Open...") );
00993 
00994 #if defined(FILELIST)
00995     wxMenu* pRecentFilesMenu = new wxMenu;
00996     m_docManager->FileHistoryUseMenu(pRecentFilesMenu);
00997     m_docManager->FileHistoryAddFilesToMenu(pRecentFilesMenu);
00998 
00999     pFileMenu->AppendSeparator();
01000     pFileMenu->Append( -1, wxT("&Recent files"),pRecentFilesMenu );
01001 #endif //defiend(FILELIST)
01002 
01003     pFileMenu->AppendSeparator();
01004     pFileMenu->Append( wxID_EXIT, wxT("E&xit") );
01005 
01006     // Build help menu
01007     wxMenu             *pHelpMenu = new wxMenu;
01008     pHelpMenu->Append( _R(DOCVIEW_ABOUT), wxT("&About...") );
01009 
01010     // Place menus into the menu bar
01011     wxMenuBar          *pMenuBar = new wxMenuBar;
01012     pMenuBar->Append( pFileMenu, wxT("File") );
01013     pMenuBar->Append( pHelpMenu, wxT("Help") );
01014 
01015 #ifdef __WXMAC__
01016     wxMenuBar::MacSetCommonMenuBar( pMenuBar );
01017 #endif //def __WXMAC__
01018 
01019     // Set up menu bar...
01020     m_pMainFrame->SetMenuBar( pMenuBar );
01021 
01022 #else
01023 
01024 #ifdef __WXMAC__
01025     wxMenuBar::MacSetCommonMenuBar( WinMDIMenu );
01026 #endif //def __WXMAC__
01027 
01028     // Set up menu bar...
01029     m_pMainFrame->SetMenuBar( WinMDIMenu );
01030     WinMDIMenu->ClearAccelTable();
01031 
01032 #endif
01033 
01034     // We don't want auto-accelerators, this is done using our hotkeys
01035     // I don't know how to do this yet, but I'm looking....
01036 //  wxAcceleratorTable* pAccelTable = pMenuBar->GetAccelTable();
01037 //  *pAccelTable = wxAcceleratorTable();
01038 
01039     TRACET(_T("CCamApp::Init Setting mainframe as top window"));
01040 
01041     m_pMainFrame->CreateToolbars();
01042     m_pMainFrame->UpdateFrameManager();
01043 
01044     // Show the main frame window
01045     // make maximized if thats what we were last time, unless overridden by user
01046     if (MainWndMaximized)
01047     {
01048         m_pMainFrame->Maximize();
01049     }
01050     if (MainWndMinimized)
01051     {
01052         m_pMainFrame->Iconize();
01053     }
01054     SetTopWindow( m_pMainFrame );
01055     ::wxYield(); // allow resizing to take place
01056     m_pMainFrame->Show( true );
01057     ::wxYield(); // allow resizing to take place
01058     wxPlatformDependent::Get()->FixUpdate(m_pMainFrame); // Force the main frame to be redrawn properly
01059     ::wxYield(); // allow resizing to take place
01060 
01061 #ifndef EXCLUDE_FROM_XARALX
01062     m_pMainFrame->CacheNormalPlaceMode();
01063     m_pMainFrame->CheckFullScreenMode();
01064 
01065     // if the splash box is up, draw our window behind it (will be a big pending WM_PAINT)
01066     // IT MUST NOT BE ACTIVE else palette problems
01067     if (AfxOleGetUserCtrl())
01068     {
01069         if (m_nCmdShow == SW_SHOWMINIMIZED || m_nCmdShow == SW_SHOWMINNOACTIVE)
01070         {
01071             pMainFrame->ShowWindow(SW_SHOWMINNOACTIVE);
01072         }
01073         else
01074         {
01075             if (m_nCmdShow == SW_SHOWMAXIMIZED)
01076                 m_pMainWnd->ShowWindow(SW_SHOWMAXIMIZED);
01077             else
01078                 pMainFrame->ShowWindow(SW_SHOWNOACTIVATE);
01079 
01080             // the ShowWindow() above has made the main window active so make the splash box active, else
01081             // we get nasty palette problems later on
01082             pSplashbox->SetActiveWindow();
01083         }
01084     }
01085 #endif
01086 
01087     Tool::SelectFirstTool();
01088 
01089     // Go through the command line and load documents
01090     TRACET(_T("CCamApp::Init Loading docs (if any) from command line"));
01091 
01092     if( 0 == parser.GetParamCount() )
01093         m_docManager->CreateDocument( _T(""), wxDOC_NEW );
01094     else
01095     {
01096         for ( UINT32 i=0 ; i<parser.GetParamCount() ; i++ )
01097             m_docManager->CreateDocument(parser.GetParam(i),wxDOC_SILENT);
01098     }
01099 
01100     // Remove the splash screen
01101     CamResource::DoneInit();
01102 
01103     CXMLUtils::Initialise();
01104 
01105     if (SingleInstanceCheck)
01106     {
01107         // We are able to load documents, so now start our own IPC server
01108         m_pServer = new CamIPCServer();
01109         if (!m_pServer)
01110         {
01111             delete (m_pSingleInstanceChecker);
01112             m_pSingleInstanceChecker = NULL;
01113             ERROR2(FALSE, "Failed to create IPC server");
01114         }
01115     
01116         // and initialize it
01117         if (!(m_pServer->Create(IPCname)))
01118         {
01119             delete m_pServer;
01120             m_pServer = NULL;
01121     
01122             delete (m_pSingleInstanceChecker);
01123             m_pSingleInstanceChecker = NULL;
01124             ERROR2(FALSE, "Failed to init IPC server");
01125         }
01126     }
01127 
01128     // Give focus to any child that will take it, parent can't have it since
01129     // it's a frame (see gtk_widget_grab_focus)
01130     GiveFocusToFocusableOffspring( m_pMainFrame );
01131     
01132     // Create timer used for background rendering.
01133 //  m_Timer.SetOwner(this,CAM_TIMER_ID);
01134 //  m_Timer.Start(CAM_TIMER_FREQUENCY);
01135 
01136     InInitOrDeInit = FALSE; // Now allow the user a chance to save their work on a SEGV
01137 
01138     return true;
01139 }

bool CCamApp::OnRecentFile INT32  RecentFileNumber  ) 
 

Loads in one of the recently opened documents that are in the 'Recent File List' near the bottom of the File Menu.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/1/95
Parameters:
RecentFileNumber - The number of the file in the Recent File list to open [INPUTS]
Returns:
TRUE if it loaded the file ok, FALSE if it failed

Definition at line 1715 of file camelot.cpp.

01716 {
01717     wxFileHistory*  pFileHist = m_docManager->GetFileHistory();
01718 
01719     if( RecentFileNumber < INT32(pFileHist->GetCount()) )
01720     {
01721         wxString    FileName( pFileHist->GetHistoryFile( RecentFileNumber ) );
01722 
01723         // Get the App to open the File
01724         if (!FileName.IsEmpty())
01725         {
01726             // See if we got a document out of the deal
01727             wxDocument* pDoc = m_docManager->CreateDocument( FileName, wxDOC_SILENT );
01728             if( pDoc != NULL )
01729                 return true;
01730         }
01731     }
01732 
01733     // Failed to find an entry for this item
01734     return false;   
01735 }

BOOL CCamApp::OnSecondInstance wxChar **  argv,
INT32  argc = 0
 

Definition at line 580 of file camelot.cpp.

00581 {
00582     // Parse command line. We do this early so we get flags which
00583     // are useful for init, such as -u
00584     //
00585     wxCmdLineParser parser(argc,argv);
00586     parser.SetDesc(cmdLineDesc);
00587     if (parser.Parse()) // Handles help automatically
00588     {
00589         return FALSE;
00590     }
00591     if (parser.GetParamCount()>=1)
00592     {
00593         for ( UINT32 i=0 ; i<parser.GetParamCount() ; i++ )
00594             m_docManager->CreateDocument(parser.GetParam(i),wxDOC_SILENT);
00595     }
00596     m_pMainFrame->Raise();
00597     return TRUE;
00598 }

void CCamApp::OnTimer wxTimerEvent &  event  ) 
 

wxDocument * CCamApp::OpenDocumentFile PCTSTR  lpcszFileName  )  [private]
 

We override this implementation function so that when the user tries to load a document that is already loaded, we can display a dialog box with various load options, instead of simply bringing the document's view to the front.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/7/95
Parameters:
lpcszFileName path to the document file to load [INPUTS]
Returns:
A pointer to the MFC CDocument object that manages the opened file, or NULL if it can't be loaded for some reason.
This function is largely copied from the MFC equivalent in APPUI.CPP.
Returns:
Errors: -
See also:
-

Definition at line 1467 of file camelot.cpp.

01468 {
01469     // find the highest confidence
01470 
01471     wxList&             listTemplates( GetDocumentManager()->GetTemplates() );
01472     wxNode*             pNode = listTemplates.GetFirst();
01473 
01474     CCamDocTemplate::Confidence bestMatch = CCamDocTemplate::noAttempt;
01475     CCamDocTemplate*    pBestTemplate = NULL;
01476     wxDocument*         pOpenDocument = NULL;
01477     wxDocument*         pNewDoc       = NULL;
01478 
01479     TCHAR               szPath[_MAX_PATH + 1];
01480     {
01481         wxFileName      FileName( lpcszFileName );
01482         camStrncpy( szPath, FileName.GetFullPath(), _MAX_PATH );
01483     }
01484 
01485     while (pNode != NULL)
01486     {
01487         CCamDocTemplate* pTemplate = (CCamDocTemplate*)pNode->GetData();
01488         ASSERT( pTemplate->IsKindOf( CLASSINFO(CCamDocTemplate) ) );
01489 
01490         CCamDocTemplate::Confidence match;
01491         ASSERT(pOpenDocument == NULL);
01492         match = pTemplate->MatchDocType(szPath, pOpenDocument);
01493 
01494         if (match > bestMatch)
01495         {
01496             bestMatch = match;
01497             pBestTemplate = pTemplate;
01498         }
01499 
01500         if (match == CCamDocTemplate::yesAlreadyOpen) break;
01501 
01502         pNode= pNode->GetNext();
01503     }
01504 
01505     if (pOpenDocument != NULL)
01506     {
01507         // Make sure it really is one of ours.
01508         ERROR3IF( !pOpenDocument->IsKindOf( CLASSINFO(CCamDoc) ),
01509                     _T("Not a CCamDoc in CCamApp::OpenDocumentFile") );
01510 
01511         wxList&         lstViews( pOpenDocument->GetViews() );
01512         wxNode*         pNode = lstViews.GetFirst();
01513         if( NULL != pNode )
01514         {
01515             // Get the first view.
01516             wxView*     pView = (wxView*)pNode->GetData();
01517             wxMDIChildFrame* pFrame = (wxMDIChildFrame*)pView->GetFrame();
01518             
01519             // Now deal with the view window.
01520             if (pFrame != NULL)
01521             {
01522                 // Run a message box to find out what the user wants to do on trying
01523                 // to load a document that is already loaded.  To begin, if we can't
01524                 // find a document template just bring the view to the front.
01525                 if (pBestTemplate == NULL)
01526                 {
01527                     pFrame->Activate();
01528                 }
01529                 else
01530                 {
01531                     // If the document is modified then we may have to ask the user what they
01532                     // want to do, ie. revert to original, load copy, do nothing.
01533                     INT32 nResult;
01534                     if (pOpenDocument->IsModified())
01535                     {
01536                         // OK, we have a modified document.  Run the message box to find out what
01537                         // the user wants to do.
01538                         nResult = InformWarning( _R(IDE_DOC_ALREADY_OPEN),
01539                                                 _R(IDS_REVERT_BTN), _R(IDS_DETACH_BTN), _R(IDS_CANCEL), 0,
01540                                                 2, 3);
01541                     }
01542                     else
01543                     {
01544                         // If the document isn't modified then force a "load copy".
01545                         // no if the document is already loaded just keep the view we have (sjk 3/2/00)
01546                         nResult = 3;
01547                     }
01548 
01549                     switch (nResult)
01550                     {
01551                     case 1:
01552                     {
01553                         // REVERT.  Reload the already-open doc, discarding unsaved changes.
01554                         ((CCamDoc*) pOpenDocument)->SetModified(FALSE);
01555                         pOpenDocument->OnCloseDocument();
01556                         pNewDoc = pBestTemplate->CreateDocument( szPath );
01557                         goto PerformLoad;
01558                     }
01559 
01560                     case 2:
01561                     {
01562                         // DETACH.  Load the doc as an "untitled" one, making sure it won't
01563                         // save over the already-open doc.
01564                         wxDocument* pCopyDoc = pBestTemplate->CreateDocument( szPath );
01565                         if (pCopyDoc != NULL)
01566                         {
01567                             // We managed to load the doc to detach, so now we detach it.
01568                             // To do this we set its path to nothing, after saving the
01569                             // original path.
01570                             ((CCamDoc*) pCopyDoc)->SetOriginalPath(szPath);
01571                             ((CCamDoc*) pCopyDoc)->SetPathNameEmpty();
01572                             ((CCamDoc*) pCopyDoc)->SetCopy(TRUE);
01573 
01574                             goto PerformLoad;
01575                         }
01576                     #ifdef _DEBUG
01577                         else
01578                         {
01579                             // Oh no, we failed to load the detached doc, so we have to
01580                             // fail this one.
01581                             TRACEUSER("JustinF", _T("Couldn't load doc to detach!\n") );
01582                             pFrame->Activate();
01583                         }
01584                     #endif                      
01585                         return NULL;
01586                     }
01587 
01588                     case 3:
01589                         // CANCEL.  Don't load, just bring the already-open doc to the front.
01590                         pFrame->Activate();
01591                         break;
01592 
01593                     default:
01594                         ERROR3( _T("Bad return val from message box in CCamApp::OpenDocumentFile") );
01595                         break;
01596                     }
01597                 }
01598             }
01599             else
01600                 TRACE0( _T("Error: Can not find a frame for document to activate.\n") );
01601         }
01602         else
01603         {
01604             TRACE0( _T("Error: Can not find a view for document to activate.\n") );
01605         }
01606 
01607         return pOpenDocument;
01608     }
01609 
01610     if (pBestTemplate == NULL)
01611     {
01612         String_256      strReport( _R(AFX_IDP_FAILED_TO_OPEN_DOC) );
01613         wxMessageBox( (PCTSTR)strReport );
01614         return NULL;
01615     }
01616 
01617     pNewDoc =  pBestTemplate->CreateDocument( szPath );
01618 
01619 PerformLoad:
01620     if( NULL == pNewDoc )
01621         return NULL;
01622 
01623     pNewDoc->SetDocumentName( pBestTemplate->GetDocumentName() );
01624     pNewDoc->SetDocumentTemplate( pBestTemplate );
01625     if( !pNewDoc->OnOpenDocument( szPath ) )
01626     {
01627         pNewDoc->DeleteAllViews();
01628         pNewDoc = NULL;
01629     }
01630 
01631     return pNewDoc;
01632 }

INT32 CCamApp::RunFalseMainLoop  )  [private]
 

Definition at line 2738 of file camelot.cpp.

02739 {
02740     class cleanupOnExit
02741     {
02742     public:
02743         ~cleanupOnExit() { wxEntryCleanup(); }
02744     } cleanupOnExit;
02745 
02746     Use(&cleanupOnExit); // suppress warning
02747 
02748     wxTRY
02749     {
02750         // ensure that OnExit() is called if OnInit() had succeeded
02751         class CallOnExit
02752         {
02753         public:
02754             ~CallOnExit() { wxTheApp->OnExit(); }
02755         } callOnExit;
02756 
02757         Use(&callOnExit); // suppress warning
02758 
02759         // app execution
02760         return wxTheApp->OnRun();
02761     }
02762     wxCATCH_ALL( wxTheApp->OnUnhandledException(); return -1; )
02763 }

bool CCamApp::SelectMediaApp  )  [static]
 

This function allows a user to select which media replay app. they'd like to use to replay the help movies.

Author:
Luke_Hart (Xara Group Ltd) <camelotdev@xara.com> <luke.hartΩxara.com>
Date:
23/08/06
Parameters:
- [INPUTS]
- [OUTPUTS]
Returns:
true if user accepts new choice

Errors: - Scope: Public

See also:
-

Definition at line 2970 of file camelot.cpp.

02971 {
02972     // Move array into a helpful structure
02973     SelMediaDlgParam::CMediaAppList mapMediaApp;
02974     FillMediaAppMap( &mapMediaApp );
02975 
02976     // First we see if the replay app. is present
02977     CMediaReplayDetect  Detect;
02978 
02979     // Setup param and open replay app selection dialog
02980     SelMediaDlgParam    Param;
02981     Param.m_pAppList = &mapMediaApp;
02982     Param.m_strSel   = m_strMediaApplication;
02983     OpDescriptor* pOpDesc = OpDescriptor::FindOpDescriptor( CC_RUNTIME_CLASS(SelMediaDlg) ); 
02984     if( NULL != pOpDesc )
02985     {
02986         pOpDesc->Invoke( &Param );
02987     
02988         if( Param.m_fValid )
02989             m_strMediaApplication = Param.m_strSel;
02990     }
02991 
02992     // User canceled, bomb out
02993     return Param.m_fValid;
02994 }


Member Data Documentation

BOOL CCamApp::allowRegistryWrite
 

Definition at line 207 of file camelot.h.

BOOL CCamApp::bFirstRun = TRUE [static]
 

If 1 then this is the first time this application has been run with this set of preferences If 0 then it has been run before.

Preference: FirstRun Section: Preferences Range: 0 (FALSE) or 1 (TRUE)

Definition at line 205 of file camelot.h.

BOOL CCamApp::InInitOrDeInit [static, private]
 

Definition at line 195 of file camelot.h.

DialogManager CCamApp::m_DlgMgr [static, private]
 

Definition at line 193 of file camelot.h.

std::auto_ptr<wxDocManager> CCamApp::m_docManager [protected]
 

Definition at line 171 of file camelot.h.

CCamFrame* CCamApp::m_pMainFrame [protected]
 

Definition at line 172 of file camelot.h.

wxServerBase* CCamApp::m_pServer [protected]
 

Definition at line 185 of file camelot.h.

wxSingleInstanceChecker* CCamApp::m_pSingleInstanceChecker [protected]
 

Definition at line 184 of file camelot.h.

String_256 CCamApp::m_strMediaApplication [static, protected]
 

Definition at line 180 of file camelot.h.

String_256 CCamApp::m_strResourceDirPath [static, protected]
 

Definition at line 177 of file camelot.h.

String_256 CCamApp::m_strResourceDirPathOverride [static, protected]
 

Definition at line 178 of file camelot.h.

wxString CCamApp::m_strResourcePath [static, protected]
 

Definition at line 176 of file camelot.h.

wxTimer CCamApp::m_Timer [protected]
 

Definition at line 182 of file camelot.h.

BOOL CCamApp::MainWndMaximized = FALSE [static]
 

If non-zero then main window defaults to maximized, else normal position. This default will be overridden if the user explicitly asked for a mode when starting the app (e.g. minimized). If the user exits while maximized, the flag will be set ready for next time.

/

camelot.cpp - main application class derived from wxApp

/*!/

include "camtypes.h"

include "camdoc.h" include "docview.h" - in camtypes.h [AUTOMATICALLY REMOVED] include "camview.h" include "camframe.h" include "Res/UKEnglish/stringtbl.h" include "kernel.h" include "grndrgn.h" include "oilmenus.h"

if !defined(__WXMSW__) include "gdraw.h" endif

include "cversion.h" include "camelot.h" include "camdoctp.h"

include "keypress.h" include "ccdc.h" include "camprofile.h" include "dlgevt.h" include "cartprov.h" include "ctrllist.h" include "cartctl.h" include "xmlutils.h" include "camplatform.h" include "filedlgs.h" include "progress.h" include "prdlgctl.h" include "prncamvw.h" include "gbrush.h" include "selmedia.h" include "filedlgs.h" include "rendwnd.h"

include "camprocess.h"

Define FILELIST for recent file list on file menu. Note that this currently seems to be rather unreliable.

if defined(_DEBUG) define FILELIST endif

Define XARA_MENUGEN to use Xtreme style menu creation. Note that this currently doesn't have full functionality but it's getting there if defined(_DEBUG) define XARA_MENUGEN endif

BOOL CCamApp::InInitOrDeInit = TRUE; IMPLEMENT_DYNAMIC_CLASS( wxWindowDeletionWatcher, wxObject); WindowToWindowDeletionWatcher * wxWindowDeletionWatcher::s_UndeletedWindowHash = NULL;

/*!

Preference: MainWndMax Section: Windows Range: 0 (FALSE) or 1 (TRUE)

Definition at line 201 of file camelot.h.

BOOL CCamApp::MainWndMinimized = FALSE [static]
 

If non-zero then main window defaults to minimized, else normal position. This default will be overridden if the user explicitly asked for a mode when starting the app (e.g. minimized). If the user exits while minimized, the flag will be set ready for next time.

Preference: MainWndMin Section: Windows Range: 0 (FALSE) or 1 (TRUE)

Definition at line 202 of file camelot.h.

String_256 CCamApp::MainWndPosString [static]
 

Remembers users last 'normal' window position for them. Also remembers the screen size so can be scaled if next time runs in different screen mode.

Preference: MainWndPos Section: Windows Range: Six numbers, separated with spaces, which are x y w h sx sy

Definition at line 203 of file camelot.h.

bool CCamApp::s_bIsDisabled [static, protected]
 

Definition at line 174 of file camelot.h.


The documentation for this class was generated from the following files:
Generated on Sat Nov 10 03:51:59 2007 for Camelot by  doxygen 1.4.4