Back to index

tetex-bin  3.0
lib_box_set.c
Go to the documentation of this file.
00001 /****************************************************************************
00002  * Copyright (c) 2002 Free Software Foundation, Inc.                        *
00003  *                                                                          *
00004  * Permission is hereby granted, free of charge, to any person obtaining a  *
00005  * copy of this software and associated documentation files (the            *
00006  * "Software"), to deal in the Software without restriction, including      *
00007  * without limitation the rights to use, copy, modify, merge, publish,      *
00008  * distribute, distribute with modifications, sublicense, and/or sell       *
00009  * copies of the Software, and to permit persons to whom the Software is    *
00010  * furnished to do so, subject to the following conditions:                 *
00011  *                                                                          *
00012  * The above copyright notice and this permission notice shall be included  *
00013  * in all copies or substantial portions of the Software.                   *
00014  *                                                                          *
00015  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS  *
00016  * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF               *
00017  * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.   *
00018  * IN NO EVENT SHALL THE ABOVE COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,   *
00019  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR    *
00020  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR    *
00021  * THE USE OR OTHER DEALINGS IN THE SOFTWARE.                               *
00022  *                                                                          *
00023  * Except as contained in this notice, the name(s) of the above copyright   *
00024  * holders shall not be used in advertising or otherwise to promote the     *
00025  * sale, use or other dealings in this Software without prior written       *
00026  * authorization.                                                           *
00027  ****************************************************************************/
00028 
00029 /****************************************************************************
00030  * Authors: Sven Verdoolaege and Thomas Dickey 2001,2002                    *
00031  ****************************************************************************/
00032 
00033 /*
00034 **     lib_box_set.c
00035 **
00036 **     The routine wborder_set().
00037 **
00038 */
00039 
00040 #include <curses.priv.h>
00041 
00042 MODULE_ID("$Id: lib_box_set.c,v 1.4 2003/12/06 18:02:13 tom Exp $")
00043 
00044 NCURSES_EXPORT(int)
00045 wborder_set(WINDOW *win,
00046            const ARG_CH_T ls, const ARG_CH_T rs,
00047            const ARG_CH_T ts, const ARG_CH_T bs,
00048            const ARG_CH_T tl, const ARG_CH_T tr,
00049            const ARG_CH_T bl, const ARG_CH_T br)
00050 {
00051     NCURSES_SIZE_T i;
00052     NCURSES_SIZE_T endx, endy;
00053     NCURSES_CH_T wls, wrs, wts, wbs, wtl, wtr, wbl, wbr;
00054 
00055     T((T_CALLED("wborder(%p,%s,%s,%s,%s,%s,%s,%s,%s)"),
00056        win,
00057        _tracech_t2(1, ls),
00058        _tracech_t2(2, rs),
00059        _tracech_t2(3, ts),
00060        _tracech_t2(4, bs),
00061        _tracech_t2(5, tl),
00062        _tracech_t2(6, tr),
00063        _tracech_t2(7, bl),
00064        _tracech_t2(8, br)));
00065 
00066     if (!win)
00067        returnCode(ERR);
00068 
00069 #define RENDER_WITH_DEFAULT(ch,def) w ##ch = _nc_render(win, (ch == 0) ? *(const ARG_CH_T)def : *ch)
00070 
00071     RENDER_WITH_DEFAULT(ls, WACS_VLINE);
00072     RENDER_WITH_DEFAULT(rs, WACS_VLINE);
00073     RENDER_WITH_DEFAULT(ts, WACS_HLINE);
00074     RENDER_WITH_DEFAULT(bs, WACS_HLINE);
00075     RENDER_WITH_DEFAULT(tl, WACS_ULCORNER);
00076     RENDER_WITH_DEFAULT(tr, WACS_URCORNER);
00077     RENDER_WITH_DEFAULT(bl, WACS_LLCORNER);
00078     RENDER_WITH_DEFAULT(br, WACS_LRCORNER);
00079 
00080     T(("using %s, %s, %s, %s, %s, %s, %s, %s",
00081        _tracech_t2(1, CHREF(wls)),
00082        _tracech_t2(2, CHREF(wrs)),
00083        _tracech_t2(3, CHREF(wts)),
00084        _tracech_t2(4, CHREF(wbs)),
00085        _tracech_t2(5, CHREF(wtl)),
00086        _tracech_t2(6, CHREF(wtr)),
00087        _tracech_t2(7, CHREF(wbl)),
00088        _tracech_t2(8, CHREF(wbr))));
00089 
00090     endx = win->_maxx;
00091     endy = win->_maxy;
00092 
00093     for (i = 0; i <= endx; i++) {
00094        win->_line[0].text[i] = wts;
00095        win->_line[endy].text[i] = wbs;
00096     }
00097     win->_line[endy].firstchar = win->_line[0].firstchar = 0;
00098     win->_line[endy].lastchar = win->_line[0].lastchar = endx;
00099 
00100     for (i = 0; i <= endy; i++) {
00101        win->_line[i].text[0] = wls;
00102        win->_line[i].text[endx] = wrs;
00103        win->_line[i].firstchar = 0;
00104        win->_line[i].lastchar = endx;
00105     }
00106     win->_line[0].text[0] = wtl;
00107     win->_line[0].text[endx] = wtr;
00108     win->_line[endy].text[0] = wbl;
00109     win->_line[endy].text[endx] = wbr;
00110 
00111     _nc_synchook(win);
00112     returnCode(OK);
00113 }