configure.ac: require GLib 2.14
[ncmpc.git] / src / paint.h
blobb3eb3ea9339d115c4df553c0c581d71b6d3dc767
1 /* ncmpc (Ncurses MPD Client)
2 * (c) 2004-2010 The Music Player Daemon Project
3 * Project homepage: http://musicpd.org
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
20 #ifndef NCMPC_PAINT_H
21 #define NCMPC_PAINT_H
23 #include "colors.h"
24 #include "options.h"
26 /**
27 * Sets the specified color, and enables "reverse" mode if selected is
28 * true.
30 static inline void
31 row_color(WINDOW *w, enum color color, bool selected)
33 colors_use(w, color);
35 if (selected)
36 wattron(w, A_REVERSE);
37 else
38 wattroff(w, A_REVERSE);
41 /**
42 * Call this when you are done with painting rows. It resets the
43 * "reverse" mode.
45 static inline void
46 row_color_end(WINDOW *w)
48 wattroff(w, A_REVERSE);
51 /**
52 * Clears the remaining space on the current row. If the row is
53 * selected and the wide_cursor option is enabled, it draws the cursor
54 * on the space.
56 static inline void
57 row_clear_to_eol(WINDOW *w, unsigned width, bool selected)
59 if (selected && options.wide_cursor)
60 whline(w, ' ', width);
61 else
62 wclrtoeol(w);
65 /**
66 * Paint a plain-text row.
68 static inline void
69 row_paint_text(WINDOW *w, unsigned width,
70 enum color color, bool selected,
71 const char *text)
73 row_color(w, color, selected);
75 waddstr(w, text);
77 /* erase the unused space after the text */
78 row_clear_to_eol(w, width, selected);
81 #endif