Author: AlbrechtS
Date: 2010-03-26 12:18:02 -0700 (Fri, 26 Mar 2010)
New Revision: 7343
Log:
Replaced Fl::readqueue() in fl_ask.cxx by real callbacks.


Modified:
   branches/branch-1.3/src/fl_ask.cxx

Modified: branches/branch-1.3/src/fl_ask.cxx
===================================================================
--- branches/branch-1.3/src/fl_ask.cxx  2010-03-26 18:10:39 UTC (rev 7342)
+++ branches/branch-1.3/src/fl_ask.cxx  2010-03-26 19:18:02 UTC (rev 7343)
@@ -58,12 +58,19 @@
 static Fl_Box *icon;
 static Fl_Button *button[3];
 static Fl_Input *input;
+static int ret_val;
 static const char *iconlabel = "?";
 Fl_Font fl_message_font_ = FL_HELVETICA;
 Fl_Fontsize fl_message_size_ = 14;
 
 static char avoidRecursion = 0;
 
+// sets the global return value (ret_val) and closes the window
+static void button_cb(Fl_Widget *bt, void *val) {
+  ret_val = (int)val;
+  message_form->hide();
+}
+
 static Fl_Window *makeform() {
  if (message_form) {
    message_form->size(410,103);
@@ -87,13 +94,13 @@
   o->color(FL_WHITE);
   o->labelcolor(FL_BLUE);
  }
- button[0] = new Fl_Button(310, 70, 90, 23);
+ // create the buttons (right to left)
+ for (int b=0, x=310; b<3; b++, x -= 100) {
+   button[b] = new Fl_Button(x, 70, 90, 23);
+   button[b]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
+   button[b]->callback(button_cb,(void *)b);
+ }
  button[0]->shortcut(FL_Escape);
- button[0]->align(FL_ALIGN_INSIDE|FL_ALIGN_WRAP);
- button[1] = new Fl_Return_Button(210, 70, 90, 23);
- 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();
@@ -218,31 +225,22 @@
   else
     button[0]->shortcut(FL_Escape);
 
-  message_form->show();
-  // deactivate Fl::grab(), because it is incompatible with Fl::readqueue()
+  // deactivate Fl::grab(), because it is incompatible with modal windows
   Fl_Window* g = Fl::grab();
   if (g) Fl::grab(0);
-  int r = 0;
-  for (;;) {
-    Fl_Widget *o = Fl::readqueue();
-    if (!o) Fl::wait();
-    else if (o == button[0]) {r = 0; break;}
-    else if (o == button[1]) {r = 1; break;}
-    else if (o == button[2]) {r = 2; break;}
-    else if (o == message_form) {r = 0; break;}
-  }
+  message_form->show();
+  while (message_form->shown()) Fl::wait();
   if (g) // regrab the previous popup menu, if there was one
     Fl::grab(g);
-  message_form->hide();
   icon->label(prev_icon_label);
 
   avoidRecursion = 0;
-  return r;
+  return ret_val;
 }
 
  /** \addtogroup group_comdlg
     @{ */
- 
+
 // pointers you can use to change FLTK to a foreign language:
 const char* fl_no = "No";        ///< string pointer used in common dialogs, 
you can change it to a foreign language
 const char* fl_yes= "Yes";       ///< string pointer used in common dialogs, 
you can change it to a foreign language

_______________________________________________
fltk-commit mailing list
[email protected]
http://lists.easysw.com/mailman/listinfo/fltk-commit

Reply via email to