ASPiK SDK
VSTGUI::CNewFileSelector Class Referenceabstract

New file selector class. More...

#include <cfileselector.h>

Inheritance diagram for VSTGUI::CNewFileSelector:
VSTGUI::CBaseObject VSTGUI::ReferenceCounted< T > VSTGUI::IReference VSTGUI::GtkFileSelector

Public Types

enum  Style { kSelectFile, kSelectSaveFile, kSelectDirectory }
 

Public Member Functions

CFileSelector setup
void setTitle (const UTF8String &title)
 set title of file selector
 
void setInitialDirectory (const UTF8String &path)
 set initial directory (UTF8 string)
 
void setDefaultSaveName (const UTF8String &name)
 set initial save name (UTF8 string)
 
void setDefaultExtension (const CFileExtension &extension)
 set default file extension
 
void setAllowMultiFileSelection (bool state)
 set allow multi file selection (only valid for kSelectFile selector style)
 
void addFileExtension (const CFileExtension &extension)
 add a file extension
 
void addFileExtension (CFileExtension &&extension)
 add a file extension
 
CFileSelector result
uint32_t getNumSelectedFiles () const
 get number of selected files
 
UTF8StringPtr getSelectedFile (uint32_t index) const
 get selected file. Result is only valid as long as the instance of CNewFileSelector is valid.
 
- Public Member Functions inherited from VSTGUI::CBaseObject
 CBaseObject (const CBaseObject &o)
 
CBaseObjectoperator= (const CBaseObject &obj)
 
virtual CMessageResult notify (CBaseObject *sender, IdStringPtr message)
 
- Public Member Functions inherited from VSTGUI::ReferenceCounted< T >
 ReferenceCounted (const ReferenceCounted &)
 
ReferenceCountedoperator= (const ReferenceCounted &)
 
void forget () override
 decrease refcount and delete object if refcount == 0
 
void remember () override
 increase refcount
 
virtual int32_t getNbReference () const
 get refcount
 
virtual void beforeDelete ()
 

Static Public Member Functions

static const CFileExtensiongetAllFilesExtension ()
 get the all files extension
 

Static Public Attributes

static IdStringPtr kSelectEndMessage = "CNewFileSelector Select End Message"
 

Protected Types

using FileExtensionList = std::list< CFileExtension >
 

Protected Member Functions

 CNewFileSelector (CFrame *frame=nullptr)
 
virtual bool runInternal (CBaseObject *delegate)=0
 
virtual void cancelInternal ()=0
 
virtual bool runModalInternal ()=0
 

Protected Attributes

CFrameframe
 
UTF8String title
 
UTF8String initialPath
 
UTF8String defaultSaveName
 
const CFileExtensiondefaultExtension
 
bool allowMultiFileSelection
 
FileExtensionList extensions
 
std::vector< UTF8Stringresult
 

CFileSelector running

using CallbackFunc = std::function< void(CNewFileSelector *)>
 
static CNewFileSelectorcreate (CFrame *parent=nullptr, Style style=kSelectFile)
 create a new instance
 
bool run (CallbackFunc &&callback)
 
bool run (CBaseObject *delegate)
 the delegate will get a kSelectEndMessage throu the notify method where the sender is this CNewFileSelector object
 
void cancel ()
 cancel running the file selector
 
bool runModal ()
 run as modal dialog
 

Detailed Description

New file selector class.

Usage

Running the file selector

void MyClass::runFileSelector ()
{
CNewFileSelector* selector = CNewFileSelector::create (getFrame (), CNewFileSelector::kSelectFile);
if (selector)
{
selector->addFileExtension (CFileExtension ("AIFF", "aif", "audio/aiff"));
selector->setDefaultExtension (CFileExtension ("WAVE", "wav"));
selector->setTitle("Choose An Audio File");
selector->run (this);
selector->forget ();
}
}

Getting results

CMessageResult MyClass::notify (CBaseObject* sender, IdStringPtr message)
{
if (message == CNewFileSelector::kSelectEndMessage)
{
CNewFileSelector* sel = dynamic_cast<CNewFileSelector*>(sender);
if (sel)
{
// do anything with the selected files here
return kMessageNotified;
}
}
return parent::notify (sender, message);
}

Member Enumeration Documentation

◆ Style

Enumerator
kSelectFile 

select file(s) selector style

kSelectSaveFile 

select save file selector style

kSelectDirectory 

select directory style


The documentation for this class was generated from the following files: