BaseFileDialog Class Reference

To provide a custom File Save / Open Dialog that goes to the correct directory etc. More...

#include <filedlgs.h>

Inheritance diagram for BaseFileDialog:

ExportFileDialog ImportFileDialog OpenFileDialog SaveFileDialog GIFExportFileDialog SaveTemplateDialog SliceSaveFileDlg List of all members.

Public Member Functions

 BaseFileDialog (BOOL IsFileOpen, DWORD dwFlags, LPCTSTR lpszFilter=NULL, wxWindow *pParentWnd=NULL)
 ~BaseFileDialog ()
 Standard destructor. Need to clean up the preview bitmap, if present.
virtual BOOL PrepareDialog ()
 Does anything the dialogs want doing after they have been created, but before they are displayed.
virtual INT32 GetSelectedFilterIndex ()
 Allows access in a kernelly fashion to the selected filter index on the common file dialog box.
virtual INT32 SetSelectedFilterIndex (INT32 NewIndex)
 Set the desired index for the filter that is going to be selected on the Common file dialog box.
virtual BOOL SetTitle (INT32 TitleId)
 Allows the title of the common file dialog box to be set up.
virtual BOOL SetInitialDirectory (const String_256 &pDir)
 Sets the directory which the common file dialog box will open looking at.
virtual BOOL SetDefaultFileName (String_256 &Name)
 Sets the name and length of the name of the default file to be used in the common file dialog box.
virtual BOOL GetChosenFileName (PathName *pName)
 Gets the pathname of the file that was chosen by the user. It will return the vailidity of the pathname to the caller. Should be valid as the file dialog box should filter out problem pathnames.
virtual FilterGetSelectedExportFilter (INT32 TheSelectedFilter)
virtual void SetSelectedExportFilter (UINT32 uiFilterID)
 Sets the selected export filter to the ID given.
virtual INT32 OpenAndGetFileName ()
 Opens the common file dialog box up, waits for the user to gives us the filename that they wish to use and either press ok or cancel.
virtual void AppendExtension (wxString *pFilename)
 Given a filename, this function should attach the appropriate file extension to the to it. This baseclass version does nothing.
virtual BOOL IsValidFilename ()
 Makes sure that the filename picked is actually OK. If there is another file of the same name, it checks to see if the user wants to replace it. Moved from SaveFileDialog 9/1/96.
virtual int ShowModal ()
afx_msg void OnPaletteChanged (CWnd *pFocusWnd)

Static Public Member Functions

static BOOL Init ()
 Declares some preferences for the Open and Save dialogs.
static TCHARBuildFilterString (BOOL GetImport, UINT32 SelectedFilterID, INT32 *SelectedFilter, CCRuntimeClass *pTypeOfFilter=CC_RUNTIME_CLASS(Filter), UINT32 Bpp=0, UINT32 BitmapCount=1)
 Build a filter string suitable for use by Windows' common dialog "File open" or "File save" boxes. This is mainly for the import and export dialog boxes. Used to be in OilFiltrs.cpp until moved to BaseFileDialog 5/1/96.

Static Public Attributes

static String_256 DefaultSaveFilePath = TEXT("")
static String_256 DefaultOpenFilePath = TEXT("")
static INT32 SelectedFilter = FILTERID_VECTOR
static BOOL MakeBakFiles = FALSE
static BOOL ShowPreviewBitmap = TRUE
static BOOL ThumbNailMode = FALSE
static BaseFileDialogm_pCurrentFileDialog = NULL

Protected Types

enum  { TITLE_SIZE = 128 }

Protected Member Functions

virtual UINT32 OnHookMsg (wxWindow *hwnd, UINT32 nMsg, WPARAM wParam, LPARAM lParam)
 Called by the common dialog library when it has a message to process. This function checks if the help button has been clicked, and runs the help engine if it has.
virtual UINT32 OnFileTypeChange ()
 Should be called when the user has selected a new file type from the "Files of type" combo box. We might need to do things like fix the file extension for the currently selected save/export filter. Baseclass version.
virtual BOOL ExplorerInitDialog (wxWindow *hDlg)
 Should be called when the explorer style dialog boxes need setting up. We can take this opportunity to add in any extra controls that we require. Baseclass version.
virtual BOOL ExplorerFileHookNotify (wxWindow *hDlg, LPOFNOTIFY pofn)
 Should be called when actions happen on the explorer style dialog boxes. We can take this opportunity to handle these actions as required. Baseclass version.
 DECLARE_DYNAMIC (BaseFileDialog)
afx_msg LRESULT OnRedrawMessage (WPARAM, LPARAM)
 Handles the Redraw control wanting to be drawn. This control is used to display the Preview bitmaps from selected files in the file list. When we get this message we will need to go and find the bitmap from the file and display it. The message is sent up by one of our cc_DialogRedraw custom controls.
afx_msg void OnShowPreviewBitmap ()
 Handle the clicks on the buttons which offer the show preview bitmap. This is the Windows 95 UI form of the function.
afx_msg void OnHelp ()
 Handle the clicks on the help button. This is the Windows 95 UI form of the function.
afx_msg void OnSize (UINT32 nType, INT32 cx, INT32 cy)
afx_msg void OnOptions ()
 Implements the options button installed for WEBSTER Base class does nowt.
virtual BOOL HandleOptions ()
 Implements the options button installed for WEBSTER Base class does nowt.
virtual void OnFileNameChange ()
 Should be called when the user has selected a new file in the file list. We might need to do things like remove the preview bitmap from the file and display it. Only called back if OFN_EXPLORER is set and you can only do this on Windows 95 otherwise a dialog is not popped up.
virtual BOOL GetPreviewBitmapFromFile (PathName *pPath)
 Rips a preview bitmap from the specified file, if appropriate. The class variable pBitmapToUse will contain the bitmap or will contain NULL if no bitmap is found.
virtual BOOL OpenFileForPreview (CCDiskFile &File, PathName *pPath)
 Sets the file up so that the preview image can be read.
virtual BOOL ReadRIFFPreview (CCDiskFile &File, PathName *pPath)
 Reads in the RIFF chunk containing the preview.
virtual BOOL ReadNativePreview (CCDiskFile &File, PathName *pPath)
 Reads in the native file chunk containing the preview.
virtual BOOL ReadBitmapPreview (CCDiskFile &File, PathName *pPath, UINT32 FilterID)
 Creates a preview image from the contents of a bitmap file.
virtual void OnFolderChange ()
 Read preference and apply thumbnail mode if required.
virtual BOOL OnNotify (WPARAM wParam, LPARAM lParam, LRESULT *pResult)
 Used to copy the OPENFILNAMEEX values into the standard OPENFILENAME member variable. This is to support XP-style common file dialogs - the places bar on the left hand side of the dialog.

Static Protected Member Functions

static UINT32 CALLBACK HookProc (wxWindow *hwnd, UINT32 nMsg, WPARAM wParam, LPARAM lParam)

Protected Attributes

TCHAR Title [TITLE_SIZE]
BOOL ExplorerInited
OPENFILENAMEEX m_ofnEx
KernelBitmappBitmapToUse
BOOL WantPreviewBitmap

Private Attributes

wxString m_previousPathName

Detailed Description

To provide a custom File Save / Open Dialog that goes to the correct directory etc.

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

Definition at line 145 of file filedlgs.h.


Member Enumeration Documentation

anonymous enum [protected]
 

Enumerator:
TITLE_SIZE 

Definition at line 219 of file filedlgs.h.

00220     {
00221         TITLE_SIZE = 128
00222     };


Constructor & Destructor Documentation

BaseFileDialog::BaseFileDialog BOOL  IsFileOpen,
DWORD  dwFlags,
LPCTSTR  lpszFilter = NULL,
wxWindow *  pParentWnd = NULL
 

Definition at line 281 of file filedlgs.cpp.

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 }

BaseFileDialog::~BaseFileDialog  ) 
 

Standard destructor. Need to clean up the preview bitmap, if present.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/7/96
Returns:
-

Definition at line 322 of file filedlgs.cpp.

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 }


Member Function Documentation

void BaseFileDialog::AppendExtension wxString *  pFilename  )  [virtual]
 

Given a filename, this function should attach the appropriate file extension to the to it. This baseclass version does nothing.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
9/1/96
Parameters:
pFilename - the filename to append an extension to [INPUTS]
pFilename - the input filename with the .art extension on the end (if needed) [OUTPUTS]

Reimplemented in SaveFileDialog, and ExportFileDialog.

Definition at line 1035 of file filedlgs.cpp.

01036 {
01037     // baseclass version so do nothing
01038 }

TCHAR * BaseFileDialog::BuildFilterString BOOL  GetImport,
UINT32  SelectedFilterID,
INT32 *  SelectedFilter,
CCRuntimeClass pTypeOfFilter = CC_RUNTIME_CLASS(Filter),
UINT32  Bpp = 0,
UINT32  BitmapCount = 1
[static]
 

Build a filter string suitable for use by Windows' common dialog "File open" or "File save" boxes. This is mainly for the import and export dialog boxes. Used to be in OilFiltrs.cpp until moved to BaseFileDialog 5/1/96.

Author:
Tim_Browse (Xara Group Ltd) <camelotdev@xara.com>
Date:
29/03/94
Parameters:
GetImport - TRUE => Build list of Import filters [INPUTS] FALSE => Build list of Export filters SelectedFilterID - the ID of the last filter that was used by the calling Operation. pTypeOfFilter - optional type of filter to use. Defaults to GenericFilter for all. Bpp - if only bitmap filters required then check this bpp against the ones that the filter supports
SelectedFilter - the position in the list box of the selected filter [OUTPUTS] identified by SelectedFilterID, or unchanged if it wasn't found.
Returns:
The filter string.

Errors: Out of memory

See also:
MetaFileFilter;

OpMenuExport; OpMenuImport;

Definition at line 563 of file filedlgs.cpp.

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 }

BaseFileDialog::DECLARE_DYNAMIC BaseFileDialog   )  [protected]
 

BOOL BaseFileDialog::ExplorerFileHookNotify wxWindow *  hDlg,
LPOFNOTIFY  pofn
[protected, virtual]
 

Should be called when actions happen on the explorer style dialog boxes. We can take this opportunity to handle these actions as required. Baseclass version.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/7/96
Parameters:
hDlg - wxWindow* of the dialog box. [INPUTS] pofn - pointer to notify structure
Returns:
TRUE if it worked, FALSE if it failed
See also:
BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;

Definition at line 453 of file filedlgs.cpp.

00454 {
00455     return TRUE;
00456 }

BOOL BaseFileDialog::ExplorerInitDialog wxWindow *  hDlg  )  [protected, virtual]
 

Should be called when the explorer style dialog boxes need setting up. We can take this opportunity to add in any extra controls that we require. Baseclass version.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
2/7/96
Returns:
TRUE if it worked, FALSE if it failed
See also:
BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;

Reimplemented in OpenFileDialog, SaveFileDialog, SaveTemplateDialog, ImportFileDialog, ExportFileDialog, and GIFExportFileDialog.

Definition at line 432 of file filedlgs.cpp.

00433 {
00434     return TRUE;
00435 }

BOOL BaseFileDialog::GetChosenFileName PathName pName  )  [virtual]
 

Gets the pathname of the file that was chosen by the user. It will return the vailidity of the pathname to the caller. Should be valid as the file dialog box should filter out problem pathnames.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96
Parameters:
The pathname that the user chose. [OUTPUTS]
Returns:
TRUE if it worked and patname is valid, FALSE if not

Definition at line 829 of file filedlgs.cpp.

00830 {
00831     TRACEUSER( "luke", _T("FileName is %s\n"), GetPath().c_str() );
00832 
00833     pName->SetPathName( GetPath() );
00834     return pName->IsValid();
00835 }

BOOL BaseFileDialog::GetPreviewBitmapFromFile PathName pPath  )  [protected, virtual]
 

Rips a preview bitmap from the specified file, if appropriate. The class variable pBitmapToUse will contain the bitmap or will contain NULL if no bitmap is found.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/7/96
Returns:
-
See also:
OpenFileDialog::OnFileNameChange;

Definition at line 1277 of file filedlgs.cpp.

01278 {
01279     CCDiskFile      File        ( 1024, FALSE, TRUE );
01280     String_256      Type        ( pPath->GetType() );
01281     KernelBitmap    *pThumbnail = NULL;
01282     BOOL            ReadOK      = FALSE;
01283 
01284     // If there is a preview bitmap in use, delete it first.
01285     if ( pBitmapToUse != NULL )
01286     {
01287         delete pBitmapToUse;
01288         pBitmapToUse = NULL;
01289     }
01290 
01291     // Get lowercase filetype
01292     Type.toLower();
01293 
01294     // Bodge to speed galleries up for art files - doesn't check or use external previews
01295     if ((Type.Sub((String_8)"cdr") != -1) ||
01296         (Type.Sub((String_8)"cmx") != -1) )
01297     {
01298         // Use the RIFF file import code.
01299         ReadOK = ReadRIFFPreview ( File, pPath );
01300     }
01301 
01302     // Read in a native file.
01303     else if ( !Type.Sub ( ( String_8 ) "art" ) ||
01304               !Type.Sub ( ( String_8 ) "xar" ) ||
01305               !Type.Sub ( ( String_8 ) "cxn" ) ||
01306               !Type.Sub ( ( String_8 ) "cxw" ) ||
01307               !Type.Sub ( ( String_8 ) "web" ) )
01308     {
01309         // Use the native file format import code.
01310         ReadOK = ReadNativePreview ( File, pPath );
01311     }
01312 
01313     // Try a PNG.
01314     else if ( !Type.Sub ( ( String_8 ) "png" ) )
01315     {
01316         // Use the PNG import code to load the bitmap up.
01317         ReadOK = ReadBitmapPreview ( File, pPath, FILTERID_PREVIEW_PNG );
01318     }
01319 
01320     // Try a BMP.
01321     else if ( !Type.Sub ( ( String_8 ) "bmp" ) )
01322     {
01323         // Use the BMP import code to load the bitmap up.
01324         ReadOK = ReadBitmapPreview ( File, pPath, FILTERID_PREVIEW_BMP );
01325     }
01326 
01327     // Try a GIF.
01328     else if ( !Type.Sub ( ( String_8 ) "gif" ) )
01329     {
01330         // Use the GIF import code to load the bitmap up.
01331         ReadOK = ReadBitmapPreview ( File, pPath, FILTERID_PREVIEW_GIF );
01332     }
01333 
01334     // Try a JPEG.
01335     else if ( !Type.Sub ( ( String_8 ) "jpg" ) || !Type.Sub ( ( String_8 ) "jpeg" ) )
01336     {
01337         // Use the JPEG import code to load the bitmap up.
01338         ReadOK = ReadBitmapPreview ( File, pPath, FILTERID_IMPORT_JPEG );
01339     }
01340 
01341     // Try a TIFF.
01342     else if ( !Type.Sub ( ( String_8 ) "tif" ) || !Type.Sub ( ( String_8 ) "tiff" ) )
01343     {
01344         // Use the JPEG import code to load the bitmap up.
01345         ReadOK = ReadBitmapPreview ( File, pPath, FILTERID_PREVIEW_TIFF );
01346     }
01347 
01348     // Clear any errors we encountered
01349     Error::ClearError();    
01350 
01351     return ReadOK;
01352 }

Filter * BaseFileDialog::GetSelectedExportFilter INT32  TheSelectedFilter  )  [virtual]
 

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96
Returns:
TRUE if it worked, FALSE if not

Definition at line 848 of file filedlgs.cpp.

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 }

INT32 BaseFileDialog::GetSelectedFilterIndex  )  [virtual]
 

Allows access in a kernelly fashion to the selected filter index on the common file dialog box.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96
Returns:
The index of the selected filter

Definition at line 731 of file filedlgs.cpp.

00732 {
00733     return GetFilterIndex();
00734 }

BOOL BaseFileDialog::HandleOptions  )  [protected, virtual]
 

Implements the options button installed for WEBSTER Base class does nowt.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/1/97
Returns:
-

Reimplemented in SaveFileDialog, ExportFileDialog, and GIFExportFileDialog.

Definition at line 1163 of file filedlgs.cpp.

01164 {
01165     return TRUE;
01166 }

UINT32 CALLBACK BaseFileDialog::HookProc wxWindow *  hwnd,
UINT32  nMsg,
WPARAM  wParam,
LPARAM  lParam
[static, protected]
 

Definition at line 349 of file filedlgs.cpp.

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 }

BOOL BaseFileDialog::Init void   )  [static]
 

Declares some preferences for the Open and Save dialogs.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/1/95
Returns:
TRUE if it worked, FALSE if it failed

Definition at line 490 of file filedlgs.cpp.

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 }

BOOL BaseFileDialog::IsValidFilename  )  [virtual]
 

Makes sure that the filename picked is actually OK. If there is another file of the same name, it checks to see if the user wants to replace it. Moved from SaveFileDialog 9/1/96.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
31/10/95
Returns:
TRUE if the current filename is Acceptable, FALSE if not

Reimplemented in SliceSaveFileDlg, and ExportFileDialog.

Definition at line 941 of file filedlgs.cpp.

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 }

void BaseFileDialog::OnFileNameChange  )  [protected, virtual]
 

Should be called when the user has selected a new file in the file list. We might need to do things like remove the preview bitmap from the file and display it. Only called back if OFN_EXPLORER is set and you can only do this on Windows 95 otherwise a dialog is not popped up.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
17/7/96
Returns:
-
See also:
BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;

ExportFileDialog::OnLBSelChangedNotify;

Reimplemented in SaveTemplateDialog.

Definition at line 1186 of file filedlgs.cpp.

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 empty then return immediately
01216             if (FileName.IsEmpty())
01217                 return;
01218 
01219             PathName Path(FileName.GetBuffer(256));
01220             FileName.ReleaseBuffer();
01221             if (!Path.IsValid())
01222             {
01223                 // There was a problem e.g. user has typed f:
01224                 // Magically a bad pathname sets an error so clear it!
01225                 Error::ClearError();
01226                 return;
01227             }
01228 
01229             BOOL Previous = (pBitmapToUse != NULL);
01230 
01231             BOOL ok = GetPreviewBitmapFromFile(&Path);
01232 
01233             BOOL Now = (pBitmapToUse != NULL);
01234             
01235             // If we have changed state or read a new preview bitmap ok then force a redraw
01236             if ((!Previous && Now) || (Previous && !Now) || ok)
01237             {
01238                 // Force a redraw of the preview bitmap icon, as we have changed state
01239                 wxWindow* Icon = FindWindow( _R(IDC_PREVIEW));
01240                 ::InvalidateRect(Icon, NULL, TRUE);
01241             }
01242         }
01243         // End added.
01244     }
01245     else
01246     {
01247         // Delete the present bitmap so we show nothing
01248         if (pBitmapToUse != NULL)
01249         {
01250             delete pBitmapToUse;
01251             pBitmapToUse = NULL;
01252 
01253             // Force a redraw of the preview bitmap icon, as we have changed state
01254             wxWindow* Icon = FindWindow( _R(IDC_PREVIEW));
01255             ::InvalidateRect(Icon, NULL, TRUE);
01256         }
01257     }
01258 
01259 #endif
01260     return;
01261 }

UINT32 BaseFileDialog::OnFileTypeChange  )  [protected, virtual]
 

Should be called when the user has selected a new file type from the "Files of type" combo box. We might need to do things like fix the file extension for the currently selected save/export filter. Baseclass version.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
12/1/96
Returns:
TRUE if it worked, FALSE if it failed
See also:
BaseFileDialog::OnHookMsg; BaseFileDialog::HookProc;

Definition at line 473 of file filedlgs.cpp.

00474 {
00475     return TRUE;
00476 }

void BaseFileDialog::OnFolderChange  )  [protected, virtual]
 

Read preference and apply thumbnail mode if required.

Author:
Marc_Power (Xara Group Ltd) <camelotdev@xara.com> Creation: 25/01/2005

Definition at line 2055 of file filedlgs.cpp.

02056 {
02057     if(ThumbNailMode)
02058     {
02059         wxWindow* view = FindWindowEx(GetParent()->m_hWnd, 0, "SHELLDLL_DefView", 0);
02060         ::SendMessage(view, WM_COMMAND, FCIDM_SHVIEW_THUMBNAIL, 0);
02061     }
02062 }

afx_msg void BaseFileDialog::OnHelp  )  [protected]
 

Handle the clicks on the help button. This is the Windows 95 UI form of the function.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
30/7/96
Returns:
-

Definition at line 1100 of file filedlgs.cpp.

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 }

UINT32 BaseFileDialog::OnHookMsg wxWindow *  hwnd,
UINT32  nMsg,
WPARAM  wParam,
LPARAM  lParam
[protected, virtual]
 

Called by the common dialog library when it has a message to process. This function checks if the help button has been clicked, and runs the help engine if it has.

Author:
Justin_Flude (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/5/95
Parameters:
(the usual message proc parameters) [INPUTS]
Returns:
FALSE if the dialog library should process this message, TRUE if it should ignore it.
See also:
BaseFileDialog::HookProc

Definition at line 376 of file filedlgs.cpp.

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 }

BOOL BaseFileDialog::OnNotify WPARAM  wParam,
LPARAM  lParam,
LRESULT pResult
[protected, virtual]
 

Used to copy the OPENFILNAMEEX values into the standard OPENFILENAME member variable. This is to support XP-style common file dialogs - the places bar on the left hand side of the dialog.

Author:
Alex
Date:
06/11/2003
Parameters:
wParam - The Windows wParam parameter [INPUTS] lParam - The Windows lParam parameter
Returns:
TRUE

Definition at line 1858 of file filedlgs.cpp.

01859 {
01860     memcpy(&m_ofn, &m_ofnEx, sizeof(m_ofn));
01861     m_ofn.lStructSize = sizeof(m_ofn);
01862 
01863     return CFileDialog::OnNotify(wParam, lParam, pResult);
01864 }

afx_msg void BaseFileDialog::OnOptions  )  [protected]
 

Implements the options button installed for WEBSTER Base class does nowt.

Author:
Mark_Neves (Xara Group Ltd) <camelotdev@xara.com>
Date:
24/1/97
Returns:
-

Definition at line 1145 of file filedlgs.cpp.

01146 {
01147     // WEBSTER - markn 28/1/97
01148     HandleOptions();
01149 }

afx_msg void BaseFileDialog::OnPaletteChanged CWnd *  pFocusWnd  ) 
 

afx_msg LRESULT BaseFileDialog::OnRedrawMessage WPARAM  wParam,
LPARAM  lParam
[protected]
 

Handles the Redraw control wanting to be drawn. This control is used to display the Preview bitmaps from selected files in the file list. When we get this message we will need to go and find the bitmap from the file and display it. The message is sent up by one of our cc_DialogRedraw custom controls.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/3/95
Parameters:
wParam - The Windows wParam parameter [INPUTS] lParam - The Windows lParam parameter
Returns:
TRUE

Definition at line 1640 of file filedlgs.cpp.

01641 {
01642 //  TRACEUSER( "Neville", _T("Draw the Blank version of the control now, as we don't have a filename\n"));
01643 
01644     // Do nothing if not an explorer type dialog box
01645     if (!CCamApp::IsNewWindowsUI())
01646         return TRUE;
01647 
01648     // Find out about the paint message and fill in the details in the kernel message
01649     RedrawInfo* pInfo = (RedrawInfo*) lParam;
01650     ReDrawInfoType ExtraInfo;
01651 
01652     ExtraInfo.pMousePos = NULL;     // No mouse position info for redraw events
01653     
01654     // Build a CC dc out of it for rendering to the screen
01655     // Get a MFC CDC to put the DC in
01656     CCDC MyDc(RENDERTYPE_SCREEN);
01657     MyDc.Attach(pInfo->PaintInfo.hdc);
01658     ExtraInfo.pDC = &MyDc;
01659 
01660     // The devices DPI
01661     ExtraInfo.Dpi = MyDc.GetDeviceCaps(LOGPIXELSY);
01662     
01663     // How big the window is
01664     RECT WindowSize;
01665     if (::GetClientRect((wxWindow*)wParam, &WindowSize))
01666     {
01667         ExtraInfo.dx = (((INT32)WindowSize.right)*72000) / ExtraInfo.Dpi;
01668         ExtraInfo.dy = (((INT32)WindowSize.bottom)*72000) / ExtraInfo.Dpi;
01669     }
01670 
01671     // Work out the size of the invalidated region
01672     RECT* ClipRect = &pInfo->PaintInfo.rcPaint;
01673     DocRect DocClipRect;
01674 
01675     // Convert to millipoints, Also need to flip the y coords to get a
01676     // rectangle in with the origin in the bottom left.
01677     DocClipRect.lo.x = (ClipRect->left * 72000) / ExtraInfo.