summaryrefslogtreecommitdiff
path: root/src/fl_ask.cxx
diff options
context:
space:
mode:
authorAlbrecht Schlosser <albrechts.fltk@online.de>2011-02-18 08:52:48 +0000
committerAlbrecht Schlosser <albrechts.fltk@online.de>2011-02-18 08:52:48 +0000
commit2c129b4833f45157fde8f90451240d4c00bbc96d (patch)
tree8c7889e8725a6844ea93359ee1635d66fd7617fe /src/fl_ask.cxx
parentdea2763983c764fcbf84b83392ba48a5092f775c (diff)
Added a default window title function for common dialogs (STR #2562).
git-svn-id: file:///fltk/svn/fltk/branches/branch-1.3@8441 ea41ed52-d2ee-0310-a9c1-e6b18d33e121
Diffstat (limited to 'src/fl_ask.cxx')
-rw-r--r--src/fl_ask.cxx32
1 files changed, 31 insertions, 1 deletions
diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx
index 133eac2be..444dabec6 100644
--- a/src/fl_ask.cxx
+++ b/src/fl_ask.cxx
@@ -54,6 +54,7 @@ static Fl_Button *button[3];
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 @@ static Fl_Window *makeform() {
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 @@ static int innards(const char* fmt, va_list ap,
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 @@ void fl_message_title(const char *title) {
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);
+}
+
/** @} */
//