1 /*
2 * util.c
3 *
4 * Copyright (C) 1999 Stephen F. White
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program (see the file "COPYING" for details); if
18 * not, write to the Free Software Foundation, Inc., 675 Mass Ave,
19 * Cambridge, MA 02139, USA.
20 */
21
22 #include <swt.h>
23
24 static void drawBox(SDC dc, int x, int y);
25 static void drawShadedRect(SDC dc, int x, int y, int width, int height,
26 int topColor, int bottomColor);
27
28 extern void
swDraw3DRect(SDC dc,SWND wnd,int x,int y,int width,int height)29 swDraw3DRect(SDC dc, SWND wnd, int x, int y, int width, int height)
30 {
31 int tColor = swGetWindowColor(wnd, SW_COLOR_BSHADOW);
32 int bColor = swGetWindowColor(wnd, SW_COLOR_TSHADOW);
33
34 drawShadedRect(dc, x, y, width, height, tColor, bColor);
35 }
36
37 extern void
swDraw3DIndent(SDC dc,SWND wnd,int x,int y,int width,int height)38 swDraw3DIndent(SDC dc, SWND wnd, int x, int y, int width, int height)
39 {
40 int tColor = swGetWindowColor(wnd, SW_COLOR_TSHADOW);
41 int bColor = swGetWindowColor(wnd, SW_COLOR_BSHADOW);
42
43 drawShadedRect(dc, x, y, width, height, tColor, bColor);
44 }
45
46 extern void
swDrawPlusBox(SDC dc,int x,int y)47 swDrawPlusBox(SDC dc, int x, int y)
48 {
49 drawBox(dc, x, y);
50 swDrawLine(dc, x + 2, y + 4, x + 6, y + 4);
51 swDrawLine(dc, x + 4, y + 2, x + 4, y + 6);
52 }
53
54 extern void
swDrawMinusBox(SDC dc,int x,int y)55 swDrawMinusBox(SDC dc, int x, int y)
56 {
57 drawBox(dc, x, y);
58 swDrawLine(dc, x + 2, y + 4, x + 6, y + 4);
59 }
60
61 static void
drawBox(SDC dc,int x,int y)62 drawBox(SDC dc, int x, int y)
63 {
64 swSetLineStyle(dc, SW_SOLID);
65 swSetFGColor(dc, 0x00ffffff);
66 swFillRect(dc, x, y, 8, 8);
67 swSetFGColor(dc, 0x00000000);
68 swDrawRect(dc, x, y, 8, 8);
69 }
70
71 static void
drawShadedRect(SDC dc,int x,int y,int width,int height,int topColor,int bottomColor)72 drawShadedRect(SDC dc, int x, int y, int width, int height,
73 int topColor, int bottomColor)
74 {
75 int x2 = x + width - 1;
76 int y2 = y + height - 1;
77
78 swSetFGColor(dc, bottomColor);
79 swDrawLine(dc, x, y2, x, y);
80 swDrawLine(dc, x, y, x2, y);
81 swSetFGColor(dc, topColor);
82 swDrawLine(dc, x2, y, x2, y2);
83 swDrawLine(dc, x2, y2, x, y2);
84 }
85