Author: AlbrechtS
Date: 2011-02-18 00:52:48 -0800 (Fri, 18 Feb 2011)
New Revision: 8441
Log:
Added a default window title function for common dialogs (STR #2562).
Modified:
branches/branch-1.3/FL/fl_ask.H
branches/branch-1.3/src/fl_ask.cxx
branches/branch-1.3/test/ask.cxx
Modified: branches/branch-1.3/FL/fl_ask.H
===================================================================
--- branches/branch-1.3/FL/fl_ask.H 2011-02-17 14:29:44 UTC (rev 8440)
+++ branches/branch-1.3/FL/fl_ask.H 2011-02-18 08:52:48 UTC (rev 8441)
@@ -68,6 +68,7 @@
FL_EXPORT int fl_message_hotspot(void);
FL_EXPORT void fl_message_title(const char *title);
+FL_EXPORT void fl_message_title_default(const char *title);
// pointers you can use to change FLTK to a foreign language:
extern FL_EXPORT const char* fl_no;
Modified: branches/branch-1.3/src/fl_ask.cxx
===================================================================
--- branches/branch-1.3/src/fl_ask.cxx 2011-02-17 14:29:44 UTC (rev 8440)
+++ branches/branch-1.3/src/fl_ask.cxx 2011-02-18 08:52:48 UTC (rev 8441)
@@ -54,6 +54,7 @@
static Fl_Input *input;
static int ret_val;
static const char *iconlabel = "?";
+static const char *message_title_default;
Fl_Font fl_message_font_ = FL_HELVETICA;
Fl_Fontsize fl_message_size_ = -1;
static int enableHotspot = 1;
@@ -84,7 +85,7 @@
Fl_Group *previously_current_group = Fl_Group::current();
Fl_Group::current(0);
// create a new top level window
- Fl_Window *w = message_form = new Fl_Window(410,103,"");
+ Fl_Window *w = message_form = new Fl_Window(410,103);
message_form->callback(button_cb,(void *)0);
// w->clear_border();
// w->box(FL_UP_BOX);
@@ -236,6 +237,10 @@
else
button[0]->shortcut(FL_Escape);
+ // set default window title, if defined and a specific title is not set
+ if (!message_form->label() && message_title_default)
+ message_form->label(message_title_default);
+
// deactivate Fl::grab(), because it is incompatible with modal windows
Fl_Window* g = Fl::grab();
if (g) Fl::grab(0);
@@ -529,6 +534,31 @@
message_form->copy_label(title);
}
+/** Sets the default title of the dialog window used in many common dialogs.
+
+ This window \p title will be used in all subsequent calls of one of the
+ common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(),
+ fl_input(), fl_password(), unless a specific title has been set
+ with fl_message_title(const char *title).
+
+ The default is no title. You can override the default title for a
+ single dialog with fl_message_title(const char *title).
+
+ The \p title string is copied internally, so that you can use a
+ local variable or free the string immediately after this call.
+
+ \note \#include <FL/fl_ask.H>
+ \param[in] title default window label, string copied internally
+*/
+void fl_message_title_default(const char *title) {
+ if (message_title_default) {
+ free ((void *)message_title_default);
+ message_title_default = 0;
+ }
+ if (title)
+ message_title_default = strdup(title);
+}
+
/** @} */
//
Modified: branches/branch-1.3/test/ask.cxx
===================================================================
--- branches/branch-1.3/test/ask.cxx 2011-02-17 14:29:44 UTC (rev 8440)
+++ branches/branch-1.3/test/ask.cxx 2011-02-18 08:52:48 UTC (rev 8441)
@@ -91,6 +91,9 @@
// Also we test to see if the exit callback works:
window.callback(window_callback);
+// set default message window title
+ // fl_message_title_default("Default Window Title");
+
return Fl::run();
}
_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit