filedlgs.cpp

Go to the documentation of this file.
00001 // $Id: filedlgs.cpp 1712 2006-08-22 16:01:26Z luke $
00002 /* @@tag:xara-cn@@ DO NOT MODIFY THIS LINE
00003 ================================XARAHEADERSTART===========================
00004  
00005                Xara LX, a vector drawing and manipulation program.
00006                     Copyright (C) 1993-2006 Xara Group Ltd.
00007        Copyright on certain contributions may be held in joint with their
00008               respective authors. See AUTHORS file for details.
00009 
00010 LICENSE TO USE AND MODIFY SOFTWARE
00011 ----------------------------------
00012 
00013 This file is part of Xara LX.
00014 
00015 Xara LX is free software; you can redistribute it and/or modify it
00016 under the terms of the GNU General Public License version 2 as published
00017 by the Free Software Foundation.
00018 
00019 Xara LX and its component source files are distributed in the hope
00020 that it will be useful, but WITHOUT ANY WARRANTY; without even the
00021 implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00022 See the GNU General Public License for more details.
00023 
00024 You should have received a copy of the GNU General Public License along
00025 with Xara LX (see the file GPL in the root directory of the
00026 distribution); if not, write to the Free Software Foundation, Inc., 51
00027 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
00028 
00029 
00030 ADDITIONAL RIGHTS
00031 -----------------
00032 
00033 Conditional upon your continuing compliance with the GNU General Public
00034 License described above, Xara Group Ltd grants to you certain additional
00035 rights. 
00036 
00037 The additional rights are to use, modify, and distribute the software
00038 together with the wxWidgets library, the wxXtra library, and the "CDraw"
00039 library and any other such library that any version of Xara LX relased
00040 by Xara Group Ltd requires in order to compile and execute, including
00041 the static linking of that library to XaraLX. In the case of the
00042 "CDraw" library, you may satisfy obligation under the GNU General Public
00043 License to provide source code by providing a binary copy of the library
00044 concerned and a copy of the license accompanying it.
00045 
00046 Nothing in this section restricts any of the rights you have under
00047 the GNU General Public License.
00048 
00049 
00050 SCOPE OF LICENSE
00051 ----------------
00052 
00053 This license applies to this program (XaraLX) and its constituent source
00054 files only, and does not necessarily apply to other Xara products which may
00055 in part share the same code base, and are subject to their own licensing
00056 terms.
00057 
00058 This license does not apply to files in the wxXtra directory, which
00059 are built into a separate library, and are subject to the wxWindows
00060 license contained within that directory in the file "WXXTRA-LICENSE".
00061 
00062 This license does not apply to the binary libraries (if any) within
00063 the "libs" directory, which are subject to a separate license contained
00064 within that directory in the file "LIBS-LICENSE".
00065 
00066 
00067 ARRANGEMENTS FOR CONTRIBUTION OF MODIFICATIONS
00068 ----------------------------------------------
00069 
00070 Subject to the terms of the GNU Public License (see above), you are
00071 free to do whatever you like with your modifications. However, you may
00072 (at your option) wish contribute them to Xara's source tree. You can
00073 find details of how to do this at:
00074   http://www.xaraxtreme.org/developers/
00075 
00076 Prior to contributing your modifications, you will need to complete our
00077 contributor agreement. This can be found at:
00078   http://www.xaraxtreme.org/developers/contribute/
00079 
00080 Please note that Xara will not accept modifications which modify any of
00081 the text between the start and end of this header (marked
00082 XARAHEADERSTART and XARAHEADEREND).
00083 
00084 
00085 MARKS
00086 -----
00087 
00088 Xara, Xara LX, Xara X, Xara X/Xtreme, Xara Xtreme, the Xtreme and Xara
00089 designs are registered or unregistered trademarks, design-marks, and/or
00090 service marks of Xara Group Ltd. All rights in these marks are reserved.
00091 
00092 
00093       Xara Group Ltd, Gaddesden Place, Hemel Hempstead, HP2 6EX, UK.
00094                         http://www.xara.com/
00095 
00096 =================================XARAHEADEREND============================
00097  */
00098 // Custom File Open and Save Dialogs
00099 
00100 #include "camtypes.h"
00101 #include "camelot.h"        // IsNewWindowsUI
00102 
00103 #include "filedlgs.h"
00104 //#include "app.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00105 #include "camframe.h"
00106 //#include "rik.h"
00107 //#include "andy.h"
00108 //#include "mario.h"            // for _R(IDE_NOMORE_MEMORY)
00109 //#include "nev.h"          // for _R(IDN_IMPORTBUTTON) etc
00110 //#include "resource.h"
00111 //#include "oilfltrs.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00112 //#include "fixmem.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00113 #include "native.h"         // The new designed native filter, used for v2
00114 #include "nativeps.h"       // The old style EPS native filter, used in v1.1
00115 //#include "custmsg.h"
00116 #include "helpuser.h"
00117 #include "camelot.h"
00118 //#include "filters.h" - in camtypes.h [AUTOMATICALLY REMOVED]
00119 #include "bmapprev.h"
00120 #include "bmpfiltr.h"
00121 
00122 #include "palman.h"
00123 
00124 // WEBSTER - markn 28/1/97
00125 //#include "tim.h"
00126 #include "webparam.h"
00127 #include "xarprefs.h"
00128 #include "webprefs.h"
00129 #include "webfiltr.h"
00130 
00131 //#include "richard2.h"     // For resource strings
00132 
00133 #include "ctrlhelp.h"
00134 #include "bitfilt.h"        // BaseBitmapFilter
00135 
00136 //#include "xardlg.h"           // For the base dialogue for the web dialogue.
00137 //#include "webdlg.h"           // Additional controls in _R(IDD_SAVEWEBOPTS)
00138 //#include "filtrres.h"     // _R(IDS_FILTEREXT_WEB)
00139 //#include "reshlpid.h"       // _R(ID_CC_HELP_BUTTON) 
00140 
00141 // New for preview bitmaps
00142 #include "dlgcol.h"         // DialogColourInfo
00143 #include "dlgview.h"        // DialogView
00144 //#include "docview.h"      // DocView - in camtypes.h [AUTOMATICALLY REMOVED]
00145 #include "osrndrgn.h"       // OSRenderRegion
00146 //#include "bitmap.h"           // KernelBitmap - in camtypes.h [AUTOMATICALLY REMOVED]
00147 #include "nodebmp.h"        // NodeBitmap
00148 #include "bitmpinf.h"       // BitmapInfo
00149 #include "oilbitmap.h"      // CWxBitmap
00150 #ifndef WEBSTER
00151 //#include "extfilts.h"     // AccusoftFilters
00152 #endif //WEBSTER
00153 //#include "cmxifltr.h"     // CMXImportFilter
00154 #include "webaddr.h"        // Olivier 09/05/97, use of the WebAddress class
00155 #include "aprps.h"              
00156 #include "exjpeg.h"
00157 #include "ngprop.h"         // for NamedExportProp::m_fApplyNotExport
00158 //#include "bmpreres.h"     // for _R(IDS_PREVIEW_APPLY)
00159 
00160 //#include "resimmap.h"     // for new templates stuff
00161 #include "menuops.h"
00162 #include "progress.h"
00163 
00164 #include "qualattr.h"
00165 //#include <shfolder.h> // For SHGetFolderPath
00166 
00167 void FixFPControlRegister();
00168 
00169 // the longest name we can display as a path, before going down to the basename
00170 #define MAX_ALLOWED_NAME_LENGTH 60
00171 
00172 #define NumberOfNames 60
00173 
00174 const DWORD FCIDM_SHVIEW_THUMBNAIL = 0x702D;
00175 
00176 String_256 BaseFileDialog::DefaultSaveFilePath = TEXT("");
00177 String_256 BaseFileDialog::DefaultOpenFilePath = TEXT("");
00178 INT32        BaseFileDialog::SelectedFilter = FILTERID_VECTOR;  // changed from FILTERID_GENERIC
00179 BOOL       BaseFileDialog::MakeBakFiles = FALSE;
00180 BOOL       BaseFileDialog::ShowPreviewBitmap = TRUE;
00181 BOOL       BaseFileDialog::ThumbNailMode = FALSE;
00182 
00183 BOOL       SaveTemplateDialog::m_fUseAsDefault = TRUE;
00184 BOOL       SaveTemplateDialog::m_fDefaultTemplatesFolder = TRUE;
00185 
00186 
00187 // This points at the current running file dialog.  NB. this will only allow one file
00188 // dialog to be open at any one time!
00189 BaseFileDialog* BaseFileDialog::m_pCurrentFileDialog = NULL;
00190 
00191 // Run-time type enquiry mechanisms.  These are required by the on-line help system.
00192 IMPLEMENT_CLASS(BaseFileDialog,     wxFileDialog);
00193 IMPLEMENT_CLASS(OpenFileDialog,     BaseFileDialog);
00194 IMPLEMENT_CLASS(SaveFileDialog,     BaseFileDialog);
00195 IMPLEMENT_CLASS(SaveTemplateDialog, SaveFileDialog);
00196 IMPLEMENT_CLASS(ImportFileDialog,   BaseFileDialog);
00197 IMPLEMENT_CLASS(ExportFileDialog,   BaseFileDialog);
00198 IMPLEMENT_CLASS(GIFExportFileDialog,ExportFileDialog);
00199 
00200 PORTNOTE("other", "Removed MFC MESSAGE_MAPs" )
00201 #if !defined(EXCLUDE_FROM_XARALX)
00202 // Need to ensure we get redraw messages back from the dialog box
00203 // so that we can redraw the preview bitmap
00204 BEGIN_MESSAGE_MAP(OpenFileDialog, BaseFileDialog)
00205     ON_BN_CLICKED(_R(ID_CC_HELP_BUTTON), BaseFileDialog::OnHelp)        // Windows 95 form
00206     ON_BN_CLICKED(_R(IDC_SHOWPREVIEW), BaseFileDialog::OnShowPreviewBitmap)     // Windows 95 form
00207     ON_MESSAGE(WM_REDRAW, OnRedrawMessage)
00208     ON_WM_SIZE()
00209 END_MESSAGE_MAP()
00210 
00211 // Map the buttons on the save dialog to the web export options handling functions
00212 // Need two forms for the Windows 95 UI and Old Windows UI types.
00213 // This code is all negated now and so is disabled.
00214 // But now we have a preview bitmap on the dialog box
00215 BEGIN_MESSAGE_MAP(SaveFileDialog, BaseFileDialog)
00216     ON_BN_CLICKED(_R(ID_CC_HELP_BUTTON), BaseFileDialog::OnHelp)        // Windows 95 form
00217     ON_BN_CLICKED(_R(IDC_SHOWPREVIEW), BaseFileDialog::OnShowPreviewBitmap)     // Windows 95 form
00218     // WEBSTER - markn 28/1/97
00219     ON_BN_CLICKED(_R(IDC_FILEDLG_OPTIONS), BaseFileDialog::OnOptions)           // Windows 95 form
00220     ON_MESSAGE(WM_REDRAW, OnRedrawMessage)
00221     ON_WM_SIZE()
00222 END_MESSAGE_MAP()
00223 
00224 BEGIN_MESSAGE_MAP(SaveTemplateDialog, BaseFileDialog)
00225     ON_BN_CLICKED(_R(ID_CC_HELP_BUTTON), BaseFileDialog::OnHelp)        // Windows 95 form
00226     ON_BN_CLICKED(_R(IDC_SHOWPREVIEW), BaseFileDialog::OnShowPreviewBitmap)     // Windows 95 form
00227     ON_BN_CLICKED(_R(IDC_USEASDEFAULT), SaveTemplateDialog::OnUseAsDefault)     // Windows 95 form
00228     ON_MESSAGE(WM_REDRAW, OnRedrawMessage)
00229     ON_WM_SIZE()
00230 END_MESSAGE_MAP()
00231 
00232 
00233 // Need to ensure we get redraw messages back from the dialog box
00234 // so that we can redraw the preview bitmap
00235 BEGIN_MESSAGE_MAP(ImportFileDialog, BaseFileDialog)
00236     ON_BN_CLICKED(_R(ID_CC_HELP_BUTTON), BaseFileDialog::OnHelp)        // Windows 95 form
00237     ON_BN_CLICKED(_R(IDC_SHOWPREVIEW), BaseFileDialog::OnShowPreviewBitmap)     // Windows 95 form
00238     ON_COMMAND(IDOK, OnOK)
00239     ON_BN_CLICKED(IDOK, OnOK)
00240     ON_MESSAGE(WM_REDRAW, OnRedrawMessage)
00241     ON_WM_LBUTTONDBLCLK()
00242     ON_WM_SIZE()
00243 END_MESSAGE_MAP()
00244 
00245 BEGIN_MESSAGE_MAP(ExportFileDialog, BaseFileDialog)
00246     ON_BN_CLICKED(_R(ID_CC_HELP_BUTTON), BaseFileDialog::OnHelp)            // Windows 95 form
00247     ON_BN_CLICKED(_R(IDC_FILEDLG_OPTIONS), BaseFileDialog::OnOptions)
00248     ON_BN_CLICKED(_R(IDC_SHOWPREVIEW), BaseFileDialog::OnShowPreviewBitmap) // Windows 95 form
00249     ON_BN_CLICKED(_R(IDC_AUTO_CHECK), OnAutoPreview)                        // Windows 95 form
00250     ON_MESSAGE(WM_REDRAW, OnRedrawMessage)
00251     ON_WM_SIZE()
00252 END_MESSAGE_MAP()
00253 #endif
00254 
00255 /********************************************************************************************
00256 >   BaseFileDialog::BaseFileDialog(BOOL IsFileOpen, WORD Flags, LPCSTR lpszFilter=NULL,
00257                 wxWindow* pParentWnd=NULL)
00258 
00259     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com> & JustinF
00260     Created:    26/1/95
00261     Inputs:     IsFileOpen - TRUE if this is a File Open dialog, FALSE if it is a Save Dialog
00262                 Flags - The flags you want set in the CFileDialog.
00263                 lpszFilter - The Filter String
00264                 pParentWnd - The owner of this window (by default the main frame window)
00265     Purpose:    Creates a base class file dialog, installing a hook etc.
00266 
00267 Technical Notes:
00268 We set the OFN_EXPLORER on Windows 95 only. Really this should include the new shell on NT
00269 when we work with it. If you set this flag on NT without the new shell, then you get a useful
00270 not enough memory or similar error and the dialog box fails to open. At present, the user will
00271 see nothing as we don't seem to cope with errors.
00272 We need to set the flag as some functions e.g. ExportFileDialog::OnTypeChange() will only
00273 work with it set. Used to fix the filenames up when switching to a new filter.
00274 ********************************************************************************************/
00275 
00276 // Visual C (MFC) 4 defines this constant, but Visual C 2 does not
00277 #ifndef OFN_EXPLORER
00278 #define OFN_EXPLORER 0
00279 #endif
00280 
00281 BaseFileDialog::BaseFileDialog(BOOL IsFileOpen, DWORD dwFlags, LPCTSTR lpszFilter, wxWindow* pParentWnd)
00282   : wxFileDialog( (pParentWnd != NULL) ? pParentWnd : pParentWnd = GetMainFrame(), _T("Choose a file"),
00283         _T(""), _T(""), lpszFilter, dwFlags | ( IsFileOpen ? wxOPEN : wxSAVE) )
00284 //  IsFileOpen, NULL, NULL, dwFlags | ((CCamApp::IsNewWindowsUI()) ? OFN_EXPLORER : OFN_SHOWHELP) | OFN_ENABLEHOOK,
00285 //  lpszFilter, )
00286 {
00287 PORTNOTE("other", "Removed MFC junk" )
00288 #if !defined(EXCLUDE_FROM_XARALX)
00289     // Set the address of the message hook procedure.
00290     m_ofn.lpfnHook = (LPOFNHOOKPROC) HookProc;
00291 
00292     // Unfortunately, MFC doesn't set the hwndOwner member of m_ofn . . .
00293     m_ofn.hwndOwner = (pParentWnd != NULL) ? pParentWnd->m_hWnd : NULL;
00294 
00295     // We haven't called the explorer style init function by default
00296     ExplorerInited = FALSE;
00297 #endif
00298     
00299     // Remember a pointer to this file dialog.
00300     m_pCurrentFileDialog = this;
00301 
00302     // Set the preview bitmap to be NULL
00303     pBitmapToUse = NULL;
00304 
00305     // Added by Craig Hamilton 20/9/00.
00306     m_previousPathName = _T("");
00307     // End added.
00308 }
00309 
00310 
00311 /********************************************************************************************
00312 
00313 >   BaseFileDialog::~BaseFileDialog()
00314 
00315     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00316     Created:    18/7/96
00317     Returns:    -
00318     Purpose:    Standard destructor. Need to clean up the preview bitmap, if present.
00319 
00320 ********************************************************************************************/
00321 
00322 BaseFileDialog::~BaseFileDialog()
00323 {
00324     // Must clean up our preview bitmap, if present
00325     if (pBitmapToUse != NULL)
00326     {
00327         delete pBitmapToUse;
00328         pBitmapToUse = NULL;
00329     }
00330     m_pCurrentFileDialog = NULL;
00331 }
00332 
00333 
00334 PORTNOTE("other", "Removed MFC type Hooks" )
00335 #if !defined(EXCLUDE_FROM_XARALX)
00336 /********************************************************************************************
00337 >   static UINT32 CALLBACK BaseFileDialog::HookProc(wxWindow* hwnd, UINT32 nMsg,
00338                                                   WPARAM wParam, LPARAM lParam)
00339     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00340     Created:    18/5/95
00341     Inputs:     (the usual message proc paramters, see Win32 SDK documentation)
00342     Returns:    FALSE if the dialog library should process this message, TRUE if it
00343                 should ignore it.
00344     Purpose:    Called by the common dialog library when it has a message to process.
00345                 Calls the virtual OnHookMsg function.
00346     SeeAlso:    BaseFileDialog::OnHookMsg
00347 ********************************************************************************************/
00348 
00349 UINT32 CALLBACK BaseFileDialog::HookProc(wxWindow* hwnd, UINT32 nMsg, WPARAM wParam, LPARAM lParam)
00350 {
00351     // If there is no current file dialog then just say nothing and do nothing
00352     // This MAY happen if we are bodging the web filename file dialog which is to get
00353     // round having double file dialogs on screen, which is BAD!
00354     if (m_pCurrentFileDialog == NULL) // || m_pCurrentFileDialog->hwnd == NULL)
00355         return FALSE;
00356 
00357     return m_pCurrentFileDialog->OnHookMsg(hwnd, nMsg, wParam, lParam);
00358 }
00359 
00360 
00361 
00362 /********************************************************************************************
00363 >   virtual UINT32 BaseFileDialog::OnHookMsg(wxWindow* hwnd, UINT32 nMsg, WPARAM wParam, LPARAM lParam)
00364 
00365     Author:     Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
00366     Created:    18/5/95
00367     Inputs:     (the usual message proc parameters)
00368     Returns:    FALSE if the dialog library should process this message, TRUE if it
00369                 should ignore it.
00370     Purpose:    Called by the common dialog library when it has a message to process.
00371                 This function checks if the help button has been clicked, and runs the
00372                 help engine if it has.
00373     SeeAlso:    BaseFileDialog::HookProc
00374 ********************************************************************************************/
00375 
00376 UINT32 BaseFileDialog::OnHookMsg(wxWindow* hwnd, UINT32 nMsg, WPARAM wParam, LPARAM lParam)
00377 {
00378     // Check for a help message.
00379     if (nMsg == WM_COMMAND && LOWORD(wParam) == pshHelp)
00380     {
00381         // Run the help engine for this dialog and don't bother processing this message
00382         // any further, we've done it.
00383         HelpUser(*this);
00384         return TRUE;
00385     }
00386 
00387     // Allow explorer style dialog boxes to set themselves up
00388     if (nMsg == WM_INITDIALOG && CCamApp::IsNewWindowsUI())
00389     {
00390         // Only call this if we are the new explorer dialog boxes
00391         return ExplorerInitDialog(hwnd);
00392     }
00393 
00394     // WM_NOTIFY notification messages indicates actions taken by the user in the dialog box.
00395     // The lParam parameter for each WM_NOTIFY message is the address of a OFNOTIFY structure
00396     // that defines the action. The code member in the header for the OFNOTIFY structure
00397     // contains the notification values
00398     if (nMsg == WM_NOTIFY && lParam != NULL)
00399     {
00400         OFNOTIFY * pNotify = (OFNOTIFY*)lParam;
00401         // This is used to inform explorer style dialogs of actions
00402         if (CCamApp::IsNewWindowsUI())
00403             return ExplorerFileHookNotify(hwnd, pNotify);
00404     }
00405 
00406     //TODO: change 'File name:' to 'File name (or URL):' (WARNING: change _R(ID_OF_FILENAME) with the correct ID)
00407     //SetDlgItemText(hwnd, _R(ID_OF_FILENAME), (TCHAR *)String_256("File name (or URL):"));
00408 
00409 #ifndef RALPH
00410     // By default let MFC handle all other messages in its own hook procedure.
00411     return _AfxCommDlgProc(hwnd, nMsg, wParam, lParam);
00412 #else
00413     // Why doesn't this work with _AFXDLL defined ?
00414     return FALSE;
00415 #endif
00416 }
00417 
00418 /********************************************************************************************
00419 
00420 >   virtual BOOL BaseFileDialog::ExplorerInitDialog(wxWindow* hDlg)
00421 
00422     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00423     Created:    2/7/96
00424     Returns:    TRUE if it worked, FALSE if it failed
00425     Purpose:    Should be called when the explorer style dialog boxes need setting up.
00426                 We can take this opportunity to add in any extra controls that we require.
00427                 Baseclass version.
00428     SeeAlso:    BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;
00429 
00430 ********************************************************************************************/
00431 
00432 BOOL BaseFileDialog::ExplorerInitDialog(wxWindow* hDlg)
00433 {
00434     return TRUE;
00435 }
00436 
00437 /********************************************************************************************
00438 
00439 >   virtual BOOL BaseFileDialog::ExplorerFileHookNotify(wxWindow* hDlg, LPOFNOTIFY pofn)
00440 
00441     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00442     Created:    3/7/96
00443     Inputs:     hDlg - wxWindow* of the dialog box.
00444                 pofn - pointer to notify structure
00445     Returns:    TRUE if it worked, FALSE if it failed
00446     Purpose:    Should be called when actions happen on the explorer style dialog boxes.
00447                 We can take this opportunity to handle these actions as required.
00448                 Baseclass version.
00449     SeeAlso:    BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;
00450 
00451 ********************************************************************************************/
00452 
00453 BOOL BaseFileDialog::ExplorerFileHookNotify(wxWindow* hDlg, LPOFNOTIFY pofn)
00454 {
00455     return TRUE;
00456 }
00457 
00458 /********************************************************************************************
00459 
00460 >   virtual UINT32 BaseFileDialog::OnFileTypeChange()
00461 
00462     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00463     Created:    12/1/96
00464     Returns:    TRUE if it worked, FALSE if it failed
00465     Purpose:    Should be called when the user has selected a new file type from the
00466                 "Files of type" combo box. We might need to do things like fix the file
00467                 extension for the currently selected save/export filter.
00468                 Baseclass version.
00469     SeeAlso:    BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;
00470 
00471 ********************************************************************************************/
00472 
00473 UINT32 BaseFileDialog::OnFileTypeChange()
00474 {
00475     return TRUE;
00476 }
00477 #endif
00478 
00479 /********************************************************************************************
00480 
00481 >   BOOL BaseFileDialog::Init()
00482 
00483     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00484     Created:    25/1/95
00485     Returns:    TRUE if it worked, FALSE if it failed
00486     Purpose:    Declares some preferences for the Open and Save dialogs
00487 
00488 ********************************************************************************************/
00489 
00490 BOOL BaseFileDialog::Init()
00491 {
00492     // Set some defaults
00493     String_256 Blank("");
00494     DefaultSaveFilePath = Blank;
00495     DefaultOpenFilePath = Blank;
00496 
00497     // declare prefs for the open and save dialogs
00498     Camelot.DeclareSection(_T("Filters"), 6);
00499     Camelot.DeclarePref(_T("Filters"), _T("DefaultSaveFilePath"), &DefaultSaveFilePath);
00500     Camelot.DeclarePref(_T("Filters"), _T("DefaultOpenFilePath"), &DefaultOpenFilePath);
00501     Camelot.DeclarePref(_T("Filters"), _T("OpenFileFilter"), &SelectedFilter);
00502     Camelot.DeclarePref(_T("Filters"), _T("MakeBakFiles"), &MakeBakFiles);
00503     Camelot.DeclarePref(_T("Filters"), _T("ShowPreviewBitmap"), &ShowPreviewBitmap);
00504     Camelot.DeclarePref(_T("Filters"), _T("ThumbNailMode"), &ThumbNailMode);
00505 
00506 
00507     return TRUE;
00508 }
00509 
00510 
00511 
00512 /********************************************************************************************
00513 
00514 >   BOOL BaseFileDialog::PrepareDialog()
00515 
00516     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00517     Created:    26/1/95
00518     Returns:    TRUE if it worked, FALSE if not
00519     Purpose:    Does anything the dialogs want doing after they have been created, but before
00520                 they are displayed.
00521 
00522 ********************************************************************************************/
00523 
00524 BOOL BaseFileDialog::PrepareDialog()
00525 {
00526     // Nothing to do in this base class . . .
00527     return TRUE;
00528 }
00529 
00530 
00531 /********************************************************************************************
00532 
00533 >   static char *BaseFileDialog::BuildFilterString(BOOL GetImport,
00534                                                    UINT32 SelectedFilterID,
00535                                                    INT32 *SelectedFilter,
00536                                                    CCRuntimeClass *pTypeOfFilter = GenericFilter,
00537                                                    UINT32 Bpp = 0)
00538 
00539     Author:     Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
00540     Created:    29/03/94
00541     Inputs:     GetImport - TRUE => Build list of Import filters
00542                            FALSE => Build list of Export filters
00543                 SelectedFilterID - the ID of the last filter that was used by the
00544                                    calling Operation.
00545                 pTypeOfFilter    - optional type of filter to use. Defaults to GenericFilter
00546                                    for all.
00547                 Bpp              - if only bitmap filters required then check this bpp against
00548                                    the ones that the filter supports 
00549     Outputs:    SelectedFilter - the position in the list box of the selected filter
00550                                  identified by SelectedFilterID, or unchanged if it wasn't 
00551                                  found.
00552     Returns:    The filter string.
00553     Purpose:    Build a filter string suitable for use by Windows' common dialog 
00554                 "File open" or "File save" boxes.
00555                 This is mainly for the import and export dialog boxes.
00556                 Used to be in OilFiltrs.cpp until moved to BaseFileDialog 5/1/96.
00557     Errors:     Out of memory
00558     SeeAlso:    MetaFileFilter;
00559     SeeAlso:    OpMenuExport; OpMenuImport;
00560 
00561 ********************************************************************************************/
00562 
00563 TCHAR *BaseFileDialog::BuildFilterString(BOOL GetImport,
00564                                         UINT32 SelectedFilterID,
00565                                         INT32 *SelectedFilter,
00566                                         CCRuntimeClass *pTypeOfFilter,
00567                                         UINT32 Bpp,
00568                                         UINT32 BitmapCount)
00569 {
00570     // Find out how much space is needed
00571     UINT32 FilterSize = 0;
00572 
00573     // Used to load in the resource strings for the filter extension descriptions.
00574     String_256 FilterExtensions;
00575 
00576     Filter *pFilter = Filter::GetFirst();
00577     BOOL FilterCanCope = TRUE;
00578     while (pFilter != NULL)
00579     {
00580         // If we are filtering for bitmap filters then check that if a Bpp has been
00581         // specified that the bitmap filter can cope with that.
00582         FilterFlags Flags = pFilter->GetFlags();
00583         if (pTypeOfFilter==CC_RUNTIME_CLASS(BitmapFilter) && pFilter->IsKindOf(pTypeOfFilter))
00584         {
00585             BaseBitmapFilter* pBitmapFilter = (BaseBitmapFilter*)pFilter;
00586             if (pBitmapFilter->IsThisBppOk(Bpp))
00587             {
00588                 // Webster - RanbirR - 25\02\97  
00589                 // If this is a single bitmap and the the Bpp is 24, 
00590                 // then we do not want to dipsplay *.gif in the export filter List.
00591                 // Only allow the format for Animated GIF's (even though they do not 
00592                 // support 24 colour bitmaps.) We later convert to an 8 Bpp. 
00593                 // This fixes an animated GIF export bug in Camelot.
00594                 // At present we error if the first bitmap in our animated gif is 24Bpp.
00595                 if (pFilter->FilterID ==  FILTERID_TI_GIF && Bpp == 24 && BitmapCount == 1)
00596                     FilterCanCope = FALSE;
00597                 else
00598                     FilterCanCope = TRUE;
00599             }
00600             else
00601                 FilterCanCope = FALSE;
00602 
00603             if (BitmapCount>1 && !Flags.CanExportMultipleImages)
00604                 FilterCanCope = FALSE;
00605         }
00606         else
00607             FilterCanCope = TRUE;
00608                 
00609         // little bit of a bodge here to stop the CamelotEPSFilter from appearing in the
00610         // import list - you can't hide it from just one list. It must be availiable though
00611         // to give it's nice little error message. Other instances of this below.
00612         if (
00613             ( ( GetImport && Flags.CanImport && !IS_A( pFilter, CamelotEPSFilter ) )
00614                 || (!GetImport && Flags.CanExport)) && NULL != pFilter->pOILFilter &&
00615                 Flags.ShowFilter && (pFilter->IsKindOf(pTypeOfFilter)) && FilterCanCope
00616            )
00617         {
00618             // Add the space required to put this into the filter string
00619             // (add 1 for the separating '|' character when not the first)
00620             if (FilterSize != 0)
00621                 FilterSize += 1;
00622             FilterSize += camStrlen(pFilter->pOILFilter->ConstructFilterString(BitmapCount));
00623         }
00624 
00625         // Try the next filter
00626         pFilter = Filter::GetNext(pFilter);
00627     }
00628 
00629     // If we have found no valid filters then we must set an error and return NULL
00630     // as otherwise we are in an illegal situation
00631     if (FilterSize == 0)
00632     {
00633         Error::SetError(_R(IDE_FORMATNOTSUPPORTED));
00634         return NULL;
00635     }
00636     
00637     // Add one for the final terminator.
00638     FilterSize += 1;
00639 
00640     // Try to get this string
00641     TCHAR *FilterString = (TCHAR *) CCMalloc(FilterSize * sizeof(TCHAR));
00642     if (FilterString==NULL)
00643     {
00644         // Error state already set by CCMalloc
00645         return NULL;
00646     }
00647     
00648     // Construct the string, and set up the position numbers for the filters.
00649     UINT32 Position = 0;
00650     FilterString[0] = 0;
00651     pFilter = Filter::GetFirst();
00652 
00653     while (pFilter != NULL)
00654     {
00655         // If we are filtering for bitmap filters then check that if a Bpp has been
00656         // specified that the bitmap filter can cope with that.
00657         FilterFlags Flags = pFilter->GetFlags();
00658         if (pTypeOfFilter==CC_RUNTIME_CLASS(BitmapFilter) && pFilter->IsKindOf(pTypeOfFilter))
00659         {
00660             BaseBitmapFilter* pBitmapFilter = (BaseBitmapFilter*)pFilter;
00661             if (pBitmapFilter->IsThisBppOk(Bpp))
00662             {
00663                 // Webster - RanbirR - 25\02\97  
00664                 // If this is a single bitmap and the the Bpp is 24, 
00665                 // then we do not want to dipsplay *.gif in the export filter List.
00666                 // Only allow the format for Animated GIF's (even though they do not 
00667                 // support 24 colour bitmaps.) We later convert to an 8 Bpp. 
00668                 // This fixes an animated GIF export bug in Camelot.
00669                 // At present we error if the first bitmap in our animated gif is 24Bpp.
00670                 if (pFilter->FilterID ==  FILTERID_TI_GIF && Bpp == 24 && BitmapCount == 1)
00671                     FilterCanCope = FALSE;
00672                 else
00673                     FilterCanCope = TRUE;
00674             }
00675             else
00676                 FilterCanCope = FALSE;
00677 
00678             if (BitmapCount>1 && !Flags.CanExportMultipleImages)
00679                 FilterCanCope = FALSE;
00680         }
00681         else
00682             FilterCanCope = TRUE;
00683 
00684         if( NULL != pFilter->pOILFilter )
00685         {
00686             if (
00687                 ( ( GetImport && Flags.CanImport && !IS_A( pFilter, CamelotEPSFilter ) )
00688                     || (!GetImport && Flags.CanExport)) &&
00689                     Flags.ShowFilter && (pFilter->IsKindOf(pTypeOfFilter)) && FilterCanCope
00690                )
00691             {
00692                 // Add this filter into the list
00693                 if (Position != 0)
00694                     camStrcat(FilterString, _T("|"));
00695                 camStrcat(FilterString, pFilter->pOILFilter->ConstructFilterString(BitmapCount));
00696                 pFilter->pOILFilter->Position = Position;
00697 
00698                 // Is this the filter we used last?
00699                 if ((*SelectedFilter == -1) && (pFilter->FilterID == SelectedFilterID))
00700                     // Yes - remember this.
00701                     *SelectedFilter = Position;
00702 
00703                 Position++;
00704             }
00705             else
00706                 // Make sure we don't try this one later
00707                 pFilter->pOILFilter->Position = -1;
00708         }
00709         
00710         // Try the next filter
00711         pFilter = Filter::GetNext(pFilter);
00712     }
00713 
00714     // All ok
00715     return FilterString;
00716 }
00717 
00718 
00719 /********************************************************************************************
00720 
00721 >   virtual INT32 BaseFileDialog::GetSelectedFilterIndex()
00722 
00723     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00724     Created:    4/1/96
00725     Returns:    The index of the selected filter
00726     Purpose:    Allows access in a kernelly fashion to the selected filter index on
00727                 the common file dialog box.
00728 
00729 ********************************************************************************************/
00730 
00731 INT32 BaseFileDialog::GetSelectedFilterIndex()
00732 {
00733     return GetFilterIndex();
00734 }
00735 
00736 /********************************************************************************************
00737 
00738 >   virtual INT32 BaseFileDialog::SetSelectedFilterIndex(INT32 NewIndex)
00739 
00740     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00741     Created:    4/1/96
00742     Returns:    TRUE if it worked, FALSE if not
00743     Purpose:    Set the desired index for the filter that is going to be selected on the 
00744                 Common file dialog box.
00745 
00746 ********************************************************************************************/
00747 
00748 INT32 BaseFileDialog::SetSelectedFilterIndex(INT32 NewIndex)
00749 {
00750     INT32 Old = GetFilterIndex();
00751     SetFilterIndex( NewIndex );
00752     TRACEUSER( "Neville", _T("SetSelectedFilterIndex - new %d (old = %d)\n"), NewIndex, Old);
00753     return Old;
00754 }
00755 
00756 /********************************************************************************************
00757 
00758 >   virtual BOOL BaseFileDialog::SetTitle(INT32 TitleId)
00759 
00760     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00761     Created:    4/1/96
00762     Returns:    TRUE if it worked, FALSE if not
00763     Purpose:    Allows the title of the common file dialog box to be set up 
00764 
00765 ********************************************************************************************/
00766 
00767 BOOL BaseFileDialog::SetTitle(INT32 TitleId) 
00768 {
00769     if (SmartLoadString(0, TitleId, Title, 128))
00770         SetName( Title );
00771     
00772     return TRUE;
00773 }
00774 
00775 
00776 /********************************************************************************************
00777 
00778 >   virtual BOOL BaseFileDialog::SetInitialDirectory(const String_256& pDir)
00779 
00780     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00781     Created:    4/1/96
00782     Inputs:     pDir    String containing the pathname to use
00783     Returns:    TRUE if it worked, FALSE if not
00784     Purpose:    Sets the directory which the common file dialog box will open looking at.
00785 
00786 ********************************************************************************************/
00787 
00788 BOOL BaseFileDialog::SetInitialDirectory(const String_256& strDir)
00789 {
00790     SetDirectory( PCTSTR(strDir) );
00791     
00792     return TRUE;
00793 }
00794 
00795 /********************************************************************************************
00796 
00797 >   virtual BOOL BaseFileDialog::SetDefaultFileName(const String_256& Name)
00798 
00799     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00800     Created:    4/1/96
00801     Inputs:     Name    name of the file to be used by default
00802     Returns:    TRUE if it worked, FALSE if not
00803     Purpose:    Sets the name and length of the name of the default file to be used in the 
00804                 common file dialog box
00805 
00806 ********************************************************************************************/
00807 
00808 BOOL BaseFileDialog::SetDefaultFileName(String_256& Name)
00809 {
00810     SetFilename( PCTSTR(Name) );
00811         
00812     return TRUE;
00813 }
00814 
00815 /********************************************************************************************
00816 
00817 >   virtual BOOL BaseFileDialog::GetChosenFileName(PathName * pName)
00818 
00819     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00820     Created:    4/1/96
00821     Outputs:    The pathname that the user chose.
00822     Returns:    TRUE if it worked and patname is valid, FALSE if not
00823     Purpose:    Gets the pathname of the file that was chosen by the user. It will return
00824                 the vailidity of the pathname to the caller. Should be valid as the file
00825                 dialog box should filter out problem pathnames.
00826 
00827 ********************************************************************************************/
00828 
00829 BOOL BaseFileDialog::GetChosenFileName(PathName * pName)
00830 {
00831     TRACEUSER( "luke", _T("FileName is %s\n"), GetPath().c_str() );
00832 
00833     pName->SetPathName( GetPath() );
00834     return pName->IsValid();
00835 }
00836 
00837 /********************************************************************************************
00838 
00839 >   virtual Filter * BaseFileDialog::GetSelectedExportFilter()
00840 
00841     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00842     Created:    4/1/96
00843     Returns:    TRUE if it worked, FALSE if not
00844     Purpose:    
00845 
00846 ********************************************************************************************/
00847 
00848 Filter * BaseFileDialog::GetSelectedExportFilter(INT32 TheSelectedFilter)
00849 {
00850     // Find the filter that the user has chosen
00851     Filter *pFilter = Filter::GetFirst();
00852     while (pFilter != NULL)
00853     {
00854         if ((pFilter->GetFlags().CanExport) && 
00855             (pFilter->pOILFilter->Position == TheSelectedFilter))
00856             // This is the filter!
00857             break;
00858 
00859         // Try the next filter
00860         pFilter = Filter::GetNext(pFilter);
00861     }
00862 
00863     return pFilter;
00864 }
00865 
00866 /********************************************************************************************
00867 
00868 >   void BaseFileDialog::SetSelectedExportFilter(UINT32 uiFilterID)
00869 
00870     Author:     Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
00871     Created:    3/7/97
00872     Returns:    -
00873     Purpose:    Sets the selected export filter to the ID given
00874 
00875 ********************************************************************************************/
00876 
00877 void BaseFileDialog::SetSelectedExportFilter(UINT32 uiFilterID)
00878 {
00879     //Search through the filters until we find the one we want
00880     Filter* pFilter = Filter::GetFirst();
00881     while (pFilter != NULL)
00882     {
00883         if (pFilter->FilterID == uiFilterID)
00884         {
00885             //We've found it
00886             //So set this as the selected filter
00887             SetSelectedFilterIndex( pFilter->pOILFilter->Position );
00888             return;
00889         }
00890         pFilter = Filter::GetNext(pFilter);
00891     }
00892 
00893     ERROR3("BaseFileDialog::SetSelectedExportFilter - couldn't find the Filter ID");
00894 }
00895 
00896 
00897 /********************************************************************************************
00898 
00899 >   virtual BOOL BaseFileDialog::OpenAndGetFileName()
00900 
00901     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
00902     Created:    4/1/96
00903     Returns:    True if the user pressed ok on the dialog box, False otherwise
00904     Purpose:    Opens the common file dialog box up, waits for the user to gives us the
00905                 filename that they wish to use and either press ok or cancel. 
00906 
00907 ********************************************************************************************/
00908 
00909 BOOL BaseFileDialog::OpenAndGetFileName()
00910 {
00911 PORTNOTE("other", "Removed ControlHelper usage" )
00912 #if !defined(EXCLUDE_FROM_XARALX)
00913     // Keep Control Helper system informed
00914     ControlHelper::InformModalDialogOpened();
00915 #endif
00916     
00917     // 'Do' the dialog
00918     INT32 DlgResult = ShowModal();
00919 
00920 PORTNOTE("other", "Removed ControlHelper usage" )
00921 #if !defined(EXCLUDE_FROM_XARALX)
00922     // Keep Control Helper system informed
00923     ControlHelper::InformModalDialogClosed();
00924 #endif
00925     
00926     return (DlgResult == wxID_OK);
00927 }
00928 
00929 /********************************************************************************************
00930 
00931 >   BOOL BaseFileDialog::IsValidFilename()
00932 
00933     Author:     Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
00934     Created:    31/10/95
00935     Returns:    TRUE if the current filename is Acceptable, FALSE if not
00936     Purpose:    Makes sure that the filename picked is actually OK. If there is another
00937                 file of the same name, it checks to see if the user wants to replace it.
00938                 Moved from SaveFileDialog 9/1/96
00939 ********************************************************************************************/
00940 
00941 BOOL BaseFileDialog::IsValidFilename()
00942 {
00943     // Get the pathname
00944     wxString FullPath = GetFilename();
00945     AppendExtension(&FullPath);
00946 
00947     // Webster - RanbirR 17/02/97
00948     // Save the file name with our Filter extension, for use in our Message Box.
00949 #ifdef WEBSTER
00950     wxString FileName(FullPath);
00951 #endif //webster
00952 
00953     // if doesn't exist then thats fine
00954     if( wxFile::Exists( FullPath ) )
00955     {
00956         //  WEBSTER-ranbirr-27/03/97
00957         // Remove the extension from the file. Webster - RanbirR 11\02\97.
00958     #ifdef WEBSTER
00959         RemoveFileExtension(&FileName);
00960     #endif //webster
00961         return TRUE;
00962     }
00963 
00964     // Added for Webster - Ranbir 11\02\97  
00965     // Removes the exstion from a file name.
00966 #ifdef WEBSTER
00967     RemoveFileExtension(&FileName);
00968 #endif //webster
00969 
00970     // Get the filename into a Path object
00971 #ifndef WEBSTER
00972     String_256 KernelFilename(FullPath);
00973     PathName FileMessage(KernelFilename);
00974     KernelFilename =  FileMessage.GetTruncatedPath(50);
00975 #endif //webster
00976     
00977     // Webster - RanbirR 17/02/97 
00978     // Use "FileName", since it contains the Filter extension.
00979 #ifdef WEBSTER
00980     String_256 KernelFilename(FileName);
00981     PathName FileMessage(KernelFilename);
00982     KernelFilename =  FileMessage.GetTruncatedPath(50);
00983 #endif //webster
00984 
00985     const TCHAR* Name;
00986     Name = (TCHAR*)KernelFilename;
00987 
00988     String_256 strPrompt( _R(IDM_OVERWRITE) );
00989 
00990     // fill in the %s field with the filename
00991     TCHAR ErrorMsg[256];
00992     camSnprintf( ErrorMsg, sizeof(ErrorMsg) / sizeof(ErrorMsg[0]), strPrompt, 
00993         (const TCHAR*)Name );
00994     Error::SetError( 0, ErrorMsg, 0 );
00995     SetNextMsgHelpContext(_R(IDM_OVERWRITE));
00996 
00997     // then ask the user
00998     ErrorInfo Info;
00999     Info.Button[0] = _R(IDB_OVERWRITE);
01000     Info.Button[1] = _R(IDS_CANCEL);
01001     
01002     // This makes the cancel button the default one in this situation
01003     // as defaulting to replace is bad.
01004     Info.OK = Info.Cancel = 2;
01005 
01006     UINT32  idResult = AskQuestion( &Info );
01007 
01008     // if they cancel, then the name is not acceptable to them
01009     if( _R(IDS_CANCEL) == idResult )
01010         return FALSE;
01011 
01012     // user was quite keen on the replace file idea.
01013     // delete the file we're replacing so rampant filters don't get upset
01014     // Removed 2/1/96 as the export filters should be using the new DeleteExportFile function
01015     // Problems with this approach as if the exporter pops up an expotr options dialog box then
01016     // most people would expect a cancel on this not to vape the file.
01017     //_unlink(FullPath);
01018 
01019     return TRUE;
01020 }
01021 
01022 /********************************************************************************************
01023 
01024 >   void BaseFileDialog::AppendExtension(wxString* pFilename)
01025 
01026     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01027     Created:    9/1/96
01028     Inputs:     pFilename - the filename to append an extension to
01029     Outputs:    pFilename - the input filename with the .art extension on the end (if needed)
01030     Purpose:    Given a filename, this function should attach the appropriate file extension
01031                 to the to it. This baseclass version does nothing
01032 
01033 ********************************************************************************************/
01034 
01035 void BaseFileDialog::AppendExtension(wxString* pFilename)
01036 {
01037     // baseclass version so do nothing
01038 }
01039 
01040 /********************************************************************************************
01041 
01042 >   void BaseFileDialog::RemoveFileExtension(wxString* pFilename)
01043 
01044     Author:     Ranbir_Rana (Xara Group Ltd) <camelotdev@xara.com>
01045     Created:    11/02/97
01046     Inputs:     pName - The filename from which the extension will be removed.
01047     Outputs:    pName - The input filename with the extension removed.
01048     
01049 ********************************************************************************************/
01050 //  WEBSTER-ranbirr-27/03/97
01051 #ifdef WEBSTER
01052 BOOL  BaseFileDialog::RemoveFileExtension(wxString* pName)
01053 {
01054     // Is this a valid file name
01055     if ((pName == NULL) || (pName->IsEmpty()))
01056         return FALSE;
01057 
01058     // Does the filename have an extension? 
01059     INT32 i = pName->GetLength() - 1;
01060     INT32 ExtensionLen = 0;
01061 
01062     // look for the dot char.
01063     while ((i >= 0) && (pName->GetAt(i) != '.'))
01064     {
01065         i--;
01066         ExtensionLen++;
01067     }
01068     
01069     // Is it a valid extension?
01070     if (ExtensionLen <= 3 && ExtensionLen > 0 && i > 0)
01071     {
01072         // Remove the extension.
01073         *pName = pName->Left(i);
01074         return TRUE;
01075     }
01076     else
01077         return FALSE;
01078 }
01079 #endif //webster
01080 
01081 
01082 /********************************************************************************************
01083 ***     New help button handling code
01084 ********************************************************************************************/
01085 
01086 /********************************************************************************************
01087 
01088 >   afx_msg void BaseFileDialog::OnHelp()
01089 
01090     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01091     Created:    30/7/96
01092     Returns:    -
01093     Purpose:    Handle the clicks on the help button.
01094                 This is the Windows 95 UI form of the function.
01095 
01096 ********************************************************************************************/
01097 
01098 PORTNOTE("other", "Removed MFC type Hooks" )
01099 #if !defined(EXCLUDE_FROM_XARALX)
01100 afx_msg void BaseFileDialog::OnHelp()
01101 {
01102     // Run the help engine for this dialog and don't bother processing this message
01103     // any further, we've done it.
01104     HelpUser(*this);
01105     return;
01106 }
01107 
01108 /********************************************************************************************
01109 ***     Preview bitmap handling code
01110 ********************************************************************************************/
01111 
01112 /********************************************************************************************
01113 
01114 >   afx_msg void BaseFileDialog::OnShowPreviewBitmap()
01115 
01116     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01117     Created:    18/7/96
01118     Returns:    -
01119     Purpose:    Handle the clicks on the buttons which offer the show preview bitmap.
01120                 This is the Windows 95 UI form of the function.
01121 
01122 ********************************************************************************************/
01123 
01124 afx_msg void BaseFileDialog::OnShowPreviewBitmap()
01125 {
01126     if (!CCamApp::IsNewWindowsUI())
01127         return;
01128 
01129     // Do exactly the same as the file name change code does
01130     OnFileNameChange();
01131 }
01132 
01133 /********************************************************************************************
01134 
01135 >   afx_msg void BaseFileDialog::OnOptions()
01136 
01137     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01138     Created:    24/1/97
01139     Returns:    -
01140     Purpose:    Implements the options button installed for WEBSTER
01141                 Base class does nowt
01142 
01143 ********************************************************************************************/
01144 
01145 afx_msg void BaseFileDialog::OnOptions()
01146 {
01147     // WEBSTER - markn 28/1/97
01148     HandleOptions();
01149 }
01150 
01151 /********************************************************************************************
01152 
01153 >   virtual BOOL BaseFileDialog::HandleOptions()
01154 
01155     Author:     Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
01156     Created:    24/1/97
01157     Returns:    -
01158     Purpose:    Implements the options button installed for WEBSTER
01159                 Base class does nowt
01160 
01161 ********************************************************************************************/
01162 
01163 BOOL BaseFileDialog::HandleOptions()
01164 {
01165     return TRUE;
01166 }
01167 
01168 /********************************************************************************************
01169 
01170 >   void BaseFileDialog::OnFileNameChange()
01171 
01172     Author:     Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
01173     Created:    17/7/96
01174     Returns:    -
01175     Purpose:    Should be called when the user has selected a new file in the file list.
01176                 We might need to do things like remove the preview bitmap from the file
01177                 and display it.
01178                 Only called back if OFN_EXPLORER is set and you can only do this on Windows 95
01179                 otherwise a dialog is not popped up.
01180 
01181     SeeAlso:    BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;
01182     SeeAlso:    ExportFileDialog::OnLBSelChangedNotify;
01183 
01184 ********************************************************************************************/
01185 
01186 void BaseFileDialog::OnFileNameChange()
01187 {
01188 #if _MFC_VER >= 0x400
01189     // Remove code completely if using less than MFC4.0 as calls like SetControlText
01190     // will not be present and this function will not work
01191     // Just in case Windows NT 3 decides to call this we'd better stop it as otherwise things
01192     // will be happening more than they should. This is the method used on Windows 95 or NT 4.
01193     if (!CCamApp::IsNewWindowsUI())
01194         return;
01195 
01196     // Graeme (1/12/00) - We need to update ShowPreviewBitmap here. This updates the registry
01197     // settings, and enables the dialogue to remember the show preview bitmap settings. The
01198     // single equals sign is intentional, as I want to perform an assignment, rather than an
01199     // equality operation.
01200     if ( ShowPreviewBitmap = IsDlgButtonChecked ( _R(IDC_SHOWPREVIEW) ) )
01201     {
01202         // Get the filename which the user has entered in the field.
01203         wxString FileName = GetFileName();
01204 
01205         // Added by Craig Hamilton 20/9/00.
01206         // This fixes the problem where a user drags a file over folders within the import
01207         // dialog causing the preview to be redone. If the previously selected file is the
01208         // same as the current then there is no need to regenerate a new preview.
01209         wxString pathName = GetPathName();
01210         if(m_previousPathName != pathName)
01211         {
01212             // Reinitialise. This is the only place this happens.
01213             m_previousPathName = pathName;
01214 
01215             // If its e