From 21e7d9260ebf66a70dc09cd912a0a5aa32abcebd Mon Sep 17 00:00:00 2001 From: Sebastian Reichel Date: Mon, 25 Feb 2013 22:33:35 +0100 Subject: new curses user interface --- src/ui/dialog.vala | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/ui/dialog.vala (limited to 'src/ui/dialog.vala') diff --git a/src/ui/dialog.vala b/src/ui/dialog.vala new file mode 100644 index 0000000..29782e5 --- /dev/null +++ b/src/ui/dialog.vala @@ -0,0 +1,36 @@ +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(); + } +} -- cgit v1.2.3