--- ../../fl_ask.cxx	Thu Jan 30 15:43:26 2003
+++ fl_ask.cxx	Mon Apr  5 16:03:13 2004
@@ -45,32 +45,57 @@
 #include <FL/x.H>
 #include <FL/fl_draw.H>
 
-static Fl_Window *message_form;
-static Fl_Box *message;
-static Fl_Box *icon;
-static Fl_Button *button[3];
-static Fl_Input *input;
-static const char *iconlabel = "?";
+
+// pointers you can use to change FLTK to a foreign language:
+const char* fl_no = "No";
+const char* fl_yes= "Yes";
+const char* fl_ok = "OK";
+const char* fl_cancel= "Cancel";
+const char* fl_close= "Close";
+
+
+// other configurable
+static const char *iconlabel_ = "?";
 Fl_Font fl_message_font_ = FL_HELVETICA;
 uchar fl_message_size_ = 14;
 
-static Fl_Window *makeform() {
- if (message_form) {
-   message_form->size(410,103);
-   return message_form;
- }
- Fl_Window *w = message_form = new Fl_Window(410,103,"");
- // w->clear_border();
- // w->box(FL_UP_BOX);
+
+// private
+static Fl_Box *icon_default;
+
+
+class Fl_Message {
+public:
+// public var
+    Fl_Window *message_form;
+    Fl_Box *message;
+    Fl_Box *icon;
+    Fl_Button *button[3];
+    Fl_Input *input;
+// public methods
+    Fl_Message(const char *iconlabel = iconlabel_);
+    ~Fl_Message() { delete message_form; }
+    void resizeform();
+    int innards(const char* fmt, va_list ap, const char *b0, const char *b1, const char *b2);
+    const char* input_innards(const char* fmt, va_list ap, const char* defstr, uchar type);
+};
+
+
+Fl_Message::Fl_Message(const char *iconlabel) {
+ Fl_Widget *icon_template = fl_message_icon();
+ message_form = new Fl_Window(410,103,"");
+ // message_form->clear_border();
+ // message_form->box(FL_UP_BOX);
  (message = new Fl_Box(60, 25, 340, 20))
    ->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
  (input = new Fl_Input(60, 37, 340, 23))->hide();
  {Fl_Box* o = icon = new Fl_Box(10, 10, 50, 50);
-  o->box(FL_THIN_UP_BOX);
-  o->labelfont(FL_TIMES_BOLD);
-  o->labelsize(34);
-  o->color(FL_WHITE);
-  o->labelcolor(FL_BLUE);
+  o->box(icon_template->box());
+  o->labelfont(icon_template->labelfont());
+  o->labelsize(icon_template->labelsize());
+  o->color(icon_template->color());
+  o->labelcolor(icon_template->labelcolor());
+  o->label(iconlabel);
  }
  button[0] = new Fl_Button(310, 70, 90, 23);
  button[0]->shortcut("^[");
@@ -79,18 +104,18 @@
  button[1]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
  button[2] = new Fl_Button(110, 70, 90, 23);
  button[2]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
- w->resizable(new Fl_Box(60,10,110-60,27));
- w->end();
- w->set_modal();
- return w;
+ message_form->resizable(new Fl_Box(60,10,110-60,27));
+ message_form->end();
+ message_form->set_modal();
 }
 
+
 /*
  * 'resizeform()' - Resize the form and widgets so that they hold everything
  *                  that is asked of them...
  */
 
-void resizeform() {
+void Fl_Message::resizeform() {
   int	i;
   int	message_w, message_h;
   int	icon_size;
@@ -162,12 +187,12 @@
     }
 }
 
-static int innards(const char* fmt, va_list ap,
+
+int Fl_Message::innards(const char* fmt, va_list ap,
   const char *b0,
   const char *b1,
   const char *b2)
 {
-  makeform();
   char buffer[1024];
   if (!strcmp(fmt,"%s")) {
     message->label(va_arg(ap, const char*));
@@ -185,8 +210,6 @@
   else button[1]->hide();
   if (b2) {button[2]->show(); button[2]->label(b2);}
   else button[2]->hide();
-  const char* prev_icon_label = icon->label();
-  if (!prev_icon_label) icon->label(iconlabel);
 
   resizeform();
 
@@ -202,16 +225,23 @@
     else if (o == message_form) {r = 0; break;}
   }
   message_form->hide();
-  icon->label(prev_icon_label);
   return r;
 }
 
-// pointers you can use to change FLTK to a foreign language:
-const char* fl_no = "No";
-const char* fl_yes= "Yes";
-const char* fl_ok = "OK";
-const char* fl_cancel= "Cancel";
-const char* fl_close= "Close";
+
+const char* Fl_Message::input_innards(const char* fmt, va_list ap,
+				 const char* defstr, uchar type) {
+  message->position(60,10);
+  input->type(type);
+  input->show();
+  input->value(defstr);
+
+  int r = innards(fmt, ap, fl_cancel, fl_ok, 0);
+  input->hide();
+  message->position(60,25);
+  return r ? input->value() : 0;
+}
+
 
 // fltk functions:
 void fl_beep(int type) {
@@ -260,88 +290,98 @@
 #endif // WIN32
 }
 
+
 void fl_message(const char *fmt, ...) {
+  Fl_Message msg("i");
   va_list ap;
 
   fl_beep(FL_BEEP_MESSAGE);
 
   va_start(ap, fmt);
-  iconlabel = "i";
-  innards(fmt, ap, 0, fl_ok, 0);
+  msg.innards(fmt, ap, 0, fl_ok, 0);
   va_end(ap);
-  iconlabel = "?";
 }
 
+
 void fl_alert(const char *fmt, ...) {
+  Fl_Message msg("!");
   va_list ap;
 
   fl_beep(FL_BEEP_ERROR);
 
   va_start(ap, fmt);
-  iconlabel = "!";
-  innards(fmt, ap, 0, fl_ok, 0);
+  msg.innards(fmt, ap, 0, fl_ok, 0);
   va_end(ap);
-  iconlabel = "?";
 }
 
+
 int fl_ask(const char *fmt, ...) {
+  Fl_Message msg("?");
   va_list ap;
 
   fl_beep(FL_BEEP_QUESTION);
 
   va_start(ap, fmt);
-  int r = innards(fmt, ap, fl_no, fl_yes, 0);
+  int r = msg.innards(fmt, ap, fl_no, fl_yes, 0);
   va_end(ap);
 
   return r;
 }
 
+
 int fl_choice(const char*fmt,const char *b0,const char *b1,const char *b2,...){
+  Fl_Message msg("?");
   va_list ap;
 
   fl_beep(FL_BEEP_QUESTION);
 
   va_start(ap, b2);
-  int r = innards(fmt, ap, b0, b1, b2);
+  int r = msg.innards(fmt, ap, b0, b1, b2);
   va_end(ap);
+
   return r;
 }
 
-Fl_Widget *fl_message_icon() {makeform(); return icon;}
 
-static const char* input_innards(const char* fmt, va_list ap,
-				 const char* defstr, uchar type) {
-  makeform();
-  message->position(60,10);
-  input->type(type);
-  input->show();
-  input->value(defstr);
-
-  int r = innards(fmt, ap, fl_cancel, fl_ok, 0);
-  input->hide();
-  message->position(60,25);
-  return r ? input->value() : 0;
+Fl_Widget *fl_message_icon() {
+  if (icon_default == NULL) {
+    Fl_Group *group_current = Fl_Group::current();
+    Fl_Group::current(0);
+    Fl_Box* o = icon_default = new Fl_Box(10, 10, 50, 50);
+    o->box(FL_THIN_UP_BOX);
+    o->labelfont(FL_TIMES_BOLD);
+    o->labelsize(34);
+    o->color(FL_WHITE);
+    o->labelcolor(FL_BLUE);
+    Fl_Group::current(group_current);
+  }
+  return icon_default;
 }
 
+
 const char* fl_input(const char *fmt, const char *defstr, ...) {
+  Fl_Message msg("?");
   fl_beep(FL_BEEP_QUESTION);
 
   va_list ap;
   va_start(ap, defstr);
-  const char* r = input_innards(fmt, ap, defstr, FL_NORMAL_INPUT);
+  const char* r = msg.input_innards(fmt, ap, defstr, FL_NORMAL_INPUT);
   va_end(ap);
   return r;
 }
 
+
 const char *fl_password(const char *fmt, const char *defstr, ...) {
+  Fl_Message msg("?");
   fl_beep(FL_BEEP_PASSWORD);
 
   va_list ap;
   va_start(ap, defstr);
-  const char* r = input_innards(fmt, ap, defstr, FL_SECRET_INPUT);
+  const char* r = msg.input_innards(fmt, ap, defstr, FL_SECRET_INPUT);
   va_end(ap);
   return r;
 }
+
 
 //
 // End of "$Id: fl_ask.cxx,v 1.8.2.8.2.12 2003/01/30 21:43:26 easysw Exp $".
