Bringing over fix [r11923] from 1.3 current to the porting branch.

(Slightly different from 1.3 current patch, as files were split)

Code indent consistency + doxygen \code indent fixes.



git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11926 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
Greg Ercolano
2016-09-05 19:45:52 +00:00
parent 832e117f81
commit 5871340263
2 changed files with 75 additions and 97 deletions
+30 -52
View File
@@ -34,25 +34,21 @@ const char *Fl_Native_File_Chooser::file_exists_message = "File exists. Are you
Destructor. Destructor.
Deallocates any resources allocated to this widget. Deallocates any resources allocated to this widget.
*/ */
Fl_Native_File_Chooser::~Fl_Native_File_Chooser() Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
{
delete platform_fnfc; delete platform_fnfc;
} }
/** /**
Sets the current Fl_Native_File_Chooser::Type of browser. Sets the current Fl_Native_File_Chooser::Type of browser.
*/ */
void Fl_Native_File_Chooser::type(int t) void Fl_Native_File_Chooser::type(int t) {
{
if (platform_fnfc) platform_fnfc->type(t); if (platform_fnfc) platform_fnfc->type(t);
} }
/** /**
Gets the current Fl_Native_File_Chooser::Type of browser. Gets the current Fl_Native_File_Chooser::Type of browser.
*/ */
int Fl_Native_File_Chooser::type() const int Fl_Native_File_Chooser::type() const {
{
return platform_fnfc->type(); return platform_fnfc->type();
} }
@@ -70,16 +66,14 @@ int Fl_Native_File_Chooser::type() const
USE_FILTER_EXT Chooser filter pilots the output file extension. Ignored Used Used (GTK) USE_FILTER_EXT Chooser filter pilots the output file extension. Ignored Used Used (GTK)
\endcode \endcode
*/ */
void Fl_Native_File_Chooser::options(int o) void Fl_Native_File_Chooser::options(int o) {
{
if (platform_fnfc) platform_fnfc->options(o); if (platform_fnfc) platform_fnfc->options(o);
} }
/** /**
Gets the platform specific Fl_Native_File_Chooser::Option flags. Gets the platform specific Fl_Native_File_Chooser::Option flags.
*/ */
int Fl_Native_File_Chooser::options() const int Fl_Native_File_Chooser::options() const {
{
return platform_fnfc->options(); return platform_fnfc->options();
} }
@@ -89,15 +83,14 @@ int Fl_Native_File_Chooser::options() const
\b Example: \b Example:
\code \code
if ( fnfc->show() == 0 ) { if ( fnfc->show() == 0 ) {
// Print all filenames user selected // Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) { for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) '%s'\n", n, fnfc->filename(n)); printf("%d) '%s'\n", n, fnfc->filename(n));
} }
} }
\endcode \endcode
*/ */
int Fl_Native_File_Chooser::count() const int Fl_Native_File_Chooser::count() const {
{
return platform_fnfc->count(); return platform_fnfc->count();
} }
@@ -107,8 +100,7 @@ int Fl_Native_File_Chooser::count() const
If more than one filename is expected, use filename(int) instead. If more than one filename is expected, use filename(int) instead.
Return value may be "" if no filename was chosen (eg. user cancelled). Return value may be "" if no filename was chosen (eg. user cancelled).
*/ */
const char *Fl_Native_File_Chooser::filename() const const char *Fl_Native_File_Chooser::filename() const {
{
return platform_fnfc->filename(); return platform_fnfc->filename();
} }
@@ -119,15 +111,14 @@ const char *Fl_Native_File_Chooser::filename() const
\b Example: \b Example:
\code \code
if ( fnfc->show() == 0 ) { if ( fnfc->show() == 0 ) {
// Print all filenames user selected // Print all filenames user selected
for (int n=0; n<fnfc->count(); n++ ) { for (int n=0; n<fnfc->count(); n++ ) {
printf("%d) '%s'\n", n, fnfc->filename(n)); printf("%d) '%s'\n", n, fnfc->filename(n));
} }
} }
\endcode \endcode
*/ */
const char *Fl_Native_File_Chooser::filename(int i) const const char *Fl_Native_File_Chooser::filename(int i) const {
{
return platform_fnfc->filename(i); return platform_fnfc->filename(i);
} }
@@ -136,16 +127,14 @@ const char *Fl_Native_File_Chooser::filename(int i) const
If \p val is NULL, or no directory is specified, the chooser will attempt If \p val is NULL, or no directory is specified, the chooser will attempt
to use the last non-cancelled folder. to use the last non-cancelled folder.
*/ */
void Fl_Native_File_Chooser::directory(const char *val) void Fl_Native_File_Chooser::directory(const char *val) {
{
if (platform_fnfc) platform_fnfc->directory(val); if (platform_fnfc) platform_fnfc->directory(val);
} }
/** /**
Returns the current preset directory() value. Returns the current preset directory() value.
*/ */
const char *Fl_Native_File_Chooser::directory() const const char *Fl_Native_File_Chooser::directory() const {
{
return platform_fnfc->directory(); return platform_fnfc->directory();
} }
@@ -154,8 +143,7 @@ const char *Fl_Native_File_Chooser::directory() const
Can be NULL if no title desired. Can be NULL if no title desired.
The default title varies according to the platform, so you are advised to set the title explicitly. The default title varies according to the platform, so you are advised to set the title explicitly.
*/ */
void Fl_Native_File_Chooser::title(const char *t) void Fl_Native_File_Chooser::title(const char *t) {
{
if (platform_fnfc) platform_fnfc->title(t); if (platform_fnfc) platform_fnfc->title(t);
} }
@@ -163,8 +151,7 @@ void Fl_Native_File_Chooser::title(const char *t)
Get the title of the file chooser's dialog window. Get the title of the file chooser's dialog window.
Return value may be NULL if no title was set. Return value may be NULL if no title was set.
*/ */
const char* Fl_Native_File_Chooser::title() const const char* Fl_Native_File_Chooser::title() const {
{
return platform_fnfc->title(); return platform_fnfc->title();
} }
@@ -172,8 +159,7 @@ const char* Fl_Native_File_Chooser::title() const
Returns the filter string last set. Returns the filter string last set.
Can be NULL if no filter was set. Can be NULL if no filter was set.
*/ */
const char *Fl_Native_File_Chooser::filter() const const char *Fl_Native_File_Chooser::filter() const {
{
return platform_fnfc->filter(); return platform_fnfc->filter();
} }
@@ -195,16 +181,14 @@ const char *Fl_Native_File_Chooser::filter() const
On most platforms, each filter is available to the user via a pulldown menu On most platforms, each filter is available to the user via a pulldown menu
in the file chooser. The 'All Files' option is always available to the user. in the file chooser. The 'All Files' option is always available to the user.
*/ */
void Fl_Native_File_Chooser::filter(const char *f) void Fl_Native_File_Chooser::filter(const char *f) {
{
if (platform_fnfc) platform_fnfc->filter(f); if (platform_fnfc) platform_fnfc->filter(f);
} }
/** /**
Gets how many filters were available, not including "All Files" Gets how many filters were available, not including "All Files"
*/ */
int Fl_Native_File_Chooser::filters() const int Fl_Native_File_Chooser::filters() const {
{
return platform_fnfc->filters(); return platform_fnfc->filters();
} }
@@ -215,8 +199,7 @@ int Fl_Native_File_Chooser::filters() const
If filter_value()==filters(), then "All Files" was chosen. If filter_value()==filters(), then "All Files" was chosen.
If filter_value() > filters(), then a custom filter was set. If filter_value() > filters(), then a custom filter was set.
*/ */
void Fl_Native_File_Chooser::filter_value(int i) void Fl_Native_File_Chooser::filter_value(int i) {
{
platform_fnfc->filter_value(i); platform_fnfc->filter_value(i);
} }
@@ -224,8 +207,7 @@ void Fl_Native_File_Chooser::filter_value(int i)
Returns which filter value was last selected by the user. Returns which filter value was last selected by the user.
This is only valid if the chooser returns success. This is only valid if the chooser returns success.
*/ */
int Fl_Native_File_Chooser::filter_value() const int Fl_Native_File_Chooser::filter_value() const {
{
return platform_fnfc->filters(); return platform_fnfc->filters();
} }
@@ -235,16 +217,14 @@ int Fl_Native_File_Chooser::filter_value() const
Mainly used to preset the filename for save dialogs, Mainly used to preset the filename for save dialogs,
and on most platforms can be used for opening files as well. and on most platforms can be used for opening files as well.
*/ */
void Fl_Native_File_Chooser::preset_file(const char*f) void Fl_Native_File_Chooser::preset_file(const char*f) {
{
if (platform_fnfc) platform_fnfc->preset_file(f); if (platform_fnfc) platform_fnfc->preset_file(f);
} }
/** /**
Get the preset filename. Get the preset filename.
*/ */
const char* Fl_Native_File_Chooser::preset_file() const const char* Fl_Native_File_Chooser::preset_file() const {
{
return platform_fnfc->preset_file(); return platform_fnfc->preset_file();
} }
@@ -253,8 +233,7 @@ const char* Fl_Native_File_Chooser::preset_file() const
This message should at least be flagged to the user in a dialog box, or to some kind of error log. This message should at least be flagged to the user in a dialog box, or to some kind of error log.
Contents will be valid only for methods that document errmsg() will have info on failures. Contents will be valid only for methods that document errmsg() will have info on failures.
*/ */
const char *Fl_Native_File_Chooser::errmsg() const const char *Fl_Native_File_Chooser::errmsg() const {
{
return platform_fnfc->errmsg(); return platform_fnfc->errmsg();
} }
@@ -265,9 +244,8 @@ const char *Fl_Native_File_Chooser::errmsg() const
- 1 -- user cancelled - 1 -- user cancelled
- -1 -- failed; errmsg() has reason - -1 -- failed; errmsg() has reason
*/ */
int Fl_Native_File_Chooser::show() int Fl_Native_File_Chooser::show() {
{ return platform_fnfc ? platform_fnfc->show() : 1;
return platform_fnfc? platform_fnfc->show() : 1;
} }
// COPY A STRING WITH 'new' // COPY A STRING WITH 'new'
+45 -45
View File
@@ -101,62 +101,62 @@ int Fl_Native_File_Chooser_FLTK_Driver::options() const {
int Fl_Native_File_Chooser_FLTK_Driver::show() { int Fl_Native_File_Chooser_FLTK_Driver::show() {
// FILTER // FILTER
if ( _parsedfilt ) { if ( _parsedfilt ) {
_file_chooser->filter(_parsedfilt); _file_chooser->filter(_parsedfilt);
} }
// FILTER VALUE // FILTER VALUE
// Set this /after/ setting the filter // Set this /after/ setting the filter
// //
_file_chooser->filter_value(_filtvalue); _file_chooser->filter_value(_filtvalue);
// DIRECTORY // DIRECTORY
if ( _directory && _directory[0] ) { if ( _directory && _directory[0] ) {
_file_chooser->directory(_directory); _file_chooser->directory(_directory);
} else { } else {
_file_chooser->directory(_prevvalue); _file_chooser->directory(_prevvalue);
} }
// PRESET FILE // PRESET FILE
if ( _preset_file ) { if ( _preset_file ) {
_file_chooser->value(_preset_file); _file_chooser->value(_preset_file);
} }
// OPTIONS: PREVIEW // OPTIONS: PREVIEW
_file_chooser->preview( (options() & Fl_Native_File_Chooser::PREVIEW) ? 1 : 0); _file_chooser->preview( (options() & Fl_Native_File_Chooser::PREVIEW) ? 1 : 0);
// OPTIONS: NEW FOLDER // OPTIONS: NEW FOLDER
if ( options() & Fl_Native_File_Chooser::NEW_FOLDER ) if ( options() & Fl_Native_File_Chooser::NEW_FOLDER )
_file_chooser->type(_file_chooser->type() | Fl_File_Chooser::CREATE); // on _file_chooser->type(_file_chooser->type() | Fl_File_Chooser::CREATE); // on
// SHOW // SHOW
_file_chooser->show(); _file_chooser->show();
// BLOCK WHILE BROWSER SHOWN // BLOCK WHILE BROWSER SHOWN
while ( _file_chooser->shown() ) { while ( _file_chooser->shown() ) {
Fl::wait(); Fl::wait();
} }
if ( _file_chooser->value() && _file_chooser->value()[0] ) { if ( _file_chooser->value() && _file_chooser->value()[0] ) {
_prevvalue = strfree(_prevvalue); _prevvalue = strfree(_prevvalue);
_prevvalue = strnew(_file_chooser->value()); _prevvalue = strnew(_file_chooser->value());
_filtvalue = _file_chooser->filter_value(); // update filter value _filtvalue = _file_chooser->filter_value(); // update filter value
// HANDLE SHOWING 'SaveAs' CONFIRM // HANDLE SHOWING 'SaveAs' CONFIRM
if ( options() & Fl_Native_File_Chooser::SAVEAS_CONFIRM && type() == Fl_Native_File_Chooser::BROWSE_SAVE_FILE ) { if ( options() & Fl_Native_File_Chooser::SAVEAS_CONFIRM && type() == Fl_Native_File_Chooser::BROWSE_SAVE_FILE ) {
struct stat buf; struct stat buf;
if ( fl_stat(_file_chooser->value(), &buf) != -1 ) { if ( stat(_file_chooser->value(), &buf) != -1 ) {
if ( buf.st_mode & S_IFREG ) { // Regular file + exists? if ( buf.st_mode & S_IFREG ) { // Regular file + exists?
if ( exist_dialog() == 0 ) { if ( exist_dialog() == 0 ) {
return(1); return(1);
}
} }
} }
} }
} }
}
if ( _file_chooser->count() ) return(0); if ( _file_chooser->count() ) return(0);
else return(1); else return(1);
} }
const char *Fl_Native_File_Chooser_FLTK_Driver::errmsg() const { const char *Fl_Native_File_Chooser_FLTK_Driver::errmsg() const {
@@ -171,8 +171,8 @@ const char* Fl_Native_File_Chooser_FLTK_Driver::filename() const {
} }
const char* Fl_Native_File_Chooser_FLTK_Driver::filename(int i) const { const char* Fl_Native_File_Chooser_FLTK_Driver::filename(int i) const {
if ( i < _file_chooser->count() ) if ( i < _file_chooser->count() )
return(_file_chooser->value(i+1)); // convert fltk 1 based to our 0 based return(_file_chooser->value(i+1)); // convert fltk 1 based to our 0 based
return(""); return("");
} }
@@ -181,7 +181,7 @@ void Fl_Native_File_Chooser_FLTK_Driver::title(const char *val) {
} }
const char *Fl_Native_File_Chooser_FLTK_Driver::title() const { const char *Fl_Native_File_Chooser_FLTK_Driver::title() const {
return(_file_chooser->label()); return(_file_chooser->label());
} }
void Fl_Native_File_Chooser_FLTK_Driver::filter(const char *val) { void Fl_Native_File_Chooser_FLTK_Driver::filter(const char *val) {