197049Speter/****************************************************************************
297049Speter * Copyright (c) 2002 Free Software Foundation, Inc.                        *
397049Speter *                                                                          *
497049Speter * Permission is hereby granted, free of charge, to any person obtaining a  *
597049Speter * copy of this software and associated documentation files (the            *
697049Speter * "Software"), to deal in the Software without restriction, including      *
797049Speter * without limitation the rights to use, copy, modify, merge, publish,      *
897049Speter * distribute, distribute with modifications, sublicense, and/or sell       *
997049Speter * copies of the Software, and to permit persons to whom the Software is    *
1097049Speter * furnished to do so, subject to the following conditions:                 *
1197049Speter *                                                                          *
1297049Speter * The above copyright notice and this permission notice shall be included  *
1397049Speter * in all copies or substantial portions of the Software.                   *
1497049Speter *                                                                          *
1597049Speter * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
1697049Speter * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
1797049Speter * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
1897049Speter * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
1997049Speter * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
2097049Speter * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
2197049Speter * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
2297049Speter *                                                                          *
2397049Speter * Except as contained in this notice, the name(s) of the above copyright   *
2497049Speter * holders shall not be used in advertising or otherwise to promote the     *
2597049Speter * sale, use or other dealings in this Software without prior written       *
2697049Speter * authorization.                                                           *
2797049Speter ****************************************************************************/
2897049Speter
2997049Speter/****************************************************************************
3097049Speter * Authors: Sven Verdoolaege and Thomas Dickey 2001,2002                    *
3197049Speter ****************************************************************************/
3297049Speter
3397049Speter/*
3497049Speter**	lib_box_set.c
3597049Speter**
3697049Speter**	The routine wborder_set().
3797049Speter**
3897049Speter*/
3997049Speter
4097049Speter#include <curses.priv.h>
4197049Speter
42166124SrafanMODULE_ID("$Id: lib_box_set.c,v 1.4 2003/12/06 18:02:13 tom Exp $")
4397049Speter
4497049SpeterNCURSES_EXPORT(int)
4597049Speterwborder_set(WINDOW *win,
4697049Speter	    const ARG_CH_T ls, const ARG_CH_T rs,
4797049Speter	    const ARG_CH_T ts, const ARG_CH_T bs,
4897049Speter	    const ARG_CH_T tl, const ARG_CH_T tr,
4997049Speter	    const ARG_CH_T bl, const ARG_CH_T br)
5097049Speter{
5197049Speter    NCURSES_SIZE_T i;
5297049Speter    NCURSES_SIZE_T endx, endy;
5397049Speter    NCURSES_CH_T wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
5497049Speter
5597049Speter    T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
5697049Speter       win,
5797049Speter       _tracech_t2(1, ls),
5897049Speter       _tracech_t2(2, rs),
5997049Speter       _tracech_t2(3, ts),
6097049Speter       _tracech_t2(4, bs),
6197049Speter       _tracech_t2(5, tl),
6297049Speter       _tracech_t2(6, tr),
6397049Speter       _tracech_t2(7, bl),
6497049Speter       _tracech_t2(8, br)));
6597049Speter
6697049Speter    if (!win)
6797049Speter	returnCode(ERR);
6897049Speter
69166124Srafan#define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == 0) ? *(const ARG_CH_T)def : *ch)
7097049Speter
7197049Speter    RENDER_WITH_DEFAULT(ls, WACS_VLINE);
7297049Speter    RENDER_WITH_DEFAULT(rs, WACS_VLINE);
7397049Speter    RENDER_WITH_DEFAULT(ts, WACS_HLINE);
7497049Speter    RENDER_WITH_DEFAULT(bs, WACS_HLINE);
7597049Speter    RENDER_WITH_DEFAULT(tl, WACS_ULCORNER);
7697049Speter    RENDER_WITH_DEFAULT(tr, WACS_URCORNER);
7797049Speter    RENDER_WITH_DEFAULT(bl, WACS_LLCORNER);
7897049Speter    RENDER_WITH_DEFAULT(br, WACS_LRCORNER);
7997049Speter
8097049Speter    T(("using %s, %s, %s, %s, %s, %s, %s, %s",
8197049Speter       _tracech_t2(1, CHREF(wls)),
8297049Speter       _tracech_t2(2, CHREF(wrs)),
8397049Speter       _tracech_t2(3, CHREF(wts)),
8497049Speter       _tracech_t2(4, CHREF(wbs)),
8597049Speter       _tracech_t2(5, CHREF(wtl)),
8697049Speter       _tracech_t2(6, CHREF(wtr)),
8797049Speter       _tracech_t2(7, CHREF(wbl)),
8897049Speter       _tracech_t2(8, CHREF(wbr))));
8997049Speter
9097049Speter    endx = win->_maxx;
9197049Speter    endy = win->_maxy;
9297049Speter
9397049Speter    for (i = 0; i <= endx; i++) {
9497049Speter	win->_line[0].text[i] = wts;
9597049Speter	win->_line[endy].text[i] = wbs;
9697049Speter    }
9797049Speter    win->_line[endy].firstchar = win->_line[0].firstchar = 0;
9897049Speter    win->_line[endy].lastchar = win->_line[0].lastchar = endx;
9997049Speter
10097049Speter    for (i = 0; i <= endy; i++) {
10197049Speter	win->_line[i].text[0] = wls;
10297049Speter	win->_line[i].text[endx] = wrs;
10397049Speter	win->_line[i].firstchar = 0;
10497049Speter	win->_line[i].lastchar = endx;
10597049Speter    }
10697049Speter    win->_line[0].text[0] = wtl;
10797049Speter    win->_line[0].text[endx] = wtr;
10897049Speter    win->_line[endy].text[0] = wbl;
10997049Speter    win->_line[endy].text[endx] = wbr;
11097049Speter
11197049Speter    _nc_synchook(win);
11297049Speter    returnCode(OK);
11397049Speter}
114