mirror of
https://github.com/fltk/fltk.git
synced 2026-05-23 15:56:10 +08:00
Use more consistent naming for derived classes of Fl_Native_File_Chooser_Driver.
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3-porting@11628 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
This commit is contained in:
@@ -28,12 +28,12 @@
|
||||
this API has a do-nothing default implementation
|
||||
|
||||
class Fl_Native_File_Chooser_FLTK_Driver <== this API implementation is the default FLTK file chooser
|
||||
class Fl_Native_File_Chooser_GTK_Driver <== this API implementation runs a GTK file chooser
|
||||
class Fl_GTK_Native_File_Chooser_Driver <== this API implementation runs a GTK file chooser
|
||||
it is determined at run-time if the GTK dynamic libraries are available
|
||||
|
||||
class Fl_Native_File_Chooser_Darwin_Driver <== this API implementation runs a Mac OS X file chooser
|
||||
class Fl_Quartz_Native_File_Chooser_Driver <== this API implementation runs a Mac OS X file chooser
|
||||
|
||||
class Fl_Native_File_Chooser_WinAPI_Driver <== this API implementation runs a MSWindows file chooser
|
||||
class Fl_WinAPI_Native_File_Chooser_Driver <== this API implementation runs a MSWindows file chooser
|
||||
|
||||
|
||||
Each platform must implement the constructor of the Fl_Native_File_Chooser class.
|
||||
@@ -47,7 +47,7 @@
|
||||
No more code is required. The cross-platform Fl_Native_File_Chooser_FLTK.cxx file must be compiled in libfltk,
|
||||
and the default FLTK file chooser will be used.
|
||||
|
||||
This other implementation
|
||||
This other implementation:
|
||||
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||
platform_fnfc = 0;
|
||||
}
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
#include <FL/Fl_Native_File_Chooser.H>
|
||||
|
||||
#ifdef FL_PORTING
|
||||
# pragma message "Implement a native file chooser (see Fl_Native_File_Chooser_Driver), or use FLTK's chooser"
|
||||
# pragma message "Implement a native file chooser (see Fl_Native_File_Chooser_Driver), or use FLTK's chooser, or don't use any chooser"
|
||||
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||
platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(val);
|
||||
}
|
||||
|
||||
@@ -96,16 +96,16 @@ typedef void (*GClosureNotify)(gpointer data, GClosure *closure);
|
||||
/* --------------------- End of Type definitions from GLIB and GTK --------------------- */
|
||||
|
||||
|
||||
class FL_EXPORT Fl_Native_File_Chooser_GTK_Driver : public Fl_Native_File_Chooser_FLTK_Driver {
|
||||
class FL_EXPORT Fl_GTK_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_FLTK_Driver {
|
||||
friend class Fl_Native_File_Chooser;
|
||||
private:
|
||||
static int have_looked_for_GTK_libs;
|
||||
typedef struct _GtkWidget GtkWidget;
|
||||
typedef struct _GtkFileFilterInfo GtkFileFilterInfo;
|
||||
struct pair {
|
||||
Fl_Native_File_Chooser_GTK_Driver* running; // the running Fl_GTK_File_Chooser
|
||||
Fl_GTK_Native_File_Chooser_Driver* running; // the running Fl_GTK_File_Chooser
|
||||
const char *filter; // a filter string of the chooser
|
||||
pair(Fl_Native_File_Chooser_GTK_Driver* c, const char *f) {
|
||||
pair(Fl_GTK_Native_File_Chooser_Driver* c, const char *f) {
|
||||
running = c;
|
||||
filter = strdup(f);
|
||||
};
|
||||
@@ -121,8 +121,8 @@ private:
|
||||
const char *previous_filter;
|
||||
|
||||
int fl_gtk_chooser_wrapper(); // method that wraps the GTK widget
|
||||
Fl_Native_File_Chooser_GTK_Driver(int val);
|
||||
virtual ~Fl_Native_File_Chooser_GTK_Driver();
|
||||
Fl_GTK_Native_File_Chooser_Driver(int val);
|
||||
virtual ~Fl_GTK_Native_File_Chooser_Driver();
|
||||
static int did_find_GTK_libs;
|
||||
static void probe_for_GTK_libs(void);
|
||||
virtual void type(int);
|
||||
@@ -134,12 +134,12 @@ private:
|
||||
virtual int show();
|
||||
void changed_output_type(const char *filter);
|
||||
|
||||
static int custom_gtk_filter_function(const GtkFileFilterInfo*, Fl_Native_File_Chooser_GTK_Driver::pair*);
|
||||
static int custom_gtk_filter_function(const GtkFileFilterInfo*, Fl_GTK_Native_File_Chooser_Driver::pair*);
|
||||
static void free_pair(pair *p);
|
||||
};
|
||||
|
||||
|
||||
int Fl_Native_File_Chooser_GTK_Driver::did_find_GTK_libs = 0;
|
||||
int Fl_GTK_Native_File_Chooser_Driver::did_find_GTK_libs = 0;
|
||||
|
||||
/* These are the GTK/GLib methods we want to load, but not call by name...! */
|
||||
|
||||
@@ -291,26 +291,26 @@ typedef void (*XX_gtk_toggle_button_set_active)(GtkToggleButton *, gboolean);
|
||||
static XX_gtk_toggle_button_set_active fl_gtk_toggle_button_set_active = NULL;
|
||||
|
||||
|
||||
int Fl_Native_File_Chooser_GTK_Driver::have_looked_for_GTK_libs = 0;
|
||||
int Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs = 0;
|
||||
|
||||
|
||||
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||
if (Fl_Native_File_Chooser_GTK_Driver::have_looked_for_GTK_libs == 0) {
|
||||
if (Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs == 0) {
|
||||
// First Time here, try to find the GTK libs if they are installed
|
||||
#if HAVE_DLSYM && HAVE_DLFCN_H
|
||||
if (Fl::option(Fl::OPTION_FNFC_USES_GTK)) {
|
||||
Fl_Native_File_Chooser_GTK_Driver::probe_for_GTK_libs();
|
||||
Fl_GTK_Native_File_Chooser_Driver::probe_for_GTK_libs();
|
||||
}
|
||||
#endif
|
||||
Fl_Native_File_Chooser_GTK_Driver::have_looked_for_GTK_libs = -1;
|
||||
Fl_GTK_Native_File_Chooser_Driver::have_looked_for_GTK_libs = -1;
|
||||
}
|
||||
// if we found all the GTK functions we need, we will use the GtkFileChooserDialog
|
||||
if (Fl_Native_File_Chooser_GTK_Driver::did_find_GTK_libs) platform_fnfc = new Fl_Native_File_Chooser_GTK_Driver(val);
|
||||
if (Fl_GTK_Native_File_Chooser_Driver::did_find_GTK_libs) platform_fnfc = new Fl_GTK_Native_File_Chooser_Driver(val);
|
||||
else platform_fnfc = new Fl_Native_File_Chooser_FLTK_Driver(val);
|
||||
}
|
||||
|
||||
|
||||
Fl_Native_File_Chooser_GTK_Driver::Fl_Native_File_Chooser_GTK_Driver(int val) : Fl_Native_File_Chooser_FLTK_Driver(-1)
|
||||
Fl_GTK_Native_File_Chooser_Driver::Fl_GTK_Native_File_Chooser_Driver(int val) : Fl_Native_File_Chooser_FLTK_Driver(-1)
|
||||
{
|
||||
gtkw_ptr = NULL; // used to hold a GtkWidget*
|
||||
gtkw_slist = NULL; // will hold the returned file names in a multi-selection...
|
||||
@@ -321,7 +321,7 @@ Fl_Native_File_Chooser_GTK_Driver::Fl_Native_File_Chooser_GTK_Driver(int val) :
|
||||
previous_filter = NULL;
|
||||
}
|
||||
|
||||
Fl_Native_File_Chooser_GTK_Driver::~Fl_Native_File_Chooser_GTK_Driver()
|
||||
Fl_GTK_Native_File_Chooser_Driver::~Fl_GTK_Native_File_Chooser_Driver()
|
||||
{
|
||||
// Should free up resources taken for...
|
||||
if(gtkw_ptr) {
|
||||
@@ -345,15 +345,15 @@ Fl_Native_File_Chooser_GTK_Driver::~Fl_Native_File_Chooser_GTK_Driver()
|
||||
gtkw_title = strfree(gtkw_title);
|
||||
}
|
||||
|
||||
void Fl_Native_File_Chooser_GTK_Driver::type(int val) {
|
||||
void Fl_GTK_Native_File_Chooser_Driver::type(int val) {
|
||||
_btype = val;
|
||||
}
|
||||
|
||||
int Fl_Native_File_Chooser_GTK_Driver::count() const {
|
||||
int Fl_GTK_Native_File_Chooser_Driver::count() const {
|
||||
return gtkw_count;
|
||||
}
|
||||
|
||||
const char *Fl_Native_File_Chooser_GTK_Driver::filename() const
|
||||
const char *Fl_GTK_Native_File_Chooser_Driver::filename() const
|
||||
{
|
||||
if(gtkw_ptr) {
|
||||
if(fl_gtk_file_chooser_get_select_multiple((GtkFileChooser *)gtkw_ptr) == FALSE) {
|
||||
@@ -368,7 +368,7 @@ const char *Fl_Native_File_Chooser_GTK_Driver::filename() const
|
||||
return("");
|
||||
}
|
||||
|
||||
const char *Fl_Native_File_Chooser_GTK_Driver::filename(int i) const
|
||||
const char *Fl_GTK_Native_File_Chooser_Driver::filename(int i) const
|
||||
{
|
||||
if(fl_gtk_file_chooser_get_select_multiple((GtkFileChooser *)gtkw_ptr) == FALSE) {
|
||||
return gtkw_filename;
|
||||
@@ -383,19 +383,19 @@ const char *Fl_Native_File_Chooser_GTK_Driver::filename(int i) const
|
||||
return("");
|
||||
}
|
||||
|
||||
void Fl_Native_File_Chooser_GTK_Driver::title(const char *val)
|
||||
void Fl_GTK_Native_File_Chooser_Driver::title(const char *val)
|
||||
{
|
||||
strfree(gtkw_title);
|
||||
gtkw_title = strnew(val);
|
||||
}
|
||||
|
||||
const char* Fl_Native_File_Chooser_GTK_Driver::title() const
|
||||
const char* Fl_GTK_Native_File_Chooser_Driver::title() const
|
||||
{
|
||||
return gtkw_title;
|
||||
}
|
||||
|
||||
/* changes the extension of the outfile in the chooser according to newly selected filter */
|
||||
void Fl_Native_File_Chooser_GTK_Driver::changed_output_type(const char *filter)
|
||||
void Fl_GTK_Native_File_Chooser_Driver::changed_output_type(const char *filter)
|
||||
{
|
||||
if ( !(options()&Fl_Native_File_Chooser::USE_FILTER_EXT) ) return;
|
||||
if (strchr(filter, '(') || strchr(filter, '{') || strchr(filter+1, '*') || strncmp(filter, "*.", 2)) return;
|
||||
@@ -413,7 +413,7 @@ void Fl_Native_File_Chooser_GTK_Driver::changed_output_type(const char *filter)
|
||||
|
||||
/* Filters files before display in chooser.
|
||||
Also used to detect when the filter just changed */
|
||||
gboolean Fl_Native_File_Chooser_GTK_Driver::custom_gtk_filter_function(const GtkFileFilterInfo *info, Fl_Native_File_Chooser_GTK_Driver::pair* p)
|
||||
gboolean Fl_GTK_Native_File_Chooser_Driver::custom_gtk_filter_function(const GtkFileFilterInfo *info, Fl_GTK_Native_File_Chooser_Driver::pair* p)
|
||||
{
|
||||
if (p->running->previous_filter != p->filter) {
|
||||
p->running->changed_output_type(p->filter);
|
||||
@@ -422,7 +422,7 @@ gboolean Fl_Native_File_Chooser_GTK_Driver::custom_gtk_filter_function(const Gtk
|
||||
return (gboolean)fl_filename_match(fl_filename_name(info->filename), p->filter);
|
||||
}
|
||||
|
||||
void Fl_Native_File_Chooser_GTK_Driver::free_pair(Fl_Native_File_Chooser_GTK_Driver::pair *p)
|
||||
void Fl_GTK_Native_File_Chooser_Driver::free_pair(Fl_GTK_Native_File_Chooser_Driver::pair *p)
|
||||
{
|
||||
delete p;
|
||||
}
|
||||
@@ -433,7 +433,7 @@ static void hidden_files_cb(GtkToggleButton *togglebutton, gpointer user_data)
|
||||
fl_gtk_file_chooser_set_show_hidden((GtkFileChooser*)user_data, state);
|
||||
}
|
||||
|
||||
int Fl_Native_File_Chooser_GTK_Driver::show()
|
||||
int Fl_GTK_Native_File_Chooser_Driver::show()
|
||||
{
|
||||
// The point here is that after running a GTK dialog, the calling program's current locale is modified.
|
||||
// To avoid that, we memorize the calling program's current locale, and the locale as modified
|
||||
@@ -489,7 +489,7 @@ static void run_response_handler(GtkDialog *dialog, gint response_id, gpointer d
|
||||
}
|
||||
|
||||
|
||||
int Fl_Native_File_Chooser_GTK_Driver::fl_gtk_chooser_wrapper()
|
||||
int Fl_GTK_Native_File_Chooser_Driver::fl_gtk_chooser_wrapper()
|
||||
{
|
||||
int result = 1;
|
||||
static int have_gtk_init = 0;
|
||||
@@ -586,9 +586,9 @@ int Fl_Native_File_Chooser_GTK_Driver::fl_gtk_chooser_wrapper()
|
||||
char *q = strchr(p, ')'); *q = 0;
|
||||
fl_gtk_file_filter_add_custom(filter_tab[count],
|
||||
GTK_FILE_FILTER_FILENAME,
|
||||
(GtkFileFilterFunc)Fl_Native_File_Chooser_GTK_Driver::custom_gtk_filter_function,
|
||||
new Fl_Native_File_Chooser_GTK_Driver::pair(this, p),
|
||||
(GDestroyNotify)Fl_Native_File_Chooser_GTK_Driver::free_pair);
|
||||
(GtkFileFilterFunc)Fl_GTK_Native_File_Chooser_Driver::custom_gtk_filter_function,
|
||||
new Fl_GTK_Native_File_Chooser_Driver::pair(this, p),
|
||||
(GDestroyNotify)Fl_GTK_Native_File_Chooser_Driver::free_pair);
|
||||
fl_gtk_file_chooser_add_filter((GtkFileChooser *)gtkw_ptr, filter_tab[count]);
|
||||
p = strtok(NULL, "\t");
|
||||
count++;
|
||||
@@ -714,7 +714,7 @@ static void* fl_dlopen(const char *filename1, const char *filename2)
|
||||
* will allow us to create a GtkFileChooserDialog() on the fly,
|
||||
* without linking to the GTK libs at compile time.
|
||||
*/
|
||||
void Fl_Native_File_Chooser_GTK_Driver::probe_for_GTK_libs(void) {
|
||||
void Fl_GTK_Native_File_Chooser_Driver::probe_for_GTK_libs(void) {
|
||||
#if HAVE_DLSYM && HAVE_DLFCN_H
|
||||
void *ptr_glib = NULL;
|
||||
void *ptr_gtk = NULL;
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
#include <FL/filename.H>
|
||||
#define MAXFILTERS 80
|
||||
|
||||
class Fl_Native_File_Chooser_Darwin_Driver : public Fl_Native_File_Chooser_Driver {
|
||||
class Fl_Quartz_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_Driver {
|
||||
private:
|
||||
int _btype; // kind-of browser to show()
|
||||
int _options; // general options
|
||||
@@ -66,8 +66,8 @@ private:
|
||||
int post();
|
||||
int runmodal();
|
||||
public:
|
||||
Fl_Native_File_Chooser_Darwin_Driver(int val);
|
||||
~Fl_Native_File_Chooser_Darwin_Driver();
|
||||
Fl_Quartz_Native_File_Chooser_Driver(int val);
|
||||
~Fl_Quartz_Native_File_Chooser_Driver();
|
||||
virtual void type(int t);
|
||||
virtual int type() const ;
|
||||
virtual void options(int o);
|
||||
@@ -91,11 +91,11 @@ public:
|
||||
};
|
||||
|
||||
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||
platform_fnfc = new Fl_Native_File_Chooser_Darwin_Driver(val);
|
||||
platform_fnfc = new Fl_Quartz_Native_File_Chooser_Driver(val);
|
||||
}
|
||||
|
||||
// FREE PATHNAMES ARRAY, IF IT HAS ANY CONTENTS
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::clear_pathnames() {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::clear_pathnames() {
|
||||
if ( _pathnames ) {
|
||||
while ( --_tpathnames >= 0 ) {
|
||||
_pathnames[_tpathnames] = strfree(_pathnames[_tpathnames]);
|
||||
@@ -107,7 +107,7 @@ void Fl_Native_File_Chooser_Darwin_Driver::clear_pathnames() {
|
||||
}
|
||||
|
||||
// SET A SINGLE PATHNAME
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::set_single_pathname(const char *s) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::set_single_pathname(const char *s) {
|
||||
clear_pathnames();
|
||||
_pathnames = new char*[1];
|
||||
_pathnames[0] = strnew(s);
|
||||
@@ -115,7 +115,7 @@ void Fl_Native_File_Chooser_Darwin_Driver::set_single_pathname(const char *s) {
|
||||
}
|
||||
|
||||
// CONSTRUCTOR
|
||||
Fl_Native_File_Chooser_Darwin_Driver::Fl_Native_File_Chooser_Darwin_Driver(int val) :
|
||||
Fl_Quartz_Native_File_Chooser_Driver::Fl_Quartz_Native_File_Chooser_Driver(int val) :
|
||||
Fl_Native_File_Chooser_Driver(val) {
|
||||
_btype = val;
|
||||
_panel = NULL;
|
||||
@@ -134,7 +134,7 @@ Fl_Native_File_Chooser_Darwin_Driver::Fl_Native_File_Chooser_Darwin_Driver(int v
|
||||
}
|
||||
|
||||
// DESTRUCTOR
|
||||
Fl_Native_File_Chooser_Darwin_Driver::~Fl_Native_File_Chooser_Darwin_Driver() {
|
||||
Fl_Quartz_Native_File_Chooser_Driver::~Fl_Quartz_Native_File_Chooser_Driver() {
|
||||
// _opts // nothing to manage
|
||||
// _options // nothing to manage
|
||||
// _keepstate // nothing to manage
|
||||
@@ -153,17 +153,17 @@ Fl_Native_File_Chooser_Darwin_Driver::~Fl_Native_File_Chooser_Darwin_Driver() {
|
||||
}
|
||||
|
||||
// GET TYPE OF BROWSER
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::type() const {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::type() const {
|
||||
return(_btype);
|
||||
}
|
||||
|
||||
// SET OPTIONS
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::options(int val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::options(int val) {
|
||||
_options = val;
|
||||
}
|
||||
|
||||
// GET OPTIONS
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::options() const {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::options() const {
|
||||
return(_options);
|
||||
}
|
||||
|
||||
@@ -173,7 +173,7 @@ int Fl_Native_File_Chooser_Darwin_Driver::options() const {
|
||||
// 1 - user cancelled
|
||||
// -1 - failed; errmsg() has reason
|
||||
//
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::show() {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::show() {
|
||||
|
||||
// Make sure fltk interface updates before posting our dialog
|
||||
Fl::flush();
|
||||
@@ -187,37 +187,37 @@ int Fl_Native_File_Chooser_Darwin_Driver::show() {
|
||||
// SET ERROR MESSAGE
|
||||
// Internal use only.
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::errmsg(const char *msg) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::errmsg(const char *msg) {
|
||||
_errmsg = strfree(_errmsg);
|
||||
_errmsg = strnew(msg);
|
||||
}
|
||||
|
||||
// RETURN ERROR MESSAGE
|
||||
const char *Fl_Native_File_Chooser_Darwin_Driver::errmsg() const {
|
||||
const char *Fl_Quartz_Native_File_Chooser_Driver::errmsg() const {
|
||||
return(_errmsg ? _errmsg : "No error");
|
||||
}
|
||||
|
||||
// GET FILENAME
|
||||
const char* Fl_Native_File_Chooser_Darwin_Driver::filename() const {
|
||||
const char* Fl_Quartz_Native_File_Chooser_Driver::filename() const {
|
||||
if ( _pathnames && _tpathnames > 0 ) return(_pathnames[0]);
|
||||
return("");
|
||||
}
|
||||
|
||||
// GET FILENAME FROM LIST OF FILENAMES
|
||||
const char* Fl_Native_File_Chooser_Darwin_Driver::filename(int i) const {
|
||||
const char* Fl_Quartz_Native_File_Chooser_Driver::filename(int i) const {
|
||||
if ( _pathnames && i < _tpathnames ) return(_pathnames[i]);
|
||||
return("");
|
||||
}
|
||||
|
||||
// GET TOTAL FILENAMES CHOSEN
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::count() const {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::count() const {
|
||||
return(_tpathnames);
|
||||
}
|
||||
|
||||
// PRESET PATHNAME
|
||||
// Value can be NULL for none.
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::directory(const char *val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::directory(const char *val) {
|
||||
_directory = strfree(_directory);
|
||||
_directory = strnew(val);
|
||||
}
|
||||
@@ -225,14 +225,14 @@ void Fl_Native_File_Chooser_Darwin_Driver::directory(const char *val) {
|
||||
// GET PRESET PATHNAME
|
||||
// Returned value can be NULL if none set.
|
||||
//
|
||||
const char* Fl_Native_File_Chooser_Darwin_Driver::directory() const {
|
||||
const char* Fl_Quartz_Native_File_Chooser_Driver::directory() const {
|
||||
return(_directory);
|
||||
}
|
||||
|
||||
// SET TITLE
|
||||
// Value can be NULL if no title desired.
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::title(const char *val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::title(const char *val) {
|
||||
_title = strfree(_title);
|
||||
_title = strnew(val);
|
||||
}
|
||||
@@ -240,14 +240,14 @@ void Fl_Native_File_Chooser_Darwin_Driver::title(const char *val) {
|
||||
// GET TITLE
|
||||
// Returned value can be NULL if none set.
|
||||
//
|
||||
const char *Fl_Native_File_Chooser_Darwin_Driver::title() const {
|
||||
const char *Fl_Quartz_Native_File_Chooser_Driver::title() const {
|
||||
return(_title);
|
||||
}
|
||||
|
||||
// SET FILTER
|
||||
// Can be NULL if no filter needed
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::filter(const char *val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::filter(const char *val) {
|
||||
_filter = strfree(_filter);
|
||||
_filter = strnew(val);
|
||||
|
||||
@@ -264,14 +264,14 @@ void Fl_Native_File_Chooser_Darwin_Driver::filter(const char *val) {
|
||||
// GET FILTER
|
||||
// Returned value can be NULL if none set.
|
||||
//
|
||||
const char *Fl_Native_File_Chooser_Darwin_Driver::filter() const {
|
||||
const char *Fl_Quartz_Native_File_Chooser_Driver::filter() const {
|
||||
return(_filter);
|
||||
}
|
||||
|
||||
// CLEAR ALL FILTERS
|
||||
// Internal use only.
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::clear_filters() {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::clear_filters() {
|
||||
_filt_names = strfree(_filt_names);
|
||||
for (int i=0; i<_filt_total; i++) {
|
||||
_filt_patt[i] = strfree(_filt_patt[i]);
|
||||
@@ -299,7 +299,7 @@ void Fl_Native_File_Chooser_Darwin_Driver::clear_filters() {
|
||||
// \_____/ \_______/
|
||||
// Name Wildcard
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::parse_filter(const char *in) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::parse_filter(const char *in) {
|
||||
clear_filters();
|
||||
if ( ! in ) return;
|
||||
int has_name = strchr(in, '\t') ? 1 : 0;
|
||||
@@ -375,7 +375,7 @@ void Fl_Native_File_Chooser_Darwin_Driver::parse_filter(const char *in) {
|
||||
// SET PRESET FILE
|
||||
// Value can be NULL for none.
|
||||
//
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::preset_file(const char* val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::preset_file(const char* val) {
|
||||
_preset_file = strfree(_preset_file);
|
||||
_preset_file = strnew(val);
|
||||
}
|
||||
@@ -383,26 +383,26 @@ void Fl_Native_File_Chooser_Darwin_Driver::preset_file(const char* val) {
|
||||
// PRESET FILE
|
||||
// Returned value can be NULL if none set.
|
||||
//
|
||||
const char* Fl_Native_File_Chooser_Darwin_Driver::preset_file() const {
|
||||
const char* Fl_Quartz_Native_File_Chooser_Driver::preset_file() const {
|
||||
return(_preset_file);
|
||||
}
|
||||
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::filter_value(int val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::filter_value(int val) {
|
||||
_filt_value = val;
|
||||
}
|
||||
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::filter_value() const {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::filter_value() const {
|
||||
return(_filt_value);
|
||||
}
|
||||
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::filters() const {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::filters() const {
|
||||
return(_filt_total);
|
||||
}
|
||||
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#define UNLIKELYPREFIX "___fl_very_unlikely_prefix_"
|
||||
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::get_saveas_basename(void) {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::get_saveas_basename(void) {
|
||||
char *q = strdup( [[[(NSSavePanel*)_panel URL] path] UTF8String] );
|
||||
if ( !(_options & Fl_Native_File_Chooser::SAVEAS_CONFIRM) ) {
|
||||
const char *d = [[[[(NSSavePanel*)_panel URL] path] stringByDeletingLastPathComponent] UTF8String];
|
||||
@@ -418,7 +418,7 @@ int Fl_Native_File_Chooser_Darwin_Driver::get_saveas_basename(void) {
|
||||
}
|
||||
|
||||
// SET THE TYPE OF BROWSER
|
||||
void Fl_Native_File_Chooser_Darwin_Driver::type(int val) {
|
||||
void Fl_Quartz_Native_File_Chooser_Driver::type(int val) {
|
||||
_btype = val;
|
||||
}
|
||||
|
||||
@@ -587,7 +587,7 @@ static NSPopUpButton *createPopupAccessory(NSSavePanel *panel, const char *filte
|
||||
return popup;
|
||||
}
|
||||
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::runmodal()
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::runmodal()
|
||||
{
|
||||
NSString *dir = nil;
|
||||
NSString *fname = nil;
|
||||
@@ -623,7 +623,7 @@ int Fl_Native_File_Chooser_Darwin_Driver::runmodal()
|
||||
// 1 - user cancelled
|
||||
// -1 - failed; errmsg() has reason
|
||||
//
|
||||
int Fl_Native_File_Chooser_Darwin_Driver::post() {
|
||||
int Fl_Quartz_Native_File_Chooser_Driver::post() {
|
||||
// INITIALIZE BROWSER
|
||||
if ( _filt_total == 0 ) { // Make sure they match
|
||||
_filt_value = 0; // TBD: move to someplace more logical?
|
||||
|
||||
@@ -38,7 +38,7 @@
|
||||
#include <FL/x.H> // for fl_open_display
|
||||
|
||||
|
||||
class Fl_Native_File_Chooser_WinAPI_Driver : public Fl_Native_File_Chooser_Driver {
|
||||
class Fl_WinAPI_Native_File_Chooser_Driver : public Fl_Native_File_Chooser_Driver {
|
||||
private:
|
||||
int _btype; // kind-of browser to show()
|
||||
int _options; // general options
|
||||
@@ -72,8 +72,8 @@ private:
|
||||
void clear_filters();
|
||||
void add_filter(const char *, const char *);
|
||||
public:
|
||||
Fl_Native_File_Chooser_WinAPI_Driver(int val);
|
||||
~Fl_Native_File_Chooser_WinAPI_Driver();
|
||||
Fl_WinAPI_Native_File_Chooser_Driver(int val);
|
||||
~Fl_WinAPI_Native_File_Chooser_Driver();
|
||||
virtual void type(int t);
|
||||
virtual int type() const ;
|
||||
virtual void options(int o);
|
||||
@@ -98,7 +98,7 @@ public:
|
||||
|
||||
|
||||
Fl_Native_File_Chooser::Fl_Native_File_Chooser(int val) {
|
||||
platform_fnfc = new Fl_Native_File_Chooser_WinAPI_Driver(val);
|
||||
platform_fnfc = new Fl_WinAPI_Native_File_Chooser_Driver(val);
|
||||
}
|
||||
|
||||
|
||||
@@ -193,7 +193,7 @@ static void dnullcat(char*&wp, const char *string, int n = -1 ) {
|
||||
}
|
||||
|
||||
// CTOR
|
||||
Fl_Native_File_Chooser_WinAPI_Driver::Fl_Native_File_Chooser_WinAPI_Driver(int val) :
|
||||
Fl_WinAPI_Native_File_Chooser_Driver::Fl_WinAPI_Native_File_Chooser_Driver(int val) :
|
||||
Fl_Native_File_Chooser_Driver(val) {
|
||||
_btype = val;
|
||||
_options = Fl_Native_File_Chooser::NO_OPTIONS;
|
||||
@@ -215,7 +215,7 @@ Fl_Native_File_Chooser_WinAPI_Driver::Fl_Native_File_Chooser_WinAPI_Driver(int v
|
||||
}
|
||||
|
||||
// DTOR
|
||||
Fl_Native_File_Chooser_WinAPI_Driver::~Fl_Native_File_Chooser_WinAPI_Driver() {
|
||||
Fl_WinAPI_Native_File_Chooser_Driver::~Fl_WinAPI_Native_File_Chooser_Driver() {
|
||||
//_pathnames // managed by clear_pathnames()
|
||||
//_tpathnames // managed by clear_pathnames()
|
||||
_directory = strfree(_directory);
|
||||
@@ -234,33 +234,33 @@ Fl_Native_File_Chooser_WinAPI_Driver::~Fl_Native_File_Chooser_WinAPI_Driver() {
|
||||
}
|
||||
|
||||
// SET TYPE OF BROWSER
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::type(int val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::type(int val) {
|
||||
_btype = val;
|
||||
}
|
||||
|
||||
// GET TYPE OF BROWSER
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::type() const {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::type() const {
|
||||
return( _btype );
|
||||
}
|
||||
|
||||
// SET OPTIONS
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::options(int val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::options(int val) {
|
||||
_options = val;
|
||||
}
|
||||
|
||||
// GET OPTIONS
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::options() const {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::options() const {
|
||||
return(_options);
|
||||
}
|
||||
|
||||
// PRIVATE: SET ERROR MESSAGE
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::errmsg(const char *val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::errmsg(const char *val) {
|
||||
_errmsg = strfree(_errmsg);
|
||||
_errmsg = strnew(val);
|
||||
}
|
||||
|
||||
// FREE PATHNAMES ARRAY, IF IT HAS ANY CONTENTS
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::clear_pathnames() {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::clear_pathnames() {
|
||||
if ( _pathnames ) {
|
||||
while ( --_tpathnames >= 0 ) {
|
||||
_pathnames[_tpathnames] = strfree(_pathnames[_tpathnames]);
|
||||
@@ -272,7 +272,7 @@ void Fl_Native_File_Chooser_WinAPI_Driver::clear_pathnames() {
|
||||
}
|
||||
|
||||
// SET A SINGLE PATHNAME
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::set_single_pathname(const char *s) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::set_single_pathname(const char *s) {
|
||||
clear_pathnames();
|
||||
_pathnames = new char*[1];
|
||||
_pathnames[0] = strnew(s);
|
||||
@@ -280,7 +280,7 @@ void Fl_Native_File_Chooser_WinAPI_Driver::set_single_pathname(const char *s) {
|
||||
}
|
||||
|
||||
// ADD PATHNAME TO EXISTING ARRAY
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::add_pathname(const char *s) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::add_pathname(const char *s) {
|
||||
if ( ! _pathnames ) {
|
||||
// Create first element in array
|
||||
++_tpathnames;
|
||||
@@ -308,7 +308,7 @@ static void FreePIDL(LPITEMIDLIST pidl) {
|
||||
}
|
||||
|
||||
// CLEAR MICROSOFT OFN (OPEN FILE NAME) CLASS
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::ClearOFN() {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::ClearOFN() {
|
||||
// Free any previously allocated lpstrFile before zeroing out _ofn_ptr
|
||||
if ( _ofn_ptr->lpstrFile ) {
|
||||
delete[] _ofn_ptr->lpstrFile;
|
||||
@@ -326,7 +326,7 @@ void Fl_Native_File_Chooser_WinAPI_Driver::ClearOFN() {
|
||||
}
|
||||
|
||||
// CLEAR MICROSOFT BINF (BROWSER INFO) CLASS
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::ClearBINF() {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::ClearBINF() {
|
||||
if ( _binf_ptr->pidlRoot ) {
|
||||
FreePIDL((ITEMIDLIST*)_binf_ptr->pidlRoot);
|
||||
_binf_ptr->pidlRoot = NULL;
|
||||
@@ -335,19 +335,19 @@ void Fl_Native_File_Chooser_WinAPI_Driver::ClearBINF() {
|
||||
}
|
||||
|
||||
// CONVERT WINDOWS BACKSLASHES TO UNIX FRONTSLASHES
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::Win2Unix(char *s) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::Win2Unix(char *s) {
|
||||
for ( ; *s; s++ )
|
||||
if ( *s == '\\' ) *s = '/';
|
||||
}
|
||||
|
||||
// CONVERT UNIX FRONTSLASHES TO WINDOWS BACKSLASHES
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::Unix2Win(char *s) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::Unix2Win(char *s) {
|
||||
for ( ; *s; s++ )
|
||||
if ( *s == '/' ) *s = '\\';
|
||||
}
|
||||
|
||||
// SHOW FILE BROWSER
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::showfile() {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::showfile() {
|
||||
ClearOFN();
|
||||
clear_pathnames();
|
||||
size_t fsize = FNFC_MAX_PATH;
|
||||
@@ -538,7 +538,7 @@ static int CALLBACK Dir_CB(HWND win, UINT msg, LPARAM param, LPARAM data) {
|
||||
}
|
||||
|
||||
// SHOW DIRECTORY BROWSER
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::showdir() {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::showdir() {
|
||||
// initialize OLE only once
|
||||
fl_open_display(); // init needed by BIF_USENEWUI
|
||||
ClearBINF();
|
||||
@@ -627,7 +627,7 @@ int Fl_Native_File_Chooser_WinAPI_Driver::showdir() {
|
||||
// 1 - user cancelled
|
||||
// -1 - failed; errmsg() has reason
|
||||
//
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::show() {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::show() {
|
||||
int retval;
|
||||
if ( _btype == Fl_Native_File_Chooser::BROWSE_DIRECTORY ||
|
||||
_btype == Fl_Native_File_Chooser::BROWSE_MULTI_DIRECTORY ||
|
||||
@@ -646,31 +646,31 @@ int Fl_Native_File_Chooser_WinAPI_Driver::show() {
|
||||
}
|
||||
|
||||
// RETURN ERROR MESSAGE
|
||||
const char *Fl_Native_File_Chooser_WinAPI_Driver::errmsg() const {
|
||||
const char *Fl_WinAPI_Native_File_Chooser_Driver::errmsg() const {
|
||||
return(_errmsg ? _errmsg : "No error");
|
||||
}
|
||||
|
||||
// GET FILENAME
|
||||
const char* Fl_Native_File_Chooser_WinAPI_Driver::filename() const {
|
||||
const char* Fl_WinAPI_Native_File_Chooser_Driver::filename() const {
|
||||
if ( _pathnames && _tpathnames > 0 ) return(_pathnames[0]);
|
||||
return("");
|
||||
}
|
||||
|
||||
// GET FILENAME FROM LIST OF FILENAMES
|
||||
const char* Fl_Native_File_Chooser_WinAPI_Driver::filename(int i) const {
|
||||
const char* Fl_WinAPI_Native_File_Chooser_Driver::filename(int i) const {
|
||||
if ( _pathnames && i < _tpathnames ) return(_pathnames[i]);
|
||||
return("");
|
||||
}
|
||||
|
||||
// GET TOTAL FILENAMES CHOSEN
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::count() const {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::count() const {
|
||||
return(_tpathnames);
|
||||
}
|
||||
|
||||
// PRESET PATHNAME
|
||||
// Can be NULL if no preset is desired.
|
||||
//
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::directory(const char *val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::directory(const char *val) {
|
||||
_directory = strfree(_directory);
|
||||
_directory = strnew(val);
|
||||
}
|
||||
@@ -678,14 +678,14 @@ void Fl_Native_File_Chooser_WinAPI_Driver::directory(const char *val) {
|
||||
// GET PRESET PATHNAME
|
||||
// Can return NULL if none set.
|
||||
//
|
||||
const char *Fl_Native_File_Chooser_WinAPI_Driver::directory() const {
|
||||
const char *Fl_WinAPI_Native_File_Chooser_Driver::directory() const {
|
||||
return(_directory);
|
||||
}
|
||||
|
||||
// SET TITLE
|
||||
// Can be NULL if no title desired.
|
||||
//
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::title(const char *val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::title(const char *val) {
|
||||
_title = strfree(_title);
|
||||
_title = strnew(val);
|
||||
}
|
||||
@@ -693,14 +693,14 @@ void Fl_Native_File_Chooser_WinAPI_Driver::title(const char *val) {
|
||||
// GET TITLE
|
||||
// Can return NULL if none set.
|
||||
//
|
||||
const char *Fl_Native_File_Chooser_WinAPI_Driver::title() const {
|
||||
const char *Fl_WinAPI_Native_File_Chooser_Driver::title() const {
|
||||
return(_title);
|
||||
}
|
||||
|
||||
// SET FILTER
|
||||
// Can be NULL if no filter needed
|
||||
//
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::filter(const char *val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::filter(const char *val) {
|
||||
_filter = strfree(_filter);
|
||||
clear_filters();
|
||||
if ( val ) {
|
||||
@@ -717,18 +717,18 @@ void Fl_Native_File_Chooser_WinAPI_Driver::filter(const char *val) {
|
||||
// GET FILTER
|
||||
// Can return NULL if none set.
|
||||
//
|
||||
const char *Fl_Native_File_Chooser_WinAPI_Driver::filter() const {
|
||||
const char *Fl_WinAPI_Native_File_Chooser_Driver::filter() const {
|
||||
return(_filter);
|
||||
}
|
||||
|
||||
// CLEAR FILTERS
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::clear_filters() {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::clear_filters() {
|
||||
_nfilters = 0;
|
||||
_parsedfilt = strfree(_parsedfilt);
|
||||
}
|
||||
|
||||
// ADD A FILTER
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::add_filter(const char *name_in, // name of filter (optional: can be null)
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::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];
|
||||
@@ -818,7 +818,7 @@ static int count_filters(const char *filter) {
|
||||
// \_____/ \_______/
|
||||
// Name Wildcard
|
||||
//
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::parse_filter(const char *in) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::parse_filter(const char *in) {
|
||||
clear_filters();
|
||||
if ( ! in ) return;
|
||||
|
||||
@@ -965,27 +965,27 @@ void Fl_Native_File_Chooser_WinAPI_Driver::parse_filter(const char *in) {
|
||||
}
|
||||
|
||||
// SET 'CURRENTLY SELECTED FILTER'
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::filter_value(int i) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::filter_value(int i) {
|
||||
_ofn_ptr->nFilterIndex = i + 1;
|
||||
}
|
||||
|
||||
// RETURN VALUE OF 'CURRENTLY SELECTED FILTER'
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::filter_value() const {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::filter_value() const {
|
||||
return(_ofn_ptr->nFilterIndex ? _ofn_ptr->nFilterIndex-1 : _nfilters+1);
|
||||
}
|
||||
|
||||
// PRESET FILENAME FOR 'SAVE AS' CHOOSER
|
||||
void Fl_Native_File_Chooser_WinAPI_Driver::preset_file(const char* val) {
|
||||
void Fl_WinAPI_Native_File_Chooser_Driver::preset_file(const char* val) {
|
||||
_preset_file = strfree(_preset_file);
|
||||
_preset_file = strnew(val);
|
||||
}
|
||||
|
||||
// GET PRESET FILENAME FOR 'SAVE AS' CHOOSER
|
||||
const char* Fl_Native_File_Chooser_WinAPI_Driver::preset_file() const {
|
||||
const char* Fl_WinAPI_Native_File_Chooser_Driver::preset_file() const {
|
||||
return(_preset_file);
|
||||
}
|
||||
|
||||
int Fl_Native_File_Chooser_WinAPI_Driver::filters() const {
|
||||
int Fl_WinAPI_Native_File_Chooser_Driver::filters() const {
|
||||
return(_nfilters);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user