aboutsummaryrefslogtreecommitdiff
path: root/timebox.c
diff options
context:
space:
mode:
Diffstat (limited to 'timebox.c')
-rw-r--r--timebox.c41
1 files changed, 20 insertions, 21 deletions
diff --git a/timebox.c b/timebox.c
index 288e76735d24..73b057ada815 100644
--- a/timebox.c
+++ b/timebox.c
@@ -1,9 +1,9 @@
/*
- * $Id: timebox.c,v 1.59 2018/06/19 22:57:01 tom Exp $
+ * $Id: timebox.c,v 1.69 2020/11/23 09:04:00 tom Exp $
*
* timebox.c -- implements the timebox dialog
*
- * Copyright 2001-2016,2018 Thomas E. Dickey
+ * Copyright 2001-2019,2020 Thomas E. Dickey
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License, version 2.1
@@ -21,7 +21,7 @@
* Boston, MA 02110, USA.
*/
-#include <dialog.h>
+#include <dlg_internals.h>
#include <dlg_keys.h>
#include <time.h>
@@ -105,12 +105,11 @@ init_object(BOX * data,
data->period = period;
data->value = value % period;
- data->window = derwin(data->parent,
- data->height, data->width,
- data->y, data->x);
+ data->window = dlg_der_window(data->parent,
+ data->height, data->width,
+ data->y, data->x);
if (data->window == 0)
return -1;
- (void) keypad(data->window, TRUE);
dlg_mouse_setbase(getbegx(parent), getbegy(parent));
dlg_mouse_mkregion(y, x, height, width, code);
@@ -176,11 +175,11 @@ dialog_timebox(const char *title,
int old_width = width;
#endif
BOX hr_box, mn_box, sc_box;
- int key = 0, key2, fkey;
+ int key, fkey;
int button;
int result = DLG_EXIT_UNKNOWN;
WINDOW *dialog;
- time_t now_time = time((time_t *) 0);
+ time_t now_time;
struct tm current;
int state = dlg_default_button();
const char **buttons = dlg_ok_labels();
@@ -210,11 +209,8 @@ dialog_timebox(const char *title,
#endif
prompt = dlg_strclone(subtitle);
- dlg_auto_size(title, prompt, &height, &width, 0, 0);
+ dlg_auto_size(title, prompt, &height, &width, MIN_HIGH, MIN_WIDE);
- height += MIN_HIGH;
- if (width < MIN_WIDE)
- width = MIN_WIDE;
dlg_button_layout(buttons, &width);
dlg_print_size(height, width);
dlg_ctl_size(height, width);
@@ -289,6 +285,7 @@ dialog_timebox(const char *title,
BOX *obj = (state == sHR ? &hr_box
: (state == sMN ? &mn_box :
(state == sSC ? &sc_box : 0)));
+ int key2;
button = (state < 0) ? 0 : state;
dlg_draw_buttons(dialog, height - 2, 0, buttons, button, FALSE, width);
@@ -296,8 +293,10 @@ dialog_timebox(const char *title,
dlg_set_focus(dialog, obj->window);
key = dlg_mouse_wgetch(dialog, &fkey);
- if (dlg_result_key(key, fkey, &result))
- break;
+ if (dlg_result_key(key, fkey, &result)) {
+ if (!dlg_button_key(result, &button, &key, &fkey))
+ break;
+ }
if ((key2 = dlg_char_to_button(key, buttons)) >= 0) {
result = key2;
@@ -316,6 +315,9 @@ dialog_timebox(const char *title,
break;
case DLGK_TOGGLE:
case DLGK_ENTER:
+ result = dlg_enter_buttoncode(button);
+ break;
+ case DLGK_LEAVE:
result = dlg_ok_buttoncode(button);
break;
case DLGK_FIELD_PREV:
@@ -361,9 +363,7 @@ dialog_timebox(const char *title,
second = sc_box.value;
/* repaint */
free(prompt);
- dlg_clear();
- dlg_del_window(dialog);
- dlg_mouse_free_regions();
+ _dlg_resize_cleanup(dialog);
goto retry;
#endif
default:
@@ -394,7 +394,7 @@ dialog_timebox(const char *title,
beep();
}
}
- } else {
+ } else if (key > 0) {
beep();
}
}
@@ -424,8 +424,7 @@ dialog_timebox(const char *title,
DefaultFormat(buffer, hr_box);
dlg_add_result(buffer);
- dlg_add_separator();
- dlg_add_last_key(-1);
+ AddLastKey();
return CleanupResult(result, dialog, prompt, &save_vars);
}