diff options
| -rw-r--r-- | CHANGES | 10 | ||||
| -rw-r--r-- | FL/Fl_File_Chooser.H | 1 | ||||
| -rw-r--r-- | FL/fl_ask.H | 31 | ||||
| -rw-r--r-- | documentation/functions.html | 28 | ||||
| -rw-r--r-- | src/Fl_File_Chooser.fl | 5 | ||||
| -rw-r--r-- | src/Fl_File_Chooser2.cxx | 42 | ||||
| -rw-r--r-- | src/fl_ask.cxx | 8 | ||||
| -rw-r--r-- | src/fl_file_dir.cxx | 14 |
8 files changed, 120 insertions, 19 deletions
@@ -2,6 +2,16 @@ CHANGES IN FLTK 1.1.7 - Documentation fixes (STR #648, STR #692, STR #730, STR #744, STR #745) + - Pressing Enter in the file chooser when selecting a + directory will choose that directory if it is currently + shown (STR #746) + - Added a fl_file_chooser_ok_label() function to set the + "OK" button label for the fl_file_chooser() and + fl_dir_chooser() functions. + - Added Fl_File_Chooser::ok_label() methods to set the + "OK" button label. + - The fl_ask() function is now deprecated since it does + not conform to the FLTK Human Interface Guidelines. - The Fl_File_Chooser window now properly resizes its controls (STR #766) - The Fl_Help_Dialog window now properly resizes its diff --git a/FL/Fl_File_Chooser.H b/FL/Fl_File_Chooser.H index bc55fb561..6bc050b32 100644 --- a/FL/Fl_File_Chooser.H +++ b/FL/Fl_File_Chooser.H @@ -176,6 +176,7 @@ public: FL_EXPORT char *fl_dir_chooser(const char *message,const char *fname,int relative=0); FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const char *fname,int relative=0); FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*)); +FL_EXPORT void fl_file_chooser_ok_label(const char*l); #endif // diff --git a/FL/fl_ask.H b/FL/fl_ask.H index 5ac067511..c0a134865 100644 --- a/FL/fl_ask.H +++ b/FL/fl_ask.H @@ -20,13 +20,15 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php // #ifndef fl_ask_H -#define fl_ask_H +# define fl_ask_H -#include "Enumerations.H" +# include "Enumerations.H" class Fl_Widget; @@ -39,13 +41,22 @@ enum { FL_BEEP_NOTIFICATION }; +# ifdef __GNUC__ +# define __fl_attr(x) __attribute__ (x) +# else +# define __fl_attr(x) +# endif // __GNUC__ + FL_EXPORT void fl_beep(int type = FL_BEEP_DEFAULT); -FL_EXPORT void fl_message(const char *,...); -FL_EXPORT void fl_alert(const char *,...); -FL_EXPORT int fl_ask(const char *,...); -FL_EXPORT int fl_choice(const char *q,const char *b0,const char *b1,const char *b2,...); -FL_EXPORT const char *fl_input(const char *label, const char *deflt = 0, ...); -FL_EXPORT const char *fl_password(const char *label, const char *deflt = 0, ...); +FL_EXPORT void fl_message(const char *,...) __fl_attr((__format__ (__printf__, 1, 2))); +FL_EXPORT void fl_alert(const char *,...) __fl_attr((__format__ (__printf__, 1, 2))); +// fl_ask() is deprecated since it uses "Yes" and "No" for the buttons, +// which does not conform to the current FLTK Human Interface Guidelines. +// Use fl_choice() instead with the appropriate verbs instead. +FL_EXPORT int fl_ask(const char *,...) __fl_attr((__format__ (__printf__, 1, 2), __deprecated__)); +FL_EXPORT int fl_choice(const char *q,const char *b0,const char *b1,const char *b2,...) __fl_attr((__format__ (__printf__, 1, 5))); +FL_EXPORT const char *fl_input(const char *label, const char *deflt = 0, ...) __fl_attr((__format__ (__printf__, 1, 3))); +FL_EXPORT const char *fl_password(const char *label, const char *deflt = 0, ...) __fl_attr((__format__ (__printf__, 1, 3))); FL_EXPORT Fl_Widget *fl_message_icon(); extern FL_EXPORT Fl_Font fl_message_font_; @@ -60,7 +71,7 @@ extern FL_EXPORT const char* fl_ok; extern FL_EXPORT const char* fl_cancel; extern FL_EXPORT const char* fl_close; -#endif +#endif // !fl_ask_H // // End of "$Id$". diff --git a/documentation/functions.html b/documentation/functions.html index 74d1e2409..5bcd54d4e 100644 --- a/documentation/functions.html +++ b/documentation/functions.html @@ -24,6 +24,7 @@ A</A>. <LI><A HREF="#fl_dir_chooser"><TT>fl_dir_chooser</TT></A></LI> <LI><A HREF="#fl_file_chooser2"><TT>fl_file_chooser</TT></A></LI> <LI><A HREF="#fl_file_chooser_callback"><TT>fl_file_chooser_callback</TT></A></LI> + <LI><A HREF="#fl_file_chooser_ok_label"><TT>fl_file_chooser_ok_label</TT></A></LI> <LI><A HREF="#fl_filename_absolute"><TT>fl_filename_absolute</TT></A></LI> <LI><A HREF="#fl_filename_expand"><TT>fl_filename_expand</TT></A></LI> <LI><A HREF="#fl_filename_ext"><TT>fl_filename_ext</TT></A></LI> @@ -60,6 +61,7 @@ A</A>. <LI><A HREF="#fl_dir_chooser"><TT>fl_dir_chooser</TT></A></LI> <LI><A HREF="#fl_file_chooser2"><TT>fl_file_chooser</TT></A></LI> <LI><A HREF="#fl_file_chooser_callback"><TT>fl_file_chooser_callback</TT></A></LI> + <LI><A HREF="#fl_file_chooser_ok_label"><TT>fl_file_chooser_ok_label</TT></A></LI> <LI><A HREF="#fl_input2"><TT>fl_input</TT></A></LI> <LI><A HREF="#fl_message"><TT>fl_message</TT></A></LI> <LI><A HREF="#fl_message_font"><TT>fl_message_font</TT></A></LI> @@ -158,7 +160,7 @@ a shortcut for No. <P ALIGN="CENTER"><IMG SRC="fl_ask.gif" ALT="The fl_ask window."> <p><b>Note:</b> Use of this function is <i>strongly</i> -discouraged. Instead, use <a +discouraged, and it will be removed in FLTK 2.0. Instead, use <a href='#fl_choice'><tt>fl_choice()</tt></a> instead and provide unambiguous verbs in place of "Yes" and "No".</p> @@ -540,6 +542,30 @@ fast, and cannot create FLTK windows. <!-- NEED 4in --> +<H2><A NAME="fl_file_chooser_ok_label">fl_file_chooser_ok_label</A></H2> + +<HR> + +<H3>Include Files</H3> + +<UL><PRE> +#include <FL/Fl_File_Chooser.H> +</PRE></UL> + +<H3>Prototype</H3> + +<UL><PRE> +void fl_file_chooser_ok_label(const char *l); +</PRE></UL> + +<H3>Description</H3> + +<P>Sets the label that is shown on the "OK" button in the file +chooser. The default label (<tt>fl_ok</tt>) can be restored by +passing a <tt>NULL</tt> pointer for the label string.</p> + + +<!-- NEED 4in --> <H2><A NAME="fl_filename_absolute">fl_filename_absolute</A></H2> <HR> diff --git a/src/Fl_File_Chooser.fl b/src/Fl_File_Chooser.fl index 656b5e987..cccbbd3e4 100644 --- a/src/Fl_File_Chooser.fl +++ b/src/Fl_File_Chooser.fl @@ -150,7 +150,7 @@ window->hide();} private xywh {408 345 72 25} code0 {o->label(fl_cancel);} } - Fl_Box {} {selected + Fl_Box {} { private xywh {10 345 30 25} resizable } } @@ -399,6 +399,9 @@ decl {FL_EXPORT char *fl_file_chooser(const char *message,const char *pat,const decl {FL_EXPORT void fl_file_chooser_callback(void (*cb)(const char*));} {public } +decl {FL_EXPORT void fl_file_chooser_ok_label(const char*l);} {selected public +} + comment { // // End of "$Id$". diff --git a/src/Fl_File_Chooser2.cxx b/src/Fl_File_Chooser2.cxx index 196d0eee3..6590395ec 100644 --- a/src/Fl_File_Chooser2.cxx +++ b/src/Fl_File_Chooser2.cxx @@ -20,7 +20,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php // // Contents: // @@ -35,6 +37,7 @@ // in the Fl_File_Browser. // Fl_File_Chooser::fileNameCB() - Handle text entry in the FileBrowser. // Fl_File_Chooser::showChoiceCB() - Handle show selections. +// compare_dirnames() - Compare two directory names. // quote_pathname() - Quote a pathname for a menu. // unquote_pathname() - Unquote a pathname from a menu. // @@ -100,6 +103,7 @@ Fl_File_Sort_F *Fl_File_Chooser::sort = fl_numericsort; // Local functions... // +static int compare_dirnames(const char *a, const char *b); static void quote_pathname(char *, const char *, int); static void unquote_pathname(char *, const char *, int); @@ -499,9 +503,11 @@ Fl_File_Chooser::fileNameCB() // Enter pressed - select or change directory... #if (defined(WIN32) && ! defined(__CYGWIN__)) || defined(__EMX__) if ((isalpha(pathname[0] & 255) && pathname[1] == ':' && !pathname[2]) || - fl_filename_isdir(pathname)) { + fl_filename_isdir(pathname) && + compare_dirnames(pathname, directory_)) { #else - if (fl_filename_isdir(pathname)) { + if (fl_filename_isdir(pathname) && + compare_dirnames(pathname, directory_)) { #endif /* WIN32 || __EMX__ */ directory(pathname); } else if ((type_ & CREATE) || access(pathname, 0) == 0) { @@ -1121,6 +1127,36 @@ Fl_File_Chooser::value(const char *filename) // I - Filename + directory // +// 'compare_dirnames()' - Compare two directory names. +// + +static int +compare_dirnames(const char *a, const char *b) { + int alen, blen; + + // Get length of each string... + alen = strlen(a) - 1; + blen = strlen(b) - 1; + + if (alen < 0 || blen < 0) return alen - blen; + + // Check for trailing slashes... + if (a[alen] != '/') alen ++; + if (b[blen] != '/') blen ++; + + // If the lengths aren't the same, then return the difference... + if (alen != blen) return alen - blen; + + // Do a comparison of the first N chars (alen == blen at this point)... +#ifdef WIN32 + return strnicmp(a, b, alen); +#else + return strncmp(a, b, alen); +#endif // WIN32 +} + + +// // 'quote_pathname()' - Quote a pathname for a menu. // diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx index 016b52495..454ecff77 100644 --- a/src/fl_ask.cxx +++ b/src/fl_ask.cxx @@ -20,7 +20,9 @@ // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 // USA. // -// Please report all bugs and problems to "fltk-bugs@fltk.org". +// Please report all bugs and problems on the following page: +// +// http://www.fltk.org/str.php // // Implementation of fl_message, fl_ask, fl_choice, fl_input @@ -273,7 +275,7 @@ void fl_message(const char *fmt, ...) { va_start(ap, fmt); iconlabel = "i"; - innards(fmt, ap, 0, fl_ok, 0); + innards(fmt, ap, 0, fl_close, 0); va_end(ap); iconlabel = "?"; } @@ -285,7 +287,7 @@ void fl_alert(const char *fmt, ...) { va_start(ap, fmt); iconlabel = "!"; - innards(fmt, ap, 0, fl_ok, 0); + innards(fmt, ap, 0, fl_close, 0); va_end(ap); iconlabel = "?"; } diff --git a/src/fl_file_dir.cxx b/src/fl_file_dir.cxx index 432a7f83e..401008e10 100644 --- a/src/fl_file_dir.cxx +++ b/src/fl_file_dir.cxx @@ -26,23 +26,34 @@ #include "flstring.h" #include <FL/filename.H> #include <FL/Fl_File_Chooser.H> -#include <FL/Fl_File_Chooser.H> +#include <FL/fl_ask.H> + static Fl_File_Chooser *fc = (Fl_File_Chooser *)0; static void (*current_callback)(const char*) = 0; +static const char *current_label = fl_ok; +// Do a file chooser callback... static void callback(Fl_File_Chooser *, void*) { if (current_callback && fc->value()) (*current_callback)(fc->value()); } +// Set the file chooser callback void fl_file_chooser_callback(void (*cb)(const char*)) { current_callback = cb; } +// Set the "OK" button label +void fl_file_chooser_ok_label(const char *l) { + if (l) current_label = l; + else current_label = fl_ok; +} + + // // 'fl_file_chooser()' - Show a file chooser dialog and get a filename. // @@ -89,6 +100,7 @@ fl_file_chooser(const char *message, // I - Message in titlebar fc->value(fname); } + fc->ok_label(current_label); fc->show(); while (fc->shown()) |
