summaryrefslogtreecommitdiff
path: root/src/dialog.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/dialog.cc')
-rw-r--r--src/dialog.cc81
1 files changed, 78 insertions, 3 deletions
diff --git a/src/dialog.cc b/src/dialog.cc
index 594ec8f1..d6dd2400 100644
--- a/src/dialog.cc
+++ b/src/dialog.cc
@@ -14,11 +14,11 @@
#include <math.h> // for rint()
#include <FL/Fl_Window.H>
-#include <FL/fl_ask.H>
#include <FL/Fl_File_Chooser.H>
#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Text_Display.H>
#include <FL/Fl_Button.H>
+#include <FL/Fl_Return_Button.H>
#include <FL/Fl_Output.H>
#include <FL/Fl_Input.H>
#include <FL/Fl_Secret_Input.H>
@@ -29,6 +29,14 @@
#include "prefs.h"
/*
+ * Local Data
+ */
+static int input_answer;
+static char *input_str = NULL;
+static int choice5_answer;
+
+
+/*
* Display a message in a popup window.
*/
void a_Dialog_msg(const char *msg)
@@ -36,12 +44,80 @@ void a_Dialog_msg(const char *msg)
fl_message("%s", msg);
}
+
+/*
+ * Callback for a_Dialog_input()
+ */
+static void input_cb(Fl_Widget *button, void *number)
+{
+ input_answer = VOIDP2INT(number);
+ button->window()->hide();
+}
+
/*
* Dialog for one line of Input with a message.
+ * avoids the sound bell in fl_input(), and allows customization
+ *
+ * Return value: string on success, NULL upon Cancel or Close window
*/
const char *a_Dialog_input(const char *msg)
{
- return fl_input("%s", "", msg);
+ int ww = 450, wh = 130, gap = 10, ih = 60, bw = 80, bh = 30;
+
+ input_answer = 0;
+
+ Fl_Window *window = new Fl_Window(ww,wh,"Ask");
+ window->set_modal();
+ window->begin();
+ Fl_Group* ib = new Fl_Group(0,0,window->w(),window->h());
+ ib->begin();
+ window->resizable(ib);
+
+ /* '?' Icon */
+ Fl_Box* o = new Fl_Box(gap, gap, ih, ih);
+ o->box(FL_THIN_UP_BOX);
+ o->labelfont(FL_TIMES_BOLD);
+ o->labelsize(34);
+ o->color(FL_WHITE);
+ o->labelcolor(FL_BLUE);
+ o->label("?");
+ o->show();
+
+ Fl_Box *box = new Fl_Box(ih+2*gap,gap,ww-(ih+3*gap),ih/2, msg);
+ box->labelfont(FL_HELVETICA);
+ box->labelsize(14);
+ box->align(FL_ALIGN_LEFT|FL_ALIGN_INSIDE|FL_ALIGN_CLIP|FL_ALIGN_WRAP);
+
+ Fl_Input *input_wid = new Fl_Input(ih+2*gap,gap+ih/2+gap,ww-(ih+3*gap),24);
+ input_wid->labelsize(14);
+ input_wid->textsize(14);
+
+ int xpos = ww-2*(gap+bw), ypos = ih+3*gap;
+ Fl_Return_Button *rb = new Fl_Return_Button(xpos, ypos, bw, bh, "OK");
+ rb->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+ rb->box(FL_UP_BOX);
+ rb->callback(input_cb, INT2VOIDP(1));
+
+ xpos = ww-(gap+bw);
+ Fl_Button *b = new Fl_Button(xpos, ypos, bw, bh, "Cancel");
+ b->align(FL_ALIGN_INSIDE|FL_ALIGN_CLIP);
+ b->box(FL_UP_BOX);
+ b->callback(input_cb, INT2VOIDP(2));
+
+ window->end();
+
+ window->show();
+ while (window->shown())
+ Fl::wait();
+ _MSG("a_Dialog_input answer = %d\n", input_answer);
+ if (input_answer == 1) {
+ /* we have a string, save it */
+ dFree(input_str);
+ input_str = dStrdup(input_wid->value());
+ }
+ delete window;
+
+ return (input_answer == 1) ? input_str : NULL;
}
/*
@@ -135,7 +211,6 @@ void a_Dialog_text_window(const char *txt, const char *title)
}
/*--------------------------------------------------------------------------*/
-static int choice5_answer;
static void choice5_cb(Fl_Widget *button, void *number)
{