VSTGUI: CNewFileSelector Class Reference

VSTGUI 4.10 Graphical User Interface Framework not only for VST plugins

Loading...
Searching...
No Matches
Classes | Public Types | List of all members
CNewFileSelector Class Referencefinal

New file selector class. More...

`#include <cfileselector.h>`

Inheritance diagram for CNewFileSelector:

## Classes
struct | Impl

## 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
Public Member Functions inherited from CBaseObject
| CBaseObject ()=default
| ~CBaseObject () noexcept override=default
| CBaseObject (const CBaseObject &)
CBaseObject & | operator= (const CBaseObject &)
virtual CMessageResult | notify (CBaseObject *sender, IdStringPtr message)
Public Member Functions inherited from ReferenceCounted< int32_t >
| ReferenceCounted ()=default
virtual | ~ReferenceCounted () noexcept=default
| ReferenceCounted (const ReferenceCounted &)
ReferenceCounted & | operator= (const ReferenceCounted &)
| ReferenceCounted ()=default
| ReferenceCounted (const ReferenceCounted &)
virtual | ~ReferenceCounted () noexcept=default
ReferenceCounted & | operator= (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
void | forget () override
| decrease refcount and delete object if refcount == 0
void | remember () override
| increase refcount
virtual int32_t | getNbReference () const
| get refcount

## CFileSelector running
using | CallbackFunc = std::function<void(CNewFileSelector*)>
static CNewFileSelector * | create (CFrame *parent=nullptr, Style style=kSelectFile)
| create a new instance
| CNewFileSelector (PlatformFileSelectorPtr &&platformFileSelector, CFrame *parent)
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

## CFileSelector result
static IdStringPtr | kSelectEndMessage = "CNewFileSelector Select End Message"
std::unique_ptr< Impl > | impl
static const CFileExtension & | getAllFilesExtension ()
| get the all files extension
uint32_t | getNumSelectedFiles () const
| get number of selected files
UTF8StringPtr | getSelectedFile (uint32_t index) const
| get selected file.
CBaseObject * | newCopy () const override
| ~CNewFileSelector () noexcept override

## 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 ();
}
}
VSTGUI::CFileExtension
file extension description
Definition cfileselector.h:19
VSTGUI::CNewFileSelector::setTitle
void setTitle(const UTF8String &title)
set title of file selector
Definition cfileselector.cpp:224
VSTGUI::CNewFileSelector::run
bool run(CallbackFunc &&callback)
Definition cfileselector.cpp:187
VSTGUI::CNewFileSelector::create
static CNewFileSelector * create(CFrame *parent=nullptr, Style style=kSelectFile)
create a new instance
Definition cfileselector.cpp:293
VSTGUI::CNewFileSelector::setDefaultExtension
void setDefaultExtension(const CFileExtension &extension)
set default file extension
Definition cfileselector.cpp:248
VSTGUI::CNewFileSelector::addFileExtension
void addFileExtension(const CFileExtension &extension)
add a file extension
Definition cfileselector.cpp:267
VSTGUI::CNewFileSelector::kSelectFile
@ kSelectFile
select file(s) selector style
Definition cfileselector.h:93
VSTGUI::CNewFileSelector::CNewFileSelector
CNewFileSelector(PlatformFileSelectorPtr &&platformFileSelector, CFrame *parent)
Definition cfileselector.cpp:154
VSTGUI::ReferenceCounted::forget
void forget() override
decrease refcount and delete object if refcount == 0
Definition vstguibase.h:270

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);
}
VSTGUI::CBaseObject::CBaseObject
CBaseObject()=default
VSTGUI::CNewFileSelector::kSelectEndMessage
static IdStringPtr kSelectEndMessage
Definition cfileselector.h:152
VSTGUI::IdStringPtr
const char * IdStringPtr
ID String pointer.
Definition vstguibase.h:216
VSTGUI::CMessageResult
CMessageResult
Definition vstguibase.h:240
VSTGUI::kMessageNotified
@ kMessageNotified
Definition vstguibase.h:242

## Member Typedef Documentation

## ◆ CallbackFunc

using CallbackFunc = std::function<void(CNewFileSelector*)>

## Member Enumeration Documentation

## ◆ Style

enum Style

Enumerator
kSelectFile | select file(s) selector style
kSelectSaveFile | select save file selector style
kSelectDirectory | select directory style

## Constructor & Destructor Documentation

## ◆ CNewFileSelector()

CNewFileSelector | ( | PlatformFileSelectorPtr && | platformFileSelector,
|  | CFrame * | parent )

## ◆ ~CNewFileSelector()

~CNewFileSelector | ( |  | ) |
| overrideprotecteddefaultnoexcept

## Member Function Documentation

## ◆ addFileExtension() [1/2]

void addFileExtension | ( | CFileExtension && | extension | ) |

add a file extension

## ◆ addFileExtension() [2/2]

void addFileExtension | ( | const CFileExtension & | extension | ) |

add a file extension

## ◆ cancel()

void cancel | ( |  | ) |

cancel running the file selector

## ◆ create()

CNewFileSelector * create | ( | CFrame * | parent = nullptr,
|  | Style | style = kSelectFile )
| static

create a new instance

## ◆ getAllFilesExtension()

const CFileExtension & getAllFilesExtension | ( |  | ) |
| static

get the all files extension

## ◆ getNumSelectedFiles()

uint32_t getNumSelectedFiles | ( |  | ) | const

get number of selected files

## ◆ getSelectedFile()

UTF8StringPtr getSelectedFile | ( | uint32_t | index | ) | const

get selected file.

Result is only valid as long as the instance of CNewFileSelector is valid.

## ◆ newCopy()

CBaseObject * newCopy | ( |  | ) | const
| inlineoverride

## ◆ run() [1/2]

bool run | ( | CallbackFunc && | callback | ) |

## ◆ run() [2/2]

bool run | ( | CBaseObject * | delegate | ) |

the delegate will get a kSelectEndMessage throu the notify method where the sender is this CNewFileSelector object

## ◆ runModal()

bool runModal | ( |  | ) |

run as modal dialog

## ◆ setAllowMultiFileSelection()

void setAllowMultiFileSelection | ( | bool | state | ) |

set allow multi file selection (only valid for kSelectFile selector style)

## ◆ setDefaultExtension()

void setDefaultExtension | ( | const CFileExtension & | extension | ) |

set default file extension

## ◆ setDefaultSaveName()

void setDefaultSaveName | ( | const UTF8String & | name | ) |

set initial save name (UTF8 string)

## ◆ setInitialDirectory()

void setInitialDirectory | ( | const UTF8String & | path | ) |

set initial directory (UTF8 string)

## ◆ setTitle()

void setTitle | ( | const UTF8String & | title | ) |

set title of file selector

## Member Data Documentation

## ◆ impl

std::unique_ptr<Impl> impl
| protected

## ◆ kSelectEndMessage

IdStringPtr kSelectEndMessage = "CNewFileSelector Select End Message"
| static

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

- cfileselector.h
- cfileselector.cpp