Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023 #ifdef HAVE_CONFIG_H
00024 #include <config.h>
00025 #endif
00026
00027 #if defined (HAVE_FLTK)
00028
00029 #ifdef WIN32
00030 #define WIN32_LEAN_AND_MEAN
00031 #endif
00032
00033 #include <FL/Fl.H>
00034 #include <FL/Fl_File_Chooser.H>
00035
00036
00037
00038
00039
00040 #undef Complex
00041
00042 #include "defun-dld.h"
00043 #include "file-ops.h"
00044
00045 DEFUN_DLD (__fltk_uigetfile__, args, ,
00046 "-*- texinfo -*-\n\
00047 @deftypefn {Built-in Function} {} __fltk_uigetfile__ (@dots{})\n\
00048 Undocumented internal function.\n\
00049 @end deftypefn")
00050 {
00051
00052
00053
00054
00055
00056
00057
00058
00059 octave_value_list retval (3, octave_value (0));
00060
00061 std::string file_filter = args(0).string_value();
00062 std::string title = args(1).string_value();
00063 std::string default_name = args(2).string_value();
00064 Matrix pos = args(3).matrix_value();
00065
00066 int multi_type = Fl_File_Chooser::SINGLE;
00067 std::string flabel = "Filename:";
00068
00069 std::string multi = args(4).string_value();
00070 if (multi == "on")
00071 multi_type = Fl_File_Chooser::MULTI;
00072 else if (multi == "dir")
00073 {
00074 multi_type = Fl_File_Chooser::DIRECTORY;
00075 flabel = "Directory:";
00076 }
00077 else if (multi == "create")
00078 multi_type = Fl_File_Chooser::CREATE;
00079
00080 Fl_File_Chooser::filename_label = flabel.c_str ();
00081
00082 Fl_File_Chooser fc (default_name.c_str (), file_filter.c_str (),
00083 multi_type, title.c_str ());
00084
00085 fc.preview (0);
00086
00087 if (multi_type == Fl_File_Chooser::CREATE)
00088 fc.ok_label ("Save");
00089
00090 fc.show ();
00091
00092 while (fc.shown ())
00093 Fl::wait ();
00094
00095 if (fc.value())
00096 {
00097 int file_count = fc.count ();
00098 std::string fname;
00099
00100
00101 std::string sep = "/";
00102 std::size_t idx;
00103
00104 if (file_count == 1 && multi_type != Fl_File_Chooser::DIRECTORY)
00105 {
00106 fname = fc.value ();
00107 idx = fname.find_last_of (sep);
00108 retval(0) = fname.substr (idx + 1);
00109 }
00110 else
00111 {
00112 Cell file_cell = Cell(file_count, 1);
00113 for (octave_idx_type n = 1; n <= file_count; n++)
00114 {
00115 fname = fc.value (n);
00116 idx = fname.find_last_of (sep);
00117 file_cell(n - 1) = fname.substr (idx + 1);
00118 }
00119 retval(0) = file_cell;
00120 }
00121
00122 if (multi_type == Fl_File_Chooser::DIRECTORY)
00123 retval(0) = std::string (fc.value ());
00124 else
00125 {
00126 retval(1) = std::string (fc.directory ()) + sep;
00127 retval(2) = fc.filter_value () + 1;
00128 }
00129 }
00130
00131 fc.hide ();
00132 Fl::flush ();
00133
00134 return retval;
00135 }
00136
00137
00138
00139
00140
00141
00142
00143
00144 #endif