New file selector class. More...
Public Types | |
enum | Style { kSelectFile, kSelectSaveFile, kSelectDirectory } |
Public Member Functions | |
CFileSelector setup | |
void | setTitle (UTF8StringPtr title) |
set title of file selector | |
void | setInitialDirectory (UTF8StringPtr path) |
set initial directory (UTF8 string) | |
void | setDefaultSaveName (UTF8StringPtr 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 | |
CFileSelector result | |
int32_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. | |
Reference Counting Methods | |
virtual void | forget () |
decrease refcount and delete object if refcount == 0 | |
virtual void | remember () |
increase refcount | |
virtual int32_t | getNbReference () const |
get refcount | |
Message Methods | |
virtual CMessageResult | notify (CBaseObject *sender, IdStringPtr message) |
Static Public Member Functions | |
static const CFileExtension & | getAllFilesExtension () |
get the all files extension | |
Static Public Attributes | |
static IdStringPtr | kSelectEndMessage = "CNewFileSelector Select End Message" |
Protected Types | |
typedef std::list< CFileExtension > | FileExtensionList |
Protected Member Functions | |
CNewFileSelector (CFrame *frame=0) | |
~CNewFileSelector () | |
virtual bool | runInternal (CBaseObject *delegate)=0 |
virtual void | cancelInternal ()=0 |
virtual bool | runModalInternal ()=0 |
Protected Attributes | |
CFrame * | frame |
UTF8StringBuffer | title |
UTF8StringBuffer | initialPath |
UTF8StringBuffer | defaultSaveName |
const CFileExtension * | defaultExtension |
bool | allowMultiFileSelection |
FileExtensionList | extensions |
std::vector< UTF8StringBuffer > | result |
CFileSelector running | |
| |
static CNewFileSelector * | create (CFrame *parent=0, Style style=kSelectFile) |
create a new instance | |
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 |
New file selector class.
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); }
typedef std::list<CFileExtension> FileExtensionList [protected] |
enum Style |
CNewFileSelector | ( | CFrame * | frame = 0 |
) | [protected] |
~CNewFileSelector | ( | ) | [protected] |
void addFileExtension | ( | const CFileExtension & | extension | ) |
add a file extension
void cancel | ( | ) |
cancel running the file selector
virtual void cancelInternal | ( | ) | [protected, pure virtual] |
static CNewFileSelector* create | ( | CFrame * | parent = 0 , |
|
Style | style = kSelectFile | |||
) | [static] |
create a new instance
virtual void forget | ( | ) | [inline, virtual, inherited] |
decrease refcount and delete object if refcount == 0
const CFileExtension & getAllFilesExtension | ( | ) | [static] |
get the all files extension
virtual int32_t getNbReference | ( | ) | const [inline, virtual, inherited] |
get refcount
int32_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.
virtual CMessageResult notify | ( | CBaseObject * | sender, | |
IdStringPtr | message | |||
) | [inline, virtual, inherited] |
virtual void remember | ( | ) | [inline, virtual, inherited] |
increase refcount
bool run | ( | CBaseObject * | delegate | ) |
the delegate will get a kSelectEndMessage throu the notify method where the sender is this CNewFileSelector object
virtual bool runInternal | ( | CBaseObject * | delegate | ) | [protected, pure virtual] |
bool runModal | ( | ) |
run as modal dialog
virtual bool runModalInternal | ( | ) | [protected, pure virtual] |
void setAllowMultiFileSelection | ( | bool | state | ) |
set allow multi file selection (only valid for kSelectFile selector style)
void setDefaultExtension | ( | const CFileExtension & | extension | ) |
set default file extension
void setDefaultSaveName | ( | UTF8StringPtr | name | ) |
set initial save name (UTF8 string)
void setInitialDirectory | ( | UTF8StringPtr | path | ) |
set initial directory (UTF8 string)
void setTitle | ( | UTF8StringPtr | title | ) |
set title of file selector
bool allowMultiFileSelection [protected] |
const CFileExtension* defaultExtension [protected] |
UTF8StringBuffer defaultSaveName [protected] |
FileExtensionList extensions [protected] |
UTF8StringBuffer initialPath [protected] |
IdStringPtr kSelectEndMessage = "CNewFileSelector Select End Message" [static] |
std::vector<UTF8StringBuffer> result [protected] |
UTF8StringBuffer title [protected] |