From 4210fdd38a511f1ea2529eea2dfd5d55ab144e37 Mon Sep 17 00:00:00 2001
From: Lukas Fleischer <calcurse@cryptocrack.de>
Date: Thu, 15 May 2014 10:29:22 +0200
Subject: Add support for drawing highlighted decoration

This allows for drawing selected scroll windows and list boxes with a
highlighted border.

Signed-off-by: Lukas Fleischer <calcurse@cryptocrack.de>
---
 src/calcurse.h |  4 ++--
 src/custom.c   |  6 +++---
 src/listbox.c  |  4 ++--
 src/notify.c   |  4 ++--
 src/wins.c     | 11 +++++++++--
 5 files changed, 18 insertions(+), 11 deletions(-)

(limited to 'src')

diff --git a/src/calcurse.h b/src/calcurse.h
index 59af8f9..aedd2f3 100644
--- a/src/calcurse.h
+++ b/src/calcurse.h
@@ -822,7 +822,7 @@ void listbox_delete(struct listbox *);
 void listbox_resize(struct listbox *, int, int, int, int);
 void listbox_set_cb_data(struct listbox *, void *);
 void listbox_load_items(struct listbox *, int);
-void listbox_draw_deco(struct listbox *);
+void listbox_draw_deco(struct listbox *, int);
 void listbox_display(struct listbox *);
 int listbox_get_sel(struct listbox *);
 void listbox_set_sel(struct listbox *, unsigned);
@@ -1081,7 +1081,7 @@ void wins_scrollwin_init(struct scrollwin *, int, int, int, int, const char *);
 void wins_scrollwin_resize(struct scrollwin *, int, int, int, int);
 void wins_scrollwin_set_linecount(struct scrollwin *, unsigned);
 void wins_scrollwin_delete(struct scrollwin *);
-void wins_scrollwin_draw_deco(struct scrollwin *);
+void wins_scrollwin_draw_deco(struct scrollwin *, int);
 void wins_scrollwin_display(struct scrollwin *);
 void wins_scrollwin_up(struct scrollwin *, int);
 void wins_scrollwin_down(struct scrollwin *, int);
diff --git a/src/custom.c b/src/custom.c
index 0c7f4b0..bb425a6 100644
--- a/src/custom.c
+++ b/src/custom.c
@@ -774,7 +774,7 @@ void custom_general_config(void)
 		     _("general options"), general_option_height,
 		     print_general_option);
 	listbox_load_items(&lb, 10);
-	listbox_draw_deco(&lb);
+	listbox_draw_deco(&lb, 0);
 	status_mesg("", "");
 	listbox_display(&lb);
 
@@ -795,7 +795,7 @@ void custom_general_config(void)
 			resize = 0;
 			wins_reset_noupdate();
 			listbox_resize(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col);
-			listbox_draw_deco(&lb);
+			listbox_draw_deco(&lb, 0);
 			delwin(win[STA].p);
 			win[STA].p = newwin(win[STA].h, win[STA].w, win[STA].y, win[STA].x);
 			keypad(win[STA].p, TRUE);
@@ -910,7 +910,7 @@ void custom_keys_config(void)
 	nbdisplayed = ((notify_bar() ? row - 3 : row - 2) - LABELLINES) / LINESPERKEY;
 	wins_scrollwin_init(&kwin, 0, 0, notify_bar() ? row - 3 : row - 2, col, _("keys configuration"));
 	wins_scrollwin_set_linecount(&kwin, NBKEYS * LINESPERKEY);
-	wins_scrollwin_draw_deco(&kwin);
+	wins_scrollwin_draw_deco(&kwin, 0);
 	custom_keys_config_bar();
 	selrow = selelm = 0;
 	nbrowelm = print_keys_bindings(kwin.inner, selrow, selelm, LINESPERKEY);
diff --git a/src/listbox.c b/src/listbox.c
index 3a31017..80b5dae 100644
--- a/src/listbox.c
+++ b/src/listbox.c
@@ -89,9 +89,9 @@ void listbox_load_items(struct listbox *lb, int item_count)
 	wins_scrollwin_set_linecount(&(lb->sw), ch);
 }
 
-void listbox_draw_deco(struct listbox *lb)
+void listbox_draw_deco(struct listbox *lb, int hilt)
 {
-	wins_scrollwin_draw_deco(&(lb->sw));
+	wins_scrollwin_draw_deco(&(lb->sw), hilt);
 }
 
 void listbox_display(struct listbox *lb)
diff --git a/src/notify.c b/src/notify.c
index c833cd9..1adaded 100644
--- a/src/notify.c
+++ b/src/notify.c
@@ -763,7 +763,7 @@ void notify_config_bar(void)
 	clear();
 	listbox_init(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col, _("notification options"), config_option_height, print_config_option);
 	listbox_load_items(&lb, 8);
-	listbox_draw_deco(&lb);
+	listbox_draw_deco(&lb, 0);
 	status_mesg("", "");
 	listbox_display(&lb);
 
@@ -785,7 +785,7 @@ void notify_config_bar(void)
 			wins_get_config();
 			wins_reset_noupdate();
 			listbox_resize(&lb, 0, 0, notify_bar() ? row - 3 : row - 2, col);
-			listbox_draw_deco(&lb);
+			listbox_draw_deco(&lb, 0);
 			delwin(win[STA].p);
 			win[STA].p =
 			    newwin(win[STA].h, win[STA].w, win[STA].y,
diff --git a/src/wins.c b/src/wins.c
index 2d521c1..09302ee 100644
--- a/src/wins.c
+++ b/src/wins.c
@@ -325,17 +325,24 @@ void wins_scrollwin_delete(struct scrollwin *sw)
 }
 
 /* Draw window border and label. */
-void wins_scrollwin_draw_deco(struct scrollwin *sw)
+void wins_scrollwin_draw_deco(struct scrollwin *sw, int hilt)
 {
+	if (hilt)
+		wattron(sw->win, A_BOLD | COLOR_PAIR(COLR_CUSTOM));
+
 	box(sw->win, 0, 0);
 
 	if (!conf.compact_panels) {
 		mvwaddch(sw->win, 2, 0, ACS_LTEE);
 		mvwhline(sw->win, 2, 1, ACS_HLINE, sw->w - 2);
 		mvwaddch(sw->win, 2, sw->w - 1, ACS_RTEE);
+	}
 
+	if (hilt)
+		wattroff(sw->win, A_BOLD | COLOR_PAIR(COLR_CUSTOM));
+
+	if (!conf.compact_panels)
 		print_in_middle(sw->win, 1, 0, sw->w, sw->label);
-	}
 }
 
 /* Display a scrolling window. */
-- 
cgit v1.2.3-70-g09d2