5 /*man-start**************************************************************
13 void bkgdset(chtype ch);
14 chtype getbkgd(WINDOW *win);
15 int wbkgd(WINDOW *win, chtype ch);
16 void wbkgdset(WINDOW *win, chtype ch);
18 int bkgrnd(const cchar_t *wch);
19 void bkgrndset(const cchar_t *wch);
20 int getbkgrnd(cchar_t *wch);
21 int wbkgrnd(WINDOW *win, const cchar_t *wch);
22 void wbkgrndset(WINDOW *win, const cchar_t *wch);
23 int wgetbkgrnd(WINDOW *win, cchar_t *wch);
27 bkgdset() and wbkgdset() manipulate the background of a window. The
28 background is a chtype consisting of any combination of attributes
29 and a character; it is combined with each chtype added or inserted to
30 the window by waddch() or winsch(). Only the attribute part is used
31 to set the background of non-blank characters, while both character
32 and attributes are used for blank positions.
34 bkgd() and wbkgd() not only change the background, but apply it
35 immediately to every cell in the window.
37 wbkgrnd(), wbkgrndset() and wgetbkgrnd() are the "wide-character"
38 versions of these functions, taking a pointer to a cchar_t instead of
39 a chtype. However, in PDCurses, cchar_t and chtype are the same.
41 The attributes that are defined with the attrset()/attron() set of
42 functions take precedence over the background attributes if there is
43 a conflict (e.g., different color pairs).
47 bkgd() and wbkgd() return OK, unless the window is NULL, in which
64 **man-end****************************************************************/
66 int wbkgd(WINDOW
*win
, chtype ch
)
69 chtype oldcolr
, oldch
, newcolr
, newch
, colr
, attr
;
70 chtype oldattr
= 0, newattr
= 0;
73 PDC_LOG(("wbkgd() - called\n"));
81 oldcolr
= win
->_bkgd
& A_COLOR
;
83 oldattr
= (win
->_bkgd
& A_ATTRIBUTES
) ^ oldcolr
;
85 oldch
= win
->_bkgd
& A_CHARTEXT
;
89 newcolr
= win
->_bkgd
& A_COLOR
;
91 newattr
= (win
->_bkgd
& A_ATTRIBUTES
) ^ newcolr
;
93 newch
= win
->_bkgd
& A_CHARTEXT
;
95 /* what follows is what seems to occur in the System V
96 implementation of this routine */
98 for (y
= 0; y
< win
->_maxy
; y
++)
100 for (x
= 0; x
< win
->_maxx
; x
++)
102 winptr
= win
->_y
[y
] + x
;
106 /* determine the colors and attributes of the character read
110 attr
= ch
& (A_ATTRIBUTES
^ A_COLOR
);
112 /* if the color is the same as the old background color,
113 then make it the new background color, otherwise leave it */
118 /* remove any attributes (non color) from the character that
119 were part of the old background, then combine the
120 remaining ones with the new background */
125 /* change character if it is there because it was the old
126 background character */
146 PDC_LOG(("bkgd() - called\n"));
148 return wbkgd(stdscr
, ch
);
151 void wbkgdset(WINDOW
*win
, chtype ch
)
153 PDC_LOG(("wbkgdset() - called\n"));
157 if (!(ch
& A_CHARTEXT
))
164 void bkgdset(chtype ch
)
166 PDC_LOG(("bkgdset() - called\n"));
168 wbkgdset(stdscr
, ch
);
171 chtype
getbkgd(WINDOW
*win
)
173 PDC_LOG(("getbkgd() - called\n"));
175 return win
? win
->_bkgd
: (chtype
)ERR
;
179 int wbkgrnd(WINDOW
*win
, const cchar_t
*wch
)
181 PDC_LOG(("wbkgrnd() - called\n"));
183 return wch
? wbkgd(win
, *wch
) : ERR
;
186 int bkgrnd(const cchar_t
*wch
)
188 PDC_LOG(("bkgrnd() - called\n"));
190 return wbkgrnd(stdscr
, wch
);
193 void wbkgrndset(WINDOW
*win
, const cchar_t
*wch
)
195 PDC_LOG(("wbkgdset() - called\n"));
201 void bkgrndset(const cchar_t
*wch
)
203 PDC_LOG(("bkgrndset() - called\n"));
205 wbkgrndset(stdscr
, wch
);
208 int wgetbkgrnd(WINDOW
*win
, cchar_t
*wch
)
210 PDC_LOG(("wgetbkgrnd() - called\n"));
220 int getbkgrnd(cchar_t
*wch
)
222 PDC_LOG(("getbkgrnd() - called\n"));
224 return wgetbkgrnd(stdscr
, wch
);