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.
This commit is contained in:
parent
f386bd2cb7
commit
ee7577a897
@ -24,7 +24,6 @@
|
||||
# define fl_ask_H
|
||||
|
||||
# include "Enumerations.H"
|
||||
|
||||
class Fl_Widget;
|
||||
|
||||
/** Different system beeps available.
|
||||
@ -66,6 +65,9 @@ inline void fl_message_font(Fl_Font f, Fl_Fontsize s) {
|
||||
FL_EXPORT void fl_message_hotspot(int enable);
|
||||
FL_EXPORT int fl_message_hotspot(void);
|
||||
|
||||
FL_EXPORT void fl_message_position(const int x = 0, const int y = 0);
|
||||
FL_EXPORT void fl_message_position(int* x = 0, int* y = 0);
|
||||
|
||||
FL_EXPORT void fl_message_title(const char *title);
|
||||
FL_EXPORT void fl_message_title_default(const char *title);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user