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.Dpi;
01678     DocClipRect.lo.y = ExtraInfo.dy - ((ClipRect->bottom * 72000) / ExtraInfo.Dpi);
01679 
01680     DocClipRect.hi.x = (ClipRect->right * 72000) / ExtraInfo.Dpi;
01681     DocClipRect.hi.y = ExtraInfo.dy - ((ClipRect->top * 72000) / ExtraInfo.Dpi);
01682 
01683     // Set the pointer in the extra info structure
01684     ExtraInfo.pClipRect = &DocClipRect;
01685 
01686     // Go get a render region
01687     DocRect VirtualSize(0, 0, ExtraInfo.dx, ExtraInfo.dy);
01688     RenderRegion* pRender = CreateOSRenderRegion(&VirtualSize, &ExtraInfo);
01689     if (pRender!=NULL)
01690     {
01691         // Code stolen from ColourEditDlg::RenderControl
01692         DialogColourInfo RedrawColours;     // Get a supplier for default dlg colours
01693         INT32 PixelSize = 72000 / ExtraInfo.Dpi;        // Size of output pixel in millipoints
01694 
01695         // Render the attributes and then a rectangle
01696         pRender->SaveContext();
01697 
01698         // pBitmapToUse stores the preview bitmap of the current file
01699         if (pBitmapToUse)
01700         {
01701             // bring the left hand edge in one pixel.
01702             VirtualSize.lox += PixelSize;
01703 
01704             // Using this method we don't get flicker on the backdrop as we draw the background rectangle
01705             // followed by the white new background
01706             // Draw single pixel black line left and top and single pixel background colour 1 pixel in
01707             pRender->SetLineWidth(0);
01708             pRender->SetFillColour(RedrawColours.DialogBack());
01709             pRender->SetLineColour(COLOUR_BLACK); //RedrawColours.ButtonShadow());
01710             pRender->DrawLine(DocCoord(VirtualSize.lo.x, VirtualSize.hi.y), VirtualSize.hi);    // Top Left to Top Right
01711             pRender->DrawLine(DocCoord(VirtualSize.lo.x, VirtualSize.hi.y), VirtualSize.lo);    // Top Left to Bottom Left
01712             pRender->SetLineColour(RedrawColours.DialogBack());
01713             pRender->DrawLine(DocCoord(VirtualSize.lo.x + PixelSize, VirtualSize.hi.y - PixelSize),
01714                               DocCoord(VirtualSize.hi.x, VirtualSize.hi.y - PixelSize));        // Top Left to Top Right
01715             pRender->DrawLine(DocCoord(VirtualSize.lo.x + PixelSize, VirtualSize.lo.y),
01716                               DocCoord(VirtualSize.lo.x + PixelSize, VirtualSize.hi.y - PixelSize)); // Bottom Left to Top Left
01717 
01718             // Draw single pixel highlight line right and bottom and single pixel background colour 1 pixel in
01719             pRender->SetLineColour(RedrawColours.ButtonHighlight());
01720             pRender->DrawLine(DocCoord(VirtualSize.hi.x, VirtualSize.hi.y - PixelSize),
01721                               DocCoord(VirtualSize.hi.x, VirtualSize.lo.y));
01722             pRender->DrawLine(DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.lo.y + PixelSize),
01723                               DocCoord(VirtualSize.lo.x + PixelSize, VirtualSize.lo.y + PixelSize));
01724 
01725             pRender->SetLineColour(RedrawColours.DialogBack());
01726             pRender->DrawLine(DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.hi.y - PixelSize),
01727                               DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.lo.y + 2 * PixelSize));
01728             pRender->DrawLine(DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.lo.y + 2 * PixelSize),
01729                               DocCoord(VirtualSize.lo.x + PixelSize, VirtualSize.lo.y + 2 * PixelSize));
01730             
01731             // put the left hand edge back again
01732             VirtualSize.lox -= PixelSize;
01733 
01734             // And deflate the rect by 2 pixels
01735             VirtualSize.Inflate(-PixelSize * 2);
01736 
01737             // Code stolen from BfxDlg::RenderBitmap
01738             pRender->SetLineColour(COLOUR_TRANS);
01739 
01740             // Draw a rectangle to fill in the background - Fill with Dialogue Background colour
01741             pRender->SetFillColour(COLOUR_WHITE);
01742             pRender->DrawRect(&VirtualSize);
01743 
01744             NodeBitmap NB;
01745             NodeBitmap * pNodeBitmap = &NB;
01746         
01747             if (!((pNodeBitmap == NULL) || (!pNodeBitmap->SetUpPath(12,12))))
01748             {
01749                 // Get a new bitmap object for this node.
01750                 pNodeBitmap->GetBitmapRef()->SetBitmap(pBitmapToUse);
01751                         
01752                 ENSURE(pNodeBitmap->GetBitmap()->ActualBitmap != NULL, "No bitmap object found!");
01753         
01754                 DocRect BitmapSize(VirtualSize);
01755                 BitmapInfo BMInfo;
01756                 pBitmapToUse->ActualBitmap->GetInfo(&BMInfo);
01757                 if (BMInfo.PixelWidth==0) BMInfo.PixelWidth=1;
01758                 if (BMInfo.PixelHeight==0) BMInfo.PixelHeight=1;
01759 
01760                 double BMAspect = ((double)(BMInfo.PixelWidth))/((double)(BMInfo.PixelHeight));
01761                 double RedrawAspect = ((double)(ExtraInfo.dx))/((double)(ExtraInfo.dy));
01762 
01763                 if (BMAspect>RedrawAspect)
01764                 {
01765                     // background colour at top and bottom
01766                     INT32 NewHeight = (INT32)( 0.5 + ((double)(VirtualSize.Width()))/BMAspect);
01767                     if (NewHeight<1) NewHeight = 1;
01768                     BitmapSize.loy = (VirtualSize.hiy + VirtualSize.loy - NewHeight) / 2;
01769                     BitmapSize.hiy = BitmapSize.loy + NewHeight;
01770                 }
01771                 else
01772                 {
01773                     // background colour on left and right
01774                     INT32 NewWidth = (INT32)( 0.5 + ((double)(VirtualSize.Height()))*BMAspect);
01775                     if (NewWidth<1) NewWidth = 1;
01776                     BitmapSize.lox = (VirtualSize.hix + VirtualSize.lox - NewWidth) / 2;
01777                     BitmapSize.hix = BitmapSize.lox + NewWidth;
01778                 }
01779 
01780                 // And set this in our bitmap node
01781                 pNodeBitmap->CreateShape(BitmapSize);
01782 
01783                 QualityAttribute* pQualAttr = new QualityAttribute;
01784                 if (pQualAttr != NULL)
01785                 {
01786                     // If all that worked then turn on anti-aliasing when drawing the bitmap in preview.
01787                     pQualAttr->QualityValue = Quality::QualityMax;
01788                     pRender->SetQuality(pQualAttr, TRUE);
01789                 }
01790 
01791                 pNodeBitmap->Render(pRender);
01792             }
01793         }
01794         else
01795         {
01796             // make the right hand side out of the box so that the right black line does not show
01797             VirtualSize.hix += PixelSize;
01798 
01799             // Draw a backgound making sure we blat anything previously there wiht the dialog
01800             // background colour
01801             pRender->SetLineWidth(0);
01802             pRender->SetFillColour(RedrawColours.DialogBack());
01803             pRender->SetLineColour(COLOUR_BLACK); //RedrawColours.ButtonShadow());
01804             pRender->DrawRect(&VirtualSize);
01805             pRender->DrawLine(DocCoord(VirtualSize.lo.x, VirtualSize.hi.y), VirtualSize.hi);
01806 
01807             pRender->SetLineWidth(0);
01808             pRender->SetLineColour(RedrawColours.ButtonHighlight());
01809             pRender->DrawLine(DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.hi.y - PixelSize), DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.lo.y));
01810             pRender->DrawLine(DocCoord(VirtualSize.hi.x - PixelSize, VirtualSize.lo.y + PixelSize), DocCoord(VirtualSize.lo.x + PixelSize, VirtualSize.lo.y + PixelSize)); // Bottom Right to Bottom Left
01811 
01812             // bring the right hand side back in
01813             VirtualSize.hix -= PixelSize;
01814             // bring the bottom up
01815             VirtualSize.loy += PixelSize;
01816 
01817             // Draw the no bitmap present cross i.e. vertical
01818             // And Deflate the rect by 1 pixels so we draw to the outer lines
01819             VirtualSize.Inflate(-PixelSize);
01820             INT32 Width = VirtualSize.Width();
01821             INT32 Height = VirtualSize.Height();
01822             pRender->SetLineWidth(0);
01823             pRender->SetLineColour(COLOUR_BLACK);
01824             pRender->DrawLine(DocCoord(VirtualSize.lo.x + Width/2, VirtualSize.lo.y),
01825                               DocCoord(VirtualSize.lo.x + Width/2, VirtualSize.hi.y));
01826             pRender->DrawLine(DocCoord(VirtualSize.lo.x, VirtualSize.lo.y + Height/2),
01827                               DocCoord(VirtualSize.hi.x, VirtualSize.lo.y + Height/2));
01828         }
01829 
01830         pRender->RestoreContext();
01831 
01832         // Get rid of the render region
01833         DestroyOSRenderRegion(pRender);
01834     }
01835 
01836     // Give back the dc
01837     MyDc.Detach();
01838 
01839     return TRUE;
01840 }

afx_msg void BaseFileDialog::OnShowPreviewBitmap  )  [protected]
 

Handle the clicks on the buttons which offer the show preview bitmap. This is the Windows 95 UI form of the function.

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

Definition at line 1124 of file filedlgs.cpp.

01125 {
01126     if (!CCamApp::IsNewWindowsUI())
01127         return;
01128 
01129     // Do exactly the same as the file name change code does
01130     OnFileNameChange();
01131 }

void BaseFileDialog::OnSize UINT32  nType,
INT32  cx,
INT32  cy
[protected]
 

Author:
Alex
Date:
12/02/2004
Parameters:
nType - [INPUTS] cx - cy -

Definition at line 1983 of file filedlgs.cpp.

01984 {
01985     wxFileDialog::OnSize(nType, cx, cy);
01986     
01987     // move the darn Help button!!
01988     CWnd *wndPreview = GetDlgItem(_R(IDC_PREVIEW));
01989     CWnd *wndHelpButton = GetDlgItem(_R(ID_CC_HELP_BUTTON));
01990     CWnd *wndDlg = GetParent();
01991     CWnd *wndCancelButton = wndDlg->GetDlgItem(IDCANCEL);
01992     if(wndPreview && wndHelpButton)
01993     {
01994         wxRect rPreview, rCancel, rHelp;
01995         wndCancelButton->GetWindowRect(&rCancel);
01996         ScreenToClient(&rCancel);
01997         wndPreview->GetWindowRect(&rPreview);
01998         ScreenToClient(&rPreview);
01999         wndHelpButton->GetWindowRect(&rHelp);
02000         ScreenToClient(&rHelp);
02001 
02002         wndHelpButton->SetWindowPos(NULL, rPreview.left, rCancel.top, 0, 0, SWP_NOSIZE);    // SWP_NOSIZE to keep the current button size
02003     }
02004 
02005 }

BOOL BaseFileDialog::OpenAndGetFileName  )  [virtual]
 

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.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96
Returns:
True if the user pressed ok on the dialog box, False otherwise

Definition at line 909 of file filedlgs.cpp.

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 }

BOOL BaseFileDialog::OpenFileForPreview CCDiskFile File,
PathName pPath
[protected, virtual]
 

Sets the file up so that the preview image can be read.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/5/00
Parameters:
&File - The file containing the preview bitmap. [INPUTS] pPath - The pathname of the file.
Returns:
TRUE - The file was opened OK. FALSE - An error occured.

Definition at line 1369 of file filedlgs.cpp.

01371 {
01372     // Don't error, just set exceptions...
01373     BOOL Found = FALSE;
01374 
01375     // Open file and check if it exists at the same time
01376     TRY
01377     {
01378         Found = File.open(*pPath, ios::in | ios::binary | ios::nocreate);
01379     }       
01380     CATCH( CFileException, e)
01381     {
01382         Found = FALSE;
01383         Error::ClearError();
01384     }
01385     END_CATCH
01386 
01387     return Found;
01388 }

BOOL BaseFileDialog::PrepareDialog  )  [virtual]
 

Does anything the dialogs want doing after they have been created, but before they are displayed.

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

Reimplemented in OpenFileDialog, SaveFileDialog, and SaveTemplateDialog.

Definition at line 524 of file filedlgs.cpp.

00525 {
00526     // Nothing to do in this base class . . .
00527     return TRUE;
00528 }

BOOL BaseFileDialog::ReadBitmapPreview CCDiskFile File,
PathName pPath,
UINT32  FilterID
[protected, virtual]
 

Creates a preview image from the contents of a bitmap file.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/5/00
Parameters:
&File - The file containing the preview bitmap. [INPUTS] pPath - The pathname of the file. FilterID - The filter to use.
Returns:
TRUE - The preview bitmap was created successfully. FALSE - An error occurred.

Definition at line 1567 of file filedlgs.cpp.

01570 {
01571     // Set up the default return value.
01572     BOOL Result = FALSE;
01573 
01574     // Try to open the file.
01575     if ( OpenFileForPreview ( File, pPath ) )
01576     {
01577         // Find the first filter in the filter list.
01578         Filter* pFilter = Filter::GetFirst ();
01579 
01580         // Scan through the list of filters until the correct one is found.
01581         while ( ( pFilter != NULL ) && ( pFilter->FilterID != FilterID ) )
01582         {
01583             // Try the next filter
01584             pFilter = Filter::GetNext ( pFilter );
01585         }
01586 
01587         // If a filter has been found, load up its contents. The IS_KIND_OF is a sanity
01588         // check to ensure that the SetPreviewBitmap isn't called on (e.g.) a vector
01589         // filter.
01590         if ( pFilter != NULL && pFilter->IS_KIND_OF ( BaseBitmapFilter ) )
01591         {
01592             // It's necessary to cast the filter to be a base bitmap filter, so
01593             // that the bitmap loading code is exposed.
01594             BaseBitmapFilter *pBMPFilter = static_cast<BaseBitmapFilter*> ( pFilter );
01595 
01596             // Tell the filter that it *IS* a preview bitmap.
01597             pBMPFilter->SetPreviewBitmap ( TRUE );
01598 
01599             // Attempt to read the preview in from the file.
01600             if ( pBMPFilter->ImportBitmap ( &File, &pBitmapToUse ) )
01601             {
01602                 // It didn't work.
01603                 Result = TRUE;
01604             }
01605 
01606             // Something went wrong with the input, so clean up the bitmap.
01607             else
01608             {
01609                 // Delete the bitmap.
01610                 delete pBitmapToUse;
01611                 pBitmapToUse = NULL;
01612             }
01613 
01614             // I need to manually shutdown the loading bar.
01615             EndSlowJob ();
01616         }
01617     }
01618 
01619     // Return to the main loop.
01620     return Result;
01621 }

BOOL BaseFileDialog::ReadNativePreview CCDiskFile File,
PathName pPath
[protected, virtual]
 

Reads in the native file chunk containing the preview.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/5/00
Parameters:
&File - The file containing the preview bitmap. [INPUTS] pPath - The pathname giving the location of the file.
Returns:
TRUE - The preview bitmap was created successfully. FALSE - An error occurred.

Definition at line 1456 of file filedlgs.cpp.

01458 {
01459     // Now that we have had the decision to make .cxns become .xars, we must check to see if
01460     // its a new native file before just doing a straight Accusoft read. This will have the
01461     // added side effect of ensuring Accusoft do not see the native format files, without
01462     // our helping hand as to where they can look. Otherwise, they are likely to access
01463     // violate.
01464     BOOL    Result      = FALSE;
01465     BOOL    IsNewFormat = FALSE;
01466     UINT32  FilterId    = FILTERID_NONE;
01467 
01468     // Try to open the file up to get the preview image first!
01469     if ( !OpenFileForPreview ( File, pPath ) )
01470     {
01471         return FALSE;
01472     }
01473 
01474     // In the process it will position the file at the start of the preview bitmap image
01475     // and get the image type
01476     // Use the special version of the function to read in bitmap which uses the present
01477     // file offset as the place that the image is stored.
01478     if ( BaseCamelotFilter::SkipToPreviewBitmap ( &File, &IsNewFormat, &FilterId ) &&
01479          ( FilterId != FILTERID_NONE ) )
01480     {
01481         // Load in the bitmap starting from the present point in the file       
01482         Filter* pFilter = Filter::GetFirst();
01483 
01484         while ((pFilter != NULL) && (pFilter->FilterID != FilterId))
01485         {
01486             // Try the next filter
01487             pFilter = Filter::GetNext(pFilter);
01488         }
01489 
01490         if ( pFilter != NULL )
01491         {
01492             // Ensure that it's a bitmap filter.
01493             ERROR3IF ( !pFilter->IS_KIND_OF ( BaseBitmapFilter ),
01494                         "Preview filter is not a BaseBitmapFilter\n" );
01495 
01496             // It's necessary to cast the filter to be a base bitmap filter, so
01497             // that the bitmap loading code is exposed.
01498             BaseBitmapFilter *pBMPFilter = static_cast<BaseBitmapFilter*> ( pFilter );
01499 
01500             // Attempt to read the preview in from the file.
01501             if ( pBMPFilter->ImportBitmap ( &File, &pBitmapToUse ) )
01502             {
01503                 // It worked!
01504                 Result = TRUE;
01505             }
01506             else
01507             {
01508                 // Import failed! Delete the bitmap.
01509                 delete pBitmapToUse;
01510                 pBitmapToUse = NULL;
01511             }
01512 
01513             // I need to manually shutdown the loading bar.
01514             EndSlowJob ();
01515         }
01516     }
01517 
01518     // Try to use another method.
01519     else if ( !IsNewFormat && AccusoftFilters::GetVersionNumber() > 0 )
01520     {
01521         // Old format had a preview as the first thing in the file so
01522         // Just do a straight load from the start of the file
01523         // But only if not a new format file as otherwise Accusoft does its usual lets load
01524         // something spappy.
01525 
01526         // Create a new bitmap record.
01527         WinBitmap *pBMP = new WinBitmap;
01528         
01529         // Read in and create the new bitmap.
01530         if ( pBMP != NULL && 
01531              AccusoftFilters::ReadFromFile ( &File, &pBMP->BMInfo, &pBMP->BMBytes, TRUE ) &&
01532              ( pBitmapToUse = new KernelBitmap ( pBMP, TRUE ) ) != NULL )
01533         {
01534             // It worked!
01535             Result = TRUE;
01536         }
01537 
01538         // The bitmap wasn't loaded.
01539         else
01540         {
01541             // Import failed! Delete the bitmap.
01542             delete pBMP;
01543         }
01544     }
01545 
01546     // Return a pointer to the bitmap loaded from the file.
01547     return Result;
01548 }

BOOL BaseFileDialog::ReadRIFFPreview CCDiskFile File,
PathName pPath
[protected, virtual]
 

Reads in the RIFF chunk containing the preview.

Author:
Graeme_Sutherland (Xara Group Ltd) <camelotdev@xara.com>
Date:
16/5/00
Parameters:
&File - The file containing the preview bitmap. [INPUTS] pPath - The pathname giving the location of the file.
Returns:
TRUE - The preview bitmap was created successfully. FALSE - An error occurred.

Definition at line 1405 of file filedlgs.cpp.

01407 {
01408     // Set up the return variable.
01409     BOOL Result = FALSE;
01410     
01411     // Attempt to open the file, and read in the preview from the CMX or CDR file.
01412     if ( OpenFileForPreview ( File, pPath ) &&
01413          AccusoftFilters::GetVersionNumber() > 0 &&
01414          CMXImportFilter::SkipToPreviewBitmap ( &File ) )
01415     {
01416         WinBitmap *pThumbnail = new WinBitmap;
01417 
01418         // Attempt to read in the bitmap.
01419         if ( !AccusoftFilters::ReadFromFile ( &File, &pThumbnail->BMInfo,
01420                                               &pThumbnail->BMBytes, TRUE, NULL,
01421                                               NULL, TRUE ) )
01422         {
01423             // It failed to load, so clean up the bitmap.
01424             delete pThumbnail;
01425             pThumbnail = NULL;
01426         }
01427 
01428         // Create a kernel bitmap.
01429         else if ( pThumbnail != NULL &&
01430                   ( pBitmapToUse = new KernelBitmap ( pThumbnail, TRUE ) ) != NULL )
01431         {
01432             // It worked.
01433             Result = TRUE;
01434         }
01435     }
01436 
01437     // Return whether it worked or not.
01438     return Result;
01439 }

BOOL BaseFileDialog::SetDefaultFileName String_256 Name  )  [virtual]
 

Sets the name and length of the name of the default file to be used in the common file dialog box.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96
Parameters:
Name name of the file to be used by default [INPUTS]
Returns:
TRUE if it worked, FALSE if not

Definition at line 808 of file filedlgs.cpp.

00809 {
00810     SetFilename( PCTSTR(Name) );
00811         
00812     return TRUE;
00813 }

BOOL BaseFileDialog::SetInitialDirectory const String_256 strDir  )  [virtual]
 

Sets the directory which the common file dialog box will open looking at.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
4/1/96
Parameters:
pDir String containing the pathname to use [INPUTS]
Returns:
TRUE if it worked, FALSE if not

Definition at line 788 of file filedlgs.cpp.

00789 {
00790     SetDirectory( PCTSTR(strDir) );
00791     
00792     return TRUE;
00793 }

void BaseFileDialog::SetSelectedExportFilter UINT32  uiFilterID  )  [virtual]
 

Sets the selected export filter to the ID given.

Author:
Graham_Walmsley (Xara Group Ltd) <camelotdev@xara.com>
Date:
3/7/97
Returns:
-

Definition at line 877 of file filedlgs.cpp.

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 }

INT32 BaseFileDialog::SetSelectedFilterIndex INT32  NewIndex  )  [virtual]
 

Set the desired index for the filter that is going to be selected on the Common file dialog box.

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

Definition at line 748 of file filedlgs.cpp.

00749 {
00750     INT32 Old = GetFilterIndex();
00751     SetFilterIndex( NewIndex );
00752     TRACEUSER( "Neville", _T("SetSelectedFilterIndex - new %d (old = %d)\n"), NewIndex, Old);
00753     return Old;
00754 }

BOOL BaseFileDialog::SetTitle INT32  TitleId  )  [virtual]
 

Allows the title of the common file dialog box to be set up.

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

Definition at line 767 of file filedlgs.cpp.

00768 {
00769     if (SmartLoadString(0, TitleId, Title, 128))
00770         SetName( Title );
00771     
00772     return TRUE;
00773 }

virtual int BaseFileDialog::ShowModal  )  [virtual]
 


Member Data Documentation

String_256 BaseFileDialog::DefaultOpenFilePath = TEXT("") [static]
 

Definition at line 152 of file filedlgs.h.

String_256 BaseFileDialog::DefaultSaveFilePath = TEXT("") [static]
 

Definition at line 151 of file filedlgs.h.

BOOL BaseFileDialog::ExplorerInited [protected]
 

Definition at line 236 of file filedlgs.h.

OPENFILENAMEEX BaseFileDialog::m_ofnEx [protected]
 

Definition at line 289 of file filedlgs.h.

BaseFileDialog * BaseFileDialog::m_pCurrentFileDialog = NULL [static]
 

Definition at line 212 of file filedlgs.h.

wxString BaseFileDialog::m_previousPathName [private]
 

Definition at line 300 of file filedlgs.h.

BOOL BaseFileDialog::MakeBakFiles = FALSE [static]
 

Definition at line 155 of file filedlgs.h.

KernelBitmap* BaseFileDialog::pBitmapToUse [protected]
 

Definition at line 294 of file filedlgs.h.

INT32 BaseFileDialog::SelectedFilter = FILTERID_VECTOR [static]
 

Definition at line 153 of file filedlgs.h.

BOOL BaseFileDialog::ShowPreviewBitmap = TRUE [static]
 

Definition at line 156 of file filedlgs.h.

BOOL BaseFileDialog::ThumbNailMode = FALSE [static]
 

Definition at line 157 of file filedlgs.h.

TCHAR BaseFileDialog::Title[TITLE_SIZE] [protected]
 

Definition at line 224 of file filedlgs.h.

BOOL BaseFileDialog::WantPreviewBitmap [protected]
 

Definition at line 296 of file filedlgs.h.


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