OpenFileDialog Class Reference

Brings up an Open file dialog that goes to the correct directory etc. More...

#include <filedlgs.h>

Inheritance diagram for OpenFileDialog:

BaseFileDialog List of all members.

Public Member Functions

 OpenFileDialog (LPCTSTR FilterString)
 Constructs a Open File Dialog. It sets the File Must Exist and Hide Read Only Flags. Call PrepareDialog() then DoModal() to use.
BOOL PrepareDialog ()
 Does anything the dialogs want doing after they have been created, but before they are displayed.
void SetDefaultPath (const String_256 &NewPath)
 Sets the default path. The next open dialog will default to this path.

Static Public Member Functions

static TCHARBuildFilterString (INT32 *NativeFilterPos)
 Builds the string that is passed to the dialog that lists all the file types.

Public Attributes

INT32 NativeFilterPos

Protected Member Functions

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.

Private Member Functions

void OnInitDialog (wxInitDialogEvent &event)
 Changes a few bits and bobs about in the Save Dialog.
void DoDataExchange (CDataExchange *pDX)
 Maintains the state of the "Show preview bitmap" check-box in the open file dialog.
 DECLARE_DYNAMIC (OpenFileDialog)

Detailed Description

Brings up an Open file dialog that goes to the correct directory etc.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/1/95
See also:
BaseFileDialog

Definition at line 315 of file filedlgs.h.


Constructor & Destructor Documentation

OpenFileDialog::OpenFileDialog LPCTSTR  FilterString  ) 
 

Constructs a Open File Dialog. It sets the File Must Exist and Hide Read Only Flags. Call PrepareDialog() then DoModal() to use.

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

Definition at line 2243 of file filedlgs.cpp.

02244   : BaseFileDialog( TRUE, wxFILE_MUST_EXIST, FilterString )
02245 {
02246     // Set some defaults
02247     NativeFilterPos = 0;
02248 
02249 PORTNOTE("other", "Deactivate template usage" )
02250 #if !defined(EXCLUDE_FROM_XARALX)
02251     if (CCamApp::IsNewWindowsUI())
02252     {
02253         // Use our template to do the ammendment and addition of controls to the dialog box
02254         m_ofn.lpTemplateName = MAKEINTRESOURCE(_R(IDD_PREVIEWBITMAP));
02255     }
02256     else
02257         m_ofn.lpTemplateName = NULL;
02258 #endif
02259     
02260     // Set the preview bitmap to be NULL
02261     pBitmapToUse = NULL;
02262 }


Member Function Documentation

TCHAR * OpenFileDialog::BuildFilterString INT32 *  NativeFilterPos  )  [static]
 

Builds the string that is passed to the dialog that lists all the file types.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/1/95
Parameters:
NativeFilterPos - The position in the list of the native filter [OUTPUTS]
Returns:
NULL if there was not enough memory, or a pointer to a CCMalloced bit of memory with a string in it in the form that dialogs like

Definition at line 2457 of file filedlgs.cpp.

02458 {
02459     // Find out how much space is needed
02460     UINT32 FilterSize = 0;
02461     *NativeFilterPos = 0;
02462 
02463     // Used to load in the resource strings for the filter extension descriptions.
02464     String_256 FilterExtensions;
02465 
02466     Filter *pFilter = Filter::GetFirst();
02467     while (pFilter != NULL)
02468     {
02469         FilterFlags Flags = pFilter->GetFlags();
02470 
02471         // little bit of a bodge here to stop the CamelotEPSFilter from appearing in the
02472         // import list - you can't hide it from just one list. It must be availiable though
02473         // to give it's nice little error message. Other instances of this below.
02474         if (Flags.CanImport && Flags.ShowFilter && !IS_A(pFilter, CamelotEPSFilter))
02475         {
02476             // Add the space required to put this into the filter string
02477             // (add 1 for the separating '|' character)
02478             FilterSize += camStrlen(pFilter->pOILFilter->ConstructFilterString()) + 1;
02479         }
02480 
02481         // Try the next filter
02482         pFilter = Filter::GetNext(pFilter);
02483     }
02484 
02485     // Add two for the final "|" and the 0 terminator.
02486     FilterSize += 2;
02487 
02488     // Try to get this string
02489     TCHAR*  FilterString = (TCHAR*)CCMalloc( FilterSize * sizeof(TCHAR) );
02490     if (FilterString==NULL)
02491         // Error state already set by CCMalloc
02492         return NULL;
02493 
02494     // Construct the string, and set up the position numbers for the filters.
02495     UINT32 Position = 0;
02496     FilterString[0] = 0;
02497     pFilter = Filter::GetFirst();
02498 
02499     while (pFilter != NULL)
02500     {
02501         FilterFlags Flags = pFilter->GetFlags();
02502 
02503         if (Flags.CanImport && Flags.ShowFilter && !IS_A(pFilter, CamelotEPSFilter))
02504         {
02505             // Add this filter into the list
02506             camStrcat(FilterString, pFilter->pOILFilter->ConstructFilterString());
02507             camStrcat(FilterString, _T("|"));
02508             pFilter->pOILFilter->Position = Position;
02509 
02510             // see if it is the native filter
02511             if (IS_A(pFilter, CamelotNativeEPSFilter))
02512             {
02513                 *NativeFilterPos = Position;
02514             }
02515 
02516             // increment
02517             Position++;
02518         }
02519         else
02520             // Make sure we don't try this one later
02521             pFilter->pOILFilter->Position = -1;
02522 
02523         // Try the next filter
02524         pFilter = Filter::GetNext(pFilter);
02525     }
02526 
02527     // Terminate the string
02528     camStrcat(FilterString, _T("|"));
02529 
02530     // All ok
02531     return FilterString;
02532 }

OpenFileDialog::DECLARE_DYNAMIC OpenFileDialog   )  [private]
 

void OpenFileDialog::DoDataExchange CDataExchange *  pDX  )  [private]
 

Maintains the state of the "Show preview bitmap" check-box in the open file dialog.

Author:
Neville_Humphrys (Xara Group Ltd) <camelotdev@xara.com>
Date:
18/7/96
Parameters:
(a standard MFC object) [INPUTS]

Definition at line 2430 of file filedlgs.cpp.

02431 {
02432     BaseFileDialog::DoDataExchange(pDX);
02433     //{{AFX_DATA_MAP(CMyDialog)
02434     if (CCamApp::IsNewWindowsUI())
02435     {
02436         DDX_Check(pDX, _R(IDC_SHOWPREVIEW), BaseFileDialog::ShowPreviewBitmap);
02437     }
02438     //}}AFX_DATA_MAP
02439 }

BOOL OpenFileDialog::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.

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

Reimplemented from BaseFileDialog.

Definition at line 2324 of file filedlgs.cpp.

02325 {
02326 PORTNOTE("other", "Remove MFC code" )
02327 #if !defined(EXCLUDE_FROM_XARALX)
02328     // Do nothing of not on explorer type dialog boxes
02329     if (!CCamApp::IsNewWindowsUI())
02330         return TRUE;
02331 
02332 
02333     // Set up and initialise the new buttons and controls
02334 
02335     // Give it the correct state according to the preference.
02336     wxCheckBox* pCheck = (wxCheckBox*)FindWindow( _R(IDC_SHOWPREVIEW));
02337     pCheck->SetValue( BaseFileDialog::ShowPreviewBitmap != FALSE );
02338 
02339     wxWindow*   Icon = FindWindow( _R(IDC_PREVIEW));
02340     Icon->EnableWindow(TRUE);
02341 
02342     // WEBSTER - markn 28/1/97
02343     Icon = FindWindow( _R(IDC_FILEDLG_OPTIONS));
02344     Icon->Show( false );
02345 
02346     //Graham 27/10/97: And the "use as default" button
02347     Icon = FindWindow( _R(IDC_USEASDEFAULT));
02348     Icon->ShowWindow( false );
02349     
02350     // Move the Preview box down a little, so that it lines up with the top of the List box
02351     wxWindow*   wndDlg = GetParent();
02352     wxWindow*   pWndPreview = FindWindow( _R(IDC_PREVIEW) );
02353     wxRect      rPreview, rList;
02354     pWndPreview->GetWindowRect(&rPreview);
02355     ScreenToClient(rPreview);
02356     wxWindow*   pWndList = wndDlg->GetDlgItem(lst1);    // lst1 is the ID for the main list box
02357     pWndList->GetWindowRect(&rList);
02358     ScreenToClient(rList);
02359     pWndPreview->SetWindowPos(NULL, rPreview.GetLeft(), rList.GetTop(), 
02360         rPreview.GetWidth(), rPreview.GetHeight(), 0);
02361 
02362     ExplorerInited = TRUE;
02363 #endif
02364 
02365     return TRUE;
02366 }

void OpenFileDialog::OnInitDialog wxInitDialogEvent &  event  )  [private]
 

Changes a few bits and bobs about in the Save Dialog.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
25/1/95
Returns:
TRUE => normal window focus is required.
See also:
SaveFileDialog

Definition at line 2276 of file filedlgs.cpp.

02277 {
02278     // Set up the string we require
02279     String_256 NewText(_R(IDS_OPENBUTTON));
02280     const TCHAR* NewTextStr = NewText;
02281 
02282     // Get the handle of the ok button.
02283     wxWindow* OkButton = FindWindow( wxID_OK );
02284 
02285     // Now replace the 'ok' by 'Save' and return
02286     OkButton->SetLabel( NewTextStr );
02287 
02288 PORTNOTE("other", "Remove code to make filter combo-deeper" )
02289 #if !defined(EXCLUDE_FROM_XARALX)
02290     // Get the handle of the filter list box.
02291     wxWindow* ComboBox = FindWindow( cmb1 );
02292 
02293     // Find out where the list box is.
02294     WINDOWPLACEMENT Placement;
02295     Placement.length = sizeof(WINDOWPLACEMENT);
02296     ::GetWindowPlacement(ComboBox, &Placement);
02297 
02298     // Make the list box deeper than usual
02299     ::MoveWindow(ComboBox,
02300                  Placement.rcNormalPosition.left,
02301                  Placement.rcNormalPosition.top,
02302                  Placement.rcNormalPosition.right - Placement.rcNormalPosition.left,
02303                  (Placement.rcNormalPosition.bottom - Placement.rcNormalPosition.top) * 5,
02304                  TRUE);
02305 #endif
02306     
02307     // Let the base class do its thang . . .
02308     return BaseFileDialog::OnInitDialog( event );
02309 }

BOOL OpenFileDialog::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 from BaseFileDialog.

Definition at line 2381 of file filedlgs.cpp.

02382 {
02383     // Set the dialogs Title
02384     if (SmartLoadString(0, _R(IDS_OPENTITLE), Title, 128))
02385         wxFileDialog::SetTitle( Title );
02386 
02387     // Select the desired path
02388     if (DefaultOpenFilePath.Length() <= 0)
02389         DefaultOpenFilePath = wxStandardPaths::Get().GetUserConfigDir();
02390 
02391     SetDirectory( DefaultOpenFilePath );
02392 
02393     // Choose the initial filter
02394     SetFilterIndex( SelectedFilter );
02395 
02396     // See if the base class wants to do anything
02397     return BaseFileDialog::PrepareDialog();
02398 }

void OpenFileDialog::SetDefaultPath const String_256 NewPath  ) 
 

Sets the default path. The next open dialog will default to this path.

Author:
Rik_Heywood (Xara Group Ltd) <camelotdev@xara.com>
Date:
26/1/95
Parameters:
NewPath - The path to use as the default [INPUTS]

Definition at line 2411 of file filedlgs.cpp.

02412 {
02413     // Set the default path
02414     DefaultOpenFilePath = NewPath;
02415 }


Member Data Documentation

INT32 OpenFileDialog::NativeFilterPos
 

Definition at line 321 of file filedlgs.h.


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