VCOM:VectorWorks:Filing:IFileChooserDialog

From Vectorworks Developer
Revision as of 16:41, 16 December 2015 by Pchang (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

.SDK|SDK ..SDK:Types|SDK Types ..VCOM:VCOM (Vectorworks Component Object Model)|VCOM Basics ..VCOM:Class Reference|VCOM Class Reference

Description

namespace VectorWorks::Filing

This interface shows the OS dialog for choosing file. There are two modes of this dialog, choosing file for reading and for saving.

The interface allows you to specify filter for the shown files. The filter is composed of file extensions list. On Win this list is shows as different filter entries. On Mac there is no such thing and the filter's file extensions are combined into one list that is used to enable the files with those extensions. If in the list 'Show All' is present then all the files are shown on Mac regardless the other extensions in the filter list.

File choose dialog for windows File choose dialog for Mac

Interface

// ----------------------------------------------------------------------------------------------------
// {885F311B-3795-11DB-9C35-00508D5E9851}
static const VWIID IID_FileChooserDialog = { 0x885F311B, 0x3795, 0x11DB, { 0x9C, 0x35, 0x00, 0x50, 0x8D, 0x5E, 0x98, 0x51 } };

class IFileChooserDialog : public IVWUnknown
{
public:
  virtual VCOMError VCOM_CALLTYPE SetTitle(const TXString& title) = 0;
  virtual VCOMError VCOM_CALLTYPE SetDefaultFile(IFileIdentifier* pFileID) = 0;
  virtual VCOMError VCOM_CALLTYPE SetDefaultFileName(const TXString& name) = 0;
  virtual VCOMError VCOM_CALLTYPE SetDefaultExtension(const TXString& ext) = 0;

  virtual VCOMError VCOM_CALLTYPE SetInitialFolder(IFolderIdentifier* pFolderID) = 0;

  virtual VCOMError VCOM_CALLTYPE SetMultiSelect(bool bMultiSelect) = 0;
  virtual VCOMError VCOM_CALLTYPE SetCheckFileExist(bool bCheckExist) = 0;
  virtual VCOMError VCOM_CALLTYPE SetCheckFolderExist(bool bCheckExist) = 0;

  virtual VCOMError VCOM_CALLTYPE GetSelectedFileNamesCount(Uint32& outValue) = 0;
  virtual VCOMError VCOM_CALLTYPE GetSelectedFileName(Uint32 fileIndex, IFileIdentifier** ppOutFileID) = 0;

  virtual VCOMError VCOM_CALLTYPE ClearFilters() = 0;
  virtual VCOMError VCOM_CALLTYPE SetAddFileExtInFilter(bool bAddExt) = 0;
  virtual VCOMError VCOM_CALLTYPE AddFilterAllFiles() = 0;
  virtual VCOMError VCOM_CALLTYPE AddFilter(const TXString& filterExt, const TXString& filterDesc) = 0;
  virtual VCOMError VCOM_CALLTYPE AddFilter(const TXStringArray& arrFilterExts, const TXString& filterDesc) = 0;

  virtual VCOMError VCOM_CALLTYPE GetSelectedFilterIndex(Uint32& outValue) = 0;
  virtual VCOMError VCOM_CALLTYPE SetSelectedFilter(Uint32 index) = 0;

  virtual VCOMError VCOM_CALLTYPE RunOpenDialog() = 0;
  virtual VCOMError VCOM_CALLTYPE RunSaveDialog() = 0;
};

Members

SetTitle Set the title of the dialog that is to be opened.
SetDefaultFile Set default file for the dialog when opened.
SetDefaultFileName Set default file name that should appear in the dialog when opened.
SetDefaultExtension Set default file extension that should appear in the dialog when opened.
SetInitialFolder Set initial folder to be selected when the dialog opens.
SetMultiSelect Enable multiple file selection.
SetCheckFileExist Specify if the dialog should check if the file exist before closing.
SetCheckFolderExist Specify if the dialog should check if the folder exist before closing.
GetSelectedFileNamesCount Returns the count of selected files.
GetSelectedFileName Return specified selected file.
ClearFilters Clears filter list.
SetAddFileExtInFilter Determines if the dialog should append the file extension for the filter list to the file name in the dialog.
AddFilterAllFiles Adds "All Files" to the filter list.
AddFilter Adds filter to the filter list.
GetSelectedFilterIndex After closing dialog returns the selected filter that user closed the dialog with.
SetSelectedFilter Specifies what is the active filter when the dialog opens.
RunOpenDialog Creates file open dialog.
RunSaveDialog Create file save dialog.
SetDescription This sets the text field above the control that displays all of the files (beneath the title bar).
SetPermitExtensionHiding This sets whether or not the end-user is allowed to hide the file extension on Mac OS X.
AddFileHFSType This adds a Mac OS X HFS file type that should be displayed to the end-user.
ShouldExtensionBeHidden This sets whether or not the file extension is hidden on Mac OS X.

Remarks

There is predefined type for smart VCOM pointer VCOMPtr to IFileChooserDialog interface:

typedef VCOMPtr<IFileChooserDialog>  IFileChooserDialogPtr;

Example

IFileChooserDialogPtr	pFileChooser( IID_FileChooserDialog );
if ( pFileChooser == NULL ) 
   return;

pFileChooser->SetTitle( "file open title" );
pFileChooser->SetDefaultFileName( "fileName" );
pFileChooser->AddFilter( "ext1", "this is the first one" );
pFileChooser->AddFilter( "ext2", "this is the second one" );
pFileChooser->AddFilter( "ext3", "this is the third one" );
pFileChooser->AddFilterAllFiles();
if ( VCOM_SUCCEEDED( pFileChooser->RunSaveDialog() ) ) {
   IFileIdentifierPtr	pFileID;

   if ( VCOM_SUCCEEDED( pFileChooser->GetSelectedFileName( 0, & pFileID ) ) ) {
       // ...
   }
}

Version

Available from: VectorWorks 12

See Also

VCOM:VCOMPtr | VCOM:VectorWorks:Filing:IFileIdentifier

[[VCOM:VCOMPtr]] | [[VCOM:VectorWorks:Filing:IFileIdentifier]]