summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2010-01-14 20:47:59 +0000
committerGreg Ercolano <erco@seriss.com>2010-01-14 20:47:59 +0000
commitf910c1c181205b9005a1ad91eac6d963eb9919a9 (patch)
tree2d03182b995302f35748689ca4a56c8f47b1fc14 /src
parent209e1bfea12f291b58a1404938b05f35e5ec1d6d (diff)
Fl_Native_File_Chooser follow up maintenance.
* doxygen docs added * Changed all FNFC_XXX macros to full Fl_Native_File_Chooser names for doxygen * Added missing svn $Id tags * Small mods to Manolo's old_dir[] in Fl_Native_File_Chooser_FLTK to use a dynamic string instead of old_dir[300] git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@7003 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Native_File_Chooser.cxx4
-rw-r--r--src/Fl_Native_File_Chooser_FLTK.cxx328
-rw-r--r--src/Fl_Native_File_Chooser_MAC.cxx87
-rw-r--r--src/Fl_Native_File_Chooser_WIN32.cxx78
4 files changed, 308 insertions, 189 deletions
diff --git a/src/Fl_Native_File_Chooser.cxx b/src/Fl_Native_File_Chooser.cxx
index a7071a532..898760d49 100644
--- a/src/Fl_Native_File_Chooser.cxx
+++ b/src/Fl_Native_File_Chooser.cxx
@@ -26,7 +26,7 @@
//
// Use Windows' chooser
-#ifdef _WIN32
+#ifdef WIN32
#include "Fl_Native_File_Chooser_WIN32.cxx"
#endif
@@ -36,7 +36,7 @@
#endif
// All else falls back to FLTK's own chooser
-#if ! defined(__APPLE__) && !defined(_WIN32)
+#if ! defined(__APPLE__) && !defined(WIN32)
#include "Fl_Native_File_Chooser_FLTK.cxx"
#endif
diff --git a/src/Fl_Native_File_Chooser_FLTK.cxx b/src/Fl_Native_File_Chooser_FLTK.cxx
index 5649c7f7e..357e4b949 100644
--- a/src/Fl_Native_File_Chooser_FLTK.cxx
+++ b/src/Fl_Native_File_Chooser_FLTK.cxx
@@ -28,8 +28,6 @@
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/Fl_File_Icon.H>
-#define FNFC_CLASS Fl_Native_File_Chooser
-#define FNFC_CTOR Fl_Native_File_Chooser
#define FLTK_CHOOSER_SINGLE Fl_File_Chooser::SINGLE
#define FLTK_CHOOSER_DIRECTORY Fl_File_Chooser::DIRECTORY
#define FLTK_CHOOSER_MULTI Fl_File_Chooser::MULTI
@@ -37,11 +35,16 @@
#include "Fl_Native_File_Chooser_common.cxx"
#include <sys/stat.h>
-
-// CTOR
-FNFC_CLASS::FNFC_CTOR(int val) {
+#include <string.h>
+
+/**
+ The constructor. Internally allocates the native widgets.
+ Optional \p val presets the type of browser this will be,
+ which can also be changed with type().
+*/
+Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
//// CANT USE THIS -- MESSES UP LINKING/CREATES DEPENDENCY ON fltk_images.
- //// Have user call this from app instead.
+ //// Have app call this from main() instead.
////
//// static int init = 0; // 'first time' initialize flag
//// if ( init == 0 ) {
@@ -58,47 +61,51 @@ FNFC_CLASS::FNFC_CTOR(int val) {
_prevvalue = NULL;
_directory = NULL;
_errmsg = NULL;
- file_chooser = new Fl_File_Chooser(NULL, NULL, 0, NULL);
- type(val); // do this after file_chooser created
+ _file_chooser = new Fl_File_Chooser(NULL, NULL, 0, NULL);
+ type(val); // do this after _file_chooser created
_nfilters = 0;
// Added by MG
- Fl_Button *b = file_chooser->previewButton;
+ Fl_Button *b = _file_chooser->previewButton;
Fl_Window *w = b->window();
- Fl_Group::current(w); // adds a "Show hidden files" check button in file_chooser's window
+ Fl_Group::current(w); // adds a "Show hidden files" check button in _file_chooser's window
show_hidden = new Fl_Check_Button(b->x() + b->w() + 10, b->y(), 145, b->h(), "Show hidden files");
show_hidden->callback((Fl_Callback*)show_hidden_cb, this);
- // This is a hack to bypass the fact that fileList is a private member of file_chooser.
- // Find it as 1st child of 2nd child of file_chooser's window.
+ // This is a hack to bypass the fact that fileList is a private member of _file_chooser.
+ // Find it as 1st child of 2nd child of _file_chooser's window.
Fl_Group *g = (Fl_Group *)w->array()[1];
my_fileList = (Fl_File_Browser *)g->array()[0];
- old_dir[0] = 0; // to detect directory changes
- prev_filtervalue = file_chooser->filter_value(); // to detect filter changes
- // Hack to get file_chooser's showChoice widget.
- // Find it as 1st child of 1st child of file_chooser's window.
+ _old_dir = 0; // to detect directory changes
+ prev_filtervalue = _file_chooser->filter_value(); // to detect filter changes
+ // Hack to get _file_chooser's showChoice widget.
+ // Find it as 1st child of 1st child of _file_chooser's window.
g = (Fl_Group *)w->array()[0];
showChoice = (Fl_Choice *)g->array()[0];
}
-// DTOR
-FNFC_CLASS::~FNFC_CTOR() {
- delete file_chooser;
+/**
+ Destructor.
+ Deallocates any resources allocated to this widget.
+*/
+Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
+ delete _file_chooser;
_filter = strfree(_filter);
_parsedfilt = strfree(_parsedfilt);
_preset_file = strfree(_preset_file);
_prevvalue = strfree(_prevvalue);
_directory = strfree(_directory);
_errmsg = strfree(_errmsg);
+ _old_dir = strfree(_old_dir);
}
// PRIVATE: SET ERROR MESSAGE
-void FNFC_CLASS::errmsg(const char *msg) {
+void Fl_Native_File_Chooser::errmsg(const char *msg) {
_errmsg = strfree(_errmsg);
_errmsg = strnew(msg);
}
// PRIVATE: translate Native types to Fl_File_Chooser types
-int FNFC_CLASS::type_fl_file(int val) {
+int Fl_Native_File_Chooser::type_fl_file(int val) {
switch (val) {
case BROWSE_FILE:
return(FLTK_CHOOSER_SINGLE);
@@ -117,85 +124,107 @@ int FNFC_CLASS::type_fl_file(int val) {
}
}
-void FNFC_CLASS::type(int val) {
+/**
+ Sets the current Fl_Native_File_Chooser::Type of browser.
+ */
+void Fl_Native_File_Chooser::type(int val) {
_btype = val;
- file_chooser->type(type_fl_file(val));
+ _file_chooser->type(type_fl_file(val));
}
-int FNFC_CLASS::type() const {
+/**
+ Gets the current Fl_Native_File_Chooser::Type of browser.
+ */
+int Fl_Native_File_Chooser::type() const {
return(_btype);
}
-// SET OPTIONS
-void FNFC_CLASS::options(int val) {
+/**
+ Sets the platform specific chooser options to \p val.
+ \p val is expected to be one or more Fl_Native_File_Chooser::Option flags ORed together.
+ Some platforms have OS-specific functions that can be enabled/disabled via this method.
+ <P>
+ \code
+ Flag Description Win Mac Other
+ -------------- ----------------------------------------------- ------- ------- -------
+ NEW_FOLDER Shows the 'New Folder' button. Ignored Used Used
+ PREVIEW Enables the 'Preview' mode by default. Ignored Ignored Used
+ SAVEAS_CONFIRM Confirm dialog if BROWSE_SAVE_FILE file exists. Ignored Used Ignored
+ \endcode
+*/
+void Fl_Native_File_Chooser::options(int val) {
_options = val;
}
-// GET OPTIONS
-int FNFC_CLASS::options() const {
+/**
+ Gets the platform specific Fl_Native_File_Chooser::Option flags.
+*/
+int Fl_Native_File_Chooser::options() const {
return(_options);
}
-// Show chooser, blocks until done.
-// RETURNS:
-// 0 - user picked a file
-// 1 - user cancelled
-// -1 - failed; errmsg() has reason
-//
-int FNFC_CLASS::show() {
+/**
+ Post the chooser's dialog. Blocks until dialog has been completed or cancelled.
+ \returns
+ - 0 -- user picked a file
+ - 1 -- user cancelled
+ - -1 -- failed; errmsg() has reason
+*/
+int Fl_Native_File_Chooser::show() {
// FILTER
if ( _parsedfilt ) {
- file_chooser->filter(_parsedfilt);
+ _file_chooser->filter(_parsedfilt);
}
// FILTER VALUE
// Set this /after/ setting the filter
//
- file_chooser->filter_value(_filtvalue);
+ _file_chooser->filter_value(_filtvalue);
// DIRECTORY
if ( _directory && _directory[0] ) {
- file_chooser->directory(_directory);
+ _file_chooser->directory(_directory);
} else {
- file_chooser->directory(_prevvalue);
+ _file_chooser->directory(_prevvalue);
}
// PRESET FILE
if ( _preset_file ) {
- file_chooser->value(_preset_file);
+ _file_chooser->value(_preset_file);
}
// OPTIONS: PREVIEW
- file_chooser->preview( (options() & PREVIEW) ? 1 : 0);
+ _file_chooser->preview( (options() & PREVIEW) ? 1 : 0);
// OPTIONS: NEW FOLDER
if ( options() & NEW_FOLDER )
- file_chooser->type(file_chooser->type() | FLTK_CHOOSER_CREATE); // on
+ _file_chooser->type(_file_chooser->type() | FLTK_CHOOSER_CREATE); // on
// SHOW
- file_chooser->show();
+ _file_chooser->show();
// BLOCK WHILE BROWSER SHOWN
- while ( file_chooser->shown() ) {
- if(strcmp(old_dir, file_chooser->directory()) != 0) {
- strcpy(old_dir, file_chooser->directory());
- if(!show_hidden->value()) remove_hidden_files(my_fileList);
- } else if(prev_filtervalue != file_chooser->filter_value() ) {
- prev_filtervalue = file_chooser->filter_value();
- if(!show_hidden->value() ) remove_hidden_files(my_fileList);
+ while ( _file_chooser->shown() ) {
+ if (_old_dir==0 || strcmp(_old_dir, _file_chooser->directory()) != 0) {
+ _old_dir = strfree(_old_dir);
+ _old_dir = strnew(_file_chooser->directory());
+ if (!show_hidden->value()) remove_hidden_files(my_fileList);
+ } else if (prev_filtervalue != _file_chooser->filter_value() ) {
+ prev_filtervalue = _file_chooser->filter_value();
+ if (!show_hidden->value() ) remove_hidden_files(my_fileList);
}
Fl::wait();
}
- if ( file_chooser->value() && file_chooser->value()[0] ) {
+ if ( _file_chooser->value() && _file_chooser->value()[0] ) {
_prevvalue = strfree(_prevvalue);
- _prevvalue = strnew(file_chooser->value());
- _filtvalue = file_chooser->filter_value(); // update filter value
+ _prevvalue = strnew(_file_chooser->value());
+ _filtvalue = _file_chooser->filter_value(); // update filter value
// HANDLE SHOWING 'SaveAs' CONFIRM
if ( options() & SAVEAS_CONFIRM && type() == BROWSE_SAVE_FILE ) {
struct stat buf;
- if ( stat(file_chooser->value(), &buf) != -1 ) {
+ if ( stat(_file_chooser->value(), &buf) != -1 ) {
if ( buf.st_mode & S_IFREG ) { // Regular file + exists?
if ( exist_dialog() == 0 ) {
return(1);
@@ -205,87 +234,160 @@ int FNFC_CLASS::show() {
}
}
- if ( file_chooser->count() ) return(0);
+ if ( _file_chooser->count() ) return(0);
else return(1);
}
-// RETURN ERROR MESSAGE
-const char *FNFC_CLASS::errmsg() const {
+/**
+ Returns a system dependent error message for the last method that failed.
+ 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.
+ */
+const char *Fl_Native_File_Chooser::errmsg() const {
return(_errmsg ? _errmsg : "No error");
}
-// GET FILENAME
-const char* FNFC_CLASS::filename() const {
- if ( file_chooser->count() > 0 ) return(file_chooser->value());
+/**
+ Return the filename the user choose.
+ Use this if only expecting a single filename.
+ If more than one filename is expected, use filename(int) instead.
+ Return value may be "" if no filename was chosen (eg. user cancelled).
+ */
+const char* Fl_Native_File_Chooser::filename() const {
+ if ( _file_chooser->count() > 0 ) return(_file_chooser->value());
return("");
}
-// GET FILENAME FROM LIST OF FILENAMES
-const char* FNFC_CLASS::filename(int i) const {
- if ( i < file_chooser->count() )
- return(file_chooser->value(i+1)); // convert fltk 1 based to our 0 based
+/**
+ Return one of the filenames the user selected.
+ Use count() to determine how many filenames the user selected.
+ <P>
+ \b Example:
+ \code
+ if ( fnfc->show() == 0 ) {
+ // Print all filenames user selected
+ for (int n=0; n<fnfc->count(); n++ ) {
+ printf("%d) '%s'\n", n, fnfc->filename(n));
+ }
+ }
+ \endcode
+ */
+const char* Fl_Native_File_Chooser::filename(int i) const {
+ if ( i < _file_chooser->count() )
+ return(_file_chooser->value(i+1)); // convert fltk 1 based to our 0 based
return("");
}
-// SET TITLE
-// Can be NULL if no title desired.
-//
-void FNFC_CLASS::title(const char *val) {
- file_chooser->label(val);
+/**
+ Set the title of the file chooser's dialog window.
+ Can be NULL if no title desired.
+ 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 *val) {
+ _file_chooser->label(val);
}
-// GET TITLE
-// Can return NULL if none set.
-//
-const char *FNFC_CLASS::title() const {
- return(file_chooser->label());
+/**
+ Get the title of the file chooser's dialog window.
+ Return value may be NULL if no title was set.
+*/
+const char *Fl_Native_File_Chooser::title() const {
+ return(_file_chooser->label());
}
-// SET FILTER
-// Can be NULL if no filter needed
-//
-void FNFC_CLASS::filter(const char *val) {
+/**
+ Sets the filename filters used for browsing.
+ The default is NULL, which browses all files.
+ <P>
+ The filter string can be any of:
+ <P>
+ - A single wildcard (eg. "*.txt")
+ - Multiple wildcards (eg. "*.{cxx,h,H}")
+ - A descriptive name followed by a "\t" and a wildcard (eg. "Text Files\t*.txt")
+ - A list of separate wildcards with a "\n" between each (eg. "*.{cxx,H}\n*.txt")
+ - A list of descriptive names and wildcards (eg. "C++ Files\t*.{cxx,H}\nTxt Files\t*.txt")
+ <P>
+ The format of each filter is a wildcard, or an optional user description
+ followed by '\\t' and the wildcard.
+ <P>
+ 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.
+*/
+void Fl_Native_File_Chooser::filter(const char *val) {
_filter = strfree(_filter);
_filter = strnew(val);
parse_filter();
}
-// GET FILTER
-const char *FNFC_CLASS::filter() const {
+/**
+ Returns the filter string last set.
+ Can be NULL if no filter was set.
+ */
+const char *Fl_Native_File_Chooser::filter() const {
return(_filter);
}
-// SET SELECTED FILTER
-void FNFC_CLASS::filter_value(int val) {
+/**
+Gets how many filters were available, not including "All Files"
+*/
+int Fl_Native_File_Chooser::filters() const {
+ return(_nfilters);
+}
+
+/**
+ Sets which filter will be initially selected.
+
+ The first filter is indexed as 0.
+ If filter_value()==filters(), then "All Files" was chosen.
+ If filter_value() > filters(), then a custom filter was set.
+ */
+void Fl_Native_File_Chooser::filter_value(int val) {
_filtvalue = val;
}
-// RETURN SELECTED FILTER
-int FNFC_CLASS::filter_value() const {
+/**
+ Returns which filter value was last selected by the user.
+ This is only valid if the chooser returns success.
+ */
+int Fl_Native_File_Chooser::filter_value() const {
return(_filtvalue);
}
-// GET TOTAL FILENAMES CHOSEN
-int FNFC_CLASS::count() const {
- return(file_chooser->count());
+/**
+ Returns the number of filenames (or directory names) the user selected.
+ <P>
+ \b Example:
+ \code
+ if ( fnfc->show() == 0 ) {
+ // Print all filenames user selected
+ for (int n=0; n<fnfc->count(); n++ ) {
+ printf("%d) '%s'\n", n, fnfc->filename(n));
+ }
+ }
+ \endcode
+*/
+int Fl_Native_File_Chooser::count() const {
+ return(_file_chooser->count());
}
-// PRESET PATHNAME
-// Can be NULL if no preset is desired.
-//
-void FNFC_CLASS::directory(const char *val) {
+/**
+ Preset the directory the browser will show when opened.
+ If \p val is NULL, or no directory is specified, the chooser will attempt
+ to use the last non-cancelled folder.
+*/
+void Fl_Native_File_Chooser::directory(const char *val) {
_directory = strfree(_directory);
_directory = strnew(val);
}
-// GET PRESET PATHNAME
-// Can return NULL if none set.
-//
-const char *FNFC_CLASS::directory() const {
+/**
+ Returns the current preset directory() value.
+*/
+const char *Fl_Native_File_Chooser::directory() const {
return(_directory);
}
-// Convert our filter format to fltk's chooser format
+// PRIVATE: Convert our filter format to fltk's chooser format
// FROM TO (FLTK)
// ------------------------- --------------------------
// "*.cxx" "*.cxx Files(*.cxx)"
@@ -295,7 +397,7 @@ const char *FNFC_CLASS::directory() const {
// Returns a modified version of the filter that the caller is responsible
// for freeing with strfree().
//
-void FNFC_CLASS::parse_filter() {
+void Fl_Native_File_Chooser::parse_filter() {
_parsedfilt = strfree(_parsedfilt); // clear previous parsed filter (if any)
_nfilters = 0;
char *in = _filter;
@@ -358,38 +460,52 @@ void FNFC_CLASS::parse_filter() {
//NOTREACHED
}
-// SET PRESET FILENAME
-void FNFC_CLASS::preset_file(const char* val) {
+/**
+ Sets the default filename for the chooser.
+ Use directory() to set the default directory.
+ Mainly used to preset the filename for save dialogs,
+ and on most platforms can be used for opening files as well.
+ */
+void Fl_Native_File_Chooser::preset_file(const char* val) {
_preset_file = strfree(_preset_file);
_preset_file = strnew(val);
}
-// GET PRESET FILENAME
-const char* FNFC_CLASS::preset_file() const {
+/**
+ Get the preset filename.
+ */
+const char* Fl_Native_File_Chooser::preset_file() const {
return(_preset_file);
}
-void FNFC_CLASS::show_hidden_cb(Fl_Check_Button *o, void *data)
+void Fl_Native_File_Chooser::show_hidden_cb(Fl_Check_Button *o, void *data)
{
Fl_Native_File_Chooser *mychooser = (Fl_Native_File_Chooser *)data;
- if(o->value()) {
- mychooser->my_fileList->load(mychooser->file_chooser->directory());
+ if (o->value()) {
+ mychooser->my_fileList->load(mychooser->_file_chooser->directory());
} else {
remove_hidden_files(mychooser->my_fileList);
mychooser->my_fileList->redraw();
}
}
-void FNFC_CLASS::remove_hidden_files(Fl_File_Browser *my_fileList)
+// PRIVATE: Don't show hidden files
+void Fl_Native_File_Chooser::remove_hidden_files(Fl_File_Browser *my_fileList)
{
int count = my_fileList->size();
for(int num = count; num >= 1; num--) {
const char *p = my_fileList->text(num);
- if(*p == '.' && strcmp(p, "../") != 0) my_fileList->remove(num);
+ if (*p == '.' && strcmp(p, "../") != 0) my_fileList->remove(num);
}
my_fileList->topline(1);
}
+// PRIVATE: Don't show hidden files
+int Fl_Native_File_Chooser::exist_dialog() {
+ return(fl_choice("File exists. Are you sure you want to overwrite?",
+ "Cancel", " OK ", NULL));
+}
+
//
// End of "$Id$".
//
diff --git a/src/Fl_Native_File_Chooser_MAC.cxx b/src/Fl_Native_File_Chooser_MAC.cxx
index b222d2d84..28d689bb9 100644
--- a/src/Fl_Native_File_Chooser_MAC.cxx
+++ b/src/Fl_Native_File_Chooser_MAC.cxx
@@ -30,6 +30,8 @@
// Possibly 'preset_file' could be used to select the filename.
//
+#ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE
+
#include "Fl_Native_File_Chooser_common.cxx" // strnew/strfree/strapp/chrcat
#include <libgen.h> // dirname(3)
#include <sys/types.h> // stat(2)
@@ -39,8 +41,6 @@
#include <FL/Fl.H>
#include <FL/Fl_Native_File_Chooser.H>
#include <FL/filename.H>
-#define FNFC_CLASS Fl_Native_File_Chooser
-#define FNFC_CTOR Fl_Native_File_Chooser
#ifndef __APPLE_COCOA__
// TRY TO CONVERT AN AEDesc TO AN FSRef
@@ -65,19 +65,19 @@ static int AEDescToFSRef(const AEDesc* desc, FSRef* fsref) {
}
// NAVREPLY: CTOR
-FNFC_CLASS::NavReply::NavReply() {
+Fl_Native_File_Chooser::NavReply::NavReply() {
_valid_reply = 0;
}
// NAVREPLY: DTOR
-FNFC_CLASS::NavReply::~NavReply() {
+Fl_Native_File_Chooser::NavReply::~NavReply() {
if ( _valid_reply ) {
NavDisposeReply(&_reply);
}
}
// GET REPLY FROM THE NAV* DIALOG
-int FNFC_CLASS::NavReply::get_reply(NavDialogRef& ref) {
+int Fl_Native_File_Chooser::NavReply::get_reply(NavDialogRef& ref) {
if ( _valid_reply ) {
NavDisposeReply(&_reply); // dispose of previous
_valid_reply = 0;
@@ -90,7 +90,7 @@ int FNFC_CLASS::NavReply::get_reply(NavDialogRef& ref) {
}
// RETURN THE BASENAME USER WANTS TO 'Save As'
-int FNFC_CLASS::NavReply::get_saveas_basename(char *s, int slen) {
+int Fl_Native_File_Chooser::NavReply::get_saveas_basename(char *s, int slen) {
if (CFStringGetCString(_reply.saveFileName, s, slen-1, kCFStringEncodingUTF8) == false) {
s[0] = '\0';
return(-1);
@@ -101,7 +101,7 @@ int FNFC_CLASS::NavReply::get_saveas_basename(char *s, int slen) {
// RETURN THE DIRECTORY NAME
// Returns 0 on success, -1 on error.
//
-int FNFC_CLASS::NavReply::get_dirname(char *s, int slen) {
+int Fl_Native_File_Chooser::NavReply::get_dirname(char *s, int slen) {
FSRef fsref;
if ( AEDescToFSRef(&_reply.selection, &fsref) != noErr ) {
// Conversion failed? Return empty name
@@ -116,7 +116,7 @@ int FNFC_CLASS::NavReply::get_dirname(char *s, int slen) {
// Returns: 0 on success with pathnames[] containing pathnames selected,
// -1 on error
//
-int FNFC_CLASS::NavReply::get_pathnames(char **&pathnames, int& tpathnames) {
+int Fl_Native_File_Chooser::NavReply::get_pathnames(char **&pathnames, int& tpathnames) {
// How many items selected?
long count = 0;
if ( AECountItems(&_reply.selection, &count) != noErr ) {
@@ -151,7 +151,7 @@ int FNFC_CLASS::NavReply::get_pathnames(char **&pathnames, int& tpathnames) {
#endif /* !__APPLE_COCOA__ */
// FREE PATHNAMES ARRAY, IF IT HAS ANY CONTENTS
-void FNFC_CLASS::clear_pathnames() {
+void Fl_Native_File_Chooser::clear_pathnames() {
if ( _pathnames ) {
while ( --_tpathnames >= 0 ) {
_pathnames[_tpathnames] = strfree(_pathnames[_tpathnames]);
@@ -163,7 +163,7 @@ void FNFC_CLASS::clear_pathnames() {
}
// SET A SINGLE PATHNAME
-void FNFC_CLASS::set_single_pathname(const char *s) {
+void Fl_Native_File_Chooser::set_single_pathname(const char *s) {
clear_pathnames();
_pathnames = new char*[1];
_pathnames[0] = strnew(s);
@@ -175,7 +175,7 @@ void FNFC_CLASS::set_single_pathname(const char *s) {
// Returns -1 on error, errmsg() has reason, filename == "".
// 0 if OK, filename() has filename chosen.
//
-int FNFC_CLASS::get_saveas_basename(NavDialogRef& ref) {
+int Fl_Native_File_Chooser::get_saveas_basename(NavDialogRef& ref) {
if ( ref == NULL ) {
errmsg("get_saveas_basename: ref is NULL");
return(-1);
@@ -216,7 +216,7 @@ int FNFC_CLASS::get_saveas_basename(NavDialogRef& ref) {
// -1 -- error, errmsg() has reason, filename == ""
// 0 -- OK, pathnames()/filename() has pathname(s) chosen
//
-int FNFC_CLASS::get_pathnames(NavDialogRef& ref) {
+int Fl_Native_File_Chooser::get_pathnames(NavDialogRef& ref) {
if ( ref == NULL ) {
errmsg("get_saveas_basename: ref is NULL");
return(-1);
@@ -278,10 +278,10 @@ static void PreselectPathname(NavCBRecPtr cbparm, const char *path) {
}
// NAV CALLBACK EVENT HANDLER
-void FNFC_CLASS::event_handler(NavEventCallbackMessage callBackSelector,
+void Fl_Native_File_Chooser::event_handler(NavEventCallbackMessage callBackSelector,
NavCBRecPtr cbparm,
void *data) {
- FNFC_CLASS *nfb = (FNFC_CLASS*)data;
+ Fl_Native_File_Chooser *nfb = (Fl_Native_File_Chooser*)data;
switch (callBackSelector) {
case kNavCBStart:
{
@@ -381,7 +381,7 @@ void FNFC_CLASS::event_handler(NavEventCallbackMessage callBackSelector,
#endif /* !__APPLE_COCOA__ */
// CONSTRUCTOR
-FNFC_CLASS::FNFC_CTOR(int val) {
+Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
_btype = val;
#ifdef __APPLE_COCOA__
_panel = NULL;
@@ -407,7 +407,7 @@ FNFC_CLASS::FNFC_CTOR(int val) {
}
// DESTRUCTOR
-FNFC_CLASS::~FNFC_CTOR() {
+Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
// _opts // nothing to manage
#ifndef __APPLE_COCOA__
if (_ref) { NavDialogDispose(_ref); _ref = NULL; }
@@ -430,23 +430,23 @@ FNFC_CLASS::~FNFC_CTOR() {
#ifndef __APPLE_COCOA__
// SET THE TYPE OF BROWSER
-void FNFC_CLASS::type(int val) {
+void Fl_Native_File_Chooser::type(int val) {
_btype = val;
}
#endif /* !__APPLE_COCOA__ */
// GET TYPE OF BROWSER
-int FNFC_CLASS::type() const {
+int Fl_Native_File_Chooser::type() const {
return(_btype);
}
// SET OPTIONS
-void FNFC_CLASS::options(int val) {
+void Fl_Native_File_Chooser::options(int val) {
_options = val;
}
// GET OPTIONS
-int FNFC_CLASS::options() const {
+int Fl_Native_File_Chooser::options() const {
return(_options);
}
@@ -456,7 +456,7 @@ int FNFC_CLASS::options() const {
// 1 - user cancelled
// -1 - failed; errmsg() has reason
//
-int FNFC_CLASS::show() {
+int Fl_Native_File_Chooser::show() {
// Make sure fltk interface updates before posting our dialog
Fl::flush();
@@ -520,7 +520,7 @@ int FNFC_CLASS::show() {
}
#ifndef __APPLE_COCOA__
-int FNFC_CLASS::post() {
+int Fl_Native_File_Chooser::post() {
// INITIALIZE BROWSER
OSStatus err;
@@ -612,37 +612,37 @@ int FNFC_CLASS::post() {
// SET ERROR MESSAGE
// Internal use only.
//
-void FNFC_CLASS::errmsg(const char *msg) {
+void Fl_Native_File_Chooser::errmsg(const char *msg) {
_errmsg = strfree(_errmsg);
_errmsg = strnew(msg);
}
// RETURN ERROR MESSAGE
-const char *FNFC_CLASS::errmsg() const {
+const char *Fl_Native_File_Chooser::errmsg() const {
return(_errmsg ? _errmsg : "No error");
}
// GET FILENAME
-const char* FNFC_CLASS::filename() const {
+const char* Fl_Native_File_Chooser::filename() const {
if ( _pathnames && _tpathnames > 0 ) return(_pathnames[0]);
return("");
}
// GET FILENAME FROM LIST OF FILENAMES
-const char* FNFC_CLASS::filename(int i) const {
+const char* Fl_Native_File_Chooser::filename(int i) const {
if ( _pathnames && i < _tpathnames ) return(_pathnames[i]);
return("");
}
// GET TOTAL FILENAMES CHOSEN
-int FNFC_CLASS::count() const {
+int Fl_Native_File_Chooser::count() const {
return(_tpathnames);
}
// PRESET PATHNAME
// Value can be NULL for none.
//
-void FNFC_CLASS::directory(const char *val) {
+void Fl_Native_File_Chooser::directory(const char *val) {
_directory = strfree(_directory);
_directory = strnew(val);
}
@@ -650,14 +650,14 @@ void FNFC_CLASS::directory(const char *val) {
// GET PRESET PATHNAME
// Returned value can be NULL if none set.
//
-const char* FNFC_CLASS::directory() const {
+const char* Fl_Native_File_Chooser::directory() const {
return(_directory);
}
// SET TITLE
// Value can be NULL if no title desired.
//
-void FNFC_CLASS::title(const char *val) {
+void Fl_Native_File_Chooser::title(const char *val) {
_title = strfree(_title);
_title = strnew(val);
}
@@ -665,14 +665,14 @@ void FNFC_CLASS::title(const char *val) {
// GET TITLE
// Returned value can be NULL if none set.
//
-const char *FNFC_CLASS::title() const {
+const char *Fl_Native_File_Chooser::title() const {
return(_title);
}
// SET FILTER
// Can be NULL if no filter needed
//
-void FNFC_CLASS::filter(const char *val) {
+void Fl_Native_File_Chooser::filter(const char *val) {
_filter = strfree(_filter);
_filter = strnew(val);
@@ -689,14 +689,14 @@ void FNFC_CLASS::filter(const char *val) {
// GET FILTER
// Returned value can be NULL if none set.
//
-const char *FNFC_CLASS::filter() const {
+const char *Fl_Native_File_Chooser::filter() const {
return(_filter);
}
// CLEAR ALL FILTERS
// Internal use only.
//
-void FNFC_CLASS::clear_filters() {
+void Fl_Native_File_Chooser::clear_filters() {
_filt_names = strfree(_filt_names);
for (int i=0; i<_filt_total; i++) {
_filt_patt[i] = strfree(_filt_patt[i]);
@@ -724,7 +724,7 @@ void FNFC_CLASS::clear_filters() {
// \_____/ \_______/
// Name Wildcard
//
-void FNFC_CLASS::parse_filter(const char *in) {
+void Fl_Native_File_Chooser::parse_filter(const char *in) {
clear_filters();
if ( ! in ) return;
int has_name = strchr(in, '\t') ? 1 : 0;
@@ -799,11 +799,11 @@ void FNFC_CLASS::parse_filter(const char *in) {
#ifndef __APPLE_COCOA__
// STATIC: FILTER CALLBACK
-Boolean FNFC_CLASS::filter_proc_cb(AEDesc *theItem,
+Boolean Fl_Native_File_Chooser::filter_proc_cb(AEDesc *theItem,
void *info,
void *callBackUD,
NavFilterModes filterMode) {
- return((FNFC_CLASS*)callBackUD)->filter_proc_cb2(theItem,
+ return((Fl_Native_File_Chooser*)callBackUD)->filter_proc_cb2(theItem,
info,
callBackUD,
filterMode);
@@ -813,7 +813,7 @@ Boolean FNFC_CLASS::filter_proc_cb(AEDesc *theItem,
// Return true if match,
// false if no match.
//
-Boolean FNFC_CLASS::filter_proc_cb2(AEDesc *theItem,
+Boolean Fl_Native_File_Chooser::filter_proc_cb2(AEDesc *theItem,
void *info,
void *callBackUD,
NavFilterModes filterMode) {
@@ -838,7 +838,7 @@ Boolean FNFC_CLASS::filter_proc_cb2(AEDesc *theItem,
// SET PRESET FILE
// Value can be NULL for none.
//
-void FNFC_CLASS::preset_file(const char* val) {
+void Fl_Native_File_Chooser::preset_file(const char* val) {
_preset_file = strfree(_preset_file);
_preset_file = strnew(val);
}
@@ -846,7 +846,7 @@ void FNFC_CLASS::preset_file(const char* val) {
// PRESET FILE
// Returned value can be NULL if none set.
//
-const char* FNFC_CLASS::preset_file() {
+const char* Fl_Native_File_Chooser::preset_file() {
return(_preset_file);
}
@@ -854,7 +854,7 @@ const char* FNFC_CLASS::preset_file() {
#import <Cocoa/Cocoa.h>
#define UNLIKELYPREFIX "___fl_very_unlikely_prefix_"
-int FNFC_CLASS::get_saveas_basename(void) {
+int Fl_Native_File_Chooser::get_saveas_basename(void) {
char *q = strdup( [[(NSSavePanel*)_panel filename] fileSystemRepresentation] );
id delegate = [(NSSavePanel*)_panel delegate];
if(delegate != nil) {
@@ -870,7 +870,7 @@ int FNFC_CLASS::get_saveas_basename(void) {
}
// SET THE TYPE OF BROWSER
-void FNFC_CLASS::type(int val) {
+void Fl_Native_File_Chooser::type(int val) {
_btype = val;
switch (_btype) {
case BROWSE_FILE:
@@ -966,7 +966,7 @@ static NSPopUpButton *createPopupAccessory(NSSavePanel *panel, const char *filte
// 1 - user cancelled
// -1 - failed; errmsg() has reason
//
-int FNFC_CLASS::post() {
+int Fl_Native_File_Chooser::post() {
// INITIALIZE BROWSER
if ( _filt_total == 0 ) { // Make sure they match
_filt_value = 0; // TBD: move to someplace more logical?
@@ -1081,6 +1081,7 @@ int FNFC_CLASS::post() {
}
#endif //__APPLE_COCOA__
+#endif /*!FL_DOXYGEN*/
//
// End of "$Id$".
diff --git a/src/Fl_Native_File_Chooser_WIN32.cxx b/src/Fl_Native_File_Chooser_WIN32.cxx
index e74e4ba6d..ac2637db1 100644
--- a/src/Fl_Native_File_Chooser_WIN32.cxx
+++ b/src/Fl_Native_File_Chooser_WIN32.cxx
@@ -30,6 +30,8 @@
// http://www.codeproject.com/dialog/selectfolder.asp
//
+#ifndef FL_DOXYGEN // PREVENT DOXYGEN'S USE OF THIS FILE
+
#include <stdio.h> // debugging
#include <wchar.h> //MG
#include "Fl_Native_File_Chooser_common.cxx" // strnew/strfree/strapp/chrcat
@@ -38,8 +40,6 @@ LPCWSTR utf8towchar(const char *in); //MG
char *wchartoutf8(LPCWSTR in); //MG
#include <FL/Fl_Native_File_Chooser.H>
-#define FNFC_CLASS Fl_Native_File_Chooser
-#define FNFC_CTOR Fl_Native_File_Chooser
#define LCURLY_CHR '{'
#define RCURLY_CHR '}'
@@ -125,7 +125,7 @@ static void dnullcat(char*&wp, const char *string, int n = -1 ) {
}
// CTOR
-FNFC_CLASS::FNFC_CTOR(int val) {
+Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
_btype = val;
_options = NO_OPTIONS;
memset((void*)&_ofn, 0, sizeof(OPENFILENAMEW));
@@ -144,7 +144,7 @@ FNFC_CLASS::FNFC_CTOR(int val) {
}
// DTOR
-FNFC_CLASS::~FNFC_CTOR() {
+Fl_Native_File_Chooser::~Fl_Native_File_Chooser() {
//_pathnames // managed by clear_pathnames()
//_tpathnames // managed by clear_pathnames()
_directory = strfree(_directory);
@@ -161,33 +161,33 @@ FNFC_CLASS::~FNFC_CTOR() {
}
// SET TYPE OF BROWSER
-void FNFC_CLASS::type(int val) {
+void Fl_Native_File_Chooser::type(int val) {
_btype = val;
}
// GET TYPE OF BROWSER
-int FNFC_CLASS::type() const {
+int Fl_Native_File_Chooser::type() const {
return( _btype );
}
// SET OPTIONS
-void FNFC_CLASS::options(int val) {
+void Fl_Native_File_Chooser::options(int val) {
_options = val;
}
// GET OPTIONS
-int FNFC_CLASS::options() const {
+int Fl_Native_File_Chooser::options() const {
return(_options);
}
// PRIVATE: SET ERROR MESSAGE
-void FNFC_CLASS::errmsg(const char *val) {
+void Fl_Native_File_Chooser::errmsg(const char *val) {
_errmsg = strfree(_errmsg);
_errmsg = strnew(val);
}
// FREE PATHNAMES ARRAY, IF IT HAS ANY CONTENTS
-void FNFC_CLASS::clear_pathnames() {
+void Fl_Native_File_Chooser::clear_pathnames() {
if ( _pathnames ) {
while ( --_tpathnames >= 0 ) {
_pathnames[_tpathnames] = strfree(_pathnames[_tpathnames]);
@@ -199,7 +199,7 @@ void FNFC_CLASS::clear_pathnames() {
}
// SET A SINGLE PATHNAME
-void FNFC_CLASS::set_single_pathname(const char *s) {
+void Fl_Native_File_Chooser::set_single_pathname(const char *s) {
clear_pathnames();
_pathnames = new char*[1];
_pathnames[0] = strnew(s);
@@ -207,7 +207,7 @@ void FNFC_CLASS::set_single_pathname(const char *s) {
}
// ADD PATHNAME TO EXISTING ARRAY
-void FNFC_CLASS::add_pathname(const char *s) {
+void Fl_Native_File_Chooser::add_pathname(const char *s) {
if ( ! _pathnames ) {
// Create first element in array
++_tpathnames;
@@ -225,7 +225,7 @@ void FNFC_CLASS::add_pathname(const char *s) {
}
// FREE A PIDL (Pointer to IDentity List)
-void FNFC_CLASS::FreePIDL(ITEMIDLIST *pidl) {
+void Fl_Native_File_Chooser::FreePIDL(ITEMIDLIST *pidl) {
IMalloc *imalloc = NULL;
if ( SUCCEEDED(SHGetMalloc(&imalloc)) ) {
imalloc->Free(pidl);
@@ -235,7 +235,7 @@ void FNFC_CLASS::FreePIDL(ITEMIDLIST *pidl) {
}
// CLEAR MICROSOFT OFN (OPEN FILE NAME) CLASS
-void FNFC_CLASS::ClearOFN() {
+void Fl_Native_File_Chooser::ClearOFN() {
// Free any previously allocated lpstrFile before zeroing out _ofn
if ( _ofn.lpstrFile ) {
delete [] _ofn.lpstrFile;
@@ -253,7 +253,7 @@ void FNFC_CLASS::ClearOFN() {
}
// CLEAR MICROSOFT BINF (BROWSER INFO) CLASS
-void FNFC_CLASS::ClearBINF() {
+void Fl_Native_File_Chooser::ClearBINF() {
if ( _binf.pidlRoot ) {
FreePIDL((ITEMIDLIST*)_binf.pidlRoot);
_binf.pidlRoot = NULL;
@@ -262,19 +262,19 @@ void FNFC_CLASS::ClearBINF() {
}
// CONVERT WINDOWS BACKSLASHES TO UNIX FRONTSLASHES
-void FNFC_CLASS::Win2Unix(char *s) {
+void Fl_Native_File_Chooser::Win2Unix(char *s) {
for ( ; *s; s++ )
if ( *s == '\\' ) *s = '/';
}
// CONVERT UNIX FRONTSLASHES TO WINDOWS BACKSLASHES
-void FNFC_CLASS::Unix2Win(char *s) {
+void Fl_Native_File_Chooser::Unix2Win(char *s) {
for ( ; *s; s++ )
if ( *s == '/' ) *s = '\\';
}
// SHOW FILE BROWSER
-int FNFC_CLASS::showfile() {
+int Fl_Native_File_Chooser::showfile() {
ClearOFN();
clear_pathnames();
size_t fsize = MAX_PATH;
@@ -437,7 +437,7 @@ int FNFC_CLASS::showfile() {
// Ref: Usenet: microsoft.public.vc.mfc, Dec 8 2000, 1:38p David Lowndes
// Subject: How to specify to select an initial folder .."
//
-int CALLBACK FNFC_CLASS::Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data) {
+int CALLBACK Fl_Native_File_Chooser::Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data) {
switch (msg) {
case BFFM_INITIALIZED:
if (data) ::SendMessage(win, BFFM_SETSELECTION, TRUE, data);
@@ -462,7 +462,7 @@ int CALLBACK FNFC_CLASS::Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data) {
}
// SHOW DIRECTORY BROWSER
-int FNFC_CLASS::showdir() {
+int Fl_Native_File_Chooser::showdir() {
OleInitialize(NULL); // init needed by BIF_USENEWUI
ClearBINF();
clear_pathnames();
@@ -531,7 +531,7 @@ int FNFC_CLASS::showdir() {
// 1 - user cancelled
// -1 - failed; errmsg() has reason
//
-int FNFC_CLASS::show() {
+int Fl_Native_File_Chooser::show() {
if ( _btype == BROWSE_DIRECTORY ||
_btype == BROWSE_MULTI_DIRECTORY ||
_btype == BROWSE_SAVE_DIRECTORY ) {
@@ -542,31 +542,31 @@ int FNFC_CLASS::show() {
}
// RETURN ERROR MESSAGE
-const char *FNFC_CLASS::errmsg() const {
+const char *Fl_Native_File_Chooser::errmsg() const {
return(_errmsg ? _errmsg : "No error");
}
// GET FILENAME
-const char* FNFC_CLASS::filename() const {
+const char* Fl_Native_File_Chooser::filename() const {
if ( _pathnames && _tpathnames > 0 ) return(_pathnames[0]);
return("");
}
// GET FILENAME FROM LIST OF FILENAMES
-const char* FNFC_CLASS::filename(int i) const {
+const char* Fl_Native_File_Chooser::filename(int i) const {
if ( _pathnames && i < _tpathnames ) return(_pathnames[i]);
return("");
}
// GET TOTAL FILENAMES CHOSEN
-int FNFC_CLASS::count() const {
+int Fl_Native_File_Chooser::count() const {
return(_tpathnames);
}
// PRESET PATHNAME
// Can be NULL if no preset is desired.
//
-void FNFC_CLASS::directory(const char *val) {
+void Fl_Native_File_Chooser::directory(const char *val) {
_directory = strfree(_directory);
_directory = strnew(val);
}
@@ -574,14 +574,14 @@ void FNFC_CLASS::directory(const char *val) {
// GET PRESET PATHNAME
// Can return NULL if none set.
//
-const char *FNFC_CLASS::directory() const {
+const char *Fl_Native_File_Chooser::directory() const {
return(_directory);
}
// SET TITLE
// Can be NULL if no title desired.
//
-void FNFC_CLASS::title(const char *val) {
+void Fl_Native_File_Chooser::title(const char *val) {
_title = strfree(_title);
_title = strnew(val);
}
@@ -589,14 +589,14 @@ void FNFC_CLASS::title(const char *val) {
// GET TITLE
// Can return NULL if none set.
//
-const char *FNFC_CLASS::title() const {
+const char *Fl_Native_File_Chooser::title() const {
return(_title);
}
// SET FILTER
// Can be NULL if no filter needed
//
-void FNFC_CLASS::filter(const char *val) {
+void Fl_Native_File_Chooser::filter(const char *val) {
_filter = strfree(_filter);
clear_filters();
if ( val ) {
@@ -613,18 +613,18 @@ void FNFC_CLASS::filter(const char *val) {
// GET FILTER
// Can return NULL if none set.
//
-const char *FNFC_CLASS::filter() const {
+const char *Fl_Native_File_Chooser::filter() const {
return(_filter);
}
// CLEAR FILTERS
-void FNFC_CLASS::clear_filters() {
+void Fl_Native_File_Chooser::clear_filters() {
_nfilters = 0;
_parsedfilt = strfree(_parsedfilt);
}
// ADD A FILTER
-void FNFC_CLASS::add_filter(const char *name_in, // name of filter (optional: can be null)
+void Fl_Native_File_Chooser::add_filter(const char *name_in, // name of filter (optional: can be null)
const char *winfilter) { // windows style filter (eg. "*.cxx;*.h")
// No name? Make one..
char name[1024];
@@ -662,7 +662,7 @@ void FNFC_CLASS::add_filter(const char *name_in, // name of filter (optional: ca
// \_____/ \_______/
// Name Wildcard
//
-void FNFC_CLASS::parse_filter(const char *in) {
+void Fl_Native_File_Chooser::parse_filter(const char *in) {
clear_filters();
if ( ! in ) return;
@@ -795,23 +795,23 @@ void FNFC_CLASS::parse_filter(const char *in) {
}
// SET 'CURRENTLY SELECTED FILTER'
-void FNFC_CLASS::filter_value(int i) {
+void Fl_Native_File_Chooser::filter_value(int i) {
_ofn.nFilterIndex = i + 1;
}
// RETURN VALUE OF 'CURRENTLY SELECTED FILTER'
-int FNFC_CLASS::filter_value() const {
+int Fl_Native_File_Chooser::filter_value() const {
return(_ofn.nFilterIndex ? _ofn.nFilterIndex-1 : _nfilters+1);
}
// PRESET FILENAME FOR 'SAVE AS' CHOOSER
-void FNFC_CLASS::preset_file(const char* val) {
+void Fl_Native_File_Chooser::preset_file(const char* val) {
_preset_file = strfree(_preset_file);
_preset_file = strnew(val);
}
// GET PRESET FILENAME FOR 'SAVE AS' CHOOSER
-const char* FNFC_CLASS::preset_file() const {
+const char* Fl_Native_File_Chooser::preset_file() const {
return(_preset_file);
}
@@ -843,6 +843,8 @@ LPCWSTR utf8towchar(const char *in)
return wout;
}
+#endif /*!FL_DOXYGEN*/
+
//
// End of "$Id$".
//