diff options
Diffstat (limited to 'src/curses-ui/dialog.vala')
-rw-r--r-- | src/curses-ui/dialog.vala | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/src/curses-ui/dialog.vala b/src/curses-ui/dialog.vala new file mode 100644 index 0000000..a8585d4 --- /dev/null +++ b/src/curses-ui/dialog.vala @@ -0,0 +1,51 @@ +/* Copyright 2013, Sebastian Reichel <sre@ring0.de> + * + * Permission to use, copy, modify, and/or distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +using Curses; + +public class Dialog { + Window win; + Window subwin; + + public Dialog(string message, string title = "KtT Shopsystem Error", int h=16, int w=60) + requires (title.length <= w-4) + { + int y = LINES/2-h/2; + int x = COLS/2-w/2; + + int title_x = (w-title.length)/2; + + win = new Window(h, w, y, x); + + /* make the dialog white on red */ + win.bkgdset(COLOR_PAIR(2) | Attribute.BOLD); + win.clrtobot(); + + /* message subwindow */ + subwin = win.derwin(h-4, w-4, 2, 2); + subwin.clrtobot(); + subwin.printw(message); + subwin.refresh(); + + /* dialog title */ + win.box(0,0); + win.mvaddstr(0, title_x, title); + win.mvaddch(0, title_x-2, Acs.RTEE); + win.mvaddch(0, title_x-1, ' '); + win.mvaddch(0, title_x+title.length, ' '); + win.mvaddch(0, title_x+title.length+1, Acs.LTEE); + win.refresh(); + } +} |