1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
|
/*
* msgboxes.c - message and error box display functions
*
* Written by Gerard Paul Java
* Copyright (c) Gerard Paul Java 2001
*/
#include <curses.h>
#include <panel.h>
#include "winops.h"
int ERR_BORDER_ATTR;
int ERR_TEXT_ATTR;
int ERR_PROMPT_ATTR;
int INFO_BORDER_ATTR;
int INFO_TEXT_ATTR;
int INFO_PROMPT_ATTR;
void tx_init_error_attrs(int border, int text, int prompt)
{
ERR_BORDER_ATTR = border;
ERR_TEXT_ATTR = text;
ERR_PROMPT_ATTR = prompt;
}
void tx_init_info_attrs(int border, int text, int prompt)
{
INFO_BORDER_ATTR = border;
INFO_TEXT_ATTR = text;
INFO_PROMPT_ATTR = prompt;
}
void tx_errbox(char *message, char *prompt, int *response)
{
WINDOW *win;
PANEL *panel;
win = newwin(4, 70, (LINES - 4) / 2, (COLS - 70) / 2);
panel = new_panel(win);
wattrset(win, ERR_BORDER_ATTR);
tx_colorwin(win);
tx_box(win, ACS_VLINE, ACS_HLINE);
wmove(win, 2, 2);
wattrset(win, ERR_PROMPT_ATTR);
wprintw(win, "%s", prompt);
wattrset(win, ERR_TEXT_ATTR);
wmove(win, 1, 2);
wprintw(win, "%s", message);
update_panels();
doupdate();
do {
*response = wgetch(win);
if (*response == 12)
tx_refresh_screen();
} while (*response == 12);
del_panel(panel);
delwin(win);
update_panels();
doupdate();
}
void tx_infobox(char *text, char *prompt)
{
WINDOW *win;
PANEL *panel;
int ch;
win = newwin(4, 50, (LINES - 4) / 2, (COLS - 50) / 2);
panel = new_panel(win);
wattrset(win, INFO_BORDER_ATTR);
tx_colorwin(win);
tx_box(win, ACS_VLINE, ACS_HLINE);
wattrset(win, INFO_TEXT_ATTR);
mvwprintw(win, 1, 2, text);
wattrset(win, INFO_PROMPT_ATTR);
mvwprintw(win, 2, 2, prompt);
update_panels();
doupdate();
do {
ch = wgetch(win);
if (ch == 12)
tx_refresh_screen();
} while (ch == 12);
del_panel(panel);
delwin(win);
update_panels();
doupdate();
}
|