summaryrefslogtreecommitdiffstats
path: root/contrib/dialog/timebox.c
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/dialog/timebox.c')
-rw-r--r--contrib/dialog/timebox.c34
1 files changed, 16 insertions, 18 deletions
diff --git a/contrib/dialog/timebox.c b/contrib/dialog/timebox.c
index 5a6be3e..38abeec 100644
--- a/contrib/dialog/timebox.c
+++ b/contrib/dialog/timebox.c
@@ -1,9 +1,9 @@
/*
- * $Id: timebox.c,v 1.45 2011/06/27 08:20:22 tom Exp $
+ * $Id: timebox.c,v 1.54 2013/03/17 15:03:41 tom Exp $
*
* timebox.c -- implements the timebox dialog
*
- * Copyright 2001-2010,2011 Thomas E. Dickey
+ * Copyright 2001-2012,2013 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
@@ -41,8 +41,6 @@ typedef enum {
struct _box;
-typedef int (*BOX_DRAW) (struct _box *, struct tm *);
-
typedef struct _box {
WINDOW *parent;
WINDOW *window;
@@ -82,9 +80,9 @@ draw_cell(BOX * data)
dlg_draw_box(data->parent,
data->y - MARGIN, data->x - MARGIN,
data->height + (2 * MARGIN), data->width + (2 * MARGIN),
- menubox_border_attr, menubox_attr);
+ menubox_border_attr, menubox_border2_attr);
- wattrset(data->window, item_attr);
+ (void) wattrset(data->window, item_attr);
wprintw(data->window, "%02d", data->value);
return 0;
}
@@ -184,7 +182,7 @@ dialog_timebox(const char *title,
WINDOW *dialog;
time_t now_time = time((time_t *) 0);
struct tm current;
- int state = dlg_defaultno_button();
+ int state = dlg_default_button();
const char **buttons = dlg_ok_labels();
char *prompt = dlg_strclone(subtitle);
char buffer[MAX_LEN];
@@ -221,12 +219,12 @@ dialog_timebox(const char *title,
dlg_register_window(dialog, "timebox", binding);
dlg_register_buttons(dialog, "timebox", buttons);
- dlg_draw_box(dialog, 0, 0, height, width, dialog_attr, border_attr);
- dlg_draw_bottom_box(dialog);
+ dlg_draw_box2(dialog, 0, 0, height, width, dialog_attr, border_attr, border2_attr);
+ dlg_draw_bottom_box2(dialog, border_attr, border2_attr, dialog_attr);
dlg_draw_title(dialog, title);
dlg_draw_helpline(dialog, FALSE);
- wattrset(dialog, dialog_attr);
+ (void) wattrset(dialog, dialog_attr);
dlg_print_autowrap(dialog, prompt, height, width);
/* compute positions of hour, month and year boxes */
@@ -275,6 +273,7 @@ dialog_timebox(const char *title,
return CleanupResult(DLG_EXIT_ERROR, dialog, prompt, &save_vars);
}
+ dlg_trace_win(dialog);
while (result == DLG_EXIT_UNKNOWN) {
BOX *obj = (state == sHR ? &hr_box
: (state == sMN ? &mn_box :
@@ -295,12 +294,6 @@ dialog_timebox(const char *title,
/* handle function-keys */
if (fkey) {
switch (key) {
- case DLGK_MOUSE(0):
- result = DLG_EXIT_OK;
- break;
- case DLGK_MOUSE(1):
- result = DLG_EXIT_CANCEL;
- break;
case DLGK_MOUSE('H'):
state = sHR;
break;
@@ -311,7 +304,7 @@ dialog_timebox(const char *title,
state = sSC;
break;
case DLGK_ENTER:
- result = button;
+ result = dlg_ok_buttoncode(button);
break;
case DLGK_FIELD_PREV:
state = dlg_prev_ok_buttonindex(state, sHR);
@@ -361,7 +354,11 @@ dialog_timebox(const char *title,
goto retry;
#endif
default:
- if (obj != 0) {
+ if (is_DLGK_MOUSE(key)) {
+ result = dlg_ok_buttoncode(key - M_EVENT);
+ if (result < 0)
+ result = DLG_EXIT_OK;
+ } else if (obj != 0) {
int step = next_or_previous(key);
if (step != 0) {
obj->value += step;
@@ -415,6 +412,7 @@ dialog_timebox(const char *title,
dlg_add_result(buffer);
dlg_add_separator();
+ dlg_add_last_key(-1);
return CleanupResult(result, dialog, prompt, &save_vars);
}
OpenPOWER on IntegriCloud