summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorGreg Ercolano <erco@seriss.com>2010-01-13 23:13:59 +0000
committerGreg Ercolano <erco@seriss.com>2010-01-13 23:13:59 +0000
commit1de0988c317c7b916daa7b4f102f0889e026c77d (patch)
treee479de5817a0d0388e1f4c1a62db018ea9f2981f /test
parent139c88c618ae6a186c59bde73e05ea93caa3e297 (diff)
Added Fl_Native_File_Chooser widget (with manolo's cocoa mods) to FLTK.
* Source brought into CMP standards compliance * test program added (test/native-filechooser.cxx) * Tested with linux (Ubuntu8) and with OSX (cocoa and non-cocoa builds) TODO: * Needs doxygen docs from Greg's original HTML documentation * Needs mods to Windows build files * Needs mods to cmake, and other build files * Needs Manolo's latest mods (from STR #2298) mentioned on and after "02:05 Jan 13, 2010" git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@6997 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'test')
-rw-r--r--test/Makefile4
-rw-r--r--test/makefile.wat3
-rw-r--r--test/native-filechooser.cxx83
3 files changed, 90 insertions, 0 deletions
diff --git a/test/Makefile b/test/Makefile
index 1f8b91aad..6479e2c61 100644
--- a/test/Makefile
+++ b/test/Makefile
@@ -74,6 +74,7 @@ CPPFILES =\
menubar.cxx \
message.cxx \
minimum.cxx \
+ native-filechooser.cxx \
navigation.cxx \
output.cxx \
overlay.cxx \
@@ -139,6 +140,7 @@ ALL = \
menubar$(EXEEXT) \
message$(EXEEXT) \
minimum$(EXEEXT) \
+ native-filechooser$(EXEEXT) \
navigation$(EXEEXT) \
output$(EXEEXT) \
overlay$(EXEEXT) \
@@ -377,6 +379,8 @@ message$(EXEEXT): message.o
minimum$(EXEEXT): minimum.o
+native-filechooser$(EXEEXT): native-filechooser.o
+
navigation$(EXEEXT): navigation.o
output$(EXEEXT): output.o $(FLLIBNAME)
diff --git a/test/makefile.wat b/test/makefile.wat
index c1e83b9c2..44d3d4821 100644
--- a/test/makefile.wat
+++ b/test/makefile.wat
@@ -62,6 +62,7 @@ ALL = &
$(ODIR)/menubar$(EXEEXT) &
$(ODIR)/message$(EXEEXT) &
$(ODIR)/minimum$(EXEEXT) &
+ $(ODIR)/native-filechooser$(EXEEXT) &
$(ODIR)/navigation$(EXEEXT) &
$(ODIR)/output$(EXEEXT) &
$(ODIR)/overlay$(EXEEXT) &
@@ -179,6 +180,8 @@ $(ODIR)/message$(EXEEXT) : $(ODIR)/message.obj
$(ODIR)/minimum$(EXEEXT) : $(ODIR)/minimum.obj
+$(ODIR)/native-filechooser$(EXEEXT) : $(ODIR)/native-filechooser.obj
+
$(ODIR)/navigation$(EXEEXT) : $(ODIR)/navigation.obj
$(ODIR)/output$(EXEEXT) : $(ODIR)/output.obj
diff --git a/test/native-filechooser.cxx b/test/native-filechooser.cxx
new file mode 100644
index 000000000..e4655e6e6
--- /dev/null
+++ b/test/native-filechooser.cxx
@@ -0,0 +1,83 @@
+//
+// "$Id$"
+//
+// Simple test of the Fl_Native_File_Chooser.
+//
+// Copyright 1998-2009 by Bill Spitzak and others.
+// Copyright 2004 Greg Ercolano.
+//
+// This library is free software; you can redistribute it and/or
+// modify it under the terms of the GNU Library General Public
+// License as published by the Free Software Foundation; either
+// version 2 of the License, or (at your option) any later version.
+//
+// This library is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+// Library General Public License for more details.
+//
+// You should have received a copy of the GNU Library General Public
+// License along with this library; if not, write to the Free Software
+// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
+// USA.
+//
+// Please report all bugs and problems on the following page:
+//
+// http://www.fltk.org/str.php
+//
+#include <stdio.h>
+#include <FL/Fl.H>
+#include <FL/fl_ask.H> // fl_beep()
+#include <FL/Fl_Window.H>
+#include <FL/Fl_Button.H>
+#include <FL/Fl_Input.H>
+#include <FL/Fl_Native_File_Chooser.H>
+
+// GLOBALS
+Fl_Input *G_filename = NULL;
+
+void Butt_CB(Fl_Widget*, void*) {
+ // Create native chooser
+ Fl_Native_File_Chooser native;
+ native.title("Pick a file");
+ native.type(Fl_Native_File_Chooser::BROWSE_FILE);
+ native.filter("Text\t*.txt\n"
+ "C Files\t*.{cxx,h,c}\n"
+ "Apps\t*.{app}\n"); // TODO: need to add kNavSupportPackages to non-cocoa <FNFC>_MAC.cxx
+ native.preset_file(G_filename->value());
+ // Show native chooser
+ switch ( native.show() ) {
+ case -1: fprintf(stderr, "ERROR: %s\n", native.errmsg()); break; // ERROR
+ case 1: fprintf(stderr, "*** CANCEL\n"); fl_beep(); break; // CANCEL
+ default: // PICKED FILE
+ if ( native.filename() ) {
+ G_filename->value(native.filename());
+ } else {
+ G_filename->value("NULL");
+ }
+ break;
+ }
+}
+
+int main(int argc, char **argv) {
+ //// For a nicer looking browser under linux, uncomment the following line.
+ //// (If you do this, you'll need to link with fltk_images)
+ ////
+ //// Fl_File_Icon::load_system_icons();
+
+ Fl_Window *win = new Fl_Window(600, 100, "FLTK Window");
+ win->begin();
+ {
+ int y = 10;
+ G_filename = new Fl_Input(80, y, win->w()-80-10, 25, "Filename");
+ G_filename->value(argc < 2 ? "." : argv[1]);
+ G_filename->tooltip("Default filename");
+ y += G_filename->h() + 5;
+ Fl_Button *but = new Fl_Button(win->w()-80-10, win->h()-25-10, 80, 25, "Pick File");
+ but->callback(Butt_CB);
+ }
+ win->end();
+ win->resizable(win);
+ win->show();
+ return(Fl::run());
+}