summaryrefslogtreecommitdiff
path: root/src/fl_ask.cxx
diff options
context:
space:
mode:
authorairbrett <mixmasterbrett@gmail.com>2019-06-06 14:01:28 -0600
committerAlbrecht Schlosser <albrechts.fltk@online.de>2020-05-07 14:59:19 +0200
commitee7577a89708370e424d90221cecf05c4b2ec121 (patch)
tree25aedbe0c9b2e0d7554a3a55ea049cb35dce4b5b /src/fl_ask.cxx
parentf386bd2cb78fc9a5bffdf0451870720aafacca37 (diff)
Add (x,y) positioning mode to common dialogs
Add new function to set (x,y) position. Reset to previous mode after innards is called by fl_* function. Use magic number for preferred position state. Note: several commits squashed and commit messages edited by AlbrechtS.
Diffstat (limited to 'src/fl_ask.cxx')
-rw-r--r--src/fl_ask.cxx46
1 files changed, 45 insertions, 1 deletions
diff --git a/src/fl_ask.cxx b/src/fl_ask.cxx
index 4825ef739..59f9caa7a 100644
--- a/src/fl_ask.cxx
+++ b/src/fl_ask.cxx
@@ -28,6 +28,7 @@
#include <stdio.h>
#include <stdarg.h>
+#include <limits.h>
#include "flstring.h"
#include <FL/Fl.H>
@@ -55,6 +56,8 @@ static const char *message_title_default;
Fl_Font fl_message_font_ = FL_HELVETICA;
Fl_Fontsize fl_message_size_ = -1;
static int enableHotspot = 1;
+static int form_x = INT_MIN;
+static int form_y = INT_MIN;
static char avoidRecursion = 0;
@@ -236,8 +239,18 @@ static int innards(const char* fmt, va_list ap,
if (button[1]->visible() && !input->visible())
button[1]->take_focus();
- if (enableHotspot)
+
+ if (form_x != INT_MIN && form_y != INT_MIN)
+ {
+ message_form->position(form_x, form_y);
+ form_x = INT_MIN;
+ form_y = INT_MIN;
+ }
+ else if (enableHotspot)
message_form->hotspot(button[0]);
+ else
+ message_form->free_position();
+
if (b0 && Fl_Widget::label_shortcut(b0))
button[0]->shortcut(0);
else
@@ -506,6 +519,37 @@ const char *fl_password(const char *fmt, const char *defstr, ...) {
return r;
}
+/** Sets the preferred position for common message box used in
+ many common dialogs like fl_message(), fl_alert(),
+ fl_ask(), fl_choice(), fl_input(), fl_password(). Resets after
+ every call to any of the common dialogs.
+
+ \note \#include <FL/fl_ask.H>
+ param[in] x Preferred X position
+ param[in] y Preferred Y position
+*/
+void fl_message_position(const int x, const int y) {
+ form_x = x;
+ form_y = y;
+}
+
+/** Gets the preferred position for common message box used in
+ many common dialogs like fl_message(), fl_alert(),
+ fl_ask(), fl_choice(), fl_input(), fl_password().
+
+ \note \#include <FL/fl_ask.H>
+ param[out] x Preferred X position, returns INT_MIN if not set
+ param[out] y Preferred Y position, returns INT_MIN if not set
+\see fl_message_position(int,int)
+*/
+void fl_message_position(int* x, int* y) {
+ if (x)
+ *x = form_x;
+
+ if (y)
+ *y = form_y;
+}
+
/** Sets whether or not to move the common message box used in
many common dialogs like fl_message(), fl_alert(),
fl_ask(), fl_choice(), fl_input(), fl_password() to follow