CEGUICommonFileDialog         A Common File Dialog window for CEGUI
Print

The code included in this page provides a Common File Dialog window for CEGUI. It is Window only, but with some effort it can be modified to Linux (I only own MSVC).
Note by ancestral: Linux version below.
Note: I have removed a direct link to the downloads, which were previous on this page and added the code itself. Use the demo code as an example how the file dialog should be used (follow step 1 through step 4). If you want the zipped version of both the filedialog code and the (working) demo, contact me by means of the Ogre forum (personal message).

The dialog makes use of an input object (CommonFileDialogInput) which configures the dialog and an output object (CommonFileDialogOutput) that contains the result. They can be used as followed:

CommonFileDialogInput

setHandle (const CEGUI::uint);

Default
0 (no handle)

 

setFileName (const CEGUI::String);

Default
"" (no filename)

 

setFilter (const CEGUI::String);

Default
"All files|*.*|"

 

The filter is build according to the common file dialog filter string in Windows. An example
The filter
produces a list that looks like this in the combobox

 

setDefaultExtension (const CEGUI::String);

Default
*.*

 

setTitle (const CEGUI::String);

 

setOpenFileDialog (const bool);

Default
TRUE

 

setDoPrompt (const bool);

Default
TRUE

 

setPromptText (const CEGUI::String);

Default for Load
"Cannot find the requested file.", if the selected file doesn't exist
Default for Save
"The file already exist. Replace it?", if the seleted file already exists

 

CommonFileDialogOutput

 

CEGUI::uint getHandle (void);

 

CEGUI::String getFullQualifiedFileName (void);

Returns the full qualified filename. Example
"C
\\TEMP\\DOCUMENT\\EXAMPLE.DOC"

 

CEGUI::String getDrive (void);

Returns the drive. Example
"C
" OR "D

 

CEGUI::String getAbsolutePath (void);

Returns the absolute path. Example
"C
\\TEMP\\DOCUMENT"

 

CEGUI::String getRelativePath (void);

Returns the path in relation to the current working directory. Example

 

CEGUI::String getFileName (void);

 

CEGUI::CommonFileDialogAction getAction (void);

Determines how the dialog was closed. Three possible actions are distinguished
*getAction() == CEGUI
*getAction() == CEGUI
*getAction() == CEGUI

 

CEGUI::bool isFileExisting (void);

 

File dialog code + demo code

 

File dialog code

(Users of VC 8, please note that hash_map has been moved to namespace stdext, so the compiler will complain about the 'hash_map' identifier in CEGUIHashMapTemplates.h if you don't at least add a "using namespace stdext;" line there. Other options are proposed in this thread: http://www.ogre3d.org/phpBB2/viewtopic.php?t=15801)

 





Linux version:

 
Windows calls left commented to show the corresponding Linux system calls

 




File dialog demo code

 

  • Demo_Gui2.cpp - this works on Linux- uses TaharezLookSkin.scheme instead of TaharezLook2.scheme

 


Contributors to this page: jacmoe111451 points  and OgreWikiBot .
Page last modified on Saturday 02 of January, 2010 21:12:25 GMT by jacmoe111451 points .


The content on this page is licensed under the terms of the Creative Commons Attribution-ShareAlike License.
As an exception, any source code contributed within the content is released into the Public Domain.