diff options
| author | Albrecht Schlosser <albrechts.fltk@online.de> | 2011-02-18 08:52:48 +0000 |
|---|---|---|
| committer | Albrecht Schlosser <albrechts.fltk@online.de> | 2011-02-18 08:52:48 +0000 |
| commit | 2c129b4833f45157fde8f90451240d4c00bbc96d (patch) | |
| tree | 8c7889e8725a6844ea93359ee1635d66fd7617fe | |
| parent | dea2763983c764fcbf84b83392ba48a5092f775c (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
| -rw-r--r-- | FL/fl_ask.H | 1 | ||||
| -rw-r--r-- | src/fl_ask.cxx | 32 | ||||
| -rw-r--r-- | test/ask.cxx | 3 |
3 files changed, 35 insertions, 1 deletions
diff --git a/FL/fl_ask.H b/FL/fl_ask.H index 553419334..77eae3be5 100644 --- a/FL/fl_ask.H +++ b/FL/fl_ask.H @@ -68,6 +68,7 @@ FL_EXPORT void fl_message_hotspot(int enable); 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; 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); +} + /** @} */ // diff --git a/test/ask.cxx b/test/ask.cxx index 29def0df3..d5d71a44f 100644 --- a/test/ask.cxx +++ b/test/ask.cxx @@ -91,6 +91,9 @@ int main(int argc, char **argv) { // 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(); } |
