summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/Fl_Message.cxx17
-rw-r--r--src/Fl_Message.h4
-rw-r--r--src/fl_ask.cxx24
3 files changed, 44 insertions, 1 deletions
diff --git a/src/Fl_Message.cxx b/src/Fl_Message.cxx
index 1b93ecad3..0aa7ed587 100644
--- a/src/Fl_Message.cxx
+++ b/src/Fl_Message.cxx
@@ -65,6 +65,8 @@
const char *Fl_Message::message_title_default_;
const char *Fl_Message::message_title_;
+const char *Fl_Message::message_icon_label_;
+
Fl_Box *Fl_Message::message_icon_;
char *Fl_Message::input_buffer_;
@@ -123,6 +125,9 @@ void Fl_Message::window_cb_(Fl_Widget *w, void *d) {
The constructor creates a default message window and sets the icon type
to the given \p iconlabel which can be any character (or string).
+ If fl_message_icon_label() has been called before this label is used
+ instead and reset to NULL after the message window has been created.
+
Message text box (Fl_Box), icon (Fl_Box), and an input (Fl_Input) widgets
are created and initialized. Three buttons are created and arranged right to
left in the message window. The second (middle) button is an Fl_Return_Button.
@@ -157,7 +162,13 @@ Fl_Message::Fl_Message(const char *iconlabel)
icon_->labelsize(icon_template->labelsize());
icon_->color(icon_template->color());
icon_->labelcolor(icon_template->labelcolor());
- icon_->label(iconlabel);
+
+ if (message_icon_label_) { // fl_message_icon_label() has been called
+ icon_->copy_label(message_icon_label_);
+ message_icon_label_ = 0;
+ } else { // use default (static, per message default string)
+ icon_->label(iconlabel);
+ }
window_->end(); // don't add the buttons automatically
@@ -526,6 +537,10 @@ void Fl_Message::message_title_default(const char *title) {
message_title_default_ = strdup(title);
}
+void Fl_Message::icon_label(const char *str) {
+ message_icon_label_ = str;
+}
+
/**
\}
\endcond
diff --git a/src/Fl_Message.h b/src/Fl_Message.h
index 83dfad1df..7e6cfd623 100644
--- a/src/Fl_Message.h
+++ b/src/Fl_Message.h
@@ -65,6 +65,9 @@ private:
static const char *message_title_;
static const char *message_title_default_;
+ // icon label for next dialog (STR #2762)
+ static const char *message_icon_label_;
+
// Note: since Fl_Message objects are destroyed before fl_input()
// and fl_password() return their input text, we *need* to store
// the text in an internal (static) buffer. :-(
@@ -89,6 +92,7 @@ public:
static Fl_Box *message_icon();
static void message_title(const char *title);
static void message_title_default(const char *title);
+ static void icon_label(const char *str);
/** Implements fl_message_position(const int, const int y, const int center). */
static void message_position(const int x, const int y, const int center) {
diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx
index a4e44ffc3..95031753e 100644
--- a/src/fl_ask.cxx
+++ b/src/fl_ask.cxx
@@ -560,4 +560,28 @@ void fl_message_title_default(const char *title) {
Fl_Message::message_title_default(title);
}
+/** Sets the icon label of the dialog window used in many common dialogs.
+
+ This icon label will be used in the next call of one of the
+ common dialogs like fl_message(), fl_alert(), fl_ask(), fl_choice(),
+ fl_input(), fl_password().
+
+ The label \p str is stored internally as a reference, it must be
+ in scope until the dialog function (e.g. fl_choice) is called.
+
+ It applies only to the \b next call of one of the common dialogs and
+ will be reset after that call so the next dialog will use its default
+ label unless set again.
+
+ \note This label string must be short, usually only one character so
+ it fits in the icon box. You can use any valid UTF-8 character, e.g.
+ the Euro sign ("€") which is three bytes in UTF-8 encoding.
+
+ \code #include <FL/fl_ask.H> \endcode
+ \param[in] str icon label
+*/
+void fl_message_icon_label(const char *str) {
+ Fl_Message::icon_label(str);
+}
+
/** @} */